pax_global_header00006660000000000000000000000064146363543130014522gustar00rootroot0000000000000052 comment=3c9b4203d663061d87d4d34dd0004690aef94db5 microsoft-node-jsonc-parser-3c9b420/000077500000000000000000000000001463635431300174065ustar00rootroot00000000000000microsoft-node-jsonc-parser-3c9b420/.eslintrc.json000066400000000000000000000013151463635431300222020ustar00rootroot00000000000000 { "root": true, "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": 6, "sourceType": "module" }, "plugins": [ "@typescript-eslint" ], "rules": { "@typescript-eslint/naming-convention": [ "warn", { "selector": "typeLike", "format": [ "PascalCase" ] } ], "@typescript-eslint/semi": "warn", "curly": "warn", "eqeqeq": "warn", "no-throw-literal": "warn", "semi": "off", "no-unused-expressions": "warn", "no-duplicate-imports": "warn", "new-parens": "warn" } }microsoft-node-jsonc-parser-3c9b420/.github/000077500000000000000000000000001463635431300207465ustar00rootroot00000000000000microsoft-node-jsonc-parser-3c9b420/.github/assignment.yml000066400000000000000000000000621463635431300236370ustar00rootroot00000000000000{ perform: true, assignees: [ aeschli ] } microsoft-node-jsonc-parser-3c9b420/.github/workflows/000077500000000000000000000000001463635431300230035ustar00rootroot00000000000000microsoft-node-jsonc-parser-3c9b420/.github/workflows/tests.yml000066400000000000000000000007151463635431300246730ustar00rootroot00000000000000on: [push] name: Tests jobs: build: strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v3 - name: Install Node.js uses: actions/setup-node@v3 with: node-version: 18.x - name: Install root project dependencies run: npm install - name: Build and run tests run: npm testmicrosoft-node-jsonc-parser-3c9b420/.gitignore000066400000000000000000000000351463635431300213740ustar00rootroot00000000000000lib/ node_modules/ yarn.lock microsoft-node-jsonc-parser-3c9b420/.mocharc.json000066400000000000000000000000461463635431300217730ustar00rootroot00000000000000{ "ui": "tdd", "color": true }microsoft-node-jsonc-parser-3c9b420/.npmignore000066400000000000000000000002131463635431300214010ustar00rootroot00000000000000.vscode/ build/ .github/ lib/**/test/ lib/**/*.map lib/*/*/*.d.ts src/ test/ .travis.yml .eslintrc .gitignore .mocharc.json .eslintrc.json microsoft-node-jsonc-parser-3c9b420/.vscode/000077500000000000000000000000001463635431300207475ustar00rootroot00000000000000microsoft-node-jsonc-parser-3c9b420/.vscode/launch.json000066400000000000000000000007711463635431300231210ustar00rootroot00000000000000{ "version": "0.2.0", "configurations": [ { "name": "Unit Tests", "type": "node", "request": "launch", "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", "stopOnEntry": false, "args": [ "./lib/umd/test", "--timeout", "999999", "--colors" ], "cwd": "${workspaceRoot}", "runtimeExecutable": null, "runtimeArgs": [], "env": {}, "sourceMaps": true, "outFiles": ["${workspaceRoot}/lib/umd/**/*.js"], "preLaunchTask": "npm: watch" } ] }microsoft-node-jsonc-parser-3c9b420/.vscode/settings.json000066400000000000000000000003661463635431300235070ustar00rootroot00000000000000{ "git.branchProtection": [ "main" ], "git.branchProtectionPrompt": "alwaysCommitToNewBranch", "git.branchRandomName.enable": true, "githubPullRequests.assignCreated": "${user}", "githubPullRequests.defaultMergeMethod": "squash" }microsoft-node-jsonc-parser-3c9b420/.vscode/tasks.json000066400000000000000000000005551463635431300227740ustar00rootroot00000000000000// See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format { "version": "2.0.0", "tasks": [ { "type": "npm", "script": "watch", "problemMatcher": "$tsc-watch", "isBackground": true, "presentation": { "reveal": "never" }, "group": { "kind": "build", "isDefault": true } } ] }microsoft-node-jsonc-parser-3c9b420/CHANGELOG.md000066400000000000000000000055271463635431300212300ustar00rootroot000000000000003.3.0 2022-06-24 ================= - `JSONVisitor.onObjectBegin` and `JSONVisitor.onArrayBegin` can now return `false` to instruct the visitor that no children should be visited. 3.2.0 2022-08-30 ================= - update the version of the bundled Javascript files to `es2020`. - include all `const enum` values in the bundled JavaScript files (`ScanError`, `SyntaxKind`, `ParseErrorCode`). 3.1.0 2022-07-07 ================== * added new API `FormattingOptions.keepLines` : It leaves the initial line positions in the formatting. 3.0.0 2020-11-13 ================== * fixed API spec for `parseTree`. Can return `undefine` for empty input. * added new API `FormattingOptions.insertFinalNewline`. 2.3.0 2020-07-03 ================== * new API `ModificationOptions.isArrayInsertion`: If `JSONPath` refers to an index of an array and `isArrayInsertion` is `true`, then `modify` will insert a new item at that location instead of overwriting its contents. * `ModificationOptions.formattingOptions` is now optional. If not set, newly inserted content will not be formatted. 2.2.0 2019-10-25 ================== * added `ParseOptions.allowEmptyContent`. Default is `false`. * new API `getNodeType`: Returns the type of a value returned by parse. * `parse`: Fix issue with empty property name 2.1.0 2019-03-29 ================== * `JSONScanner` and `JSONVisitor` return lineNumber / character. 2.0.0 2018-04-12 ================== * renamed `Node.columnOffset` to `Node.colonOffset` * new API `getNodePath`: Gets the JSON path of the given JSON DOM node * new API `findNodeAtOffset`: Finds the most inner node at the given offset. If `includeRightBound` is set, also finds nodes that end at the given offset. 1.0.3 2018-03-07 ================== * provide ems modules 1.0.2 2018-03-05 ================== * added the `visit.onComment` API, reported when comments are allowed. * added the `ParseErrorCode.InvalidCommentToken` enum value, reported when comments are disallowed. 1.0.1 ================== * added the `format` API: computes edits to format a JSON document. * added the `modify` API: computes edits to insert, remove or replace a property or value in a JSON document. * added the `allyEdits` API: applies edits to a document 1.0.0 ================== * remove nls dependency (remove `getParseErrorMessage`) 0.4.2 / 2017-05-05 ================== * added `ParseError.offset` & `ParseError.length` 0.4.1 / 2017-04-02 ================== * added `ParseOptions.allowTrailingComma` 0.4.0 / 2017-02-23 ================== * fix for `getLocation`. Now `getLocation` inside an object will always return a property from inside that property. Can be empty string if the object has no properties or if the offset is before a actual property `{ "a": { | }} will return location ['a', ' ']` 0.3.0 / 2017-01-17 ================== * Updating to typescript 2.0microsoft-node-jsonc-parser-3c9b420/LICENSE.md000066400000000000000000000021041463635431300210070ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Microsoft 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. microsoft-node-jsonc-parser-3c9b420/README.md000066400000000000000000000337011463635431300206710ustar00rootroot00000000000000# jsonc-parser Scanner and parser for JSON with comments. [![npm Package](https://img.shields.io/npm/v/jsonc-parser.svg?style=flat-square)](https://www.npmjs.org/package/jsonc-parser) [![NPM Downloads](https://img.shields.io/npm/dm/jsonc-parser.svg)](https://npmjs.org/package/jsonc-parser) [![Build Status](https://github.com/microsoft/node-jsonc-parser/workflows/Tests/badge.svg)](https://github.com/microsoft/node-jsonc-parser/workflows/Tests) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) Why? ---- JSONC is JSON with JavaScript style comments. This node module provides a scanner and fault tolerant parser that can process JSONC but is also useful for standard JSON. - the *scanner* tokenizes the input string into tokens and token offsets - the *visit* function implements a 'SAX' style parser with callbacks for the encountered properties and values. - the *parseTree* function computes a hierarchical DOM with offsets representing the encountered properties and values. - the *parse* function evaluates the JavaScript object represented by JSON string in a fault tolerant fashion. - the *getLocation* API returns a location object that describes the property or value located at a given offset in a JSON document. - the *findNodeAtLocation* API finds the node at a given location path in a JSON DOM. - the *format* API computes edits to format a JSON document. - the *modify* API computes edits to insert, remove or replace a property or value in a JSON document. - the *applyEdits* API applies edits to a document. Installation ------------ ``` npm install --save jsonc-parser ``` API --- ### Scanner: ```typescript /** * Creates a JSON scanner on the given text. * If ignoreTrivia is set, whitespaces or comments are ignored. */ export function createScanner(text: string, ignoreTrivia: boolean = false): JSONScanner; /** * The scanner object, representing a JSON scanner at a position in the input string. */ export interface JSONScanner { /** * Sets the scan position to a new offset. A call to 'scan' is needed to get the first token. */ setPosition(pos: number): any; /** * Read the next token. Returns the token code. */ scan(): SyntaxKind; /** * Returns the zero-based current scan position, which is after the last read token. */ getPosition(): number; /** * Returns the last read token. */ getToken(): SyntaxKind; /** * Returns the last read token value. The value for strings is the decoded string content. For numbers it's of type number, for boolean it's true or false. */ getTokenValue(): string; /** * The zero-based start offset of the last read token. */ getTokenOffset(): number; /** * The length of the last read token. */ getTokenLength(): number; /** * The zero-based start line number of the last read token. */ getTokenStartLine(): number; /** * The zero-based start character (column) of the last read token. */ getTokenStartCharacter(): number; /** * An error code of the last scan. */ getTokenError(): ScanError; } ``` ### Parser: ```typescript export interface ParseOptions { disallowComments?: boolean; allowTrailingComma?: boolean; allowEmptyContent?: boolean; } /** * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result. * Therefore always check the errors list to find out if the input was valid. */ export declare function parse(text: string, errors?: {error: ParseErrorCode;}[], options?: ParseOptions): any; /** * Parses the given text and invokes the visitor functions for each object, array and literal reached. */ export declare function visit(text: string, visitor: JSONVisitor, options?: ParseOptions): any; /** * Visitor called by {@linkcode visit} when parsing JSON. * * The visitor functions have the following common parameters: * - `offset`: Global offset within the JSON document, starting at 0 * - `startLine`: Line number, starting at 0 * - `startCharacter`: Start character (column) within the current line, starting at 0 * * Additionally some functions have a `pathSupplier` parameter which can be used to obtain the * current `JSONPath` within the document. */ export interface JSONVisitor { /** * Invoked when an open brace is encountered and an object is started. The offset and length represent the location of the open brace. * When `false` is returned, the array items will not be visited. */ onObjectBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void | boolean; /** * Invoked when a property is encountered. The offset and length represent the location of the property name. * The `JSONPath` created by the `pathSupplier` refers to the enclosing JSON object, it does not include the * property name yet. */ onObjectProperty?: (property: string, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void; /** * Invoked when a closing brace is encountered and an object is completed. The offset and length represent the location of the closing brace. */ onObjectEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void; /** * Invoked when an open bracket is encountered. The offset and length represent the location of the open bracket. * When `false` is returned, the array items will not be visited.* */ onArrayBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void | boolean; /** * Invoked when a closing bracket is encountered. The offset and length represent the location of the closing bracket. */ onArrayEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void; /** * Invoked when a literal value is encountered. The offset and length represent the location of the literal value. */ onLiteralValue?: (value: any, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void; /** * Invoked when a comma or colon separator is encountered. The offset and length represent the location of the separator. */ onSeparator?: (character: string, offset: number, length: number, startLine: number, startCharacter: number) => void; /** * When comments are allowed, invoked when a line or block comment is encountered. The offset and length represent the location of the comment. */ onComment?: (offset: number, length: number, startLine: number, startCharacter: number) => void; /** * Invoked on an error. */ onError?: (error: ParseErrorCode, offset: number, length: number, startLine: number, startCharacter: number) => void; } /** * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result. */ export declare function parseTree(text: string, errors?: ParseError[], options?: ParseOptions): Node | undefined; export declare type NodeType = "object" | "array" | "property" | "string" | "number" | "boolean" | "null"; export interface Node { type: NodeType; value?: any; offset: number; length: number; colonOffset?: number; parent?: Node; children?: Node[]; } ``` ### Utilities: ```typescript /** * Takes JSON with JavaScript-style comments and remove * them. Optionally replaces every none-newline character * of comments with a replaceCharacter */ export declare function stripComments(text: string, replaceCh?: string): string; /** * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index. */ export declare function getLocation(text: string, position: number): Location; /** * A {@linkcode JSONPath} segment. Either a string representing an object property name * or a number (starting at 0) for array indices. */ export declare type Segment = string | number; export declare type JSONPath = Segment[]; export interface Location { /** * The previous property key or literal value (string, number, boolean or null) or undefined. */ previousNode?: Node; /** * The path describing the location in the JSON document. The path consists of a sequence strings * representing an object property or numbers for array indices. */ path: JSONPath; /** * Matches the locations path against a pattern consisting of strings (for properties) and numbers (for array indices). * '*' will match a single segment, of any property name or index. * '**' will match a sequence of segments or no segment, of any property name or index. */ matches: (patterns: JSONPath) => boolean; /** * If set, the location's offset is at a property key. */ isAtPropertyKey: boolean; } /** * Finds the node at the given path in a JSON DOM. */ export function findNodeAtLocation(root: Node, path: JSONPath): Node | undefined; /** * Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset. */ export function findNodeAtOffset(root: Node, offset: number, includeRightBound?: boolean) : Node | undefined; /** * Gets the JSON path of the given JSON DOM node */ export function getNodePath(node: Node): JSONPath; /** * Evaluates the JavaScript object of the given JSON DOM node */ export function getNodeValue(node: Node): any; /** * Computes the edit operations needed to format a JSON document. * * @param documentText The input text * @param range The range to format or `undefined` to format the full content * @param options The formatting options * @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}. * To apply the edit operations to the input, use {@linkcode applyEdits}. */ export function format(documentText: string, range: Range, options: FormattingOptions): EditResult; /** * Computes the edit operations needed to modify a value in the JSON document. * * @param documentText The input text * @param path The path of the value to change. The path represents either to the document root, a property or an array item. * If the path points to an non-existing property or item, it will be created. * @param value The new value for the specified property or item. If the value is undefined, * the property or item will be removed. * @param options Options * @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}. * To apply the edit operations to the input, use {@linkcode applyEdits}. */ export function modify(text: string, path: JSONPath, value: any, options: ModificationOptions): EditResult; /** * Applies edits to an input string. * @param text The input text * @param edits Edit operations following the format described in {@linkcode EditResult}. * @returns The text with the applied edits. * @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}. */ export function applyEdits(text: string, edits: EditResult): string; /** * An edit result describes a textual edit operation. It is the result of a {@linkcode format} and {@linkcode modify} operation. * It consist of one or more edits describing insertions, replacements or removals of text segments. * * The offsets of the edits refer to the original state of the document. * * No two edits change or remove the same range of text in the original document. * * Multiple edits can have the same offset if they are multiple inserts, or an insert followed by a remove or replace. * * The order in the array defines which edit is applied first. * To apply an edit result use {@linkcode applyEdits}. * In general multiple EditResults must not be concatenated because they might impact each other, producing incorrect or malformed JSON data. */ export type EditResult = Edit[]; /** * Represents a text modification */ export interface Edit { /** * The start offset of the modification. */ offset: number; /** * The length of the modification. Must not be negative. Empty length represents an *insert*. */ length: number; /** * The new content. Empty content represents a *remove*. */ content: string; } /** * A text range in the document */ export interface Range { /** * The start offset of the range. */ offset: number; /** * The length of the range. Must not be negative. */ length: number; } /** * Options used by {@linkcode format} when computing the formatting edit operations */ export interface FormattingOptions { /** * If indentation is based on spaces (`insertSpaces` = true), then what is the number of spaces that make an indent? */ tabSize: number; /** * Is indentation based on spaces? */ insertSpaces: boolean; /** * The default 'end of line' character */ eol: string; } /** * Options used by {@linkcode modify} when computing the modification edit operations */ export interface ModificationOptions { /** * Formatting options. If undefined, the newly inserted code will be inserted unformatted. */ formattingOptions?: FormattingOptions; /** * Default false. If `JSONPath` refers to an index of an array and `isArrayInsertion` is `true`, then * {@linkcode modify} will insert a new item at that location instead of overwriting its contents. */ isArrayInsertion?: boolean; /** * Optional function to define the insertion index given an existing list of properties. */ getInsertionIndex?: (properties: string[]) => number; } ``` License ------- (MIT License) Copyright 2018, Microsoft microsoft-node-jsonc-parser-3c9b420/SECURITY.md000066400000000000000000000053341463635431300212040ustar00rootroot00000000000000 ## Security Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. ## Reporting Security Issues **Please do not report security vulnerabilities through public GitHub issues.** Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) * Full paths of source file(s) related to the manifestation of the issue * The location of the affected source code (tag/branch/commit or direct URL) * Any special configuration required to reproduce the issue * Step-by-step instructions to reproduce the issue * Proof-of-concept or exploit code (if possible) * Impact of the issue, including how an attacker might exploit the issue This information will help us triage your report more quickly. If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. ## Preferred Languages We prefer all communications to be in English. ## Policy Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). microsoft-node-jsonc-parser-3c9b420/build/000077500000000000000000000000001463635431300205055ustar00rootroot00000000000000microsoft-node-jsonc-parser-3c9b420/build/pipeline.yml000066400000000000000000000020461463635431300230370ustar00rootroot00000000000000name: $(Date:yyyyMMdd)$(Rev:.r) trigger: batch: true branches: include: - main pr: none resources: repositories: - repository: templates type: github name: microsoft/vscode-engineering ref: main endpoint: Monaco parameters: - name: publishPackage displayName: 🚀 Publish jsonc-parser type: boolean default: false extends: template: azure-pipelines/npm-package/pipeline.yml@templates parameters: npmPackages: - name: jsonc-parser testPlatforms: - name: Linux nodeVersions: - 18.x - name: MacOS nodeVersions: - 18.x - name: Windows nodeVersions: - 18.x buildSteps: - script: npm ci displayName: Install dependencies testSteps: - script: npm ci displayName: Install dependencies - script: npm test displayName: Test npm package publishPackage: ${{ parameters.publishPackage }} microsoft-node-jsonc-parser-3c9b420/build/remove-sourcemap-refs.js000066400000000000000000000022531463635431300252730ustar00rootroot00000000000000/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ const fs = require('fs'); const path = require('path'); function deleteRefs(dir) { const files = fs.readdirSync(dir); for (let file of files) { const filePath = path.join(dir, file); const stat = fs.statSync(filePath); if (stat.isDirectory()) { deleteRefs(filePath); } else if (path.extname(file) === '.js') { const content = fs.readFileSync(filePath, 'utf8'); const newContent = content.replace(/\/\/\# sourceMappingURL=[^]+.js.map/, '') if (content.length !== newContent.length) { console.log('remove sourceMappingURL in ' + filePath); fs.writeFileSync(filePath, newContent); } } else if (path.extname(file) === '.map') { fs.unlinkSync(filePath) console.log('remove ' + filePath); } } } let location = path.join(__dirname, '..', 'lib'); console.log('process ' + location); deleteRefs(location);microsoft-node-jsonc-parser-3c9b420/package-lock.json000066400000000000000000002456051463635431300226360ustar00rootroot00000000000000{ "name": "jsonc-parser", "version": "3.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "jsonc-parser", "version": "3.3.1", "license": "MIT", "devDependencies": { "@types/mocha": "^10.0.7", "@types/node": "^18.x", "@typescript-eslint/eslint-plugin": "^7.13.1", "@typescript-eslint/parser": "^7.13.1", "eslint": "^8.57.0", "mocha": "^10.4.0", "rimraf": "^5.0.7", "typescript": "^5.4.2" } }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", "dev": true, "dependencies": { "eslint-visitor-keys": "^3.3.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, "node_modules/@eslint-community/regexpp": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.1.tgz", "integrity": "sha512-Zm2NGpWELsQAD1xsJzGQpYfvICSsFkEpU0jxBjfdC6uNEWXcHnfs9hScFWtXVDVl+rBQJGrl4g1vcKIejpH9dA==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, "node_modules/@eslint/eslintrc": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/@eslint/js": { "version": "8.57.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "deprecated": "Use @eslint/config-array instead", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^2.0.2", "debug": "^4.3.1", "minimatch": "^3.0.5" }, "engines": { "node": ">=10.10.0" } }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", "dev": true, "engines": { "node": ">=12.22" }, "funding": { "type": "github", "url": "https://github.com/sponsors/nzakas" } }, "node_modules/@humanwhocodes/object-schema": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "deprecated": "Use @eslint/object-schema instead", "dev": true }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", "dev": true, "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", "strip-ansi": "^7.0.1", "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", "wrap-ansi": "^8.1.0", "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" }, "engines": { "node": ">=12" } }, "node_modules/@isaacs/cliui/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, "node_modules/@isaacs/cliui/node_modules/ansi-styles": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "dev": true, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/@isaacs/cliui/node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "dev": true }, "node_modules/@isaacs/cliui/node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "dev": true, "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/@isaacs/cliui/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "dev": true, "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", "strip-ansi": "^7.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" }, "engines": { "node": ">= 8" } }, "node_modules/@nodelib/fs.stat": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true, "engines": { "node": ">= 8" } }, "node_modules/@nodelib/fs.walk": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" }, "engines": { "node": ">= 8" } }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", "dev": true, "optional": true, "engines": { "node": ">=14" } }, "node_modules/@types/mocha": { "version": "10.0.7", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.7.tgz", "integrity": "sha512-GN8yJ1mNTcFcah/wKEFIJckJx9iJLoMSzWcfRRuxz/Jk+U6KQNnml+etbtxFK8lPjzOw3zp4Ha/kjSst9fsHYw==", "dev": true }, "node_modules/@types/node": { "version": "18.19.39", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.39.tgz", "integrity": "sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ==", "dev": true, "dependencies": { "undici-types": "~5.26.4" } }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "7.13.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.13.1.tgz", "integrity": "sha512-kZqi+WZQaZfPKnsflLJQCz6Ze9FFSMfXrrIOcyargekQxG37ES7DJNpJUE9Q/X5n3yTIP/WPutVNzgknQ7biLg==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "7.13.1", "@typescript-eslint/type-utils": "7.13.1", "@typescript-eslint/utils": "7.13.1", "@typescript-eslint/visitor-keys": "7.13.1", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { "@typescript-eslint/parser": "^7.0.0", "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { "optional": true } } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/type-utils": { "version": "7.13.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.13.1.tgz", "integrity": "sha512-aWDbLu1s9bmgPGXSzNCxELu+0+HQOapV/y+60gPXafR8e2g1Bifxzevaa+4L2ytCWm+CHqpELq4CSoN9ELiwCg==", "dev": true, "dependencies": { "@typescript-eslint/typescript-estree": "7.13.1", "@typescript-eslint/utils": "7.13.1", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { "optional": true } } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": { "version": "7.13.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.13.1.tgz", "integrity": "sha512-h5MzFBD5a/Gh/fvNdp9pTfqJAbuQC4sCN2WzuXme71lqFJsZtLbjxfSk4r3p02WIArOF9N94pdsLiGutpDbrXQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@typescript-eslint/scope-manager": "7.13.1", "@typescript-eslint/types": "7.13.1", "@typescript-eslint/typescript-estree": "7.13.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { "eslint": "^8.56.0" } }, "node_modules/@typescript-eslint/parser": { "version": "7.13.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.13.1.tgz", "integrity": "sha512-1ELDPlnLvDQ5ybTSrMhRTFDfOQEOXNM+eP+3HT/Yq7ruWpciQw+Avi73pdEbA4SooCawEWo3dtYbF68gN7Ed1A==", "dev": true, "dependencies": { "@typescript-eslint/scope-manager": "7.13.1", "@typescript-eslint/types": "7.13.1", "@typescript-eslint/typescript-estree": "7.13.1", "@typescript-eslint/visitor-keys": "7.13.1", "debug": "^4.3.4" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { "optional": true } } }, "node_modules/@typescript-eslint/scope-manager": { "version": "7.13.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.13.1.tgz", "integrity": "sha512-adbXNVEs6GmbzaCpymHQ0MB6E4TqoiVbC0iqG3uijR8ZYfpAXMGttouQzF4Oat3P2GxDVIrg7bMI/P65LiQZdg==", "dev": true, "dependencies": { "@typescript-eslint/types": "7.13.1", "@typescript-eslint/visitor-keys": "7.13.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" } }, "node_modules/@typescript-eslint/types": { "version": "7.13.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.13.1.tgz", "integrity": "sha512-7K7HMcSQIAND6RBL4kDl24sG/xKM13cA85dc7JnmQXw2cBDngg7c19B++JzvJHRG3zG36n9j1i451GBzRuHchw==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" } }, "node_modules/@typescript-eslint/typescript-estree": { "version": "7.13.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.13.1.tgz", "integrity": "sha512-uxNr51CMV7npU1BxZzYjoVz9iyjckBduFBP0S5sLlh1tXYzHzgZ3BR9SVsNed+LmwKrmnqN3Kdl5t7eZ5TS1Yw==", "dev": true, "dependencies": { "@typescript-eslint/types": "7.13.1", "@typescript-eslint/visitor-keys": "7.13.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", "minimatch": "^9.0.4", "semver": "^7.6.0", "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependenciesMeta": { "typescript": { "optional": true } } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { "version": "9.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/@typescript-eslint/visitor-keys": { "version": "7.13.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.13.1.tgz", "integrity": "sha512-k/Bfne7lrP7hcb7m9zSsgcBmo+8eicqqfNAJ7uUY+jkTFpKeH2FSkWpFRtimBxgkyvqfu9jTPRbYOvud6isdXA==", "dev": true, "dependencies": { "@typescript-eslint/types": "7.13.1", "eslint-visitor-keys": "^3.4.3" }, "engines": { "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" } }, "node_modules/@ungap/structured-clone": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "dev": true }, "node_modules/acorn": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", "dev": true, "bin": { "acorn": "bin/acorn" }, "engines": { "node": ">=0.4.0" } }, "node_modules/acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" }, "funding": { "type": "github", "url": "https://github.com/sponsors/epoberezkin" } }, "node_modules/ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", "dev": true, "engines": { "node": ">=6" } }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "dependencies": { "color-convert": "^2.0.1" }, "engines": { "node": ">=8" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", "dev": true, "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" }, "engines": { "node": ">= 8" } }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "node_modules/braces": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { "fill-range": "^7.1.1" }, "engines": { "node": ">=8" } }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true, "engines": { "node": ">=6" } }, "node_modules/camelcase": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/chalk?sponsor=1" } }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", "dev": true, "funding": [ { "type": "individual", "url": "https://paulmillr.com/funding/" } ], "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "engines": { "node": ">= 8.10.0" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", "dev": true, "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", "wrap-ansi": "^7.0.0" } }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "dependencies": { "color-name": "~1.1.4" }, "engines": { "node": ">=7.0.0" } }, "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" }, "engines": { "node": ">= 8" } }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "dependencies": { "ms": "2.1.2" }, "engines": { "node": ">=6.0" }, "peerDependenciesMeta": { "supports-color": { "optional": true } } }, "node_modules/decamelize": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, "node_modules/diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", "dev": true, "engines": { "node": ">=0.3.1" } }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", "dev": true, "dependencies": { "path-type": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "dependencies": { "esutils": "^2.0.2" }, "engines": { "node": ">=6.0.0" } }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "dev": true }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", "dev": true, "engines": { "node": ">=6" } }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/eslint": { "version": "8.57.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.4", "@eslint/js": "8.57.0", "@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.2.2", "eslint-visitor-keys": "^3.4.3", "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", "graphemer": "^1.4.0", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3", "strip-ansi": "^6.0.1", "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, "dependencies": { "is-glob": "^4.0.3" }, "engines": { "node": ">=10.13.0" } }, "node_modules/espree": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "dependencies": { "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/esquery": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "dependencies": { "estraverse": "^5.1.0" }, "engines": { "node": ">=0.10" } }, "node_modules/esrecurse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "dependencies": { "estraverse": "^5.2.0" }, "engines": { "node": ">=4.0" } }, "node_modules/estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, "engines": { "node": ">=4.0" } }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.4" }, "engines": { "node": ">=8.6.0" } }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "node_modules/fastq": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dev": true, "dependencies": { "reusify": "^1.0.4" } }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "dependencies": { "flat-cache": "^3.0.4" }, "engines": { "node": "^10.12.0 || >=12.0.0" } }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" }, "engines": { "node": ">=8" } }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "dependencies": { "locate-path": "^6.0.0", "path-exists": "^4.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", "dev": true, "bin": { "flat": "cli.js" } }, "node_modules/flat-cache": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", "dev": true, "dependencies": { "flatted": "^3.2.9", "keyv": "^4.5.3", "rimraf": "^3.0.2" }, "engines": { "node": "^10.12.0 || >=12.0.0" } }, "node_modules/flat-cache/node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "deprecated": "Glob versions prior to v9 are no longer supported", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, "engines": { "node": "*" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/flat-cache/node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "deprecated": "Rimraf versions prior to v4 are no longer supported", "dev": true, "dependencies": { "glob": "^7.1.3" }, "bin": { "rimraf": "bin.js" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/flatted": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, "node_modules/foreground-child": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", "dev": true, "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" }, "engines": { "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true, "engines": { "node": "6.* || 8.* || >= 10.*" } }, "node_modules/glob": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", "deprecated": "Glob versions prior to v9 are no longer supported", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^5.0.1", "once": "^1.3.0" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, "dependencies": { "is-glob": "^4.0.1" }, "engines": { "node": ">= 6" } }, "node_modules/glob/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/glob/node_modules/minimatch": { "version": "5.1.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { "node": ">=10" } }, "node_modules/globals": { "version": "13.24.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" }, "engines": { "node": ">=8" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", "dev": true, "dependencies": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", "fast-glob": "^3.2.9", "ignore": "^5.2.0", "merge2": "^1.4.1", "slash": "^3.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true, "bin": { "he": "bin/he" } }, "node_modules/ignore": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "dev": true, "engines": { "node": ">= 4" } }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" }, "engines": { "node": ">=6" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, "engines": { "node": ">=0.8.19" } }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", "dev": true, "dependencies": { "binary-extensions": "^2.0.0" }, "engines": { "node": ">=8" } }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, "dependencies": { "is-extglob": "^2.1.1" }, "engines": { "node": ">=0.10.0" } }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, "engines": { "node": ">=0.12.0" } }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/is-unicode-supported": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "node_modules/jackspeak": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.0.tgz", "integrity": "sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==", "dev": true, "dependencies": { "@isaacs/cliui": "^8.0.2" }, "engines": { "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" }, "optionalDependencies": { "@pkgjs/parseargs": "^0.11.0" } }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "node_modules/js-yaml/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", "dev": true }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", "dev": true, "dependencies": { "json-buffer": "3.0.1" } }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "dependencies": { "prelude-ls": "^1.2.1", "type-check": "~0.4.0" }, "engines": { "node": ">= 0.8.0" } }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "dependencies": { "p-locate": "^5.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", "dev": true, "dependencies": { "chalk": "^4.1.0", "is-unicode-supported": "^0.1.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/lru-cache": { "version": "10.2.2", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz", "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", "dev": true, "engines": { "node": "14 || >=16.14" } }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true, "engines": { "node": ">= 8" } }, "node_modules/micromatch": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", "dev": true, "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { "node": ">=8.6" } }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, "engines": { "node": "*" } }, "node_modules/minipass": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, "engines": { "node": ">=16 || 14 >=14.17" } }, "node_modules/mocha": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.4.0.tgz", "integrity": "sha512-eqhGB8JKapEYcC4ytX/xrzKforgEc3j1pGlAXVy3eRwrtAy5/nIfT1SvgGzfN0XZZxeLq0aQWkOUAmqIJiv+bA==", "dev": true, "dependencies": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", "chokidar": "3.5.3", "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", "glob": "8.1.0", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" }, "bin": { "_mocha": "bin/_mocha", "mocha": "bin/mocha.js" }, "engines": { "node": ">= 14.0.0" } }, "node_modules/mocha/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/mocha/node_modules/minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { "node": ">=10" } }, "node_modules/mocha/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, "node_modules/mocha/node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, "dependencies": { "has-flag": "^4.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/supports-color?sponsor=1" } }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "dependencies": { "wrappy": "1" } }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", "word-wrap": "^1.2.5" }, "engines": { "node": ">= 0.8.0" } }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "dependencies": { "yocto-queue": "^0.1.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/p-locate": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "dependencies": { "p-limit": "^3.0.2" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/package-json-from-dist": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", "dev": true }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, "dependencies": { "callsites": "^3.0.0" }, "engines": { "node": ">=6" } }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/path-scurry": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", "dev": true, "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, "engines": { "node": ">=8.6" }, "funding": { "url": "https://github.com/sponsors/jonschlinkert" } }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, "engines": { "node": ">= 0.8.0" } }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "engines": { "node": ">=6" } }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true, "funding": [ { "type": "github", "url": "https://github.com/sponsors/feross" }, { "type": "patreon", "url": "https://www.patreon.com/feross" }, { "type": "consulting", "url": "https://feross.org/support" } ] }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dev": true, "dependencies": { "safe-buffer": "^5.1.0" } }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "dev": true, "dependencies": { "picomatch": "^2.2.1" }, "engines": { "node": ">=8.10.0" } }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, "engines": { "node": ">=4" } }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", "dev": true, "engines": { "iojs": ">=1.0.0", "node": ">=0.10.0" } }, "node_modules/rimraf": { "version": "5.0.7", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", "dev": true, "dependencies": { "glob": "^10.3.7" }, "bin": { "rimraf": "dist/esm/bin.mjs" }, "engines": { "node": ">=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/rimraf/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/rimraf/node_modules/glob": { "version": "10.4.2", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", "dev": true, "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^3.1.2", "minimatch": "^9.0.4", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", "path-scurry": "^1.11.1" }, "bin": { "glob": "dist/esm/bin.mjs" }, "engines": { "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/rimraf/node_modules/minimatch": { "version": "9.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, "funding": [ { "type": "github", "url": "https://github.com/sponsors/feross" }, { "type": "patreon", "url": "https://www.patreon.com/feross" }, { "type": "consulting", "url": "https://feross.org/support" } ], "dependencies": { "queue-microtask": "^1.2.2" } }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "dev": true, "funding": [ { "type": "github", "url": "https://github.com/sponsors/feross" }, { "type": "patreon", "url": "https://www.patreon.com/feross" }, { "type": "consulting", "url": "https://feross.org/support" } ] }, "node_modules/semver": { "version": "7.6.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "dev": true, "bin": { "semver": "bin/semver.js" }, "engines": { "node": ">=10" } }, "node_modules/serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", "dev": true, "dependencies": { "randombytes": "^2.1.0" } }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, "engines": { "node": ">=8" } }, "node_modules/shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true, "engines": { "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true, "engines": { "node": ">=8" } }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "engines": { "node": ">=8" } }, "node_modules/string-width-cjs": { "name": "string-width", "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "engines": { "node": ">=8" } }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, "engines": { "node": ">=8" } }, "node_modules/strip-ansi-cjs": { "name": "strip-ansi", "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, "engines": { "node": ">=8" } }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, "engines": { "node": ">=8" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "dependencies": { "has-flag": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, "dependencies": { "is-number": "^7.0.0" }, "engines": { "node": ">=8.0" } }, "node_modules/ts-api-utils": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "dev": true, "engines": { "node": ">=16" }, "peerDependencies": { "typescript": ">=4.2.0" } }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "dependencies": { "prelude-ls": "^1.2.1" }, "engines": { "node": ">= 0.8.0" } }, "node_modules/type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/typescript": { "version": "5.4.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz", "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { "node": ">=14.17" } }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "dependencies": { "punycode": "^2.1.0" } }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "bin/node-which" }, "engines": { "node": ">= 8" } }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/workerpool": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true, "engines": { "node": ">=10" } }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", "dev": true, "dependencies": { "cliui": "^7.0.2", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.0", "y18n": "^5.0.5", "yargs-parser": "^20.2.2" }, "engines": { "node": ">=10" } }, "node_modules/yargs-parser": { "version": "20.2.4", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", "dev": true, "engines": { "node": ">=10" } }, "node_modules/yargs-unparser": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", "dev": true, "dependencies": { "camelcase": "^6.0.0", "decamelize": "^4.0.0", "flat": "^5.0.2", "is-plain-obj": "^2.1.0" }, "engines": { "node": ">=10" } }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } } } } microsoft-node-jsonc-parser-3c9b420/package.json000066400000000000000000000022341463635431300216750ustar00rootroot00000000000000{ "name": "jsonc-parser", "version": "3.3.1", "description": "Scanner and parser for JSON with comments.", "main": "./lib/umd/main.js", "typings": "./lib/umd/main.d.ts", "module": "./lib/esm/main.js", "author": "Microsoft Corporation", "repository": { "type": "git", "url": "https://github.com/microsoft/node-jsonc-parser" }, "license": "MIT", "bugs": { "url": "https://github.com/microsoft/node-jsonc-parser/issues" }, "devDependencies": { "@types/mocha": "^10.0.7", "@types/node": "^18.x", "@typescript-eslint/eslint-plugin": "^7.13.1", "@typescript-eslint/parser": "^7.13.1", "eslint": "^8.57.0", "mocha": "^10.4.0", "rimraf": "^5.0.7", "typescript": "^5.4.2" }, "scripts": { "prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs", "compile": "tsc -p ./src && npm run lint", "compile-esm": "tsc -p ./src/tsconfig.esm.json", "remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js", "clean": "rimraf lib", "watch": "tsc -w -p ./src", "test": "npm run compile && mocha ./lib/umd/test", "lint": "eslint src/**/*.ts" } } microsoft-node-jsonc-parser-3c9b420/src/000077500000000000000000000000001463635431300201755ustar00rootroot00000000000000microsoft-node-jsonc-parser-3c9b420/src/impl/000077500000000000000000000000001463635431300211365ustar00rootroot00000000000000microsoft-node-jsonc-parser-3c9b420/src/impl/edit.ts000066400000000000000000000166071463635431300224450ustar00rootroot00000000000000/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import { Edit, ParseError, Node, JSONPath, Segment, ModificationOptions } from '../main'; import { format, isEOL } from './format'; import { parseTree, findNodeAtLocation } from './parser'; export function removeProperty(text: string, path: JSONPath, options: ModificationOptions): Edit[] { return setProperty(text, path, void 0, options); } export function setProperty(text: string, originalPath: JSONPath, value: any, options: ModificationOptions): Edit[] { const path = originalPath.slice(); const errors: ParseError[] = []; const root = parseTree(text, errors); let parent: Node | undefined = void 0; let lastSegment: Segment | undefined = void 0; while (path.length > 0) { lastSegment = path.pop(); parent = findNodeAtLocation(root, path); if (parent === void 0 && value !== void 0) { if (typeof lastSegment === 'string') { value = { [lastSegment]: value }; } else { value = [value]; } } else { break; } } if (!parent) { // empty document if (value === void 0) { // delete throw new Error('Can not delete in empty document'); } return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options); } else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) { const existing = findNodeAtLocation(parent, [lastSegment]); if (existing !== void 0) { if (value === void 0) { // delete if (!existing.parent) { throw new Error('Malformed AST'); } const propertyIndex = parent.children.indexOf(existing.parent); let removeBegin: number; let removeEnd = existing.parent.offset + existing.parent.length; if (propertyIndex > 0) { // remove the comma of the previous node let previous = parent.children[propertyIndex - 1]; removeBegin = previous.offset + previous.length; } else { removeBegin = parent.offset + 1; if (parent.children.length > 1) { // remove the comma of the next node let next = parent.children[1]; removeEnd = next.offset; } } return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, options); } else { // set value of existing property return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options); } } else { if (value === void 0) { // delete return []; // property does not exist, nothing to do } const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`; const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map(p => p.children![0].value)) : parent.children.length; let edit: Edit; if (index > 0) { let previous = parent.children[index - 1]; edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty }; } else if (parent.children.length === 0) { edit = { offset: parent.offset + 1, length: 0, content: newProperty }; } else { edit = { offset: parent.offset + 1, length: 0, content: newProperty + ',' }; } return withFormatting(text, edit, options); } } else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) { const insertIndex = lastSegment; if (insertIndex === -1) { // Insert const newProperty = `${JSON.stringify(value)}`; let edit: Edit; if (parent.children.length === 0) { edit = { offset: parent.offset + 1, length: 0, content: newProperty }; } else { const previous = parent.children[parent.children.length - 1]; edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty }; } return withFormatting(text, edit, options); } else if (value === void 0 && parent.children.length >= 0) { // Removal const removalIndex = lastSegment; const toRemove = parent.children[removalIndex]; let edit: Edit; if (parent.children.length === 1) { // only item edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' }; } else if (parent.children.length - 1 === removalIndex) { // last item let previous = parent.children[removalIndex - 1]; let offset = previous.offset + previous.length; let parentEndOffset = parent.offset + parent.length; edit = { offset, length: parentEndOffset - 2 - offset, content: '' }; } else { edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' }; } return withFormatting(text, edit, options); } else if (value !== void 0) { let edit: Edit; const newProperty = `${JSON.stringify(value)}`; if (!options.isArrayInsertion && parent.children.length > lastSegment) { const toModify = parent.children[lastSegment]; edit = { offset: toModify.offset, length: toModify.length, content: newProperty }; } else if (parent.children.length === 0 || lastSegment === 0) { edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + ',' }; } else { const index = lastSegment > parent.children.length ? parent.children.length : lastSegment; const previous = parent.children[index - 1]; edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty }; } return withFormatting(text, edit, options); } else { throw new Error(`Can not ${value === void 0 ? 'remove' : (options.isArrayInsertion ? 'insert' : 'modify')} Array index ${insertIndex} as length is not sufficient`); } } else { throw new Error(`Can not add ${typeof lastSegment !== 'number' ? 'index' : 'property'} to parent of type ${parent.type}`); } } function withFormatting(text: string, edit: Edit, options: ModificationOptions): Edit[] { if (!options.formattingOptions) { return [edit]; } // apply the edit let newText = applyEdit(text, edit); // format the new text let begin = edit.offset; let end = edit.offset + edit.content.length; if (edit.length === 0 || edit.content.length === 0) { // insert or remove while (begin > 0 && !isEOL(newText, begin - 1)) { begin--; } while (end < newText.length && !isEOL(newText, end)) { end++; } } const edits = format(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false }); // apply the formatting edits and track the begin and end offsets of the changes for (let i = edits.length - 1; i >= 0; i--) { const edit = edits[i]; newText = applyEdit(newText, edit); begin = Math.min(begin, edit.offset); end = Math.max(end, edit.offset + edit.length); end += edit.content.length - edit.length; } // create a single edit with all changes const editLength = text.length - (newText.length - end) - begin; return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }]; } export function applyEdit(text: string, edit: Edit): string { return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length); } export function isWS(text: string, offset: number) { return '\r\n \t'.indexOf(text.charAt(offset)) !== -1; } microsoft-node-jsonc-parser-3c9b420/src/impl/format.ts000066400000000000000000000214111463635431300227750ustar00rootroot00000000000000/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import { Range, FormattingOptions, Edit, SyntaxKind, ScanError } from '../main'; import { createScanner } from './scanner'; import { cachedSpaces, cachedBreakLinesWithSpaces, supportedEols, SupportedEOL } from './string-intern'; export function format(documentText: string, range: Range | undefined, options: FormattingOptions): Edit[] { let initialIndentLevel: number; let formatText: string; let formatTextStart: number; let rangeStart: number; let rangeEnd: number; if (range) { rangeStart = range.offset; rangeEnd = rangeStart + range.length; formatTextStart = rangeStart; while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) { formatTextStart--; } let endOffset = rangeEnd; while (endOffset < documentText.length && !isEOL(documentText, endOffset)) { endOffset++; } formatText = documentText.substring(formatTextStart, endOffset); initialIndentLevel = computeIndentLevel(formatText, options); } else { formatText = documentText; initialIndentLevel = 0; formatTextStart = 0; rangeStart = 0; rangeEnd = documentText.length; } const eol = getEOL(options, documentText); const eolFastPathSupported = supportedEols.includes(eol as any); let numberLineBreaks = 0; let indentLevel = 0; let indentValue: string; if (options.insertSpaces) { indentValue = cachedSpaces[options.tabSize || 4] ?? repeat(cachedSpaces[1], options.tabSize || 4); } else { indentValue = '\t'; } const indentType = indentValue === '\t' ? '\t' : ' '; let scanner = createScanner(formatText, false); let hasError = false; function newLinesAndIndent(): string { if (numberLineBreaks > 1) { return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel); } const amountOfSpaces = indentValue.length * (initialIndentLevel + indentLevel); if (!eolFastPathSupported || amountOfSpaces > cachedBreakLinesWithSpaces[indentType][eol as SupportedEOL].length) { return eol + repeat(indentValue, initialIndentLevel + indentLevel); } if (amountOfSpaces <= 0) { return eol; } return cachedBreakLinesWithSpaces[indentType][eol as SupportedEOL][amountOfSpaces]; } function scanNext(): SyntaxKind { let token = scanner.scan(); numberLineBreaks = 0; while (token === SyntaxKind.Trivia || token === SyntaxKind.LineBreakTrivia) { if (token === SyntaxKind.LineBreakTrivia && options.keepLines) { numberLineBreaks += 1; } else if (token === SyntaxKind.LineBreakTrivia) { numberLineBreaks = 1; } token = scanner.scan(); } hasError = token === SyntaxKind.Unknown || scanner.getTokenError() !== ScanError.None; return token; } const editOperations: Edit[] = []; function addEdit(text: string, startOffset: number, endOffset: number) { if (!hasError && (!range || (startOffset < rangeEnd && endOffset > rangeStart)) && documentText.substring(startOffset, endOffset) !== text) { editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text }); } } let firstToken = scanNext(); if (options.keepLines && numberLineBreaks > 0) { addEdit(repeat(eol, numberLineBreaks), 0, 0); } if (firstToken !== SyntaxKind.EOF) { let firstTokenStart = scanner.getTokenOffset() + formatTextStart; let initialIndent = (indentValue.length * initialIndentLevel < 20) && options.insertSpaces ? cachedSpaces[indentValue.length * initialIndentLevel] : repeat(indentValue, initialIndentLevel); addEdit(initialIndent, formatTextStart, firstTokenStart); } while (firstToken !== SyntaxKind.EOF) { let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart; let secondToken = scanNext(); let replaceContent = ''; let needsLineBreak = false; while (numberLineBreaks === 0 && (secondToken === SyntaxKind.LineCommentTrivia || secondToken === SyntaxKind.BlockCommentTrivia)) { let commentTokenStart = scanner.getTokenOffset() + formatTextStart; addEdit(cachedSpaces[1], firstTokenEnd, commentTokenStart); firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart; needsLineBreak = secondToken === SyntaxKind.LineCommentTrivia; replaceContent = needsLineBreak ? newLinesAndIndent() : ''; secondToken = scanNext(); } if (secondToken === SyntaxKind.CloseBraceToken) { if (firstToken !== SyntaxKind.OpenBraceToken) { indentLevel--; }; if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== SyntaxKind.OpenBraceToken) { replaceContent = newLinesAndIndent(); } else if (options.keepLines) { replaceContent = cachedSpaces[1]; } } else if (secondToken === SyntaxKind.CloseBracketToken) { if (firstToken !== SyntaxKind.OpenBracketToken) { indentLevel--; }; if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== SyntaxKind.OpenBracketToken) { replaceContent = newLinesAndIndent(); } else if (options.keepLines) { replaceContent = cachedSpaces[1]; } } else { switch (firstToken) { case SyntaxKind.OpenBracketToken: case SyntaxKind.OpenBraceToken: indentLevel++; if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) { replaceContent = newLinesAndIndent(); } else { replaceContent = cachedSpaces[1]; } break; case SyntaxKind.CommaToken: if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) { replaceContent = newLinesAndIndent(); } else { replaceContent = cachedSpaces[1]; } break; case SyntaxKind.LineCommentTrivia: replaceContent = newLinesAndIndent(); break; case SyntaxKind.BlockCommentTrivia: if (numberLineBreaks > 0) { replaceContent = newLinesAndIndent(); } else if (!needsLineBreak) { replaceContent = cachedSpaces[1]; } break; case SyntaxKind.ColonToken: if (options.keepLines && numberLineBreaks > 0) { replaceContent = newLinesAndIndent(); } else if (!needsLineBreak) { replaceContent = cachedSpaces[1]; } break; case SyntaxKind.StringLiteral: if (options.keepLines && numberLineBreaks > 0) { replaceContent = newLinesAndIndent(); } else if (secondToken === SyntaxKind.ColonToken && !needsLineBreak) { replaceContent = ''; } break; case SyntaxKind.NullKeyword: case SyntaxKind.TrueKeyword: case SyntaxKind.FalseKeyword: case SyntaxKind.NumericLiteral: case SyntaxKind.CloseBraceToken: case SyntaxKind.CloseBracketToken: if (options.keepLines && numberLineBreaks > 0) { replaceContent = newLinesAndIndent(); } else { if ((secondToken === SyntaxKind.LineCommentTrivia || secondToken === SyntaxKind.BlockCommentTrivia) && !needsLineBreak) { replaceContent = cachedSpaces[1]; } else if (secondToken !== SyntaxKind.CommaToken && secondToken !== SyntaxKind.EOF) { hasError = true; } } break; case SyntaxKind.Unknown: hasError = true; break; } if (numberLineBreaks > 0 && (secondToken === SyntaxKind.LineCommentTrivia || secondToken === SyntaxKind.BlockCommentTrivia)) { replaceContent = newLinesAndIndent(); } } if (secondToken === SyntaxKind.EOF) { if (options.keepLines && numberLineBreaks > 0) { replaceContent = newLinesAndIndent(); } else { replaceContent = options.insertFinalNewline ? eol : ''; } } const secondTokenStart = scanner.getTokenOffset() + formatTextStart; addEdit(replaceContent, firstTokenEnd, secondTokenStart); firstToken = secondToken; } return editOperations; } function repeat(s: string, count: number): string { let result = ''; for (let i = 0; i < count; i++) { result += s; } return result; } function computeIndentLevel(content: string, options: FormattingOptions): number { let i = 0; let nChars = 0; const tabSize = options.tabSize || 4; while (i < content.length) { let ch = content.charAt(i); if (ch === cachedSpaces[1]) { nChars++; } else if (ch === '\t') { nChars += tabSize; } else { break; } i++; } return Math.floor(nChars / tabSize); } function getEOL(options: FormattingOptions, text: string): string { for (let i = 0; i < text.length; i++) { const ch = text.charAt(i); if (ch === '\r') { if (i + 1 < text.length && text.charAt(i + 1) === '\n') { return '\r\n'; } return '\r'; } else if (ch === '\n') { return '\n'; } } return (options && options.eol) || '\n'; } export function isEOL(text: string, offset: number) { return '\r\n'.indexOf(text.charAt(offset)) !== -1; } microsoft-node-jsonc-parser-3c9b420/src/impl/parser.ts000066400000000000000000000527111463635431300230100ustar00rootroot00000000000000/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import { createScanner } from './scanner'; import { JSONPath, JSONVisitor, Location, Node, NodeType, ParseError, ParseErrorCode, ParseOptions, ScanError, Segment, SyntaxKind } from '../main'; namespace ParseOptions { export const DEFAULT = { allowTrailingComma: false }; } interface NodeImpl extends Node { type: NodeType; value?: any; offset: number; length: number; colonOffset?: number; parent?: NodeImpl; children?: NodeImpl[]; } /** * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index. */ export function getLocation(text: string, position: number): Location { const segments: Segment[] = []; // strings or numbers const earlyReturnException = new Object(); let previousNode: NodeImpl | undefined = undefined; const previousNodeInst: NodeImpl = { value: {}, offset: 0, length: 0, type: 'object', parent: undefined }; let isAtPropertyKey = false; function setPreviousNode(value: string, offset: number, length: number, type: NodeType) { previousNodeInst.value = value; previousNodeInst.offset = offset; previousNodeInst.length = length; previousNodeInst.type = type; previousNodeInst.colonOffset = undefined; previousNode = previousNodeInst; } try { visit(text, { onObjectBegin: (offset: number, length: number) => { if (position <= offset) { throw earlyReturnException; } previousNode = undefined; isAtPropertyKey = position > offset; segments.push(''); // push a placeholder (will be replaced) }, onObjectProperty: (name: string, offset: number, length: number) => { if (position < offset) { throw earlyReturnException; } setPreviousNode(name, offset, length, 'property'); segments[segments.length - 1] = name; if (position <= offset + length) { throw earlyReturnException; } }, onObjectEnd: (offset: number, length: number) => { if (position <= offset) { throw earlyReturnException; } previousNode = undefined; segments.pop(); }, onArrayBegin: (offset: number, length: number) => { if (position <= offset) { throw earlyReturnException; } previousNode = undefined; segments.push(0); }, onArrayEnd: (offset: number, length: number) => { if (position <= offset) { throw earlyReturnException; } previousNode = undefined; segments.pop(); }, onLiteralValue: (value: any, offset: number, length: number) => { if (position < offset) { throw earlyReturnException; } setPreviousNode(value, offset, length, getNodeType(value)); if (position <= offset + length) { throw earlyReturnException; } }, onSeparator: (sep: string, offset: number, length: number) => { if (position <= offset) { throw earlyReturnException; } if (sep === ':' && previousNode && previousNode.type === 'property') { previousNode.colonOffset = offset; isAtPropertyKey = false; previousNode = undefined; } else if (sep === ',') { const last = segments[segments.length - 1]; if (typeof last === 'number') { segments[segments.length - 1] = last + 1; } else { isAtPropertyKey = true; segments[segments.length - 1] = ''; } previousNode = undefined; } } }); } catch (e) { if (e !== earlyReturnException) { throw e; } } return { path: segments, previousNode, isAtPropertyKey, matches: (pattern: Segment[]) => { let k = 0; for (let i = 0; k < pattern.length && i < segments.length; i++) { if (pattern[k] === segments[i] || pattern[k] === '*') { k++; } else if (pattern[k] !== '**') { return false; } } return k === pattern.length; } }; } /** * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result. * Therefore always check the errors list to find out if the input was valid. */ export function parse(text: string, errors: ParseError[] = [], options: ParseOptions = ParseOptions.DEFAULT): any { let currentProperty: string | null = null; let currentParent: any = []; const previousParents: any[] = []; function onValue(value: any) { if (Array.isArray(currentParent)) { (currentParent).push(value); } else if (currentProperty !== null) { currentParent[currentProperty] = value; } } const visitor: JSONVisitor = { onObjectBegin: () => { const object = {}; onValue(object); previousParents.push(currentParent); currentParent = object; currentProperty = null; }, onObjectProperty: (name: string) => { currentProperty = name; }, onObjectEnd: () => { currentParent = previousParents.pop(); }, onArrayBegin: () => { const array: any[] = []; onValue(array); previousParents.push(currentParent); currentParent = array; currentProperty = null; }, onArrayEnd: () => { currentParent = previousParents.pop(); }, onLiteralValue: onValue, onError: (error: ParseErrorCode, offset: number, length: number) => { errors.push({ error, offset, length }); } }; visit(text, visitor, options); return currentParent[0]; } /** * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result. */ export function parseTree(text: string, errors: ParseError[] = [], options: ParseOptions = ParseOptions.DEFAULT): Node | undefined { let currentParent: NodeImpl = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root function ensurePropertyComplete(endOffset: number) { if (currentParent.type === 'property') { currentParent.length = endOffset - currentParent.offset; currentParent = currentParent.parent!; } } function onValue(valueNode: Node): Node { currentParent.children!.push(valueNode); return valueNode; } const visitor: JSONVisitor = { onObjectBegin: (offset: number) => { currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] }); }, onObjectProperty: (name: string, offset: number, length: number) => { currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] }); currentParent.children!.push({ type: 'string', value: name, offset, length, parent: currentParent }); }, onObjectEnd: (offset: number, length: number) => { ensurePropertyComplete(offset + length); // in case of a missing value for a property: make sure property is complete currentParent.length = offset + length - currentParent.offset; currentParent = currentParent.parent!; ensurePropertyComplete(offset + length); }, onArrayBegin: (offset: number, length: number) => { currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] }); }, onArrayEnd: (offset: number, length: number) => { currentParent.length = offset + length - currentParent.offset; currentParent = currentParent.parent!; ensurePropertyComplete(offset + length); }, onLiteralValue: (value: any, offset: number, length: number) => { onValue({ type: getNodeType(value), offset, length, parent: currentParent, value }); ensurePropertyComplete(offset + length); }, onSeparator: (sep: string, offset: number, length: number) => { if (currentParent.type === 'property') { if (sep === ':') { currentParent.colonOffset = offset; } else if (sep === ',') { ensurePropertyComplete(offset); } } }, onError: (error: ParseErrorCode, offset: number, length: number) => { errors.push({ error, offset, length }); } }; visit(text, visitor, options); const result = currentParent.children![0]; if (result) { delete result.parent; } return result; } /** * Finds the node at the given path in a JSON DOM. */ export function findNodeAtLocation(root: Node | undefined, path: JSONPath): Node | undefined { if (!root) { return undefined; } let node = root; for (let segment of path) { if (typeof segment === 'string') { if (node.type !== 'object' || !Array.isArray(node.children)) { return undefined; } let found = false; for (const propertyNode of node.children) { if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) { node = propertyNode.children[1]; found = true; break; } } if (!found) { return undefined; } } else { const index = segment; if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) { return undefined; } node = node.children[index]; } } return node; } /** * Gets the JSON path of the given JSON DOM node */ export function getNodePath(node: Node): JSONPath { if (!node.parent || !node.parent.children) { return []; } const path = getNodePath(node.parent); if (node.parent.type === 'property') { const key = node.parent.children[0].value; path.push(key); } else if (node.parent.type === 'array') { const index = node.parent.children.indexOf(node); if (index !== -1) { path.push(index); } } return path; } /** * Evaluates the JavaScript object of the given JSON DOM node */ export function getNodeValue(node: Node): any { switch (node.type) { case 'array': return node.children!.map(getNodeValue); case 'object': const obj = Object.create(null); for (let prop of node.children!) { const valueNode = prop.children![1]; if (valueNode) { obj[prop.children![0].value] = getNodeValue(valueNode); } } return obj; case 'null': case 'string': case 'number': case 'boolean': return node.value; default: return undefined; } } export function contains(node: Node, offset: number, includeRightBound = false): boolean { return (offset >= node.offset && offset < (node.offset + node.length)) || includeRightBound && (offset === (node.offset + node.length)); } /** * Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset. */ export function findNodeAtOffset(node: Node, offset: number, includeRightBound = false): Node | undefined { if (contains(node, offset, includeRightBound)) { const children = node.children; if (Array.isArray(children)) { for (let i = 0; i < children.length && children[i].offset <= offset; i++) { const item = findNodeAtOffset(children[i], offset, includeRightBound); if (item) { return item; } } } return node; } return undefined; } /** * Parses the given text and invokes the visitor functions for each object, array and literal reached. */ export function visit(text: string, visitor: JSONVisitor, options: ParseOptions = ParseOptions.DEFAULT): any { const _scanner = createScanner(text, false); // Important: Only pass copies of this to visitor functions to prevent accidental modification, and // to not affect visitor functions which stored a reference to a previous JSONPath const _jsonPath: JSONPath = []; // Depth of onXXXBegin() callbacks suppressed. onXXXEnd() decrements this if it isn't 0 already. // Callbacks are only called when this value is 0. let suppressedCallbacks = 0; function toNoArgVisit(visitFunction?: (offset: number, length: number, startLine: number, startCharacter: number) => void): () => void { return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true; } function toOneArgVisit(visitFunction?: (arg: T, offset: number, length: number, startLine: number, startCharacter: number) => void): (arg: T) => void { return visitFunction ? (arg: T) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true; } function toOneArgVisitWithPath(visitFunction?: (arg: T, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void): (arg: T) => void { return visitFunction ? (arg: T) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true; } function toBeginVisit(visitFunction?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => boolean | void): () => void { return visitFunction ? () => { if (suppressedCallbacks > 0) { suppressedCallbacks++; } else { let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()); if (cbReturn === false) { suppressedCallbacks = 1; } } } : () => true; } function toEndVisit(visitFunction?: (offset: number, length: number, startLine: number, startCharacter: number) => void): () => void { return visitFunction ? () => { if (suppressedCallbacks > 0) { suppressedCallbacks--; } if (suppressedCallbacks === 0) { visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()); } } : () => true; } const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError); const disallowComments = options && options.disallowComments; const allowTrailingComma = options && options.allowTrailingComma; function scanNext(): SyntaxKind { while (true) { const token = _scanner.scan(); switch (_scanner.getTokenError()) { case ScanError.InvalidUnicode: handleError(ParseErrorCode.InvalidUnicode); break; case ScanError.InvalidEscapeCharacter: handleError(ParseErrorCode.InvalidEscapeCharacter); break; case ScanError.UnexpectedEndOfNumber: handleError(ParseErrorCode.UnexpectedEndOfNumber); break; case ScanError.UnexpectedEndOfComment: if (!disallowComments) { handleError(ParseErrorCode.UnexpectedEndOfComment); } break; case ScanError.UnexpectedEndOfString: handleError(ParseErrorCode.UnexpectedEndOfString); break; case ScanError.InvalidCharacter: handleError(ParseErrorCode.InvalidCharacter); break; } switch (token) { case SyntaxKind.LineCommentTrivia: case SyntaxKind.BlockCommentTrivia: if (disallowComments) { handleError(ParseErrorCode.InvalidCommentToken); } else { onComment(); } break; case SyntaxKind.Unknown: handleError(ParseErrorCode.InvalidSymbol); break; case SyntaxKind.Trivia: case SyntaxKind.LineBreakTrivia: break; default: return token; } } } function handleError(error: ParseErrorCode, skipUntilAfter: SyntaxKind[] = [], skipUntil: SyntaxKind[] = []): void { onError(error); if (skipUntilAfter.length + skipUntil.length > 0) { let token = _scanner.getToken(); while (token !== SyntaxKind.EOF) { if (skipUntilAfter.indexOf(token) !== -1) { scanNext(); break; } else if (skipUntil.indexOf(token) !== -1) { break; } token = scanNext(); } } } function parseString(isValue: boolean): boolean { const value = _scanner.getTokenValue(); if (isValue) { onLiteralValue(value); } else { onObjectProperty(value); // add property name afterwards _jsonPath.push(value); } scanNext(); return true; } function parseLiteral(): boolean { switch (_scanner.getToken()) { case SyntaxKind.NumericLiteral: const tokenValue = _scanner.getTokenValue(); let value = Number(tokenValue); if (isNaN(value)) { handleError(ParseErrorCode.InvalidNumberFormat); value = 0; } onLiteralValue(value); break; case SyntaxKind.NullKeyword: onLiteralValue(null); break; case SyntaxKind.TrueKeyword: onLiteralValue(true); break; case SyntaxKind.FalseKeyword: onLiteralValue(false); break; default: return false; } scanNext(); return true; } function parseProperty(): boolean { if (_scanner.getToken() !== SyntaxKind.StringLiteral) { handleError(ParseErrorCode.PropertyNameExpected, [], [SyntaxKind.CloseBraceToken, SyntaxKind.CommaToken]); return false; } parseString(false); if (_scanner.getToken() === SyntaxKind.ColonToken) { onSeparator(':'); scanNext(); // consume colon if (!parseValue()) { handleError(ParseErrorCode.ValueExpected, [], [SyntaxKind.CloseBraceToken, SyntaxKind.CommaToken]); } } else { handleError(ParseErrorCode.ColonExpected, [], [SyntaxKind.CloseBraceToken, SyntaxKind.CommaToken]); } _jsonPath.pop(); // remove processed property name return true; } function parseObject(): boolean { onObjectBegin(); scanNext(); // consume open brace let needsComma = false; while (_scanner.getToken() !== SyntaxKind.CloseBraceToken && _scanner.getToken() !== SyntaxKind.EOF) { if (_scanner.getToken() === SyntaxKind.CommaToken) { if (!needsComma) { handleError(ParseErrorCode.ValueExpected, [], []); } onSeparator(','); scanNext(); // consume comma if (_scanner.getToken() === SyntaxKind.CloseBraceToken && allowTrailingComma) { break; } } else if (needsComma) { handleError(ParseErrorCode.CommaExpected, [], []); } if (!parseProperty()) { handleError(ParseErrorCode.ValueExpected, [], [SyntaxKind.CloseBraceToken, SyntaxKind.CommaToken]); } needsComma = true; } onObjectEnd(); if (_scanner.getToken() !== SyntaxKind.CloseBraceToken) { handleError(ParseErrorCode.CloseBraceExpected, [SyntaxKind.CloseBraceToken], []); } else { scanNext(); // consume close brace } return true; } function parseArray(): boolean { onArrayBegin(); scanNext(); // consume open bracket let isFirstElement = true; let needsComma = false; while (_scanner.getToken() !== SyntaxKind.CloseBracketToken && _scanner.getToken() !== SyntaxKind.EOF) { if (_scanner.getToken() === SyntaxKind.CommaToken) { if (!needsComma) { handleError(ParseErrorCode.ValueExpected, [], []); } onSeparator(','); scanNext(); // consume comma if (_scanner.getToken() === SyntaxKind.CloseBracketToken && allowTrailingComma) { break; } } else if (needsComma) { handleError(ParseErrorCode.CommaExpected, [], []); } if (isFirstElement) { _jsonPath.push(0); isFirstElement = false; } else { (_jsonPath[_jsonPath.length - 1] as number)++; } if (!parseValue()) { handleError(ParseErrorCode.ValueExpected, [], [SyntaxKind.CloseBracketToken, SyntaxKind.CommaToken]); } needsComma = true; } onArrayEnd(); if (!isFirstElement) { _jsonPath.pop(); // remove array index } if (_scanner.getToken() !== SyntaxKind.CloseBracketToken) { handleError(ParseErrorCode.CloseBracketExpected, [SyntaxKind.CloseBracketToken], []); } else { scanNext(); // consume close bracket } return true; } function parseValue(): boolean { switch (_scanner.getToken()) { case SyntaxKind.OpenBracketToken: return parseArray(); case SyntaxKind.OpenBraceToken: return parseObject(); case SyntaxKind.StringLiteral: return parseString(true); default: return parseLiteral(); } } scanNext(); if (_scanner.getToken() === SyntaxKind.EOF) { if (options.allowEmptyContent) { return true; } handleError(ParseErrorCode.ValueExpected, [], []); return false; } if (!parseValue()) { handleError(ParseErrorCode.ValueExpected, [], []); return false; } if (_scanner.getToken() !== SyntaxKind.EOF) { handleError(ParseErrorCode.EndOfFileExpected, [], []); } return true; } /** * Takes JSON with JavaScript-style comments and remove * them. Optionally replaces every none-newline character * of comments with a replaceCharacter */ export function stripComments(text: string, replaceCh?: string): string { let _scanner = createScanner(text), parts: string[] = [], kind: SyntaxKind, offset = 0, pos: number; do { pos = _scanner.getPosition(); kind = _scanner.scan(); switch (kind) { case SyntaxKind.LineCommentTrivia: case SyntaxKind.BlockCommentTrivia: case SyntaxKind.EOF: if (offset !== pos) { parts.push(text.substring(offset, pos)); } if (replaceCh !== undefined) { parts.push(_scanner.getTokenValue().replace(/[^\r\n]/g, replaceCh)); } offset = _scanner.getPosition(); break; } } while (kind !== SyntaxKind.EOF); return parts.join(''); } export function getNodeType(value: any): NodeType { switch (typeof value) { case 'boolean': return 'boolean'; case 'number': return 'number'; case 'string': return 'string'; case 'object': { if (!value) { return 'null'; } else if (Array.isArray(value)) { return 'array'; } return 'object'; } default: return 'null'; } } microsoft-node-jsonc-parser-3c9b420/src/impl/scanner.ts000066400000000000000000000266521463635431300231520ustar00rootroot00000000000000/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import { ScanError, SyntaxKind, JSONScanner } from '../main'; /** * Creates a JSON scanner on the given text. * If ignoreTrivia is set, whitespaces or comments are ignored. */ export function createScanner(text: string, ignoreTrivia: boolean = false): JSONScanner { const len = text.length; let pos = 0, value: string = '', tokenOffset = 0, token: SyntaxKind = SyntaxKind.Unknown, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError: ScanError = ScanError.None; function scanHexDigits(count: number, exact?: boolean): number { let digits = 0; let value = 0; while (digits < count || !exact) { let ch = text.charCodeAt(pos); if (ch >= CharacterCodes._0 && ch <= CharacterCodes._9) { value = value * 16 + ch - CharacterCodes._0; } else if (ch >= CharacterCodes.A && ch <= CharacterCodes.F) { value = value * 16 + ch - CharacterCodes.A + 10; } else if (ch >= CharacterCodes.a && ch <= CharacterCodes.f) { value = value * 16 + ch - CharacterCodes.a + 10; } else { break; } pos++; digits++; } if (digits < count) { value = -1; } return value; } function setPosition(newPosition: number) { pos = newPosition; value = ''; tokenOffset = 0; token = SyntaxKind.Unknown; scanError = ScanError.None; } function scanNumber(): string { let start = pos; if (text.charCodeAt(pos) === CharacterCodes._0) { pos++; } else { pos++; while (pos < text.length && isDigit(text.charCodeAt(pos))) { pos++; } } if (pos < text.length && text.charCodeAt(pos) === CharacterCodes.dot) { pos++; if (pos < text.length && isDigit(text.charCodeAt(pos))) { pos++; while (pos < text.length && isDigit(text.charCodeAt(pos))) { pos++; } } else { scanError = ScanError.UnexpectedEndOfNumber; return text.substring(start, pos); } } let end = pos; if (pos < text.length && (text.charCodeAt(pos) === CharacterCodes.E || text.charCodeAt(pos) === CharacterCodes.e)) { pos++; if (pos < text.length && text.charCodeAt(pos) === CharacterCodes.plus || text.charCodeAt(pos) === CharacterCodes.minus) { pos++; } if (pos < text.length && isDigit(text.charCodeAt(pos))) { pos++; while (pos < text.length && isDigit(text.charCodeAt(pos))) { pos++; } end = pos; } else { scanError = ScanError.UnexpectedEndOfNumber; } } return text.substring(start, end); } function scanString(): string { let result = '', start = pos; while (true) { if (pos >= len) { result += text.substring(start, pos); scanError = ScanError.UnexpectedEndOfString; break; } const ch = text.charCodeAt(pos); if (ch === CharacterCodes.doubleQuote) { result += text.substring(start, pos); pos++; break; } if (ch === CharacterCodes.backslash) { result += text.substring(start, pos); pos++; if (pos >= len) { scanError = ScanError.UnexpectedEndOfString; break; } const ch2 = text.charCodeAt(pos++); switch (ch2) { case CharacterCodes.doubleQuote: result += '\"'; break; case CharacterCodes.backslash: result += '\\'; break; case CharacterCodes.slash: result += '/'; break; case CharacterCodes.b: result += '\b'; break; case CharacterCodes.f: result += '\f'; break; case CharacterCodes.n: result += '\n'; break; case CharacterCodes.r: result += '\r'; break; case CharacterCodes.t: result += '\t'; break; case CharacterCodes.u: const ch3 = scanHexDigits(4, true); if (ch3 >= 0) { result += String.fromCharCode(ch3); } else { scanError = ScanError.InvalidUnicode; } break; default: scanError = ScanError.InvalidEscapeCharacter; } start = pos; continue; } if (ch >= 0 && ch <= 0x1f) { if (isLineBreak(ch)) { result += text.substring(start, pos); scanError = ScanError.UnexpectedEndOfString; break; } else { scanError = ScanError.InvalidCharacter; // mark as error but continue with string } } pos++; } return result; } function scanNext(): SyntaxKind { value = ''; scanError = ScanError.None; tokenOffset = pos; lineStartOffset = lineNumber; prevTokenLineStartOffset = tokenLineStartOffset; if (pos >= len) { // at the end tokenOffset = len; return token = SyntaxKind.EOF; } let code = text.charCodeAt(pos); // trivia: whitespace if (isWhiteSpace(code)) { do { pos++; value += String.fromCharCode(code); code = text.charCodeAt(pos); } while (isWhiteSpace(code)); return token = SyntaxKind.Trivia; } // trivia: newlines if (isLineBreak(code)) { pos++; value += String.fromCharCode(code); if (code === CharacterCodes.carriageReturn && text.charCodeAt(pos) === CharacterCodes.lineFeed) { pos++; value += '\n'; } lineNumber++; tokenLineStartOffset = pos; return token = SyntaxKind.LineBreakTrivia; } switch (code) { // tokens: []{}:, case CharacterCodes.openBrace: pos++; return token = SyntaxKind.OpenBraceToken; case CharacterCodes.closeBrace: pos++; return token = SyntaxKind.CloseBraceToken; case CharacterCodes.openBracket: pos++; return token = SyntaxKind.OpenBracketToken; case CharacterCodes.closeBracket: pos++; return token = SyntaxKind.CloseBracketToken; case CharacterCodes.colon: pos++; return token = SyntaxKind.ColonToken; case CharacterCodes.comma: pos++; return token = SyntaxKind.CommaToken; // strings case CharacterCodes.doubleQuote: pos++; value = scanString(); return token = SyntaxKind.StringLiteral; // comments case CharacterCodes.slash: const start = pos - 1; // Single-line comment if (text.charCodeAt(pos + 1) === CharacterCodes.slash) { pos += 2; while (pos < len) { if (isLineBreak(text.charCodeAt(pos))) { break; } pos++; } value = text.substring(start, pos); return token = SyntaxKind.LineCommentTrivia; } // Multi-line comment if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) { pos += 2; const safeLength = len - 1; // For lookahead. let commentClosed = false; while (pos < safeLength) { const ch = text.charCodeAt(pos); if (ch === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) { pos += 2; commentClosed = true; break; } pos++; if (isLineBreak(ch)) { if (ch === CharacterCodes.carriageReturn && text.charCodeAt(pos) === CharacterCodes.lineFeed) { pos++; } lineNumber++; tokenLineStartOffset = pos; } } if (!commentClosed) { pos++; scanError = ScanError.UnexpectedEndOfComment; } value = text.substring(start, pos); return token = SyntaxKind.BlockCommentTrivia; } // just a single slash value += String.fromCharCode(code); pos++; return token = SyntaxKind.Unknown; // numbers case CharacterCodes.minus: value += String.fromCharCode(code); pos++; if (pos === len || !isDigit(text.charCodeAt(pos))) { return token = SyntaxKind.Unknown; } // found a minus, followed by a number so // we fall through to proceed with scanning // numbers case CharacterCodes._0: case CharacterCodes._1: case CharacterCodes._2: case CharacterCodes._3: case CharacterCodes._4: case CharacterCodes._5: case CharacterCodes._6: case CharacterCodes._7: case CharacterCodes._8: case CharacterCodes._9: value += scanNumber(); return token = SyntaxKind.NumericLiteral; // literals and unknown symbols default: // is a literal? Read the full word. while (pos < len && isUnknownContentCharacter(code)) { pos++; code = text.charCodeAt(pos); } if (tokenOffset !== pos) { value = text.substring(tokenOffset, pos); // keywords: true, false, null switch (value) { case 'true': return token = SyntaxKind.TrueKeyword; case 'false': return token = SyntaxKind.FalseKeyword; case 'null': return token = SyntaxKind.NullKeyword; } return token = SyntaxKind.Unknown; } // some value += String.fromCharCode(code); pos++; return token = SyntaxKind.Unknown; } } function isUnknownContentCharacter(code: CharacterCodes) { if (isWhiteSpace(code) || isLineBreak(code)) { return false; } switch (code) { case CharacterCodes.closeBrace: case CharacterCodes.closeBracket: case CharacterCodes.openBrace: case CharacterCodes.openBracket: case CharacterCodes.doubleQuote: case CharacterCodes.colon: case CharacterCodes.comma: case CharacterCodes.slash: return false; } return true; } function scanNextNonTrivia(): SyntaxKind { let result: SyntaxKind; do { result = scanNext(); } while (result >= SyntaxKind.LineCommentTrivia && result <= SyntaxKind.Trivia); return result; } return { setPosition: setPosition, getPosition: () => pos, scan: ignoreTrivia ? scanNextNonTrivia : scanNext, getToken: () => token, getTokenValue: () => value, getTokenOffset: () => tokenOffset, getTokenLength: () => pos - tokenOffset, getTokenStartLine: () => lineStartOffset, getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset, getTokenError: () => scanError, }; } function isWhiteSpace(ch: number): boolean { return ch === CharacterCodes.space || ch === CharacterCodes.tab; } function isLineBreak(ch: number): boolean { return ch === CharacterCodes.lineFeed || ch === CharacterCodes.carriageReturn; } function isDigit(ch: number): boolean { return ch >= CharacterCodes._0 && ch <= CharacterCodes._9; } const enum CharacterCodes { lineFeed = 0x0A, // \n carriageReturn = 0x0D, // \r space = 0x0020, // " " _0 = 0x30, _1 = 0x31, _2 = 0x32, _3 = 0x33, _4 = 0x34, _5 = 0x35, _6 = 0x36, _7 = 0x37, _8 = 0x38, _9 = 0x39, a = 0x61, b = 0x62, c = 0x63, d = 0x64, e = 0x65, f = 0x66, g = 0x67, h = 0x68, i = 0x69, j = 0x6A, k = 0x6B, l = 0x6C, m = 0x6D, n = 0x6E, o = 0x6F, p = 0x70, q = 0x71, r = 0x72, s = 0x73, t = 0x74, u = 0x75, v = 0x76, w = 0x77, x = 0x78, y = 0x79, z = 0x7A, A = 0x41, B = 0x42, C = 0x43, D = 0x44, E = 0x45, F = 0x46, G = 0x47, H = 0x48, I = 0x49, J = 0x4A, K = 0x4B, L = 0x4C, M = 0x4D, N = 0x4E, O = 0x4F, P = 0x50, Q = 0x51, R = 0x52, S = 0x53, T = 0x54, U = 0x55, V = 0x56, W = 0x57, X = 0x58, Y = 0x59, Z = 0x5a, asterisk = 0x2A, // * backslash = 0x5C, // \ closeBrace = 0x7D, // } closeBracket = 0x5D, // ] colon = 0x3A, // : comma = 0x2C, // , dot = 0x2E, // . doubleQuote = 0x22, // " minus = 0x2D, // - openBrace = 0x7B, // { openBracket = 0x5B, // [ plus = 0x2B, // + slash = 0x2F, // / formFeed = 0x0C, // \f tab = 0x09, // \t } microsoft-node-jsonc-parser-3c9b420/src/impl/string-intern.ts000066400000000000000000000017471463635431300243220ustar00rootroot00000000000000export const cachedSpaces = new Array(20).fill(0).map((_, index) => { return ' '.repeat(index); }); const maxCachedValues = 200; export const cachedBreakLinesWithSpaces = { ' ': { '\n': new Array(maxCachedValues).fill(0).map((_, index) => { return '\n' + ' '.repeat(index); }), '\r': new Array(maxCachedValues).fill(0).map((_, index) => { return '\r' + ' '.repeat(index); }), '\r\n': new Array(maxCachedValues).fill(0).map((_, index) => { return '\r\n' + ' '.repeat(index); }), }, '\t': { '\n': new Array(maxCachedValues).fill(0).map((_, index) => { return '\n' + '\t'.repeat(index); }), '\r': new Array(maxCachedValues).fill(0).map((_, index) => { return '\r' + '\t'.repeat(index); }), '\r\n': new Array(maxCachedValues).fill(0).map((_, index) => { return '\r\n' + '\t'.repeat(index); }), } }; export const supportedEols = ['\n', '\r', '\r\n'] as const; export type SupportedEOL = '\n' | '\r' | '\r\n'; microsoft-node-jsonc-parser-3c9b420/src/main.ts000066400000000000000000000370271463635431300215020ustar00rootroot00000000000000/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import * as formatter from './impl/format'; import * as edit from './impl/edit'; import * as scanner from './impl/scanner'; import * as parser from './impl/parser'; /** * Creates a JSON scanner on the given text. * If ignoreTrivia is set, whitespaces or comments are ignored. */ export const createScanner: (text: string, ignoreTrivia?: boolean) => JSONScanner = scanner.createScanner; export const enum ScanError { None = 0, UnexpectedEndOfComment = 1, UnexpectedEndOfString = 2, UnexpectedEndOfNumber = 3, InvalidUnicode = 4, InvalidEscapeCharacter = 5, InvalidCharacter = 6 } export const enum SyntaxKind { OpenBraceToken = 1, CloseBraceToken = 2, OpenBracketToken = 3, CloseBracketToken = 4, CommaToken = 5, ColonToken = 6, NullKeyword = 7, TrueKeyword = 8, FalseKeyword = 9, StringLiteral = 10, NumericLiteral = 11, LineCommentTrivia = 12, BlockCommentTrivia = 13, LineBreakTrivia = 14, Trivia = 15, Unknown = 16, EOF = 17 } /** * The scanner object, representing a JSON scanner at a position in the input string. */ export interface JSONScanner { /** * Sets the scan position to a new offset. A call to 'scan' is needed to get the first token. */ setPosition(pos: number): void; /** * Read the next token. Returns the token code. */ scan(): SyntaxKind; /** * Returns the zero-based current scan position, which is after the last read token. */ getPosition(): number; /** * Returns the last read token. */ getToken(): SyntaxKind; /** * Returns the last read token value. The value for strings is the decoded string content. For numbers it's of type number, for boolean it's true or false. */ getTokenValue(): string; /** * The zero-based start offset of the last read token. */ getTokenOffset(): number; /** * The length of the last read token. */ getTokenLength(): number; /** * The zero-based start line number of the last read token. */ getTokenStartLine(): number; /** * The zero-based start character (column) of the last read token. */ getTokenStartCharacter(): number; /** * An error code of the last scan. */ getTokenError(): ScanError; } /** * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index. */ export const getLocation: (text: string, position: number) => Location = parser.getLocation; /** * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result. * Therefore, always check the errors list to find out if the input was valid. */ export const parse: (text: string, errors?: ParseError[], options?: ParseOptions) => any = parser.parse; /** * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result. */ export const parseTree: (text: string, errors?: ParseError[], options?: ParseOptions) => Node | undefined = parser.parseTree; /** * Finds the node at the given path in a JSON DOM. */ export const findNodeAtLocation: (root: Node, path: JSONPath) => Node | undefined = parser.findNodeAtLocation; /** * Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset. */ export const findNodeAtOffset: (root: Node, offset: number, includeRightBound?: boolean) => Node | undefined = parser.findNodeAtOffset; /** * Gets the JSON path of the given JSON DOM node */ export const getNodePath: (node: Node) => JSONPath = parser.getNodePath; /** * Evaluates the JavaScript object of the given JSON DOM node */ export const getNodeValue: (node: Node) => any = parser.getNodeValue; /** * Parses the given text and invokes the visitor functions for each object, array and literal reached. */ export const visit: (text: string, visitor: JSONVisitor, options?: ParseOptions) => any = parser.visit; /** * Takes JSON with JavaScript-style comments and remove * them. Optionally replaces every none-newline character * of comments with a replaceCharacter */ export const stripComments: (text: string, replaceCh?: string) => string = parser.stripComments; export interface ParseError { error: ParseErrorCode; offset: number; length: number; } export const enum ParseErrorCode { InvalidSymbol = 1, InvalidNumberFormat = 2, PropertyNameExpected = 3, ValueExpected = 4, ColonExpected = 5, CommaExpected = 6, CloseBraceExpected = 7, CloseBracketExpected = 8, EndOfFileExpected = 9, InvalidCommentToken = 10, UnexpectedEndOfComment = 11, UnexpectedEndOfString = 12, UnexpectedEndOfNumber = 13, InvalidUnicode = 14, InvalidEscapeCharacter = 15, InvalidCharacter = 16 } export function printParseErrorCode(code: ParseErrorCode) { switch (code) { case ParseErrorCode.InvalidSymbol: return 'InvalidSymbol'; case ParseErrorCode.InvalidNumberFormat: return 'InvalidNumberFormat'; case ParseErrorCode.PropertyNameExpected: return 'PropertyNameExpected'; case ParseErrorCode.ValueExpected: return 'ValueExpected'; case ParseErrorCode.ColonExpected: return 'ColonExpected'; case ParseErrorCode.CommaExpected: return 'CommaExpected'; case ParseErrorCode.CloseBraceExpected: return 'CloseBraceExpected'; case ParseErrorCode.CloseBracketExpected: return 'CloseBracketExpected'; case ParseErrorCode.EndOfFileExpected: return 'EndOfFileExpected'; case ParseErrorCode.InvalidCommentToken: return 'InvalidCommentToken'; case ParseErrorCode.UnexpectedEndOfComment: return 'UnexpectedEndOfComment'; case ParseErrorCode.UnexpectedEndOfString: return 'UnexpectedEndOfString'; case ParseErrorCode.UnexpectedEndOfNumber: return 'UnexpectedEndOfNumber'; case ParseErrorCode.InvalidUnicode: return 'InvalidUnicode'; case ParseErrorCode.InvalidEscapeCharacter: return 'InvalidEscapeCharacter'; case ParseErrorCode.InvalidCharacter: return 'InvalidCharacter'; } return ''; } export type NodeType = 'object' | 'array' | 'property' | 'string' | 'number' | 'boolean' | 'null'; export interface Node { readonly type: NodeType; readonly value?: any; readonly offset: number; readonly length: number; readonly colonOffset?: number; readonly parent?: Node; readonly children?: Node[]; } /** * A {@linkcode JSONPath} segment. Either a string representing an object property name * or a number (starting at 0) for array indices. */ export type Segment = string | number; export type JSONPath = Segment[]; export interface Location { /** * The previous property key or literal value (string, number, boolean or null) or undefined. */ previousNode?: Node; /** * The path describing the location in the JSON document. The path consists of a sequence of strings * representing an object property or numbers for array indices. */ path: JSONPath; /** * Matches the locations path against a pattern consisting of strings (for properties) and numbers (for array indices). * '*' will match a single segment of any property name or index. * '**' will match a sequence of segments of any property name or index, or no segment. */ matches: (patterns: JSONPath) => boolean; /** * If set, the location's offset is at a property key. */ isAtPropertyKey: boolean; } export interface ParseOptions { disallowComments?: boolean; allowTrailingComma?: boolean; allowEmptyContent?: boolean; } /** * Visitor called by {@linkcode visit} when parsing JSON. * * The visitor functions have the following common parameters: * - `offset`: Global offset within the JSON document, starting at 0 * - `startLine`: Line number, starting at 0 * - `startCharacter`: Start character (column) within the current line, starting at 0 * * Additionally some functions have a `pathSupplier` parameter which can be used to obtain the * current `JSONPath` within the document. */ export interface JSONVisitor { /** * Invoked when an open brace is encountered and an object is started. The offset and length represent the location of the open brace. * When `false` is returned, the object properties will not be visited. */ onObjectBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => boolean | void; /** * Invoked when a property is encountered. The offset and length represent the location of the property name. * The `JSONPath` created by the `pathSupplier` refers to the enclosing JSON object, it does not include the * property name yet. */ onObjectProperty?: (property: string, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void; /** * Invoked when a closing brace is encountered and an object is completed. The offset and length represent the location of the closing brace. */ onObjectEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void; /** * Invoked when an open bracket is encountered. The offset and length represent the location of the open bracket. * When `false` is returned, the array items will not be visited. */ onArrayBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => boolean | void; /** * Invoked when a closing bracket is encountered. The offset and length represent the location of the closing bracket. */ onArrayEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void; /** * Invoked when a literal value is encountered. The offset and length represent the location of the literal value. */ onLiteralValue?: (value: any, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void; /** * Invoked when a comma or colon separator is encountered. The offset and length represent the location of the separator. */ onSeparator?: (character: string, offset: number, length: number, startLine: number, startCharacter: number) => void; /** * When comments are allowed, invoked when a line or block comment is encountered. The offset and length represent the location of the comment. */ onComment?: (offset: number, length: number, startLine: number, startCharacter: number) => void; /** * Invoked on an error. */ onError?: (error: ParseErrorCode, offset: number, length: number, startLine: number, startCharacter: number) => void; } /** * An edit result describes a textual edit operation. It is the result of a {@linkcode format} and {@linkcode modify} operation. * It consist of one or more edits describing insertions, replacements or removals of text segments. * * The offsets of the edits refer to the original state of the document. * * No two edits change or remove the same range of text in the original document. * * Multiple edits can have the same offset if they are multiple inserts, or an insert followed by a remove or replace. * * The order in the array defines which edit is applied first. * To apply an edit result use {@linkcode applyEdits}. * In general multiple EditResults must not be concatenated because they might impact each other, producing incorrect or malformed JSON data. */ export type EditResult = Edit[]; /** * Represents a text modification */ export interface Edit { /** * The start offset of the modification. */ offset: number; /** * The length of the modification. Must not be negative. Empty length represents an *insert*. */ length: number; /** * The new content. Empty content represents a *remove*. */ content: string; } /** * A text range in the document */ export interface Range { /** * The start offset of the range. */ offset: number; /** * The length of the range. Must not be negative. */ length: number; } /** * Options used by {@linkcode format} when computing the formatting edit operations */ export interface FormattingOptions { /** * If indentation is based on spaces (`insertSpaces` = true), the number of spaces that make an indent. */ tabSize?: number; /** * Is indentation based on spaces? */ insertSpaces?: boolean; /** * The default 'end of line' character. If not set, '\n' is used as default. */ eol?: string; /** * If set, will add a new line at the end of the document. */ insertFinalNewline?: boolean; /** * If true, will keep line positions as is in the formatting */ keepLines?: boolean; } /** * Computes the edit operations needed to format a JSON document. * * @param documentText The input text * @param range The range to format or `undefined` to format the full content * @param options The formatting options * @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}. * To apply the edit operations to the input, use {@linkcode applyEdits}. */ export function format(documentText: string, range: Range | undefined, options: FormattingOptions): EditResult { return formatter.format(documentText, range, options); } /** * Options used by {@linkcode modify} when computing the modification edit operations */ export interface ModificationOptions { /** * Formatting options. If undefined, the newly inserted code will be inserted unformatted. */ formattingOptions?: FormattingOptions; /** * Default false. If `JSONPath` refers to an index of an array and `isArrayInsertion` is `true`, then * {@linkcode modify} will insert a new item at that location instead of overwriting its contents. */ isArrayInsertion?: boolean; /** * Optional function to define the insertion index given an existing list of properties. */ getInsertionIndex?: (properties: string[]) => number; } /** * Computes the edit operations needed to modify a value in the JSON document. * * @param documentText The input text * @param path The path of the value to change. The path represents either to the document root, a property or an array item. * If the path points to an non-existing property or item, it will be created. * @param value The new value for the specified property or item. If the value is undefined, * the property or item will be removed. * @param options Options * @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}. * To apply the edit operations to the input, use {@linkcode applyEdits}. */ export function modify(text: string, path: JSONPath, value: any, options: ModificationOptions): EditResult { return edit.setProperty(text, path, value, options); } /** * Applies edits to an input string. * @param text The input text * @param edits Edit operations following the format described in {@linkcode EditResult}. * @returns The text with the applied edits. * @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}. */ export function applyEdits(text: string, edits: EditResult): string { let sortedEdits = edits.slice(0).sort((a, b) => { const diff = a.offset - b.offset; if (diff === 0) { return a.length - b.length; } return diff; }); let lastModifiedOffset = text.length; for (let i = sortedEdits.length - 1; i >= 0; i--) { let e = sortedEdits[i]; if (e.offset + e.length <= lastModifiedOffset) { text = edit.applyEdit(text, e); } else { throw new Error('Overlapping edit'); } lastModifiedOffset = e.offset; } return text; } microsoft-node-jsonc-parser-3c9b420/src/test/000077500000000000000000000000001463635431300211545ustar00rootroot00000000000000microsoft-node-jsonc-parser-3c9b420/src/test/edit.test.ts000066400000000000000000000213361463635431300234340ustar00rootroot00000000000000/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import * as assert from 'assert'; import { FormattingOptions, Edit, ModificationOptions, modify } from '../main'; suite('JSON - edits', () => { function assertEdit(content: string, edits: Edit[], expected: string) { assert(edits); let lastEditOffset = content.length; for (let i = edits.length - 1; i >= 0; i--) { let edit = edits[i]; assert(edit.offset >= 0 && edit.length >= 0 && edit.offset + edit.length <= content.length); assert(typeof edit.content === 'string'); assert(lastEditOffset >= edit.offset + edit.length); // make sure all edits are ordered lastEditOffset = edit.offset; content = content.substring(0, edit.offset) + edit.content + content.substring(edit.offset + edit.length); } assert.strictEqual(content, expected); } let formattingOptions: FormattingOptions = { insertSpaces: true, tabSize: 2, eol: '\n', keepLines: false }; let formattingOptionsKeepLines: FormattingOptions = { insertSpaces: true, tabSize: 2, eol: '\n', keepLines: true }; let options: ModificationOptions = { formattingOptions }; let optionsKeepLines: ModificationOptions = { formattingOptions : formattingOptionsKeepLines }; test('set property', () => { let content = '{\n "x": "y"\n}'; let edits = modify(content, ['x'], 'bar', options); assertEdit(content, edits, '{\n "x": "bar"\n}'); content = 'true'; edits = modify(content, [], 'bar', options); assertEdit(content, edits, '"bar"'); content = '{\n "x": "y"\n}'; edits = modify(content, ['x'], { key: true }, options); assertEdit(content, edits, '{\n "x": {\n "key": true\n }\n}'); content = '{\n "a": "b", "x": "y"\n}'; edits = modify(content, ['a'], null, options); assertEdit(content, edits, '{\n "a": null, "x": "y"\n}'); }); test('insert property', () => { let content = '{}'; let edits = modify(content, ['foo'], 'bar', options); assertEdit(content, edits, '{\n "foo": "bar"\n}'); edits = modify(content, ['foo', 'foo2'], 'bar', options); assertEdit(content, edits, '{\n "foo": {\n "foo2": "bar"\n }\n}'); content = '{\n}'; edits = modify(content, ['foo'], 'bar', options); assertEdit(content, edits, '{\n "foo": "bar"\n}'); content = ' {\n }'; edits = modify(content, ['foo'], 'bar', options); assertEdit(content, edits, ' {\n "foo": "bar"\n }'); content = '{\n "x": "y"\n}'; edits = modify(content, ['foo'], 'bar', options); assertEdit(content, edits, '{\n "x": "y",\n "foo": "bar"\n}'); content = '{\n "x": "y"\n}'; edits = modify(content, ['e'], 'null', options); assertEdit(content, edits, '{\n "x": "y",\n "e": "null"\n}'); edits = modify(content, ['x'], 'bar', options); assertEdit(content, edits, '{\n "x": "bar"\n}'); content = '{\n "x": {\n "a": 1,\n "b": true\n }\n}\n'; edits = modify(content, ['x'], 'bar', options); assertEdit(content, edits, '{\n "x": "bar"\n}\n'); edits = modify(content, ['x', 'b'], 'bar', options); assertEdit(content, edits, '{\n "x": {\n "a": 1,\n "b": "bar"\n }\n}\n'); edits = modify(content, ['x', 'c'], 'bar', { formattingOptions, getInsertionIndex: () => 0 }); assertEdit(content, edits, '{\n "x": {\n "c": "bar",\n "a": 1,\n "b": true\n }\n}\n'); edits = modify(content, ['x', 'c'], 'bar', { formattingOptions, getInsertionIndex: () => 1 }); assertEdit(content, edits, '{\n "x": {\n "a": 1,\n "c": "bar",\n "b": true\n }\n}\n'); edits = modify(content, ['x', 'c'], 'bar', { formattingOptions, getInsertionIndex: () => 2 }); assertEdit(content, edits, '{\n "x": {\n "a": 1,\n "b": true,\n "c": "bar"\n }\n}\n'); edits = modify(content, ['c'], 'bar', options); assertEdit(content, edits, '{\n "x": {\n "a": 1,\n "b": true\n },\n "c": "bar"\n}\n'); content = '{\n "a": [\n {\n } \n ] \n}'; edits = modify(content, ['foo'], 'bar', options); assertEdit(content, edits, '{\n "a": [\n {\n } \n ],\n "foo": "bar"\n}'); content = ''; edits = modify(content, ['foo', 0], 'bar', options); assertEdit(content, edits, '{\n "foo": [\n "bar"\n ]\n}'); content = '//comment'; edits = modify(content, ['foo', 0], 'bar', options); assertEdit(content, edits, '{\n "foo": [\n "bar"\n ]\n} //comment'); }); test('remove property', () => { let content = '{\n "x": "y"\n}'; let edits = modify(content, ['x'], undefined, options); assertEdit(content, edits, '{\n}'); content = '{\n "x": "y", "a": []\n}'; edits = modify(content, ['x'], undefined, options); assertEdit(content, edits, '{\n "a": []\n}'); content = '{\n "x": "y", "a": []\n}'; edits = modify(content, ['a'], undefined, options); assertEdit(content, edits, '{\n "x": "y"\n}'); }); test('set item', () => { let content = '{\n "x": [1, 2, 3],\n "y": 0\n}'; let edits = modify(content, ['x', 0], 6, options); assertEdit(content, edits, '{\n "x": [6, 2, 3],\n "y": 0\n}'); edits = modify(content, ['x', 1], 5, options); assertEdit(content, edits, '{\n "x": [1, 5, 3],\n "y": 0\n}'); edits = modify(content, ['x', 2], 4, options); assertEdit(content, edits, '{\n "x": [1, 2, 4],\n "y": 0\n}'); edits = modify(content, ['x', 3], 3, options); assertEdit(content, edits, '{\n "x": [\n 1,\n 2,\n 3,\n 3\n ],\n "y": 0\n}'); }); test('insert item at 0; isArrayInsertion = true', () => { let content = '[\n 2,\n 3\n]'; let edits = modify(content, [0], 1, { formattingOptions, isArrayInsertion: true }); assertEdit(content, edits, '[\n 1,\n 2,\n 3\n]'); }); test('insert item at 0 in empty array', () => { let content = '[\n]'; let edits = modify(content, [0], 1, options); assertEdit(content, edits, '[\n 1\n]'); }); test('insert item at an index; isArrayInsertion = true', () => { let content = '[\n 1,\n 3\n]'; let edits = modify(content, [1], 2, { formattingOptions, isArrayInsertion: true }); assertEdit(content, edits, '[\n 1,\n 2,\n 3\n]'); }); test('insert item at an index in empty array', () => { let content = '[\n]'; let edits = modify(content, [1], 1, options); assertEdit(content, edits, '[\n 1\n]'); }); test('insert item at end index', () => { let content = '[\n 1,\n 2\n]'; let edits = modify(content, [2], 3, options); assertEdit(content, edits, '[\n 1,\n 2,\n 3\n]'); }); test('insert item at end to empty array', () => { let content = '[\n]'; let edits = modify(content, [-1], 'bar', options); assertEdit(content, edits, '[\n "bar"\n]'); }); test('insert item at end', () => { let content = '[\n 1,\n 2\n]'; let edits = modify(content, [-1], 'bar', options); assertEdit(content, edits, '[\n 1,\n 2,\n "bar"\n]'); }); test('remove item in array with one item', () => { let content = '[\n 1\n]'; let edits = modify(content, [0], void 0, options); assertEdit(content, edits, '[]'); }); test('remove item in the middle of the array', () => { let content = '[\n 1,\n 2,\n 3\n]'; let edits = modify(content, [1], void 0, options); assertEdit(content, edits, '[\n 1,\n 3\n]'); }); test('remove last item in the array', () => { let content = '[\n 1,\n 2,\n "bar"\n]'; let edits = modify(content, [2], void 0, options); assertEdit(content, edits, '[\n 1,\n 2\n]'); }); test('remove last item in the array if ends with comma', () => { let content = '[\n 1,\n "foo",\n "bar",\n]'; let edits = modify(content, [2], void 0, options); assertEdit(content, edits, '[\n 1,\n "foo"\n]'); }); test('remove last item in the array if there is a comment in the beginning', () => { let content = '// This is a comment\n[\n 1,\n "foo",\n "bar"\n]'; let edits = modify(content, [2], void 0, options); assertEdit(content, edits, '// This is a comment\n[\n 1,\n "foo"\n]'); }); test('set property without formatting', () => { let content = '{\n "x": [1, 2, 3],\n "y": 0\n}'; let edits = modify(content, ['x', 0], { a: 1, b: 2 }, { formattingOptions }); assertEdit(content, edits, '{\n "x": [{\n "a": 1,\n "b": 2\n }, 2, 3],\n "y": 0\n}'); edits = modify(content, ['x', 0], { a: 1, b: 2 }, { formattingOptions: undefined }); assertEdit(content, edits, '{\n "x": [{"a":1,"b":2}, 2, 3],\n "y": 0\n}'); }); // test added for the keepLines feature test('insert property when keepLines is true', () => { let content = '{}'; let edits = modify(content, ['foo', 'foo2'], 'bar', options); assertEdit(content, edits, '{\n "foo": {\n "foo2": "bar"\n }\n}'); }); });microsoft-node-jsonc-parser-3c9b420/src/test/format.test.ts000066400000000000000000000307021463635431300237740ustar00rootroot00000000000000/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import * as assert from 'assert'; import * as Formatter from '../impl/format'; import { Range } from '../main'; suite('JSON - formatter', () => { function format(content: string, expected: string, insertSpaces = true, insertFinalNewline = false, keepLines = false) { let range: Range | undefined = void 0; const rangeStart = content.indexOf('|'); const rangeEnd = content.lastIndexOf('|'); if (rangeStart !== -1 && rangeEnd !== -1) { content = content.substring(0, rangeStart) + content.substring(rangeStart + 1, rangeEnd) + content.substring(rangeEnd + 1); range = { offset: rangeStart, length: rangeEnd - rangeStart }; } const edits = Formatter.format(content, range, { tabSize: 2, insertSpaces, insertFinalNewline, eol: '\n', keepLines }); let lastEditOffset = content.length; for (let i = edits.length - 1; i >= 0; i--) { const edit = edits[i]; // assert(edit.offset >= 0 && edit.length >= 0 && edit.offset + edit.length <= content.length); // assert(typeof edit.content === 'string'); // assert(lastEditOffset >= edit.offset + edit.length); // make sure all edits are ordered lastEditOffset = edit.offset; content = content.substring(0, edit.offset) + edit.content + content.substring(edit.offset + edit.length); } assert.strictEqual(content, expected); } test('object - single property', () => { const content = [ '{"x" : 1}' ].join('\n'); const expected = [ '{', ' "x": 1', '}' ].join('\n'); format(content, expected); }); test('object - multiple properties', () => { const content = [ '{"x" : 1, "y" : "foo", "z" : true}' ].join('\n'); const expected = [ '{', ' "x": 1,', ' "y": "foo",', ' "z": true', '}' ].join('\n'); format(content, expected); }); test('object - no properties ', () => { const content = [ '{"x" : { }, "y" : {}}' ].join('\n'); const expected = [ '{', ' "x": {},', ' "y": {}', '}' ].join('\n'); format(content, expected); }); test('object - nesting', () => { const content = [ '{"x" : { "y" : { "z" : { }}, "a": true}}' ].join('\n'); const expected = [ '{', ' "x": {', ' "y": {', ' "z": {}', ' },', ' "a": true', ' }', '}' ].join('\n'); format(content, expected); }); test('array - single items', () => { const content = [ '["[]"]' ].join('\n'); const expected = [ '[', ' "[]"', ']' ].join('\n'); format(content, expected); }); test('array - multiple items', () => { const content = [ '[true,null,1.2]' ].join('\n'); const expected = [ '[', ' true,', ' null,', ' 1.2', ']' ].join('\n'); format(content, expected); }); test('array - no items', () => { const content = [ '[ ]' ].join('\n'); const expected = [ '[]' ].join('\n'); format(content, expected); }); test('array - nesting', () => { const content = [ '[ [], [ [ {} ], "a" ] ]' ].join('\n'); const expected = [ '[', ' [],', ' [', ' [', ' {}', ' ],', ' "a"', ' ]', ']', ].join('\n'); format(content, expected); }); test('syntax errors', () => { const content = [ '[ null 1.2 "Hello" ]' ].join('\n'); const expected = [ '[', ' null 1.2 "Hello"', ']', ].join('\n'); format(content, expected); }); test('syntax errors 2', () => { const content = [ '{"a":"b""c":"d" }' ].join('\n'); const expected = [ '{', ' "a": "b""c": "d"', '}', ].join('\n'); format(content, expected); }); test('empty lines', () => { const content = [ '{', '"a": true,', '', '"b": true', '}', ].join('\n'); const expected = [ '{', '\t"a": true,', '\t"b": true', '}', ].join('\n'); format(content, expected, false); }); test('single line comment', () => { const content = [ '[ ', '//comment', '"foo", "bar"', '] ' ].join('\n'); const expected = [ '[', ' //comment', ' "foo",', ' "bar"', ']', ].join('\n'); format(content, expected); }); test('block line comment', () => { const content = [ '[{', ' /*comment*/ ', '"foo" : true', '}] ' ].join('\n'); const expected = [ '[', ' {', ' /*comment*/', ' "foo": true', ' }', ']', ].join('\n'); format(content, expected); }); test('single line comment on same line', () => { const content = [ ' { ', ' "a": {}// comment ', ' } ' ].join('\n'); const expected = [ '{', ' "a": {} // comment ', '}', ].join('\n'); format(content, expected); }); test('single line comment on same line 2', () => { const content = [ '{ //comment', '}' ].join('\n'); const expected = [ '{ //comment', '}' ].join('\n'); format(content, expected); }); test('block comment on same line', () => { const content = [ '{ "a": {}, /*comment*/ ', ' /*comment*/ "b": {}, ', ' "c": {/*comment*/} } ', ].join('\n'); const expected = [ '{', ' "a": {}, /*comment*/', ' /*comment*/ "b": {},', ' "c": { /*comment*/}', '}', ].join('\n'); format(content, expected); }); test('block comment on same line advanced', () => { const content = [ ' { "d": [', ' null', ' ] /*comment*/', ' ,"e": /*comment*/ [null] }', ].join('\n'); const expected = [ '{', ' "d": [', ' null', ' ] /*comment*/,', ' "e": /*comment*/ [', ' null', ' ]', '}', ].join('\n'); format(content, expected); }); test('multiple block comments on same line', () => { const content = [ '{ "a": {} /*comment*/, /*comment*/ ', ' /*comment*/ "b": {} /*comment*/ } ' ].join('\n'); const expected = [ '{', ' "a": {} /*comment*/, /*comment*/', ' /*comment*/ "b": {} /*comment*/', '}', ].join('\n'); format(content, expected); }); test('multiple mixed comments on same line', () => { const content = [ '[ /*comment*/ /*comment*/ // comment ', ']' ].join('\n'); const expected = [ '[ /*comment*/ /*comment*/ // comment ', ']' ].join('\n'); format(content, expected); }); test('range', () => { const content = [ '{ "a": {},', '|"b": [null, null]|', '} ' ].join('\n'); const expected = [ '{ "a": {},', '"b": [', ' null,', ' null', ']', '} ', ].join('\n'); format(content, expected); }); test('range with existing indent', () => { const content = [ '{ "a": {},', ' |"b": [null],', '"c": {}', '}|' ].join('\n'); const expected = [ '{ "a": {},', ' "b": [', ' null', ' ],', ' "c": {}', '}', ].join('\n'); format(content, expected); }); test('range with existing indent - tabs', () => { const content = [ '{ "a": {},', '| "b": [null], ', '"c": {}', '}| ' ].join('\n'); const expected = [ '{ "a": {},', '\t"b": [', '\t\tnull', '\t],', '\t"c": {}', '}', ].join('\n'); format(content, expected, false); }); test('property range - issue 14623', () => { const content = [ '{ |"a" :| 1,', ' "b": 1', '}' ].join('\n'); const expected = [ '{ "a": 1,', ' "b": 1', '}' ].join('\n'); format(content, expected, false); }); test('block comment none-line breaking symbols', () => { const content = [ '{ "a": [ 1', '/* comment */', ', 2', '/* comment */', ']', '/* comment */', ',', ' "b": true', '/* comment */', '}' ].join('\n'); const expected = [ '{', ' "a": [', ' 1', ' /* comment */', ' ,', ' 2', ' /* comment */', ' ]', ' /* comment */', ' ,', ' "b": true', ' /* comment */', '}', ].join('\n'); format(content, expected); }); test('line comment after none-line breaking symbols', () => { const content = [ '{ "a":', '// comment', 'null,', ' "b"', '// comment', ': null', '// comment', '}' ].join('\n'); const expected = [ '{', ' "a":', ' // comment', ' null,', ' "b"', ' // comment', ' : null', ' // comment', '}', ].join('\n'); format(content, expected); }); test('line comment, enforce line comment ', () => { const content = [ '{"settings": // This is some text', '{', '"foo": 1', '}', '}' ].join('\n'); const expected = [ '{', ' "settings": // This is some text', ' {', ' "foo": 1', ' }', '}' ].join('\n'); format(content, expected); }); test('random content', () => { const content = [ 'a 1 b 1 3 true' ].join('\n'); const expected = [ 'a 1 b 1 3 true', ].join('\n'); format(content, expected); }); test('insertFinalNewline', () => { const content = [ '{', '}' ].join('\n'); const expected = [ '{}', '' ].join('\n'); format(content, expected, undefined, true); }); // tests added for the keepLines feature test('adjust the indentation of a one-line array', () => { const content = [ '{ "array": [1,2,3]', '}' ].join('\n'); const expected = [ '{ "array": [ 1, 2, 3 ]', '}' ].join('\n'); format(content, expected, true, false, true); }); test('adjust the indentation of a multi-line array', () => { const content = [ '{"array":', ' [1,2,', ' 3]', '}' ].join('\n'); const expected = [ '{ "array":', ' [ 1, 2,', ' 3 ]', '}' ].join('\n'); format(content, expected, true, false, true); }); test('adjust the identation of a one-line object', () => { const content = [ '{"settings": // This is some text', '{"foo": 1}', '}' ].join('\n'); const expected = [ '{ "settings": // This is some text', ' { "foo": 1 }', '}' ].join('\n'); format(content, expected, true, false, true); }); test('multiple line breaks are kept', () => { const content = [ '{"settings":', '', '', '', '{"foo": 1}', '}' ].join('\n'); const expected = [ '{ "settings":', '', '', '', ' { "foo": 1 }', '}' ].join('\n'); format(content, expected, true, false, true); }); test('adjusting multiple line breaks and a block comment, line breaks are kept', () => { const content = [ '{"settings":', '', '', '{"foo": 1} /* this is a multiline', 'comment */', '}' ].join('\n'); const expected = [ '{ "settings":', '', '', ' { "foo": 1 } /* this is a multiline', 'comment */', '}' ].join('\n'); format(content, expected, true, false, true); }); test('colon is kept on its own line', () => { const content = [ '{"settings"', ':', '{"foo"', ':', '1}', '}' ].join('\n'); const expected = [ '{ "settings"', ' :', ' { "foo"', ' :', ' 1 }', '}' ].join('\n'); format(content, expected, true, false, true); }); test('adjusting the indentation of a nested multi-line array', () => { const content = [ '{', '', '{', '', '"array" : [1, 2', '3, 4]', '}', '}' ].join('\n'); const expected = [ '{', '', ' {', '', ' "array": [ 1, 2', ' 3, 4 ]', ' }', '}' ].join('\n'); format(content, expected, true, false, true); }); test('adjusting the indentation for a series of empty arrays or objects', () => { const content = [ '{', '', '}', '', '{', '[', ']', '}' ].join('\n'); const expected = [ '{', '', '}', '', '{', ' [', ' ]', '}' ].join('\n'); format(content, expected, true, false, true); }); test('adjusting the indentation for a series of multiple empty lines at the end', () => { const content = [ '{', '}', '', '', '' ].join('\n'); const expected = [ '{', '}', '', '', '' ].join('\n'); format(content, expected, true, false, true); }); test('adjusting the indentation for comments on separate lines', () => { const content = [ '', '', '', ' // comment 1', '', '', '', ' /* comment 2 */', 'const' ].join('\n'); const expected = [ '', '', '', '// comment 1', '', '', '', '/* comment 2 */', 'const' ].join('\n'); format(content, expected, true, false, true); }); }); microsoft-node-jsonc-parser-3c9b420/src/test/json.test.ts000066400000000000000000001052771463635431300234670ustar00rootroot00000000000000/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import * as assert from 'assert'; import { SyntaxKind, createScanner, parse, getLocation, Node, ParseError, parseTree, ParseErrorCode, ParseOptions, Segment, findNodeAtLocation, getNodeValue, getNodePath, ScanError, visit, JSONVisitor, JSONPath } from '../main'; function assertKinds(text: string, ...kinds: SyntaxKind[]): void { var scanner = createScanner(text); var kind: SyntaxKind; while ((kind = scanner.scan()) !== SyntaxKind.EOF) { assert.strictEqual(kind, kinds.shift()); assert.strictEqual(scanner.getTokenError(), ScanError.None, text); } assert.strictEqual(kinds.length, 0); } function assertScanError(text: string, scanError: ScanError, ...kinds: SyntaxKind[]): void { var scanner = createScanner(text); scanner.scan(); assert.strictEqual(scanner.getToken(), kinds.shift()); assert.strictEqual(scanner.getTokenError(), scanError); var kind: SyntaxKind; while ((kind = scanner.scan()) !== SyntaxKind.EOF) { assert.strictEqual(kind, kinds.shift()); } assert.strictEqual(kinds.length, 0); } function assertValidParse(input: string, expected: any, options?: ParseOptions): void { var errors: ParseError[] = []; var actual = parse(input, errors, options); assert.deepStrictEqual([], errors); assert.deepStrictEqual(actual, expected); } function assertInvalidParse(input: string, expected: any, options?: ParseOptions): void { var errors: ParseError[] = []; var actual = parse(input, errors, options); assert(errors.length > 0); assert.deepStrictEqual(actual, expected); } function assertTree(input: string, expected: any, expectedErrors: ParseError[] = []): void { var errors: ParseError[] = []; var actual = parseTree(input, errors); assert.deepStrictEqual(errors, expectedErrors); let checkParent = (node: Node | undefined) => { if (node?.children) { for (let child of node.children) { assert.strictEqual(node, child.parent); delete (child).parent; // delete to avoid recursion in deep equal checkParent(child); } } }; checkParent(actual); assert.deepStrictEqual(actual, expected, JSON.stringify(actual)); } interface VisitorCallback { id: keyof JSONVisitor, text: string; startLine: number; startCharacter: number; arg?: any; path?: JSONPath; } interface VisitorError extends ParseError { startLine: number; startCharacter: number; } function assertVisit(input: string, expected: VisitorCallback[], expectedErrors: VisitorError[] = [], disallowComments = false, stopOffsets?: number[]): void { let errors: VisitorError[] = []; let actuals: VisitorCallback[] = []; let noArgHandler = (id: keyof JSONVisitor) => (offset: number, length: number, startLine: number, startCharacter: number) => actuals.push({ id, text: input.substr(offset, length), startLine, startCharacter }); let oneArgHandler = (id: keyof JSONVisitor) => (arg: any, offset: number, length: number, startLine: number, startCharacter: number) => actuals.push({ id, text: input.substr(offset, length), startLine, startCharacter, arg }); let oneArgHandlerWithPath = (id: keyof JSONVisitor) => (arg: any, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => actuals.push({ id, text: input.substr(offset, length), startLine, startCharacter, arg, path: pathSupplier() }); let beginHandler = (id: keyof JSONVisitor) => (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => { actuals.push({ id, text: input.substr(offset, length), startLine, startCharacter, path: pathSupplier() }); return !stopOffsets || (stopOffsets.indexOf(offset) === -1); }; visit(input, { onObjectBegin: beginHandler('onObjectBegin'), onObjectProperty: oneArgHandlerWithPath('onObjectProperty'), onObjectEnd: noArgHandler('onObjectEnd'), onArrayBegin: beginHandler('onArrayBegin'), onArrayEnd: noArgHandler('onArrayEnd'), onLiteralValue: oneArgHandlerWithPath('onLiteralValue'), onSeparator: oneArgHandler('onSeparator'), onComment: noArgHandler('onComment'), onError: (error: ParseErrorCode, offset: number, length: number, startLine: number, startCharacter: number) => { errors.push({ error, offset, length, startLine, startCharacter }); } }, { disallowComments }); assert.deepStrictEqual(errors, expectedErrors); assert.deepStrictEqual(actuals, expected, JSON.stringify(actuals)); } function assertNodeAtLocation(input: Node | undefined, segments: Segment[], expected: any) { let actual = input && findNodeAtLocation(input, segments); assert.deepEqual(actual ? getNodeValue(actual) : void 0, expected); if (actual) { assert.deepStrictEqual(getNodePath(actual), segments); } } function assertLocation(input: string, expectedSegments: Segment[], expectedNodeType: string | undefined, expectedCompleteProperty: boolean): void { var offset = input.indexOf('|'); input = input.substring(0, offset) + input.substring(offset + 1, input.length); var actual = getLocation(input, offset); assert(actual); assert.deepStrictEqual(actual.path, expectedSegments, input); assert.strictEqual(actual.previousNode && actual.previousNode.type, expectedNodeType, input); assert.strictEqual(actual.isAtPropertyKey, expectedCompleteProperty, input); } function assertMatchesLocation(input: string, matchingSegments: Segment[], expectedResult = true): void { var offset = input.indexOf('|'); input = input.substring(0, offset) + input.substring(offset + 1, input.length); var actual = getLocation(input, offset); assert(actual); assert.strictEqual(actual.matches(matchingSegments), expectedResult); } suite('JSON', () => { test('tokens', () => { assertKinds('{', SyntaxKind.OpenBraceToken); assertKinds('}', SyntaxKind.CloseBraceToken); assertKinds('[', SyntaxKind.OpenBracketToken); assertKinds(']', SyntaxKind.CloseBracketToken); assertKinds(':', SyntaxKind.ColonToken); assertKinds(',', SyntaxKind.CommaToken); }); test('comments', () => { assertKinds('// this is a comment', SyntaxKind.LineCommentTrivia); assertKinds('// this is a comment\n', SyntaxKind.LineCommentTrivia, SyntaxKind.LineBreakTrivia); assertKinds('/* this is a comment*/', SyntaxKind.BlockCommentTrivia); assertKinds('/* this is a \r\ncomment*/', SyntaxKind.BlockCommentTrivia); assertKinds('/* this is a \ncomment*/', SyntaxKind.BlockCommentTrivia); // unexpected end assertScanError('/* this is a', ScanError.UnexpectedEndOfComment, SyntaxKind.BlockCommentTrivia); assertScanError('/* this is a \ncomment', ScanError.UnexpectedEndOfComment, SyntaxKind.BlockCommentTrivia); // broken comment assertKinds('/ ttt', SyntaxKind.Unknown, SyntaxKind.Trivia, SyntaxKind.Unknown); }); test('strings', () => { assertKinds('"test"', SyntaxKind.StringLiteral); assertKinds('"\\""', SyntaxKind.StringLiteral); assertKinds('"\\/"', SyntaxKind.StringLiteral); assertKinds('"\\b"', SyntaxKind.StringLiteral); assertKinds('"\\f"', SyntaxKind.StringLiteral); assertKinds('"\\n"', SyntaxKind.StringLiteral); assertKinds('"\\r"', SyntaxKind.StringLiteral); assertKinds('"\\t"', SyntaxKind.StringLiteral); assertKinds('"\u88ff"', SyntaxKind.StringLiteral); assertKinds('"​\u2028"', SyntaxKind.StringLiteral); assertScanError('"\\v"', ScanError.InvalidEscapeCharacter, SyntaxKind.StringLiteral); // unexpected end assertScanError('"test', ScanError.UnexpectedEndOfString, SyntaxKind.StringLiteral); assertScanError('"test\n"', ScanError.UnexpectedEndOfString, SyntaxKind.StringLiteral, SyntaxKind.LineBreakTrivia, SyntaxKind.StringLiteral); // invalid characters assertScanError('"\t"', ScanError.InvalidCharacter, SyntaxKind.StringLiteral); assertScanError('"\t "', ScanError.InvalidCharacter, SyntaxKind.StringLiteral); assertScanError('"\0 "', ScanError.InvalidCharacter, SyntaxKind.StringLiteral); }); test('numbers', () => { assertKinds('0', SyntaxKind.NumericLiteral); assertKinds('0.1', SyntaxKind.NumericLiteral); assertKinds('-0.1', SyntaxKind.NumericLiteral); assertKinds('-1', SyntaxKind.NumericLiteral); assertKinds('1', SyntaxKind.NumericLiteral); assertKinds('123456789', SyntaxKind.NumericLiteral); assertKinds('10', SyntaxKind.NumericLiteral); assertKinds('90', SyntaxKind.NumericLiteral); assertKinds('90E+123', SyntaxKind.NumericLiteral); assertKinds('90e+123', SyntaxKind.NumericLiteral); assertKinds('90e-123', SyntaxKind.NumericLiteral); assertKinds('90E-123', SyntaxKind.NumericLiteral); assertKinds('90E123', SyntaxKind.NumericLiteral); assertKinds('90e123', SyntaxKind.NumericLiteral); // zero handling assertKinds('01', SyntaxKind.NumericLiteral, SyntaxKind.NumericLiteral); assertKinds('-01', SyntaxKind.NumericLiteral, SyntaxKind.NumericLiteral); // unexpected end assertKinds('-', SyntaxKind.Unknown); assertKinds('.0', SyntaxKind.Unknown); }); test('keywords: true, false, null', () => { assertKinds('true', SyntaxKind.TrueKeyword); assertKinds('false', SyntaxKind.FalseKeyword); assertKinds('null', SyntaxKind.NullKeyword); assertKinds('true false null', SyntaxKind.TrueKeyword, SyntaxKind.Trivia, SyntaxKind.FalseKeyword, SyntaxKind.Trivia, SyntaxKind.NullKeyword); // invalid words assertKinds('nulllll', SyntaxKind.Unknown); assertKinds('True', SyntaxKind.Unknown); assertKinds('foo-bar', SyntaxKind.Unknown); assertKinds('foo bar', SyntaxKind.Unknown, SyntaxKind.Trivia, SyntaxKind.Unknown); assertKinds('false//hello', SyntaxKind.FalseKeyword, SyntaxKind.LineCommentTrivia); }); test('trivia', () => { assertKinds(' ', SyntaxKind.Trivia); assertKinds(' \t ', SyntaxKind.Trivia); assertKinds(' \t \n \t ', SyntaxKind.Trivia, SyntaxKind.LineBreakTrivia, SyntaxKind.Trivia); assertKinds('\r\n', SyntaxKind.LineBreakTrivia); assertKinds('\r', SyntaxKind.LineBreakTrivia); assertKinds('\n', SyntaxKind.LineBreakTrivia); assertKinds('\n\r', SyntaxKind.LineBreakTrivia, SyntaxKind.LineBreakTrivia); assertKinds('\n \n', SyntaxKind.LineBreakTrivia, SyntaxKind.Trivia, SyntaxKind.LineBreakTrivia); }); test('parse: literals', () => { assertValidParse('true', true); assertValidParse('false', false); assertValidParse('null', null); assertValidParse('"foo"', 'foo'); assertValidParse('"\\"-\\\\-\\/-\\b-\\f-\\n-\\r-\\t"', '"-\\-/-\b-\f-\n-\r-\t'); assertValidParse('"\\u00DC"', 'Ü'); assertValidParse('9', 9); assertValidParse('-9', -9); assertValidParse('0.129', 0.129); assertValidParse('23e3', 23e3); assertValidParse('1.2E+3', 1.2E+3); assertValidParse('1.2E-3', 1.2E-3); assertValidParse('1.2E-3 // comment', 1.2E-3); }); test('parse: objects', () => { assertValidParse('{}', {}); assertValidParse('{ "foo": true }', { foo: true }); assertValidParse('{ "bar": 8, "xoo": "foo" }', { bar: 8, xoo: 'foo' }); assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} }); assertValidParse('{ "a": false, "b": true, "c": [ 7.4 ] }', { a: false, b: true, c: [7.4] }); assertValidParse('{ "lineComment": "//", "blockComment": ["/*", "*/"], "brackets": [ ["{", "}"], ["[", "]"], ["(", ")"] ] }', { lineComment: '//', blockComment: ['/*', '*/'], brackets: [['{', '}'], ['[', ']'], ['(', ')']] }); assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} }); assertValidParse('{ "hello": { "again": { "inside": 5 }, "world": 1 }}', { hello: { again: { inside: 5 }, world: 1 } }); assertValidParse('{ "foo": /*hello*/true }', { foo: true }); assertValidParse('{ "": true }', { '': true }); }); test('parse: arrays', () => { assertValidParse('[]', []); assertValidParse('[ [], [ [] ]]', [[], [[]]]); assertValidParse('[ 1, 2, 3 ]', [1, 2, 3]); assertValidParse('[ { "a": null } ]', [{ a: null }]); }); test('parse: objects with errors', () => { assertInvalidParse('{,}', {}); assertInvalidParse('{ "foo": true, }', { foo: true }); assertInvalidParse('{ "bar": 8 "xoo": "foo" }', { bar: 8, xoo: 'foo' }); assertInvalidParse('{ ,"bar": 8 }', { bar: 8 }); assertInvalidParse('{ ,"bar": 8, "foo" }', { bar: 8 }); assertInvalidParse('{ "bar": 8, "foo": }', { bar: 8 }); assertInvalidParse('{ 8, "foo": 9 }', { foo: 9 }); }); test('parse: array with errors', () => { assertInvalidParse('[,]', []); assertInvalidParse('[ 1 2, 3 ]', [1, 2, 3]); assertInvalidParse('[ ,1, 2, 3 ]', [1, 2, 3]); assertInvalidParse('[ ,1, 2, 3, ]', [1, 2, 3]); }); test('parse: errors', () => { assertInvalidParse('', undefined); assertInvalidParse('1,1', 1); }); test('parse: disallow comments', () => { let options = { disallowComments: true }; assertValidParse('[ 1, 2, null, "foo" ]', [1, 2, null, 'foo'], options); assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} }, options); assertInvalidParse('{ "foo": /*comment*/ true }', { foo: true }, options); }); test('parse: trailing comma', () => { let options = { allowTrailingComma: true }; assertValidParse('{ "hello": [], }', { hello: [] }, options); assertValidParse('{ "hello": [] }', { hello: [] }, options); assertValidParse('{ "hello": [], "world": {}, }', { hello: [], world: {} }, options); assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} }, options); assertValidParse('[ 1, 2, ]', [1, 2], options); assertValidParse('[ 1, 2 ]', [1, 2], options); assertInvalidParse('{ "hello": [], }', { hello: [] }); assertInvalidParse('{ "hello": [], "world": {}, }', { hello: [], world: {} }); assertInvalidParse('[ 1, 2, ]', [1, 2]); }); test('location: properties', () => { assertLocation('|{ "foo": "bar" }', [], void 0, false); assertLocation('{| "foo": "bar" }', [''], void 0, true); assertLocation('{ |"foo": "bar" }', ['foo'], 'property', true); assertLocation('{ "foo|": "bar" }', ['foo'], 'property', true); assertLocation('{ "foo"|: "bar" }', ['foo'], 'property', true); assertLocation('{ "foo": "bar"| }', ['foo'], 'string', false); assertLocation('{ "foo":| "bar" }', ['foo'], void 0, false); assertLocation('{ "foo": {"bar|": 1, "car": 2 } }', ['foo', 'bar'], 'property', true); assertLocation('{ "foo": {"bar": 1|, "car": 3 } }', ['foo', 'bar'], 'number', false); assertLocation('{ "foo": {"bar": 1,| "car": 4 } }', ['foo', ''], void 0, true); assertLocation('{ "foo": {"bar": 1, "ca|r": 5 } }', ['foo', 'car'], 'property', true); assertLocation('{ "foo": {"bar": 1, "car": 6| } }', ['foo', 'car'], 'number', false); assertLocation('{ "foo": {"bar": 1, "car": 7 }| }', ['foo'], void 0, false); assertLocation('{ "foo": {"bar": 1, "car": 8 },| "goo": {} }', [''], void 0, true); assertLocation('{ "foo": {"bar": 1, "car": 9 }, "go|o": {} }', ['goo'], 'property', true); assertLocation('{ "dep": {"bar": 1, "car": |', ['dep', 'car'], void 0, false); assertLocation('{ "dep": {"bar": 1,, "car": |', ['dep', 'car'], void 0, false); assertLocation('{ "dep": {"bar": "na", "dar": "ma", "car": | } }', ['dep', 'car'], void 0, false); }); test('location: arrays', () => { assertLocation('|["foo", null ]', [], void 0, false); assertLocation('[|"foo", null ]', [0], 'string', false); assertLocation('["foo"|, null ]', [0], 'string', false); assertLocation('["foo",| null ]', [1], void 0, false); assertLocation('["foo", |null ]', [1], 'null', false); assertLocation('["foo", null,| ]', [2], void 0, false); assertLocation('["foo", null,,| ]', [3], void 0, false); assertLocation('[["foo", null,, ],|', [1], void 0, false); }); test('tree: literals', () => { assertTree('true', { type: 'boolean', offset: 0, length: 4, value: true }); assertTree('false', { type: 'boolean', offset: 0, length: 5, value: false }); assertTree('null', { type: 'null', offset: 0, length: 4, value: null }); assertTree('23', { type: 'number', offset: 0, length: 2, value: 23 }); assertTree('-1.93e-19', { type: 'number', offset: 0, length: 9, value: -1.93e-19 }); assertTree('"hello"', { type: 'string', offset: 0, length: 7, value: 'hello' }); }); test('tree: arrays', () => { assertTree('[]', { type: 'array', offset: 0, length: 2, children: [] }); assertTree('[ 1 ]', { type: 'array', offset: 0, length: 5, children: [{ type: 'number', offset: 2, length: 1, value: 1 }] }); assertTree('[ 1,"x"]', { type: 'array', offset: 0, length: 8, children: [ { type: 'number', offset: 2, length: 1, value: 1 }, { type: 'string', offset: 4, length: 3, value: 'x' } ] }); assertTree('[[]]', { type: 'array', offset: 0, length: 4, children: [ { type: 'array', offset: 1, length: 2, children: [] } ] }); }); test('tree: objects', () => { assertTree('{ }', { type: 'object', offset: 0, length: 3, children: [] }); assertTree('{ "val": 1 }', { type: 'object', offset: 0, length: 12, children: [ { type: 'property', offset: 2, length: 8, colonOffset: 7, children: [ { type: 'string', offset: 2, length: 5, value: 'val' }, { type: 'number', offset: 9, length: 1, value: 1 } ] } ] }); assertTree('{"id": "$", "v": [ null, null] }', { type: 'object', offset: 0, length: 32, children: [ { type: 'property', offset: 1, length: 9, colonOffset: 5, children: [ { type: 'string', offset: 1, length: 4, value: 'id' }, { type: 'string', offset: 7, length: 3, value: '$' } ] }, { type: 'property', offset: 12, length: 18, colonOffset: 15, children: [ { type: 'string', offset: 12, length: 3, value: 'v' }, { type: 'array', offset: 17, length: 13, children: [ { type: 'null', offset: 19, length: 4, value: null }, { type: 'null', offset: 25, length: 4, value: null } ] } ] } ] } ); assertTree('{ "id": { "foo": { } } , }', { type: 'object', offset: 0, length: 27, children: [ { type: 'property', offset: 3, length: 20, colonOffset: 7, children: [ { type: 'string', offset: 3, length: 4, value: 'id' }, { type: 'object', offset: 9, length: 14, children: [ { type: 'property', offset: 11, length: 10, colonOffset: 16, children: [ { type: 'string', offset: 11, length: 5, value: 'foo' }, { type: 'object', offset: 18, length: 3, children: [] } ] } ] } ] } ] }, [ { error: ParseErrorCode.PropertyNameExpected, offset: 26, length: 1 }, { error: ParseErrorCode.ValueExpected, offset: 26, length: 1 } ]); }); test('visit: object', () => { assertVisit('{ }', [ { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 0, path: [] }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 2 }, ]); assertVisit('{ "foo": "bar" }', [ { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 0, path: [] }, { id: 'onObjectProperty', text: '"foo"', startLine: 0, startCharacter: 2, arg: 'foo', path: [] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 7, arg: ':' }, { id: 'onLiteralValue', text: '"bar"', startLine: 0, startCharacter: 9, arg: 'bar', path: ['foo'] }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 15 }, ]); assertVisit('{ "foo": { "goo": 3 } }', [ { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 0, path: [] }, { id: 'onObjectProperty', text: '"foo"', startLine: 0, startCharacter: 2, arg: 'foo', path: [] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 7, arg: ':' }, { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 9, path: ['foo'] }, { id: 'onObjectProperty', text: '"goo"', startLine: 0, startCharacter: 11, arg: 'goo', path: ['foo'] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 16, arg: ':' }, { id: 'onLiteralValue', text: '3', startLine: 0, startCharacter: 18, arg: 3, path: ['foo', 'goo'] }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 20 }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 22 }, ]); assertVisit('{ "foo": "bar", "a": {"b": "c"} }', [ { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 0, path: [] }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 32 }, ], [], false, [0]); assertVisit('{ "a": { "b": "c", "d": { "e": "f" } } }', [ { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 0, path: [] }, { id: 'onObjectProperty', text: '"a"', startLine: 0, startCharacter: 2, arg: 'a', path: [] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 5, arg: ':' }, { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 7, path: ['a'] }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 37 }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 39 } ], [], true, [7]); }); test('visit: array', () => { assertVisit('[]', [ { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 0, path: [] }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 1 }, ]); assertVisit('[ true, null, [] ]', [ { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 0, path: [] }, { id: 'onLiteralValue', text: 'true', startLine: 0, startCharacter: 2, arg: true, path: [0] }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 6, arg: ',' }, { id: 'onLiteralValue', text: 'null', startLine: 0, startCharacter: 8, arg: null, path: [1] }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 12, arg: ',' }, { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 14, path: [2] }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 15 }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 17 }, ]); assertVisit('[\r\n0,\r\n1,\r\n2\r\n]', [ { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 0, path: [] }, { id: 'onLiteralValue', text: '0', startLine: 1, startCharacter: 0, arg: 0, path: [0] }, { id: 'onSeparator', text: ',', startLine: 1, startCharacter: 1, arg: ',' }, { id: 'onLiteralValue', text: '1', startLine: 2, startCharacter: 0, arg: 1, path: [1] }, { id: 'onSeparator', text: ',', startLine: 2, startCharacter: 1, arg: ',' }, { id: 'onLiteralValue', text: '2', startLine: 3, startCharacter: 0, arg: 2, path: [2] }, { id: 'onArrayEnd', text: ']', startLine: 4, startCharacter: 0 }, ]); }); test('visit: object & array', () => { assertVisit('[ { "p1": [ { "p11": 1, "p12": [ true, [ false, 2 ] ] } ] } ]', [ { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 0, path: [] }, { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 2, path: [0] }, { id: 'onObjectProperty', text: '"p1"', startLine: 0, startCharacter: 4, arg: 'p1', path: [0] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 8, arg: ':' }, { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 10, path: [0, 'p1'] }, { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 12, path: [0, 'p1', 0] }, { id: 'onObjectProperty', text: '"p11"', startLine: 0, startCharacter: 14, arg: 'p11', path: [0, 'p1', 0] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 19, arg: ':' }, { id: 'onLiteralValue', text: '1', startLine: 0, startCharacter: 21, arg: 1, path: [0, 'p1', 0, 'p11'] }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 22, arg: ',' }, { id: 'onObjectProperty', text: '"p12"', startLine: 0, startCharacter: 24, arg: 'p12', path: [0, 'p1', 0] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 29, arg: ':' }, { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 31, path: [0, 'p1', 0, 'p12'] }, { id: 'onLiteralValue', text: 'true', startLine: 0, startCharacter: 33, arg: true, path: [0, 'p1', 0, 'p12', 0] }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 37, arg: ',' }, { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 39, path: [0, 'p1', 0, 'p12', 1] }, { id: 'onLiteralValue', text: 'false', startLine: 0, startCharacter: 41, arg: false, path: [0, 'p1', 0, 'p12', 1, 0] }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 46, arg: ',' }, { id: 'onLiteralValue', text: '2', startLine: 0, startCharacter: 48, arg: 2, path: [0, 'p1', 0, 'p12', 1, 1] }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 50 }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 52 }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 54 }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 56 }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 58 }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 60 }, ]); assertVisit('{ "foo": [ { "a": "b", "c:": "d", "d": { "e": "f" } } ] }', [ { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 0, path: [] }, { id: 'onObjectProperty', text: '"foo"', startLine: 0, startCharacter: 2, arg: 'foo', path: [] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 7, arg: ':' }, { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 9, path: ['foo'] }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 54 }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 56 } ], [], true, [9]); }); test('visit: comment', () => { assertVisit('/* g */ { "foo": //f\n"bar" }', [ { id: 'onComment', text: '/* g */', startLine: 0, startCharacter: 0 }, { id: 'onObjectBegin', text: '{', startLine: 0, startCharacter: 8, path: [] }, { id: 'onObjectProperty', text: '"foo"', startLine: 0, startCharacter: 10, arg: 'foo', path: [] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 15, arg: ':' }, { id: 'onComment', text: '//f', startLine: 0, startCharacter: 17 }, { id: 'onLiteralValue', text: '"bar"', startLine: 1, startCharacter: 0, arg: 'bar', path: ['foo'] }, { id: 'onObjectEnd', text: '}', startLine: 1, startCharacter: 6 }, ]); assertVisit('/* g\r\n */ { "foo": //f\n"bar" }', [ { id: 'onComment', text: '/* g\r\n */', startLine: 0, startCharacter: 0 }, { id: 'onObjectBegin', text: '{', startLine: 1, startCharacter: 4, path: [] }, { id: 'onObjectProperty', text: '"foo"', startLine: 1, startCharacter: 6, arg: 'foo', path: [] }, { id: 'onSeparator', text: ':', startLine: 1, startCharacter: 11, arg: ':' }, { id: 'onComment', text: '//f', startLine: 1, startCharacter: 13 }, { id: 'onLiteralValue', text: '"bar"', startLine: 2, startCharacter: 0, arg: 'bar', path: ['foo'] }, { id: 'onObjectEnd', text: '}', startLine: 2, startCharacter: 6 }, ]); assertVisit('/* g\n */ { "foo": //f\n"bar"\n}', [ { id: 'onObjectBegin', text: '{', startLine: 1, startCharacter: 4, path: [] }, { id: 'onObjectProperty', text: '"foo"', startLine: 1, startCharacter: 6, arg: 'foo', path: [] }, { id: 'onSeparator', text: ':', startLine: 1, startCharacter: 11, arg: ':' }, { id: 'onLiteralValue', text: '"bar"', startLine: 2, startCharacter: 0, arg: 'bar', path: ['foo'] }, { id: 'onObjectEnd', text: '}', startLine: 3, startCharacter: 0 }, ], [ { error: ParseErrorCode.InvalidCommentToken, offset: 0, length: 8, startLine: 0, startCharacter: 0 }, { error: ParseErrorCode.InvalidCommentToken, offset: 18, length: 3, startLine: 1, startCharacter: 13 }, ], true ); }); test('visit: malformed', () => { // Note: The expected visitor calls below heavily depend on implementation details; they don't // dictate how exactly malformed JSON should be parsed assertVisit('[ { "a", "b": [] 1, "c" [ 1 2 ], true: "d":, "e": }, 2, 3 4 ]', [ { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 0, path: [] }, { id: 'onObjectBegin', text: "{", startLine: 0, startCharacter: 2, path: [0] }, { id: 'onObjectProperty', text: '"a"', startLine: 0, startCharacter: 4, arg: 'a', path: [0] }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 7, arg: ',' }, { id: 'onObjectProperty', text: '"b"', startLine: 0, startCharacter: 9, arg: 'b', path: [0] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 12, arg: ':' }, { id: 'onArrayBegin', text: '[', startLine: 0, startCharacter: 14, path: [0, 'b'] }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 15 }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 18, arg: ',' }, { id: 'onObjectProperty', text: '"c"', startLine: 0, startCharacter: 20, arg: 'c', path: [0] }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 31, arg: ',' }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 43, arg: ',' }, { id: 'onObjectProperty', text: '"e"', startLine: 0, startCharacter: 45, arg: 'e', path: [0] }, { id: 'onSeparator', text: ':', startLine: 0, startCharacter: 48, arg: ':' }, { id: 'onObjectEnd', text: '}', startLine: 0, startCharacter: 50 }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 51, arg: ',' }, { id: 'onLiteralValue', text: '2', startLine: 0, startCharacter: 53, arg: 2, path: [1] }, { id: 'onSeparator', text: ',', startLine: 0, startCharacter: 54, arg: ',' }, { id: 'onLiteralValue', text: '3', startLine: 0, startCharacter: 56, arg: 3, path: [2] }, { id: 'onLiteralValue', text: '4', startLine: 0, startCharacter: 58, arg: 4, path: [3] }, { id: 'onArrayEnd', text: ']', startLine: 0, startCharacter: 60 }, ], [ { error: ParseErrorCode.ColonExpected, offset: 7, length: 1, startLine: 0, startCharacter: 7 }, { error: ParseErrorCode.CommaExpected, offset: 17, length: 1, startLine: 0, startCharacter: 17 }, { error: ParseErrorCode.PropertyNameExpected, offset: 17, length: 1, startLine: 0, startCharacter: 17 }, { error: ParseErrorCode.ValueExpected, offset: 18, length: 1, startLine: 0, startCharacter: 18 }, { error: ParseErrorCode.ColonExpected, offset: 24, length: 1, startLine: 0, startCharacter: 24 }, { error: ParseErrorCode.PropertyNameExpected, offset: 33, length: 4, startLine: 0, startCharacter: 33 }, { error: ParseErrorCode.ValueExpected, offset: 43, length: 1, startLine: 0, startCharacter: 43 }, { error: ParseErrorCode.ValueExpected, offset: 50, length: 1, startLine: 0, startCharacter: 50 }, { error: ParseErrorCode.CommaExpected, offset: 58, length: 1, startLine: 0, startCharacter: 58 }, ] ); }); test('visit: incomplete', () => { assertVisit('{"prop1":"foo","prop2":"foo2","prop3":{"prp1":{""}}}', [ { id: 'onObjectBegin', text: "{", startLine: 0, startCharacter: 0, path: [] }, { id: 'onObjectProperty', text: '"prop1"', startLine: 0, startCharacter: 1, arg: 'prop1', path: [] }, { id: 'onSeparator', text: ":", startLine: 0, startCharacter: 8, arg: ":" }, { id: 'onLiteralValue', text: '"foo"', startLine: 0, startCharacter: 9, arg: 'foo', path: ['prop1'] }, { id: 'onSeparator', text: ",", startLine: 0, startCharacter: 14, arg: "," }, { id: 'onObjectProperty', text: '"prop2"', startLine: 0, startCharacter: 15, arg: 'prop2', path: [] }, { id: 'onSeparator', text: ":", startLine: 0, startCharacter: 22, arg: ":" }, { id: 'onLiteralValue', text: '"foo2"', startLine: 0, startCharacter: 23, arg: 'foo2', path: ['prop2'] }, { id: 'onSeparator', text: ",", startLine: 0, startCharacter: 29, arg: "," }, { id: 'onObjectProperty', text: '"prop3"', startLine: 0, startCharacter: 30, arg: 'prop3', path: [] }, { id: 'onSeparator', text: ":", startLine: 0, startCharacter: 37, arg: ":" }, { id: 'onObjectBegin', text: "{", startLine: 0, startCharacter: 38, path: ['prop3'] }, { id: 'onObjectProperty', text: '"prp1"', startLine: 0, startCharacter: 39, arg: 'prp1', path: ['prop3'] }, { id: 'onSeparator', text: ":", startLine: 0, startCharacter: 45, arg: ':' }, { id: 'onObjectBegin', text: "{", startLine: 0, startCharacter: 46, path: ['prop3', 'prp1'] }, { id: 'onObjectProperty', text: '""', startLine: 0, startCharacter: 47, arg: '', path: ['prop3', 'prp1'] }, { id: 'onObjectEnd', text: "}", startLine: 0, startCharacter: 49 }, { id: 'onObjectEnd', text: "}", startLine: 0, startCharacter: 50 }, { id: 'onObjectEnd', text: "}", startLine: 0, startCharacter: 51 }, ], [ { error: ParseErrorCode.ColonExpected, offset: 49, length: 1, startLine: 0, startCharacter: 49 }, ] ); assertTree('{"prop1":"foo","prop2":"foo2","prop3":{"prp1":{""}}}', { type: 'object', offset: 0, length: 52, children: [ { type: 'property', offset: 1, length: 13, children: [ { type: 'string', value: 'prop1', offset: 1, length: 7 }, { type: 'string', offset: 9, length: 5, value: 'foo' } ], colonOffset: 8 }, { type: 'property', offset: 15, length: 14, children: [ { type: 'string', value: 'prop2', offset: 15, length: 7 }, { type: 'string', offset: 23, length: 6, value: 'foo2' } ], colonOffset: 22 }, { type: 'property', offset: 30, length: 21, children: [ { type: 'string', value: 'prop3', offset: 30, length: 7 }, { type: 'object', offset: 38, length: 13, children: [ { type: 'property', offset: 39, length: 11, children: [ { type: 'string', value: 'prp1', offset: 39, length: 6 }, { type: 'object', offset: 46, length: 4, children: [ { type: 'property', offset: 47, length: 3, children: [ { type: 'string', value: '', offset: 47, length: 2 }, ] } ] } ], colonOffset: 45 } ] } ], colonOffset: 37 } ] }, [{ error: ParseErrorCode.ColonExpected, offset: 49, length: 1 }]); }); test('tree: find location', () => { let root = parseTree('{ "key1": { "key11": [ "val111", "val112" ] }, "key2": [ { "key21": false, "key22": 221 }, null, [{}] ], "key3": { "key31":, "key32": 32 } }'); assertNodeAtLocation(root, ['key1'], { key11: ['val111', 'val112'] }); assertNodeAtLocation(root, ['key1', 'key11'], ['val111', 'val112']); assertNodeAtLocation(root, ['key1', 'key11', 0], 'val111'); assertNodeAtLocation(root, ['key1', 'key11', 1], 'val112'); assertNodeAtLocation(root, ['key1', 'key11', 2], void 0); assertNodeAtLocation(root, ['key2', 0, 'key21'], false); assertNodeAtLocation(root, ['key2', 0, 'key22'], 221); assertNodeAtLocation(root, ['key2', 1], null); assertNodeAtLocation(root, ['key2', 2], [{}]); assertNodeAtLocation(root, ['key2', 2, 0], {}); assertNodeAtLocation(root, ['key3', 'key31', 'key311'], undefined); assertNodeAtLocation(root, ['key3', 'key32'], 32); }); test('location: matches', () => { assertMatchesLocation('{ "dependencies": { | } }', ['dependencies']); assertMatchesLocation('{ "dependencies": { "fo| } }', ['dependencies']); assertMatchesLocation('{ "dependencies": { "fo|" } }', ['dependencies']); assertMatchesLocation('{ "dependencies": { "fo|": 1 } }', ['dependencies']); assertMatchesLocation('{ "dependencies": { "fo|": 1 } }', ['dependencies']); assertMatchesLocation('{ "dependencies": { "fo": | } }', ['dependencies', '*']); }); }); microsoft-node-jsonc-parser-3c9b420/src/test/string-intern.test.ts000066400000000000000000000013401463635431300253030ustar00rootroot00000000000000import { cachedBreakLinesWithSpaces, cachedSpaces, supportedEols } from '../impl/string-intern'; import * as assert from 'assert'; suite('string intern', () => { test('should correctly define spaces intern', () => { for (let i = 0; i < cachedSpaces.length; i++) { assert.strictEqual(cachedSpaces[i], ' '.repeat(i)); } }); test('should correctly define break lines with spaces intern', () => { for (const indentType of [' ', '\t'] as const) { for (const eol of supportedEols) { for (let i = 0; i < cachedBreakLinesWithSpaces[indentType][eol].length; i++) { assert.strictEqual(cachedBreakLinesWithSpaces[indentType][eol][i], eol + indentType.repeat(i)); } } } }); }); microsoft-node-jsonc-parser-3c9b420/src/tsconfig.esm.json000066400000000000000000000004151463635431300234670ustar00rootroot00000000000000{ "compilerOptions": { "target": "es2020", "module": "es6", "moduleResolution": "node", "sourceMap": true, "declaration": true, "stripInternal": true, "outDir": "../lib/esm", "strict": true, "preserveConstEnums": true, "lib": [ "es2020" ] } }microsoft-node-jsonc-parser-3c9b420/src/tsconfig.json000066400000000000000000000004151463635431300227040ustar00rootroot00000000000000{ "compilerOptions": { "target": "es2020", "module": "umd", "moduleResolution": "node", "sourceMap": true, "declaration": true, "stripInternal": true, "outDir": "../lib/umd", "strict": true, "preserveConstEnums": true, "lib": [ "es2020" ] } }