new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
var createCaseFirst = require('./_createCaseFirst');
|
||||
|
||||
/**
|
||||
* Converts the first character of `string` to lower case.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to convert.
|
||||
* @returns {string} Returns the converted string.
|
||||
* @example
|
||||
*
|
||||
* _.lowerFirst('Fred');
|
||||
* // => 'fred'
|
||||
*
|
||||
* _.lowerFirst('FRED');
|
||||
* // => 'fRED'
|
||||
*/
|
||||
var lowerFirst = createCaseFirst('toLowerCase');
|
||||
|
||||
module.exports = lowerFirst;
|
||||
@@ -0,0 +1,18 @@
|
||||
esprima:
|
||||
|
||||
$ for i in {1..5}; do node detect.js; done
|
||||
704
|
||||
702
|
||||
704
|
||||
704
|
||||
697
|
||||
|
||||
acorn:
|
||||
|
||||
$ for i in {1..5}; do node detect.js; done
|
||||
555
|
||||
552
|
||||
585
|
||||
549
|
||||
583
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export type ImportRunner = {
|
||||
firstname: string;
|
||||
middlename?: string;
|
||||
lastname: string;
|
||||
team?: string;
|
||||
class?: string;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Observable } from '../Observable';
|
||||
/**
|
||||
* An Observable that emits no items to the Observer and never completes.
|
||||
*
|
||||
* 
|
||||
*
|
||||
* A simple Observable that emits neither values nor errors nor the completion
|
||||
* notification. It can be used for testing purposes or for composing with other
|
||||
* Observables. Please note that by never emitting a complete notification, this
|
||||
* Observable keeps the subscription from being disposed automatically.
|
||||
* Subscriptions need to be manually disposed.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* Emit the number 7, then never emit anything else (not even complete)
|
||||
*
|
||||
* ```ts
|
||||
* import { NEVER, startWith } from 'rxjs';
|
||||
*
|
||||
* const info = () => console.log('Will not be called');
|
||||
*
|
||||
* const result = NEVER.pipe(startWith(7));
|
||||
* result.subscribe({
|
||||
* next: x => console.log(x),
|
||||
* error: info,
|
||||
* complete: info
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @see {@link Observable}
|
||||
* @see {@link EMPTY}
|
||||
* @see {@link of}
|
||||
* @see {@link throwError}
|
||||
*/
|
||||
export declare const NEVER: Observable<never>;
|
||||
/**
|
||||
* @deprecated Replaced with the {@link NEVER} constant. Will be removed in v8.
|
||||
*/
|
||||
export declare function never(): Observable<never>;
|
||||
//# sourceMappingURL=never.d.ts.map
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "@octokit/types",
|
||||
"description": "Shared TypeScript definitions for Octokit projects",
|
||||
"version": "9.0.0",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"octokit": {
|
||||
"openapi-version": "10.0.0"
|
||||
},
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js",
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"github",
|
||||
"api",
|
||||
"sdk",
|
||||
"toolkit",
|
||||
"typescript"
|
||||
],
|
||||
"repository": "github:octokit/types.ts",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^16.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pika/pack": "^0.3.7",
|
||||
"@pika/plugin-build-node": "^0.9.0",
|
||||
"@pika/plugin-build-web": "^0.9.0",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.0",
|
||||
"@types/node": ">= 8",
|
||||
"github-openapi-graphql-query": "^3.0.0",
|
||||
"handlebars": "^4.7.6",
|
||||
"json-schema-to-typescript": "^11.0.0",
|
||||
"lodash.set": "^4.3.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"pascal-case": "^3.1.1",
|
||||
"pika-plugin-merge-properties": "^1.0.6",
|
||||
"prettier": "^2.0.0",
|
||||
"semantic-release": "^20.0.0",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"sort-keys": "^4.2.0",
|
||||
"string-to-jsdoc-comment": "^1.0.0",
|
||||
"typedoc": "^0.23.0",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -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:{"1":"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 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 EC FC","194":"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"},D:{"1":"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 CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB","66":"RB"},E:{"1":"3B 4B 5B sB 6B 7B 8B 9B 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"},F:{"1":"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":"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 PC QC RC SC qB AC TC rB","66":"EB FB"},G:{"1":"3B 4B 5B sB 6B 7B 8B 9B","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"},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:{"2":"A B"},O:{"1":"vC"},P:{"1":"g xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I wC"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"BD","194":"AD"}},B:2,C:"CSS Containment"};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { withAuthorizationPrefix } from "./with-authorization-prefix";
|
||||
export async function hook(token, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
||||
return request(endpoint);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
|
||||
var strCompare = require("../string/#/case-insensitive-compare")
|
||||
, isObject = require("./is-object")
|
||||
, isValue = require("./is-value")
|
||||
, numIsNaN = require("../number/is-nan")
|
||||
, resolve
|
||||
, typeMap;
|
||||
|
||||
typeMap = { undefined: 0, object: 1, boolean: 2, string: 3, number: 4 };
|
||||
|
||||
resolve = function (a) {
|
||||
if (isObject(a)) {
|
||||
if (typeof a.valueOf !== "function") return NaN;
|
||||
a = a.valueOf();
|
||||
if (isObject(a)) {
|
||||
if (typeof a.toString !== "function") return NaN;
|
||||
a = a.toString();
|
||||
if (typeof a !== "string") return NaN;
|
||||
}
|
||||
}
|
||||
return a;
|
||||
};
|
||||
|
||||
module.exports = function (val1, val2) {
|
||||
if (val1 === val2) return 0; // Same
|
||||
|
||||
val1 = resolve(val1);
|
||||
val2 = resolve(val2);
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (val1 == val2) return typeMap[typeof val1] - typeMap[typeof val2];
|
||||
if (!isValue(val1)) return -1;
|
||||
if (!isValue(val2)) return 1;
|
||||
if (typeof val1 === "string" || typeof val2 === "string") {
|
||||
return strCompare.call(val1, val2);
|
||||
}
|
||||
if (numIsNaN(val1) && numIsNaN(val2)) return 0; // Jslint: ignore
|
||||
return Number(val1) - Number(val2);
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var isNaN = require('../../helpers/isNaN');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-number-lessThan
|
||||
|
||||
module.exports = function NumberLessThan(x, y) {
|
||||
if (Type(x) !== 'Number' || Type(y) !== 'Number') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers');
|
||||
}
|
||||
|
||||
// If x is NaN, return undefined.
|
||||
// If y is NaN, return undefined.
|
||||
if (isNaN(x) || isNaN(y)) {
|
||||
return void undefined;
|
||||
}
|
||||
|
||||
// shortcut for the actual spec mechanics
|
||||
return x < y;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { ApiRequestOptions } from './ApiRequestOptions';
|
||||
import type { ApiResult } from './ApiResult';
|
||||
/**
|
||||
* Request using fetch client
|
||||
* @param options The request options from the the service
|
||||
* @result ApiResult
|
||||
* @throws ApiError
|
||||
*/
|
||||
export declare function request(options: ApiRequestOptions): Promise<ApiResult>;
|
||||
@@ -0,0 +1,54 @@
|
||||
let list = require('postcss').list
|
||||
|
||||
let flexSpec = require('./flex-spec')
|
||||
let Declaration = require('../declaration')
|
||||
|
||||
class Flex extends Declaration {
|
||||
/**
|
||||
* Change property name for 2009 spec
|
||||
*/
|
||||
prefixed(prop, prefix) {
|
||||
let spec
|
||||
;[spec, prefix] = flexSpec(prefix)
|
||||
if (spec === 2009) {
|
||||
return prefix + 'box-flex'
|
||||
}
|
||||
return super.prefixed(prop, prefix)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return property name by final spec
|
||||
*/
|
||||
normalize() {
|
||||
return 'flex'
|
||||
}
|
||||
|
||||
/**
|
||||
* Spec 2009 supports only first argument
|
||||
* Spec 2012 disallows unitless basis
|
||||
*/
|
||||
set(decl, prefix) {
|
||||
let spec = flexSpec(prefix)[0]
|
||||
if (spec === 2009) {
|
||||
decl.value = list.space(decl.value)[0]
|
||||
decl.value = Flex.oldValues[decl.value] || decl.value
|
||||
return super.set(decl, prefix)
|
||||
}
|
||||
if (spec === 2012) {
|
||||
let components = list.space(decl.value)
|
||||
if (components.length === 3 && components[2] === '0') {
|
||||
decl.value = components.slice(0, 2).concat('0px').join(' ')
|
||||
}
|
||||
}
|
||||
return super.set(decl, prefix)
|
||||
}
|
||||
}
|
||||
|
||||
Flex.names = ['flex', 'box-flex']
|
||||
|
||||
Flex.oldValues = {
|
||||
auto: '1',
|
||||
none: '0'
|
||||
}
|
||||
|
||||
module.exports = Flex
|
||||
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("chai").assert
|
||||
, ensureArrayLike = require("../../array-like/ensure");
|
||||
|
||||
describe("array-like/ensure", function () {
|
||||
it("Should return input value", function () {
|
||||
var value = [];
|
||||
assert.equal(ensureArrayLike(value), value);
|
||||
});
|
||||
it("Should allow strings with allowString option", function () {
|
||||
var value = "foo";
|
||||
assert.equal(ensureArrayLike(value, { allowString: true }), value);
|
||||
});
|
||||
it("Should crash on invalid value", function () {
|
||||
try {
|
||||
ensureArrayLike("foo");
|
||||
throw new Error("Unexpected");
|
||||
} catch (error) {
|
||||
assert.equal(error.name, "TypeError");
|
||||
assert(error.message.includes("is not an array like value"));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
TIMESTAMP,UPDATE,UID,BYTES SENT,BYTES RCVED
|
||||
1395426422,n,10028,1213,5461
|
||||
1395426422,n,10013,9954,13560
|
||||
1395426422,n,10109,221391500,141836
|
||||
1395426422,n,10007,53448,308549
|
||||
1395426422,n,10022,15506,72125
|
||||
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = ensureObject;
|
||||
|
||||
function ensureObject(obj) {
|
||||
for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
props[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
while (props.length > 0) {
|
||||
var prop = props.shift();
|
||||
|
||||
if (!obj[prop]) {
|
||||
obj[prop] = {};
|
||||
}
|
||||
|
||||
obj = obj[prop];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1,172 @@
|
||||
import { Subscription } from '../Subscription';
|
||||
import { EMPTY } from '../observable/empty';
|
||||
import { operate } from '../util/lift';
|
||||
import { MonoTypeOperatorFunction, ObservableInput } from '../types';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
import { innerFrom } from '../observable/innerFrom';
|
||||
import { timer } from '../observable/timer';
|
||||
|
||||
export interface RepeatConfig {
|
||||
/**
|
||||
* The number of times to repeat the source. Defaults to `Infinity`.
|
||||
*/
|
||||
count?: number;
|
||||
|
||||
/**
|
||||
* If a `number`, will delay the repeat of the source by that number of milliseconds.
|
||||
* If a function, it will provide the number of times the source has been subscribed to,
|
||||
* and the return value should be a valid observable input that will notify when the source
|
||||
* should be repeated. If the notifier observable is empty, the result will complete.
|
||||
*/
|
||||
delay?: number | ((count: number) => ObservableInput<any>);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Observable that will resubscribe to the source stream when the source stream completes.
|
||||
*
|
||||
* <span class="informal">Repeats all values emitted on the source. It's like {@link retry}, but for non error cases.</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* Repeat will output values from a source until the source completes, then it will resubscribe to the
|
||||
* source a specified number of times, with a specified delay. Repeat can be particularly useful in
|
||||
* combination with closing operators like {@link take}, {@link takeUntil}, {@link first}, or {@link takeWhile},
|
||||
* as it can be used to restart a source again from scratch.
|
||||
*
|
||||
* Repeat is very similar to {@link retry}, where {@link retry} will resubscribe to the source in the error case, but
|
||||
* `repeat` will resubscribe if the source completes.
|
||||
*
|
||||
* Note that `repeat` will _not_ catch errors. Use {@link retry} for that.
|
||||
*
|
||||
* - `repeat(0)` returns an empty observable
|
||||
* - `repeat()` will repeat forever
|
||||
* - `repeat({ delay: 200 })` will repeat forever, with a delay of 200ms between repetitions.
|
||||
* - `repeat({ count: 2, delay: 400 })` will repeat twice, with a delay of 400ms between repetitions.
|
||||
* - `repeat({ delay: (count) => timer(count * 1000) })` will repeat forever, but will have a delay that grows by one second for each repetition.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* Repeat a message stream
|
||||
*
|
||||
* ```ts
|
||||
* import { of, repeat } from 'rxjs';
|
||||
*
|
||||
* const source = of('Repeat message');
|
||||
* const result = source.pipe(repeat(3));
|
||||
*
|
||||
* result.subscribe(x => console.log(x));
|
||||
*
|
||||
* // Results
|
||||
* // 'Repeat message'
|
||||
* // 'Repeat message'
|
||||
* // 'Repeat message'
|
||||
* ```
|
||||
*
|
||||
* Repeat 3 values, 2 times
|
||||
*
|
||||
* ```ts
|
||||
* import { interval, take, repeat } from 'rxjs';
|
||||
*
|
||||
* const source = interval(1000);
|
||||
* const result = source.pipe(take(3), repeat(2));
|
||||
*
|
||||
* result.subscribe(x => console.log(x));
|
||||
*
|
||||
* // Results every second
|
||||
* // 0
|
||||
* // 1
|
||||
* // 2
|
||||
* // 0
|
||||
* // 1
|
||||
* // 2
|
||||
* ```
|
||||
*
|
||||
* Defining two complex repeats with delays on the same source.
|
||||
* Note that the second repeat cannot be called until the first
|
||||
* repeat as exhausted it's count.
|
||||
*
|
||||
* ```ts
|
||||
* import { defer, of, repeat } from 'rxjs';
|
||||
*
|
||||
* const source = defer(() => {
|
||||
* return of(`Hello, it is ${new Date()}`)
|
||||
* });
|
||||
*
|
||||
* source.pipe(
|
||||
* // Repeat 3 times with a delay of 1 second between repetitions
|
||||
* repeat({
|
||||
* count: 3,
|
||||
* delay: 1000,
|
||||
* }),
|
||||
*
|
||||
* // *Then* repeat forever, but with an exponential step-back
|
||||
* // maxing out at 1 minute.
|
||||
* repeat({
|
||||
* delay: (count) => timer(Math.min(60000, 2 ^ count * 1000))
|
||||
* })
|
||||
* )
|
||||
* ```
|
||||
*
|
||||
* @see {@link repeatWhen}
|
||||
* @see {@link retry}
|
||||
*
|
||||
* @param count The number of times the source Observable items are repeated, a count of 0 will yield
|
||||
* an empty Observable.
|
||||
*/
|
||||
export function repeat<T>(countOrConfig?: number | RepeatConfig): MonoTypeOperatorFunction<T> {
|
||||
let count = Infinity;
|
||||
let delay: RepeatConfig['delay'];
|
||||
|
||||
if (countOrConfig != null) {
|
||||
if (typeof countOrConfig === 'object') {
|
||||
({ count = Infinity, delay } = countOrConfig);
|
||||
} else {
|
||||
count = countOrConfig;
|
||||
}
|
||||
}
|
||||
|
||||
return count <= 0
|
||||
? () => EMPTY
|
||||
: operate((source, subscriber) => {
|
||||
let soFar = 0;
|
||||
let sourceSub: Subscription | null;
|
||||
|
||||
const resubscribe = () => {
|
||||
sourceSub?.unsubscribe();
|
||||
sourceSub = null;
|
||||
if (delay != null) {
|
||||
const notifier = typeof delay === 'number' ? timer(delay) : innerFrom(delay(soFar));
|
||||
const notifierSubscriber = createOperatorSubscriber(subscriber, () => {
|
||||
notifierSubscriber.unsubscribe();
|
||||
subscribeToSource();
|
||||
});
|
||||
notifier.subscribe(notifierSubscriber);
|
||||
} else {
|
||||
subscribeToSource();
|
||||
}
|
||||
};
|
||||
|
||||
const subscribeToSource = () => {
|
||||
let syncUnsub = false;
|
||||
sourceSub = source.subscribe(
|
||||
createOperatorSubscriber(subscriber, undefined, () => {
|
||||
if (++soFar < count) {
|
||||
if (sourceSub) {
|
||||
resubscribe();
|
||||
} else {
|
||||
syncUnsub = true;
|
||||
}
|
||||
} else {
|
||||
subscriber.complete();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
if (syncUnsub) {
|
||||
resubscribe();
|
||||
}
|
||||
};
|
||||
|
||||
subscribeToSource();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
var hasStrictMode = require('has-strict-mode')();
|
||||
|
||||
var global = Function('return this')(); // eslint-disable-line no-new-func
|
||||
var identity = function (x) { return x; };
|
||||
var arrayWrap = function (x) { return [x]; };
|
||||
|
||||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false.
|
||||
var undefinedIfNoSparseBug = canDistinguishSparseFromUndefined ? undefined : { valueOf: function () { return 0; } };
|
||||
|
||||
var createArrayLikeFromArray = function createArrayLike(arr) {
|
||||
var o = {};
|
||||
for (var i = 0; i < arr.length; i += 1) {
|
||||
if (i in arr) {
|
||||
o[i] = arr[i];
|
||||
}
|
||||
}
|
||||
o.length = arr.length;
|
||||
return o;
|
||||
};
|
||||
|
||||
var getTestArr = function () {
|
||||
var arr = [2, 3, undefinedIfNoSparseBug, true, 'hej', null, false, 0];
|
||||
delete arr[1];
|
||||
return arr;
|
||||
};
|
||||
|
||||
module.exports = function (map, t) {
|
||||
t.test('does not change the array it is called on', function (st) {
|
||||
var arr = getTestArr();
|
||||
var copy = getTestArr();
|
||||
map(arr, arrayWrap);
|
||||
st.deepEqual(arr, copy, 'array');
|
||||
|
||||
var arrayLike = createArrayLikeFromArray(arr);
|
||||
map(arrayLike, arrayWrap);
|
||||
st.deepEqual(arrayLike, createArrayLikeFromArray(copy), 'arrayLike');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('properly translates the values as according to the callback', function (st) {
|
||||
var expected = [[2], [3], [undefinedIfNoSparseBug], [true], ['hej'], [null], [false], [0]];
|
||||
delete expected[1];
|
||||
|
||||
var result = map(getTestArr(), arrayWrap);
|
||||
st.deepEqual(result, expected, 'array');
|
||||
|
||||
var arrayLikeResult = map(createArrayLikeFromArray(getTestArr()), arrayWrap);
|
||||
st.deepEqual(arrayLikeResult, expected, 'arrayLike');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('skips non-existing values', function (st) {
|
||||
var array = [1, 2, 3, 4];
|
||||
var arrayLike = createArrayLikeFromArray([1, 2, 3, 4]);
|
||||
delete array[2];
|
||||
delete arrayLike[2];
|
||||
|
||||
var i = 0;
|
||||
map(array, function () { i += 1; });
|
||||
st.equal(i, 3, 'array');
|
||||
|
||||
i = 0;
|
||||
map(arrayLike, function () { i += 1; });
|
||||
st.equal(i, 3, 'arrayLike');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('passes the correct values to the callback', function (st) {
|
||||
st.plan(5);
|
||||
|
||||
var expectedValue = {};
|
||||
var arr = [expectedValue];
|
||||
var context = {};
|
||||
map(
|
||||
arr,
|
||||
function (value, key, list) {
|
||||
st.equal(arguments.length, 3);
|
||||
st.equal(value, expectedValue, 'first argument is the value');
|
||||
st.equal(key, 0, 'second argument is the index');
|
||||
st.equal(list, arr, 'third argument is the array being iterated');
|
||||
st.equal(this, context, 'receiver is the expected value');
|
||||
},
|
||||
context
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not visit elements added to the array after it has begun', function (st) {
|
||||
st.plan(4);
|
||||
|
||||
var arr = [1, 2, 3];
|
||||
var i = 0;
|
||||
map(arr, function (a) {
|
||||
i += 1;
|
||||
arr.push(a + 3);
|
||||
});
|
||||
st.deepEqual(arr, [1, 2, 3, 4, 5, 6], 'array has received 3 new elements');
|
||||
st.equal(i, 3, 'map callback only called thrice');
|
||||
|
||||
var arrayLike = createArrayLikeFromArray([1, 2, 3]);
|
||||
i = 0;
|
||||
map(arrayLike, function (a) {
|
||||
i += 1;
|
||||
arrayLike[arrayLike.length] = a + 3;
|
||||
arrayLike.length += 1;
|
||||
});
|
||||
st.deepEqual(Array.prototype.slice.call(arrayLike), [1, 2, 3, 4, 5, 6], 'arrayLike has received 3 new elements');
|
||||
st.equal(i, 3, 'map callback only called thrice');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not visit elements deleted from the array after it has begun', function (st) {
|
||||
var arr = [1, 2, 3];
|
||||
var actual = [];
|
||||
map(arr, function (x, i) {
|
||||
actual.push([i, x]);
|
||||
delete arr[1];
|
||||
});
|
||||
st.deepEqual(actual, [[0, 1], [2, 3]]);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('sets the right context when given none', function (st) {
|
||||
var context;
|
||||
map([1], function () { context = this; });
|
||||
st.equal(context, global, 'receiver is global object in sloppy mode');
|
||||
|
||||
st.test('strict mode', { skip: !hasStrictMode }, function (sst) {
|
||||
map([1], function () {
|
||||
'use strict';
|
||||
|
||||
context = this;
|
||||
});
|
||||
sst.equal(context, undefined, 'receiver is undefined in strict mode');
|
||||
sst.end();
|
||||
});
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('empty array', function (st) {
|
||||
var arr = [];
|
||||
var actual = map(arr, identity);
|
||||
st.notEqual(actual, arr, 'empty array returns !== array');
|
||||
st.deepEqual(actual, arr, 'empty array returns empty array');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('list arg boxing', function (st) {
|
||||
st.plan(3);
|
||||
|
||||
map('f', function (item, index, list) {
|
||||
st.equal(item, 'f', 'letter matches');
|
||||
st.equal(typeof list, 'object', 'primitive list arg is boxed');
|
||||
st.equal(Object.prototype.toString.call(list), '[object String]', 'boxed list arg is a String');
|
||||
});
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('Symbol.species', { skip: typeof Symbol !== 'function' || typeof Symbol.species !== 'symbol' }, function (st) {
|
||||
var a = [1];
|
||||
var callCount = 0;
|
||||
var cb = function () {
|
||||
callCount += 1;
|
||||
};
|
||||
|
||||
a.constructor = {};
|
||||
a.constructor[Symbol.species] = parseInt;
|
||||
|
||||
st['throws'](
|
||||
function () { map(a, cb); },
|
||||
TypeError
|
||||
);
|
||||
st.equal(callCount, 0);
|
||||
|
||||
st.end();
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,109 @@
|
||||
declare const dotProp: {
|
||||
/**
|
||||
Get the value of the property at the given path.
|
||||
|
||||
@param object - Object to get the `path` value.
|
||||
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
|
||||
@param defaultValue - Default value.
|
||||
|
||||
@example
|
||||
```
|
||||
import dotProp = require('dot-prop');
|
||||
|
||||
dotProp.get({foo: {bar: 'unicorn'}}, 'foo.bar');
|
||||
//=> 'unicorn'
|
||||
|
||||
dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep');
|
||||
//=> undefined
|
||||
|
||||
dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value');
|
||||
//=> 'default value'
|
||||
|
||||
dotProp.get({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot');
|
||||
//=> 'unicorn'
|
||||
```
|
||||
*/
|
||||
get<T>(
|
||||
object: {[key: string]: any} | undefined,
|
||||
path: string
|
||||
): T | undefined;
|
||||
get<T>(
|
||||
object: {[key: string]: any} | undefined,
|
||||
path: string,
|
||||
defaultValue: T
|
||||
): T;
|
||||
|
||||
/**
|
||||
Set the property at the given path to the given value.
|
||||
|
||||
@param object - Object to set the `path` value.
|
||||
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
|
||||
@param value - Value to set at `path`.
|
||||
@returns The object.
|
||||
|
||||
@example
|
||||
```
|
||||
import dotProp = require('dot-prop');
|
||||
|
||||
const object = {foo: {bar: 'a'}};
|
||||
dotProp.set(object, 'foo.bar', 'b');
|
||||
console.log(object);
|
||||
//=> {foo: {bar: 'b'}}
|
||||
|
||||
const foo = dotProp.set({}, 'foo.bar', 'c');
|
||||
console.log(foo);
|
||||
//=> {foo: {bar: 'c'}}
|
||||
|
||||
dotProp.set(object, 'foo.baz', 'x');
|
||||
console.log(object);
|
||||
//=> {foo: {bar: 'b', baz: 'x'}}
|
||||
```
|
||||
*/
|
||||
set<T extends {[key: string]: any}>(
|
||||
object: T,
|
||||
path: string,
|
||||
value: unknown
|
||||
): T;
|
||||
|
||||
/**
|
||||
Check whether the property at the given path exists.
|
||||
|
||||
@param object - Object to test the `path` value.
|
||||
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
|
||||
|
||||
@example
|
||||
```
|
||||
import dotProp = require('dot-prop');
|
||||
|
||||
dotProp.has({foo: {bar: 'unicorn'}}, 'foo.bar');
|
||||
//=> true
|
||||
```
|
||||
*/
|
||||
has(object: {[key: string]: any} | undefined, path: string): boolean;
|
||||
|
||||
/**
|
||||
Delete the property at the given path.
|
||||
|
||||
@param object - Object to delete the `path` value.
|
||||
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
|
||||
@returns A boolean of whether the property existed before being deleted.
|
||||
|
||||
@example
|
||||
```
|
||||
import dotProp = require('dot-prop');
|
||||
|
||||
const object = {foo: {bar: 'a'}};
|
||||
dotProp.delete(object, 'foo.bar');
|
||||
console.log(object);
|
||||
//=> {foo: {}}
|
||||
|
||||
object.foo.bar = {x: 'y', y: 'x'};
|
||||
dotProp.delete(object, 'foo.bar.x');
|
||||
console.log(object);
|
||||
//=> {foo: {bar: {y: 'x'}}}
|
||||
```
|
||||
*/
|
||||
delete(object: {[key: string]: any}, path: string): boolean;
|
||||
};
|
||||
|
||||
export = dotProp;
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var isFunction = require("./is-function");
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!isFunction(value)) throw new TypeError(value + " is not a function");
|
||||
return value;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { AsyncSubject } from '../AsyncSubject';
|
||||
import { ConnectableObservable } from '../observable/ConnectableObservable';
|
||||
export function publishLast() {
|
||||
return function (source) {
|
||||
var subject = new AsyncSubject();
|
||||
return new ConnectableObservable(source, function () { return subject; });
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=publishLast.js.map
|
||||
@@ -0,0 +1,145 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const net_1 = __importDefault(require("net"));
|
||||
const tls_1 = __importDefault(require("tls"));
|
||||
const url_1 = __importDefault(require("url"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const once_1 = __importDefault(require("@tootallnate/once"));
|
||||
const agent_base_1 = require("agent-base");
|
||||
const debug = debug_1.default('http-proxy-agent');
|
||||
function isHTTPS(protocol) {
|
||||
return typeof protocol === 'string' ? /^https:?$/i.test(protocol) : false;
|
||||
}
|
||||
/**
|
||||
* The `HttpProxyAgent` implements an HTTP Agent subclass that connects
|
||||
* to the specified "HTTP proxy server" in order to proxy HTTP requests.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
class HttpProxyAgent extends agent_base_1.Agent {
|
||||
constructor(_opts) {
|
||||
let opts;
|
||||
if (typeof _opts === 'string') {
|
||||
opts = url_1.default.parse(_opts);
|
||||
}
|
||||
else {
|
||||
opts = _opts;
|
||||
}
|
||||
if (!opts) {
|
||||
throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
|
||||
}
|
||||
debug('Creating new HttpProxyAgent instance: %o', opts);
|
||||
super(opts);
|
||||
const proxy = Object.assign({}, opts);
|
||||
// If `true`, then connect to the proxy server over TLS.
|
||||
// Defaults to `false`.
|
||||
this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol);
|
||||
// Prefer `hostname` over `host`, and set the `port` if needed.
|
||||
proxy.host = proxy.hostname || proxy.host;
|
||||
if (typeof proxy.port === 'string') {
|
||||
proxy.port = parseInt(proxy.port, 10);
|
||||
}
|
||||
if (!proxy.port && proxy.host) {
|
||||
proxy.port = this.secureProxy ? 443 : 80;
|
||||
}
|
||||
if (proxy.host && proxy.path) {
|
||||
// If both a `host` and `path` are specified then it's most likely
|
||||
// the result of a `url.parse()` call... we need to remove the
|
||||
// `path` portion so that `net.connect()` doesn't attempt to open
|
||||
// that as a Unix socket file.
|
||||
delete proxy.path;
|
||||
delete proxy.pathname;
|
||||
}
|
||||
this.proxy = proxy;
|
||||
}
|
||||
/**
|
||||
* Called when the node-core HTTP client library is creating a
|
||||
* new HTTP request.
|
||||
*
|
||||
* @api protected
|
||||
*/
|
||||
callback(req, opts) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { proxy, secureProxy } = this;
|
||||
const parsed = url_1.default.parse(req.path);
|
||||
if (!parsed.protocol) {
|
||||
parsed.protocol = 'http:';
|
||||
}
|
||||
if (!parsed.hostname) {
|
||||
parsed.hostname = opts.hostname || opts.host || null;
|
||||
}
|
||||
if (parsed.port == null && typeof opts.port) {
|
||||
parsed.port = String(opts.port);
|
||||
}
|
||||
if (parsed.port === '80') {
|
||||
// if port is 80, then we can remove the port so that the
|
||||
// ":80" portion is not on the produced URL
|
||||
delete parsed.port;
|
||||
}
|
||||
// Change the `http.ClientRequest` instance's "path" field
|
||||
// to the absolute path of the URL that will be requested.
|
||||
req.path = url_1.default.format(parsed);
|
||||
// Inject the `Proxy-Authorization` header if necessary.
|
||||
if (proxy.auth) {
|
||||
req.setHeader('Proxy-Authorization', `Basic ${Buffer.from(proxy.auth).toString('base64')}`);
|
||||
}
|
||||
// Create a socket connection to the proxy server.
|
||||
let socket;
|
||||
if (secureProxy) {
|
||||
debug('Creating `tls.Socket`: %o', proxy);
|
||||
socket = tls_1.default.connect(proxy);
|
||||
}
|
||||
else {
|
||||
debug('Creating `net.Socket`: %o', proxy);
|
||||
socket = net_1.default.connect(proxy);
|
||||
}
|
||||
// At this point, the http ClientRequest's internal `_header` field
|
||||
// might have already been set. If this is the case then we'll need
|
||||
// to re-generate the string since we just changed the `req.path`.
|
||||
if (req._header) {
|
||||
let first;
|
||||
let endOfHeaders;
|
||||
debug('Regenerating stored HTTP header string for request');
|
||||
req._header = null;
|
||||
req._implicitHeader();
|
||||
if (req.output && req.output.length > 0) {
|
||||
// Node < 12
|
||||
debug('Patching connection write() output buffer with updated header');
|
||||
first = req.output[0];
|
||||
endOfHeaders = first.indexOf('\r\n\r\n') + 4;
|
||||
req.output[0] = req._header + first.substring(endOfHeaders);
|
||||
debug('Output buffer: %o', req.output);
|
||||
}
|
||||
else if (req.outputData && req.outputData.length > 0) {
|
||||
// Node >= 12
|
||||
debug('Patching connection write() output buffer with updated header');
|
||||
first = req.outputData[0].data;
|
||||
endOfHeaders = first.indexOf('\r\n\r\n') + 4;
|
||||
req.outputData[0].data =
|
||||
req._header + first.substring(endOfHeaders);
|
||||
debug('Output buffer: %o', req.outputData[0].data);
|
||||
}
|
||||
}
|
||||
// Wait for the socket's `connect` event, so that this `callback()`
|
||||
// function throws instead of the `http` request machinery. This is
|
||||
// important for i.e. `PacProxyAgent` which determines a failed proxy
|
||||
// connection via the `callback()` function throwing.
|
||||
yield once_1.default(socket, 'connect');
|
||||
return socket;
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = HttpProxyAgent;
|
||||
//# sourceMappingURL=agent.js.map
|
||||
@@ -0,0 +1,64 @@
|
||||
#through
|
||||
|
||||
[](http://travis-ci.org/dominictarr/through)
|
||||
[](https://ci.testling.com/dominictarr/through)
|
||||
|
||||
Easy way to create a `Stream` that is both `readable` and `writable`.
|
||||
|
||||
* Pass in optional `write` and `end` methods.
|
||||
* `through` takes care of pause/resume logic if you use `this.queue(data)` instead of `this.emit('data', data)`.
|
||||
* Use `this.pause()` and `this.resume()` to manage flow.
|
||||
* Check `this.paused` to see current flow state. (`write` always returns `!this.paused`).
|
||||
|
||||
This function is the basis for most of the synchronous streams in
|
||||
[event-stream](http://github.com/dominictarr/event-stream).
|
||||
|
||||
``` js
|
||||
var through = require('through')
|
||||
|
||||
through(function write(data) {
|
||||
this.queue(data) //data *must* not be null
|
||||
},
|
||||
function end () { //optional
|
||||
this.queue(null)
|
||||
})
|
||||
```
|
||||
|
||||
Or, can also be used _without_ buffering on pause, use `this.emit('data', data)`,
|
||||
and this.emit('end')
|
||||
|
||||
``` js
|
||||
var through = require('through')
|
||||
|
||||
through(function write(data) {
|
||||
this.emit('data', data)
|
||||
//this.pause()
|
||||
},
|
||||
function end () { //optional
|
||||
this.emit('end')
|
||||
})
|
||||
```
|
||||
|
||||
## Extended Options
|
||||
|
||||
You will probably not need these 99% of the time.
|
||||
|
||||
### autoDestroy=false
|
||||
|
||||
By default, `through` emits close when the writable
|
||||
and readable side of the stream has ended.
|
||||
If that is not desired, set `autoDestroy=false`.
|
||||
|
||||
``` js
|
||||
var through = require('through')
|
||||
|
||||
//like this
|
||||
var ts = through(write, end, {autoDestroy: false})
|
||||
//or like this
|
||||
var ts = through(write, end)
|
||||
ts.autoDestroy = false
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT / Apache2
|
||||
@@ -0,0 +1,112 @@
|
||||
'use strict';
|
||||
|
||||
exports.isInteger = num => {
|
||||
if (typeof num === 'number') {
|
||||
return Number.isInteger(num);
|
||||
}
|
||||
if (typeof num === 'string' && num.trim() !== '') {
|
||||
return Number.isInteger(Number(num));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find a node of the given type
|
||||
*/
|
||||
|
||||
exports.find = (node, type) => node.nodes.find(node => node.type === type);
|
||||
|
||||
/**
|
||||
* Find a node of the given type
|
||||
*/
|
||||
|
||||
exports.exceedsLimit = (min, max, step = 1, limit) => {
|
||||
if (limit === false) return false;
|
||||
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
||||
return ((Number(max) - Number(min)) / Number(step)) >= limit;
|
||||
};
|
||||
|
||||
/**
|
||||
* Escape the given node with '\\' before node.value
|
||||
*/
|
||||
|
||||
exports.escapeNode = (block, n = 0, type) => {
|
||||
let node = block.nodes[n];
|
||||
if (!node) return;
|
||||
|
||||
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
||||
if (node.escaped !== true) {
|
||||
node.value = '\\' + node.value;
|
||||
node.escaped = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given brace node should be enclosed in literal braces
|
||||
*/
|
||||
|
||||
exports.encloseBrace = node => {
|
||||
if (node.type !== 'brace') return false;
|
||||
if ((node.commas >> 0 + node.ranges >> 0) === 0) {
|
||||
node.invalid = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if a brace node is invalid.
|
||||
*/
|
||||
|
||||
exports.isInvalidBrace = block => {
|
||||
if (block.type !== 'brace') return false;
|
||||
if (block.invalid === true || block.dollar) return true;
|
||||
if ((block.commas >> 0 + block.ranges >> 0) === 0) {
|
||||
block.invalid = true;
|
||||
return true;
|
||||
}
|
||||
if (block.open !== true || block.close !== true) {
|
||||
block.invalid = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if a node is an open or close node
|
||||
*/
|
||||
|
||||
exports.isOpenOrClose = node => {
|
||||
if (node.type === 'open' || node.type === 'close') {
|
||||
return true;
|
||||
}
|
||||
return node.open === true || node.close === true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reduce an array of text nodes.
|
||||
*/
|
||||
|
||||
exports.reduce = nodes => nodes.reduce((acc, node) => {
|
||||
if (node.type === 'text') acc.push(node.value);
|
||||
if (node.type === 'range') node.type = 'text';
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Flatten an array
|
||||
*/
|
||||
|
||||
exports.flatten = (...args) => {
|
||||
const result = [];
|
||||
const flat = arr => {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
let ele = arr[i];
|
||||
Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
flat(args);
|
||||
return result;
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [ljharb]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/has-proto
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
@@ -0,0 +1,216 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var store = require('../store/index.js');
|
||||
var internal = require('../internal/index.js');
|
||||
var easing = require('../easing/index.js');
|
||||
|
||||
function is_date(obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object Date]';
|
||||
}
|
||||
|
||||
function tick_spring(ctx, last_value, current_value, target_value) {
|
||||
if (typeof current_value === 'number' || is_date(current_value)) {
|
||||
// @ts-ignore
|
||||
const delta = target_value - current_value;
|
||||
// @ts-ignore
|
||||
const velocity = (current_value - last_value) / (ctx.dt || 1 / 60); // guard div by 0
|
||||
const spring = ctx.opts.stiffness * delta;
|
||||
const damper = ctx.opts.damping * velocity;
|
||||
const acceleration = (spring - damper) * ctx.inv_mass;
|
||||
const d = (velocity + acceleration) * ctx.dt;
|
||||
if (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) {
|
||||
return target_value; // settled
|
||||
}
|
||||
else {
|
||||
ctx.settled = false; // signal loop to keep ticking
|
||||
// @ts-ignore
|
||||
return is_date(current_value) ?
|
||||
new Date(current_value.getTime() + d) : current_value + d;
|
||||
}
|
||||
}
|
||||
else if (Array.isArray(current_value)) {
|
||||
// @ts-ignore
|
||||
return current_value.map((_, i) => tick_spring(ctx, last_value[i], current_value[i], target_value[i]));
|
||||
}
|
||||
else if (typeof current_value === 'object') {
|
||||
const next_value = {};
|
||||
for (const k in current_value) {
|
||||
// @ts-ignore
|
||||
next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);
|
||||
}
|
||||
// @ts-ignore
|
||||
return next_value;
|
||||
}
|
||||
else {
|
||||
throw new Error(`Cannot spring ${typeof current_value} values`);
|
||||
}
|
||||
}
|
||||
function spring(value, opts = {}) {
|
||||
const store$1 = store.writable(value);
|
||||
const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;
|
||||
let last_time;
|
||||
let task;
|
||||
let current_token;
|
||||
let last_value = value;
|
||||
let target_value = value;
|
||||
let inv_mass = 1;
|
||||
let inv_mass_recovery_rate = 0;
|
||||
let cancel_task = false;
|
||||
function set(new_value, opts = {}) {
|
||||
target_value = new_value;
|
||||
const token = current_token = {};
|
||||
if (value == null || opts.hard || (spring.stiffness >= 1 && spring.damping >= 1)) {
|
||||
cancel_task = true; // cancel any running animation
|
||||
last_time = internal.now();
|
||||
last_value = new_value;
|
||||
store$1.set(value = target_value);
|
||||
return Promise.resolve();
|
||||
}
|
||||
else if (opts.soft) {
|
||||
const rate = opts.soft === true ? .5 : +opts.soft;
|
||||
inv_mass_recovery_rate = 1 / (rate * 60);
|
||||
inv_mass = 0; // infinite mass, unaffected by spring forces
|
||||
}
|
||||
if (!task) {
|
||||
last_time = internal.now();
|
||||
cancel_task = false;
|
||||
task = internal.loop(now => {
|
||||
if (cancel_task) {
|
||||
cancel_task = false;
|
||||
task = null;
|
||||
return false;
|
||||
}
|
||||
inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1);
|
||||
const ctx = {
|
||||
inv_mass,
|
||||
opts: spring,
|
||||
settled: true,
|
||||
dt: (now - last_time) * 60 / 1000
|
||||
};
|
||||
const next_value = tick_spring(ctx, last_value, value, target_value);
|
||||
last_time = now;
|
||||
last_value = value;
|
||||
store$1.set(value = next_value);
|
||||
if (ctx.settled) {
|
||||
task = null;
|
||||
}
|
||||
return !ctx.settled;
|
||||
});
|
||||
}
|
||||
return new Promise(fulfil => {
|
||||
task.promise.then(() => {
|
||||
if (token === current_token)
|
||||
fulfil();
|
||||
});
|
||||
});
|
||||
}
|
||||
const spring = {
|
||||
set,
|
||||
update: (fn, opts) => set(fn(target_value, value), opts),
|
||||
subscribe: store$1.subscribe,
|
||||
stiffness,
|
||||
damping,
|
||||
precision
|
||||
};
|
||||
return spring;
|
||||
}
|
||||
|
||||
function get_interpolator(a, b) {
|
||||
if (a === b || a !== a)
|
||||
return () => a;
|
||||
const type = typeof a;
|
||||
if (type !== typeof b || Array.isArray(a) !== Array.isArray(b)) {
|
||||
throw new Error('Cannot interpolate values of different type');
|
||||
}
|
||||
if (Array.isArray(a)) {
|
||||
const arr = b.map((bi, i) => {
|
||||
return get_interpolator(a[i], bi);
|
||||
});
|
||||
return t => arr.map(fn => fn(t));
|
||||
}
|
||||
if (type === 'object') {
|
||||
if (!a || !b)
|
||||
throw new Error('Object cannot be null');
|
||||
if (is_date(a) && is_date(b)) {
|
||||
a = a.getTime();
|
||||
b = b.getTime();
|
||||
const delta = b - a;
|
||||
return t => new Date(a + t * delta);
|
||||
}
|
||||
const keys = Object.keys(b);
|
||||
const interpolators = {};
|
||||
keys.forEach(key => {
|
||||
interpolators[key] = get_interpolator(a[key], b[key]);
|
||||
});
|
||||
return t => {
|
||||
const result = {};
|
||||
keys.forEach(key => {
|
||||
result[key] = interpolators[key](t);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
}
|
||||
if (type === 'number') {
|
||||
const delta = b - a;
|
||||
return t => a + t * delta;
|
||||
}
|
||||
throw new Error(`Cannot interpolate ${type} values`);
|
||||
}
|
||||
function tweened(value, defaults = {}) {
|
||||
const store$1 = store.writable(value);
|
||||
let task;
|
||||
let target_value = value;
|
||||
function set(new_value, opts) {
|
||||
if (value == null) {
|
||||
store$1.set(value = new_value);
|
||||
return Promise.resolve();
|
||||
}
|
||||
target_value = new_value;
|
||||
let previous_task = task;
|
||||
let started = false;
|
||||
let { delay = 0, duration = 400, easing: easing$1 = easing.linear, interpolate = get_interpolator } = internal.assign(internal.assign({}, defaults), opts);
|
||||
if (duration === 0) {
|
||||
if (previous_task) {
|
||||
previous_task.abort();
|
||||
previous_task = null;
|
||||
}
|
||||
store$1.set(value = target_value);
|
||||
return Promise.resolve();
|
||||
}
|
||||
const start = internal.now() + delay;
|
||||
let fn;
|
||||
task = internal.loop(now => {
|
||||
if (now < start)
|
||||
return true;
|
||||
if (!started) {
|
||||
fn = interpolate(value, new_value);
|
||||
if (typeof duration === 'function')
|
||||
duration = duration(value, new_value);
|
||||
started = true;
|
||||
}
|
||||
if (previous_task) {
|
||||
previous_task.abort();
|
||||
previous_task = null;
|
||||
}
|
||||
const elapsed = now - start;
|
||||
if (elapsed > duration) {
|
||||
store$1.set(value = new_value);
|
||||
return false;
|
||||
}
|
||||
// @ts-ignore
|
||||
store$1.set(value = fn(easing$1(elapsed / duration)));
|
||||
return true;
|
||||
});
|
||||
return task.promise;
|
||||
}
|
||||
return {
|
||||
set,
|
||||
update: (fn, opts) => set(fn(target_value, value), opts),
|
||||
subscribe: store$1.subscribe
|
||||
};
|
||||
}
|
||||
|
||||
exports.spring = spring;
|
||||
exports.tweened = tweened;
|
||||
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var isRegex = require('is-regex');
|
||||
|
||||
var $exec = callBound('RegExp.prototype.exec');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
module.exports = function regexTester(regex) {
|
||||
if (!isRegex(regex)) {
|
||||
throw new $TypeError('`regex` must be a RegExp');
|
||||
}
|
||||
return function test(s) {
|
||||
return $exec(regex, s) !== null;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,236 @@
|
||||
export interface CSPair { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
/**
|
||||
The ANSI terminal control sequence for starting this style.
|
||||
*/
|
||||
readonly open: string;
|
||||
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this style.
|
||||
*/
|
||||
readonly close: string;
|
||||
}
|
||||
|
||||
export interface ColorBase {
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this color.
|
||||
*/
|
||||
readonly close: string;
|
||||
|
||||
ansi(code: number): string;
|
||||
|
||||
ansi256(code: number): string;
|
||||
|
||||
ansi16m(red: number, green: number, blue: number): string;
|
||||
}
|
||||
|
||||
export interface Modifier {
|
||||
/**
|
||||
Resets the current color chain.
|
||||
*/
|
||||
readonly reset: CSPair;
|
||||
|
||||
/**
|
||||
Make text bold.
|
||||
*/
|
||||
readonly bold: CSPair;
|
||||
|
||||
/**
|
||||
Emitting only a small amount of light.
|
||||
*/
|
||||
readonly dim: CSPair;
|
||||
|
||||
/**
|
||||
Make text italic. (Not widely supported)
|
||||
*/
|
||||
readonly italic: CSPair;
|
||||
|
||||
/**
|
||||
Make text underline. (Not widely supported)
|
||||
*/
|
||||
readonly underline: CSPair;
|
||||
|
||||
/**
|
||||
Make text overline.
|
||||
|
||||
Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.
|
||||
*/
|
||||
readonly overline: CSPair;
|
||||
|
||||
/**
|
||||
Inverse background and foreground colors.
|
||||
*/
|
||||
readonly inverse: CSPair;
|
||||
|
||||
/**
|
||||
Prints the text, but makes it invisible.
|
||||
*/
|
||||
readonly hidden: CSPair;
|
||||
|
||||
/**
|
||||
Puts a horizontal line through the center of the text. (Not widely supported)
|
||||
*/
|
||||
readonly strikethrough: CSPair;
|
||||
}
|
||||
|
||||
export interface ForegroundColor {
|
||||
readonly black: CSPair;
|
||||
readonly red: CSPair;
|
||||
readonly green: CSPair;
|
||||
readonly yellow: CSPair;
|
||||
readonly blue: CSPair;
|
||||
readonly cyan: CSPair;
|
||||
readonly magenta: CSPair;
|
||||
readonly white: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly gray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly grey: CSPair;
|
||||
|
||||
readonly blackBright: CSPair;
|
||||
readonly redBright: CSPair;
|
||||
readonly greenBright: CSPair;
|
||||
readonly yellowBright: CSPair;
|
||||
readonly blueBright: CSPair;
|
||||
readonly cyanBright: CSPair;
|
||||
readonly magentaBright: CSPair;
|
||||
readonly whiteBright: CSPair;
|
||||
}
|
||||
|
||||
export interface BackgroundColor {
|
||||
readonly bgBlack: CSPair;
|
||||
readonly bgRed: CSPair;
|
||||
readonly bgGreen: CSPair;
|
||||
readonly bgYellow: CSPair;
|
||||
readonly bgBlue: CSPair;
|
||||
readonly bgCyan: CSPair;
|
||||
readonly bgMagenta: CSPair;
|
||||
readonly bgWhite: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGrey: CSPair;
|
||||
|
||||
readonly bgBlackBright: CSPair;
|
||||
readonly bgRedBright: CSPair;
|
||||
readonly bgGreenBright: CSPair;
|
||||
readonly bgYellowBright: CSPair;
|
||||
readonly bgBlueBright: CSPair;
|
||||
readonly bgCyanBright: CSPair;
|
||||
readonly bgMagentaBright: CSPair;
|
||||
readonly bgWhiteBright: CSPair;
|
||||
}
|
||||
|
||||
export interface ConvertColor {
|
||||
/**
|
||||
Convert from the RGB color space to the ANSI 256 color space.
|
||||
|
||||
@param red - (`0...255`)
|
||||
@param green - (`0...255`)
|
||||
@param blue - (`0...255`)
|
||||
*/
|
||||
rgbToAnsi256(red: number, green: number, blue: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the RGB color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToRgb(hex: string): [red: number, green: number, blue: number];
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the ANSI 256 color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToAnsi256(hex: string): number;
|
||||
|
||||
/**
|
||||
Convert from the ANSI 256 color space to the ANSI 16 color space.
|
||||
|
||||
@param code - A number representing the ANSI 256 color.
|
||||
*/
|
||||
ansi256ToAnsi(code: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB color space to the ANSI 16 color space.
|
||||
|
||||
@param red - (`0...255`)
|
||||
@param green - (`0...255`)
|
||||
@param blue - (`0...255`)
|
||||
*/
|
||||
rgbToAnsi(red: number, green: number, blue: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the ANSI 16 color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToAnsi(hex: string): number;
|
||||
}
|
||||
|
||||
/**
|
||||
Basic modifier names.
|
||||
*/
|
||||
export type ModifierName = keyof Modifier;
|
||||
|
||||
/**
|
||||
Basic foreground color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ForegroundColorName = keyof ForegroundColor;
|
||||
|
||||
/**
|
||||
Basic background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type BackgroundColorName = keyof BackgroundColor;
|
||||
|
||||
/**
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ColorName = ForegroundColorName | BackgroundColorName;
|
||||
|
||||
/**
|
||||
Basic modifier names.
|
||||
*/
|
||||
export const modifierNames: readonly ModifierName[];
|
||||
|
||||
/**
|
||||
Basic foreground color names.
|
||||
*/
|
||||
export const foregroundColorNames: readonly ForegroundColorName[];
|
||||
|
||||
/**
|
||||
Basic background color names.
|
||||
*/
|
||||
export const backgroundColorNames: readonly BackgroundColorName[];
|
||||
|
||||
/*
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
*/
|
||||
export const colorNames: readonly ColorName[];
|
||||
|
||||
declare const ansiStyles: {
|
||||
readonly modifier: Modifier;
|
||||
readonly color: ColorBase & ForegroundColor;
|
||||
readonly bgColor: ColorBase & BackgroundColor;
|
||||
readonly codes: ReadonlyMap<number, number>;
|
||||
} & ForegroundColor & BackgroundColor & Modifier & ConvertColor;
|
||||
|
||||
export default ansiStyles;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"F A B","2":"J D E CC"},B:{"1":"C K L G M N O","2":"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:{"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:{"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 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"},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:{"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 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 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:{"2":"tB I f pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"2":"A B C h qB AC rB"},L:{"2":"H"},M:{"2":"H"},N:{"1":"A B"},O:{"2":"vC"},P:{"2":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"2":"1B"},R:{"2":"9C"},S:{"2":"AD BD"}},B:6,C:"JPEG XR image format"};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { createErrorClass } from './createErrorClass';
|
||||
export const UnsubscriptionError = createErrorClass((_super) => function UnsubscriptionErrorImpl(errors) {
|
||||
_super(this);
|
||||
this.message = errors
|
||||
? `${errors.length} errors occurred during unsubscription:
|
||||
${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}`
|
||||
: '';
|
||||
this.name = 'UnsubscriptionError';
|
||||
this.errors = errors;
|
||||
});
|
||||
//# sourceMappingURL=UnsubscriptionError.js.map
|
||||
@@ -0,0 +1,97 @@
|
||||
import test from 'ava';
|
||||
import sinon from 'sinon';
|
||||
import Prompt from '../lib/prompt.js';
|
||||
import Config from '../lib/config.js';
|
||||
import git from '../lib/plugin/git/prompts.js';
|
||||
import github from '../lib/plugin/github/prompts.js';
|
||||
import gitlab from '../lib/plugin/gitlab/prompts.js';
|
||||
import npm from '../lib/plugin/npm/prompts.js';
|
||||
import { factory } from './util/index.js';
|
||||
|
||||
const prompts = { git, github, gitlab, npm };
|
||||
|
||||
const yes = ([options]) => Promise.resolve({ [options.name]: true });
|
||||
const no = ([options]) => Promise.resolve({ [options.name]: false });
|
||||
|
||||
test.beforeEach(t => {
|
||||
t.context.getInquirer = stub => ({
|
||||
prompt: stub
|
||||
});
|
||||
});
|
||||
|
||||
test('should not create prompt if disabled', async t => {
|
||||
const task = sinon.spy();
|
||||
const stub = sinon.stub().callsFake(yes);
|
||||
const inquirer = t.context.getInquirer(stub);
|
||||
const prompt = factory(Prompt, { container: { inquirer } });
|
||||
prompt.register(prompts.git);
|
||||
await prompt.show({ enabled: false, prompt: 'push', task });
|
||||
t.is(stub.callCount, 0);
|
||||
t.is(task.callCount, 0);
|
||||
});
|
||||
|
||||
test('should create prompt', async t => {
|
||||
const stub = sinon.stub().callsFake(yes);
|
||||
const inquirer = t.context.getInquirer(stub);
|
||||
const prompt = factory(Prompt, { container: { inquirer } });
|
||||
prompt.register(prompts.git);
|
||||
await prompt.show({ prompt: 'push' });
|
||||
t.is(stub.callCount, 1);
|
||||
t.deepEqual(stub.firstCall.args[0][0], {
|
||||
type: 'confirm',
|
||||
message: 'Push?',
|
||||
name: 'push',
|
||||
choices: false,
|
||||
transformer: false,
|
||||
default: true
|
||||
});
|
||||
});
|
||||
|
||||
[
|
||||
['git', 'commit', 'Commit (Release 1.0.0)?'],
|
||||
['git', 'tag', 'Tag (1.0.0)?'],
|
||||
['git', 'push', 'Push?'],
|
||||
['github', 'release', 'Create a pre-release on GitHub (Release 1.0.0)?'],
|
||||
['gitlab', 'release', 'Create a release on GitLab (Release 1.0.0)?'],
|
||||
['npm', 'publish', 'Publish my-pkg@next to npm?'],
|
||||
['npm', 'otp', 'Please enter OTP for npm:']
|
||||
].map(async ([namespace, prompt, message]) => {
|
||||
test(`should create prompt and render template message (${namespace}.${prompt})`, async t => {
|
||||
const stub = sinon.stub().callsFake(yes);
|
||||
const config = new Config({
|
||||
isPreRelease: true,
|
||||
git: { tagName: 'v${version}' },
|
||||
npm: { name: 'my-pkg', tag: 'next' }
|
||||
});
|
||||
config.setContext({ version: '1.0.0', tagName: '1.0.0' });
|
||||
const inquirer = t.context.getInquirer(stub);
|
||||
const p = factory(Prompt, { container: { inquirer } });
|
||||
p.register(prompts[namespace], namespace);
|
||||
await p.show({ namespace, prompt, context: config.getContext() });
|
||||
t.is(stub.callCount, 1);
|
||||
t.is(stub.firstCall.args[0][0].message, message);
|
||||
});
|
||||
});
|
||||
|
||||
test('should execute task after positive answer', async t => {
|
||||
const task = sinon.spy();
|
||||
const stub = sinon.stub().callsFake(yes);
|
||||
const inquirer = t.context.getInquirer(stub);
|
||||
const prompt = factory(Prompt, { container: { inquirer } });
|
||||
prompt.register(prompts.git);
|
||||
await prompt.show({ prompt: 'push', task });
|
||||
t.is(stub.callCount, 1);
|
||||
t.is(task.callCount, 1);
|
||||
t.is(task.firstCall.args[0], true);
|
||||
});
|
||||
|
||||
test('should not execute task after negative answer', async t => {
|
||||
const task = sinon.spy();
|
||||
const stub = sinon.stub().callsFake(no);
|
||||
const inquirer = t.context.getInquirer(stub);
|
||||
const prompt = factory(Prompt, { container: { inquirer } });
|
||||
prompt.register(prompts.git);
|
||||
await prompt.show({ prompt: 'push', task });
|
||||
t.is(stub.callCount, 1);
|
||||
t.is(task.callCount, 0);
|
||||
});
|
||||
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "run-parallel",
|
||||
"description": "Run an array of functions in parallel",
|
||||
"version": "1.2.0",
|
||||
"author": {
|
||||
"name": "Feross Aboukhadijeh",
|
||||
"email": "feross@feross.org",
|
||||
"url": "https://feross.org"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/feross/run-parallel/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"queue-microtask": "^1.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"airtap": "^3.0.0",
|
||||
"standard": "*",
|
||||
"tape": "^5.0.1"
|
||||
},
|
||||
"homepage": "https://github.com/feross/run-parallel",
|
||||
"keywords": [
|
||||
"parallel",
|
||||
"async",
|
||||
"function",
|
||||
"callback",
|
||||
"asynchronous",
|
||||
"run",
|
||||
"array",
|
||||
"run parallel"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/feross/run-parallel.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && npm run test-node && npm run test-browser",
|
||||
"test-browser": "airtap -- test/*.js",
|
||||
"test-browser-local": "airtap --local -- test/*.js",
|
||||
"test-node": "tape test/*.js"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
require('core-js');
|
||||
|
||||
require('./');
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Escape fieldname following the spec requirements.
|
||||
*
|
||||
* See: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data
|
||||
*
|
||||
* @param name A fieldname to escape
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
export declare const escapeName: (name: unknown) => string;
|
||||
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var ToNumber = require('./ToNumber');
|
||||
|
||||
// http://262.ecma-international.org/5.1/#sec-9.5
|
||||
|
||||
module.exports = function ToInt32(x) {
|
||||
return ToNumber(x) >> 0;
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { ApiResult } from './ApiResult';
|
||||
export declare class ApiError extends Error {
|
||||
readonly url: string;
|
||||
readonly status: number;
|
||||
readonly statusText: string;
|
||||
readonly body: any;
|
||||
constructor(response: ApiResult, message: string);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AsapScheduler.js","sourceRoot":"","sources":["../../../../src/internal/scheduler/AsapScheduler.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;IAAmC,iCAAc;IAAjD;;IAkCA,CAAC;IAjCQ,6BAAK,GAAZ,UAAa,MAAyB;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAUpB,IAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAEpB,IAAA,OAAO,GAAK,IAAI,QAAT,CAAU;QACzB,IAAI,KAAU,CAAC;QACf,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,KAAK,EAAG,CAAC;QAEpC,GAAG;YACD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;gBACxD,MAAM;aACP;SACF,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE;QAE5E,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QAErB,IAAI,KAAK,EAAE;YACT,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE;gBACxE,MAAM,CAAC,WAAW,EAAE,CAAC;aACtB;YACD,MAAM,KAAK,CAAC;SACb;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AAlCD,CAAmC,cAAc,GAkChD"}
|
||||
@@ -0,0 +1,37 @@
|
||||
declare function fastq<C, T = any, R = any>(context: C, worker: fastq.worker<C, T, R>, concurrency: number): fastq.queue<T, R>
|
||||
declare function fastq<C, T = any, R = any>(worker: fastq.worker<C, T, R>, concurrency: number): fastq.queue<T, R>
|
||||
|
||||
declare namespace fastq {
|
||||
type worker<C, T = any, R = any> = (this: C, task: T, cb: fastq.done<R>) => void
|
||||
type asyncWorker<C, T = any, R = any> = (this: C, task: T) => Promise<R>
|
||||
type done<R = any> = (err: Error | null, result?: R) => void
|
||||
type errorHandler<T = any> = (err: Error, task: T) => void
|
||||
|
||||
interface queue<T = any, R = any> {
|
||||
push(task: T, done?: done<R>): void
|
||||
unshift(task: T, done?: done<R>): void
|
||||
pause(): any
|
||||
resume(): any
|
||||
idle(): boolean
|
||||
length(): number
|
||||
getQueue(): T[]
|
||||
kill(): any
|
||||
killAndDrain(): any
|
||||
error(handler: errorHandler<T>): void
|
||||
concurrency: number
|
||||
drain(): any
|
||||
empty: () => void
|
||||
saturated: () => void
|
||||
}
|
||||
|
||||
interface queueAsPromised<T = any, R = any> extends queue<T, R> {
|
||||
push(task: T): Promise<R>
|
||||
unshift(task: T): Promise<R>
|
||||
drained(): Promise<void>
|
||||
}
|
||||
|
||||
function promise<C, T = any, R = any>(context: C, worker: fastq.asyncWorker<C, T, R>, concurrency: number): fastq.queueAsPromised<T, R>
|
||||
function promise<C, T = any, R = any>(worker: fastq.asyncWorker<C, T, R>, concurrency: number): fastq.queueAsPromised<T, R>
|
||||
}
|
||||
|
||||
export = fastq
|
||||
@@ -0,0 +1,22 @@
|
||||
var createMathOperation = require('./_createMathOperation');
|
||||
|
||||
/**
|
||||
* Adds two numbers.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.4.0
|
||||
* @category Math
|
||||
* @param {number} augend The first number in an addition.
|
||||
* @param {number} addend The second number in an addition.
|
||||
* @returns {number} Returns the total.
|
||||
* @example
|
||||
*
|
||||
* _.add(6, 4);
|
||||
* // => 10
|
||||
*/
|
||||
var add = createMathOperation(function(augend, addend) {
|
||||
return augend + addend;
|
||||
}, 0);
|
||||
|
||||
module.exports = add;
|
||||
@@ -0,0 +1,757 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
||||
var __assign = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, {get: all[name], enumerable: true});
|
||||
};
|
||||
var __exportStar = (target, module2, desc) => {
|
||||
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
||||
for (let key of __getOwnPropNames(module2))
|
||||
if (!__hasOwnProp.call(target, key) && key !== "default")
|
||||
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
||||
}
|
||||
return target;
|
||||
};
|
||||
var __toModule = (module2) => {
|
||||
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
||||
};
|
||||
|
||||
// src/index.ts
|
||||
__markAsModule(exports);
|
||||
__export(exports, {
|
||||
default: () => vitePluginSvelte
|
||||
});
|
||||
var path2 = __toModule(require("path"));
|
||||
var relative = __toModule(require("require-relative"));
|
||||
|
||||
// src/utils/log.ts
|
||||
var import_chalk = __toModule(require("chalk"));
|
||||
var import_debug = __toModule(require("debug"));
|
||||
var levels = ["debug", "info", "warn", "error", "silent"];
|
||||
var prefix = "vite-plugin-svelte";
|
||||
var loggers = {
|
||||
debug: {
|
||||
log: (0, import_debug.default)(`vite:${prefix}`),
|
||||
enabled: false,
|
||||
isDebug: true
|
||||
},
|
||||
info: {
|
||||
color: import_chalk.default.cyan,
|
||||
log: console.log,
|
||||
enabled: true
|
||||
},
|
||||
warn: {
|
||||
color: import_chalk.default.yellow,
|
||||
log: console.warn,
|
||||
enabled: true
|
||||
},
|
||||
error: {
|
||||
color: import_chalk.default.red,
|
||||
log: console.error,
|
||||
enabled: true
|
||||
},
|
||||
silent: {
|
||||
enabled: false
|
||||
}
|
||||
};
|
||||
var _level = "info";
|
||||
function setLevel(level) {
|
||||
if (level === _level) {
|
||||
return;
|
||||
}
|
||||
const levelIndex = levels.indexOf(level);
|
||||
if (levelIndex > -1) {
|
||||
_level = level;
|
||||
for (let i = 0; i < levels.length; i++) {
|
||||
loggers[levels[i]].enabled = i >= levelIndex;
|
||||
}
|
||||
} else {
|
||||
_log(loggers.error, `invalid log level: ${level} `);
|
||||
}
|
||||
}
|
||||
var _viteLogOverwriteProtection = false;
|
||||
function setViteLogOverwriteProtection(viteLogOverwriteProtection) {
|
||||
_viteLogOverwriteProtection = viteLogOverwriteProtection;
|
||||
}
|
||||
function _log(logger, message, payload) {
|
||||
if (!logger.enabled) {
|
||||
return;
|
||||
}
|
||||
if (logger.isDebug) {
|
||||
payload !== void 0 ? logger.log(message, payload) : logger.log(message);
|
||||
} else {
|
||||
logger.log(logger.color(`[${prefix}] ${message}`));
|
||||
if (payload) {
|
||||
logger.log(payload);
|
||||
}
|
||||
}
|
||||
if (_viteLogOverwriteProtection) {
|
||||
logger.log("");
|
||||
}
|
||||
}
|
||||
function createLogger(level) {
|
||||
const logger = loggers[level];
|
||||
const logFn = _log.bind(null, logger);
|
||||
Object.defineProperty(logFn, "enabled", {
|
||||
get() {
|
||||
return logger.enabled;
|
||||
}
|
||||
});
|
||||
return logFn;
|
||||
}
|
||||
var log = {
|
||||
debug: createLogger("debug"),
|
||||
info: createLogger("info"),
|
||||
warn: createLogger("warn"),
|
||||
error: createLogger("error"),
|
||||
setLevel,
|
||||
setViteLogOverwriteProtection
|
||||
};
|
||||
|
||||
// src/handleHotUpdate.ts
|
||||
async function handleHotUpdate(compileSvelte, ctx, svelteRequest, cache) {
|
||||
const {read, server} = ctx;
|
||||
const cachedCompileData = cache.getCompileData(svelteRequest, false);
|
||||
if (!cachedCompileData) {
|
||||
log.debug(`handleHotUpdate first call ${svelteRequest.id}`);
|
||||
return;
|
||||
}
|
||||
const content = await read();
|
||||
const compileData = await compileSvelte(svelteRequest, content, cachedCompileData.options);
|
||||
cache.setCompileData(compileData);
|
||||
const affectedModules = new Set();
|
||||
const cssModule = server.moduleGraph.getModuleById(svelteRequest.cssId);
|
||||
const mainModule = server.moduleGraph.getModuleById(svelteRequest.id);
|
||||
if (cssModule && cssChanged(cachedCompileData, compileData)) {
|
||||
log.debug("handleHotUpdate css changed");
|
||||
affectedModules.add(cssModule);
|
||||
}
|
||||
if (mainModule && jsChanged(cachedCompileData, compileData)) {
|
||||
log.debug("handleHotUpdate js changed");
|
||||
affectedModules.add(mainModule);
|
||||
}
|
||||
const result = [...affectedModules].filter(Boolean);
|
||||
log.debug(`handleHotUpdate result for ${svelteRequest.id}`, result);
|
||||
const ssrModulesToInvalidate = result.filter((m) => !!m.ssrTransformResult);
|
||||
if (ssrModulesToInvalidate.length > 0) {
|
||||
log.debug(`invalidating modules ${ssrModulesToInvalidate.map((m) => m.id).join(", ")}`);
|
||||
ssrModulesToInvalidate.forEach((moduleNode) => server.moduleGraph.invalidateModule(moduleNode));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function cssChanged(prev, next) {
|
||||
var _a, _b;
|
||||
return !isCodeEqual((_a = prev.compiled.css) == null ? void 0 : _a.code, (_b = next.compiled.css) == null ? void 0 : _b.code);
|
||||
}
|
||||
function jsChanged(prev, next) {
|
||||
const prevJs = prev.compiled.js.code;
|
||||
const nextJs = next.compiled.js.code;
|
||||
const isStrictEqual = isCodeEqual(prevJs, nextJs);
|
||||
if (isStrictEqual) {
|
||||
return false;
|
||||
}
|
||||
const isLooseEqual = isCodeEqual(normalizeJsCode(prevJs), normalizeJsCode(nextJs));
|
||||
if (!isStrictEqual && isLooseEqual) {
|
||||
log.warn(`ignoring compiler output js change for ${next.filename} as it is equal to previous output after normalization`);
|
||||
}
|
||||
return !isLooseEqual;
|
||||
}
|
||||
function isCodeEqual(prev, next) {
|
||||
if (!prev && !next) {
|
||||
return true;
|
||||
}
|
||||
if (!prev && next || prev && !next) {
|
||||
return false;
|
||||
}
|
||||
return prev === next;
|
||||
}
|
||||
function normalizeJsCode(code) {
|
||||
if (!code) {
|
||||
return code;
|
||||
}
|
||||
return code.replace(/\s*\badd_location\s*\([^)]*\)\s*;?/g, "");
|
||||
}
|
||||
|
||||
// src/utils/compile.ts
|
||||
var import_compiler = __toModule(require("svelte/compiler"));
|
||||
var import_svelte_hmr = __toModule(require("svelte-hmr"));
|
||||
|
||||
// src/utils/hash.ts
|
||||
var crypto = __toModule(require("crypto"));
|
||||
var hashes = Object.create(null);
|
||||
var hash_length = 12;
|
||||
function safeBase64Hash(input) {
|
||||
if (hashes[input]) {
|
||||
return hashes[input];
|
||||
}
|
||||
const md5 = crypto.createHash("md5");
|
||||
md5.update(input);
|
||||
const hash = toSafe(md5.digest("base64")).substr(0, hash_length);
|
||||
hashes[input] = hash;
|
||||
return hash;
|
||||
}
|
||||
var replacements = {
|
||||
"+": "-",
|
||||
"/": "_",
|
||||
"=": ""
|
||||
};
|
||||
var replaceRE = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
|
||||
function toSafe(base64) {
|
||||
return base64.replace(replaceRE, (x) => replacements[x]);
|
||||
}
|
||||
|
||||
// src/utils/preprocess.ts
|
||||
var supportedStyleLangs = ["css", "less", "sass", "scss", "styl", "stylus", "postcss"];
|
||||
var supportedScriptLangs = ["ts"];
|
||||
function createPreprocessorFromVitePlugin(config, options, pluginName, supportedLangs) {
|
||||
const plugin = config.plugins.find((p) => p.name === pluginName);
|
||||
if (!plugin) {
|
||||
throw new Error(`failed to find plugin ${pluginName}`);
|
||||
}
|
||||
if (!plugin.transform) {
|
||||
throw new Error(`plugin ${pluginName} has no transform`);
|
||||
}
|
||||
const pluginTransform = plugin.transform.bind(null);
|
||||
return async ({attributes, content, filename}) => {
|
||||
var _a, _b, _c, _d;
|
||||
const lang = attributes.lang;
|
||||
if (!supportedLangs.includes(lang)) {
|
||||
return {code: content};
|
||||
}
|
||||
const moduleId = `${filename}.${lang}`;
|
||||
const moduleGraph = (_a = options.server) == null ? void 0 : _a.moduleGraph;
|
||||
if (moduleGraph && !moduleGraph.getModuleById(moduleId)) {
|
||||
await moduleGraph.ensureEntryFromUrl(moduleId);
|
||||
}
|
||||
const transformResult = await pluginTransform(content, moduleId);
|
||||
const hasMap = !!((_b = transformResult.map) == null ? void 0 : _b.mappings);
|
||||
if (((_d = (_c = transformResult.map) == null ? void 0 : _c.sources) == null ? void 0 : _d[0]) === moduleId) {
|
||||
transformResult.map.sources[0] = filename;
|
||||
}
|
||||
return {
|
||||
code: transformResult.code,
|
||||
map: hasMap ? transformResult.map : null,
|
||||
dependencies: transformResult.deps
|
||||
};
|
||||
};
|
||||
}
|
||||
function createVitePreprocessorGroup(config, options) {
|
||||
return {
|
||||
script: createPreprocessorFromVitePlugin(config, options, "vite:esbuild", supportedScriptLangs),
|
||||
style: createPreprocessorFromVitePlugin(config, options, "vite:css", supportedStyleLangs)
|
||||
};
|
||||
}
|
||||
function createInjectScopeEverythingRulePreprocessorGroup() {
|
||||
return {
|
||||
style({content}) {
|
||||
return {
|
||||
code: `${content} *{}`
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
function buildExtraPreprocessors(options, config) {
|
||||
const extraPreprocessors = [];
|
||||
if (options.useVitePreprocess) {
|
||||
log.debug("adding vite preprocessor");
|
||||
extraPreprocessors.push(createVitePreprocessorGroup(config, options));
|
||||
}
|
||||
const pluginsWithPreprocessors = config.plugins.filter((p) => p == null ? void 0 : p.sveltePreprocess);
|
||||
if (pluginsWithPreprocessors.length > 0) {
|
||||
log.debug(`adding preprocessors from other vite plugins: ${pluginsWithPreprocessors.map((p) => p.name).join(", ")}`);
|
||||
extraPreprocessors.push(...pluginsWithPreprocessors.map((p) => p.sveltePreprocess));
|
||||
}
|
||||
if (options.hot && !options.disableCssHmr) {
|
||||
extraPreprocessors.push(createInjectScopeEverythingRulePreprocessorGroup());
|
||||
}
|
||||
return extraPreprocessors;
|
||||
}
|
||||
|
||||
// src/utils/compile.ts
|
||||
var _createCompileSvelte = (makeHot, extraPreprocessors) => async function compileSvelte(svelteRequest, code, options) {
|
||||
const {filename, normalizedFilename, cssId, ssr} = svelteRequest;
|
||||
const {onwarn, emitCss = true} = options;
|
||||
const dependencies = [];
|
||||
const finalCompilerOptions = __assign(__assign({}, options.compilerOptions), {
|
||||
filename,
|
||||
generate: ssr ? "ssr" : "dom",
|
||||
css: !emitCss,
|
||||
hydratable: true
|
||||
});
|
||||
if (options.hot) {
|
||||
const hash = `s-${safeBase64Hash(normalizedFilename)}`;
|
||||
log.debug(`setting cssHash ${hash} for ${normalizedFilename}`);
|
||||
finalCompilerOptions.cssHash = () => hash;
|
||||
}
|
||||
let preprocessed;
|
||||
const preprocessors = [];
|
||||
if (options.preprocess) {
|
||||
if (Array.isArray(options.preprocess)) {
|
||||
preprocessors.push(...options.preprocess);
|
||||
} else {
|
||||
preprocessors.push(options.preprocess);
|
||||
}
|
||||
}
|
||||
preprocessors.push(...extraPreprocessors || []);
|
||||
if (preprocessors.length > 0) {
|
||||
preprocessed = await (0, import_compiler.preprocess)(code, preprocessors, {filename});
|
||||
if (preprocessed.dependencies)
|
||||
dependencies.push(...preprocessed.dependencies);
|
||||
if (preprocessed.map)
|
||||
finalCompilerOptions.sourcemap = preprocessed.map;
|
||||
}
|
||||
const compiled = (0, import_compiler.compile)(preprocessed ? preprocessed.code : code, finalCompilerOptions);
|
||||
(compiled.warnings || []).forEach((warning) => {
|
||||
if (!emitCss && warning.code === "css-unused-selector")
|
||||
return;
|
||||
if (onwarn)
|
||||
onwarn(warning);
|
||||
});
|
||||
if (emitCss && compiled.css.code) {
|
||||
compiled.js.code += `
|
||||
import ${JSON.stringify(cssId)};
|
||||
`;
|
||||
}
|
||||
if (!ssr && makeHot) {
|
||||
compiled.js.code = makeHot({
|
||||
id: filename,
|
||||
compiledCode: compiled.js.code,
|
||||
hotOptions: options.hot,
|
||||
compiled,
|
||||
originalCode: code,
|
||||
compileOptions: finalCompilerOptions
|
||||
});
|
||||
}
|
||||
compiled.js.dependencies = dependencies;
|
||||
const result = {
|
||||
filename,
|
||||
normalizedFilename,
|
||||
cssId,
|
||||
code,
|
||||
preprocessed,
|
||||
compiled,
|
||||
compilerOptions: finalCompilerOptions,
|
||||
options,
|
||||
ssr
|
||||
};
|
||||
return result;
|
||||
};
|
||||
function buildMakeHot(options) {
|
||||
var _a, _b;
|
||||
const needsMakeHot = options.hot !== false && options.isServe && !options.isProduction;
|
||||
if (needsMakeHot) {
|
||||
const hotApi = (_a = options == null ? void 0 : options.hot) == null ? void 0 : _a.hotApi;
|
||||
const adapter = (_b = options == null ? void 0 : options.hot) == null ? void 0 : _b.adapter;
|
||||
return (0, import_svelte_hmr.createMakeHot)({
|
||||
walk: import_compiler.walk,
|
||||
hotApi,
|
||||
adapter,
|
||||
hotOptions: __assign({noOverlay: true}, options.hot)
|
||||
});
|
||||
}
|
||||
}
|
||||
function createCompileSvelte(options, config) {
|
||||
const makeHot = buildMakeHot(options);
|
||||
const extraPreprocessors = buildExtraPreprocessors(options, config);
|
||||
return _createCompileSvelte(makeHot, extraPreprocessors);
|
||||
}
|
||||
|
||||
// src/utils/id.ts
|
||||
var import_querystring = __toModule(require("querystring"));
|
||||
var import_pluginutils = __toModule(require("@rollup/pluginutils"));
|
||||
var import_vite = __toModule(require("vite"));
|
||||
var fs = __toModule(require("fs"));
|
||||
var VITE_FS_PREFIX = "/@fs/";
|
||||
var IS_WINDOWS = process.platform === "win32";
|
||||
function splitId(id) {
|
||||
const parts = id.split(`?`, 2);
|
||||
const filename = parts[0];
|
||||
const rawQuery = parts[1];
|
||||
return {filename, rawQuery};
|
||||
}
|
||||
function parseToSvelteRequest(id, filename, rawQuery, root, timestamp, ssr) {
|
||||
const query = import_querystring.default.parse(rawQuery);
|
||||
if (query.svelte != null) {
|
||||
query.svelte = true;
|
||||
}
|
||||
const normalizedFilename = normalize(filename, root);
|
||||
const cssId = createVirtualImportId(filename, root, "style");
|
||||
return {
|
||||
id,
|
||||
filename,
|
||||
normalizedFilename,
|
||||
cssId,
|
||||
query,
|
||||
timestamp,
|
||||
ssr
|
||||
};
|
||||
}
|
||||
function createVirtualImportId(filename, root, type) {
|
||||
const parts = ["svelte", `type=${type}`];
|
||||
if (type === "style") {
|
||||
parts.push("lang.css");
|
||||
}
|
||||
if (existsInRoot(filename, root)) {
|
||||
filename = root + filename;
|
||||
} else if (filename.startsWith(VITE_FS_PREFIX)) {
|
||||
filename = IS_WINDOWS ? filename.slice(VITE_FS_PREFIX.length) : filename.slice(VITE_FS_PREFIX.length - 1);
|
||||
}
|
||||
return `${filename}?${parts.join("&")}`;
|
||||
}
|
||||
function normalize(filename, normalizedRoot) {
|
||||
return stripRoot((0, import_vite.normalizePath)(filename), normalizedRoot);
|
||||
}
|
||||
function existsInRoot(filename, root) {
|
||||
if (filename.startsWith(VITE_FS_PREFIX)) {
|
||||
return false;
|
||||
}
|
||||
return fs.existsSync(root + filename);
|
||||
}
|
||||
function stripRoot(normalizedFilename, normalizedRoot) {
|
||||
return normalizedFilename.startsWith(normalizedRoot + "/") ? normalizedFilename.slice(normalizedRoot.length) : normalizedFilename;
|
||||
}
|
||||
function buildFilter(include, exclude, extensions) {
|
||||
const rollupFilter = (0, import_pluginutils.createFilter)(include, exclude);
|
||||
return (filename) => rollupFilter(filename) && extensions.some((ext) => filename.endsWith(ext));
|
||||
}
|
||||
function buildIdParser(options) {
|
||||
const {include, exclude, extensions, root} = options;
|
||||
const normalizedRoot = (0, import_vite.normalizePath)(root);
|
||||
const filter = buildFilter(include, exclude, extensions);
|
||||
return (id, ssr, timestamp = Date.now()) => {
|
||||
const {filename, rawQuery} = splitId(id);
|
||||
if (filter(filename)) {
|
||||
return parseToSvelteRequest(id, filename, rawQuery, normalizedRoot, timestamp, ssr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/utils/loadSvelteConfig.ts
|
||||
var import_path = __toModule(require("path"));
|
||||
var import_fs = __toModule(require("fs"));
|
||||
var knownSvelteConfigNames = ["svelte.config.js", "svelte.config.cjs"];
|
||||
function loadSvelteConfig(root = process.cwd()) {
|
||||
const foundConfigs = knownSvelteConfigNames.map((candidate) => import_path.default.resolve(root, candidate)).filter((file) => import_fs.default.existsSync(file));
|
||||
if (foundConfigs.length === 0) {
|
||||
log.debug(`no svelte config found at ${root}`);
|
||||
return;
|
||||
} else if (foundConfigs.length > 1) {
|
||||
log.warn(`found more than one svelte config file, using ${foundConfigs[0]}. you should only have one!`, foundConfigs);
|
||||
}
|
||||
try {
|
||||
const config = require(foundConfigs[0]);
|
||||
log.debug(`loaded svelte config ${foundConfigs[0]}`, config);
|
||||
return config;
|
||||
} catch (e) {
|
||||
log.error(`failed to load config ${foundConfigs[0]}`, e);
|
||||
}
|
||||
}
|
||||
|
||||
// src/utils/options.ts
|
||||
var knownOptions = new Set([
|
||||
"include",
|
||||
"exclude",
|
||||
"extensions",
|
||||
"emitCss",
|
||||
"compilerOptions",
|
||||
"preprocess",
|
||||
"hot",
|
||||
"disableTransformCache",
|
||||
"disableCssHmr",
|
||||
"useVitePreprocess"
|
||||
]);
|
||||
function buildDefaultOptions({isProduction}, options) {
|
||||
const disableCssHmr = !!(options == null ? void 0 : options.disableCssHmr);
|
||||
const emitCss = isProduction || !disableCssHmr;
|
||||
const hot = isProduction ? false : {
|
||||
injectCss: !emitCss
|
||||
};
|
||||
const defaultOptions = {
|
||||
extensions: [".svelte"],
|
||||
hot,
|
||||
emitCss,
|
||||
compilerOptions: {
|
||||
format: "esm",
|
||||
css: !emitCss,
|
||||
dev: !isProduction
|
||||
}
|
||||
};
|
||||
log.debug(`default options for ${isProduction ? "production" : "development"} ${!isProduction && disableCssHmr ? " with css hmr disabled" : ""}`, defaultOptions);
|
||||
return defaultOptions;
|
||||
}
|
||||
function validateInlineOptions(inlineOptions) {
|
||||
const invalidKeys = Object.keys(inlineOptions || {}).filter((key) => !knownOptions.has(key));
|
||||
if (invalidKeys.length) {
|
||||
log.warn(`invalid plugin options "${invalidKeys.join(", ")}" in config`, inlineOptions);
|
||||
}
|
||||
}
|
||||
function enforceOptionsForHmr(options) {
|
||||
if (options.hot) {
|
||||
if (!options.compilerOptions.dev) {
|
||||
log.warn("hmr is enabled but compilerOptions.dev is false, forcing it to true");
|
||||
options.compilerOptions.dev = true;
|
||||
}
|
||||
if (options.emitCss) {
|
||||
if (options.hot !== true && options.hot.injectCss) {
|
||||
log.warn("hmr and emitCss are enabled but hot.injectCss is true, forcing it to false");
|
||||
options.hot.injectCss = false;
|
||||
}
|
||||
if (options.compilerOptions.css) {
|
||||
log.warn("hmr and emitCss are enabled but compilerOptions.css is true, forcing it to false");
|
||||
options.compilerOptions.css = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function enforceOptionsForProduction(options) {
|
||||
if (options.isProduction) {
|
||||
if (options.hot) {
|
||||
log.warn("options.hot is enabled but does not work on production build, forcing it to false");
|
||||
options.hot = false;
|
||||
}
|
||||
if (!options.emitCss) {
|
||||
log.warn("you are building for production but emitCss is disabled. forcing it to true");
|
||||
options.emitCss = true;
|
||||
}
|
||||
if (options.compilerOptions.dev) {
|
||||
log.warn("you are building for production but compilerOptions.dev is true, forcing it to false");
|
||||
options.compilerOptions.dev = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
function mergeOptions(defaultOptions, svelteConfig, inlineOptions, viteConfig) {
|
||||
return __assign(__assign(__assign(__assign({}, defaultOptions), svelteConfig), inlineOptions), {
|
||||
compilerOptions: __assign(__assign(__assign({}, defaultOptions.compilerOptions), (svelteConfig == null ? void 0 : svelteConfig.compilerOptions) || {}), (inlineOptions == null ? void 0 : inlineOptions.compilerOptions) || {}),
|
||||
root: viteConfig.root,
|
||||
isProduction: viteConfig.isProduction,
|
||||
isBuild: viteConfig.command === "build",
|
||||
isServe: viteConfig.command === "serve"
|
||||
});
|
||||
}
|
||||
function resolveOptions(inlineOptions = {}, viteConfig) {
|
||||
const defaultOptions = buildDefaultOptions(viteConfig, inlineOptions);
|
||||
const svelteConfig = loadSvelteConfig(viteConfig.root) || {};
|
||||
const resolvedOptions = mergeOptions(defaultOptions, svelteConfig, inlineOptions, viteConfig);
|
||||
enforceOptionsForProduction(resolvedOptions);
|
||||
enforceOptionsForHmr(resolvedOptions);
|
||||
log.debug("resolved options", resolvedOptions);
|
||||
return resolvedOptions;
|
||||
}
|
||||
|
||||
// src/utils/VitePluginSvelteCache.ts
|
||||
var VitePluginSvelteCache = class {
|
||||
constructor() {
|
||||
this._compile = new Map();
|
||||
this._compileSSR = new Map();
|
||||
}
|
||||
selectCache(ssr) {
|
||||
return ssr ? this._compileSSR : this._compile;
|
||||
}
|
||||
getCompileData(svelteRequest, errorOnMissing = true) {
|
||||
const cache = this.selectCache(svelteRequest.ssr);
|
||||
const id = svelteRequest.normalizedFilename;
|
||||
if (cache.has(id)) {
|
||||
return cache.get(id);
|
||||
}
|
||||
if (errorOnMissing) {
|
||||
throw new Error(`${id} has no corresponding entry in the ${svelteRequest.ssr ? "ssr" : ""}cache. This is a @sveltejs/vite-plugin-svelte internal error, please open an issue.`);
|
||||
}
|
||||
}
|
||||
setCompileData(compileData) {
|
||||
const cache = this.selectCache(!!compileData.ssr);
|
||||
const id = compileData.normalizedFilename;
|
||||
cache.set(id, compileData);
|
||||
}
|
||||
};
|
||||
|
||||
// src/utils/constants.ts
|
||||
var VITE_RESOLVE_MAIN_FIELDS = ["module", "jsnext:main", "jsnext"];
|
||||
var SVELTE_RESOLVE_MAIN_FIELDS = ["svelte", ...VITE_RESOLVE_MAIN_FIELDS];
|
||||
var SVELTE_IMPORTS = [
|
||||
"svelte/animate",
|
||||
"svelte/easing",
|
||||
"svelte/internal",
|
||||
"svelte/motion",
|
||||
"svelte/store",
|
||||
"svelte/transition",
|
||||
"svelte",
|
||||
"svelte-hmr/runtime/hot-api-esm.js",
|
||||
"svelte-hmr/runtime/proxy-adapter-dom.js",
|
||||
"svelte-hmr"
|
||||
];
|
||||
|
||||
// src/index.ts
|
||||
var pkg_export_errors = new Set();
|
||||
function vitePluginSvelte(inlineOptions) {
|
||||
if (process.env.DEBUG != null) {
|
||||
log.setLevel("debug");
|
||||
}
|
||||
validateInlineOptions(inlineOptions);
|
||||
const cache = new VitePluginSvelteCache();
|
||||
let requestParser;
|
||||
let options;
|
||||
let compileSvelte;
|
||||
return {
|
||||
name: "vite-plugin-svelte",
|
||||
enforce: "pre",
|
||||
config(config) {
|
||||
if (process.env.DEBUG) {
|
||||
log.setLevel("debug");
|
||||
} else if (config.logLevel) {
|
||||
log.setLevel(config.logLevel);
|
||||
}
|
||||
const extraViteConfig = {
|
||||
optimizeDeps: {
|
||||
exclude: [...SVELTE_IMPORTS]
|
||||
},
|
||||
resolve: {
|
||||
mainFields: [...SVELTE_RESOLVE_MAIN_FIELDS],
|
||||
dedupe: [...SVELTE_IMPORTS]
|
||||
}
|
||||
};
|
||||
if (inlineOptions == null ? void 0 : inlineOptions.useVitePreprocess) {
|
||||
extraViteConfig.esbuild = {
|
||||
tsconfigRaw: {
|
||||
compilerOptions: {
|
||||
importsNotUsedAsValues: "preserve"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
log.debug("additional vite config", extraViteConfig);
|
||||
return extraViteConfig;
|
||||
},
|
||||
configResolved(config) {
|
||||
options = resolveOptions(inlineOptions, config);
|
||||
requestParser = buildIdParser(options);
|
||||
compileSvelte = createCompileSvelte(options, config);
|
||||
},
|
||||
configureServer(server) {
|
||||
options.server = server;
|
||||
},
|
||||
load(id, ssr) {
|
||||
var _a;
|
||||
const svelteRequest = requestParser(id, !!ssr);
|
||||
if (!svelteRequest) {
|
||||
return;
|
||||
}
|
||||
log.debug("load", svelteRequest);
|
||||
const {filename, query} = svelteRequest;
|
||||
if (query.svelte) {
|
||||
if (query.type === "style") {
|
||||
const compileData = cache.getCompileData(svelteRequest, false);
|
||||
if ((_a = compileData == null ? void 0 : compileData.compiled) == null ? void 0 : _a.css) {
|
||||
log.debug(`load returns css for ${filename}`);
|
||||
return compileData.compiled.css;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
async resolveId(importee, importer, customOptions, ssr) {
|
||||
const svelteRequest = requestParser(importee, !!ssr);
|
||||
log.debug("resolveId", svelteRequest || importee);
|
||||
if (svelteRequest == null ? void 0 : svelteRequest.query.svelte) {
|
||||
if (svelteRequest.query.type === "style") {
|
||||
log.debug(`resolveId resolved virtual css module ${svelteRequest.cssId}`);
|
||||
return svelteRequest.cssId;
|
||||
}
|
||||
log.debug(`resolveId resolved ${importee}`);
|
||||
return importee;
|
||||
}
|
||||
if (!importer || importee[0] === "." || importee[0] === "\0" || path2.isAbsolute(importee)) {
|
||||
return null;
|
||||
}
|
||||
const parts = importee.split("/");
|
||||
let dir, pkg, name = parts.shift();
|
||||
if (name && name[0] === "@") {
|
||||
name += `/${parts.shift()}`;
|
||||
}
|
||||
try {
|
||||
const file = `${name}/package.json`;
|
||||
const resolved = relative.resolve(file, path2.dirname(importer));
|
||||
dir = path2.dirname(resolved);
|
||||
pkg = require(resolved);
|
||||
} catch (err) {
|
||||
if (err.code === "MODULE_NOT_FOUND")
|
||||
return null;
|
||||
if (err.code === "ERR_PACKAGE_PATH_NOT_EXPORTED") {
|
||||
pkg_export_errors.add(name);
|
||||
return null;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
if (parts.length === 0 && pkg.svelte) {
|
||||
return path2.resolve(dir, pkg.svelte);
|
||||
}
|
||||
log.debug(`resolveId did not resolve ${importee}`);
|
||||
},
|
||||
async transform(code, id, ssr) {
|
||||
var _a;
|
||||
const svelteRequest = requestParser(id, !!ssr);
|
||||
if (!svelteRequest) {
|
||||
return;
|
||||
}
|
||||
log.debug("transform", svelteRequest);
|
||||
const {filename, query} = svelteRequest;
|
||||
const cachedCompileData = cache.getCompileData(svelteRequest, false);
|
||||
if (query.svelte) {
|
||||
if (query.type === "style" && ((_a = cachedCompileData == null ? void 0 : cachedCompileData.compiled) == null ? void 0 : _a.css)) {
|
||||
log.debug(`transform returns css for ${filename}`);
|
||||
return cachedCompileData.compiled.css;
|
||||
}
|
||||
log.error("failed to transform tagged svelte request", svelteRequest);
|
||||
throw new Error(`failed to transform tagged svelte request for id ${id}`);
|
||||
}
|
||||
if (cachedCompileData && !options.disableTransformCache) {
|
||||
log.debug(`transform returns cached js for ${filename}`);
|
||||
return cachedCompileData.compiled.js;
|
||||
}
|
||||
const compileData = await compileSvelte(svelteRequest, code, options);
|
||||
cache.setCompileData(compileData);
|
||||
log.debug(`transform returns compiled js for ${filename}`);
|
||||
return compileData.compiled.js;
|
||||
},
|
||||
handleHotUpdate(ctx) {
|
||||
if (!options.emitCss || options.disableCssHmr) {
|
||||
return;
|
||||
}
|
||||
const svelteRequest = requestParser(ctx.file, false, ctx.timestamp);
|
||||
if (!svelteRequest) {
|
||||
return;
|
||||
}
|
||||
log.debug("handleHotUpdate", svelteRequest);
|
||||
return handleHotUpdate(compileSvelte, ctx, svelteRequest, cache);
|
||||
},
|
||||
transformIndexHtml(html, ctx) {
|
||||
log.debug("transformIndexHtml", html);
|
||||
},
|
||||
buildEnd() {
|
||||
if (pkg_export_errors.size > 0) {
|
||||
log.warn(`The following packages did not export their \`package.json\` file so we could not check the "svelte" field.If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.`, Array.from(pkg_export_errors, (s) => `- ${s}`).join("\n"));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
module.exports = vitePluginSvelte;
|
||||
vitePluginSvelte["default"] = vitePluginSvelte;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {});
|
||||
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
var test = function (arg1, arg2) { return arg2; };
|
||||
|
||||
try {
|
||||
Object.defineProperty(test, "length", {
|
||||
configurable: true,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
value: 1
|
||||
});
|
||||
}
|
||||
catch (ignore) {}
|
||||
|
||||
if (test.length === 1) {
|
||||
// ES2015+
|
||||
var desc = { configurable: true, writable: false, enumerable: false };
|
||||
module.exports = function (length, fn) {
|
||||
if (fn.length === length) return fn;
|
||||
desc.value = length;
|
||||
return Object.defineProperty(fn, "length", desc);
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
module.exports = function (length, fn) {
|
||||
if (fn.length === length) return fn;
|
||||
switch (length) {
|
||||
case 0:
|
||||
return function () { return fn.apply(this, arguments); };
|
||||
case 1:
|
||||
return function (ignored1) { return fn.apply(this, arguments); };
|
||||
case 2:
|
||||
return function (ignored1, ignored2) { return fn.apply(this, arguments); };
|
||||
case 3:
|
||||
return function (ignored1, ignored2, ignored3) { return fn.apply(this, arguments); };
|
||||
case 4:
|
||||
return function (ignored1, ignored2, ignored3, ignored4) {
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
case 5:
|
||||
return function (ignored1, ignored2, ignored3, ignored4, ignored5) {
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
case 6:
|
||||
return function (ignored1, ignored2, ignored3, ignored4, ignored5, ignored6) {
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
case 7:
|
||||
return function (ignored1, ignored2, ignored3, ignored4, ignored5, ignored6, ignored7) {
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
default:
|
||||
throw new Error("Usupported function length");
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
import type {JsonPrimitive, JsonValue} from './basic';
|
||||
import {Finite, NegativeInfinity, PositiveInfinity} from './numeric';
|
||||
import {TypedArray} from './typed-array';
|
||||
|
||||
// Note: The return value has to be `any` and not `unknown` so it can match `void`.
|
||||
type NotJsonable = ((...args: any[]) => any) | undefined | symbol;
|
||||
|
||||
/**
|
||||
Transform a type to one that is assignable to the `JsonValue` type.
|
||||
|
||||
This includes:
|
||||
1. Transforming JSON `interface` to a `type` that is assignable to `JsonValue`.
|
||||
2. Transforming non-JSON value that is *jsonable* to a type that is assignable to `JsonValue`, where *jsonable* means the non-JSON value implements the `.toJSON()` method that returns a value that is assignable to `JsonValue`.
|
||||
|
||||
@remarks
|
||||
|
||||
An interface cannot be structurally compared to `JsonValue` because an interface can be re-opened to add properties that may not be satisfy `JsonValue`.
|
||||
|
||||
@example
|
||||
```
|
||||
import type {Jsonify} from 'type-fest';
|
||||
|
||||
interface Geometry {
|
||||
type: 'Point' | 'Polygon';
|
||||
coordinates: [number, number];
|
||||
}
|
||||
|
||||
const point: Geometry = {
|
||||
type: 'Point',
|
||||
coordinates: [1, 1]
|
||||
};
|
||||
|
||||
const problemFn = (data: JsonValue) => {
|
||||
// Does something with data
|
||||
};
|
||||
|
||||
problemFn(point); // Error: type Geometry is not assignable to parameter of type JsonValue because it is an interface
|
||||
|
||||
const fixedFn = <T>(data: Jsonify<T>) => {
|
||||
// Does something with data
|
||||
};
|
||||
|
||||
fixedFn(point); // Good: point is assignable. Jsonify<T> transforms Geometry into value assignable to JsonValue
|
||||
fixedFn(new Date()); // Error: As expected, Date is not assignable. Jsonify<T> cannot transforms Date into value assignable to JsonValue
|
||||
```
|
||||
|
||||
Non-JSON values such as `Date` implement `.toJSON()`, so they can be transformed to a value assignable to `JsonValue`:
|
||||
|
||||
@example
|
||||
```
|
||||
import type {Jsonify} from 'type-fest';
|
||||
|
||||
const time = {
|
||||
timeValue: new Date()
|
||||
};
|
||||
|
||||
// `Jsonify<typeof time>` is equivalent to `{timeValue: string}`
|
||||
const timeJson = JSON.parse(JSON.stringify(time)) as Jsonify<typeof time>;
|
||||
```
|
||||
|
||||
@link https://github.com/Microsoft/TypeScript/issues/1897#issuecomment-710744173
|
||||
|
||||
@category JSON
|
||||
*/
|
||||
type Jsonify<T> =
|
||||
// Check if there are any non-JSONable types represented in the union.
|
||||
// Note: The use of tuples in this first condition side-steps distributive conditional types
|
||||
// (see https://github.com/microsoft/TypeScript/issues/29368#issuecomment-453529532)
|
||||
[Extract<T, NotJsonable | bigint>] extends [never]
|
||||
? T extends PositiveInfinity | NegativeInfinity ? null
|
||||
: T extends JsonPrimitive ? T // Primitive is acceptable
|
||||
: T extends object
|
||||
// Any object with toJSON is special case
|
||||
? T extends {toJSON(): infer J} ? (() => J) extends (() => JsonValue) // Is J assignable to JsonValue?
|
||||
? J // Then T is Jsonable and its Jsonable value is J
|
||||
: never // Not Jsonable because its toJSON() method does not return JsonValue
|
||||
// Instanced primitives are objects
|
||||
: T extends Number ? number
|
||||
: T extends String ? string
|
||||
: T extends Boolean ? boolean
|
||||
: T extends Map<any, any> | Set<any> ? {}
|
||||
: T extends TypedArray ? Record<string, number>
|
||||
: T extends any[]
|
||||
? {[I in keyof T]: T[I] extends NotJsonable ? null : Jsonify<T[I]>}
|
||||
: {[P in keyof T as P extends symbol ? never
|
||||
: T[P] extends NotJsonable ? never
|
||||
: P
|
||||
]: Jsonify<Required<T>[P]>} // Recursive call for its children
|
||||
: never // Otherwise any other non-object is removed
|
||||
: never; // Otherwise non-JSONable type union was found not empty
|
||||
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-isarray
|
||||
module.exports = require('../helpers/IsArray');
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(Promise.prototype, "finally", {
|
||||
value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.00494,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0.01483,"103":0,"104":0,"105":0,"106":0,"107":0,"108":0.02472,"109":0.68227,"110":0.53395,"111":0,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0.00494,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0.01483,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0.00494,"77":0,"78":0,"79":0.00989,"80":0,"81":0,"83":0.00494,"84":0,"85":0.01483,"86":0,"87":0.00989,"88":0,"89":0,"90":0,"91":0,"92":0.03461,"93":0.05438,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0.00494,"100":0.00494,"101":0,"102":0.00494,"103":0.05933,"104":0.00494,"105":0.06922,"106":0.01483,"107":0.09888,"108":0.85037,"109":7.73242,"110":4.50398,"111":0.00494,"112":0,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.00989,"94":0.3708,"95":0.1681,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0.00494,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0.00494,"101":0.00494,"102":0,"103":0.00494,"104":0,"105":0,"106":0.00989,"107":0.01978,"108":0.09888,"109":1.6859,"110":1.94299},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.02472,"14":0.03955,"15":0.04944,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0.07416,"13.1":0.17304,"14.1":0.18787,"15.1":0.11371,"15.2-15.3":0.00989,"15.4":0.01978,"15.5":0.10877,"15.6":0.99374,"16.0":0.0791,"16.1":0.30158,"16.2":1.27061,"16.3":0.80587,"16.4":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0,"8.1-8.4":0,"9.0-9.2":0,"9.3":0.00807,"10.0-10.2":0,"10.3":0.0605,"11.0-11.2":0.00403,"11.3-11.4":0.01613,"12.0-12.1":0,"12.2-12.5":0.45171,"13.0-13.1":0,"13.2":0.0121,"13.3":0.0726,"13.4-13.7":0.10486,"14.0-14.4":0.12099,"14.5-14.8":0.41541,"15.0-15.1":0.10889,"15.2-15.3":0.17746,"15.4":0.14923,"15.5":0.52028,"15.6":4.21061,"16.0":3.30718,"16.1":8.7842,"16.2":12.59149,"16.3":6.95718,"16.4":0.10889},P:{"4":0.10355,"20":1.62575,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.60059,"8.2":0,"9.2":0,"10.1":0,"11.1-11.2":0.0932,"12.0":0,"13.0":0,"14.0":0.01036,"15.0":0,"16.0":0.06213,"17.0":0.0932,"18.0":0.07249,"19.0":2.72339},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.11031,"4.4":0,"4.4.3-4.4.4":0.08273},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.00989,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.07584},H:{"0":0.01436},L:{"0":29.57643},R:{_:"0"},M:{"0":0.11629},Q:{"13.1":0}};
|
||||
@@ -0,0 +1,59 @@
|
||||
import type { CreateUserGroup } from '../models/CreateUserGroup';
|
||||
import type { ResponseEmpty } from '../models/ResponseEmpty';
|
||||
import type { ResponseUserGroup } from '../models/ResponseUserGroup';
|
||||
import type { ResponseUserGroupPermissions } from '../models/ResponseUserGroupPermissions';
|
||||
import type { UpdateUserGroup } from '../models/UpdateUserGroup';
|
||||
import type { UserGroup } from '../models/UserGroup';
|
||||
import type { UserGroupNotFoundError } from '../models/UserGroupNotFoundError';
|
||||
export declare class UserGroupService {
|
||||
/**
|
||||
* Get all
|
||||
* Lists all groups. <br> The information provided might change while the project continues to evolve.
|
||||
* @result ResponseUserGroup
|
||||
* @throws ApiError
|
||||
*/
|
||||
static userGroupControllerGetAll(): Promise<Array<ResponseUserGroup>>;
|
||||
/**
|
||||
* Post
|
||||
* Create a new group. <br> If you want to grant permissions to the group you have to create them seperately by posting to /api/permissions after creating the group.
|
||||
* @param requestBody CreateUserGroup
|
||||
* @result any
|
||||
* @throws ApiError
|
||||
*/
|
||||
static userGroupControllerPost(requestBody?: CreateUserGroup): Promise<(UserGroup | UserGroupNotFoundError)>;
|
||||
/**
|
||||
* Get one
|
||||
* Lists all information about the group whose id got provided. <br> The information provided might change while the project continues to evolve.
|
||||
* @param id
|
||||
* @result ResponseUserGroup
|
||||
* @throws ApiError
|
||||
*/
|
||||
static userGroupControllerGetOne(id: number): Promise<ResponseUserGroup>;
|
||||
/**
|
||||
* Put
|
||||
* Update the group whose id you provided. <br> To change the permissions granted to the group please use /api/permissions instead. <br> Please remember that ids can't be changed.
|
||||
* @param id
|
||||
* @param requestBody UpdateUserGroup
|
||||
* @result UserGroup
|
||||
* @throws ApiError
|
||||
*/
|
||||
static userGroupControllerPut(id: number, requestBody?: UpdateUserGroup): Promise<UserGroup>;
|
||||
/**
|
||||
* Remove
|
||||
* Delete the group whose id you provided. <br> If there are any permissions directly granted to the group they will get deleted as well. <br> Users associated with this group won't get deleted - just deassociated. <br> If no group with this id exists it will just return 204(no content).
|
||||
* @param id
|
||||
* @param force
|
||||
* @result ResponseUserGroup
|
||||
* @result ResponseEmpty
|
||||
* @throws ApiError
|
||||
*/
|
||||
static userGroupControllerRemove(id: number, force?: boolean): Promise<ResponseUserGroup | ResponseEmpty>;
|
||||
/**
|
||||
* Get permissions
|
||||
* Lists all permissions granted to the group as permission response objects.
|
||||
* @param id
|
||||
* @result ResponseUserGroupPermissions
|
||||
* @throws ApiError
|
||||
*/
|
||||
static userGroupControllerGetPermissions(id: number): Promise<ResponseUserGroupPermissions>;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { FileSystemAdapter, StatAsynchronousMethod, StatSynchronousMethod } from './adapters/fs';
|
||||
import * as async from './providers/async';
|
||||
import Settings, { Options } from './settings';
|
||||
import type { Stats } from './types';
|
||||
declare type AsyncCallback = async.AsyncCallback;
|
||||
declare function stat(path: string, callback: AsyncCallback): void;
|
||||
declare function stat(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
|
||||
declare namespace stat {
|
||||
function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Stats>;
|
||||
}
|
||||
declare function statSync(path: string, optionsOrSettings?: Options | Settings): Stats;
|
||||
export { Settings, stat, statSync, AsyncCallback, FileSystemAdapter, StatAsynchronousMethod, StatSynchronousMethod, Options, Stats };
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { Config, ResolvableTo } from './types/config'
|
||||
|
||||
type UnwrapResolvables<T> = {
|
||||
[K in keyof T]: T[K] extends ResolvableTo<infer R> ? R : T[K]
|
||||
}
|
||||
|
||||
type ResolvedConfig<T extends Config> = Omit<T, 'theme'> & {
|
||||
theme: UnwrapResolvables<T['theme']>
|
||||
}
|
||||
|
||||
declare function resolveConfig<T extends Config>(config: T): ResolvedConfig<T>
|
||||
export = resolveConfig
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"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","2":"C K"},C:{"1":"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","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 EC FC","1025":"FB","1218":"AB BB CB DB EB"},D:{"1":"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 CB DB EB FB","260":"GB","772":"HB"},E:{"1":"B C K L G 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J D E F A HC zB IC JC KC LC"},F:{"1":"5 6 7 8 9 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":"0 1 2 F B C G M N O w g x y z PC QC RC SC qB AC TC rB","260":"3","772":"4"},G:{"1":"cC dC eC fC gC 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 aC bC"},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:{"2":"A B"},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":"AD BD"}},B:1,C:"Fetch"};
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UserAction = void 0;
|
||||
var UserAction;
|
||||
(function (UserAction) {
|
||||
let action;
|
||||
(function (action) {
|
||||
action["GET"] = "GET";
|
||||
action["CREATE"] = "CREATE";
|
||||
action["UPDATE"] = "UPDATE";
|
||||
action["DELETE"] = "DELETE";
|
||||
action["IMPORT"] = "IMPORT";
|
||||
})(action = UserAction.action || (UserAction.action = {}));
|
||||
})(UserAction = exports.UserAction || (exports.UserAction = {}));
|
||||
Reference in New Issue
Block a user