WIP: bootstrap and partial real Solana watcher implementation

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

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021-Present VoidZero Inc. and Vitest 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.

View File

@@ -0,0 +1,23 @@
var test = require('tape');
var equal = require('../');
test('equal', function (t) {
t.ok(equal(
{ a : [ 2, 3 ], b : [ 4 ] },
{ a : [ 2, 3 ], b : [ 4 ] }
));
t.end();
});
test('not equal', function (t) {
t.notOk(equal(
{ x : 5, y : [6] },
{ x : 5, y : 6 }
));
t.end();
});
test('nested nulls', function (t) {
t.ok(equal([ null, null, null ], [ null, null, null ]));
t.end();
});

View File

@@ -0,0 +1 @@
export { _ as default } from "../esm/_iterable_to_array.js";

View File

@@ -0,0 +1,25 @@
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
import type plugin from './index';
declare const cjsExport: {
flatConfigs: {
'flat/all': FlatConfig.ConfigArray;
'flat/base': FlatConfig.Config;
'flat/disable-type-checked': FlatConfig.Config;
'flat/eslint-recommended': FlatConfig.Config;
'flat/recommended': FlatConfig.ConfigArray;
'flat/recommended-type-checked': FlatConfig.ConfigArray;
'flat/recommended-type-checked-only': FlatConfig.ConfigArray;
'flat/strict': FlatConfig.ConfigArray;
'flat/strict-type-checked': FlatConfig.ConfigArray;
'flat/strict-type-checked-only': FlatConfig.ConfigArray;
'flat/stylistic': FlatConfig.ConfigArray;
'flat/stylistic-type-checked': FlatConfig.ConfigArray;
'flat/stylistic-type-checked-only': FlatConfig.ConfigArray;
};
parser: FlatConfig.Parser;
plugin: typeof plugin;
};
export = cjsExport;

View File

@@ -0,0 +1,143 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const noEmptyMessage = (emptyType) => [
`${emptyType} allows any non-nullish value, including literals like \`0\` and \`""\`.`,
"- If that's what you want, disable this lint rule with an inline comment or configure the '{{ option }}' rule option.",
'- If you want a type meaning "any object", you probably want `object` instead.',
'- If you want a type meaning "any value", you probably want `unknown` instead.',
].join('\n');
exports.default = (0, util_1.createRule)({
name: 'no-empty-object-type',
meta: {
type: 'suggestion',
docs: {
description: 'Disallow accidentally using the "empty object" type',
recommended: 'recommended',
},
hasSuggestions: true,
messages: {
noEmptyInterface: noEmptyMessage('An empty interface declaration'),
noEmptyInterfaceWithSuper: 'An interface declaring no members is equivalent to its supertype.',
noEmptyObject: noEmptyMessage('The `{}` ("empty object") type'),
replaceEmptyInterface: 'Replace empty interface with `{{replacement}}`.',
replaceEmptyInterfaceWithSuper: 'Replace empty interface with a type alias.',
replaceEmptyObjectType: 'Replace `{}` with `{{replacement}}`.',
},
schema: [
{
type: 'object',
additionalProperties: false,
properties: {
allowInterfaces: {
type: 'string',
description: 'Whether to allow empty interfaces.',
enum: ['always', 'never', 'with-single-extends'],
},
allowObjectTypes: {
type: 'string',
description: 'Whether to allow empty object type literals.',
enum: ['always', 'never'],
},
allowWithName: {
type: 'string',
description: 'A stringified regular expression to allow interfaces and object type aliases with the configured name.',
},
},
},
],
},
defaultOptions: [
{
allowInterfaces: 'never',
allowObjectTypes: 'never',
},
],
create(context, [{ allowInterfaces, allowObjectTypes, allowWithName }]) {
const allowWithNameTester = allowWithName
? new RegExp(allowWithName, 'u')
: undefined;
return {
...(allowInterfaces !== 'always' && {
TSInterfaceDeclaration(node) {
if (allowWithNameTester?.test(node.id.name)) {
return;
}
const extend = node.extends;
if (node.body.body.length !== 0 ||
(extend.length === 1 &&
allowInterfaces === 'with-single-extends') ||
extend.length > 1) {
return;
}
const scope = context.sourceCode.getScope(node);
const mergedWithClassDeclaration = scope.set
.get(node.id.name)
?.defs.some(def => def.node.type === utils_1.AST_NODE_TYPES.ClassDeclaration);
if (extend.length === 0) {
context.report({
node: node.id,
messageId: 'noEmptyInterface',
data: { option: 'allowInterfaces' },
...(!mergedWithClassDeclaration && {
suggest: ['object', 'unknown'].map(replacement => ({
messageId: 'replaceEmptyInterface',
data: { replacement },
fix(fixer) {
const id = context.sourceCode.getText(node.id);
const typeParam = node.typeParameters
? context.sourceCode.getText(node.typeParameters)
: '';
return fixer.replaceText(node, `type ${id}${typeParam} = ${replacement}`);
},
})),
}),
});
return;
}
context.report({
node: node.id,
messageId: 'noEmptyInterfaceWithSuper',
...(!mergedWithClassDeclaration && {
suggest: [
{
messageId: 'replaceEmptyInterfaceWithSuper',
fix(fixer) {
const extended = context.sourceCode.getText(extend[0]);
const id = context.sourceCode.getText(node.id);
const typeParam = node.typeParameters
? context.sourceCode.getText(node.typeParameters)
: '';
return fixer.replaceText(node, `type ${id}${typeParam} = ${extended}`);
},
},
],
}),
});
},
}),
...(allowObjectTypes !== 'always' && {
TSTypeLiteral(node) {
if (node.members.length ||
node.parent.type === utils_1.AST_NODE_TYPES.TSIntersectionType ||
(allowWithNameTester &&
node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration &&
allowWithNameTester.test(node.parent.id.name))) {
return;
}
context.report({
node,
messageId: 'noEmptyObject',
data: { option: 'allowObjectTypes' },
suggest: ['object', 'unknown'].map(replacement => ({
messageId: 'replaceEmptyObjectType',
data: { replacement },
fix: (fixer) => fixer.replaceText(node, replacement),
})),
});
},
}),
};
},
});

