WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["../src/pbkdf2.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAkCF;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,SAAS,GACd,UAAU,CAsBZ;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,UAAU,CAAC,CAsBrB"}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,259 @@
|
||||
'use strict'
|
||||
|
||||
const { EventEmitter } = require('events')
|
||||
|
||||
const Result = require('./result')
|
||||
const utils = require('./utils')
|
||||
|
||||
class Query extends EventEmitter {
|
||||
constructor(config, values, callback) {
|
||||
super()
|
||||
|
||||
config = utils.normalizeQueryConfig(config, values, callback)
|
||||
|
||||
this.text = config.text
|
||||
this.values = config.values
|
||||
this.rows = config.rows
|
||||
this.types = config.types
|
||||
this.name = config.name
|
||||
this.queryMode = config.queryMode
|
||||
this.binary = config.binary
|
||||
// use unique portal name each time
|
||||
this.portal = config.portal || ''
|
||||
this.callback = config.callback
|
||||
this._rowMode = config.rowMode
|
||||
if (process.domain && config.callback) {
|
||||
this.callback = process.domain.bind(config.callback)
|
||||
}
|
||||
this._result = new Result(this._rowMode, this.types)
|
||||
|
||||
// potential for multiple results
|
||||
this._results = this._result
|
||||
this._canceledDueToError = false
|
||||
}
|
||||
|
||||
requiresPreparation() {
|
||||
if (this.queryMode === 'extended') {
|
||||
return true
|
||||
}
|
||||
|
||||
// named queries must always be prepared
|
||||
if (this.name) {
|
||||
return true
|
||||
}
|
||||
// always prepare if there are max number of rows expected per
|
||||
// portal execution
|
||||
if (this.rows) {
|
||||
return true
|
||||
}
|
||||
// don't prepare empty text queries
|
||||
if (!this.text) {
|
||||
return false
|
||||
}
|
||||
// prepare if there are values
|
||||
if (!this.values) {
|
||||
return false
|
||||
}
|
||||
return this.values.length > 0
|
||||
}
|
||||
|
||||
_checkForMultirow() {
|
||||
// if we already have a result with a command property
|
||||
// then we've already executed one query in a multi-statement simple query
|
||||
// turn our results into an array of results
|
||||
if (this._result.command) {
|
||||
if (!Array.isArray(this._results)) {
|
||||
this._results = [this._result]
|
||||
}
|
||||
this._result = new Result(this._rowMode, this._result._types)
|
||||
this._results.push(this._result)
|
||||
}
|
||||
}
|
||||
|
||||
// associates row metadata from the supplied
|
||||
// message with this query object
|
||||
// metadata used when parsing row results
|
||||
handleRowDescription(msg) {
|
||||
this._checkForMultirow()
|
||||
this._result.addFields(msg.fields)
|
||||
this._accumulateRows = this.callback || !this.listeners('row').length
|
||||
}
|
||||
|
||||
handleDataRow(msg) {
|
||||
let row
|
||||
|
||||
if (this._canceledDueToError) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
row = this._result.parseRow(msg.fields)
|
||||
} catch (err) {
|
||||
this._canceledDueToError = err
|
||||
return
|
||||
}
|
||||
|
||||
this.emit('row', row, this._result)
|
||||
if (this._accumulateRows) {
|
||||
this._result.addRow(row)
|
||||
}
|
||||
}
|
||||
|
||||
handleCommandComplete(msg, connection) {
|
||||
this._checkForMultirow()
|
||||
this._result.addCommandComplete(msg)
|
||||
// need to sync after each command complete of a prepared statement
|
||||
// if we were using a row count which results in multiple calls to _getRows
|
||||
if (this.rows) {
|
||||
connection.sync()
|
||||
}
|
||||
}
|
||||
|
||||
// if a named prepared statement is created with empty query text
|
||||
// the backend will send an emptyQuery message but *not* a command complete message
|
||||
// since we pipeline sync immediately after execute we don't need to do anything here
|
||||
// unless we have rows specified, in which case we did not pipeline the initial sync call
|
||||
handleEmptyQuery(connection) {
|
||||
if (this.rows) {
|
||||
connection.sync()
|
||||
}
|
||||
}
|
||||
|
||||
handleError(err, connection) {
|
||||
// need to sync after error during a prepared statement
|
||||
if (this._canceledDueToError) {
|
||||
err = this._canceledDueToError
|
||||
this._canceledDueToError = false
|
||||
}
|
||||
// if callback supplied do not emit error event as uncaught error
|
||||
// events will bubble up to node process
|
||||
if (this.callback) {
|
||||
return this.callback(err)
|
||||
}
|
||||
this.emit('error', err)
|
||||
}
|
||||
|
||||
handleReadyForQuery(con) {
|
||||
if (this._canceledDueToError) {
|
||||
return this.handleError(this._canceledDueToError, con)
|
||||
}
|
||||
if (this.callback) {
|
||||
try {
|
||||
this.callback(null, this._results)
|
||||
} catch (err) {
|
||||
process.nextTick(() => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
}
|
||||
this.emit('end', this._results)
|
||||
}
|
||||
|
||||
submit(connection) {
|
||||
if (typeof this.text !== 'string' && typeof this.name !== 'string') {
|
||||
return new Error('A query must have either text or a name. Supplying neither is unsupported.')
|
||||
}
|
||||
const previous = connection.parsedStatements[this.name] || connection.submittedNamedStatements[this.name]
|
||||
if (this.text && previous && this.text !== previous) {
|
||||
return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`)
|
||||
}
|
||||
if (this.values && !Array.isArray(this.values)) {
|
||||
return new Error('Query values must be an array')
|
||||
}
|
||||
if (this.requiresPreparation()) {
|
||||
// If we're using the extended query protocol we fire off several separate commands
|
||||
// to the backend. On some versions of node & some operating system versions
|
||||
// the network stack writes each message separately instead of buffering them together
|
||||
// causing the client & network to send more slowly. Corking & uncorking the stream
|
||||
// allows node to buffer up the messages internally before sending them all off at once.
|
||||
// note: we're checking for existence of cork/uncork because some versions of streams
|
||||
// might not have this (cloudflare?)
|
||||
connection.stream.cork && connection.stream.cork()
|
||||
try {
|
||||
this.prepare(connection)
|
||||
} finally {
|
||||
// while unlikely for this.prepare to throw, if it does & we don't uncork this stream
|
||||
// this client becomes unresponsive, so put in finally block "just in case"
|
||||
connection.stream.uncork && connection.stream.uncork()
|
||||
}
|
||||
} else {
|
||||
connection.query(this.text)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
hasBeenParsed(connection) {
|
||||
return this.name && (connection.parsedStatements[this.name] || connection.submittedNamedStatements[this.name])
|
||||
}
|
||||
|
||||
handlePortalSuspended(connection) {
|
||||
this._getRows(connection, this.rows)
|
||||
}
|
||||
|
||||
_getRows(connection, rows) {
|
||||
connection.execute({
|
||||
portal: this.portal,
|
||||
rows: rows,
|
||||
})
|
||||
// if we're not reading pages of rows send the sync command
|
||||
// to indicate the pipeline is finished
|
||||
if (!rows) {
|
||||
connection.sync()
|
||||
} else {
|
||||
// otherwise flush the call out to read more rows
|
||||
connection.flush()
|
||||
}
|
||||
}
|
||||
|
||||
// http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
|
||||
prepare(connection) {
|
||||
// TODO refactor this poor encapsulation
|
||||
if (!this.hasBeenParsed(connection)) {
|
||||
connection.parse({
|
||||
text: this.text,
|
||||
name: this.name,
|
||||
types: this.types,
|
||||
})
|
||||
if (this.name) {
|
||||
connection.submittedNamedStatements[this.name] = this.text
|
||||
}
|
||||
}
|
||||
|
||||
// because we're mapping user supplied values to
|
||||
// postgres wire protocol compatible values it could
|
||||
// throw an exception, so try/catch this section
|
||||
try {
|
||||
connection.bind({
|
||||
portal: this.portal,
|
||||
statement: this.name,
|
||||
values: this.values,
|
||||
binary: this.binary,
|
||||
valueMapper: utils.prepareValue,
|
||||
})
|
||||
} catch (err) {
|
||||
// we should close parse to avoid leaking connections
|
||||
connection.close({ type: 'S', name: this.name })
|
||||
connection.sync()
|
||||
|
||||
this.handleError(err, connection)
|
||||
return
|
||||
}
|
||||
|
||||
connection.describe({
|
||||
type: 'P',
|
||||
name: this.portal || '',
|
||||
})
|
||||
|
||||
this._getRows(connection, this.rows)
|
||||
}
|
||||
|
||||
handleCopyInResponse(connection) {
|
||||
connection.sendCopyFail('No source stream defined')
|
||||
}
|
||||
|
||||
handleCopyData(msg, connection) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Query
|
||||
@@ -0,0 +1,103 @@
|
||||
var test = require("tape")
|
||||
var extend = require("./")
|
||||
var mutableExtend = require("./mutable")
|
||||
|
||||
test("merge", function(assert) {
|
||||
var a = { a: "foo" }
|
||||
var b = { b: "bar" }
|
||||
|
||||
assert.deepEqual(extend(a, b), { a: "foo", b: "bar" })
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("replace", function(assert) {
|
||||
var a = { a: "foo" }
|
||||
var b = { a: "bar" }
|
||||
|
||||
assert.deepEqual(extend(a, b), { a: "bar" })
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("undefined", function(assert) {
|
||||
var a = { a: undefined }
|
||||
var b = { b: "foo" }
|
||||
|
||||
assert.deepEqual(extend(a, b), { a: undefined, b: "foo" })
|
||||
assert.deepEqual(extend(b, a), { a: undefined, b: "foo" })
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("handle 0", function(assert) {
|
||||
var a = { a: "default" }
|
||||
var b = { a: 0 }
|
||||
|
||||
assert.deepEqual(extend(a, b), { a: 0 })
|
||||
assert.deepEqual(extend(b, a), { a: "default" })
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("is immutable", function (assert) {
|
||||
var record = {}
|
||||
|
||||
extend(record, { foo: "bar" })
|
||||
assert.equal(record.foo, undefined)
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("null as argument", function (assert) {
|
||||
var a = { foo: "bar" }
|
||||
var b = null
|
||||
var c = void 0
|
||||
|
||||
assert.deepEqual(extend(b, a, c), { foo: "bar" })
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("mutable", function (assert) {
|
||||
var a = { foo: "bar" }
|
||||
|
||||
mutableExtend(a, { bar: "baz" })
|
||||
|
||||
assert.equal(a.bar, "baz")
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("null prototype", function(assert) {
|
||||
var a = { a: "foo" }
|
||||
var b = Object.create(null)
|
||||
b.b = "bar";
|
||||
|
||||
assert.deepEqual(extend(a, b), { a: "foo", b: "bar" })
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("null prototype mutable", function (assert) {
|
||||
var a = { foo: "bar" }
|
||||
var b = Object.create(null)
|
||||
b.bar = "baz";
|
||||
|
||||
mutableExtend(a, b)
|
||||
|
||||
assert.equal(a.bar, "baz")
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("prototype pollution", function (assert) {
|
||||
var a = {}
|
||||
var maliciousPayload = '{"__proto__":{"oops":"It works!"}}'
|
||||
|
||||
assert.strictEqual(a.oops, undefined)
|
||||
extend({}, maliciousPayload)
|
||||
assert.strictEqual(a.oops, undefined)
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("prototype pollution mutable", function (assert) {
|
||||
var a = {}
|
||||
var maliciousPayload = '{"__proto__":{"oops":"It works!"}}'
|
||||
|
||||
assert.strictEqual(a.oops, undefined)
|
||||
mutableExtend({}, maliciousPayload)
|
||||
assert.strictEqual(a.oops, undefined)
|
||||
assert.end()
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict'
|
||||
|
||||
const { join } = require('path')
|
||||
const { tmpdir } = require('os')
|
||||
const { unlinkSync } = require('fs')
|
||||
|
||||
const files = []
|
||||
let count = 0
|
||||
|
||||
function file () {
|
||||
const file = join(tmpdir(), `thread-stream-${process.pid}-${count++}`)
|
||||
files.push(file)
|
||||
return file
|
||||
}
|
||||
|
||||
process.on('beforeExit', () => {
|
||||
for (const file of files) {
|
||||
try {
|
||||
unlinkSync(file)
|
||||
} catch (e) {
|
||||
// ignore cleanup errors
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
module.exports.file = file
|
||||
@@ -0,0 +1,88 @@
|
||||
export type Schema = ObjectSchema | ArraySchema | StringSchema | NumberSchema | IntegerSchema | BooleanSchema | NullSchema;
|
||||
export type _JSONSchema = boolean | JSONSchema;
|
||||
export type JSONSchema = {
|
||||
[k: string]: unknown;
|
||||
$schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
|
||||
$id?: string;
|
||||
$anchor?: string;
|
||||
$ref?: string;
|
||||
$dynamicRef?: string;
|
||||
$dynamicAnchor?: string;
|
||||
$vocabulary?: Record<string, boolean>;
|
||||
$comment?: string;
|
||||
$defs?: Record<string, JSONSchema>;
|
||||
type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
|
||||
additionalItems?: _JSONSchema;
|
||||
unevaluatedItems?: _JSONSchema;
|
||||
prefixItems?: _JSONSchema[];
|
||||
items?: _JSONSchema | _JSONSchema[];
|
||||
contains?: _JSONSchema;
|
||||
additionalProperties?: _JSONSchema;
|
||||
unevaluatedProperties?: _JSONSchema;
|
||||
properties?: Record<string, _JSONSchema>;
|
||||
patternProperties?: Record<string, _JSONSchema>;
|
||||
dependentSchemas?: Record<string, _JSONSchema>;
|
||||
propertyNames?: _JSONSchema;
|
||||
if?: _JSONSchema;
|
||||
then?: _JSONSchema;
|
||||
else?: _JSONSchema;
|
||||
allOf?: JSONSchema[];
|
||||
anyOf?: JSONSchema[];
|
||||
oneOf?: JSONSchema[];
|
||||
not?: _JSONSchema;
|
||||
multipleOf?: number;
|
||||
maximum?: number;
|
||||
exclusiveMaximum?: number | boolean;
|
||||
minimum?: number;
|
||||
exclusiveMinimum?: number | boolean;
|
||||
maxLength?: number;
|
||||
minLength?: number;
|
||||
pattern?: string;
|
||||
maxItems?: number;
|
||||
minItems?: number;
|
||||
uniqueItems?: boolean;
|
||||
maxContains?: number;
|
||||
minContains?: number;
|
||||
maxProperties?: number;
|
||||
minProperties?: number;
|
||||
required?: string[];
|
||||
dependentRequired?: Record<string, string[]>;
|
||||
enum?: Array<string | number | boolean | null>;
|
||||
const?: string | number | boolean | null;
|
||||
id?: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
default?: unknown;
|
||||
deprecated?: boolean;
|
||||
readOnly?: boolean;
|
||||
writeOnly?: boolean;
|
||||
nullable?: boolean;
|
||||
examples?: unknown[];
|
||||
format?: string;
|
||||
contentMediaType?: string;
|
||||
contentEncoding?: string;
|
||||
contentSchema?: JSONSchema;
|
||||
_prefault?: unknown;
|
||||
};
|
||||
export type BaseSchema = JSONSchema;
|
||||
export interface ObjectSchema extends JSONSchema {
|
||||
type: "object";
|
||||
}
|
||||
export interface ArraySchema extends JSONSchema {
|
||||
type: "array";
|
||||
}
|
||||
export interface StringSchema extends JSONSchema {
|
||||
type: "string";
|
||||
}
|
||||
export interface NumberSchema extends JSONSchema {
|
||||
type: "number";
|
||||
}
|
||||
export interface IntegerSchema extends JSONSchema {
|
||||
type: "integer";
|
||||
}
|
||||
export interface BooleanSchema extends JSONSchema {
|
||||
type: "boolean";
|
||||
}
|
||||
export interface NullSchema extends JSONSchema {
|
||||
type: "null";
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LegacyESLint = exports.ESLint = exports.FlatESLint = void 0;
|
||||
var FlatESLint_1 = require("./eslint/FlatESLint");
|
||||
Object.defineProperty(exports, "FlatESLint", { enumerable: true, get: function () { return FlatESLint_1.FlatESLint; } });
|
||||
var FlatESLint_2 = require("./eslint/FlatESLint");
|
||||
Object.defineProperty(exports, "ESLint", { enumerable: true, get: function () { return FlatESLint_2.FlatESLint; } });
|
||||
var LegacyESLint_1 = require("./eslint/LegacyESLint");
|
||||
// TODO(typescript-eslint@v9) - remove this in the next major release
|
||||
/**
|
||||
* @deprecated - use ESLint instead
|
||||
*/
|
||||
Object.defineProperty(exports, "LegacyESLint", { enumerable: true, get: function () { return LegacyESLint_1.LegacyESLint; } });
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../src/assertions.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iCAAiC,CAC7C,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,kBAAkB,GAAG,UAAU,EACtC,MAAM,SAAI,QAOb;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qCAAqC,CACjD,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,kBAAkB,GAAG,UAAU,EACtC,MAAM,SAAI,QAUb;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oCAAoC,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAQjH"}
|
||||
@@ -0,0 +1,12 @@
|
||||
export type MessageIds = 'comparingNullableToFalse' | 'comparingNullableToTrueDirect' | 'comparingNullableToTrueNegated' | 'direct' | 'negated' | 'noStrictNullCheck';
|
||||
export type Options = [
|
||||
{
|
||||
allowComparingNullableBooleansToFalse?: boolean;
|
||||
allowComparingNullableBooleansToTrue?: boolean;
|
||||
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean;
|
||||
}
|
||||
];
|
||||
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,19 @@
|
||||
export { N as NodeBenchmarkRunner, T as VitestTestRunner } from './chunks/test.DNmyFkvJ.js';
|
||||
import '@vitest/runner';
|
||||
import '@vitest/utils/helpers';
|
||||
import '@vitest/utils/timers';
|
||||
import './chunks/benchmark.CX_oY03V.js';
|
||||
import '@vitest/runner/utils';
|
||||
import './chunks/utils.BX5Fg8C4.js';
|
||||
import '@vitest/expect';
|
||||
import '@vitest/utils/error';
|
||||
import 'pathe';
|
||||
import '@vitest/spy';
|
||||
import '@vitest/utils/offset';
|
||||
import '@vitest/utils/source-map';
|
||||
import './chunks/_commonjsHelpers.D26ty3Ew.js';
|
||||
import './chunks/rpc.MzXet3jl.js';
|
||||
import './chunks/index.Chj8NDwU.js';
|
||||
import '@vitest/snapshot';
|
||||
|
||||
console.warn("Importing from \"vitest/runners\" is deprecated since Vitest 4.1. Please use \"vitest\" instead.");
|
||||
@@ -0,0 +1,94 @@
|
||||
import { IncomingHttpHeaders } from './header'
|
||||
import Dispatcher from './dispatcher'
|
||||
import { BodyInit, Headers } from './fetch'
|
||||
|
||||
/** The scope associated with a mock dispatch. */
|
||||
declare class MockScope<TData extends object = object> {
|
||||
constructor (mockDispatch: MockInterceptor.MockDispatch<TData>)
|
||||
/** Delay a reply by a set amount of time in ms. */
|
||||
delay (waitInMs: number): MockScope<TData>
|
||||
/** Persist the defined mock data for the associated reply. It will return the defined mock data indefinitely. */
|
||||
persist (): MockScope<TData>
|
||||
/** Define a reply for a set amount of matching requests. */
|
||||
times (repeatTimes: number): MockScope<TData>
|
||||
}
|
||||
|
||||
/** The interceptor for a Mock. */
|
||||
declare class MockInterceptor {
|
||||
constructor (options: MockInterceptor.Options, mockDispatches: MockInterceptor.MockDispatch[])
|
||||
/** Mock an undici request with the defined reply. */
|
||||
reply<TData extends object = object>(replyOptionsCallback: MockInterceptor.MockReplyOptionsCallback<TData>): MockScope<TData>
|
||||
reply<TData extends object = object>(
|
||||
statusCode: number,
|
||||
data?: TData | Buffer | string | MockInterceptor.MockResponseDataHandler<TData>,
|
||||
responseOptions?: MockInterceptor.MockResponseOptions
|
||||
): MockScope<TData>
|
||||
/** Mock an undici request by throwing the defined reply error. */
|
||||
replyWithError<TError extends Error = Error>(error: TError): MockScope
|
||||
/** Set default reply headers on the interceptor for subsequent mocked replies. */
|
||||
defaultReplyHeaders (headers: IncomingHttpHeaders): MockInterceptor
|
||||
/** Set default reply trailers on the interceptor for subsequent mocked replies. */
|
||||
defaultReplyTrailers (trailers: Record<string, string>): MockInterceptor
|
||||
/** Set automatically calculated content-length header on subsequent mocked replies. */
|
||||
replyContentLength (): MockInterceptor
|
||||
}
|
||||
|
||||
declare namespace MockInterceptor {
|
||||
/** MockInterceptor options. */
|
||||
export interface Options {
|
||||
/** Path to intercept on. */
|
||||
path: string | RegExp | ((path: string) => boolean);
|
||||
/** Method to intercept on. Defaults to GET. */
|
||||
method?: string | RegExp | ((method: string) => boolean);
|
||||
/** Body to intercept on. */
|
||||
body?: string | RegExp | ((body: string) => boolean);
|
||||
/** Headers to intercept on. */
|
||||
headers?: Record<string, string | RegExp | ((body: string) => boolean)> | ((headers: Record<string, string>) => boolean);
|
||||
/** Query params to intercept on */
|
||||
query?: Record<string, any>;
|
||||
}
|
||||
export interface MockDispatch<TData extends object = object, TError extends Error = Error> extends Options {
|
||||
times: number | null;
|
||||
persist: boolean;
|
||||
consumed: boolean;
|
||||
data: MockDispatchData<TData, TError>;
|
||||
}
|
||||
export interface MockDispatchData<TData extends object = object, TError extends Error = Error> extends MockResponseOptions {
|
||||
error: TError | null;
|
||||
statusCode?: number;
|
||||
data?: TData | string;
|
||||
}
|
||||
export interface MockResponseOptions {
|
||||
headers?: IncomingHttpHeaders;
|
||||
trailers?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface MockResponseCallbackOptions {
|
||||
path: string;
|
||||
method: string;
|
||||
headers?: Headers | Record<string, string>;
|
||||
origin?: string;
|
||||
body?: BodyInit | Dispatcher.DispatchOptions['body'] | null;
|
||||
}
|
||||
|
||||
export type MockResponseDataHandler<TData extends object = object> = (
|
||||
opts: MockResponseCallbackOptions
|
||||
) => TData | Buffer | string
|
||||
|
||||
export type MockReplyOptionsCallback<TData extends object = object> = (
|
||||
opts: MockResponseCallbackOptions
|
||||
) => { statusCode: number, data?: TData | Buffer | string, responseOptions?: MockResponseOptions }
|
||||
}
|
||||
|
||||
interface Interceptable extends Dispatcher {
|
||||
/** Intercepts any matching requests that use the same origin as this mock client. */
|
||||
intercept(options: MockInterceptor.Options): MockInterceptor;
|
||||
/** Clean up all the prepared mocks. */
|
||||
cleanMocks (): void
|
||||
}
|
||||
|
||||
export {
|
||||
Interceptable,
|
||||
MockInterceptor,
|
||||
MockScope
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABILITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference lib="es2021.promise" />
|
||||
|
||||
interface ErrorOptions {
|
||||
cause?: unknown;
|
||||
}
|
||||
|
||||
interface Error {
|
||||
cause?: unknown;
|
||||
}
|
||||
|
||||
interface ErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): Error;
|
||||
(message?: string, options?: ErrorOptions): Error;
|
||||
}
|
||||
|
||||
interface EvalErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): EvalError;
|
||||
(message?: string, options?: ErrorOptions): EvalError;
|
||||
}
|
||||
|
||||
interface RangeErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): RangeError;
|
||||
(message?: string, options?: ErrorOptions): RangeError;
|
||||
}
|
||||
|
||||
interface ReferenceErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): ReferenceError;
|
||||
(message?: string, options?: ErrorOptions): ReferenceError;
|
||||
}
|
||||
|
||||
interface SyntaxErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): SyntaxError;
|
||||
(message?: string, options?: ErrorOptions): SyntaxError;
|
||||
}
|
||||
|
||||
interface TypeErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): TypeError;
|
||||
(message?: string, options?: ErrorOptions): TypeError;
|
||||
}
|
||||
|
||||
interface URIErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): URIError;
|
||||
(message?: string, options?: ErrorOptions): URIError;
|
||||
}
|
||||
|
||||
interface AggregateErrorConstructor {
|
||||
new (
|
||||
errors: Iterable<any>,
|
||||
message?: string,
|
||||
options?: ErrorOptions,
|
||||
): AggregateError;
|
||||
(
|
||||
errors: Iterable<any>,
|
||||
message?: string,
|
||||
options?: ErrorOptions,
|
||||
): AggregateError;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2014 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var util = require('./util');
|
||||
|
||||
/**
|
||||
* Determine whether mappingB is after mappingA with respect to generated
|
||||
* position.
|
||||
*/
|
||||
function generatedPositionAfter(mappingA, mappingB) {
|
||||
// Optimized for most common case
|
||||
var lineA = mappingA.generatedLine;
|
||||
var lineB = mappingB.generatedLine;
|
||||
var columnA = mappingA.generatedColumn;
|
||||
var columnB = mappingB.generatedColumn;
|
||||
return lineB > lineA || lineB == lineA && columnB >= columnA ||
|
||||
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* A data structure to provide a sorted view of accumulated mappings in a
|
||||
* performance conscious manner. It trades a neglibable overhead in general
|
||||
* case for a large speedup in case of mappings being added in order.
|
||||
*/
|
||||
function MappingList() {
|
||||
this._array = [];
|
||||
this._sorted = true;
|
||||
// Serves as infimum
|
||||
this._last = {generatedLine: -1, generatedColumn: 0};
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through internal items. This method takes the same arguments that
|
||||
* `Array.prototype.forEach` takes.
|
||||
*
|
||||
* NOTE: The order of the mappings is NOT guaranteed.
|
||||
*/
|
||||
MappingList.prototype.unsortedForEach =
|
||||
function MappingList_forEach(aCallback, aThisArg) {
|
||||
this._array.forEach(aCallback, aThisArg);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add the given source mapping.
|
||||
*
|
||||
* @param Object aMapping
|
||||
*/
|
||||
MappingList.prototype.add = function MappingList_add(aMapping) {
|
||||
if (generatedPositionAfter(this._last, aMapping)) {
|
||||
this._last = aMapping;
|
||||
this._array.push(aMapping);
|
||||
} else {
|
||||
this._sorted = false;
|
||||
this._array.push(aMapping);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the flat, sorted array of mappings. The mappings are sorted by
|
||||
* generated position.
|
||||
*
|
||||
* WARNING: This method returns internal data without copying, for
|
||||
* performance. The return value must NOT be mutated, and should be treated as
|
||||
* an immutable borrow. If you want to take ownership, you must make your own
|
||||
* copy.
|
||||
*/
|
||||
MappingList.prototype.toArray = function MappingList_toArray() {
|
||||
if (!this._sorted) {
|
||||
this._array.sort(util.compareByGeneratedPositionsInflated);
|
||||
this._sorted = true;
|
||||
}
|
||||
return this._array;
|
||||
};
|
||||
|
||||
exports.MappingList = MappingList;
|
||||
@@ -0,0 +1,70 @@
|
||||
import fs from "node:fs";
|
||||
import module from "node:module";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
// NOTE: Keep VS Code extension's resolveTsdkPathToExe in sync with this function.
|
||||
export default function getExePath() {
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const normalizedDirname = __dirname.replace(/\\/g, "/");
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
|
||||
const pkgName = pkg.name;
|
||||
const baseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
||||
const expectedBinName = baseName === "typescript" ? "tsc" : "tsgo";
|
||||
const binNames = pkg.bin && typeof pkg.bin === "object" ? Object.keys(pkg.bin) : [];
|
||||
if (binNames.length !== 1 || binNames[0] !== expectedBinName) {
|
||||
throw new Error(`Expected ${pkgName} to declare exactly one bin entry named ${expectedBinName}.`);
|
||||
}
|
||||
let binName = expectedBinName;
|
||||
let exeDir;
|
||||
|
||||
const expectedPackage = baseName + "-" + process.platform + "-" + process.arch;
|
||||
|
||||
if (normalizedDirname.endsWith("/_packages/" + baseName + "/lib")) {
|
||||
// We're running directly from source in the repo.
|
||||
// The local repo build (`hereby build`) always produces `tsgo`, regardless
|
||||
// of the published `bin` name, so don't use binName here.
|
||||
exeDir = path.resolve(__dirname, "..", "..", "..", "built", "local");
|
||||
binName = "tsgo";
|
||||
}
|
||||
else if (normalizedDirname.endsWith("/built/npm/" + baseName + "/lib")) {
|
||||
// We're running from the built output.
|
||||
exeDir = path.resolve(__dirname, "..", "..", expectedPackage, "lib");
|
||||
}
|
||||
else {
|
||||
// We're actually running from an installed package.
|
||||
const platformPackageName = "@typescript/" + expectedPackage;
|
||||
try {
|
||||
if (typeof import.meta.resolve === "undefined") {
|
||||
// v16.20.1
|
||||
const require = module.createRequire(import.meta.url);
|
||||
const packageJson = require.resolve(platformPackageName + "/package.json");
|
||||
exeDir = path.join(path.dirname(packageJson), "lib");
|
||||
}
|
||||
else {
|
||||
// v20.6.0, v18.19.0
|
||||
const packageJson = import.meta.resolve(platformPackageName + "/package.json");
|
||||
const packageJsonPath = fileURLToPath(packageJson);
|
||||
exeDir = path.join(path.dirname(packageJsonPath), "lib");
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("Unable to resolve " + platformPackageName + ". Either your platform is unsupported, or you are missing the package on disk.");
|
||||
}
|
||||
}
|
||||
|
||||
let exe = path.join(exeDir, binName);
|
||||
if (process.platform === "win32") {
|
||||
exe += ".exe";
|
||||
if (exe.length >= 248) {
|
||||
exe = "\\\\?\\" + exe;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs.existsSync(exe)) {
|
||||
throw new Error("Executable not found: " + exe);
|
||||
}
|
||||
|
||||
return exe;
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
var parseInt64 = require('pg-int8');
|
||||
|
||||
var parseBits = function(data, bits, offset, invert, callback) {
|
||||
offset = offset || 0;
|
||||
invert = invert || false;
|
||||
callback = callback || function(lastValue, newValue, bits) { return (lastValue * Math.pow(2, bits)) + newValue; };
|
||||
var offsetBytes = offset >> 3;
|
||||
|
||||
var inv = function(value) {
|
||||
if (invert) {
|
||||
return ~value & 0xff;
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
// read first (maybe partial) byte
|
||||
var mask = 0xff;
|
||||
var firstBits = 8 - (offset % 8);
|
||||
if (bits < firstBits) {
|
||||
mask = (0xff << (8 - bits)) & 0xff;
|
||||
firstBits = bits;
|
||||
}
|
||||
|
||||
if (offset) {
|
||||
mask = mask >> (offset % 8);
|
||||
}
|
||||
|
||||
var result = 0;
|
||||
if ((offset % 8) + bits >= 8) {
|
||||
result = callback(0, inv(data[offsetBytes]) & mask, firstBits);
|
||||
}
|
||||
|
||||
// read bytes
|
||||
var bytes = (bits + offset) >> 3;
|
||||
for (var i = offsetBytes + 1; i < bytes; i++) {
|
||||
result = callback(result, inv(data[i]), 8);
|
||||
}
|
||||
|
||||
// bits to read, that are not a complete byte
|
||||
var lastBits = (bits + offset) % 8;
|
||||
if (lastBits > 0) {
|
||||
result = callback(result, inv(data[bytes]) >> (8 - lastBits), lastBits);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
var parseFloatFromBits = function(data, precisionBits, exponentBits) {
|
||||
var bias = Math.pow(2, exponentBits - 1) - 1;
|
||||
var sign = parseBits(data, 1);
|
||||
var exponent = parseBits(data, exponentBits, 1);
|
||||
|
||||
if (exponent === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// parse mantissa
|
||||
var precisionBitsCounter = 1;
|
||||
var parsePrecisionBits = function(lastValue, newValue, bits) {
|
||||
if (lastValue === 0) {
|
||||
lastValue = 1;
|
||||
}
|
||||
|
||||
for (var i = 1; i <= bits; i++) {
|
||||
precisionBitsCounter /= 2;
|
||||
if ((newValue & (0x1 << (bits - i))) > 0) {
|
||||
lastValue += precisionBitsCounter;
|
||||
}
|
||||
}
|
||||
|
||||
return lastValue;
|
||||
};
|
||||
|
||||
var mantissa = parseBits(data, precisionBits, exponentBits + 1, false, parsePrecisionBits);
|
||||
|
||||
// special cases
|
||||
if (exponent == (Math.pow(2, exponentBits + 1) - 1)) {
|
||||
if (mantissa === 0) {
|
||||
return (sign === 0) ? Infinity : -Infinity;
|
||||
}
|
||||
|
||||
return NaN;
|
||||
}
|
||||
|
||||
// normale number
|
||||
return ((sign === 0) ? 1 : -1) * Math.pow(2, exponent - bias) * mantissa;
|
||||
};
|
||||
|
||||
var parseInt16 = function(value) {
|
||||
if (parseBits(value, 1) == 1) {
|
||||
return -1 * (parseBits(value, 15, 1, true) + 1);
|
||||
}
|
||||
|
||||
return parseBits(value, 15, 1);
|
||||
};
|
||||
|
||||
var parseInt32 = function(value) {
|
||||
if (parseBits(value, 1) == 1) {
|
||||
return -1 * (parseBits(value, 31, 1, true) + 1);
|
||||
}
|
||||
|
||||
return parseBits(value, 31, 1);
|
||||
};
|
||||
|
||||
var parseFloat32 = function(value) {
|
||||
return parseFloatFromBits(value, 23, 8);
|
||||
};
|
||||
|
||||
var parseFloat64 = function(value) {
|
||||
return parseFloatFromBits(value, 52, 11);
|
||||
};
|
||||
|
||||
var parseNumeric = function(value) {
|
||||
var sign = parseBits(value, 16, 32);
|
||||
if (sign == 0xc000) {
|
||||
return NaN;
|
||||
}
|
||||
|
||||
var weight = Math.pow(10000, parseBits(value, 16, 16));
|
||||
var result = 0;
|
||||
|
||||
var digits = [];
|
||||
var ndigits = parseBits(value, 16);
|
||||
for (var i = 0; i < ndigits; i++) {
|
||||
result += parseBits(value, 16, 64 + (16 * i)) * weight;
|
||||
weight /= 10000;
|
||||
}
|
||||
|
||||
var scale = Math.pow(10, parseBits(value, 16, 48));
|
||||
return ((sign === 0) ? 1 : -1) * Math.round(result * scale) / scale;
|
||||
};
|
||||
|
||||
var parseDate = function(isUTC, value) {
|
||||
var sign = parseBits(value, 1);
|
||||
var rawValue = parseBits(value, 63, 1);
|
||||
|
||||
// discard usecs and shift from 2000 to 1970
|
||||
var result = new Date((((sign === 0) ? 1 : -1) * rawValue / 1000) + 946684800000);
|
||||
|
||||
if (!isUTC) {
|
||||
result.setTime(result.getTime() + result.getTimezoneOffset() * 60000);
|
||||
}
|
||||
|
||||
// add microseconds to the date
|
||||
result.usec = rawValue % 1000;
|
||||
result.getMicroSeconds = function() {
|
||||
return this.usec;
|
||||
};
|
||||
result.setMicroSeconds = function(value) {
|
||||
this.usec = value;
|
||||
};
|
||||
result.getUTCMicroSeconds = function() {
|
||||
return this.usec;
|
||||
};
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
var parseArray = function(value) {
|
||||
var dim = parseBits(value, 32);
|
||||
|
||||
var flags = parseBits(value, 32, 32);
|
||||
var elementType = parseBits(value, 32, 64);
|
||||
|
||||
var offset = 96;
|
||||
var dims = [];
|
||||
for (var i = 0; i < dim; i++) {
|
||||
// parse dimension
|
||||
dims[i] = parseBits(value, 32, offset);
|
||||
offset += 32;
|
||||
|
||||
// ignore lower bounds
|
||||
offset += 32;
|
||||
}
|
||||
|
||||
var parseElement = function(elementType) {
|
||||
// parse content length
|
||||
var length = parseBits(value, 32, offset);
|
||||
offset += 32;
|
||||
|
||||
// parse null values
|
||||
if (length == 0xffffffff) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var result;
|
||||
if ((elementType == 0x17) || (elementType == 0x14)) {
|
||||
// int/bigint
|
||||
result = parseBits(value, length * 8, offset);
|
||||
offset += length * 8;
|
||||
return result;
|
||||
}
|
||||
else if (elementType == 0x19) {
|
||||
// string
|
||||
result = value.toString(this.encoding, offset >> 3, (offset += (length << 3)) >> 3);
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
console.log("ERROR: ElementType not implemented: " + elementType);
|
||||
}
|
||||
};
|
||||
|
||||
var parse = function(dimension, elementType) {
|
||||
var array = [];
|
||||
var i;
|
||||
|
||||
if (dimension.length > 1) {
|
||||
var count = dimension.shift();
|
||||
for (i = 0; i < count; i++) {
|
||||
array[i] = parse(dimension, elementType);
|
||||
}
|
||||
dimension.unshift(count);
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < dimension[0]; i++) {
|
||||
array[i] = parseElement(elementType);
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
};
|
||||
|
||||
return parse(dims, elementType);
|
||||
};
|
||||
|
||||
var parseText = function(value) {
|
||||
return value.toString('utf8');
|
||||
};
|
||||
|
||||
var parseBool = function(value) {
|
||||
if(value === null) return null;
|
||||
return (parseBits(value, 8) > 0);
|
||||
};
|
||||
|
||||
var init = function(register) {
|
||||
register(20, parseInt64);
|
||||
register(21, parseInt16);
|
||||
register(23, parseInt32);
|
||||
register(26, parseInt32);
|
||||
register(1700, parseNumeric);
|
||||
register(700, parseFloat32);
|
||||
register(701, parseFloat64);
|
||||
register(16, parseBool);
|
||||
register(1114, parseDate.bind(null, false));
|
||||
register(1184, parseDate.bind(null, true));
|
||||
register(1000, parseArray);
|
||||
register(1007, parseArray);
|
||||
register(1016, parseArray);
|
||||
register(1008, parseArray);
|
||||
register(1009, parseArray);
|
||||
register(25, parseText);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
init: init
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sha1 = exports.SHA1 = void 0;
|
||||
/**
|
||||
* SHA1 (RFC 3174) legacy hash function.
|
||||
* @module
|
||||
* @deprecated
|
||||
*/
|
||||
const legacy_ts_1 = require("./legacy.js");
|
||||
/** @deprecated Use import from `noble/hashes/legacy` module */
|
||||
exports.SHA1 = legacy_ts_1.SHA1;
|
||||
/** @deprecated Use import from `noble/hashes/legacy` module */
|
||||
exports.sha1 = legacy_ts_1.sha1;
|
||||
//# sourceMappingURL=sha1.js.map
|
||||
@@ -0,0 +1,23 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/////////////////////////////
|
||||
/// WorkerGlobalScope APIs
|
||||
/////////////////////////////
|
||||
// These are only available in a Web Worker
|
||||
declare function importScripts(...urls: string[]): void;
|
||||
@@ -0,0 +1,9 @@
|
||||
import { _ as _array_with_holes } from "./_array_with_holes.js";
|
||||
import { _ as _iterable_to_array_limit_loose } from "./_iterable_to_array_limit_loose.js";
|
||||
import { _ as _non_iterable_rest } from "./_non_iterable_rest.js";
|
||||
import { _ as _unsupported_iterable_to_array } from "./_unsupported_iterable_to_array.js";
|
||||
|
||||
function _sliced_to_array_loose(arr, i) {
|
||||
return _array_with_holes(arr) || _iterable_to_array_limit_loose(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
||||
}
|
||||
export { _sliced_to_array_loose as _ };
|
||||
@@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
module.exports = function generate_not(it, $keyword, $ruleType) {
|
||||
var out = ' ';
|
||||
var $lvl = it.level;
|
||||
var $dataLvl = it.dataLevel;
|
||||
var $schema = it.schema[$keyword];
|
||||
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||
var $breakOnError = !it.opts.allErrors;
|
||||
var $data = 'data' + ($dataLvl || '');
|
||||
var $errs = 'errs__' + $lvl;
|
||||
var $it = it.util.copy(it);
|
||||
$it.level++;
|
||||
var $nextValid = 'valid' + $it.level;
|
||||
if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
|
||||
$it.schema = $schema;
|
||||
$it.schemaPath = $schemaPath;
|
||||
$it.errSchemaPath = $errSchemaPath;
|
||||
out += ' var ' + ($errs) + ' = errors; ';
|
||||
var $wasComposite = it.compositeRule;
|
||||
it.compositeRule = $it.compositeRule = true;
|
||||
$it.createErrors = false;
|
||||
var $allErrorsOption;
|
||||
if ($it.opts.allErrors) {
|
||||
$allErrorsOption = $it.opts.allErrors;
|
||||
$it.opts.allErrors = false;
|
||||
}
|
||||
out += ' ' + (it.validate($it)) + ' ';
|
||||
$it.createErrors = true;
|
||||
if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption;
|
||||
it.compositeRule = $it.compositeRule = $wasComposite;
|
||||
out += ' if (' + ($nextValid) + ') { ';
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should NOT be valid\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
out += ' } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
|
||||
if (it.opts.allErrors) {
|
||||
out += ' } ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = '; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should NOT be valid\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
if ($breakOnError) {
|
||||
out += ' if (false) { ';
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import postcss from './postcss.js'
|
||||
|
||||
export default postcss
|
||||
|
||||
export const stringify = postcss.stringify
|
||||
export const fromJSON = postcss.fromJSON
|
||||
export const plugin = postcss.plugin
|
||||
export const parse = postcss.parse
|
||||
export const list = postcss.list
|
||||
|
||||
export const document = postcss.document
|
||||
export const comment = postcss.comment
|
||||
export const atRule = postcss.atRule
|
||||
export const rule = postcss.rule
|
||||
export const decl = postcss.decl
|
||||
export const root = postcss.root
|
||||
|
||||
export const CssSyntaxError = postcss.CssSyntaxError
|
||||
export const Declaration = postcss.Declaration
|
||||
export const Container = postcss.Container
|
||||
export const Processor = postcss.Processor
|
||||
export const Document = postcss.Document
|
||||
export const Comment = postcss.Comment
|
||||
export const Warning = postcss.Warning
|
||||
export const AtRule = postcss.AtRule
|
||||
export const Result = postcss.Result
|
||||
export const Input = postcss.Input
|
||||
export const Rule = postcss.Rule
|
||||
export const Root = postcss.Root
|
||||
export const Node = postcss.Node
|
||||
@@ -0,0 +1,114 @@
|
||||
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from './codec';
|
||||
import { ReadonlyUint8Array } from './readonly-uint8array';
|
||||
/**
|
||||
* Transforms an encoder by mapping its input values.
|
||||
*
|
||||
* This function takes an existing `Encoder<A>` and returns an `Encoder<B>`, allowing values of type `B`
|
||||
* to be converted into values of type `A` before encoding. The transformation is applied via the `unmap` function.
|
||||
*
|
||||
* This is useful for handling type conversions, applying default values, or structuring data before encoding.
|
||||
*
|
||||
* For more details, see {@link transformCodec}.
|
||||
*
|
||||
* @typeParam TOldFrom - The original type expected by the encoder.
|
||||
* @typeParam TNewFrom - The new type that will be transformed before encoding.
|
||||
*
|
||||
* @param encoder - The encoder to transform.
|
||||
* @param unmap - A function that converts values of `TNewFrom` into `TOldFrom` before encoding.
|
||||
* @returns A new encoder that accepts `TNewFrom` values and transforms them before encoding.
|
||||
*
|
||||
* @example
|
||||
* Encoding a string by counting its characters and storing the length as a `u32`.
|
||||
* ```ts
|
||||
* const encoder = transformEncoder(getU32Encoder(), (value: string) => value.length);
|
||||
* encoder.encode("hello"); // 0x05000000 (stores length 5)
|
||||
* ```
|
||||
*
|
||||
* @see {@link transformCodec}
|
||||
* @see {@link transformDecoder}
|
||||
*/
|
||||
export declare function transformEncoder<TOldFrom, TNewFrom, TSize extends number>(encoder: FixedSizeEncoder<TOldFrom, TSize>, unmap: (value: TNewFrom) => TOldFrom): FixedSizeEncoder<TNewFrom, TSize>;
|
||||
export declare function transformEncoder<TOldFrom, TNewFrom>(encoder: VariableSizeEncoder<TOldFrom>, unmap: (value: TNewFrom) => TOldFrom): VariableSizeEncoder<TNewFrom>;
|
||||
export declare function transformEncoder<TOldFrom, TNewFrom>(encoder: Encoder<TOldFrom>, unmap: (value: TNewFrom) => TOldFrom): Encoder<TNewFrom>;
|
||||
/**
|
||||
* Transforms a decoder by mapping its output values.
|
||||
*
|
||||
* This function takes an existing `Decoder<A>` and returns a `Decoder<B>`, allowing values of type `A`
|
||||
* to be converted into values of type `B` after decoding. The transformation is applied via the `map` function.
|
||||
*
|
||||
* This is useful for post-processing, type conversions, or enriching decoded data.
|
||||
*
|
||||
* For more details, see {@link transformCodec}.
|
||||
*
|
||||
* @typeParam TOldTo - The original type returned by the decoder.
|
||||
* @typeParam TNewTo - The new type that will be transformed after decoding.
|
||||
*
|
||||
* @param decoder - The decoder to transform.
|
||||
* @param map - A function that converts values of `TOldTo` into `TNewTo` after decoding.
|
||||
* @returns A new decoder that decodes into `TNewTo`.
|
||||
*
|
||||
* @example
|
||||
* Decoding a stored `u32` length into a string of `'x'` characters.
|
||||
* ```ts
|
||||
* const decoder = transformDecoder(getU32Decoder(), (length) => 'x'.repeat(length));
|
||||
* decoder.decode(new Uint8Array([0x05, 0x00, 0x00, 0x00])); // "xxxxx"
|
||||
* ```
|
||||
*
|
||||
* @see {@link transformCodec}
|
||||
* @see {@link transformEncoder}
|
||||
*/
|
||||
export declare function transformDecoder<TOldTo, TNewTo, TSize extends number>(decoder: FixedSizeDecoder<TOldTo, TSize>, map: (value: TOldTo, bytes: ReadonlyUint8Array | Uint8Array, offset: number) => TNewTo): FixedSizeDecoder<TNewTo, TSize>;
|
||||
export declare function transformDecoder<TOldTo, TNewTo>(decoder: VariableSizeDecoder<TOldTo>, map: (value: TOldTo, bytes: ReadonlyUint8Array | Uint8Array, offset: number) => TNewTo): VariableSizeDecoder<TNewTo>;
|
||||
export declare function transformDecoder<TOldTo, TNewTo>(decoder: Decoder<TOldTo>, map: (value: TOldTo, bytes: ReadonlyUint8Array | Uint8Array, offset: number) => TNewTo): Decoder<TNewTo>;
|
||||
/**
|
||||
* Transforms a codec by mapping its input and output values.
|
||||
*
|
||||
* This function takes an existing `Codec<A, B>` and returns a `Codec<C, D>`, allowing:
|
||||
* - Values of type `C` to be transformed into `A` before encoding.
|
||||
* - Values of type `B` to be transformed into `D` after decoding.
|
||||
*
|
||||
* This is useful for adapting codecs to work with different representations, handling default values, or
|
||||
* converting between primitive and structured types.
|
||||
*
|
||||
* @typeParam TOldFrom - The original type expected by the codec.
|
||||
* @typeParam TNewFrom - The new type that will be transformed before encoding.
|
||||
* @typeParam TOldTo - The original type returned by the codec.
|
||||
* @typeParam TNewTo - The new type that will be transformed after decoding.
|
||||
*
|
||||
* @param codec - The codec to transform.
|
||||
* @param unmap - A function that converts values of `TNewFrom` into `TOldFrom` before encoding.
|
||||
* @param map - A function that converts values of `TOldTo` into `TNewTo` after decoding (optional).
|
||||
* @returns A new codec that encodes `TNewFrom` and decodes into `TNewTo`.
|
||||
*
|
||||
* @example
|
||||
* Mapping a `u32` codec to encode string lengths and decode them into `'x'` characters.
|
||||
* ```ts
|
||||
* const codec = transformCodec(
|
||||
* getU32Codec(),
|
||||
* (value: string) => value.length, // Encode string length
|
||||
* (length) => 'x'.repeat(length) // Decode length into a string of 'x's
|
||||
* );
|
||||
*
|
||||
* const bytes = codec.encode("hello"); // 0x05000000 (stores length 5)
|
||||
* const value = codec.decode(bytes); // "xxxxx"
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
* If only input transformation is needed, use {@link transformEncoder}.
|
||||
* If only output transformation is needed, use {@link transformDecoder}.
|
||||
*
|
||||
* ```ts
|
||||
* const bytes = transformEncoder(getU32Encoder(), (value: string) => value.length).encode("hello");
|
||||
* const value = transformDecoder(getU32Decoder(), (length) => 'x'.repeat(length)).decode(bytes);
|
||||
* ```
|
||||
*
|
||||
* @see {@link transformEncoder}
|
||||
* @see {@link transformDecoder}
|
||||
*/
|
||||
export declare function transformCodec<TOldFrom, TNewFrom, TTo extends TNewFrom & TOldFrom, TSize extends number>(codec: FixedSizeCodec<TOldFrom, TTo, TSize>, unmap: (value: TNewFrom) => TOldFrom): FixedSizeCodec<TNewFrom, TTo, TSize>;
|
||||
export declare function transformCodec<TOldFrom, TNewFrom, TTo extends TNewFrom & TOldFrom>(codec: VariableSizeCodec<TOldFrom, TTo>, unmap: (value: TNewFrom) => TOldFrom): VariableSizeCodec<TNewFrom, TTo>;
|
||||
export declare function transformCodec<TOldFrom, TNewFrom, TTo extends TNewFrom & TOldFrom>(codec: Codec<TOldFrom, TTo>, unmap: (value: TNewFrom) => TOldFrom): Codec<TNewFrom, TTo>;
|
||||
export declare function transformCodec<TOldFrom, TNewFrom, TOldTo extends TOldFrom, TNewTo extends TNewFrom, TSize extends number>(codec: FixedSizeCodec<TOldFrom, TOldTo, TSize>, unmap: (value: TNewFrom) => TOldFrom, map: (value: TOldTo, bytes: ReadonlyUint8Array | Uint8Array, offset: number) => TNewTo): FixedSizeCodec<TNewFrom, TNewTo, TSize>;
|
||||
export declare function transformCodec<TOldFrom, TNewFrom, TOldTo extends TOldFrom, TNewTo extends TNewFrom>(codec: VariableSizeCodec<TOldFrom, TOldTo>, unmap: (value: TNewFrom) => TOldFrom, map: (value: TOldTo, bytes: ReadonlyUint8Array | Uint8Array, offset: number) => TNewTo): VariableSizeCodec<TNewFrom, TNewTo>;
|
||||
export declare function transformCodec<TOldFrom, TNewFrom, TOldTo extends TOldFrom, TNewTo extends TNewFrom>(codec: Codec<TOldFrom, TOldTo>, unmap: (value: TNewFrom) => TOldFrom, map: (value: TOldTo, bytes: ReadonlyUint8Array | Uint8Array, offset: number) => TNewTo): Codec<TNewFrom, TNewTo>;
|
||||
//# sourceMappingURL=transform-codec.d.ts.map
|
||||
@@ -0,0 +1,5 @@
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
test("z.function", () => {
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
/* eslint-disable ts/ban-ts-comment */
|
||||
|
||||
export interface Disposable {
|
||||
// @ts-ignore -- Symbol.dispose might not be in user types
|
||||
[Symbol.dispose]: () => void
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024-present VoidZero Inc. & Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
end of terms and conditions
|
||||
|
||||
The licenses of externally maintained libraries from which parts of the Software is derived are listed [here](https://github.com/rolldown/rolldown/blob/main/THIRD-PARTY-LICENSE).
|
||||
Reference in New Issue
Block a user