new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,257 @@
|
||||
import { MonoTypeOperatorFunction, SchedulerLike, OperatorFunction, ObservableInput, ObservedValueOf } from '../types';
|
||||
export interface TimeoutConfig<T, O extends ObservableInput<unknown> = ObservableInput<T>, M = unknown> {
|
||||
/**
|
||||
* The time allowed between values from the source before timeout is triggered.
|
||||
*/
|
||||
each?: number;
|
||||
/**
|
||||
* The relative time as a `number` in milliseconds, or a specific time as a `Date` object,
|
||||
* by which the first value must arrive from the source before timeout is triggered.
|
||||
*/
|
||||
first?: number | Date;
|
||||
/**
|
||||
* The scheduler to use with time-related operations within this operator. Defaults to {@link asyncScheduler}
|
||||
*/
|
||||
scheduler?: SchedulerLike;
|
||||
/**
|
||||
* A factory used to create observable to switch to when timeout occurs. Provides
|
||||
* a {@link TimeoutInfo} about the source observable's emissions and what delay or
|
||||
* exact time triggered the timeout.
|
||||
*/
|
||||
with?: (info: TimeoutInfo<T, M>) => O;
|
||||
/**
|
||||
* Optional additional metadata you can provide to code that handles
|
||||
* the timeout, will be provided through the {@link TimeoutError}.
|
||||
* This can be used to help identify the source of a timeout or pass along
|
||||
* other information related to the timeout.
|
||||
*/
|
||||
meta?: M;
|
||||
}
|
||||
export interface TimeoutInfo<T, M = unknown> {
|
||||
/** Optional metadata that was provided to the timeout configuration. */
|
||||
readonly meta: M;
|
||||
/** The number of messages seen before the timeout */
|
||||
readonly seen: number;
|
||||
/** The last message seen */
|
||||
readonly lastValue: T | null;
|
||||
}
|
||||
/**
|
||||
* An error emitted when a timeout occurs.
|
||||
*/
|
||||
export interface TimeoutError<T = unknown, M = unknown> extends Error {
|
||||
/**
|
||||
* The information provided to the error by the timeout
|
||||
* operation that created the error. Will be `null` if
|
||||
* used directly in non-RxJS code with an empty constructor.
|
||||
* (Note that using this constructor directly is not recommended,
|
||||
* you should create your own errors)
|
||||
*/
|
||||
info: TimeoutInfo<T, M> | null;
|
||||
}
|
||||
export interface TimeoutErrorCtor {
|
||||
/**
|
||||
* @deprecated Internal implementation detail. Do not construct error instances.
|
||||
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
|
||||
*/
|
||||
new <T = unknown, M = unknown>(info?: TimeoutInfo<T, M>): TimeoutError<T, M>;
|
||||
}
|
||||
/**
|
||||
* An error thrown by the {@link timeout} operator.
|
||||
*
|
||||
* Provided so users can use as a type and do quality comparisons.
|
||||
* We recommend you do not subclass this or create instances of this class directly.
|
||||
* If you have need of a error representing a timeout, you should
|
||||
* create your own error class and use that.
|
||||
*
|
||||
* @see {@link timeout}
|
||||
*
|
||||
* @class TimeoutError
|
||||
*/
|
||||
export declare const TimeoutError: TimeoutErrorCtor;
|
||||
/**
|
||||
* If `with` is provided, this will return an observable that will switch to a different observable if the source
|
||||
* does not push values within the specified time parameters.
|
||||
*
|
||||
* <span class="informal">The most flexible option for creating a timeout behavior.</span>
|
||||
*
|
||||
* The first thing to know about the configuration is if you do not provide a `with` property to the configuration,
|
||||
* when timeout conditions are met, this operator will emit a {@link TimeoutError}. Otherwise, it will use the factory
|
||||
* function provided by `with`, and switch your subscription to the result of that. Timeout conditions are provided by
|
||||
* the settings in `first` and `each`.
|
||||
*
|
||||
* The `first` property can be either a `Date` for a specific time, a `number` for a time period relative to the
|
||||
* point of subscription, or it can be skipped. This property is to check timeout conditions for the arrival of
|
||||
* the first value from the source _only_. The timings of all subsequent values from the source will be checked
|
||||
* against the time period provided by `each`, if it was provided.
|
||||
*
|
||||
* The `each` property can be either a `number` or skipped. If a value for `each` is provided, it represents the amount of
|
||||
* time the resulting observable will wait between the arrival of values from the source before timing out. Note that if
|
||||
* `first` is _not_ provided, the value from `each` will be used to check timeout conditions for the arrival of the first
|
||||
* value and all subsequent values. If `first` _is_ provided, `each` will only be use to check all values after the first.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* Emit a custom error if there is too much time between values
|
||||
*
|
||||
* ```ts
|
||||
* import { interval, timeout, throwError } from 'rxjs';
|
||||
*
|
||||
* class CustomTimeoutError extends Error {
|
||||
* constructor() {
|
||||
* super('It was too slow');
|
||||
* this.name = 'CustomTimeoutError';
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const slow$ = interval(900);
|
||||
*
|
||||
* slow$.pipe(
|
||||
* timeout({
|
||||
* each: 1000,
|
||||
* with: () => throwError(() => new CustomTimeoutError())
|
||||
* })
|
||||
* )
|
||||
* .subscribe({
|
||||
* error: console.error
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Switch to a faster observable if your source is slow.
|
||||
*
|
||||
* ```ts
|
||||
* import { interval, timeout } from 'rxjs';
|
||||
*
|
||||
* const slow$ = interval(900);
|
||||
* const fast$ = interval(500);
|
||||
*
|
||||
* slow$.pipe(
|
||||
* timeout({
|
||||
* each: 1000,
|
||||
* with: () => fast$,
|
||||
* })
|
||||
* )
|
||||
* .subscribe(console.log);
|
||||
* ```
|
||||
* @param config The configuration for the timeout.
|
||||
*/
|
||||
export declare function timeout<T, O extends ObservableInput<unknown>, M = unknown>(config: TimeoutConfig<T, O, M> & {
|
||||
with: (info: TimeoutInfo<T, M>) => O;
|
||||
}): OperatorFunction<T, T | ObservedValueOf<O>>;
|
||||
/**
|
||||
* Returns an observable that will error or switch to a different observable if the source does not push values
|
||||
* within the specified time parameters.
|
||||
*
|
||||
* <span class="informal">The most flexible option for creating a timeout behavior.</span>
|
||||
*
|
||||
* The first thing to know about the configuration is if you do not provide a `with` property to the configuration,
|
||||
* when timeout conditions are met, this operator will emit a {@link TimeoutError}. Otherwise, it will use the factory
|
||||
* function provided by `with`, and switch your subscription to the result of that. Timeout conditions are provided by
|
||||
* the settings in `first` and `each`.
|
||||
*
|
||||
* The `first` property can be either a `Date` for a specific time, a `number` for a time period relative to the
|
||||
* point of subscription, or it can be skipped. This property is to check timeout conditions for the arrival of
|
||||
* the first value from the source _only_. The timings of all subsequent values from the source will be checked
|
||||
* against the time period provided by `each`, if it was provided.
|
||||
*
|
||||
* The `each` property can be either a `number` or skipped. If a value for `each` is provided, it represents the amount of
|
||||
* time the resulting observable will wait between the arrival of values from the source before timing out. Note that if
|
||||
* `first` is _not_ provided, the value from `each` will be used to check timeout conditions for the arrival of the first
|
||||
* value and all subsequent values. If `first` _is_ provided, `each` will only be use to check all values after the first.
|
||||
*
|
||||
* ### Handling TimeoutErrors
|
||||
*
|
||||
* If no `with` property was provided, subscriptions to the resulting observable may emit an error of {@link TimeoutError}.
|
||||
* The timeout error provides useful information you can examine when you're handling the error. The most common way to handle
|
||||
* the error would be with {@link catchError}, although you could use {@link tap} or just the error handler in your `subscribe` call
|
||||
* directly, if your error handling is only a side effect (such as notifying the user, or logging).
|
||||
*
|
||||
* In this case, you would check the error for `instanceof TimeoutError` to validate that the error was indeed from `timeout`, and
|
||||
* not from some other source. If it's not from `timeout`, you should probably rethrow it if you're in a `catchError`.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* Emit a {@link TimeoutError} if the first value, and _only_ the first value, does not arrive within 5 seconds
|
||||
*
|
||||
* ```ts
|
||||
* import { interval, timeout } from 'rxjs';
|
||||
*
|
||||
* // A random interval that lasts between 0 and 10 seconds per tick
|
||||
* const source$ = interval(Math.round(Math.random() * 10_000));
|
||||
*
|
||||
* source$.pipe(
|
||||
* timeout({ first: 5_000 })
|
||||
* )
|
||||
* .subscribe({
|
||||
* next: console.log,
|
||||
* error: console.error
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Emit a {@link TimeoutError} if the source waits longer than 5 seconds between any two values or the first value
|
||||
* and subscription.
|
||||
*
|
||||
* ```ts
|
||||
* import { timer, timeout, expand } from 'rxjs';
|
||||
*
|
||||
* const getRandomTime = () => Math.round(Math.random() * 10_000);
|
||||
*
|
||||
* // An observable that waits a random amount of time between each delivered value
|
||||
* const source$ = timer(getRandomTime())
|
||||
* .pipe(expand(() => timer(getRandomTime())));
|
||||
*
|
||||
* source$
|
||||
* .pipe(timeout({ each: 5_000 }))
|
||||
* .subscribe({
|
||||
* next: console.log,
|
||||
* error: console.error
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Emit a {@link TimeoutError} if the source does not emit before 7 seconds, _or_ if the source waits longer than
|
||||
* 5 seconds between any two values after the first.
|
||||
*
|
||||
* ```ts
|
||||
* import { timer, timeout, expand } from 'rxjs';
|
||||
*
|
||||
* const getRandomTime = () => Math.round(Math.random() * 10_000);
|
||||
*
|
||||
* // An observable that waits a random amount of time between each delivered value
|
||||
* const source$ = timer(getRandomTime())
|
||||
* .pipe(expand(() => timer(getRandomTime())));
|
||||
*
|
||||
* source$
|
||||
* .pipe(timeout({ first: 7_000, each: 5_000 }))
|
||||
* .subscribe({
|
||||
* next: console.log,
|
||||
* error: console.error
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export declare function timeout<T, M = unknown>(config: Omit<TimeoutConfig<T, any, M>, 'with'>): OperatorFunction<T, T>;
|
||||
/**
|
||||
* Returns an observable that will error if the source does not push its first value before the specified time passed as a `Date`.
|
||||
* This is functionally the same as `timeout({ first: someDate })`.
|
||||
*
|
||||
* <span class="informal">Errors if the first value doesn't show up before the given date and time</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* @param first The date to at which the resulting observable will timeout if the source observable
|
||||
* does not emit at least one value.
|
||||
* @param scheduler The scheduler to use. Defaults to {@link asyncScheduler}.
|
||||
*/
|
||||
export declare function timeout<T>(first: Date, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
|
||||
/**
|
||||
* Returns an observable that will error if the source does not push a value within the specified time in milliseconds.
|
||||
* This is functionally the same as `timeout({ each: milliseconds })`.
|
||||
*
|
||||
* <span class="informal">Errors if it waits too long between any value</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* @param each The time allowed between each pushed value from the source before the resulting observable
|
||||
* will timeout.
|
||||
* @param scheduler The scheduler to use. Defaults to {@link asyncScheduler}.
|
||||
*/
|
||||
export declare function timeout<T>(each: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
|
||||
//# sourceMappingURL=timeout.d.ts.map
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function (value) {
|
||||
// eslint-disable-next-line no-bitwise
|
||||
value >>>= 0;
|
||||
return value ? 32 - value.toString(2).length : 32;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"@formatjs/fast-memoize","version":"1.2.1","files":{"LICENSE.md":{"checkedAt":1678883668770,"integrity":"sha512-yk2UNYv66P09cmrZfyyPP55PUfEg0xPWmRDhfrdw/jfa6koIQxk7tEwAgbA67F+p2th8eepIbNnFU8q+nEhnYQ==","mode":493,"size":1065},"index.js":{"checkedAt":1678883668810,"integrity":"sha512-rcEVpmNZyfG1jNvime6IXRCyJNv4I3O/z0NFBERadPnuMWevf960LPck/TrZ3DzjRJYHYXUo9nr3BmMXwjhujw==","mode":493,"size":2567},"lib/index.js":{"checkedAt":1678883668810,"integrity":"sha512-dpbojFKTgzPT28v0DPDr4B2ba+tBxxX5o7ZLqIkGhuhPi7Bp/22hvtFfdXoNMm1sr0MAjFOeS6uf96r5dJ0qAw==","mode":493,"size":2452},"index.d.ts.map":{"checkedAt":1678883668810,"integrity":"sha512-sMgJFC3JGeSYsww6D0Eo2+62HEZWSTMyIL8i5d8NrC9kFSF9llVr/82pt3i/TUA4IagzZEqD/i0QmZRUmck5Pg==","mode":493,"size":1552},"package.json":{"checkedAt":1678883668810,"integrity":"sha512-IXhpbUNPnUt0lIHuV12oifJPGO8x7gLY9GRVPd+zy+UyomlF2wb832aak7XeJ1Tl73BolliK/LLr/1owkW8tTw==","mode":493,"size":677},"lib/index.d.ts.map":{"checkedAt":1678883668810,"integrity":"sha512-N/UUfb19nGz9R7ByGnzhcQZMfBuFAohRqVc9zRAp3VZE3iN0qNm1waNiR2tyQB10dkEFUhtYrc767zfxJPj/GA==","mode":493,"size":1555},"README.md":{"checkedAt":1678883668810,"integrity":"sha512-hgKJbYUwoG7wx8dnkQj1lnROGv2CFhXTif5GNwUwMOvREvUxIvq+vpA6psc70aC3w/60ENbJqF2hnUbWXJaHQw==","mode":493,"size":65},"index.d.ts":{"checkedAt":1678883668814,"integrity":"sha512-VHBYxaUCzwaGkUgnHtSjq6S8FHsVED2pl3mO5pTrOdK0RhVRksvWfUusM+bG/5rGkAMczJndAREosHxNGTT9pQ==","mode":493,"size":1142},"lib/index.d.ts":{"checkedAt":1678883668814,"integrity":"sha512-VHBYxaUCzwaGkUgnHtSjq6S8FHsVED2pl3mO5pTrOdK0RhVRksvWfUusM+bG/5rGkAMczJndAREosHxNGTT9pQ==","mode":493,"size":1142}}}
|
||||
@@ -0,0 +1,13 @@
|
||||
export { render, hydrate } from './render';
|
||||
export {
|
||||
createElement,
|
||||
createElement as h,
|
||||
Fragment,
|
||||
createRef,
|
||||
isValidElement
|
||||
} from './create-element';
|
||||
export { Component } from './component';
|
||||
export { cloneElement } from './clone-element';
|
||||
export { createContext } from './create-context';
|
||||
export { toChildArray } from './diff/children';
|
||||
export { default as options } from './options';
|
||||
@@ -0,0 +1,36 @@
|
||||
import Tag from './shared/Tag';
|
||||
import Action from './Action';
|
||||
import Animation from './Animation';
|
||||
import Attribute from './Attribute';
|
||||
import AwaitBlock from './AwaitBlock';
|
||||
import Binding from './Binding';
|
||||
import Body from './Body';
|
||||
import CatchBlock from './CatchBlock';
|
||||
import Class from './Class';
|
||||
import StyleDirective from './StyleDirective';
|
||||
import Comment from './Comment';
|
||||
import ConstTag from './ConstTag';
|
||||
import DebugTag from './DebugTag';
|
||||
import EachBlock from './EachBlock';
|
||||
import Element from './Element';
|
||||
import ElseBlock from './ElseBlock';
|
||||
import EventHandler from './EventHandler';
|
||||
import Fragment from './Fragment';
|
||||
import Head from './Head';
|
||||
import IfBlock from './IfBlock';
|
||||
import InlineComponent from './InlineComponent';
|
||||
import KeyBlock from './KeyBlock';
|
||||
import Let from './Let';
|
||||
import MustacheTag from './MustacheTag';
|
||||
import Options from './Options';
|
||||
import PendingBlock from './PendingBlock';
|
||||
import RawMustacheTag from './RawMustacheTag';
|
||||
import Slot from './Slot';
|
||||
import SlotTemplate from './SlotTemplate';
|
||||
import Text from './Text';
|
||||
import ThenBlock from './ThenBlock';
|
||||
import Title from './Title';
|
||||
import Transition from './Transition';
|
||||
import Window from './Window';
|
||||
export declare type INode = Action | Animation | Attribute | AwaitBlock | Binding | Body | CatchBlock | Class | Comment | ConstTag | DebugTag | EachBlock | Element | ElseBlock | EventHandler | Fragment | Head | IfBlock | InlineComponent | KeyBlock | Let | MustacheTag | Options | PendingBlock | RawMustacheTag | Slot | SlotTemplate | StyleDirective | Tag | Text | ThenBlock | Title | Transition | Window;
|
||||
export declare type INodeAllowConstTag = IfBlock | ElseBlock | EachBlock | CatchBlock | ThenBlock | InlineComponent | SlotTemplate;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L G M N O"},C:{"2":"0 1 2 3 4 5 6 7 8 9 DC tB I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB EC FC"},D:{"1":"eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB"},E:{"1":"OC","2":"I v J D E F A B C K L G HC zB IC JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B"},F:{"1":"TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB PC QC RC SC qB AC TC rB"},G:{"2":"E zB UC BC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"2":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"1":"g 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I wC xC yC zC"},Q:{"1":"1B"},R:{"1":"9C"},S:{"2":"AD BD"}},B:1,C:"Resource Hints: modulepreload"};
|
||||
@@ -0,0 +1,3 @@
|
||||
import Renderer, { RenderOptions } from '../Renderer';
|
||||
import EachBlock from '../../nodes/EachBlock';
|
||||
export default function (node: EachBlock, renderer: Renderer, options: RenderOptions): void;
|
||||
@@ -0,0 +1,560 @@
|
||||
import { EMPTY_OBJ } from '../constants';
|
||||
import { Component, getDomSibling } from '../component';
|
||||
import { Fragment } from '../create-element';
|
||||
import { diffChildren } from './children';
|
||||
import { diffProps, setProperty } from './props';
|
||||
import { assign, removeNode, slice } from '../util';
|
||||
import options from '../options';
|
||||
|
||||
/**
|
||||
* Diff two virtual nodes and apply proper changes to the DOM
|
||||
* @param {import('../internal').PreactElement} parentDom The parent of the DOM element
|
||||
* @param {import('../internal').VNode} newVNode The new virtual node
|
||||
* @param {import('../internal').VNode} oldVNode The old virtual node
|
||||
* @param {object} globalContext The current context object. Modified by getChildContext
|
||||
* @param {boolean} isSvg Whether or not this element is an SVG node
|
||||
* @param {Array<import('../internal').PreactElement>} excessDomChildren
|
||||
* @param {Array<import('../internal').Component>} commitQueue List of components
|
||||
* which have callbacks to invoke in commitRoot
|
||||
* @param {import('../internal').PreactElement} oldDom The current attached DOM
|
||||
* element any new dom elements should be placed around. Likely `null` on first
|
||||
* render (except when hydrating). Can be a sibling DOM element when diffing
|
||||
* Fragments that have siblings. In most cases, it starts out as `oldChildren[0]._dom`.
|
||||
* @param {boolean} [isHydrating] Whether or not we are in hydration
|
||||
*/
|
||||
export function diff(
|
||||
parentDom,
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
oldDom,
|
||||
isHydrating
|
||||
) {
|
||||
let tmp,
|
||||
newType = newVNode.type;
|
||||
|
||||
// When passing through createElement it assigns the object
|
||||
// constructor as undefined. This to prevent JSON-injection.
|
||||
if (newVNode.constructor !== undefined) return null;
|
||||
|
||||
// If the previous diff bailed out, resume creating/hydrating.
|
||||
if (oldVNode._hydrating != null) {
|
||||
isHydrating = oldVNode._hydrating;
|
||||
oldDom = newVNode._dom = oldVNode._dom;
|
||||
// if we resume, we want the tree to be "unlocked"
|
||||
newVNode._hydrating = null;
|
||||
excessDomChildren = [oldDom];
|
||||
}
|
||||
|
||||
if ((tmp = options._diff)) tmp(newVNode);
|
||||
|
||||
try {
|
||||
outer: if (typeof newType == 'function') {
|
||||
let c, isNew, oldProps, oldState, snapshot, clearProcessingException;
|
||||
let newProps = newVNode.props;
|
||||
|
||||
// Necessary for createContext api. Setting this property will pass
|
||||
// the context value as `this.context` just for this component.
|
||||
tmp = newType.contextType;
|
||||
let provider = tmp && globalContext[tmp._id];
|
||||
let componentContext = tmp
|
||||
? provider
|
||||
? provider.props.value
|
||||
: tmp._defaultValue
|
||||
: globalContext;
|
||||
|
||||
// Get component and set it to `c`
|
||||
if (oldVNode._component) {
|
||||
c = newVNode._component = oldVNode._component;
|
||||
clearProcessingException = c._processingException = c._pendingError;
|
||||
} else {
|
||||
// Instantiate the new component
|
||||
if ('prototype' in newType && newType.prototype.render) {
|
||||
// @ts-ignore The check above verifies that newType is suppose to be constructed
|
||||
newVNode._component = c = new newType(newProps, componentContext); // eslint-disable-line new-cap
|
||||
} else {
|
||||
// @ts-ignore Trust me, Component implements the interface we want
|
||||
newVNode._component = c = new Component(newProps, componentContext);
|
||||
c.constructor = newType;
|
||||
c.render = doRender;
|
||||
}
|
||||
if (provider) provider.sub(c);
|
||||
|
||||
c.props = newProps;
|
||||
if (!c.state) c.state = {};
|
||||
c.context = componentContext;
|
||||
c._globalContext = globalContext;
|
||||
isNew = c._dirty = true;
|
||||
c._renderCallbacks = [];
|
||||
c._stateCallbacks = [];
|
||||
}
|
||||
|
||||
// Invoke getDerivedStateFromProps
|
||||
if (c._nextState == null) {
|
||||
c._nextState = c.state;
|
||||
}
|
||||
|
||||
if (newType.getDerivedStateFromProps != null) {
|
||||
if (c._nextState == c.state) {
|
||||
c._nextState = assign({}, c._nextState);
|
||||
}
|
||||
|
||||
assign(
|
||||
c._nextState,
|
||||
newType.getDerivedStateFromProps(newProps, c._nextState)
|
||||
);
|
||||
}
|
||||
|
||||
oldProps = c.props;
|
||||
oldState = c.state;
|
||||
c._vnode = newVNode;
|
||||
|
||||
// Invoke pre-render lifecycle methods
|
||||
if (isNew) {
|
||||
if (
|
||||
newType.getDerivedStateFromProps == null &&
|
||||
c.componentWillMount != null
|
||||
) {
|
||||
c.componentWillMount();
|
||||
}
|
||||
|
||||
if (c.componentDidMount != null) {
|
||||
c._renderCallbacks.push(c.componentDidMount);
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
newType.getDerivedStateFromProps == null &&
|
||||
newProps !== oldProps &&
|
||||
c.componentWillReceiveProps != null
|
||||
) {
|
||||
c.componentWillReceiveProps(newProps, componentContext);
|
||||
}
|
||||
|
||||
if (
|
||||
(!c._force &&
|
||||
c.shouldComponentUpdate != null &&
|
||||
c.shouldComponentUpdate(
|
||||
newProps,
|
||||
c._nextState,
|
||||
componentContext
|
||||
) === false) ||
|
||||
newVNode._original === oldVNode._original
|
||||
) {
|
||||
// More info about this here: https://gist.github.com/JoviDeCroock/bec5f2ce93544d2e6070ef8e0036e4e8
|
||||
if (newVNode._original !== oldVNode._original) {
|
||||
// When we are dealing with a bail because of sCU we have to update
|
||||
// the props, state and dirty-state.
|
||||
// when we are dealing with strict-equality we don't as the child could still
|
||||
// be dirtied see #3883
|
||||
c.props = newProps;
|
||||
c.state = c._nextState;
|
||||
c._dirty = false;
|
||||
}
|
||||
newVNode._dom = oldVNode._dom;
|
||||
newVNode._children = oldVNode._children;
|
||||
newVNode._children.forEach(vnode => {
|
||||
if (vnode) vnode._parent = newVNode;
|
||||
});
|
||||
|
||||
for (let i = 0; i < c._stateCallbacks.length; i++) {
|
||||
c._renderCallbacks.push(c._stateCallbacks[i]);
|
||||
}
|
||||
c._stateCallbacks = [];
|
||||
|
||||
if (c._renderCallbacks.length) {
|
||||
commitQueue.push(c);
|
||||
}
|
||||
|
||||
break outer;
|
||||
}
|
||||
|
||||
if (c.componentWillUpdate != null) {
|
||||
c.componentWillUpdate(newProps, c._nextState, componentContext);
|
||||
}
|
||||
|
||||
if (c.componentDidUpdate != null) {
|
||||
c._renderCallbacks.push(() => {
|
||||
c.componentDidUpdate(oldProps, oldState, snapshot);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
c.context = componentContext;
|
||||
c.props = newProps;
|
||||
c._parentDom = parentDom;
|
||||
|
||||
let renderHook = options._render,
|
||||
count = 0;
|
||||
if ('prototype' in newType && newType.prototype.render) {
|
||||
c.state = c._nextState;
|
||||
c._dirty = false;
|
||||
|
||||
if (renderHook) renderHook(newVNode);
|
||||
|
||||
tmp = c.render(c.props, c.state, c.context);
|
||||
|
||||
for (let i = 0; i < c._stateCallbacks.length; i++) {
|
||||
c._renderCallbacks.push(c._stateCallbacks[i]);
|
||||
}
|
||||
c._stateCallbacks = [];
|
||||
} else {
|
||||
do {
|
||||
c._dirty = false;
|
||||
if (renderHook) renderHook(newVNode);
|
||||
|
||||
tmp = c.render(c.props, c.state, c.context);
|
||||
|
||||
// Handle setState called in render, see #2553
|
||||
c.state = c._nextState;
|
||||
} while (c._dirty && ++count < 25);
|
||||
}
|
||||
|
||||
// Handle setState called in render, see #2553
|
||||
c.state = c._nextState;
|
||||
|
||||
if (c.getChildContext != null) {
|
||||
globalContext = assign(assign({}, globalContext), c.getChildContext());
|
||||
}
|
||||
|
||||
if (!isNew && c.getSnapshotBeforeUpdate != null) {
|
||||
snapshot = c.getSnapshotBeforeUpdate(oldProps, oldState);
|
||||
}
|
||||
|
||||
let isTopLevelFragment =
|
||||
tmp != null && tmp.type === Fragment && tmp.key == null;
|
||||
let renderResult = isTopLevelFragment ? tmp.props.children : tmp;
|
||||
|
||||
diffChildren(
|
||||
parentDom,
|
||||
Array.isArray(renderResult) ? renderResult : [renderResult],
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
oldDom,
|
||||
isHydrating
|
||||
);
|
||||
|
||||
c.base = newVNode._dom;
|
||||
|
||||
// We successfully rendered this VNode, unset any stored hydration/bailout state:
|
||||
newVNode._hydrating = null;
|
||||
|
||||
if (c._renderCallbacks.length) {
|
||||
commitQueue.push(c);
|
||||
}
|
||||
|
||||
if (clearProcessingException) {
|
||||
c._pendingError = c._processingException = null;
|
||||
}
|
||||
|
||||
c._force = false;
|
||||
} else if (
|
||||
excessDomChildren == null &&
|
||||
newVNode._original === oldVNode._original
|
||||
) {
|
||||
newVNode._children = oldVNode._children;
|
||||
newVNode._dom = oldVNode._dom;
|
||||
} else {
|
||||
newVNode._dom = diffElementNodes(
|
||||
oldVNode._dom,
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
isHydrating
|
||||
);
|
||||
}
|
||||
|
||||
if ((tmp = options.diffed)) tmp(newVNode);
|
||||
} catch (e) {
|
||||
newVNode._original = null;
|
||||
// if hydrating or creating initial tree, bailout preserves DOM:
|
||||
if (isHydrating || excessDomChildren != null) {
|
||||
newVNode._dom = oldDom;
|
||||
newVNode._hydrating = !!isHydrating;
|
||||
excessDomChildren[excessDomChildren.indexOf(oldDom)] = null;
|
||||
// ^ could possibly be simplified to:
|
||||
// excessDomChildren.length = 0;
|
||||
}
|
||||
options._catchError(e, newVNode, oldVNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<import('../internal').Component>} commitQueue List of components
|
||||
* which have callbacks to invoke in commitRoot
|
||||
* @param {import('../internal').VNode} root
|
||||
*/
|
||||
export function commitRoot(commitQueue, root) {
|
||||
if (options._commit) options._commit(root, commitQueue);
|
||||
|
||||
commitQueue.some(c => {
|
||||
try {
|
||||
// @ts-ignore Reuse the commitQueue variable here so the type changes
|
||||
commitQueue = c._renderCallbacks;
|
||||
c._renderCallbacks = [];
|
||||
commitQueue.some(cb => {
|
||||
// @ts-ignore See above ts-ignore on commitQueue
|
||||
cb.call(c);
|
||||
});
|
||||
} catch (e) {
|
||||
options._catchError(e, c._vnode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Diff two virtual nodes representing DOM element
|
||||
* @param {import('../internal').PreactElement} dom The DOM element representing
|
||||
* the virtual nodes being diffed
|
||||
* @param {import('../internal').VNode} newVNode The new virtual node
|
||||
* @param {import('../internal').VNode} oldVNode The old virtual node
|
||||
* @param {object} globalContext The current context object
|
||||
* @param {boolean} isSvg Whether or not this DOM node is an SVG node
|
||||
* @param {*} excessDomChildren
|
||||
* @param {Array<import('../internal').Component>} commitQueue List of components
|
||||
* which have callbacks to invoke in commitRoot
|
||||
* @param {boolean} isHydrating Whether or not we are in hydration
|
||||
* @returns {import('../internal').PreactElement}
|
||||
*/
|
||||
function diffElementNodes(
|
||||
dom,
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg,
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
isHydrating
|
||||
) {
|
||||
let oldProps = oldVNode.props;
|
||||
let newProps = newVNode.props;
|
||||
let nodeType = newVNode.type;
|
||||
let i = 0;
|
||||
|
||||
// Tracks entering and exiting SVG namespace when descending through the tree.
|
||||
if (nodeType === 'svg') isSvg = true;
|
||||
|
||||
if (excessDomChildren != null) {
|
||||
for (; i < excessDomChildren.length; i++) {
|
||||
const child = excessDomChildren[i];
|
||||
|
||||
// if newVNode matches an element in excessDomChildren or the `dom`
|
||||
// argument matches an element in excessDomChildren, remove it from
|
||||
// excessDomChildren so it isn't later removed in diffChildren
|
||||
if (
|
||||
child &&
|
||||
'setAttribute' in child === !!nodeType &&
|
||||
(nodeType ? child.localName === nodeType : child.nodeType === 3)
|
||||
) {
|
||||
dom = child;
|
||||
excessDomChildren[i] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dom == null) {
|
||||
if (nodeType === null) {
|
||||
// @ts-ignore createTextNode returns Text, we expect PreactElement
|
||||
return document.createTextNode(newProps);
|
||||
}
|
||||
|
||||
if (isSvg) {
|
||||
dom = document.createElementNS(
|
||||
'http://www.w3.org/2000/svg',
|
||||
// @ts-ignore We know `newVNode.type` is a string
|
||||
nodeType
|
||||
);
|
||||
} else {
|
||||
dom = document.createElement(
|
||||
// @ts-ignore We know `newVNode.type` is a string
|
||||
nodeType,
|
||||
newProps.is && newProps
|
||||
);
|
||||
}
|
||||
|
||||
// we created a new parent, so none of the previously attached children can be reused:
|
||||
excessDomChildren = null;
|
||||
// we are creating a new node, so we can assume this is a new subtree (in case we are hydrating), this deopts the hydrate
|
||||
isHydrating = false;
|
||||
}
|
||||
|
||||
if (nodeType === null) {
|
||||
// During hydration, we still have to split merged text from SSR'd HTML.
|
||||
if (oldProps !== newProps && (!isHydrating || dom.data !== newProps)) {
|
||||
dom.data = newProps;
|
||||
}
|
||||
} else {
|
||||
// If excessDomChildren was not null, repopulate it with the current element's children:
|
||||
excessDomChildren = excessDomChildren && slice.call(dom.childNodes);
|
||||
|
||||
oldProps = oldVNode.props || EMPTY_OBJ;
|
||||
|
||||
let oldHtml = oldProps.dangerouslySetInnerHTML;
|
||||
let newHtml = newProps.dangerouslySetInnerHTML;
|
||||
|
||||
// During hydration, props are not diffed at all (including dangerouslySetInnerHTML)
|
||||
// @TODO we should warn in debug mode when props don't match here.
|
||||
if (!isHydrating) {
|
||||
// But, if we are in a situation where we are using existing DOM (e.g. replaceNode)
|
||||
// we should read the existing DOM attributes to diff them
|
||||
if (excessDomChildren != null) {
|
||||
oldProps = {};
|
||||
for (i = 0; i < dom.attributes.length; i++) {
|
||||
oldProps[dom.attributes[i].name] = dom.attributes[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
if (newHtml || oldHtml) {
|
||||
// Avoid re-applying the same '__html' if it did not changed between re-render
|
||||
if (
|
||||
!newHtml ||
|
||||
((!oldHtml || newHtml.__html != oldHtml.__html) &&
|
||||
newHtml.__html !== dom.innerHTML)
|
||||
) {
|
||||
dom.innerHTML = (newHtml && newHtml.__html) || '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
diffProps(dom, newProps, oldProps, isSvg, isHydrating);
|
||||
|
||||
// If the new vnode didn't have dangerouslySetInnerHTML, diff its children
|
||||
if (newHtml) {
|
||||
newVNode._children = [];
|
||||
} else {
|
||||
i = newVNode.props.children;
|
||||
diffChildren(
|
||||
dom,
|
||||
Array.isArray(i) ? i : [i],
|
||||
newVNode,
|
||||
oldVNode,
|
||||
globalContext,
|
||||
isSvg && nodeType !== 'foreignObject',
|
||||
excessDomChildren,
|
||||
commitQueue,
|
||||
excessDomChildren
|
||||
? excessDomChildren[0]
|
||||
: oldVNode._children && getDomSibling(oldVNode, 0),
|
||||
isHydrating
|
||||
);
|
||||
|
||||
// Remove children that are not part of any vnode.
|
||||
if (excessDomChildren != null) {
|
||||
for (i = excessDomChildren.length; i--; ) {
|
||||
if (excessDomChildren[i] != null) removeNode(excessDomChildren[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// (as above, don't diff props during hydration)
|
||||
if (!isHydrating) {
|
||||
if (
|
||||
'value' in newProps &&
|
||||
(i = newProps.value) !== undefined &&
|
||||
// #2756 For the <progress>-element the initial value is 0,
|
||||
// despite the attribute not being present. When the attribute
|
||||
// is missing the progress bar is treated as indeterminate.
|
||||
// To fix that we'll always update it when it is 0 for progress elements
|
||||
(i !== dom.value ||
|
||||
(nodeType === 'progress' && !i) ||
|
||||
// This is only for IE 11 to fix <select> value not being updated.
|
||||
// To avoid a stale select value we need to set the option.value
|
||||
// again, which triggers IE11 to re-evaluate the select value
|
||||
(nodeType === 'option' && i !== oldProps.value))
|
||||
) {
|
||||
setProperty(dom, 'value', i, oldProps.value, false);
|
||||
}
|
||||
if (
|
||||
'checked' in newProps &&
|
||||
(i = newProps.checked) !== undefined &&
|
||||
i !== dom.checked
|
||||
) {
|
||||
setProperty(dom, 'checked', i, oldProps.checked, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke or update a ref, depending on whether it is a function or object ref.
|
||||
* @param {object|function} ref
|
||||
* @param {any} value
|
||||
* @param {import('../internal').VNode} vnode
|
||||
*/
|
||||
export function applyRef(ref, value, vnode) {
|
||||
try {
|
||||
if (typeof ref == 'function') ref(value);
|
||||
else ref.current = value;
|
||||
} catch (e) {
|
||||
options._catchError(e, vnode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmount a virtual node from the tree and apply DOM changes
|
||||
* @param {import('../internal').VNode} vnode The virtual node to unmount
|
||||
* @param {import('../internal').VNode} parentVNode The parent of the VNode that
|
||||
* initiated the unmount
|
||||
* @param {boolean} [skipRemove] Flag that indicates that a parent node of the
|
||||
* current element is already detached from the DOM.
|
||||
*/
|
||||
export function unmount(vnode, parentVNode, skipRemove) {
|
||||
let r;
|
||||
if (options.unmount) options.unmount(vnode);
|
||||
|
||||
if ((r = vnode.ref)) {
|
||||
if (!r.current || r.current === vnode._dom) {
|
||||
applyRef(r, null, parentVNode);
|
||||
}
|
||||
}
|
||||
|
||||
if ((r = vnode._component) != null) {
|
||||
if (r.componentWillUnmount) {
|
||||
try {
|
||||
r.componentWillUnmount();
|
||||
} catch (e) {
|
||||
options._catchError(e, parentVNode);
|
||||
}
|
||||
}
|
||||
|
||||
r.base = r._parentDom = null;
|
||||
vnode._component = undefined;
|
||||
}
|
||||
|
||||
if ((r = vnode._children)) {
|
||||
for (let i = 0; i < r.length; i++) {
|
||||
if (r[i]) {
|
||||
unmount(
|
||||
r[i],
|
||||
parentVNode,
|
||||
skipRemove || typeof vnode.type !== 'function'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipRemove && vnode._dom != null) {
|
||||
removeNode(vnode._dom);
|
||||
}
|
||||
|
||||
// Must be set to `undefined` to properly clean up `_nextDom`
|
||||
// for which `null` is a valid value. See comment in `create-element.js`
|
||||
vnode._parent = vnode._dom = vnode._nextDom = undefined;
|
||||
}
|
||||
|
||||
/** The `.render()` method for a PFC backing instance. */
|
||||
function doRender(props, state, context) {
|
||||
return this.constructor(props, context);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"lie","version":"3.1.1","files":{"package.json":{"checkedAt":1678883668044,"integrity":"sha512-cYMnNzSNRfG68qYWY39n8faYtARDTdIpNiEI1yNqe8sLBqsyh0hYf3HBdPEGdQbuIXf6pbiDDdR9ltHEhoQUjQ==","mode":420,"size":2333},"polyfill.js":{"checkedAt":1678883668044,"integrity":"sha512-mSZzzkzK7naw4CpuE7Ax1r1TleROeVXKt4ZDJgK2NRZmq0WKS9dNOG5ZqVJQPskWy1esvqcKyYzr01ETpdINeQ==","mode":420,"size":97},"README.md":{"checkedAt":1678883668044,"integrity":"sha512-KoJT/bI8+uUu16RD1kd3/kGV1yLAdq78bW0FxvInHB4BhjLlDV+yA+3xC/xBNlhSjZ0PcYUfX0odyZqP8G0yvw==","mode":420,"size":2185},"dist/lie.js":{"checkedAt":1678883668052,"integrity":"sha512-WZR4TCjJZRHz5fZ/c6HOdrnVpCPr5107lJNQqDFkPSp0dcv1ApXbCuPe9ykfEPXTOHxw12e4rNXLEXyYMQ2i+Q==","mode":420,"size":8882},"dist/lie.min.js":{"checkedAt":1678883668052,"integrity":"sha512-0TzNCFTvt7ki7RyArA9Yk/3fd54yndJ/aB2bKnueL5+wMQTqWmjDoZOO4+lm9SDQESc4/OQ87IEYoTDO3WAEqA==","mode":420,"size":4560},"dist/lie.polyfill.js":{"checkedAt":1678883668052,"integrity":"sha512-3rqtC0rBprt3BWw2iRnxnN9n1ASp9s5am+kc1cz11umHlBNypaiByUe36syzsZnYC9V8rq+qvx1Bx6KBLodf9g==","mode":420,"size":8806},"dist/lie.polyfill.min.js":{"checkedAt":1678883668056,"integrity":"sha512-wERV3ookDjUNe1kyI60k20oweXfL/uuSwo5iHIL6gn/t3CclYS7T7O5aOJF3G1+T0a0phzdXPcpM45XkAYwqnA==","mode":420,"size":4473},"lib/index.js":{"checkedAt":1678883668061,"integrity":"sha512-jCY0Dyd5OeXLGWGbwQXOAh6iflL1Cly4UfhqJp0M0KE9mlbbNGYhAiS1S+cAZqiwVSpjdOMrSEW6sMmn02fKxQ==","mode":420,"size":6544},"license.md":{"checkedAt":1678883668061,"integrity":"sha512-JOdt7CDRNQG7NkWvCy+iDOCMRoKaMj5VJczZgV05EiGDW/kbaOW8Lbvw35I1PCWgIUZlTXIPyRi0a/vfSHOwwA==","mode":420,"size":1063},"lib/browser.js":{"checkedAt":1678883668061,"integrity":"sha512-w4hjm8gtWwL6mRFzQiS1BeSZcWeUL83FWgev6QVIpEjVw/dn7FH4LPSn4JxdE0JHhJ8DCIVAqO00mRuPTECNeQ==","mode":420,"size":5933}}}
|
||||
@@ -0,0 +1,10 @@
|
||||
import assertString from './util/assertString';
|
||||
/* eslint-disable no-control-regex */
|
||||
|
||||
var ascii = /^[\x00-\x7F]+$/;
|
||||
/* eslint-enable no-control-regex */
|
||||
|
||||
export default function isAscii(str) {
|
||||
assertString(str);
|
||||
return ascii.test(str);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export type AddressFirstLineEmptyError = {
|
||||
name: string;
|
||||
message: string;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"@nodelib/fs.stat","version":"2.0.5","files":{"LICENSE":{"checkedAt":1678883670836,"integrity":"sha512-klyzttd362E9inpFU2X0jkZ+kaWZ+PhDEXJfMgfuWDKwC4dCmwlGbdsDCsQjWPUstsuss2EizcqjeZNZs2Qp9A==","mode":436,"size":1079},"out/types/index.js":{"checkedAt":1678883670006,"integrity":"sha512-f2XGQDoj2T+xSOglmwEtZVKrO/8Xj0p9ap2c7A9gQp/BiZ45tLyozAivx12afHv9sT/DcspjyF6yKwNV601gAA==","mode":436,"size":77},"out/providers/async.js":{"checkedAt":1678883670853,"integrity":"sha512-WGvkZNI53zAS924GU7bHom60HgY8gSFZ3U87JX4Rts4pssL4MB3TvrgFK85RJvaB7zJOrr0JuJQK3MnrsUoNFg==","mode":436,"size":1172},"out/settings.js":{"checkedAt":1678883670853,"integrity":"sha512-KEfb5/CC6cKYgaEF+c6jLeeNqJEWdvp/CTQpl8d5Oo6CWUAqzrQeGnTDIeP0seCwHDiZ7K2dOgncktxCLhkUPA==","mode":436,"size":696},"out/providers/sync.js":{"checkedAt":1678883670853,"integrity":"sha512-LBPUBjmUgAk9/K1qLnzDYMOcdVBK86FGNT/nFUDkfBL+PykFHj1lOfc5IJYGrfum7WT4un5WEeNdmpVaCT2O0w==","mode":436,"size":619},"out/adapters/fs.js":{"checkedAt":1678883670853,"integrity":"sha512-MZSasW+xOVwHCHfQTVPc1Lbaxw0JGvYlxdfqC/U8m9uARkhYRmucM8GK/BjW6OLx4P198wH9bcyv9UK8dhaLHQ==","mode":436,"size":582},"out/index.js":{"checkedAt":1678883670853,"integrity":"sha512-43c8NlDLnb4dqqc/a2J/qlV03sGez3pQ3+eBiLFiixwTLKkenEnWGpmuagt9bf0PEW8tMfyP1vu6KU1LETAylw==","mode":436,"size":985},"package.json":{"checkedAt":1678883670853,"integrity":"sha512-AIZWEYtERaNH6NsgrP6h7h2YkA8MaehXOfxsXe5EVMIHCJUkqa/iY2dc6G6HDN9cfzYWiOhxhenwlmw4zQEIfw==","mode":436,"size":987},"README.md":{"checkedAt":1678883670855,"integrity":"sha512-lT8GLsiILkVtz6YDwn9akZXaCLrEDfrEaHlz8eSaWJmtrWsgBQ20l68GIO8y2VR1gbtkU/SGaahiV8wnSXIPQQ==","mode":436,"size":3075},"out/providers/async.d.ts":{"checkedAt":1678883670855,"integrity":"sha512-aYrSEI082VSfkWQtWxTbraQdRZfzFMPV4gjcdBd5Bt7MRfS1t58Y+hLOpK5ww/rM07tKu70d5IRLaqNdAmzIRg==","mode":436,"size":274},"out/adapters/fs.d.ts":{"checkedAt":1678883670855,"integrity":"sha512-gDdCZQwy88D0U5Z/MCfbOltQR1BURn8zAGtqpX1vLfa6J7OksDIsp4hHd31QkGH0vWK6yIw4aDiAHa3+IeLW3w==","mode":436,"size":665},"out/index.d.ts":{"checkedAt":1678883670855,"integrity":"sha512-5/Ajq22Pze3f0J8MQ9hDNBqbC40hN5c+sxT8Jverr01tMZPL8LPQRWzpxBUJP63lmxVfv6K53orP57tl6/ikuQ==","mode":436,"size":805},"out/types/index.d.ts":{"checkedAt":1678883670855,"integrity":"sha512-dzVCLi5yHoYiNUOP3ZPdWo9VGH2RONeiu1QuBLKCblm3MNor7kYBHFF+iUMHo9yi/xsWxoxmAPaMhRDcoPo/uA==","mode":436,"size":160},"out/settings.d.ts":{"checkedAt":1678883670855,"integrity":"sha512-1XtWvI2VxITfAZx3onYNHlBv/SH7VgpjSVVQYU7+sCjpUd22GgBqo1wnOVCbJRO4WLFT1SWuM3KLSD5VX8txig==","mode":436,"size":518},"out/providers/sync.d.ts":{"checkedAt":1678883670855,"integrity":"sha512-C5x5aZuOh9iht9jAeTg8kM832/Yt4SazArNl9w08NmxAhx8AXy4aclMWCoeI2/EyVK7+46pKei1SbV/RV48L1Q==","mode":436,"size":151}}}
|
||||
@@ -0,0 +1,129 @@
|
||||
import { AsyncAction } from './AsyncAction';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { AsyncScheduler } from './AsyncScheduler';
|
||||
import { SchedulerAction } from '../types';
|
||||
import { TimerHandle } from './timerHandle';
|
||||
|
||||
export class VirtualTimeScheduler extends AsyncScheduler {
|
||||
/** @deprecated Not used in VirtualTimeScheduler directly. Will be removed in v8. */
|
||||
static frameTimeFactor = 10;
|
||||
|
||||
/**
|
||||
* The current frame for the state of the virtual scheduler instance. The difference
|
||||
* between two "frames" is synonymous with the passage of "virtual time units". So if
|
||||
* you record `scheduler.frame` to be `1`, then later, observe `scheduler.frame` to be at `11`,
|
||||
* that means `10` virtual time units have passed.
|
||||
*/
|
||||
public frame: number = 0;
|
||||
|
||||
/**
|
||||
* Used internally to examine the current virtual action index being processed.
|
||||
* @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
|
||||
*/
|
||||
public index: number = -1;
|
||||
|
||||
/**
|
||||
* This creates an instance of a `VirtualTimeScheduler`. Experts only. The signature of
|
||||
* this constructor is likely to change in the long run.
|
||||
*
|
||||
* @param schedulerActionCtor The type of Action to initialize when initializing actions during scheduling.
|
||||
* @param maxFrames The maximum number of frames to process before stopping. Used to prevent endless flush cycles.
|
||||
*/
|
||||
constructor(schedulerActionCtor: typeof AsyncAction = VirtualAction as any, public maxFrames: number = Infinity) {
|
||||
super(schedulerActionCtor, () => this.frame);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the Scheduler to execute all of its queued actions, therefore
|
||||
* clearing its queue.
|
||||
* @return {void}
|
||||
*/
|
||||
public flush(): void {
|
||||
const { actions, maxFrames } = this;
|
||||
let error: any;
|
||||
let action: AsyncAction<any> | undefined;
|
||||
|
||||
while ((action = actions[0]) && action.delay <= maxFrames) {
|
||||
actions.shift();
|
||||
this.frame = action.delay;
|
||||
|
||||
if ((error = action.execute(action.state, action.delay))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (error) {
|
||||
while ((action = actions.shift())) {
|
||||
action.unsubscribe();
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class VirtualAction<T> extends AsyncAction<T> {
|
||||
protected active: boolean = true;
|
||||
|
||||
constructor(
|
||||
protected scheduler: VirtualTimeScheduler,
|
||||
protected work: (this: SchedulerAction<T>, state?: T) => void,
|
||||
protected index: number = (scheduler.index += 1)
|
||||
) {
|
||||
super(scheduler, work);
|
||||
this.index = scheduler.index = index;
|
||||
}
|
||||
|
||||
public schedule(state?: T, delay: number = 0): Subscription {
|
||||
if (Number.isFinite(delay)) {
|
||||
if (!this.id) {
|
||||
return super.schedule(state, delay);
|
||||
}
|
||||
this.active = false;
|
||||
// If an action is rescheduled, we save allocations by mutating its state,
|
||||
// pushing it to the end of the scheduler queue, and recycling the action.
|
||||
// But since the VirtualTimeScheduler is used for testing, VirtualActions
|
||||
// must be immutable so they can be inspected later.
|
||||
const action = new VirtualAction(this.scheduler, this.work);
|
||||
this.add(action);
|
||||
return action.schedule(state, delay);
|
||||
} else {
|
||||
// If someone schedules something with Infinity, it'll never happen. So we
|
||||
// don't even schedule it.
|
||||
return Subscription.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
protected requestAsyncId(scheduler: VirtualTimeScheduler, id?: any, delay: number = 0): TimerHandle {
|
||||
this.delay = scheduler.frame + delay;
|
||||
const { actions } = scheduler;
|
||||
actions.push(this);
|
||||
(actions as Array<VirtualAction<T>>).sort(VirtualAction.sortActions);
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected recycleAsyncId(scheduler: VirtualTimeScheduler, id?: any, delay: number = 0): TimerHandle | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
protected _execute(state: T, delay: number): any {
|
||||
if (this.active === true) {
|
||||
return super._execute(state, delay);
|
||||
}
|
||||
}
|
||||
|
||||
private static sortActions<T>(a: VirtualAction<T>, b: VirtualAction<T>) {
|
||||
if (a.delay === b.delay) {
|
||||
if (a.index === b.index) {
|
||||
return 0;
|
||||
} else if (a.index > b.index) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else if (a.delay > b.delay) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
module.exports=function filterRow(row, param) {
|
||||
if (param.ignoreColumns instanceof Array && param.ignoreColumns.length > 0) {
|
||||
for (var igRow = 0, igColLen = param.ignoreColumns.length; igRow < igColLen; igRow++) {
|
||||
if (param.ignoreColumns[igRow] >= 0) {
|
||||
row.splice(param.ignoreColumns[igRow], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (param.includeColumns instanceof Array && param.includeColumns.length > 0) {
|
||||
var cleanRowArr = [];
|
||||
for (var inRow = 0, inColLen = param.includeColumns.length; inRow < inColLen; inRow++) {
|
||||
if (param.includeColumns[inRow] >= 0) {
|
||||
cleanRowArr.push(row[param.includeColumns[inRow]]);
|
||||
}
|
||||
}
|
||||
row = cleanRowArr;
|
||||
}
|
||||
return row;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./is-implemented")() ? Array.prototype.find : require("./shim");
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"B","2":"J D E F CC","289":"A"},B:{"1":"C K L G M N O P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H"},C:{"1":"XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"0 1 2 3 4 DC tB I v J D E F A B C K L G M N O w g x y z EC FC","194":"5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB","1025":"SB TB UB VB WB"},D:{"1":"CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB"},E:{"2":"I v J D E F A B C K L G HC zB IC JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"F B C G M N O w g x y PC QC RC SC qB AC TC rB"},G:{"1":"hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"E zB UC BC VC WC XC YC ZC","516":"aC bC cC dC eC fC gC"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"1":"B","289":"A"},O:{"1":"vC"},P:{"1":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"BD","194":"AD"}},B:2,C:"CSS touch-action property"};
|
||||
@@ -0,0 +1,156 @@
|
||||
import * as preact from './index';
|
||||
|
||||
export enum HookType {
|
||||
useState = 1,
|
||||
useReducer = 2,
|
||||
useEffect = 3,
|
||||
useLayoutEffect = 4,
|
||||
useRef = 5,
|
||||
useImperativeHandle = 6,
|
||||
useMemo = 7,
|
||||
useCallback = 8,
|
||||
useContext = 9,
|
||||
useErrorBoundary = 10,
|
||||
// Not a real hook, but the devtools treat is as such
|
||||
useDebugvalue = 11
|
||||
}
|
||||
|
||||
export interface DevSource {
|
||||
fileName: string;
|
||||
lineNumber: number;
|
||||
}
|
||||
|
||||
export interface ErrorInfo {
|
||||
componentStack?: string;
|
||||
}
|
||||
|
||||
export interface Options extends preact.Options {
|
||||
/** Attach a hook that is invoked before render, mainly to check the arguments. */
|
||||
_root?(
|
||||
vnode: ComponentChild,
|
||||
parent: Element | Document | ShadowRoot | DocumentFragment
|
||||
): void;
|
||||
/** Attach a hook that is invoked before a vnode is diffed. */
|
||||
_diff?(vnode: VNode): void;
|
||||
/** Attach a hook that is invoked after a tree was mounted or was updated. */
|
||||
_commit?(vnode: VNode, commitQueue: Component[]): void;
|
||||
/** Attach a hook that is invoked before a vnode has rendered. */
|
||||
_render?(vnode: VNode): void;
|
||||
/** Attach a hook that is invoked before a hook's state is queried. */
|
||||
_hook?(component: Component, index: number, type: HookType): void;
|
||||
/** Bypass effect execution. Currenty only used in devtools for hooks inspection */
|
||||
_skipEffects?: boolean;
|
||||
/** Attach a hook that is invoked after an error is caught in a component but before calling lifecycle hooks */
|
||||
_catchError(
|
||||
error: any,
|
||||
vnode: VNode,
|
||||
oldVNode: VNode | undefined,
|
||||
errorInfo: ErrorInfo | undefined
|
||||
): void;
|
||||
}
|
||||
|
||||
export type ComponentChild =
|
||||
| VNode<any>
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null
|
||||
| undefined;
|
||||
export type ComponentChildren = ComponentChild[] | ComponentChild;
|
||||
|
||||
export interface FunctionComponent<P = {}> extends preact.FunctionComponent<P> {
|
||||
// Internally, createContext uses `contextType` on a Function component to
|
||||
// implement the Consumer component
|
||||
contextType?: PreactContext;
|
||||
|
||||
// Internally, createContext stores a ref to the context object on the Provider
|
||||
// Function component to help devtools
|
||||
_contextRef?: PreactContext;
|
||||
|
||||
// Define these properties as undefined on FunctionComponent to get rid of
|
||||
// some errors in `diff()`
|
||||
getDerivedStateFromProps?: undefined;
|
||||
getDerivedStateFromError?: undefined;
|
||||
}
|
||||
|
||||
export interface ComponentClass<P = {}> extends preact.ComponentClass<P> {
|
||||
_contextRef?: any;
|
||||
|
||||
// Override public contextType with internal PreactContext type
|
||||
contextType?: PreactContext;
|
||||
}
|
||||
|
||||
// Redefine ComponentType using our new internal FunctionComponent interface above
|
||||
export type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
||||
|
||||
export interface PreactElement extends HTMLElement {
|
||||
_children?: VNode<any> | null;
|
||||
/** Event listeners to support event delegation */
|
||||
_listeners?: Record<string, (e: Event) => void>;
|
||||
|
||||
// Preact uses this attribute to detect SVG nodes
|
||||
ownerSVGElement?: SVGElement | null;
|
||||
|
||||
// style: HTMLElement["style"]; // From HTMLElement
|
||||
|
||||
data?: string | number; // From Text node
|
||||
}
|
||||
|
||||
// We use the `current` property to differentiate between the two kinds of Refs so
|
||||
// internally we'll define `current` on both to make TypeScript happy
|
||||
type RefObject<T> = { current: T | null };
|
||||
type RefCallback<T> = { (instance: T | null): void; current: undefined };
|
||||
type Ref<T> = RefObject<T> | RefCallback<T>;
|
||||
|
||||
export interface VNode<P = {}> extends preact.VNode<P> {
|
||||
// Redefine type here using our internal ComponentType type
|
||||
type: string | ComponentType<P>;
|
||||
props: P & { children: ComponentChildren };
|
||||
ref?: Ref<any> | null;
|
||||
_children: Array<VNode<any>> | null;
|
||||
_parent: VNode | null;
|
||||
_depth: number | null;
|
||||
/**
|
||||
* The [first (for Fragments)] DOM child of a VNode
|
||||
*/
|
||||
_dom: PreactElement | null;
|
||||
/**
|
||||
* The last dom child of a Fragment, or components that return a Fragment
|
||||
*/
|
||||
_nextDom: PreactElement | null;
|
||||
_component: Component | null;
|
||||
_hydrating: boolean | null;
|
||||
constructor: undefined;
|
||||
_original: number;
|
||||
}
|
||||
|
||||
export interface Component<P = {}, S = {}> extends preact.Component<P, S> {
|
||||
// When component is functional component, this is reset to functional component
|
||||
constructor: ComponentType<P>;
|
||||
state: S; // Override Component["state"] to not be readonly for internal use, specifically Hooks
|
||||
base?: PreactElement;
|
||||
|
||||
_dirty: boolean;
|
||||
_force?: boolean;
|
||||
_renderCallbacks: Array<() => void>; // Only class components
|
||||
_stateCallbacks: Array<() => void>; // Only class components
|
||||
_globalContext?: any;
|
||||
_vnode?: VNode<P> | null;
|
||||
_nextState?: S | null; // Only class components
|
||||
/** Only used in the devtools to later dirty check if state has changed */
|
||||
_prevState?: S | null;
|
||||
/**
|
||||
* Pointer to the parent dom node. This is only needed for top-level Fragment
|
||||
* components or array returns.
|
||||
*/
|
||||
_parentDom?: PreactElement | null;
|
||||
// Always read, set only when handling error
|
||||
_processingException?: Component<any, any> | null;
|
||||
// Always read, set only when handling error. This is used to indicate at diffTime to set _processingException
|
||||
_pendingError?: Component<any, any> | null;
|
||||
}
|
||||
|
||||
export interface PreactContext extends preact.Context<any> {
|
||||
_id: string;
|
||||
_defaultValue: any;
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
import { SHA2 } from './_sha2.js';
|
||||
import { rotr, wrapConstructor } from './utils.js';
|
||||
|
||||
// Choice: a ? b : c
|
||||
const Chi = (a: number, b: number, c: number) => (a & b) ^ (~a & c);
|
||||
// Majority function, true if any two inpust is true
|
||||
const Maj = (a: number, b: number, c: number) => (a & b) ^ (a & c) ^ (b & c);
|
||||
|
||||
// Round constants:
|
||||
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
||||
// prettier-ignore
|
||||
const SHA256_K = new Uint32Array([
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
]);
|
||||
|
||||
// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
||||
// prettier-ignore
|
||||
const IV = new Uint32Array([
|
||||
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
||||
]);
|
||||
|
||||
// Temporary buffer, not used to store anything between runs
|
||||
// Named this way because it matches specification.
|
||||
const SHA256_W = new Uint32Array(64);
|
||||
class SHA256 extends SHA2<SHA256> {
|
||||
// We cannot use array here since array allows indexing by variable
|
||||
// which means optimizer/compiler cannot use registers.
|
||||
A = IV[0] | 0;
|
||||
B = IV[1] | 0;
|
||||
C = IV[2] | 0;
|
||||
D = IV[3] | 0;
|
||||
E = IV[4] | 0;
|
||||
F = IV[5] | 0;
|
||||
G = IV[6] | 0;
|
||||
H = IV[7] | 0;
|
||||
|
||||
constructor() {
|
||||
super(64, 32, 8, false);
|
||||
}
|
||||
protected get(): [number, number, number, number, number, number, number, number] {
|
||||
const { A, B, C, D, E, F, G, H } = this;
|
||||
return [A, B, C, D, E, F, G, H];
|
||||
}
|
||||
// prettier-ignore
|
||||
protected set(
|
||||
A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number
|
||||
) {
|
||||
this.A = A | 0;
|
||||
this.B = B | 0;
|
||||
this.C = C | 0;
|
||||
this.D = D | 0;
|
||||
this.E = E | 0;
|
||||
this.F = F | 0;
|
||||
this.G = G | 0;
|
||||
this.H = H | 0;
|
||||
}
|
||||
protected process(view: DataView, offset: number): void {
|
||||
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
||||
for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);
|
||||
for (let i = 16; i < 64; i++) {
|
||||
const W15 = SHA256_W[i - 15];
|
||||
const W2 = SHA256_W[i - 2];
|
||||
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
|
||||
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
|
||||
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
||||
}
|
||||
// Compression function main loop, 64 rounds
|
||||
let { A, B, C, D, E, F, G, H } = this;
|
||||
for (let i = 0; i < 64; i++) {
|
||||
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
||||
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
||||
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
||||
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
||||
H = G;
|
||||
G = F;
|
||||
F = E;
|
||||
E = (D + T1) | 0;
|
||||
D = C;
|
||||
C = B;
|
||||
B = A;
|
||||
A = (T1 + T2) | 0;
|
||||
}
|
||||
// Add the compressed chunk to the current hash value
|
||||
A = (A + this.A) | 0;
|
||||
B = (B + this.B) | 0;
|
||||
C = (C + this.C) | 0;
|
||||
D = (D + this.D) | 0;
|
||||
E = (E + this.E) | 0;
|
||||
F = (F + this.F) | 0;
|
||||
G = (G + this.G) | 0;
|
||||
H = (H + this.H) | 0;
|
||||
this.set(A, B, C, D, E, F, G, H);
|
||||
}
|
||||
protected roundClean() {
|
||||
SHA256_W.fill(0);
|
||||
}
|
||||
destroy() {
|
||||
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
this.buffer.fill(0);
|
||||
}
|
||||
}
|
||||
// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
|
||||
class SHA224 extends SHA256 {
|
||||
A = 0xc1059ed8 | 0;
|
||||
B = 0x367cd507 | 0;
|
||||
C = 0x3070dd17 | 0;
|
||||
D = 0xf70e5939 | 0;
|
||||
E = 0xffc00b31 | 0;
|
||||
F = 0x68581511 | 0;
|
||||
G = 0x64f98fa7 | 0;
|
||||
H = 0xbefa4fa4 | 0;
|
||||
constructor() {
|
||||
super();
|
||||
this.outputLen = 28;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA2-256 hash function
|
||||
* @param message - data that would be hashed
|
||||
*/
|
||||
export const sha256 = wrapConstructor(() => new SHA256());
|
||||
export const sha224 = wrapConstructor(() => new SHA224());
|
||||
@@ -0,0 +1,141 @@
|
||||
var Parser = require('../lib/parser'),
|
||||
parseListEntry = Parser.parseListEntry;
|
||||
|
||||
var path = require('path'),
|
||||
assert = require('assert'),
|
||||
inspect = require('util').inspect;
|
||||
|
||||
var group = path.basename(__filename, '.js') + '/';
|
||||
|
||||
[
|
||||
{ source: 'drwxr-xr-x 10 root root 4096 Dec 21 2012 usr',
|
||||
expected: {
|
||||
type: 'd',
|
||||
name: 'usr',
|
||||
target: undefined,
|
||||
sticky: false,
|
||||
rights: { user: 'rwx', group: 'rx', other: 'rx' },
|
||||
acl: false,
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
size: 4096,
|
||||
date: new Date('2012-12-21T00:00')
|
||||
},
|
||||
what: 'Normal directory'
|
||||
},
|
||||
{ source: 'drwxrwxrwx 1 owner group 0 Aug 31 2012 e-books',
|
||||
expected: {
|
||||
type: 'd',
|
||||
name: 'e-books',
|
||||
target: undefined,
|
||||
sticky: false,
|
||||
rights: { user: 'rwx', group: 'rwx', other: 'rwx' },
|
||||
acl: false,
|
||||
owner: 'owner',
|
||||
group: 'group',
|
||||
size: 0,
|
||||
date: new Date('2012-08-31T00:00')
|
||||
},
|
||||
what: 'Normal directory #2'
|
||||
},
|
||||
{ source: '-rw-rw-rw- 1 owner group 7045120 Sep 02 2012 music.mp3',
|
||||
expected: {
|
||||
type: '-',
|
||||
name: 'music.mp3',
|
||||
target: undefined,
|
||||
sticky: false,
|
||||
rights: { user: 'rw', group: 'rw', other: 'rw' },
|
||||
acl: false,
|
||||
owner: 'owner',
|
||||
group: 'group',
|
||||
size: 7045120,
|
||||
date: new Date('2012-09-02T00:00')
|
||||
},
|
||||
what: 'Normal file'
|
||||
},
|
||||
{ source: '-rw-rw-rw-+ 1 owner group 7045120 Sep 02 2012 music.mp3',
|
||||
expected: {
|
||||
type: '-',
|
||||
name: 'music.mp3',
|
||||
target: undefined,
|
||||
sticky: false,
|
||||
rights: { user: 'rw', group: 'rw', other: 'rw' },
|
||||
acl: true,
|
||||
owner: 'owner',
|
||||
group: 'group',
|
||||
size: 7045120,
|
||||
date: new Date('2012-09-02T00:00')
|
||||
},
|
||||
what: 'File with ACL set'
|
||||
},
|
||||
{ source: 'drwxrwxrwt 7 root root 4096 May 19 2012 tmp',
|
||||
expected: {
|
||||
type: 'd',
|
||||
name: 'tmp',
|
||||
target: undefined,
|
||||
sticky: true,
|
||||
rights: { user: 'rwx', group: 'rwx', other: 'rwx' },
|
||||
acl: false,
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
size: 4096,
|
||||
date: new Date('2012-05-19T00:00')
|
||||
},
|
||||
what: 'Directory with sticky bit and executable for others'
|
||||
},
|
||||
{ source: 'drwxrwx--t 7 root root 4096 May 19 2012 tmp',
|
||||
expected: {
|
||||
type: 'd',
|
||||
name: 'tmp',
|
||||
target: undefined,
|
||||
sticky: true,
|
||||
rights: { user: 'rwx', group: 'rwx', other: 'x' },
|
||||
acl: false,
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
size: 4096,
|
||||
date: new Date('2012-05-19T00:00')
|
||||
},
|
||||
what: 'Directory with sticky bit and executable for others #2'
|
||||
},
|
||||
{ source: 'drwxrwxrwT 7 root root 4096 May 19 2012 tmp',
|
||||
expected: {
|
||||
type: 'd',
|
||||
name: 'tmp',
|
||||
target: undefined,
|
||||
sticky: true,
|
||||
rights: { user: 'rwx', group: 'rwx', other: 'rw' },
|
||||
acl: false,
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
size: 4096,
|
||||
date: new Date('2012-05-19T00:00')
|
||||
},
|
||||
what: 'Directory with sticky bit and not executable for others'
|
||||
},
|
||||
{ source: 'drwxrwx--T 7 root root 4096 May 19 2012 tmp',
|
||||
expected: {
|
||||
type: 'd',
|
||||
name: 'tmp',
|
||||
target: undefined,
|
||||
sticky: true,
|
||||
rights: { user: 'rwx', group: 'rwx', other: '' },
|
||||
acl: false,
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
size: 4096,
|
||||
date: new Date('2012-05-19T00:00')
|
||||
},
|
||||
what: 'Directory with sticky bit and not executable for others #2'
|
||||
},
|
||||
{ source: 'total 871',
|
||||
expected: null,
|
||||
what: 'Ignored line'
|
||||
},
|
||||
].forEach(function(v) {
|
||||
var result = parseListEntry(v.source),
|
||||
msg = '[' + group + v.what + ']: parsed output mismatch.\n'
|
||||
+ 'Saw: ' + inspect(result) + '\n'
|
||||
+ 'Expected: ' + inspect(v.expected);
|
||||
assert.deepEqual(result, v.expected, msg);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import { __read, __spreadArray } from "tslib";
|
||||
import { concat } from './concat';
|
||||
export function concatWith() {
|
||||
var otherSources = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
otherSources[_i] = arguments[_i];
|
||||
}
|
||||
return concat.apply(void 0, __spreadArray([], __read(otherSources)));
|
||||
}
|
||||
//# sourceMappingURL=concatWith.js.map
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Loader, LoaderSync, Options, OptionsSync } from './index';
|
||||
export declare type Config = any;
|
||||
export declare type CosmiconfigResult = {
|
||||
config: Config;
|
||||
filepath: string;
|
||||
isEmpty?: boolean;
|
||||
} | null;
|
||||
export interface InternalOptions {
|
||||
usePackagePropInConfigFiles?: boolean;
|
||||
metaConfigFilePath: string | null;
|
||||
}
|
||||
export interface ExplorerOptions extends Required<Options>, InternalOptions {
|
||||
}
|
||||
export interface ExplorerOptionsSync extends Required<OptionsSync>, InternalOptions {
|
||||
}
|
||||
export declare type Cache = Map<string, CosmiconfigResult>;
|
||||
export declare type LoadedFileContent = Config | null | undefined;
|
||||
export interface Loaders {
|
||||
[key: string]: Loader;
|
||||
}
|
||||
export interface LoadersSync {
|
||||
[key: string]: LoaderSync;
|
||||
}
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
@@ -0,0 +1,2 @@
|
||||
import { AnyResponse, EndpointOptions, RequestInterface, RequestParameters, Route, Token } from "./types";
|
||||
export declare function hook(token: Token, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<AnyResponse>;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"onErrorResumeNext.d.ts","sourceRoot":"","sources":["../../../../src/internal/observable/onErrorResumeNext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAOhD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9H,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
||||
@@ -0,0 +1,4 @@
|
||||
export type RunnerGroupNotFoundError = {
|
||||
name: string;
|
||||
message: string;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["../dist-src/version.js","../dist-src/index.js"],"sourcesContent":["export const VERSION = \"19.0.7\";\n","import { Octokit as Core } from \"@octokit/core\";\nimport { requestLog } from \"@octokit/plugin-request-log\";\nimport { paginateRest } from \"@octokit/plugin-paginate-rest\";\nimport { legacyRestEndpointMethods } from \"@octokit/plugin-rest-endpoint-methods\";\nimport { VERSION } from \"./version\";\nexport const Octokit = Core.plugin(requestLog, legacyRestEndpointMethods, paginateRest).defaults({\n userAgent: `octokit-rest.js/${VERSION}`,\n});\n"],"names":["VERSION","Octokit","Core","plugin","requestLog","legacyRestEndpointMethods","paginateRest","defaults","userAgent"],"mappings":";;;;;;;;;AAAO,MAAMA,OAAO,GAAG,mBAAmB;;MCK7BC,OAAO,GAAGC,YAAI,CAACC,MAAM,CAACC,2BAAU,EAAEC,mDAAyB,EAAEC,+BAAY,CAAC,CAACC,QAAQ,CAAC;EAC7FC,SAAS,EAAG,mBAAkBR,OAAQ;AAC1C,CAAC,CAAC;;;;"}
|
||||
@@ -0,0 +1,23 @@
|
||||
const parse = require('./parse')
|
||||
const eq = require('./eq')
|
||||
|
||||
const diff = (version1, version2) => {
|
||||
if (eq(version1, version2)) {
|
||||
return null
|
||||
} else {
|
||||
const v1 = parse(version1)
|
||||
const v2 = parse(version2)
|
||||
const hasPre = v1.prerelease.length || v2.prerelease.length
|
||||
const prefix = hasPre ? 'pre' : ''
|
||||
const defaultResult = hasPre ? 'prerelease' : ''
|
||||
for (const key in v1) {
|
||||
if (key === 'major' || key === 'minor' || key === 'patch') {
|
||||
if (v1[key] !== v2[key]) {
|
||||
return prefix + key
|
||||
}
|
||||
}
|
||||
}
|
||||
return defaultResult // may be undefined
|
||||
}
|
||||
}
|
||||
module.exports = diff
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('toLength', require('../toLength'), require('./_falseOptions'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ftp.js","sourceRoot":"","sources":["../src/ftp.ts"],"names":[],"mappings":"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"}
|
||||
@@ -0,0 +1,20 @@
|
||||
import Node from './shared/Node';
|
||||
import Expression from './shared/Expression';
|
||||
import Component from '../Component';
|
||||
import TemplateScope from './shared/TemplateScope';
|
||||
import { Context } from './shared/Context';
|
||||
import { ConstTag as ConstTagType } from '../../interfaces';
|
||||
import { INodeAllowConstTag } from './interfaces';
|
||||
import { Node as ESTreeNode } from 'estree';
|
||||
export default class ConstTag extends Node {
|
||||
type: 'ConstTag';
|
||||
expression: Expression;
|
||||
contexts: Context[];
|
||||
node: ConstTagType;
|
||||
scope: TemplateScope;
|
||||
context_rest_properties: Map<string, ESTreeNode>;
|
||||
assignees: Set<string>;
|
||||
dependencies: Set<string>;
|
||||
constructor(component: Component, parent: INodeAllowConstTag, scope: TemplateScope, info: ConstTagType);
|
||||
parse_expression(): void;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"combineLatest.js","sourceRoot":"","sources":["../../../../src/internal/observable/combineLatest.ts"],"names":[],"mappings":"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"}
|
||||
@@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var assign = require('object.assign');
|
||||
|
||||
var isPropertyDescriptor = require('../helpers/isPropertyDescriptor');
|
||||
|
||||
var IsArray = require('./IsArray');
|
||||
var IsAccessorDescriptor = require('./IsAccessorDescriptor');
|
||||
var IsDataDescriptor = require('./IsDataDescriptor');
|
||||
var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty');
|
||||
var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty');
|
||||
var ToNumber = require('./ToNumber');
|
||||
var ToString = require('./ToString');
|
||||
var ToUint32 = require('./ToUint32');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-arraysetlength
|
||||
|
||||
// eslint-disable-next-line max-statements, max-lines-per-function
|
||||
module.exports = function ArraySetLength(A, Desc) {
|
||||
if (!IsArray(A)) {
|
||||
throw new $TypeError('Assertion failed: A must be an Array');
|
||||
}
|
||||
if (!isPropertyDescriptor({
|
||||
Type: Type,
|
||||
IsDataDescriptor: IsDataDescriptor,
|
||||
IsAccessorDescriptor: IsAccessorDescriptor
|
||||
}, Desc)) {
|
||||
throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
|
||||
}
|
||||
if (!('[[Value]]' in Desc)) {
|
||||
return OrdinaryDefineOwnProperty(A, 'length', Desc);
|
||||
}
|
||||
var newLenDesc = assign({}, Desc);
|
||||
var newLen = ToUint32(Desc['[[Value]]']);
|
||||
var numberLen = ToNumber(Desc['[[Value]]']);
|
||||
if (newLen !== numberLen) {
|
||||
throw new $RangeError('Invalid array length');
|
||||
}
|
||||
newLenDesc['[[Value]]'] = newLen;
|
||||
var oldLenDesc = OrdinaryGetOwnProperty(A, 'length');
|
||||
if (!IsDataDescriptor(oldLenDesc)) {
|
||||
throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`');
|
||||
}
|
||||
var oldLen = oldLenDesc['[[Value]]'];
|
||||
if (newLen >= oldLen) {
|
||||
return OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
|
||||
}
|
||||
if (!oldLenDesc['[[Writable]]']) {
|
||||
return false;
|
||||
}
|
||||
var newWritable;
|
||||
if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) {
|
||||
newWritable = true;
|
||||
} else {
|
||||
newWritable = false;
|
||||
newLenDesc['[[Writable]]'] = true;
|
||||
}
|
||||
var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
|
||||
if (!succeeded) {
|
||||
return false;
|
||||
}
|
||||
while (newLen < oldLen) {
|
||||
oldLen -= 1;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
var deleteSucceeded = delete A[ToString(oldLen)];
|
||||
if (!deleteSucceeded) {
|
||||
newLenDesc['[[Value]]'] = oldLen + 1;
|
||||
if (!newWritable) {
|
||||
newLenDesc['[[Writable]]'] = false;
|
||||
OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!newWritable) {
|
||||
return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false });
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { IntlMessageFormat } from './src/core';
|
||||
export * from './src/formatters';
|
||||
export * from './src/core';
|
||||
export * from './src/error';
|
||||
export default IntlMessageFormat;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SubscriptionLoggable.js","sourceRoot":"","sources":["../../../../src/internal/testing/SubscriptionLoggable.ts"],"names":[],"mappings":";;;AACA,qDAAoD;AAEpD;IAAA;QACS,kBAAa,GAAsB,EAAE,CAAC;IAiB/C,CAAC;IAbC,iDAAkB,GAAlB;QACE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,iCAAe,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,mDAAoB,GAApB,UAAqB,KAAa;QAChC,IAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC;QAC5C,IAAM,kBAAkB,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACnD,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI,iCAAe,CAC3C,kBAAkB,CAAC,eAAe,EAClC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CACrB,CAAC;IACJ,CAAC;IACH,2BAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,oDAAoB"}
|
||||
@@ -0,0 +1,37 @@
|
||||
var baseSlice = require('./_baseSlice'),
|
||||
isIterateeCall = require('./_isIterateeCall'),
|
||||
toInteger = require('./toInteger');
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` from `start` up to, but not including, `end`.
|
||||
*
|
||||
* **Note:** This method is used instead of
|
||||
* [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
|
||||
* returned.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to slice.
|
||||
* @param {number} [start=0] The start position.
|
||||
* @param {number} [end=array.length] The end position.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
*/
|
||||
function slice(array, start, end) {
|
||||
var length = array == null ? 0 : array.length;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
|
||||
start = 0;
|
||||
end = length;
|
||||
}
|
||||
else {
|
||||
start = start == null ? 0 : toInteger(start);
|
||||
end = end === undefined ? length : toInteger(end);
|
||||
}
|
||||
return baseSlice(array, start, end);
|
||||
}
|
||||
|
||||
module.exports = slice;
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@formatjs/ecma402-abstract",
|
||||
"version": "1.11.4",
|
||||
"description": "A collection of implementation for ECMAScript abstract operations",
|
||||
"keywords": [
|
||||
"intl",
|
||||
"i18n",
|
||||
"relative",
|
||||
"javascript",
|
||||
"es",
|
||||
"abstract",
|
||||
"ecma402",
|
||||
"ecma262",
|
||||
"format"
|
||||
],
|
||||
"dependencies": {
|
||||
"@formatjs/intl-localematcher": "0.2.25",
|
||||
"tslib": "^2.1.0"
|
||||
},
|
||||
"author": "Long Ho <holevietlong@gmail.com",
|
||||
"bugs": {
|
||||
"url": "https://github.com/formatjs/formatjs/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:formatjs/formatjs.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"main": "index.js",
|
||||
"module": "lib/index.js",
|
||||
"types": "index.d.ts",
|
||||
"homepage": "https://github.com/formatjs/formatjs",
|
||||
"license": "MIT",
|
||||
"gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ConnectableObservable.js","sourceRoot":"","sources":["../../../../src/internal/observable/ConnectableObservable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,4CAA2C;AAE3C,gDAA+C;AAC/C,kDAAwE;AACxE,sEAA2E;AAC3E,qCAAuC;AASvC;IAA8C,yCAAa;IAgBzD,+BAAmB,MAAqB,EAAY,cAAgC;QAApF,YACE,iBAAO,SAOR;QARkB,YAAM,GAAN,MAAM,CAAe;QAAY,oBAAc,GAAd,cAAc,CAAkB;QAf1E,cAAQ,GAAsB,IAAI,CAAC;QACnC,eAAS,GAAW,CAAC,CAAC;QACtB,iBAAW,GAAwB,IAAI,CAAC;QAkBhD,IAAI,cAAO,CAAC,MAAM,CAAC,EAAE;YACnB,KAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;SACzB;;IACH,CAAC;IAGS,0CAAU,GAApB,UAAqB,UAAyB;QAC5C,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAES,0CAAU,GAApB;QACE,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;SACvC;QACD,OAAO,IAAI,CAAC,QAAS,CAAC;IACxB,CAAC;IAES,yCAAS,GAAnB;QACE,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACX,IAAA,WAAW,GAAK,IAAI,YAAT,CAAU;QAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,EAAE,CAAC;IAC7B,CAAC;IAMD,uCAAO,GAAP;QAAA,iBA6BC;QA5BC,IAAI,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;QAClC,IAAI,CAAC,UAAU,EAAE;YACf,UAAU,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,2BAAY,EAAE,CAAC;YACnD,IAAM,SAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAClC,UAAU,CAAC,GAAG,CACZ,IAAI,CAAC,MAAM,CAAC,SAAS,CACnB,6CAAwB,CACtB,SAAc,EACd,SAAS,EACT;gBACE,KAAI,CAAC,SAAS,EAAE,CAAC;gBACjB,SAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,CAAC,EACD,UAAC,GAAG;gBACF,KAAI,CAAC,SAAS,EAAE,CAAC;gBACjB,SAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC,EACD,cAAM,OAAA,KAAI,CAAC,SAAS,EAAE,EAAhB,CAAgB,CACvB,CACF,CACF,CAAC;YAEF,IAAI,UAAU,CAAC,MAAM,EAAE;gBACrB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;gBACxB,UAAU,GAAG,2BAAY,CAAC,KAAK,CAAC;aACjC;SACF;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAMD,wCAAQ,GAAR;QACE,OAAO,mBAAmB,EAAE,CAAC,IAAI,CAAkB,CAAC;IACtD,CAAC;IACH,4BAAC;AAAD,CAAC,AAxFD,CAA8C,uBAAU,GAwFvD;AAxFY,sDAAqB"}
|
||||
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var isFunction = require("../function/is");
|
||||
|
||||
var constructorRe = /^\s*(?:class[\s{/}]|function[\s(])/
|
||||
, functionToString = Function.prototype.toString;
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!isFunction(value)) return false;
|
||||
if (!constructorRe.test(functionToString.call(value))) return false;
|
||||
return true;
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"name": "gridjs",
|
||||
"version": "3.4.0",
|
||||
"description": "Advanced table plugin",
|
||||
"keywords": [
|
||||
"grid",
|
||||
"table",
|
||||
"gridjs",
|
||||
"list",
|
||||
"filter",
|
||||
"search",
|
||||
"sort",
|
||||
"pagination",
|
||||
"react",
|
||||
"angular",
|
||||
"jquery"
|
||||
],
|
||||
"homepage": "https://gridjs.io",
|
||||
"repository": "https://github.com/grid-js/gridjs",
|
||||
"main": "dist/gridjs.production.min.js",
|
||||
"module": "dist/gridjs.production.es.min.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/*"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||
"@types/enzyme": "^3.10.5",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/jest-axe": "^3.2.2",
|
||||
"@types/node": "^14.0.9",
|
||||
"@typescript-eslint/eslint-plugin": "~2.19.2",
|
||||
"@typescript-eslint/parser": "~2.34.0",
|
||||
"autoprefixer": "^9.8.0",
|
||||
"axe-core": "^4.0.0",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-preact-pure": "^3.0.0",
|
||||
"eslint": "~6.8.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-jest": "~24.2.1",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"jest": "~25.5.4",
|
||||
"jest-axe": "^4.0.0",
|
||||
"jest-extended": "^0.11.5",
|
||||
"jsdom": "^16.2.2",
|
||||
"jsdom-global": "^3.0.2",
|
||||
"lerna": "^3.22.1",
|
||||
"lerna-changelog": "^1.0.1",
|
||||
"node-sass": "^5.0.0",
|
||||
"node-sass-chokidar": "^1.5.0",
|
||||
"prettier": "~2.2.1",
|
||||
"rimraf": "~3.0.2",
|
||||
"rollup": "^2.11.2",
|
||||
"rollup-plugin-postcss": "^3.1.1",
|
||||
"rollup-plugin-sizes": "^1.0.3",
|
||||
"rollup-plugin-terser": "^7.0.0",
|
||||
"rollup-plugin-typescript2": "^0.30.0",
|
||||
"source-map-loader": "^0.2.4",
|
||||
"ts-jest": "^25.5.1",
|
||||
"ts-loader": "^8.0.0",
|
||||
"tsutils": "~3.21.0",
|
||||
"typescript": "^3.9.3"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf coverage dist tmp",
|
||||
"build": "rollup -c",
|
||||
"build:watch": "rollup -c --watch",
|
||||
"lint": "eslint . --ext .ts,.tsx",
|
||||
"test": "jest --coverage",
|
||||
"test:watch": "jest --watch"
|
||||
},
|
||||
"author": "Afshin Mehrabani <afshin.meh@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"preact": "^10.5.12",
|
||||
"tslib": "^2.0.1"
|
||||
},
|
||||
"changelog": {
|
||||
"labels": {
|
||||
"new feature": ":rocket: New Feature",
|
||||
"breaking": ":boom: Breaking Change",
|
||||
"bug fix": ":bug: Bug Fix",
|
||||
"polish": ":nail_care: Polish",
|
||||
"documentation": ":memo: Documentation",
|
||||
"internal": ":house: Internal",
|
||||
"performance": ":running_woman: Performance"
|
||||
},
|
||||
"cacheDir": ".changelog"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { ObservableInputTuple, OperatorFunction } from '../types';
|
||||
/**
|
||||
* Merge the values from all observables to a single observable result.
|
||||
*
|
||||
* Creates an observable, that when subscribed to, subscribes to the source
|
||||
* observable, and all other sources provided as arguments. All values from
|
||||
* every source are emitted from the resulting subscription.
|
||||
*
|
||||
* When all sources complete, the resulting observable will complete.
|
||||
*
|
||||
* When any source errors, the resulting observable will error.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* Joining all outputs from multiple user input event streams
|
||||
*
|
||||
* ```ts
|
||||
* import { fromEvent, map, mergeWith } from 'rxjs';
|
||||
*
|
||||
* const clicks$ = fromEvent(document, 'click').pipe(map(() => 'click'));
|
||||
* const mousemoves$ = fromEvent(document, 'mousemove').pipe(map(() => 'mousemove'));
|
||||
* const dblclicks$ = fromEvent(document, 'dblclick').pipe(map(() => 'dblclick'));
|
||||
*
|
||||
* mousemoves$
|
||||
* .pipe(mergeWith(clicks$, dblclicks$))
|
||||
* .subscribe(x => console.log(x));
|
||||
*
|
||||
* // result (assuming user interactions)
|
||||
* // 'mousemove'
|
||||
* // 'mousemove'
|
||||
* // 'mousemove'
|
||||
* // 'click'
|
||||
* // 'click'
|
||||
* // 'dblclick'
|
||||
* ```
|
||||
*
|
||||
* @see {@link merge}
|
||||
*
|
||||
* @param otherSources the sources to combine the current source with.
|
||||
* @return A function that returns an Observable that merges the values from
|
||||
* all given Observables.
|
||||
*/
|
||||
export declare function mergeWith<T, A extends readonly unknown[]>(...otherSources: [...ObservableInputTuple<A>]): OperatorFunction<T, T | A[number]>;
|
||||
//# sourceMappingURL=mergeWith.d.ts.map
|
||||
@@ -0,0 +1,27 @@
|
||||
var memoizeCapped = require('./_memoizeCapped');
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
||||
|
||||
/** Used to match backslashes in property paths. */
|
||||
var reEscapeChar = /\\(\\)?/g;
|
||||
|
||||
/**
|
||||
* Converts `string` to a property path array.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to convert.
|
||||
* @returns {Array} Returns the property path array.
|
||||
*/
|
||||
var stringToPath = memoizeCapped(function(string) {
|
||||
var result = [];
|
||||
if (string.charCodeAt(0) === 46 /* . */) {
|
||||
result.push('');
|
||||
}
|
||||
string.replace(rePropName, function(match, number, quote, subString) {
|
||||
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
module.exports = stringToPath;
|
||||
@@ -0,0 +1,16 @@
|
||||
// Thanks: https://github.com/monolithed/ECMAScript-6
|
||||
|
||||
"use strict";
|
||||
|
||||
var exp = Math.exp;
|
||||
|
||||
module.exports = function (value) {
|
||||
if (isNaN(value)) return NaN;
|
||||
value = Number(value);
|
||||
if (value === 0) return value;
|
||||
if (value === Infinity) return Infinity;
|
||||
if (value === -Infinity) return -1;
|
||||
|
||||
if (value > -1.0e-6 && value < 1.0e-6) return value + (value * value) / 2;
|
||||
return exp(value) - 1;
|
||||
};
|
||||
@@ -0,0 +1,553 @@
|
||||
# request.js
|
||||
|
||||
> Send parameterized requests to GitHub’s APIs with sensible defaults in browsers and Node
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/request)
|
||||
[](https://github.com/octokit/request.js/actions?query=workflow%3ATest+branch%3Amain)
|
||||
|
||||
`@octokit/request` is a request library for browsers & node that makes it easier
|
||||
to interact with [GitHub’s REST API](https://developer.github.com/v3/) and
|
||||
[GitHub’s GraphQL API](https://developer.github.com/v4/guides/forming-calls/#the-graphql-endpoint).
|
||||
|
||||
It uses [`@octokit/endpoint`](https://github.com/octokit/endpoint.js) to parse
|
||||
the passed options and sends the request using [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||
([node-fetch](https://github.com/bitinn/node-fetch) when the runtime has no native `fetch` API).
|
||||
|
||||
<!-- update table of contents by running `npx markdown-toc README.md -i` -->
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Features](#features)
|
||||
- [Usage](#usage)
|
||||
- [REST API example](#rest-api-example)
|
||||
- [GraphQL example](#graphql-example)
|
||||
- [Alternative: pass `method` & `url` as part of options](#alternative-pass-method--url-as-part-of-options)
|
||||
- [Authentication](#authentication)
|
||||
- [request()](#request)
|
||||
- [`request.defaults()`](#requestdefaults)
|
||||
- [`request.endpoint`](#requestendpoint)
|
||||
- [Special cases](#special-cases)
|
||||
- [The `data` parameter – set request body directly](#the-data-parameter--set-request-body-directly)
|
||||
- [Set parameters for both the URL/query and the request body](#set-parameters-for-both-the-urlquery-and-the-request-body)
|
||||
- [LICENSE](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Features
|
||||
|
||||
🤩 1:1 mapping of REST API endpoint documentation, e.g. [Add labels to an issue](https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue) becomes
|
||||
|
||||
```js
|
||||
request("POST /repos/{owner}/{repo}/issues/{number}/labels", {
|
||||
mediaType: {
|
||||
previews: ["symmetra"],
|
||||
},
|
||||
owner: "octokit",
|
||||
repo: "request.js",
|
||||
number: 1,
|
||||
labels: ["🐛 bug"],
|
||||
});
|
||||
```
|
||||
|
||||
👶 [Small bundle size](https://bundlephobia.com/result?p=@octokit/request@5.0.3) (\<4kb minified + gzipped)
|
||||
|
||||
😎 [Authenticate](#authentication) with any of [GitHubs Authentication Strategies](https://github.com/octokit/auth.js).
|
||||
|
||||
👍 Sensible defaults
|
||||
|
||||
- `baseUrl`: `https://api.github.com`
|
||||
- `headers.accept`: `application/vnd.github.v3+json`
|
||||
- `headers.agent`: `octokit-request.js/<current version> <OS information>`, e.g. `octokit-request.js/1.2.3 Node.js/10.15.0 (macOS Mojave; x64)`
|
||||
|
||||
👌 Simple to test: mock requests by passing a custom fetch method.
|
||||
|
||||
🧐 Simple to debug: Sets `error.request` to request options causing the error (with redacted credentials).
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
Load <code>@octokit/request</code> directly from <a href="https://cdn.skypack.dev">cdn.skypack.dev</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { request } from "https://cdn.skypack.dev/@octokit/request";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/request</code>
|
||||
|
||||
```js
|
||||
const { request } = require("@octokit/request");
|
||||
// or: import { request } from "@octokit/request";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### REST API example
|
||||
|
||||
```js
|
||||
// Following GitHub docs formatting:
|
||||
// https://developer.github.com/v3/repos/#list-organization-repositories
|
||||
const result = await request("GET /orgs/{org}/repos", {
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
|
||||
console.log(`${result.data.length} repos found.`);
|
||||
```
|
||||
|
||||
### GraphQL example
|
||||
|
||||
For GraphQL request we recommend using [`@octokit/graphql`](https://github.com/octokit/graphql.js#readme)
|
||||
|
||||
```js
|
||||
const result = await request("POST /graphql", {
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
query: `query ($login: String!) {
|
||||
organization(login: $login) {
|
||||
repositories(privacy: PRIVATE) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}`,
|
||||
variables: {
|
||||
login: "octokit",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Alternative: pass `method` & `url` as part of options
|
||||
|
||||
Alternatively, pass in a method and a url
|
||||
|
||||
```js
|
||||
const result = await request({
|
||||
method: "GET",
|
||||
url: "/orgs/{org}/repos",
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
The simplest way to authenticate a request is to set the `Authorization` header directly, e.g. to a [personal access token](https://github.com/settings/tokens/).
|
||||
|
||||
```js
|
||||
const requestWithAuth = request.defaults({
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
});
|
||||
const result = await requestWithAuth("GET /user");
|
||||
```
|
||||
|
||||
For more complex authentication strategies such as GitHub Apps or Basic, we recommend the according authentication library exported by [`@octokit/auth`](https://github.com/octokit/auth.js).
|
||||
|
||||
```js
|
||||
const { createAppAuth } = require("@octokit/auth-app");
|
||||
const auth = createAppAuth({
|
||||
appId: process.env.APP_ID,
|
||||
privateKey: process.env.PRIVATE_KEY,
|
||||
installationId: 123,
|
||||
});
|
||||
const requestWithAuth = request.defaults({
|
||||
request: {
|
||||
hook: auth.hook,
|
||||
},
|
||||
mediaType: {
|
||||
previews: ["machine-man"],
|
||||
},
|
||||
});
|
||||
|
||||
const { data: app } = await requestWithAuth("GET /app");
|
||||
const { data: app } = await requestWithAuth(
|
||||
"POST /repos/{owner}/{repo}/issues",
|
||||
{
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
title: "Hello from the engine room",
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## request()
|
||||
|
||||
`request(route, options)` or `request(options)`.
|
||||
|
||||
**Options**
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align=left>
|
||||
name
|
||||
</th>
|
||||
<th align=left>
|
||||
type
|
||||
</th>
|
||||
<th align=left>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>route</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
**Required**. If <code>route</code> is set it has to be a string consisting of the request method and URL, e.g. <code>GET /orgs/{org}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.baseUrl</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
The base URL that <code>route</code> or <code>url</code> will be prefixed with, if they use relative paths. <em>Defaults to <code>https://api.github.com</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<th align=left>
|
||||
<code>options.headers</code>
|
||||
</th>
|
||||
<td>
|
||||
Object
|
||||
</td>
|
||||
<td>
|
||||
Custom headers. Passed headers are merged with defaults:<br>
|
||||
<em><code>headers['user-agent']</code> defaults to <code>octokit-rest.js/1.2.3</code> (where <code>1.2.3</code> is the released version)</em>.<br>
|
||||
<em><code>headers['accept']</code> defaults to <code>application/vnd.github.v3+json</code>.<br> Use <code>options.mediaType.{format,previews}</code> to request API previews and custom media types.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.mediaType.format</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
Media type param, such as `raw`, `html`, or `full`. See <a href="https://developer.github.com/v3/media/">Media Types</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.mediaType.previews</code>
|
||||
</th>
|
||||
<td>
|
||||
Array of strings
|
||||
</td>
|
||||
<td>
|
||||
Name of previews, such as `mercy`, `symmetra`, or `scarlet-witch`. See <a href="https://developer.github.com/v3/previews/">API Previews</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.method</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>, case insensitive. <em>Defaults to <code>Get</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.url</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
**Required**. A path or full URL which may contain <code>:variable</code> or <code>{variable}</code> placeholders,
|
||||
e.g. <code>/orgs/{org}/repos</code>. The <code>url</code> is parsed using <a href="https://github.com/bramstein/url-template">url-template</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.data</code>
|
||||
</th>
|
||||
<td>
|
||||
Any
|
||||
</td>
|
||||
<td>
|
||||
Set request body directly instead of setting it to JSON based on additional parameters. See <a href="#data-parameter">"The `data` parameter"</a> below.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.agent</code>
|
||||
</th>
|
||||
<td>
|
||||
<a href="https://nodejs.org/api/http.html#http_class_http_agent">http(s).Agent</a> instance
|
||||
</td>
|
||||
<td>
|
||||
Node only. Useful for custom proxy, certificate, or dns lookup.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.fetch</code>
|
||||
</th>
|
||||
<td>
|
||||
Function
|
||||
</td>
|
||||
<td>
|
||||
Custom replacement for <a href="https://github.com/bitinn/node-fetch">built-in fetch method</a>. Useful for testing or request hooks.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.hook</code>
|
||||
</th>
|
||||
<td>
|
||||
Function
|
||||
</td>
|
||||
<td>
|
||||
Function with the signature <code>hook(request, endpointOptions)</code>, where <code>endpointOptions</code> are the parsed options as returned by <a href="https://github.com/octokit/endpoint.js#endpointmergeroute-options-or-endpointmergeoptions"><code>endpoint.merge()</code></a>, and <code>request</code> is <a href="https://github.com/octokit/request.js#request"><code>request()</code></a>. This option works great in conjuction with <a href="https://github.com/gr2m/before-after-hook">before-after-hook</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<a name="options-request-signal"></a><code>options.request.signal</code>
|
||||
</th>
|
||||
<td>
|
||||
<a href="https://github.com/bitinn/node-fetch/tree/e996bdab73baf996cf2dbf25643c8fe2698c3249#request-cancellation-with-abortsignal">new AbortController().signal</a>
|
||||
</td>
|
||||
<td>
|
||||
Use an <code>AbortController</code> instance to cancel a request. In node you can only cancel streamed requests.
|
||||
</td>
|
||||
</tr>
|
||||
<th align=left>
|
||||
<code>options.request.log</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>object</code>
|
||||
</td>
|
||||
<td>
|
||||
Used for internal logging. Defaults to <a href="https://developer.mozilla.org/en-US/docs/Web/API/console"><code>console</code></a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.timeout</code>
|
||||
</th>
|
||||
<td>
|
||||
Number
|
||||
</td>
|
||||
<td>
|
||||
Node only. Request/response timeout in ms, it resets on redirect. 0 to disable (OS limit applies). <a href="#options-request-signal">options.request.signal</a> is recommended instead.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
All other options except `options.request.*` will be passed depending on the `method` and `url` options.
|
||||
|
||||
1. If the option key is a placeholder in the `url`, it will be used as replacement. For example, if the passed options are `{url: '/orgs/{org}/repos', org: 'foo'}` the returned `options.url` is `https://api.github.com/orgs/foo/repos`
|
||||
2. If the `method` is `GET` or `HEAD`, the option is passed as query parameter
|
||||
3. Otherwise the parameter is passed in the request body as JSON key.
|
||||
|
||||
**Result**
|
||||
|
||||
`request` returns a promise. If the request was successful, the promise resolves with an object containing 4 keys:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align=left>
|
||||
key
|
||||
</th>
|
||||
<th align=left>
|
||||
type
|
||||
</th>
|
||||
<th align=left>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<th align=left><code>status</code></th>
|
||||
<td>Integer</td>
|
||||
<td>Response status status</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left><code>url</code></th>
|
||||
<td>String</td>
|
||||
<td>URL of response. If a request results in redirects, this is the final URL. You can send a <code>HEAD</code> request to retrieve it without loading the full response body.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left><code>headers</code></th>
|
||||
<td>Object</td>
|
||||
<td>All response headers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left><code>data</code></th>
|
||||
<td>Any</td>
|
||||
<td>The response body as returned from server. If the response is JSON then it will be parsed into an object</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
If an error occurs, the promise is rejected with an `error` object containing 3 keys to help with debugging:
|
||||
|
||||
- `error.status` The http response status code
|
||||
- `error.request` The request options such as `method`, `url` and `data`
|
||||
- `error.response` The http response object with `url`, `headers`, and `data`
|
||||
|
||||
If the error is due to an `AbortSignal` being used, the resulting `AbortError` is bubbled up to the caller.
|
||||
|
||||
## `request.defaults()`
|
||||
|
||||
Override or set default options. Example:
|
||||
|
||||
```js
|
||||
const myrequest = require("@octokit/request").defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
org: "my-project",
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
myrequest(`GET /orgs/{org}/repos`);
|
||||
```
|
||||
|
||||
You can call `.defaults()` again on the returned method, the defaults will cascade.
|
||||
|
||||
```js
|
||||
const myProjectRequest = request.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
},
|
||||
org: "my-project",
|
||||
});
|
||||
const myProjectRequestWithAuth = myProjectRequest.defaults({
|
||||
headers: {
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`myProjectRequest` now defaults the `baseUrl`, `headers['user-agent']`,
|
||||
`org` and `headers['authorization']` on top of `headers['accept']` that is set
|
||||
by the global default.
|
||||
|
||||
## `request.endpoint`
|
||||
|
||||
See https://github.com/octokit/endpoint.js. Example
|
||||
|
||||
```js
|
||||
const options = request.endpoint("GET /orgs/{org}/repos", {
|
||||
org: "my-project",
|
||||
type: "private",
|
||||
});
|
||||
|
||||
// {
|
||||
// method: 'GET',
|
||||
// url: 'https://api.github.com/orgs/my-project/repos?type=private',
|
||||
// headers: {
|
||||
// accept: 'application/vnd.github.v3+json',
|
||||
// authorization: 'token 0000000000000000000000000000000000000001',
|
||||
// 'user-agent': 'octokit/endpoint.js v1.2.3'
|
||||
// }
|
||||
// }
|
||||
```
|
||||
|
||||
All of the [`@octokit/endpoint`](https://github.com/octokit/endpoint.js) API can be used:
|
||||
|
||||
- [`octokitRequest.endpoint()`](#endpoint)
|
||||
- [`octokitRequest.endpoint.defaults()`](#endpointdefaults)
|
||||
- [`octokitRequest.endpoint.merge()`](#endpointdefaults)
|
||||
- [`octokitRequest.endpoint.parse()`](#endpointmerge)
|
||||
|
||||
## Special cases
|
||||
|
||||
<a name="data-parameter"></a>
|
||||
|
||||
### The `data` parameter – set request body directly
|
||||
|
||||
Some endpoints such as [Render a Markdown document in raw mode](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode) don’t have parameters that are sent as request body keys, instead the request body needs to be set directly. In these cases, set the `data` parameter.
|
||||
|
||||
```js
|
||||
const response = await request("POST /markdown/raw", {
|
||||
data: "Hello world github/linguist#1 **cool**, and #1!",
|
||||
headers: {
|
||||
accept: "text/html;charset=utf-8",
|
||||
"content-type": "text/plain",
|
||||
},
|
||||
});
|
||||
|
||||
// Request is sent as
|
||||
//
|
||||
// {
|
||||
// method: 'post',
|
||||
// url: 'https://api.github.com/markdown/raw',
|
||||
// headers: {
|
||||
// accept: 'text/html;charset=utf-8',
|
||||
// 'content-type': 'text/plain',
|
||||
// 'user-agent': userAgent
|
||||
// },
|
||||
// body: 'Hello world github/linguist#1 **cool**, and #1!'
|
||||
// }
|
||||
//
|
||||
// not as
|
||||
//
|
||||
// {
|
||||
// ...
|
||||
// body: '{"data": "Hello world github/linguist#1 **cool**, and #1!"}'
|
||||
// }
|
||||
```
|
||||
|
||||
### Set parameters for both the URL/query and the request body
|
||||
|
||||
There are API endpoints that accept both query parameters as well as a body. In that case you need to add the query parameters as templates to `options.url`, as defined in the [RFC 6570 URI Template specification](https://tools.ietf.org/html/rfc6570).
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
request(
|
||||
"POST https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}",
|
||||
{
|
||||
name: "example.zip",
|
||||
label: "short description",
|
||||
headers: {
|
||||
"content-type": "text/plain",
|
||||
"content-length": 14,
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
data: "Hello, world!",
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
Check if the process is running inside a Docker container.
|
||||
|
||||
@example
|
||||
```
|
||||
import isDocker = require('is-docker');
|
||||
|
||||
if (isDocker()) {
|
||||
console.log('Running inside a Docker container');
|
||||
}
|
||||
```
|
||||
*/
|
||||
declare function isDocker(): boolean;
|
||||
|
||||
export = isDocker;
|
||||
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.createNewLookupObject = createNewLookupObject;
|
||||
|
||||
var _utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Create a new object with "null"-prototype to avoid truthy results on prototype properties.
|
||||
* The resulting object can be used with "object[property]" to check if a property exists
|
||||
* @param {...object} sources a varargs parameter of source objects that will be merged
|
||||
* @returns {object}
|
||||
*/
|
||||
|
||||
function createNewLookupObject() {
|
||||
for (var _len = arguments.length, sources = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
sources[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _utils.extend.apply(undefined, [Object.create(null)].concat(sources));
|
||||
}
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL2xpYi9oYW5kbGViYXJzL2ludGVybmFsL2NyZWF0ZS1uZXctbG9va3VwLW9iamVjdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztxQkFBdUIsVUFBVTs7Ozs7Ozs7O0FBUTFCLFNBQVMscUJBQXFCLEdBQWE7b0NBQVQsT0FBTztBQUFQLFdBQU87OztBQUM5QyxTQUFPLGdDQUFPLE1BQU0sQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLFNBQUssT0FBTyxFQUFDLENBQUM7Q0FDaEQiLCJmaWxlIjoiY3JlYXRlLW5ldy1sb29rdXAtb2JqZWN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgZXh0ZW5kIH0gZnJvbSAnLi4vdXRpbHMnO1xuXG4vKipcbiAqIENyZWF0ZSBhIG5ldyBvYmplY3Qgd2l0aCBcIm51bGxcIi1wcm90b3R5cGUgdG8gYXZvaWQgdHJ1dGh5IHJlc3VsdHMgb24gcHJvdG90eXBlIHByb3BlcnRpZXMuXG4gKiBUaGUgcmVzdWx0aW5nIG9iamVjdCBjYW4gYmUgdXNlZCB3aXRoIFwib2JqZWN0W3Byb3BlcnR5XVwiIHRvIGNoZWNrIGlmIGEgcHJvcGVydHkgZXhpc3RzXG4gKiBAcGFyYW0gey4uLm9iamVjdH0gc291cmNlcyBhIHZhcmFyZ3MgcGFyYW1ldGVyIG9mIHNvdXJjZSBvYmplY3RzIHRoYXQgd2lsbCBiZSBtZXJnZWRcbiAqIEByZXR1cm5zIHtvYmplY3R9XG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBjcmVhdGVOZXdMb29rdXBPYmplY3QoLi4uc291cmNlcykge1xuICByZXR1cm4gZXh0ZW5kKE9iamVjdC5jcmVhdGUobnVsbCksIC4uLnNvdXJjZXMpO1xufVxuIl19
|
||||
@@ -0,0 +1,8 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
@@ -0,0 +1,138 @@
|
||||
import assertString from './util/assertString';
|
||||
/**
|
||||
* List of country codes with
|
||||
* corresponding IBAN regular expression
|
||||
* Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
|
||||
*/
|
||||
|
||||
var ibanRegexThroughCountryCode = {
|
||||
AD: /^(AD[0-9]{2})\d{8}[A-Z0-9]{12}$/,
|
||||
AE: /^(AE[0-9]{2})\d{3}\d{16}$/,
|
||||
AL: /^(AL[0-9]{2})\d{8}[A-Z0-9]{16}$/,
|
||||
AT: /^(AT[0-9]{2})\d{16}$/,
|
||||
AZ: /^(AZ[0-9]{2})[A-Z0-9]{4}\d{20}$/,
|
||||
BA: /^(BA[0-9]{2})\d{16}$/,
|
||||
BE: /^(BE[0-9]{2})\d{12}$/,
|
||||
BG: /^(BG[0-9]{2})[A-Z]{4}\d{6}[A-Z0-9]{8}$/,
|
||||
BH: /^(BH[0-9]{2})[A-Z]{4}[A-Z0-9]{14}$/,
|
||||
BR: /^(BR[0-9]{2})\d{23}[A-Z]{1}[A-Z0-9]{1}$/,
|
||||
BY: /^(BY[0-9]{2})[A-Z0-9]{4}\d{20}$/,
|
||||
CH: /^(CH[0-9]{2})\d{5}[A-Z0-9]{12}$/,
|
||||
CR: /^(CR[0-9]{2})\d{18}$/,
|
||||
CY: /^(CY[0-9]{2})\d{8}[A-Z0-9]{16}$/,
|
||||
CZ: /^(CZ[0-9]{2})\d{20}$/,
|
||||
DE: /^(DE[0-9]{2})\d{18}$/,
|
||||
DK: /^(DK[0-9]{2})\d{14}$/,
|
||||
DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/,
|
||||
EE: /^(EE[0-9]{2})\d{16}$/,
|
||||
EG: /^(EG[0-9]{2})\d{25}$/,
|
||||
ES: /^(ES[0-9]{2})\d{20}$/,
|
||||
FI: /^(FI[0-9]{2})\d{14}$/,
|
||||
FO: /^(FO[0-9]{2})\d{14}$/,
|
||||
FR: /^(FR[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
|
||||
GB: /^(GB[0-9]{2})[A-Z]{4}\d{14}$/,
|
||||
GE: /^(GE[0-9]{2})[A-Z0-9]{2}\d{16}$/,
|
||||
GI: /^(GI[0-9]{2})[A-Z]{4}[A-Z0-9]{15}$/,
|
||||
GL: /^(GL[0-9]{2})\d{14}$/,
|
||||
GR: /^(GR[0-9]{2})\d{7}[A-Z0-9]{16}$/,
|
||||
GT: /^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/,
|
||||
HR: /^(HR[0-9]{2})\d{17}$/,
|
||||
HU: /^(HU[0-9]{2})\d{24}$/,
|
||||
IE: /^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/,
|
||||
IL: /^(IL[0-9]{2})\d{19}$/,
|
||||
IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,
|
||||
IR: /^(IR[0-9]{2})0\d{2}0\d{18}$/,
|
||||
IS: /^(IS[0-9]{2})\d{22}$/,
|
||||
IT: /^(IT[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
|
||||
JO: /^(JO[0-9]{2})[A-Z]{4}\d{22}$/,
|
||||
KW: /^(KW[0-9]{2})[A-Z]{4}[A-Z0-9]{22}$/,
|
||||
KZ: /^(KZ[0-9]{2})\d{3}[A-Z0-9]{13}$/,
|
||||
LB: /^(LB[0-9]{2})\d{4}[A-Z0-9]{20}$/,
|
||||
LC: /^(LC[0-9]{2})[A-Z]{4}[A-Z0-9]{24}$/,
|
||||
LI: /^(LI[0-9]{2})\d{5}[A-Z0-9]{12}$/,
|
||||
LT: /^(LT[0-9]{2})\d{16}$/,
|
||||
LU: /^(LU[0-9]{2})\d{3}[A-Z0-9]{13}$/,
|
||||
LV: /^(LV[0-9]{2})[A-Z]{4}[A-Z0-9]{13}$/,
|
||||
MC: /^(MC[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
|
||||
MD: /^(MD[0-9]{2})[A-Z0-9]{20}$/,
|
||||
ME: /^(ME[0-9]{2})\d{18}$/,
|
||||
MK: /^(MK[0-9]{2})\d{3}[A-Z0-9]{10}\d{2}$/,
|
||||
MR: /^(MR[0-9]{2})\d{23}$/,
|
||||
MT: /^(MT[0-9]{2})[A-Z]{4}\d{5}[A-Z0-9]{18}$/,
|
||||
MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/,
|
||||
MZ: /^(MZ[0-9]{2})\d{21}$/,
|
||||
NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/,
|
||||
NO: /^(NO[0-9]{2})\d{11}$/,
|
||||
PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,
|
||||
PL: /^(PL[0-9]{2})\d{24}$/,
|
||||
PS: /^(PS[0-9]{2})[A-Z0-9]{4}\d{21}$/,
|
||||
PT: /^(PT[0-9]{2})\d{21}$/,
|
||||
QA: /^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
|
||||
RO: /^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/,
|
||||
RS: /^(RS[0-9]{2})\d{18}$/,
|
||||
SA: /^(SA[0-9]{2})\d{2}[A-Z0-9]{18}$/,
|
||||
SC: /^(SC[0-9]{2})[A-Z]{4}\d{20}[A-Z]{3}$/,
|
||||
SE: /^(SE[0-9]{2})\d{20}$/,
|
||||
SI: /^(SI[0-9]{2})\d{15}$/,
|
||||
SK: /^(SK[0-9]{2})\d{20}$/,
|
||||
SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
|
||||
SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,
|
||||
TL: /^(TL[0-9]{2})\d{19}$/,
|
||||
TN: /^(TN[0-9]{2})\d{20}$/,
|
||||
TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,
|
||||
UA: /^(UA[0-9]{2})\d{6}[A-Z0-9]{19}$/,
|
||||
VA: /^(VA[0-9]{2})\d{18}$/,
|
||||
VG: /^(VG[0-9]{2})[A-Z0-9]{4}\d{16}$/,
|
||||
XK: /^(XK[0-9]{2})\d{16}$/
|
||||
};
|
||||
/**
|
||||
* Check whether string has correct universal IBAN format
|
||||
* The IBAN consists of up to 34 alphanumeric characters, as follows:
|
||||
* Country Code using ISO 3166-1 alpha-2, two letters
|
||||
* check digits, two digits and
|
||||
* Basic Bank Account Number (BBAN), up to 30 alphanumeric characters.
|
||||
* NOTE: Permitted IBAN characters are: digits [0-9] and the 26 latin alphabetic [A-Z]
|
||||
*
|
||||
* @param {string} str - string under validation
|
||||
* @return {boolean}
|
||||
*/
|
||||
|
||||
function hasValidIbanFormat(str) {
|
||||
// Strip white spaces and hyphens
|
||||
var strippedStr = str.replace(/[\s\-]+/gi, '').toUpperCase();
|
||||
var isoCountryCode = strippedStr.slice(0, 2).toUpperCase();
|
||||
return isoCountryCode in ibanRegexThroughCountryCode && ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
|
||||
}
|
||||
/**
|
||||
* Check whether string has valid IBAN Checksum
|
||||
* by performing basic mod-97 operation and
|
||||
* the remainder should equal 1
|
||||
* -- Start by rearranging the IBAN by moving the four initial characters to the end of the string
|
||||
* -- Replace each letter in the string with two digits, A -> 10, B = 11, Z = 35
|
||||
* -- Interpret the string as a decimal integer and
|
||||
* -- compute the remainder on division by 97 (mod 97)
|
||||
* Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {boolean}
|
||||
*/
|
||||
|
||||
|
||||
function hasValidIbanChecksum(str) {
|
||||
var strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase(); // Keep only digits and A-Z latin alphabetic
|
||||
|
||||
var rearranged = strippedStr.slice(4) + strippedStr.slice(0, 4);
|
||||
var alphaCapsReplacedWithDigits = rearranged.replace(/[A-Z]/g, function (_char) {
|
||||
return _char.charCodeAt(0) - 55;
|
||||
});
|
||||
var remainder = alphaCapsReplacedWithDigits.match(/\d{1,7}/g).reduce(function (acc, value) {
|
||||
return Number(acc + value) % 97;
|
||||
}, '');
|
||||
return remainder === 1;
|
||||
}
|
||||
|
||||
export default function isIBAN(str) {
|
||||
assertString(str);
|
||||
return hasValidIbanFormat(str) && hasValidIbanChecksum(str);
|
||||
}
|
||||
export var locales = Object.keys(ibanRegexThroughCountryCode);
|
||||
Reference in New Issue
Block a user