WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "Zeichen", verb: "zu haben" },
|
||||
file: { unit: "Bytes", verb: "zu haben" },
|
||||
array: { unit: "Elemente", verb: "zu haben" },
|
||||
set: { unit: "Elemente", verb: "zu haben" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "Eingabe",
|
||||
email: "E-Mail-Adresse",
|
||||
url: "URL",
|
||||
emoji: "Emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO-Datum und -Uhrzeit",
|
||||
date: "ISO-Datum",
|
||||
time: "ISO-Uhrzeit",
|
||||
duration: "ISO-Dauer",
|
||||
ipv4: "IPv4-Adresse",
|
||||
ipv6: "IPv6-Adresse",
|
||||
cidrv4: "IPv4-Bereich",
|
||||
cidrv6: "IPv6-Bereich",
|
||||
base64: "Base64-codierter String",
|
||||
base64url: "Base64-URL-codierter String",
|
||||
json_string: "JSON-String",
|
||||
e164: "E.164-Nummer",
|
||||
jwt: "JWT",
|
||||
template_literal: "Eingabe",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "Zahl",
|
||||
array: "Array",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Ungültige Eingabe: erwartet instanceof ${issue.expected}, erhalten ${received}`;
|
||||
}
|
||||
return `Ungültige Eingabe: erwartet ${expected}, erhalten ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Ungültige Eingabe: erwartet ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Ungültige Option: erwartet eine von ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "Elemente"} hat`;
|
||||
return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ist`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} hat`;
|
||||
}
|
||||
return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ist`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Ungültiger String: muss mit "${_issue.prefix}" beginnen`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Ungültiger String: muss mit "${_issue.suffix}" enden`;
|
||||
if (_issue.format === "includes")
|
||||
return `Ungültiger String: muss "${_issue.includes}" enthalten`;
|
||||
if (_issue.format === "regex")
|
||||
return `Ungültiger String: muss dem Muster ${_issue.pattern} entsprechen`;
|
||||
return `Ungültig: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Ungültige Zahl: muss ein Vielfaches von ${issue.divisor} sein`;
|
||||
case "unrecognized_keys":
|
||||
return `${issue.keys.length > 1 ? "Unbekannte Schlüssel" : "Unbekannter Schlüssel"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Ungültiger Schlüssel in ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Ungültige Eingabe";
|
||||
case "invalid_element":
|
||||
return `Ungültiger Wert in ${issue.origin}`;
|
||||
default:
|
||||
return `Ungültige Eingabe`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1,91 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as http from "http";
|
||||
|
||||
/**
|
||||
* Create a new connect server.
|
||||
*/
|
||||
declare function createServer(): createServer.Server;
|
||||
|
||||
declare namespace createServer {
|
||||
export type ServerHandle = HandleFunction | http.Server;
|
||||
|
||||
export class IncomingMessage extends http.IncomingMessage {
|
||||
originalUrl?: http.IncomingMessage["url"] | undefined;
|
||||
}
|
||||
|
||||
type NextFunction = (err?: any) => void;
|
||||
|
||||
export type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) => void;
|
||||
export type NextHandleFunction = (req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
|
||||
export type ErrorHandleFunction = (
|
||||
err: any,
|
||||
req: IncomingMessage,
|
||||
res: http.ServerResponse,
|
||||
next: NextFunction,
|
||||
) => void;
|
||||
export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
|
||||
|
||||
export interface ServerStackItem {
|
||||
route: string;
|
||||
handle: ServerHandle;
|
||||
}
|
||||
|
||||
export interface Server extends NodeJS.EventEmitter {
|
||||
(req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
|
||||
|
||||
route: string;
|
||||
stack: ServerStackItem[];
|
||||
|
||||
/**
|
||||
* Utilize the given middleware `handle` to the given `route`,
|
||||
* defaulting to _/_. This "route" is the mount-point for the
|
||||
* middleware, when given a value other than _/_ the middleware
|
||||
* is only effective when that segment is present in the request's
|
||||
* pathname.
|
||||
*
|
||||
* For example if we were to mount a function at _/admin_, it would
|
||||
* be invoked on _/admin_, and _/admin/settings_, however it would
|
||||
* not be invoked for _/_, or _/posts_.
|
||||
*/
|
||||
use(fn: NextHandleFunction): Server;
|
||||
use(fn: HandleFunction): Server;
|
||||
use(route: string, fn: NextHandleFunction): Server;
|
||||
use(route: string, fn: HandleFunction): Server;
|
||||
|
||||
/**
|
||||
* Handle server requests, punting them down
|
||||
* the middleware stack.
|
||||
*/
|
||||
handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void;
|
||||
|
||||
/**
|
||||
* Listen for connections.
|
||||
*
|
||||
* This method takes the same arguments
|
||||
* as node's `http.Server#listen()`.
|
||||
*
|
||||
* HTTP and HTTPS:
|
||||
*
|
||||
* If you run your application both as HTTP
|
||||
* and HTTPS you may wrap them individually,
|
||||
* since your Connect "server" is really just
|
||||
* a JavaScript `Function`.
|
||||
*
|
||||
* var connect = require('connect')
|
||||
* , http = require('http')
|
||||
* , https = require('https');
|
||||
*
|
||||
* var app = connect();
|
||||
*
|
||||
* http.createServer(app).listen(80);
|
||||
* https.createServer(options, app).listen(443);
|
||||
*/
|
||||
listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server;
|
||||
listen(port: number, hostname?: string, callback?: Function): http.Server;
|
||||
listen(path: string, callback?: Function): http.Server;
|
||||
listen(handle: any, listeningListener?: Function): http.Server;
|
||||
}
|
||||
}
|
||||
|
||||
export = createServer;
|
||||
@@ -0,0 +1,67 @@
|
||||
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from './codec';
|
||||
type NumberEncoder = Encoder<bigint | number> | Encoder<number>;
|
||||
type FixedSizeNumberEncoder<TSize extends number = number> = FixedSizeEncoder<bigint | number, TSize> | FixedSizeEncoder<number, TSize>;
|
||||
type NumberDecoder = Decoder<bigint> | Decoder<number>;
|
||||
type FixedSizeNumberDecoder<TSize extends number = number> = FixedSizeDecoder<bigint, TSize> | FixedSizeDecoder<number, TSize>;
|
||||
type NumberCodec = Codec<bigint | number, bigint> | Codec<number>;
|
||||
type FixedSizeNumberCodec<TSize extends number = number> = FixedSizeCodec<bigint | number, bigint, TSize> | FixedSizeCodec<number, number, TSize>;
|
||||
/**
|
||||
* Stores the size of the `encoder` in bytes as a prefix using the `prefix` encoder.
|
||||
*
|
||||
* See {@link addCodecSizePrefix} for more information.
|
||||
*
|
||||
* @typeParam TFrom - The type of the value to encode.
|
||||
*
|
||||
* @see {@link addCodecSizePrefix}
|
||||
*/
|
||||
export declare function addEncoderSizePrefix<TFrom>(encoder: FixedSizeEncoder<TFrom>, prefix: FixedSizeNumberEncoder): FixedSizeEncoder<TFrom>;
|
||||
export declare function addEncoderSizePrefix<TFrom>(encoder: Encoder<TFrom>, prefix: NumberEncoder): VariableSizeEncoder<TFrom>;
|
||||
/**
|
||||
* Bounds the size of the nested `decoder` by reading its encoded `prefix`.
|
||||
*
|
||||
* See {@link addCodecSizePrefix} for more information.
|
||||
*
|
||||
* @typeParam TTo - The type of the decoded value.
|
||||
*
|
||||
* @see {@link addCodecSizePrefix}
|
||||
*/
|
||||
export declare function addDecoderSizePrefix<TTo>(decoder: FixedSizeDecoder<TTo>, prefix: FixedSizeNumberDecoder): FixedSizeDecoder<TTo>;
|
||||
export declare function addDecoderSizePrefix<TTo>(decoder: Decoder<TTo>, prefix: NumberDecoder): VariableSizeDecoder<TTo>;
|
||||
/**
|
||||
* Stores the byte size of any given codec as an encoded number prefix.
|
||||
*
|
||||
* This sets a limit on variable-size codecs and tells us when to stop decoding.
|
||||
* When encoding, the size of the encoded data is stored before the encoded data itself.
|
||||
* When decoding, the size is read first to know how many bytes to read next.
|
||||
*
|
||||
* @typeParam TFrom - The type of the value to encode.
|
||||
* @typeParam TTo - The type of the decoded value.
|
||||
*
|
||||
* @example
|
||||
* For example, say we want to bound a variable-size base-58 string using a `u32` size prefix.
|
||||
* Here’s how you can use the `addCodecSizePrefix` function to achieve that.
|
||||
*
|
||||
* ```ts
|
||||
* const getU32Base58Codec = () => addCodecSizePrefix(getBase58Codec(), getU32Codec());
|
||||
*
|
||||
* getU32Base58Codec().encode('hello world');
|
||||
* // 0x0b00000068656c6c6f20776f726c64
|
||||
* // | └-- Our encoded base-58 string.
|
||||
* // └-- Our encoded u32 size prefix.
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
* Separate {@link addEncoderSizePrefix} and {@link addDecoderSizePrefix} functions are also available.
|
||||
*
|
||||
* ```ts
|
||||
* const bytes = addEncoderSizePrefix(getBase58Encoder(), getU32Encoder()).encode('hello');
|
||||
* const value = addDecoderSizePrefix(getBase58Decoder(), getU32Decoder()).decode(bytes);
|
||||
* ```
|
||||
*
|
||||
* @see {@link addEncoderSizePrefix}
|
||||
* @see {@link addDecoderSizePrefix}
|
||||
*/
|
||||
export declare function addCodecSizePrefix<TFrom, TTo extends TFrom>(codec: FixedSizeCodec<TFrom, TTo>, prefix: FixedSizeNumberCodec): FixedSizeCodec<TFrom, TTo>;
|
||||
export declare function addCodecSizePrefix<TFrom, TTo extends TFrom>(codec: Codec<TFrom, TTo>, prefix: NumberCodec): VariableSizeCodec<TFrom, TTo>;
|
||||
export {};
|
||||
//# sourceMappingURL=add-codec-size-prefix.d.ts.map
|
||||
@@ -0,0 +1,132 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "karakter", verb: "olmalı" },
|
||||
file: { unit: "bayt", verb: "olmalı" },
|
||||
array: { unit: "öğe", verb: "olmalı" },
|
||||
set: { unit: "öğe", verb: "olmalı" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "girdi",
|
||||
email: "e-posta adresi",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO tarih ve saat",
|
||||
date: "ISO tarih",
|
||||
time: "ISO saat",
|
||||
duration: "ISO süre",
|
||||
ipv4: "IPv4 adresi",
|
||||
ipv6: "IPv6 adresi",
|
||||
cidrv4: "IPv4 aralığı",
|
||||
cidrv6: "IPv6 aralığı",
|
||||
base64: "base64 ile şifrelenmiş metin",
|
||||
base64url: "base64url ile şifrelenmiş metin",
|
||||
json_string: "JSON dizesi",
|
||||
e164: "E.164 sayısı",
|
||||
jwt: "JWT",
|
||||
template_literal: "Şablon dizesi",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Geçersiz değer: beklenen instanceof ${issue.expected}, alınan ${received}`;
|
||||
}
|
||||
return `Geçersiz değer: beklenen ${expected}, alınan ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Geçersiz değer: beklenen ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Geçersiz seçenek: aşağıdakilerden biri olmalı: ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Çok büyük: beklenen ${issue.origin ?? "değer"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "öğe"}`;
|
||||
return `Çok büyük: beklenen ${issue.origin ?? "değer"} ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Çok küçük: beklenen ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
return `Çok küçük: beklenen ${issue.origin} ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Geçersiz metin: "${_issue.prefix}" ile başlamalı`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Geçersiz metin: "${_issue.suffix}" ile bitmeli`;
|
||||
if (_issue.format === "includes")
|
||||
return `Geçersiz metin: "${_issue.includes}" içermeli`;
|
||||
if (_issue.format === "regex")
|
||||
return `Geçersiz metin: ${_issue.pattern} desenine uymalı`;
|
||||
return `Geçersiz ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Geçersiz sayı: ${issue.divisor} ile tam bölünebilmeli`;
|
||||
case "unrecognized_keys":
|
||||
return `Tanınmayan anahtar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `${issue.origin} içinde geçersiz anahtar`;
|
||||
case "invalid_union":
|
||||
return "Geçersiz değer";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} içinde geçersiz değer`;
|
||||
default:
|
||||
return `Geçersiz değer`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"name": "@solana/web3.js",
|
||||
"version": "1.98.4",
|
||||
"description": "Solana Javascript API",
|
||||
"keywords": [
|
||||
"api",
|
||||
"blockchain"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
|
||||
"homepage": "https://solana.com/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/solana-foundation/solana-web3.js.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/solana-foundation/solana-web3.js.git/issues"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"browser": {
|
||||
"./lib/index.cjs.js": "./lib/index.browser.cjs.js",
|
||||
"./lib/index.esm.js": "./lib/index.browser.esm.js"
|
||||
},
|
||||
"react-native": "lib/index.native.js",
|
||||
"main": "lib/index.cjs.js",
|
||||
"module": "lib/index.esm.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"browserslist": [
|
||||
"defaults",
|
||||
"not IE 11",
|
||||
"maintained node versions"
|
||||
],
|
||||
"files": [
|
||||
"/lib",
|
||||
"/src"
|
||||
],
|
||||
"scripts": {
|
||||
"compile:docs": "typedoc --treatWarningsAsErrors",
|
||||
"compile:js": "cross-env NODE_ENV=production rollup -c",
|
||||
"compile:typedefs": "./scripts/typegen.sh",
|
||||
"build:fixtures": "set -ex; ./test/fixtures/noop-program/build.sh",
|
||||
"clean": "rimraf ./doc ./declarations ./lib",
|
||||
"dev": "cross-env NODE_ENV=development rollup -c --watch",
|
||||
"prepublishOnly": "pnpm pkg delete devDependencies",
|
||||
"publish-packages": "semantic-release --repository-url git@github.com:solana-foundation/solana-web3.js.git",
|
||||
"test:lint": "eslint src/ test/ --ext .js,.ts",
|
||||
"test:lint:fix": "eslint src/ test/ --fix --ext .js,.ts",
|
||||
"test:live": "TEST_LIVE=1 pnpm run test:unit",
|
||||
"test:live-with-test-validator": "start-server-and-test './scripts/start-shared-test-validator.sh' http://127.0.0.1:8899/health test:live",
|
||||
"test:live-with-test-validator:setup": "./scripts/setup-test-validator.sh",
|
||||
"test:prettier": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
|
||||
"test:prettier:fix": "pnpm prettier --write '{,{src,test}/**/}*.{j,t}s'",
|
||||
"test:typecheck": "tsc --noEmit",
|
||||
"test:unit": "cross-env NODE_ENV=test NODE_OPTIONS='--import tsx' mocha './test/**/*.test.ts'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.25.0",
|
||||
"@noble/curves": "^1.4.2",
|
||||
"@noble/hashes": "^1.4.0",
|
||||
"@solana/buffer-layout": "^4.0.1",
|
||||
"@solana/codecs-numbers": "^2.1.0",
|
||||
"agentkeepalive": "^4.5.0",
|
||||
"bn.js": "^5.2.1",
|
||||
"borsh": "^0.7.0",
|
||||
"bs58": "^4.0.1",
|
||||
"buffer": "6.0.3",
|
||||
"fast-stable-stringify": "^1.0.0",
|
||||
"jayson": "^4.1.1",
|
||||
"node-fetch": "^2.7.0",
|
||||
"rpc-websockets": "^9.0.2",
|
||||
"superstruct": "^2.0.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const ts_api_utils_1 = require("ts-api-utils");
|
||||
const ts = __importStar(require("typescript"));
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'prefer-return-this-type',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce that `this` is used when only `this` type is returned',
|
||||
recommended: 'strict',
|
||||
requiresTypeChecking: true,
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
useThisType: 'Use `this` type instead.',
|
||||
},
|
||||
schema: [],
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
const services = (0, util_1.getParserServices)(context);
|
||||
const checker = services.program.getTypeChecker();
|
||||
function tryGetNameInType(name, typeNode) {
|
||||
if (typeNode.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
|
||||
typeNode.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
typeNode.typeName.name === name) {
|
||||
return typeNode;
|
||||
}
|
||||
if (typeNode.type === utils_1.AST_NODE_TYPES.TSUnionType) {
|
||||
for (const type of typeNode.types) {
|
||||
const found = tryGetNameInType(name, type);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function isThisSpecifiedInParameters(originalFunc) {
|
||||
const firstArg = originalFunc.params.at(0);
|
||||
return (firstArg?.type === utils_1.AST_NODE_TYPES.Identifier && firstArg.name === 'this');
|
||||
}
|
||||
function isFunctionReturningThis(originalFunc, originalClass) {
|
||||
if (isThisSpecifiedInParameters(originalFunc)) {
|
||||
return false;
|
||||
}
|
||||
const func = services.esTreeNodeToTSNodeMap.get(originalFunc);
|
||||
if (!func.body) {
|
||||
return false;
|
||||
}
|
||||
const classType = services.getTypeAtLocation(originalClass);
|
||||
if (func.body.kind !== ts.SyntaxKind.Block) {
|
||||
const type = checker.getTypeAtLocation(func.body);
|
||||
return classType.thisType === type;
|
||||
}
|
||||
let hasReturnThis = false;
|
||||
let hasReturnClassType = false;
|
||||
(0, util_1.forEachReturnStatement)(func.body, stmt => {
|
||||
const expr = stmt.expression;
|
||||
if (!expr) {
|
||||
return;
|
||||
}
|
||||
// fast check
|
||||
if (expr.kind === ts.SyntaxKind.ThisKeyword) {
|
||||
hasReturnThis = true;
|
||||
return;
|
||||
}
|
||||
const type = checker.getTypeAtLocation(expr);
|
||||
if (classType === type) {
|
||||
hasReturnClassType = true;
|
||||
return true;
|
||||
}
|
||||
if (classType.thisType === type) {
|
||||
hasReturnThis = true;
|
||||
return;
|
||||
}
|
||||
if ((0, ts_api_utils_1.isUnionType)(type) &&
|
||||
type.types.some(typePart => typePart === classType)) {
|
||||
hasReturnClassType = true;
|
||||
return true;
|
||||
}
|
||||
return;
|
||||
});
|
||||
return !hasReturnClassType && hasReturnThis;
|
||||
}
|
||||
function checkFunction(originalFunc, originalClass) {
|
||||
const className = originalClass.id?.name;
|
||||
if (!className || !originalFunc.returnType) {
|
||||
return;
|
||||
}
|
||||
const node = tryGetNameInType(className, originalFunc.returnType.typeAnnotation);
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
if (isFunctionReturningThis(originalFunc, originalClass)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'useThisType',
|
||||
fix: fixer => fixer.replaceText(node, 'this'),
|
||||
});
|
||||
}
|
||||
}
|
||||
function checkProperty(node) {
|
||||
if (!(node.value?.type === utils_1.AST_NODE_TYPES.FunctionExpression ||
|
||||
node.value?.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression)) {
|
||||
return;
|
||||
}
|
||||
checkFunction(node.value, node.parent.parent);
|
||||
}
|
||||
return {
|
||||
'ClassBody > AccessorProperty': checkProperty,
|
||||
'ClassBody > MethodDefinition'(node) {
|
||||
checkFunction(node.value, node.parent.parent);
|
||||
},
|
||||
'ClassBody > PropertyDefinition': checkProperty,
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"name": "@humanwhocodes/retry",
|
||||
"version": "0.4.3",
|
||||
"description": "A utility to retry failed async methods.",
|
||||
"type": "module",
|
||||
"main": "dist/retrier.cjs",
|
||||
"module": "dist/retrier.js",
|
||||
"types": "dist/retrier.d.ts",
|
||||
"exports": {
|
||||
"require": {
|
||||
"types": "./dist/retrier.d.cts",
|
||||
"default": "./dist/retrier.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/retrier.d.ts",
|
||||
"default": "./dist/retrier.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18.18"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint --fix"
|
||||
]
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/nzakas"
|
||||
},
|
||||
"scripts": {
|
||||
"build:cts-types": "node -e \"fs.copyFileSync('dist/retrier.d.ts', 'dist/retrier.d.cts')\"",
|
||||
"build": "rollup -c && tsc && npm run build:cts-types",
|
||||
"prepare": "npm run build",
|
||||
"lint": "eslint src/ tests/",
|
||||
"pretest": "npm run build",
|
||||
"test:unit": "mocha tests/retrier.test.js",
|
||||
"test:build": "node tests/pkg.test.cjs && node tests/pkg.test.mjs",
|
||||
"test:jsr": "npx jsr@latest publish --dry-run",
|
||||
"test:emfile": "node tools/check-emfile-handling.js",
|
||||
"test": "npm run test:unit && npm run test:build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/humanwhocodes/retry.git"
|
||||
},
|
||||
"keywords": [
|
||||
"nodejs",
|
||||
"retry",
|
||||
"async",
|
||||
"promises"
|
||||
],
|
||||
"author": "Nicholas C. Zaks",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^8.49.0",
|
||||
"@rollup/plugin-terser": "0.4.4",
|
||||
"@tsconfig/node16": "^16.1.1",
|
||||
"@types/mocha": "^10.0.3",
|
||||
"@types/node": "20.12.6",
|
||||
"eslint": "^8.21.0",
|
||||
"lint-staged": "15.2.1",
|
||||
"mocha": "^10.3.0",
|
||||
"rollup": "3.29.4",
|
||||
"typescript": "5.4.4",
|
||||
"yorkie": "2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
{{# def.definitions }}
|
||||
{{# def.errors }}
|
||||
{{# def.defaults }}
|
||||
{{# def.coerce }}
|
||||
|
||||
{{ /**
|
||||
* schema compilation (render) time:
|
||||
* it = { schema, RULES, _validate, opts }
|
||||
* it.validate - this template function,
|
||||
* it is used recursively to generate code for subschemas
|
||||
*
|
||||
* runtime:
|
||||
* "validate" is a variable name to which this function will be assigned
|
||||
* validateRef etc. are defined in the parent scope in index.js
|
||||
*/ }}
|
||||
|
||||
{{
|
||||
var $async = it.schema.$async === true
|
||||
, $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref')
|
||||
, $id = it.self._getId(it.schema);
|
||||
}}
|
||||
|
||||
{{
|
||||
if (it.opts.strictKeywords) {
|
||||
var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords);
|
||||
if ($unknownKwd) {
|
||||
var $keywordsMsg = 'unknown keyword: ' + $unknownKwd;
|
||||
if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg);
|
||||
else throw new Error($keywordsMsg);
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
{{? it.isTop }}
|
||||
var validate = {{?$async}}{{it.async = true;}}async {{?}}function(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
{{? $id && (it.opts.sourceCode || it.opts.processCode) }}
|
||||
{{= '/\*# sourceURL=' + $id + ' */' }}
|
||||
{{?}}
|
||||
{{?}}
|
||||
|
||||
{{? typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref) }}
|
||||
{{ var $keyword = 'false schema'; }}
|
||||
{{# def.setupKeyword }}
|
||||
{{? it.schema === false}}
|
||||
{{? it.isTop}}
|
||||
{{ $breakOnError = true; }}
|
||||
{{??}}
|
||||
var {{=$valid}} = false;
|
||||
{{?}}
|
||||
{{# def.error:'false schema' }}
|
||||
{{??}}
|
||||
{{? it.isTop}}
|
||||
{{? $async }}
|
||||
return data;
|
||||
{{??}}
|
||||
validate.errors = null;
|
||||
return true;
|
||||
{{?}}
|
||||
{{??}}
|
||||
var {{=$valid}} = true;
|
||||
{{?}}
|
||||
{{?}}
|
||||
|
||||
{{? it.isTop}}
|
||||
};
|
||||
return validate;
|
||||
{{?}}
|
||||
|
||||
{{ return out; }}
|
||||
{{?}}
|
||||
|
||||
|
||||
{{? it.isTop }}
|
||||
{{
|
||||
var $top = it.isTop
|
||||
, $lvl = it.level = 0
|
||||
, $dataLvl = it.dataLevel = 0
|
||||
, $data = 'data';
|
||||
it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
|
||||
it.baseId = it.baseId || it.rootId;
|
||||
delete it.isTop;
|
||||
|
||||
it.dataPathArr = [""];
|
||||
|
||||
if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
|
||||
var $defaultMsg = 'default is ignored in the schema root';
|
||||
if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
|
||||
else throw new Error($defaultMsg);
|
||||
}
|
||||
}}
|
||||
|
||||
var vErrors = null; {{ /* don't edit, used in replace */ }}
|
||||
var errors = 0; {{ /* don't edit, used in replace */ }}
|
||||
if (rootData === undefined) rootData = data; {{ /* don't edit, used in replace */ }}
|
||||
{{??}}
|
||||
{{
|
||||
var $lvl = it.level
|
||||
, $dataLvl = it.dataLevel
|
||||
, $data = 'data' + ($dataLvl || '');
|
||||
|
||||
if ($id) it.baseId = it.resolve.url(it.baseId, $id);
|
||||
|
||||
if ($async && !it.async) throw new Error('async schema in sync schema');
|
||||
}}
|
||||
|
||||
var errs_{{=$lvl}} = errors;
|
||||
{{?}}
|
||||
|
||||
{{
|
||||
var $valid = 'valid' + $lvl
|
||||
, $breakOnError = !it.opts.allErrors
|
||||
, $closingBraces1 = ''
|
||||
, $closingBraces2 = '';
|
||||
|
||||
var $errorKeyword;
|
||||
var $typeSchema = it.schema.type
|
||||
, $typeIsArray = Array.isArray($typeSchema);
|
||||
|
||||
if ($typeSchema && it.opts.nullable && it.schema.nullable === true) {
|
||||
if ($typeIsArray) {
|
||||
if ($typeSchema.indexOf('null') == -1)
|
||||
$typeSchema = $typeSchema.concat('null');
|
||||
} else if ($typeSchema != 'null') {
|
||||
$typeSchema = [$typeSchema, 'null'];
|
||||
$typeIsArray = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($typeIsArray && $typeSchema.length == 1) {
|
||||
$typeSchema = $typeSchema[0];
|
||||
$typeIsArray = false;
|
||||
}
|
||||
}}
|
||||
|
||||
{{## def.checkType:
|
||||
{{
|
||||
var $schemaPath = it.schemaPath + '.type'
|
||||
, $errSchemaPath = it.errSchemaPath + '/type'
|
||||
, $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
|
||||
}}
|
||||
|
||||
if ({{= it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true) }}) {
|
||||
#}}
|
||||
|
||||
{{? it.schema.$ref && $refKeywords }}
|
||||
{{? it.opts.extendRefs == 'fail' }}
|
||||
{{ throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)'); }}
|
||||
{{?? it.opts.extendRefs !== true }}
|
||||
{{
|
||||
$refKeywords = false;
|
||||
it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
|
||||
}}
|
||||
{{?}}
|
||||
{{?}}
|
||||
|
||||
{{? it.schema.$comment && it.opts.$comment }}
|
||||
{{= it.RULES.all.$comment.code(it, '$comment') }}
|
||||
{{?}}
|
||||
|
||||
{{? $typeSchema }}
|
||||
{{? it.opts.coerceTypes }}
|
||||
{{ var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema); }}
|
||||
{{?}}
|
||||
|
||||
{{ var $rulesGroup = it.RULES.types[$typeSchema]; }}
|
||||
{{? $coerceToTypes || $typeIsArray || $rulesGroup === true ||
|
||||
($rulesGroup && !$shouldUseGroup($rulesGroup)) }}
|
||||
{{
|
||||
var $schemaPath = it.schemaPath + '.type'
|
||||
, $errSchemaPath = it.errSchemaPath + '/type';
|
||||
}}
|
||||
{{# def.checkType }}
|
||||
{{? $coerceToTypes }}
|
||||
{{# def.coerceType }}
|
||||
{{??}}
|
||||
{{# def.error:'type' }}
|
||||
{{?}}
|
||||
}
|
||||
{{?}}
|
||||
{{?}}
|
||||
|
||||
|
||||
{{? it.schema.$ref && !$refKeywords }}
|
||||
{{= it.RULES.all.$ref.code(it, '$ref') }}
|
||||
{{? $breakOnError }}
|
||||
}
|
||||
if (errors === {{?$top}}0{{??}}errs_{{=$lvl}}{{?}}) {
|
||||
{{ $closingBraces2 += '}'; }}
|
||||
{{?}}
|
||||
{{??}}
|
||||
{{~ it.RULES:$rulesGroup }}
|
||||
{{? $shouldUseGroup($rulesGroup) }}
|
||||
{{? $rulesGroup.type }}
|
||||
if ({{= it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers) }}) {
|
||||
{{?}}
|
||||
{{? it.opts.useDefaults }}
|
||||
{{? $rulesGroup.type == 'object' && it.schema.properties }}
|
||||
{{# def.defaultProperties }}
|
||||
{{?? $rulesGroup.type == 'array' && Array.isArray(it.schema.items) }}
|
||||
{{# def.defaultItems }}
|
||||
{{?}}
|
||||
{{?}}
|
||||
{{~ $rulesGroup.rules:$rule }}
|
||||
{{? $shouldUseRule($rule) }}
|
||||
{{ var $code = $rule.code(it, $rule.keyword, $rulesGroup.type); }}
|
||||
{{? $code }}
|
||||
{{= $code }}
|
||||
{{? $breakOnError }}
|
||||
{{ $closingBraces1 += '}'; }}
|
||||
{{?}}
|
||||
{{?}}
|
||||
{{?}}
|
||||
{{~}}
|
||||
{{? $breakOnError }}
|
||||
{{= $closingBraces1 }}
|
||||
{{ $closingBraces1 = ''; }}
|
||||
{{?}}
|
||||
{{? $rulesGroup.type }}
|
||||
}
|
||||
{{? $typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes }}
|
||||
else {
|
||||
{{
|
||||
var $schemaPath = it.schemaPath + '.type'
|
||||
, $errSchemaPath = it.errSchemaPath + '/type';
|
||||
}}
|
||||
{{# def.error:'type' }}
|
||||
}
|
||||
{{?}}
|
||||
{{?}}
|
||||
|
||||
{{? $breakOnError }}
|
||||
if (errors === {{?$top}}0{{??}}errs_{{=$lvl}}{{?}}) {
|
||||
{{ $closingBraces2 += '}'; }}
|
||||
{{?}}
|
||||
{{?}}
|
||||
{{~}}
|
||||
{{?}}
|
||||
|
||||
{{? $breakOnError }} {{= $closingBraces2 }} {{?}}
|
||||
|
||||
{{? $top }}
|
||||
{{? $async }}
|
||||
if (errors === 0) return data; {{ /* don't edit, used in replace */ }}
|
||||
else throw new ValidationError(vErrors); {{ /* don't edit, used in replace */ }}
|
||||
{{??}}
|
||||
validate.errors = vErrors; {{ /* don't edit, used in replace */ }}
|
||||
return errors === 0; {{ /* don't edit, used in replace */ }}
|
||||
{{?}}
|
||||
};
|
||||
|
||||
return validate;
|
||||
{{??}}
|
||||
var {{=$valid}} = errors === errs_{{=$lvl}};
|
||||
{{?}}
|
||||
|
||||
{{
|
||||
function $shouldUseGroup($rulesGroup) {
|
||||
var rules = $rulesGroup.rules;
|
||||
for (var i=0; i < rules.length; i++)
|
||||
if ($shouldUseRule(rules[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
function $shouldUseRule($rule) {
|
||||
return it.schema[$rule.keyword] !== undefined ||
|
||||
($rule.implements && $ruleImplementsSomeKeyword($rule));
|
||||
}
|
||||
|
||||
function $ruleImplementsSomeKeyword($rule) {
|
||||
var impl = $rule.implements;
|
||||
for (var i=0; i < impl.length; i++)
|
||||
if (it.schema[impl[i]] !== undefined)
|
||||
return true;
|
||||
}
|
||||
}}
|
||||
@@ -0,0 +1,24 @@
|
||||
export {};
|
||||
|
||||
// These interfaces are absent from lib.webworker, so the conditionals use `onabort` rather than `onmessage`
|
||||
type _Storage = typeof globalThis extends { onabort: any } ? {} : Storage;
|
||||
interface Storage {
|
||||
readonly length: number;
|
||||
clear(): void;
|
||||
getItem(key: string): string | null;
|
||||
key(index: number): string | null;
|
||||
removeItem(key: string): void;
|
||||
setItem(key: string, value: string): void;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Storage extends _Storage {}
|
||||
var Storage: typeof globalThis extends { onabort: any; Storage: infer T } ? T : {
|
||||
prototype: Storage;
|
||||
new(): Storage;
|
||||
};
|
||||
|
||||
var localStorage: Storage;
|
||||
var sessionStorage: Storage;
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import { ModuleEvaluator, ModuleRunnerImportMeta, ModuleRunnerContext, EvaluatedModuleNode } from 'vite/module-runner';
|
||||
import { V as VitestEvaluatedModules } from './chunks/evaluatedModules.d.BxJ5omdx.js';
|
||||
import vm from 'node:vm';
|
||||
import { R as RuntimeRPC } from './chunks/rpc.d.B_8sPU0w.js';
|
||||
import '@vitest/runner';
|
||||
import '@vitest/snapshot';
|
||||
import './chunks/traces.d.D2T_R8rx.js';
|
||||
|
||||
type ModuleExecutionInfo = Map<string, ModuleExecutionInfoEntry>;
|
||||
interface ModuleExecutionInfoEntry {
|
||||
startOffset: number;
|
||||
/** The duration that was spent executing the module. */
|
||||
duration: number;
|
||||
/** The time that was spent executing the module itself and externalized imports. */
|
||||
selfTime: number;
|
||||
external?: boolean;
|
||||
importer?: string;
|
||||
}
|
||||
|
||||
declare class FileMap {
|
||||
private fsCache;
|
||||
private fsBufferCache;
|
||||
readFileAsync(path: string): Promise<string>;
|
||||
readFile(path: string): string;
|
||||
readBuffer(path: string): Buffer<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface ModuleEvaluateOptions {
|
||||
timeout?: vm.RunningScriptOptions["timeout"] | undefined;
|
||||
breakOnSigint?: vm.RunningScriptOptions["breakOnSigint"] | undefined;
|
||||
}
|
||||
type ModuleLinker = (specifier: string, referencingModule: VMModule, extra: {
|
||||
assert: object;
|
||||
}) => VMModule | Promise<VMModule>;
|
||||
type ModuleStatus = "unlinked" | "linking" | "linked" | "evaluating" | "evaluated" | "errored";
|
||||
declare class VMModule {
|
||||
dependencySpecifiers: readonly string[];
|
||||
error: any;
|
||||
identifier: string;
|
||||
context: vm.Context;
|
||||
namespace: object;
|
||||
status: ModuleStatus;
|
||||
evaluate(options?: ModuleEvaluateOptions): Promise<void>;
|
||||
link(linker: ModuleLinker): Promise<void>;
|
||||
}
|
||||
|
||||
interface ExternalModulesExecutorOptions {
|
||||
context: vm.Context;
|
||||
fileMap: FileMap;
|
||||
packageCache: Map<string, any>;
|
||||
transform: RuntimeRPC["transform"];
|
||||
interopDefault?: boolean;
|
||||
viteClientModule: Record<string, unknown>;
|
||||
}
|
||||
declare class ExternalModulesExecutor {
|
||||
#private;
|
||||
private options;
|
||||
private cjs;
|
||||
private esm;
|
||||
private vite;
|
||||
private context;
|
||||
private fs;
|
||||
private resolvers;
|
||||
constructor(options: ExternalModulesExecutorOptions);
|
||||
import(identifier: string): Promise<object>;
|
||||
require(identifier: string): any;
|
||||
createRequire(identifier: string): NodeJS.Require;
|
||||
importModuleDynamically: (specifier: string, referencer: VMModule) => Promise<VMModule>;
|
||||
resolveModule: (specifier: string, referencer: string) => Promise<VMModule>;
|
||||
resolve(specifier: string, parent: string): string;
|
||||
private getModuleInformation;
|
||||
private createModule;
|
||||
private get isNetworkSupported();
|
||||
}
|
||||
|
||||
declare module "vite/module-runner" {
|
||||
interface EvaluatedModuleNode {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
mockedExports?: Record<string, any>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "vite/module-runner" {
|
||||
interface EvaluatedModuleNode {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
mockedExports?: Record<string, any>;
|
||||
}
|
||||
}
|
||||
|
||||
interface VitestVmOptions {
|
||||
context: vm.Context;
|
||||
externalModulesExecutor: ExternalModulesExecutor;
|
||||
}
|
||||
|
||||
interface VitestModuleEvaluatorOptions {
|
||||
evaluatedModules?: VitestEvaluatedModules;
|
||||
interopDefault?: boolean | undefined;
|
||||
moduleExecutionInfo?: ModuleExecutionInfo;
|
||||
getCurrentTestFilepath?: () => string | undefined;
|
||||
compiledFunctionArgumentsNames?: string[];
|
||||
compiledFunctionArgumentsValues?: unknown[];
|
||||
}
|
||||
declare class VitestModuleEvaluator implements ModuleEvaluator {
|
||||
private options;
|
||||
stubs: Record<string, any>;
|
||||
env: ModuleRunnerImportMeta["env"];
|
||||
private vm;
|
||||
private compiledFunctionArgumentsNames?;
|
||||
private compiledFunctionArgumentsValues;
|
||||
private primitives;
|
||||
private debug;
|
||||
private _otel;
|
||||
private _evaluatedModules?;
|
||||
constructor(vmOptions?: VitestVmOptions | undefined, options?: VitestModuleEvaluatorOptions);
|
||||
private convertIdToImportUrl;
|
||||
runExternalModule(id: string): Promise<any>;
|
||||
runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
|
||||
private _createCJSGlobals;
|
||||
private _runInlinedModule;
|
||||
private createRequire;
|
||||
private shouldInterop;
|
||||
}
|
||||
declare function createImportMetaEnvProxy(): ModuleRunnerImportMeta["env"];
|
||||
declare function getDefaultRequestStubs(context?: vm.Context): Record<string, any>;
|
||||
declare function isPrimitive(v: any): boolean;
|
||||
declare function wrapId(id: string): string;
|
||||
declare function unwrapId(id: string): string;
|
||||
|
||||
export { VitestModuleEvaluator, createImportMetaEnvProxy, getDefaultRequestStubs, isPrimitive, unwrapId, wrapId };
|
||||
export type { VitestModuleEvaluatorOptions };
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sourcemap-codec.d.ts","sourceRoot":"","sources":["../src/sourcemap-codec.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,MAAM,gBAAgB,GACxB,CAAC,MAAM,CAAC,GACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAChC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,aAAa,EAAE,CAAC;AAEhD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAiD1D;AAUD,wBAAgB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAAC;AAC3D,wBAAgB,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC"}
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Colin McDonnell
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,30 @@
|
||||
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
||||
|
||||
type Inspect = (value: unknown, options: Options) => string;
|
||||
interface Options {
|
||||
showHidden: boolean;
|
||||
depth: number;
|
||||
colors: boolean;
|
||||
customInspect: boolean;
|
||||
showProxy: boolean;
|
||||
maxArrayLength: number;
|
||||
breakLength: number;
|
||||
truncate: number;
|
||||
seen: unknown[];
|
||||
inspect: Inspect;
|
||||
stylize: (value: string, styleType: string) => string;
|
||||
}
|
||||
type LoupeOptions = Partial<Options>;
|
||||
interface StringifyOptions extends PrettyFormatOptions {
|
||||
maxLength?: number;
|
||||
filterNode?: string | ((node: any) => boolean);
|
||||
}
|
||||
declare function stringify(object: unknown, maxDepth?: number, { maxLength, filterNode, ...options }?: StringifyOptions): string;
|
||||
declare const formatRegExp: RegExp;
|
||||
declare function format(...args: unknown[]): string;
|
||||
declare function browserFormat(...args: unknown[]): string;
|
||||
declare function inspect(obj: unknown, options?: LoupeOptions): string;
|
||||
declare function objDisplay(obj: unknown, options?: LoupeOptions): string;
|
||||
|
||||
export { browserFormat, format, formatRegExp, inspect, objDisplay, stringify };
|
||||
export type { LoupeOptions, StringifyOptions };
|
||||
@@ -0,0 +1,90 @@
|
||||
'use strict';
|
||||
|
||||
var MissingRefError = require('./error_classes').MissingRef;
|
||||
|
||||
module.exports = compileAsync;
|
||||
|
||||
|
||||
/**
|
||||
* Creates validating function for passed schema with asynchronous loading of missing schemas.
|
||||
* `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
|
||||
* @this Ajv
|
||||
* @param {Object} schema schema object
|
||||
* @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
|
||||
* @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
|
||||
* @return {Promise} promise that resolves with a validating function.
|
||||
*/
|
||||
function compileAsync(schema, meta, callback) {
|
||||
/* eslint no-shadow: 0 */
|
||||
/* global Promise */
|
||||
/* jshint validthis: true */
|
||||
var self = this;
|
||||
if (typeof this._opts.loadSchema != 'function')
|
||||
throw new Error('options.loadSchema should be a function');
|
||||
|
||||
if (typeof meta == 'function') {
|
||||
callback = meta;
|
||||
meta = undefined;
|
||||
}
|
||||
|
||||
var p = loadMetaSchemaOf(schema).then(function () {
|
||||
var schemaObj = self._addSchema(schema, undefined, meta);
|
||||
return schemaObj.validate || _compileAsync(schemaObj);
|
||||
});
|
||||
|
||||
if (callback) {
|
||||
p.then(
|
||||
function(v) { callback(null, v); },
|
||||
callback
|
||||
);
|
||||
}
|
||||
|
||||
return p;
|
||||
|
||||
|
||||
function loadMetaSchemaOf(sch) {
|
||||
var $schema = sch.$schema;
|
||||
return $schema && !self.getSchema($schema)
|
||||
? compileAsync.call(self, { $ref: $schema }, true)
|
||||
: Promise.resolve();
|
||||
}
|
||||
|
||||
|
||||
function _compileAsync(schemaObj) {
|
||||
try { return self._compile(schemaObj); }
|
||||
catch(e) {
|
||||
if (e instanceof MissingRefError) return loadMissingSchema(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
function loadMissingSchema(e) {
|
||||
var ref = e.missingSchema;
|
||||
if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
|
||||
|
||||
var schemaPromise = self._loadingSchemas[ref];
|
||||
if (!schemaPromise) {
|
||||
schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
|
||||
schemaPromise.then(removePromise, removePromise);
|
||||
}
|
||||
|
||||
return schemaPromise.then(function (sch) {
|
||||
if (!added(ref)) {
|
||||
return loadMetaSchemaOf(sch).then(function () {
|
||||
if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
|
||||
});
|
||||
}
|
||||
}).then(function() {
|
||||
return _compileAsync(schemaObj);
|
||||
});
|
||||
|
||||
function removePromise() {
|
||||
delete self._loadingSchemas[ref];
|
||||
}
|
||||
|
||||
function added(ref) {
|
||||
return self._refs[ref] || self._schemas[ref];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import type { $ZodStringFormats } from "../core/checks.js";
|
||||
import type * as errors from "../core/errors.js";
|
||||
import * as util from "../core/util.js";
|
||||
|
||||
const error: () => errors.$ZodErrorMap = () => {
|
||||
const Sizable: Record<string, { unit: string; verb: string }> = {
|
||||
string: { unit: "caractères", verb: "avoir" },
|
||||
file: { unit: "octets", verb: "avoir" },
|
||||
array: { unit: "éléments", verb: "avoir" },
|
||||
set: { unit: "éléments", verb: "avoir" },
|
||||
};
|
||||
|
||||
function getSizing(origin: string): { unit: string; verb: string } | null {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
|
||||
const FormatDictionary: {
|
||||
[k in $ZodStringFormats | (string & {})]?: string;
|
||||
} = {
|
||||
regex: "entrée",
|
||||
email: "adresse courriel",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "date-heure ISO",
|
||||
date: "date ISO",
|
||||
time: "heure ISO",
|
||||
duration: "durée ISO",
|
||||
ipv4: "adresse IPv4",
|
||||
ipv6: "adresse IPv6",
|
||||
cidrv4: "plage IPv4",
|
||||
cidrv6: "plage IPv6",
|
||||
base64: "chaîne encodée en base64",
|
||||
base64url: "chaîne encodée en base64url",
|
||||
json_string: "chaîne JSON",
|
||||
e164: "numéro E.164",
|
||||
jwt: "JWT",
|
||||
template_literal: "entrée",
|
||||
};
|
||||
|
||||
const TypeDictionary: {
|
||||
[k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
|
||||
} = {
|
||||
nan: "NaN",
|
||||
};
|
||||
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Entrée invalide : attendu instanceof ${issue.expected}, reçu ${received}`;
|
||||
}
|
||||
return `Entrée invalide : attendu ${expected}, reçu ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1) return `Entrée invalide : attendu ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Option invalide : attendu l'une des valeurs suivantes ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "≤" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Trop grand : attendu que ${issue.origin ?? "la valeur"} ait ${adj}${issue.maximum.toString()} ${sizing.unit}`;
|
||||
return `Trop grand : attendu que ${issue.origin ?? "la valeur"} soit ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? "≥" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Trop petit : attendu que ${issue.origin} ait ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
|
||||
return `Trop petit : attendu que ${issue.origin} soit ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue as errors.$ZodStringFormatIssues;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Chaîne invalide : doit commencer par "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with") return `Chaîne invalide : doit se terminer par "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes") return `Chaîne invalide : doit inclure "${_issue.includes}"`;
|
||||
if (_issue.format === "regex") return `Chaîne invalide : doit correspondre au motif ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} invalide`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Nombre invalide : doit être un multiple de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Clé${issue.keys.length > 1 ? "s" : ""} non reconnue${issue.keys.length > 1 ? "s" : ""} : ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Clé invalide dans ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Entrée invalide";
|
||||
case "invalid_element":
|
||||
return `Valeur invalide dans ${issue.origin}`;
|
||||
default:
|
||||
return `Entrée invalide`;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export default function (): { localeError: errors.$ZodErrorMap } {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
var _get_prototype_of = require("./_get_prototype_of.cjs");
|
||||
var _is_native_reflect_construct = require("./_is_native_reflect_construct.cjs");
|
||||
var _possible_constructor_return = require("./_possible_constructor_return.cjs");
|
||||
|
||||
function _create_super(Derived) {
|
||||
var hasNativeReflectConstruct = _is_native_reflect_construct._();
|
||||
|
||||
return function _createSuperInternal() {
|
||||
var Super = _get_prototype_of._(Derived), result;
|
||||
|
||||
if (hasNativeReflectConstruct) {
|
||||
var NewTarget = _get_prototype_of._(this).constructor;
|
||||
result = Reflect.construct(Super, arguments, NewTarget);
|
||||
} else {
|
||||
result = Super.apply(this, arguments);
|
||||
}
|
||||
|
||||
return _possible_constructor_return._(this, result);
|
||||
};
|
||||
}
|
||||
exports._ = _create_super;
|
||||
@@ -0,0 +1,366 @@
|
||||
[](https://www.npmjs.com/package/eslint)
|
||||
[](https://www.npmjs.com/package/eslint)
|
||||
[](https://github.com/eslint/eslint/actions)
|
||||
<br>
|
||||
[](https://opencollective.com/eslint)
|
||||
[](https://opencollective.com/eslint)
|
||||
|
||||
# ESLint
|
||||
|
||||
[Website](https://eslint.org) |
|
||||
[Configure ESLint](https://eslint.org/docs/latest/use/configure) |
|
||||
[Rules](https://eslint.org/docs/rules/) |
|
||||
[Contribute to ESLint](https://eslint.org/docs/latest/contribute) |
|
||||
[Report Bugs](https://eslint.org/docs/latest/contribute/report-bugs) |
|
||||
[Code of Conduct](https://eslint.org/conduct) |
|
||||
[X](https://x.com/geteslint) |
|
||||
[Discord](https://eslint.org/chat) |
|
||||
[Mastodon](https://fosstodon.org/@eslint) |
|
||||
[Bluesky](https://bsky.app/profile/eslint.org)
|
||||
|
||||
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. In many ways, it is similar to JSLint and JSHint with a few exceptions:
|
||||
|
||||
- ESLint uses [Espree](https://github.com/eslint/js/tree/main/packages/espree) for JavaScript parsing.
|
||||
- ESLint uses an AST to evaluate patterns in code.
|
||||
- ESLint is completely pluggable, every single rule is a plugin and you can add more at runtime.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
1. [Installation and Usage](#installation-and-usage)
|
||||
1. [Configuration](#configuration)
|
||||
1. [Version Support](#version-support)
|
||||
1. [Code of Conduct](#code-of-conduct)
|
||||
1. [Filing Issues](#filing-issues)
|
||||
1. [Frequently Asked Questions](#frequently-asked-questions)
|
||||
1. [Releases](#releases)
|
||||
1. [Security Policy](#security-policy)
|
||||
1. [Semantic Versioning Policy](#semantic-versioning-policy)
|
||||
1. [ESM Dependencies](#esm-dependencies)
|
||||
1. [License](#license)
|
||||
1. [Team](#team)
|
||||
1. [Sponsors](#sponsors)
|
||||
1. [Technology Sponsors](#technology-sponsors) <!-- markdownlint-disable-line MD051 -->
|
||||
|
||||
## Installation and Usage
|
||||
|
||||
### Prerequisites
|
||||
|
||||
To use ESLint, you must have [Node.js](https://nodejs.org/) (`^20.19.0`, `^22.13.0`, or `>=24`) installed and built with SSL and ICU support. (If you are using an official Node.js distribution, both SSL and ICU are always built in.)
|
||||
|
||||
If you use ESLint's TypeScript type definitions, TypeScript 5.3 or later is required.
|
||||
|
||||
### npm Installation
|
||||
|
||||
You can install and configure ESLint using this command:
|
||||
|
||||
```shell
|
||||
npm init @eslint/config@latest
|
||||
```
|
||||
|
||||
After that, you can run ESLint on any file or directory like this:
|
||||
|
||||
```shell
|
||||
npx eslint yourfile.js
|
||||
```
|
||||
|
||||
### pnpm Installation
|
||||
|
||||
To use ESLint with pnpm, we recommend setting up a `.npmrc` file with at least the following settings:
|
||||
|
||||
```text
|
||||
auto-install-peers=true
|
||||
node-linker=hoisted
|
||||
```
|
||||
|
||||
This ensures that pnpm installs dependencies in a way that is more compatible with npm and is less likely to produce errors.
|
||||
|
||||
## Configuration
|
||||
|
||||
You can configure rules in your `eslint.config.js` files as in this example:
|
||||
|
||||
```js
|
||||
import { defineConfig } from "eslint/config";
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
|
||||
rules: {
|
||||
"prefer-const": "warn",
|
||||
"no-constant-binary-expression": "error",
|
||||
},
|
||||
},
|
||||
]);
|
||||
```
|
||||
|
||||
The names `"prefer-const"` and `"no-constant-binary-expression"` are the names of [rules](https://eslint.org/docs/rules) in ESLint. The first value is the error level of the rule and can be one of these values:
|
||||
|
||||
- `"off"` or `0` - turn the rule off
|
||||
- `"warn"` or `1` - turn the rule on as a warning (doesn't affect exit code)
|
||||
- `"error"` or `2` - turn the rule on as an error (exit code will be 1)
|
||||
|
||||
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the [configuration docs](https://eslint.org/docs/latest/use/configure)).
|
||||
|
||||
## Version Support
|
||||
|
||||
The ESLint team provides ongoing support for the current version and six months of limited support for the previous version. Limited support includes critical bug fixes, security issues, and compatibility issues only.
|
||||
|
||||
ESLint offers commercial support for both current and previous versions through our partners, [Tidelift][tidelift] and [HeroDevs][herodevs].
|
||||
|
||||
See [Version Support](https://eslint.org/version-support) for more details.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
ESLint adheres to the [OpenJS Foundation Code of Conduct](https://eslint.org/conduct).
|
||||
|
||||
## Filing Issues
|
||||
|
||||
Before filing an issue, please be sure to read the guidelines for what you're reporting:
|
||||
|
||||
- [Bug Report](https://eslint.org/docs/latest/contribute/report-bugs)
|
||||
- [Propose a New Rule](https://eslint.org/docs/latest/contribute/propose-new-rule)
|
||||
- [Proposing a Rule Change](https://eslint.org/docs/latest/contribute/propose-rule-change)
|
||||
- [Request a Change](https://eslint.org/docs/latest/contribute/request-change)
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
### Does ESLint support JSX?
|
||||
|
||||
Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](https://eslint.org/docs/latest/use/configure)). Please note that supporting JSX syntax _is not_ the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.
|
||||
|
||||
### Does Prettier replace ESLint?
|
||||
|
||||
No, ESLint and Prettier have different jobs: ESLint is a linter (looking for problematic patterns) and Prettier is a code formatter. Using both tools is common, refer to [Prettier's documentation](https://prettier.io/docs/en/install#eslint-and-other-linters) to learn how to configure them to work well with each other.
|
||||
|
||||
### What ECMAScript versions does ESLint support?
|
||||
|
||||
ESLint has full support for ECMAScript 3, 5, and every year from 2015 up until the most recent stage 4 specification (the default). You can set your desired ECMAScript syntax and other settings (like global variables) through [configuration](https://eslint.org/docs/latest/use/configure).
|
||||
|
||||
### What about experimental features?
|
||||
|
||||
ESLint's parser only officially supports the latest final ECMAScript standard. We will make changes to core rules in order to avoid crashes on stage 3 ECMAScript syntax proposals (as long as they are implemented using the correct experimental ESTree syntax). We may make changes to core rules to better work with language extensions (such as JSX, Flow, and TypeScript) on a case-by-case basis.
|
||||
|
||||
In other cases (including if rules need to warn on more or fewer cases due to new syntax, rather than just not crashing), we recommend you use other parsers and/or rule plugins. If you are using Babel, you can use [@babel/eslint-parser](https://www.npmjs.com/package/@babel/eslint-parser) and [@babel/eslint-plugin](https://www.npmjs.com/package/@babel/eslint-plugin) to use any option available in Babel.
|
||||
|
||||
Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](https://eslint.org/docs/latest/contribute). Until then, please use the appropriate parser and plugin(s) for your experimental feature.
|
||||
|
||||
### Which Node.js versions does ESLint support?
|
||||
|
||||
ESLint updates the supported Node.js versions with each major release of ESLint. At that time, ESLint's supported Node.js versions are updated to be:
|
||||
|
||||
1. The most recent maintenance release of Node.js
|
||||
1. The lowest minor version of the Node.js LTS release that includes the features the ESLint team wants to use.
|
||||
1. The Node.js Current release
|
||||
|
||||
ESLint is also expected to work with Node.js versions released after the Node.js Current release.
|
||||
|
||||
Refer to the [Quick Start Guide](https://eslint.org/docs/latest/use/getting-started#prerequisites) for the officially supported Node.js versions for a given ESLint release.
|
||||
|
||||
### Where to ask for help?
|
||||
|
||||
Open a [discussion](https://github.com/eslint/eslint/discussions) or stop by our [Discord server](https://eslint.org/chat).
|
||||
|
||||
### Why doesn't ESLint lock dependency versions?
|
||||
|
||||
Lock files like `package-lock.json` are helpful for deployed applications. They ensure that dependencies are consistent between environments and across deployments.
|
||||
|
||||
Packages like `eslint` that get published to the npm registry do not include lock files. `npm install eslint` as a user will respect version constraints in ESLint's `package.json`. ESLint and its dependencies will be included in the user's lock file if one exists, but ESLint's own lock file would not be used.
|
||||
|
||||
We intentionally don't lock dependency versions so that we have the latest compatible dependency versions in development and CI that our users get when installing ESLint in a project.
|
||||
|
||||
The Twilio blog has a [deeper dive](https://www.twilio.com/blog/lockfiles-nodejs) to learn more.
|
||||
|
||||
## Releases
|
||||
|
||||
We have scheduled releases every two weeks on Friday or Saturday. You can follow a [release issue](https://github.com/eslint/eslint/issues?q=is%3Aopen+is%3Aissue+label%3Arelease) for updates about the scheduling of any particular release.
|
||||
|
||||
## Security Policy
|
||||
|
||||
ESLint takes security seriously. We work hard to ensure that ESLint is safe for everyone and that security issues are addressed quickly and responsibly. Read the full [security policy](https://github.com/eslint/.github/blob/master/SECURITY.md).
|
||||
|
||||
## Semantic Versioning Policy
|
||||
|
||||
ESLint follows [semantic versioning](https://semver.org). However, due to the nature of ESLint as a code quality tool, it's not always clear when a minor or major version bump occurs. To help clarify this for everyone, we've defined the following semantic versioning policy for ESLint:
|
||||
|
||||
- Patch release (intended to not break your lint build)
|
||||
- A bug fix in a rule that results in ESLint reporting fewer linting errors.
|
||||
- A bug fix to the CLI or core (including formatters).
|
||||
- Improvements to documentation.
|
||||
- Non-user-facing changes such as refactoring code, adding, deleting, or modifying tests, and increasing test coverage.
|
||||
- Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone).
|
||||
- Minor release (might break your lint build)
|
||||
- A bug fix that results in ESLint reporting more linting errors (e.g., fixing false negatives in a core rule, or linting additional files that were previously incorrectly skipped).
|
||||
- A new rule is created.
|
||||
- A new option to an existing rule that does not result in ESLint reporting more linting errors by default.
|
||||
- A new addition to an existing rule to support a newly-added language feature (within the last 12 months) that will result in ESLint reporting more linting errors by default.
|
||||
- An existing rule is deprecated.
|
||||
- A new CLI capability is created.
|
||||
- New capabilities to the public API are added (new classes, new methods, new arguments to existing methods, etc.).
|
||||
- A new formatter is created.
|
||||
- `eslint:recommended` is updated and will result in strictly fewer linting errors (e.g., rule removals).
|
||||
- Major release (likely to break your lint build)
|
||||
- `eslint:recommended` is updated and may result in new linting errors (e.g., rule additions, most rule option updates).
|
||||
- A new option to an existing rule that results in ESLint reporting more linting errors by default.
|
||||
- An existing formatter is removed.
|
||||
- Part of the public API is removed or changed in an incompatible way. The public API includes:
|
||||
- Rule schemas
|
||||
- Configuration schema
|
||||
- Command-line options
|
||||
- Node.js API
|
||||
- Rule, formatter, parser, plugin APIs
|
||||
|
||||
According to our policy, any minor update may report more linting errors than the previous release (ex: from a bug fix). As such, we recommend using the tilde (`~`) in `package.json` e.g. `"eslint": "~3.1.0"` to guarantee the results of your builds.
|
||||
|
||||
## ESM Dependencies
|
||||
|
||||
Since ESLint is a CommonJS package, there are restrictions on which ESM-only packages can be used as dependencies.
|
||||
|
||||
Packages that are controlled by the ESLint team and have no external dependencies can be safely loaded synchronously using [`require(esm)`](https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require) and therefore used in any contexts.
|
||||
|
||||
For external packages, we don't use `require(esm)` because a package could add a top-level `await` and thus break ESLint. We can use an external ESM-only package only in case it is needed only in asynchronous code, in which case it can be loaded using dynamic `import()`.
|
||||
|
||||
These policies don't apply to packages intended for our own usage only, such as `eslint-config-eslint`.
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
|
||||
|
||||
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.
|
||||
|
||||
## Team
|
||||
|
||||
These folks keep the project moving and are resources for help.
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
|
||||
<!--teamstart-->
|
||||
|
||||
### Technical Steering Committee (TSC)
|
||||
|
||||
The people who manage releases, review feature requests, and meet regularly to ensure ESLint is properly maintained.
|
||||
|
||||
<table><tbody><tr><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/nzakas">
|
||||
<img src="https://github.com/nzakas.png?s=75" width="75" height="75" alt="Nicholas C. Zakas's Avatar"><br />
|
||||
Nicholas C. Zakas
|
||||
</a>
|
||||
</td><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/fasttime">
|
||||
<img src="https://github.com/fasttime.png?s=75" width="75" height="75" alt="Francesco Trotta's Avatar"><br />
|
||||
Francesco Trotta
|
||||
</a>
|
||||
</td><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/mdjermanovic">
|
||||
<img src="https://github.com/mdjermanovic.png?s=75" width="75" height="75" alt="Milos Djermanovic's Avatar"><br />
|
||||
Milos Djermanovic
|
||||
</a>
|
||||
</td></tr></tbody></table>
|
||||
|
||||
### Reviewers
|
||||
|
||||
The people who review and implement new features.
|
||||
|
||||
<table><tbody><tr><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/aladdin-add">
|
||||
<img src="https://github.com/aladdin-add.png?s=75" width="75" height="75" alt="唯然's Avatar"><br />
|
||||
唯然
|
||||
</a>
|
||||
</td><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/snitin315">
|
||||
<img src="https://github.com/snitin315.png?s=75" width="75" height="75" alt="Nitin Kumar's Avatar"><br />
|
||||
Nitin Kumar
|
||||
</a>
|
||||
</td></tr></tbody></table>
|
||||
|
||||
### Committers
|
||||
|
||||
The people who review and fix bugs and help triage issues.
|
||||
|
||||
<table><tbody><tr><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/DMartens">
|
||||
<img src="https://github.com/DMartens.png?s=75" width="75" height="75" alt="fnx's Avatar"><br />
|
||||
fnx
|
||||
</a>
|
||||
</td><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/SwetaTanwar">
|
||||
<img src="https://github.com/SwetaTanwar.png?s=75" width="75" height="75" alt="Sweta Tanwar's Avatar"><br />
|
||||
Sweta Tanwar
|
||||
</a>
|
||||
</td><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/Tanujkanti4441">
|
||||
<img src="https://github.com/Tanujkanti4441.png?s=75" width="75" height="75" alt="Tanuj Kanti's Avatar"><br />
|
||||
Tanuj Kanti
|
||||
</a>
|
||||
</td><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/lumirlumir">
|
||||
<img src="https://github.com/lumirlumir.png?s=75" width="75" height="75" alt="lumir's Avatar"><br />
|
||||
lumir
|
||||
</a>
|
||||
</td><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/Pixel998">
|
||||
<img src="https://github.com/Pixel998.png?s=75" width="75" height="75" alt="Pixel's Avatar"><br />
|
||||
Pixel
|
||||
</a>
|
||||
</td></tr></tbody></table>
|
||||
|
||||
### Website Team
|
||||
|
||||
Team members who focus specifically on eslint.org
|
||||
|
||||
<table><tbody><tr><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/amareshsm">
|
||||
<img src="https://github.com/amareshsm.png?s=75" width="75" height="75" alt="Amaresh S M's Avatar"><br />
|
||||
Amaresh S M
|
||||
</a>
|
||||
</td><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/harish-sethuraman">
|
||||
<img src="https://github.com/harish-sethuraman.png?s=75" width="75" height="75" alt="Harish's Avatar"><br />
|
||||
Harish
|
||||
</a>
|
||||
</td><td align="center" valign="top" width="11%">
|
||||
<a href="https://github.com/kecrily">
|
||||
<img src="https://github.com/kecrily.png?s=75" width="75" height="75" alt="Percy Ma's Avatar"><br />
|
||||
Percy Ma
|
||||
</a>
|
||||
</td></tr></tbody></table>
|
||||
|
||||
<!--teamend-->
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
|
||||
## Sponsors
|
||||
|
||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
||||
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a> <a href="https://www.coderabbit.ai/?utm_source=cr_org&utm_medium=github"><img src="https://avatars.githubusercontent.com/u/132028505" alt="CodeRabbit" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
|
||||
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://apuesdeportivas.es/"><img src="https://images.opencollective.com/apuesdeportivas-es/6ecf644/avatar.png" alt="apuesdeportivas.es" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://citadel-ai.com"><img src="https://avatars.githubusercontent.com/u/75781367" alt="Citadel AI" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
|
||||
<h3>Technology Sponsors</h3>
|
||||
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
|
||||
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
|
||||
|
||||
<!--sponsorsend-->
|
||||
|
||||
[tidelift]: https://tidelift.com/funding/github/npm/eslint
|
||||
[herodevs]: https://www.herodevs.com/support/eslint-nes?utm_source=ESLintWebsite&utm_medium=ESLintWebsite&utm_campaign=ESLintNES&utm_id=ESLintNES
|
||||
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
|
||||
// npx nx generate-lib repo
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.es2019 = void 0;
|
||||
const es2018_1 = require("./es2018");
|
||||
const es2019_array_1 = require("./es2019.array");
|
||||
const es2019_intl_1 = require("./es2019.intl");
|
||||
const es2019_object_1 = require("./es2019.object");
|
||||
const es2019_string_1 = require("./es2019.string");
|
||||
const es2019_symbol_1 = require("./es2019.symbol");
|
||||
exports.es2019 = {
|
||||
libs: [
|
||||
es2018_1.es2018,
|
||||
es2019_array_1.es2019_array,
|
||||
es2019_object_1.es2019_object,
|
||||
es2019_string_1.es2019_string,
|
||||
es2019_symbol_1.es2019_symbol,
|
||||
es2019_intl_1.es2019_intl,
|
||||
],
|
||||
variables: [],
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
var classApplyDescriptorDestructureSet = require("./classApplyDescriptorDestructureSet.js");
|
||||
var classPrivateFieldGet2 = require("./classPrivateFieldGet2.js");
|
||||
function _classPrivateFieldDestructureSet(e, t) {
|
||||
var r = classPrivateFieldGet2(t, e);
|
||||
return classApplyDescriptorDestructureSet(e, r);
|
||||
}
|
||||
module.exports = _classPrivateFieldDestructureSet, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
import type { LibDefinition } from '../variable';
|
||||
export declare const es2017_string: LibDefinition;
|
||||
@@ -0,0 +1,97 @@
|
||||
'use strict'
|
||||
|
||||
exports.parse = function (source, transform) {
|
||||
return new ArrayParser(source, transform).parse()
|
||||
}
|
||||
|
||||
class ArrayParser {
|
||||
constructor (source, transform) {
|
||||
this.source = source
|
||||
this.transform = transform || identity
|
||||
this.position = 0
|
||||
this.entries = []
|
||||
this.recorded = []
|
||||
this.dimension = 0
|
||||
}
|
||||
|
||||
isEof () {
|
||||
return this.position >= this.source.length
|
||||
}
|
||||
|
||||
nextCharacter () {
|
||||
var character = this.source[this.position++]
|
||||
if (character === '\\') {
|
||||
return {
|
||||
value: this.source[this.position++],
|
||||
escaped: true
|
||||
}
|
||||
}
|
||||
return {
|
||||
value: character,
|
||||
escaped: false
|
||||
}
|
||||
}
|
||||
|
||||
record (character) {
|
||||
this.recorded.push(character)
|
||||
}
|
||||
|
||||
newEntry (includeEmpty) {
|
||||
var entry
|
||||
if (this.recorded.length > 0 || includeEmpty) {
|
||||
entry = this.recorded.join('')
|
||||
if (entry === 'NULL' && !includeEmpty) {
|
||||
entry = null
|
||||
}
|
||||
if (entry !== null) entry = this.transform(entry)
|
||||
this.entries.push(entry)
|
||||
this.recorded = []
|
||||
}
|
||||
}
|
||||
|
||||
consumeDimensions () {
|
||||
if (this.source[0] === '[') {
|
||||
while (!this.isEof()) {
|
||||
var char = this.nextCharacter()
|
||||
if (char.value === '=') break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parse (nested) {
|
||||
var character, parser, quote
|
||||
this.consumeDimensions()
|
||||
while (!this.isEof()) {
|
||||
character = this.nextCharacter()
|
||||
if (character.value === '{' && !quote) {
|
||||
this.dimension++
|
||||
if (this.dimension > 1) {
|
||||
parser = new ArrayParser(this.source.substr(this.position - 1), this.transform)
|
||||
this.entries.push(parser.parse(true))
|
||||
this.position += parser.position - 2
|
||||
}
|
||||
} else if (character.value === '}' && !quote) {
|
||||
this.dimension--
|
||||
if (!this.dimension) {
|
||||
this.newEntry()
|
||||
if (nested) return this.entries
|
||||
}
|
||||
} else if (character.value === '"' && !character.escaped) {
|
||||
if (quote) this.newEntry(true)
|
||||
quote = !quote
|
||||
} else if (character.value === ',' && !quote) {
|
||||
this.newEntry()
|
||||
} else {
|
||||
this.record(character.value)
|
||||
}
|
||||
}
|
||||
if (this.dimension !== 0) {
|
||||
throw new Error('array dimension not balanced')
|
||||
}
|
||||
return this.entries
|
||||
}
|
||||
}
|
||||
|
||||
function identity (value) {
|
||||
return value
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
var test = require('tape');
|
||||
var stringify = require('../');
|
||||
|
||||
test('replace root', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var obj = { a: 1, b: 2, c: false };
|
||||
var replacer = function(key, value) { return 'one'; };
|
||||
|
||||
t.equal(stringify(obj, { replacer: replacer }), '"one"');
|
||||
});
|
||||
|
||||
test('replace numbers', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var obj = { a: 1, b: 2, c: false };
|
||||
var replacer = function(key, value) {
|
||||
if(value === 1) return 'one';
|
||||
if(value === 2) return 'two';
|
||||
return value;
|
||||
};
|
||||
|
||||
t.equal(stringify(obj, { replacer: replacer }), '{"a":"one","b":"two","c":false}');
|
||||
});
|
||||
|
||||
test('replace with object', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var obj = { a: 1, b: 2, c: false };
|
||||
var replacer = function(key, value) {
|
||||
if(key === 'b') return { d: 1 };
|
||||
if(value === 1) return 'one';
|
||||
return value;
|
||||
};
|
||||
|
||||
t.equal(stringify(obj, { replacer: replacer }), '{"a":"one","b":{"d":"one"},"c":false}');
|
||||
});
|
||||
|
||||
test('replace with undefined', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var obj = { a: 1, b: 2, c: false };
|
||||
var replacer = function(key, value) {
|
||||
if(value === false) return;
|
||||
return value;
|
||||
};
|
||||
|
||||
t.equal(stringify(obj, { replacer: replacer }), '{"a":1,"b":2}');
|
||||
});
|
||||
|
||||
test('replace with array', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var obj = { a: 1, b: 2, c: false };
|
||||
var replacer = function(key, value) {
|
||||
if(key === 'b') return ['one', 'two'];
|
||||
return value;
|
||||
};
|
||||
|
||||
t.equal(stringify(obj, { replacer: replacer }), '{"a":1,"b":["one","two"],"c":false}');
|
||||
});
|
||||
|
||||
test('replace array item', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var obj = { a: 1, b: 2, c: [1,2] };
|
||||
var replacer = function(key, value) {
|
||||
if(value === 1) return 'one';
|
||||
if(value === 2) return 'two';
|
||||
return value;
|
||||
};
|
||||
|
||||
t.equal(stringify(obj, { replacer: replacer }), '{"a":"one","b":"two","c":["one","two"]}');
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
declare module 'trace_events' {
|
||||
/**
|
||||
* The `Tracing` object is used to enable or disable tracing for sets of
|
||||
* categories. Instances are created using the
|
||||
* `trace_events.createTracing()` method.
|
||||
*
|
||||
* When created, the `Tracing` object is disabled. Calling the
|
||||
* `tracing.enable()` method adds the categories to the set of enabled trace
|
||||
* event categories. Calling `tracing.disable()` will remove the categories
|
||||
* from the set of enabled trace event categories.
|
||||
*/
|
||||
interface Tracing {
|
||||
/**
|
||||
* A comma-separated list of the trace event categories covered by this
|
||||
* `Tracing` object.
|
||||
*/
|
||||
readonly categories: string;
|
||||
|
||||
/**
|
||||
* Disables this `Tracing` object.
|
||||
*
|
||||
* Only trace event categories _not_ covered by other enabled `Tracing`
|
||||
* objects and _not_ specified by the `--trace-event-categories` flag
|
||||
* will be disabled.
|
||||
*/
|
||||
disable(): void;
|
||||
|
||||
/**
|
||||
* Enables this `Tracing` object for the set of categories covered by
|
||||
* the `Tracing` object.
|
||||
*/
|
||||
enable(): void;
|
||||
|
||||
/**
|
||||
* `true` only if the `Tracing` object has been enabled.
|
||||
*/
|
||||
readonly enabled: boolean;
|
||||
}
|
||||
|
||||
interface CreateTracingOptions {
|
||||
/**
|
||||
* An array of trace category names. Values included in the array are
|
||||
* coerced to a string when possible. An error will be thrown if the
|
||||
* value cannot be coerced.
|
||||
*/
|
||||
categories: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a Tracing object for the given set of categories.
|
||||
*/
|
||||
function createTracing(options: CreateTracingOptions): Tracing;
|
||||
|
||||
/**
|
||||
* Returns a comma-separated list of all currently-enabled trace event
|
||||
* categories. The current set of enabled trace event categories is
|
||||
* determined by the union of all currently-enabled `Tracing` objects and
|
||||
* any categories enabled using the `--trace-event-categories` flag.
|
||||
*/
|
||||
function getEnabledCategories(): string | undefined;
|
||||
}
|
||||
@@ -0,0 +1,480 @@
|
||||
/**
|
||||
* URI.js
|
||||
*
|
||||
* @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
|
||||
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
||||
* @see http://github.com/garycourt/uri-js
|
||||
*/
|
||||
/**
|
||||
* Copyright 2011 Gary Court. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of Gary Court.
|
||||
*/
|
||||
import URI_PROTOCOL from "./regexps-uri";
|
||||
import IRI_PROTOCOL from "./regexps-iri";
|
||||
import punycode from "punycode";
|
||||
import { toUpperCase, typeOf, assign } from "./util";
|
||||
export const SCHEMES = {};
|
||||
export function pctEncChar(chr) {
|
||||
const c = chr.charCodeAt(0);
|
||||
let e;
|
||||
if (c < 16)
|
||||
e = "%0" + c.toString(16).toUpperCase();
|
||||
else if (c < 128)
|
||||
e = "%" + c.toString(16).toUpperCase();
|
||||
else if (c < 2048)
|
||||
e = "%" + ((c >> 6) | 192).toString(16).toUpperCase() + "%" + ((c & 63) | 128).toString(16).toUpperCase();
|
||||
else
|
||||
e = "%" + ((c >> 12) | 224).toString(16).toUpperCase() + "%" + (((c >> 6) & 63) | 128).toString(16).toUpperCase() + "%" + ((c & 63) | 128).toString(16).toUpperCase();
|
||||
return e;
|
||||
}
|
||||
export function pctDecChars(str) {
|
||||
let newStr = "";
|
||||
let i = 0;
|
||||
const il = str.length;
|
||||
while (i < il) {
|
||||
const c = parseInt(str.substr(i + 1, 2), 16);
|
||||
if (c < 128) {
|
||||
newStr += String.fromCharCode(c);
|
||||
i += 3;
|
||||
}
|
||||
else if (c >= 194 && c < 224) {
|
||||
if ((il - i) >= 6) {
|
||||
const c2 = parseInt(str.substr(i + 4, 2), 16);
|
||||
newStr += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||
}
|
||||
else {
|
||||
newStr += str.substr(i, 6);
|
||||
}
|
||||
i += 6;
|
||||
}
|
||||
else if (c >= 224) {
|
||||
if ((il - i) >= 9) {
|
||||
const c2 = parseInt(str.substr(i + 4, 2), 16);
|
||||
const c3 = parseInt(str.substr(i + 7, 2), 16);
|
||||
newStr += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
}
|
||||
else {
|
||||
newStr += str.substr(i, 9);
|
||||
}
|
||||
i += 9;
|
||||
}
|
||||
else {
|
||||
newStr += str.substr(i, 3);
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
return newStr;
|
||||
}
|
||||
function _normalizeComponentEncoding(components, protocol) {
|
||||
function decodeUnreserved(str) {
|
||||
const decStr = pctDecChars(str);
|
||||
return (!decStr.match(protocol.UNRESERVED) ? str : decStr);
|
||||
}
|
||||
if (components.scheme)
|
||||
components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, "");
|
||||
if (components.userinfo !== undefined)
|
||||
components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
||||
if (components.host !== undefined)
|
||||
components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
||||
if (components.path !== undefined)
|
||||
components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace((components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME), pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
||||
if (components.query !== undefined)
|
||||
components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
||||
if (components.fragment !== undefined)
|
||||
components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
||||
return components;
|
||||
}
|
||||
;
|
||||
function _stripLeadingZeros(str) {
|
||||
return str.replace(/^0*(.*)/, "$1") || "0";
|
||||
}
|
||||
function _normalizeIPv4(host, protocol) {
|
||||
const matches = host.match(protocol.IPV4ADDRESS) || [];
|
||||
const [, address] = matches;
|
||||
if (address) {
|
||||
return address.split(".").map(_stripLeadingZeros).join(".");
|
||||
}
|
||||
else {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
function _normalizeIPv6(host, protocol) {
|
||||
const matches = host.match(protocol.IPV6ADDRESS) || [];
|
||||
const [, address, zone] = matches;
|
||||
if (address) {
|
||||
const [last, first] = address.toLowerCase().split('::').reverse();
|
||||
const firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
|
||||
const lastFields = last.split(":").map(_stripLeadingZeros);
|
||||
const isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
|
||||
const fieldCount = isLastFieldIPv4Address ? 7 : 8;
|
||||
const lastFieldsStart = lastFields.length - fieldCount;
|
||||
const fields = Array(fieldCount);
|
||||
for (let x = 0; x < fieldCount; ++x) {
|
||||
fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
|
||||
}
|
||||
if (isLastFieldIPv4Address) {
|
||||
fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
|
||||
}
|
||||
const allZeroFields = fields.reduce((acc, field, index) => {
|
||||
if (!field || field === "0") {
|
||||
const lastLongest = acc[acc.length - 1];
|
||||
if (lastLongest && lastLongest.index + lastLongest.length === index) {
|
||||
lastLongest.length++;
|
||||
}
|
||||
else {
|
||||
acc.push({ index, length: 1 });
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
const longestZeroFields = allZeroFields.sort((a, b) => b.length - a.length)[0];
|
||||
let newHost;
|
||||
if (longestZeroFields && longestZeroFields.length > 1) {
|
||||
const newFirst = fields.slice(0, longestZeroFields.index);
|
||||
const newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
|
||||
newHost = newFirst.join(":") + "::" + newLast.join(":");
|
||||
}
|
||||
else {
|
||||
newHost = fields.join(":");
|
||||
}
|
||||
if (zone) {
|
||||
newHost += "%" + zone;
|
||||
}
|
||||
return newHost;
|
||||
}
|
||||
else {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
const URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
|
||||
const NO_MATCH_IS_UNDEFINED = ("").match(/(){0}/)[1] === undefined;
|
||||
export function parse(uriString, options = {}) {
|
||||
const components = {};
|
||||
const protocol = (options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL);
|
||||
if (options.reference === "suffix")
|
||||
uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
|
||||
const matches = uriString.match(URI_PARSE);
|
||||
if (matches) {
|
||||
if (NO_MATCH_IS_UNDEFINED) {
|
||||
//store each component
|
||||
components.scheme = matches[1];
|
||||
components.userinfo = matches[3];
|
||||
components.host = matches[4];
|
||||
components.port = parseInt(matches[5], 10);
|
||||
components.path = matches[6] || "";
|
||||
components.query = matches[7];
|
||||
components.fragment = matches[8];
|
||||
//fix port number
|
||||
if (isNaN(components.port)) {
|
||||
components.port = matches[5];
|
||||
}
|
||||
}
|
||||
else { //IE FIX for improper RegExp matching
|
||||
//store each component
|
||||
components.scheme = matches[1] || undefined;
|
||||
components.userinfo = (uriString.indexOf("@") !== -1 ? matches[3] : undefined);
|
||||
components.host = (uriString.indexOf("//") !== -1 ? matches[4] : undefined);
|
||||
components.port = parseInt(matches[5], 10);
|
||||
components.path = matches[6] || "";
|
||||
components.query = (uriString.indexOf("?") !== -1 ? matches[7] : undefined);
|
||||
components.fragment = (uriString.indexOf("#") !== -1 ? matches[8] : undefined);
|
||||
//fix port number
|
||||
if (isNaN(components.port)) {
|
||||
components.port = (uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined);
|
||||
}
|
||||
}
|
||||
if (components.host) {
|
||||
//normalize IP hosts
|
||||
components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
|
||||
}
|
||||
//determine reference type
|
||||
if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
|
||||
components.reference = "same-document";
|
||||
}
|
||||
else if (components.scheme === undefined) {
|
||||
components.reference = "relative";
|
||||
}
|
||||
else if (components.fragment === undefined) {
|
||||
components.reference = "absolute";
|
||||
}
|
||||
else {
|
||||
components.reference = "uri";
|
||||
}
|
||||
//check for reference errors
|
||||
if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
|
||||
components.error = components.error || "URI is not a " + options.reference + " reference.";
|
||||
}
|
||||
//find scheme handler
|
||||
const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
|
||||
//check if scheme can't handle IRIs
|
||||
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
||||
//if host component is a domain name
|
||||
if (components.host && (options.domainHost || (schemeHandler && schemeHandler.domainHost))) {
|
||||
//convert Unicode IDN -> ASCII IDN
|
||||
try {
|
||||
components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
|
||||
}
|
||||
catch (e) {
|
||||
components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
|
||||
}
|
||||
}
|
||||
//convert IRI -> URI
|
||||
_normalizeComponentEncoding(components, URI_PROTOCOL);
|
||||
}
|
||||
else {
|
||||
//normalize encodings
|
||||
_normalizeComponentEncoding(components, protocol);
|
||||
}
|
||||
//perform scheme specific parsing
|
||||
if (schemeHandler && schemeHandler.parse) {
|
||||
schemeHandler.parse(components, options);
|
||||
}
|
||||
}
|
||||
else {
|
||||
components.error = components.error || "URI can not be parsed.";
|
||||
}
|
||||
return components;
|
||||
}
|
||||
;
|
||||
function _recomposeAuthority(components, options) {
|
||||
const protocol = (options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL);
|
||||
const uriTokens = [];
|
||||
if (components.userinfo !== undefined) {
|
||||
uriTokens.push(components.userinfo);
|
||||
uriTokens.push("@");
|
||||
}
|
||||
if (components.host !== undefined) {
|
||||
//normalize IP hosts, add brackets and escape zone separator for IPv6
|
||||
uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, (_, $1, $2) => "[" + $1 + ($2 ? "%25" + $2 : "") + "]"));
|
||||
}
|
||||
if (typeof components.port === "number" || typeof components.port === "string") {
|
||||
uriTokens.push(":");
|
||||
uriTokens.push(String(components.port));
|
||||
}
|
||||
return uriTokens.length ? uriTokens.join("") : undefined;
|
||||
}
|
||||
;
|
||||
const RDS1 = /^\.\.?\//;
|
||||
const RDS2 = /^\/\.(\/|$)/;
|
||||
const RDS3 = /^\/\.\.(\/|$)/;
|
||||
const RDS4 = /^\.\.?$/;
|
||||
const RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
|
||||
export function removeDotSegments(input) {
|
||||
const output = [];
|
||||
while (input.length) {
|
||||
if (input.match(RDS1)) {
|
||||
input = input.replace(RDS1, "");
|
||||
}
|
||||
else if (input.match(RDS2)) {
|
||||
input = input.replace(RDS2, "/");
|
||||
}
|
||||
else if (input.match(RDS3)) {
|
||||
input = input.replace(RDS3, "/");
|
||||
output.pop();
|
||||
}
|
||||
else if (input === "." || input === "..") {
|
||||
input = "";
|
||||
}
|
||||
else {
|
||||
const im = input.match(RDS5);
|
||||
if (im) {
|
||||
const s = im[0];
|
||||
input = input.slice(s.length);
|
||||
output.push(s);
|
||||
}
|
||||
else {
|
||||
throw new Error("Unexpected dot segment condition");
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.join("");
|
||||
}
|
||||
;
|
||||
export function serialize(components, options = {}) {
|
||||
const protocol = (options.iri ? IRI_PROTOCOL : URI_PROTOCOL);
|
||||
const uriTokens = [];
|
||||
//find scheme handler
|
||||
const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
|
||||
//perform scheme specific serialization
|
||||
if (schemeHandler && schemeHandler.serialize)
|
||||
schemeHandler.serialize(components, options);
|
||||
if (components.host) {
|
||||
//if host component is an IPv6 address
|
||||
if (protocol.IPV6ADDRESS.test(components.host)) {
|
||||
//TODO: normalize IPv6 address as per RFC 5952
|
||||
}
|
||||
//if host component is a domain name
|
||||
else if (options.domainHost || (schemeHandler && schemeHandler.domainHost)) {
|
||||
//convert IDN via punycode
|
||||
try {
|
||||
components.host = (!options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host));
|
||||
}
|
||||
catch (e) {
|
||||
components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
|
||||
}
|
||||
}
|
||||
}
|
||||
//normalize encoding
|
||||
_normalizeComponentEncoding(components, protocol);
|
||||
if (options.reference !== "suffix" && components.scheme) {
|
||||
uriTokens.push(components.scheme);
|
||||
uriTokens.push(":");
|
||||
}
|
||||
const authority = _recomposeAuthority(components, options);
|
||||
if (authority !== undefined) {
|
||||
if (options.reference !== "suffix") {
|
||||
uriTokens.push("//");
|
||||
}
|
||||
uriTokens.push(authority);
|
||||
if (components.path && components.path.charAt(0) !== "/") {
|
||||
uriTokens.push("/");
|
||||
}
|
||||
}
|
||||
if (components.path !== undefined) {
|
||||
let s = components.path;
|
||||
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
||||
s = removeDotSegments(s);
|
||||
}
|
||||
if (authority === undefined) {
|
||||
s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
|
||||
}
|
||||
uriTokens.push(s);
|
||||
}
|
||||
if (components.query !== undefined) {
|
||||
uriTokens.push("?");
|
||||
uriTokens.push(components.query);
|
||||
}
|
||||
if (components.fragment !== undefined) {
|
||||
uriTokens.push("#");
|
||||
uriTokens.push(components.fragment);
|
||||
}
|
||||
return uriTokens.join(""); //merge tokens into a string
|
||||
}
|
||||
;
|
||||
export function resolveComponents(base, relative, options = {}, skipNormalization) {
|
||||
const target = {};
|
||||
if (!skipNormalization) {
|
||||
base = parse(serialize(base, options), options); //normalize base components
|
||||
relative = parse(serialize(relative, options), options); //normalize relative components
|
||||
}
|
||||
options = options || {};
|
||||
if (!options.tolerant && relative.scheme) {
|
||||
target.scheme = relative.scheme;
|
||||
//target.authority = relative.authority;
|
||||
target.userinfo = relative.userinfo;
|
||||
target.host = relative.host;
|
||||
target.port = relative.port;
|
||||
target.path = removeDotSegments(relative.path || "");
|
||||
target.query = relative.query;
|
||||
}
|
||||
else {
|
||||
if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
|
||||
//target.authority = relative.authority;
|
||||
target.userinfo = relative.userinfo;
|
||||
target.host = relative.host;
|
||||
target.port = relative.port;
|
||||
target.path = removeDotSegments(relative.path || "");
|
||||
target.query = relative.query;
|
||||
}
|
||||
else {
|
||||
if (!relative.path) {
|
||||
target.path = base.path;
|
||||
if (relative.query !== undefined) {
|
||||
target.query = relative.query;
|
||||
}
|
||||
else {
|
||||
target.query = base.query;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (relative.path.charAt(0) === "/") {
|
||||
target.path = removeDotSegments(relative.path);
|
||||
}
|
||||
else {
|
||||
if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
|
||||
target.path = "/" + relative.path;
|
||||
}
|
||||
else if (!base.path) {
|
||||
target.path = relative.path;
|
||||
}
|
||||
else {
|
||||
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
|
||||
}
|
||||
target.path = removeDotSegments(target.path);
|
||||
}
|
||||
target.query = relative.query;
|
||||
}
|
||||
//target.authority = base.authority;
|
||||
target.userinfo = base.userinfo;
|
||||
target.host = base.host;
|
||||
target.port = base.port;
|
||||
}
|
||||
target.scheme = base.scheme;
|
||||
}
|
||||
target.fragment = relative.fragment;
|
||||
return target;
|
||||
}
|
||||
;
|
||||
export function resolve(baseURI, relativeURI, options) {
|
||||
const schemelessOptions = assign({ scheme: 'null' }, options);
|
||||
return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
||||
}
|
||||
;
|
||||
export function normalize(uri, options) {
|
||||
if (typeof uri === "string") {
|
||||
uri = serialize(parse(uri, options), options);
|
||||
}
|
||||
else if (typeOf(uri) === "object") {
|
||||
uri = parse(serialize(uri, options), options);
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
;
|
||||
export function equal(uriA, uriB, options) {
|
||||
if (typeof uriA === "string") {
|
||||
uriA = serialize(parse(uriA, options), options);
|
||||
}
|
||||
else if (typeOf(uriA) === "object") {
|
||||
uriA = serialize(uriA, options);
|
||||
}
|
||||
if (typeof uriB === "string") {
|
||||
uriB = serialize(parse(uriB, options), options);
|
||||
}
|
||||
else if (typeOf(uriB) === "object") {
|
||||
uriB = serialize(uriB, options);
|
||||
}
|
||||
return uriA === uriB;
|
||||
}
|
||||
;
|
||||
export function escapeComponent(str, options) {
|
||||
return str && str.toString().replace((!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE), pctEncChar);
|
||||
}
|
||||
;
|
||||
export function unescapeComponent(str, options) {
|
||||
return str && str.toString().replace((!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED), pctDecChars);
|
||||
}
|
||||
;
|
||||
//# sourceMappingURL=uri.js.map
|
||||
@@ -0,0 +1,117 @@
|
||||
declare module 'assert' {
|
||||
function assert(value: any, message?: string | Error): asserts value;
|
||||
namespace assert {
|
||||
class AssertionError implements Error {
|
||||
name: string;
|
||||
message: string;
|
||||
actual: any;
|
||||
expected: any;
|
||||
operator: string;
|
||||
generatedMessage: boolean;
|
||||
code: 'ERR_ASSERTION';
|
||||
|
||||
constructor(options?: {
|
||||
message?: string | undefined;
|
||||
actual?: any;
|
||||
expected?: any;
|
||||
operator?: string | undefined;
|
||||
// tslint:disable-next-line:ban-types
|
||||
stackStartFn?: Function | undefined;
|
||||
});
|
||||
}
|
||||
|
||||
class CallTracker {
|
||||
calls(exact?: number): () => void;
|
||||
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
||||
report(): CallTrackerReportInformation[];
|
||||
verify(): void;
|
||||
}
|
||||
interface CallTrackerReportInformation {
|
||||
message: string;
|
||||
/** The actual number of times the function was called. */
|
||||
actual: number;
|
||||
/** The number of times the function was expected to be called. */
|
||||
expected: number;
|
||||
/** The name of the function that is wrapped. */
|
||||
operator: string;
|
||||
/** A stack trace of the function. */
|
||||
stack: object;
|
||||
}
|
||||
|
||||
type AssertPredicate = RegExp | (new () => object) | ((thrown: any) => boolean) | object | Error;
|
||||
|
||||
function fail(message?: string | Error): never;
|
||||
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
||||
function fail(
|
||||
actual: any,
|
||||
expected: any,
|
||||
message?: string | Error,
|
||||
operator?: string,
|
||||
// tslint:disable-next-line:ban-types
|
||||
stackStartFn?: Function,
|
||||
): never;
|
||||
function ok(value: any, message?: string | Error): asserts value;
|
||||
/** @deprecated since v9.9.0 - use strictEqual() instead. */
|
||||
function equal(actual: any, expected: any, message?: string | Error): void;
|
||||
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
|
||||
function notEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
|
||||
function deepEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
|
||||
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
||||
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
||||
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
|
||||
function throws(block: () => any, message?: string | Error): void;
|
||||
function throws(block: () => any, error: AssertPredicate, message?: string | Error): void;
|
||||
function doesNotThrow(block: () => any, message?: string | Error): void;
|
||||
function doesNotThrow(block: () => any, error: AssertPredicate, message?: string | Error): void;
|
||||
|
||||
function ifError(value: any): asserts value is null | undefined;
|
||||
|
||||
function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
||||
function rejects(
|
||||
block: (() => Promise<any>) | Promise<any>,
|
||||
error: AssertPredicate,
|
||||
message?: string | Error,
|
||||
): Promise<void>;
|
||||
function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
||||
function doesNotReject(
|
||||
block: (() => Promise<any>) | Promise<any>,
|
||||
error: AssertPredicate,
|
||||
message?: string | Error,
|
||||
): Promise<void>;
|
||||
|
||||
const strict: Omit<
|
||||
typeof assert,
|
||||
| 'equal'
|
||||
| 'notEqual'
|
||||
| 'deepEqual'
|
||||
| 'notDeepEqual'
|
||||
| 'ok'
|
||||
| 'strictEqual'
|
||||
| 'deepStrictEqual'
|
||||
| 'ifError'
|
||||
| 'strict'
|
||||
> & {
|
||||
(value: any, message?: string | Error): asserts value;
|
||||
equal: typeof strictEqual;
|
||||
notEqual: typeof notStrictEqual;
|
||||
deepEqual: typeof deepStrictEqual;
|
||||
notDeepEqual: typeof notDeepStrictEqual;
|
||||
|
||||
// Mapped types and assertion functions are incompatible?
|
||||
// TS2775: Assertions require every name in the call target
|
||||
// to be declared with an explicit type annotation.
|
||||
ok: typeof ok;
|
||||
strictEqual: typeof strictEqual;
|
||||
deepStrictEqual: typeof deepStrictEqual;
|
||||
ifError: typeof ifError;
|
||||
strict: typeof strict;
|
||||
};
|
||||
}
|
||||
|
||||
export = assert;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
'use strict'
|
||||
|
||||
let AtRule = require('./at-rule')
|
||||
let Comment = require('./comment')
|
||||
let Container = require('./container')
|
||||
let CssSyntaxError = require('./css-syntax-error')
|
||||
let Declaration = require('./declaration')
|
||||
let Document = require('./document')
|
||||
let fromJSON = require('./fromJSON')
|
||||
let Input = require('./input')
|
||||
let LazyResult = require('./lazy-result')
|
||||
let list = require('./list')
|
||||
let Node = require('./node')
|
||||
let parse = require('./parse')
|
||||
let Processor = require('./processor')
|
||||
let Result = require('./result.js')
|
||||
let Root = require('./root')
|
||||
let Rule = require('./rule')
|
||||
let stringify = require('./stringify')
|
||||
let Warning = require('./warning')
|
||||
|
||||
function postcss(...plugins) {
|
||||
if (plugins.length === 1 && Array.isArray(plugins[0])) {
|
||||
plugins = plugins[0]
|
||||
}
|
||||
return new Processor(plugins)
|
||||
}
|
||||
|
||||
postcss.plugin = function plugin(name, initializer) {
|
||||
let warningPrinted = false
|
||||
function creator(...args) {
|
||||
// eslint-disable-next-line no-console
|
||||
if (console && console.warn && !warningPrinted) {
|
||||
warningPrinted = true
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
name +
|
||||
': postcss.plugin was deprecated. Migration guide:\n' +
|
||||
'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
|
||||
)
|
||||
if (process.env.LANG && process.env.LANG.startsWith('cn')) {
|
||||
/* c8 ignore next 7 */
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
name +
|
||||
': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
|
||||
'https://www.w3ctech.com/topic/2226'
|
||||
)
|
||||
}
|
||||
}
|
||||
let transformer = initializer(...args)
|
||||
transformer.postcssPlugin = name
|
||||
transformer.postcssVersion = new Processor().version
|
||||
return transformer
|
||||
}
|
||||
|
||||
let cache
|
||||
Object.defineProperty(creator, 'postcss', {
|
||||
get() {
|
||||
if (!cache) cache = creator()
|
||||
return cache
|
||||
}
|
||||
})
|
||||
|
||||
creator.process = function (css, processOpts, pluginOpts) {
|
||||
return postcss([creator(pluginOpts)]).process(css, processOpts)
|
||||
}
|
||||
|
||||
return creator
|
||||
}
|
||||
|
||||
postcss.stringify = stringify
|
||||
postcss.parse = parse
|
||||
postcss.fromJSON = fromJSON
|
||||
postcss.list = list
|
||||
|
||||
postcss.comment = defaults => new Comment(defaults)
|
||||
postcss.atRule = defaults => new AtRule(defaults)
|
||||
postcss.decl = defaults => new Declaration(defaults)
|
||||
postcss.rule = defaults => new Rule(defaults)
|
||||
postcss.root = defaults => new Root(defaults)
|
||||
postcss.document = defaults => new Document(defaults)
|
||||
|
||||
postcss.CssSyntaxError = CssSyntaxError
|
||||
postcss.Declaration = Declaration
|
||||
postcss.Container = Container
|
||||
postcss.Processor = Processor
|
||||
postcss.Document = Document
|
||||
postcss.Comment = Comment
|
||||
postcss.Warning = Warning
|
||||
postcss.AtRule = AtRule
|
||||
postcss.Result = Result
|
||||
postcss.Input = Input
|
||||
postcss.Rule = Rule
|
||||
postcss.Root = Root
|
||||
postcss.Node = Node
|
||||
|
||||
LazyResult.registerPostcss(postcss)
|
||||
|
||||
module.exports = postcss
|
||||
postcss.default = postcss
|
||||
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_class_private_method_get.cjs",
|
||||
"module": "../../esm/_class_private_method_get.js"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user