View File

@@ -0,0 +1,134 @@
'use strict'
const nocolor = input => input
const plain = {
default: nocolor,
60: nocolor,
50: nocolor,
40: nocolor,
30: nocolor,
20: nocolor,
10: nocolor,
message: nocolor,
greyMessage: nocolor,
property: nocolor
}
const { createColors } = require('colorette')
const getLevelLabelData = require('./utils/get-level-label-data')
const availableColors = createColors({ useColor: true })
const { white, bgRed, red, yellow, green, blue, gray, cyan, magenta } = availableColors
const colored = {
default: white,
60: bgRed,
50: red,
40: yellow,
30: green,
20: blue,
10: gray,
message: cyan,
greyMessage: gray,
property: magenta
}
function resolveCustomColoredColorizer (customColors) {
return customColors.reduce(
function (agg, [level, color]) {
agg[level] = typeof availableColors[color] === 'function' ? availableColors[color] : white
return agg
},
{ default: white, message: cyan, greyMessage: gray, property: magenta }
)
}
function colorizeLevel (useOnlyCustomProps) {
return function (level, colorizer, { customLevels, customLevelNames } = {}) {
const [levelStr, levelNum] = getLevelLabelData(useOnlyCustomProps, customLevels, customLevelNames)(level)
return Object.prototype.hasOwnProperty.call(colorizer, levelNum) ? colorizer[levelNum](levelStr) : colorizer.default(levelStr)
}
}
function plainColorizer (useOnlyCustomProps) {
const newPlainColorizer = colorizeLevel(useOnlyCustomProps)
const customColoredColorizer = function (level, opts) {
return newPlainColorizer(level, plain, opts)
}
customColoredColorizer.message = plain.message
customColoredColorizer.greyMessage = plain.greyMessage
customColoredColorizer.property = plain.property
customColoredColorizer.colors = createColors({ useColor: false })
return customColoredColorizer
}
function coloredColorizer (useOnlyCustomProps) {
const newColoredColorizer = colorizeLevel(useOnlyCustomProps)
const customColoredColorizer = function (level, opts) {
return newColoredColorizer(level, colored, opts)
}
customColoredColorizer.message = colored.message
customColoredColorizer.property = colored.property
customColoredColorizer.greyMessage = colored.greyMessage
customColoredColorizer.colors = availableColors
return customColoredColorizer
}
function customColoredColorizerFactory (customColors, useOnlyCustomProps) {
const onlyCustomColored = resolveCustomColoredColorizer(customColors)
const customColored = useOnlyCustomProps ? onlyCustomColored : Object.assign({}, colored, onlyCustomColored)
const colorizeLevelCustom = colorizeLevel(useOnlyCustomProps)
const customColoredColorizer = function (level, opts) {
return colorizeLevelCustom(level, customColored, opts)
}
customColoredColorizer.colors = availableColors
customColoredColorizer.message = customColoredColorizer.message || customColored.message
customColoredColorizer.property = customColoredColorizer.property || customColored.property
customColoredColorizer.greyMessage = customColoredColorizer.greyMessage || customColored.greyMessage
return customColoredColorizer
}
/**
* Applies colorization, if possible, to a string representing the passed in
* `level`. For example, the default colorizer will return a "green" colored
* string for the "info" level.
*
* @typedef {function} ColorizerFunc
* @param {string|number} level In either case, the input will map to a color
* for the specified level or to the color for `USERLVL` if the level is not
* recognized.
* @property {function} message Accepts one string parameter that will be
* colorized to a predefined color.
* @property {Colorette.Colorette} colors Available color functions based on `useColor` (or `colorize`) context
*/
/**
* Factory function get a function to colorized levels. The returned function
* also includes a `.message(str)` method to colorize strings.
*
* @param {boolean} [useColors=false] When `true` a function that applies standard
* terminal colors is returned.
* @param {array[]} [customColors] Tuple where first item of each array is the
* level index and the second item is the color
* @param {boolean} [useOnlyCustomProps] When `true`, only use the provided
* custom colors provided and not fallback to default
*
* @returns {ColorizerFunc} `function (level) {}` has a `.message(str)` method to
* apply colorization to a string. The core function accepts either an integer
* `level` or a `string` level. The integer level will map to a known level
* string or to `USERLVL` if not known. The string `level` will map to the same
* colors as the integer `level` and will also default to `USERLVL` if the given
* string is not a recognized level name.
*/
module.exports = function getColorizer (useColors = false, customColors, useOnlyCustomProps) {
if (useColors && customColors !== undefined) {
return customColoredColorizerFactory(customColors, useOnlyCustomProps)
} else if (useColors) {
return coloredColorizer(useOnlyCustomProps)
}
return plainColorizer(useOnlyCustomProps)
}

View File

@@ -0,0 +1,4 @@
import { SyntaxKind } from "../../ast/index.ts";
export declare const childProperties: Readonly<Partial<Record<SyntaxKind, readonly (string | undefined)[]>>>;
export declare const singleChildNodePropertyNames: Readonly<Partial<Record<SyntaxKind, string>>>;
//# sourceMappingURL=protocol.generated.d.ts.map

View File

@@ -0,0 +1,14 @@
"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.es2016 = void 0;
const es2015_1 = require("./es2015");
const es2016_array_include_1 = require("./es2016.array.include");
const es2016_intl_1 = require("./es2016.intl");
exports.es2016 = {
libs: [es2015_1.es2015, es2016_array_include_1.es2016_array_include, es2016_intl_1.es2016_intl],
variables: [],
};

View File

@@ -0,0 +1,9 @@
/**
* Clears all of the internal caches.
* Generally you shouldn't need or want to use this.
* Examples of intended uses:
* - In tests to reset parser state to keep tests isolated.
* - In custom lint tooling that iteratively lints one project at a time to prevent OOMs.
*/
export declare function clearCaches(): void;
export declare const clearProgramCache: typeof clearCaches;

View File

@@ -0,0 +1,10 @@
"use strict";
function _get_prototype_of(o) {
exports._ = _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _get_prototype_of(o);
}
exports._ = _get_prototype_of;

View File

@@ -0,0 +1,33 @@
import OverloadYield from "./OverloadYield.js";
import regeneratorDefine from "./regeneratorDefine.js";
function AsyncIterator(t, e) {
function n(r, o, i, f) {
try {
var c = t[r](o),
u = c.value;
return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
n("next", t, i, f);
}, function (t) {
n("throw", t, i, f);
}) : e.resolve(u).then(function (t) {
c.value = t, i(c);
}, function (t) {
return n("throw", t, i, f);
});
} catch (t) {
f(t);
}
}
var r;
this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
return this;
})), regeneratorDefine(this, "_invoke", function (t, o, i) {
function f() {
return new e(function (e, r) {
n(t, i, e, r);
});
}
return r = r ? r.then(f, f) : f();
}, !0);
}
export { AsyncIterator as default };

View File

@@ -0,0 +1,128 @@
import { describe, expect, it } from "vitest";
import ru from "../../../locales/ru.js";
describe("Russian localization", () => {
const localeError = ru().localeError;
describe("pluralization rules", () => {
for (const { type, cases } of TEST_CASES) {
describe(`${type} pluralization`, () => {
for (const { count, expected } of cases) {
it(`correctly pluralizes ${count} ${type}`, () => {
const error = localeError({
code: "too_small",
minimum: count,
type: "number",
inclusive: true,
path: [],
origin: type,
input: count - 1,
});
expect(error).toContain(expected);
});
}
});
}
it("handles negative numbers correctly", () => {
const error = localeError({
code: "too_small",
minimum: -2,
type: "number",
inclusive: true,
path: [],
origin: "array",
input: -3,
});
expect(error).toContain("-2 элемента");
});
it("handles zero correctly", () => {
const error = localeError({
code: "too_small",
minimum: 0,
type: "number",
inclusive: true,
path: [],
origin: "array",
input: -1,
});
expect(error).toContain("0 элементов");
});
it("handles bigint values correctly", () => {
const error = localeError({
code: "too_small",
minimum: BigInt(21),
type: "number",
inclusive: true,
path: [],
origin: "array",
input: BigInt(20),
});
expect(error).toContain("21 элемент");
});
});
});
const TEST_CASES = [
{
type: "array",
cases: [
{ count: 1, expected: "1 элемент" },
{ count: 2, expected: "2 элемента" },
{ count: 5, expected: "5 элементов" },
{ count: 11, expected: "11 элементов" },
{ count: 21, expected: "21 элемент" },
{ count: 22, expected: "22 элемента" },
{ count: 25, expected: "25 элементов" },
{ count: 101, expected: "101 элемент" },
{ count: 111, expected: "111 элементов" },
],
},
{
type: "set",
cases: [
{ count: 1, expected: "1 элемент" },
{ count: 2, expected: "2 элемента" },
{ count: 5, expected: "5 элементов" },
{ count: 11, expected: "11 элементов" },
{ count: 21, expected: "21 элемент" },
{ count: 22, expected: "22 элемента" },
{ count: 25, expected: "25 элементов" },
{ count: 101, expected: "101 элемент" },
{ count: 111, expected: "111 элементов" },
],
},
{
type: "string",
cases: [
{ count: 1, expected: "1 символ" },
{ count: 2, expected: "2 символа" },
{ count: 5, expected: "5 символов" },
{ count: 11, expected: "11 символов" },
{ count: 21, expected: "21 символ" },
{ count: 22, expected: "22 символа" },
{ count: 25, expected: "25 символов" },
],
},
{
type: "file",
cases: [
{ count: 0, expected: "0 байт" },
{ count: 1, expected: "1 байт" },
{ count: 2, expected: "2 байта" },
{ count: 5, expected: "5 байт" },
{ count: 11, expected: "11 байт" },
{ count: 21, expected: "21 байт" },
{ count: 22, expected: "22 байта" },
{ count: 25, expected: "25 байт" },
{ count: 101, expected: "101 байт" },
{ count: 110, expected: "110 байт" },
],
},
] as const;

View File

@@ -0,0 +1,20 @@
/*!
* is-extglob <https://github.com/jonschlinkert/is-extglob>
*
* Copyright (c) 2014-2016, Jon Schlinkert.
* Licensed under the MIT License.
*/
module.exports = function isExtglob(str) {
if (typeof str !== 'string' || str === '') {
return false;
}
var match;
while ((match = /(\\).|([@?!+*]\(.*\))/g.exec(str))) {
if (match[2]) return true;
str = str.slice(match.index + match[0].length);
}
return false;
};

View File

@@ -0,0 +1,44 @@
function _async_iterator(iterable) {
var method, async, sync, retry = 2;
for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) {
if (async && null != (method = iterable[async])) return method.call(iterable);
if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
async = "@@asyncIterator", sync = "@@iterator";
}
throw new TypeError("Object is not async iterable");
}
function AsyncFromSyncIterator(s) {
function AsyncFromSyncIteratorContinuation(r) {
if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
var done = r.done;
return Promise.resolve(r.value).then(function(value) {
return { value: value, done: done };
});
}
return AsyncFromSyncIterator = function(s) {
this.s = s, this.n = s.next;
},
AsyncFromSyncIterator.prototype = {
s: null,
n: null,
next: function() {
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
},
return: function(value) {
var ret = this.s.return;
return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
},
throw: function(value) {
var thr = this.s.return;
return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
}
},
new AsyncFromSyncIterator(s);
}
export { _async_iterator as _ };

View File

@@ -0,0 +1,4 @@
{
"main": "../../cjs/_super_prop_base.cjs",
"module": "../../esm/_super_prop_base.js"
}

View File

@@ -0,0 +1,53 @@
declare namespace pLocate {
interface Options {
/**
Number of concurrently pending promises returned by `tester`. Minimum: `1`.
@default Infinity
*/
readonly concurrency?: number;
/**
Preserve `input` order when searching.
Disable this to improve performance if you don't care about the order.
@default true
*/
readonly preserveOrder?: boolean;
}
}
/**
Get the first fulfilled promise that satisfies the provided testing function.
@param input - An iterable of promises/values to test.
@param tester - This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.
@returns A `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.
@example
```
import pathExists = require('path-exists');
import pLocate = require('p-locate');
const files = [
'unicorn.png',
'rainbow.png', // Only this one actually exists on disk
'pony.png'
];
(async () => {
const foundPath = await pLocate(files, file => pathExists(file));
console.log(foundPath);
//=> 'rainbow'
})();
```
*/
declare function pLocate<ValueType>(
input: Iterable<PromiseLike<ValueType> | ValueType>,
tester: (element: ValueType) => PromiseLike<boolean> | boolean,
options?: pLocate.Options
): Promise<ValueType | undefined>;
export = pLocate;

View File

@@ -0,0 +1,243 @@
import {
objectOrFunction,
isFunction
} from './utils';
import {
asap
} from './asap';
import originalThen from './then';
import originalResolve from './promise/resolve';
export const PROMISE_ID = Math.random().toString(36).substring(2);
function noop() {}
const PENDING = void 0;
const FULFILLED = 1;
const REJECTED = 2;
function selfFulfillment() {
return new TypeError("You cannot resolve a promise with itself");
}
function cannotReturnOwn() {
return new TypeError('A promises callback cannot return that same promise.');
}
function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
try {
then.call(value, fulfillmentHandler, rejectionHandler);
} catch(e) {
return e;
}
}
function handleForeignThenable(promise, thenable, then) {
asap(promise => {
let sealed = false;
let error = tryThen(then, thenable, value => {
if (sealed) { return; }
sealed = true;
if (thenable !== value) {
resolve(promise, value);
} else {
fulfill(promise, value);
}
}, reason => {
if (sealed) { return; }
sealed = true;
reject(promise, reason);
}, 'Settle: ' + (promise._label || ' unknown promise'));
if (!sealed && error) {
sealed = true;
reject(promise, error);
}
}, promise);
}
function handleOwnThenable(promise, thenable) {
if (thenable._state === FULFILLED) {
fulfill(promise, thenable._result);
} else if (thenable._state === REJECTED) {
reject(promise, thenable._result);
} else {
subscribe(thenable, undefined, value => resolve(promise, value),
reason => reject(promise, reason))
}
}
function handleMaybeThenable(promise, maybeThenable, then) {
if (maybeThenable.constructor === promise.constructor &&
then === originalThen &&
maybeThenable.constructor.resolve === originalResolve) {
handleOwnThenable(promise, maybeThenable);
} else {
if (then === undefined) {
fulfill(promise, maybeThenable);
} else if (isFunction(then)) {
handleForeignThenable(promise, maybeThenable, then);
} else {
fulfill(promise, maybeThenable);
}
}
}
function resolve(promise, value) {
if (promise === value) {
reject(promise, selfFulfillment());
} else if (objectOrFunction(value)) {
let then;
try {
then = value.then;
} catch (error) {
reject(promise, error);
return;
}
handleMaybeThenable(promise, value, then);
} else {
fulfill(promise, value);
}
}
function publishRejection(promise) {
if (promise._onerror) {
promise._onerror(promise._result);
}
publish(promise);
}
function fulfill(promise, value) {
if (promise._state !== PENDING) { return; }
promise._result = value;
promise._state = FULFILLED;
if (promise._subscribers.length !== 0) {
asap(publish, promise);
}
}
function reject(promise, reason) {
if (promise._state !== PENDING) { return; }
promise._state = REJECTED;
promise._result = reason;
asap(publishRejection, promise);
}
function subscribe(parent, child, onFulfillment, onRejection) {
let { _subscribers } = parent;
let { length } = _subscribers;
parent._onerror = null;
_subscribers[length] = child;
_subscribers[length + FULFILLED] = onFulfillment;
_subscribers[length + REJECTED] = onRejection;
if (length === 0 && parent._state) {
asap(publish, parent);
}
}
function publish(promise) {
let subscribers = promise._subscribers;
let settled = promise._state;
if (subscribers.length === 0) { return; }
let child, callback, detail = promise._result;
for (let i = 0; i < subscribers.length; i += 3) {
child = subscribers[i];
callback = subscribers[i + settled];
if (child) {
invokeCallback(settled, child, callback, detail);
} else {
callback(detail);
}
}
promise._subscribers.length = 0;
}
function invokeCallback(settled, promise, callback, detail) {
let hasCallback = isFunction(callback),
value, error, succeeded = true;
if (hasCallback) {
try {
value = callback(detail);
} catch (e) {
succeeded = false;
error = e;
}
if (promise === value) {
reject(promise, cannotReturnOwn());
return;
}
} else {
value = detail;
}
if (promise._state !== PENDING) {
// noop
} else if (hasCallback && succeeded) {
resolve(promise, value);
} else if (succeeded === false) {
reject(promise, error);
} else if (settled === FULFILLED) {
fulfill(promise, value);
} else if (settled === REJECTED) {
reject(promise, value);
}
}
function initializePromise(promise, resolver) {
try {
resolver(function resolvePromise(value){
resolve(promise, value);
}, function rejectPromise(reason) {
reject(promise, reason);
});
} catch(e) {
reject(promise, e);
}
}
let id = 0;
function nextId() {
return id++;
}
function makePromise(promise) {
promise[PROMISE_ID] = id++;
promise._state = undefined;
promise._result = undefined;
promise._subscribers = [];
}
export {
nextId,
makePromise,
noop,
resolve,
reject,
fulfill,
subscribe,
publish,
publishRejection,
initializePromise,
invokeCallback,
FULFILLED,
REJECTED,
PENDING,
handleMaybeThenable
};

View File

@@ -0,0 +1,4 @@
{
"main": "../../cjs/_check_private_redeclaration.cjs",
"module": "../../esm/_check_private_redeclaration.js"
}