websocket-ts 2.1.4 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +212 -211
- package/dist/cjs/src/backoff/constantbackoff.js.map +1 -1
- package/dist/cjs/src/backoff/exponentialbackoff.js.map +1 -1
- package/dist/cjs/src/backoff/linearbackoff.js.map +1 -1
- package/dist/cjs/src/queue/ring_queue.js.map +1 -1
- package/dist/cjs/src/websocket.d.ts +1 -1
- package/dist/cjs/src/websocket.d.ts.map +1 -1
- package/dist/cjs/src/websocket.js +4 -3
- package/dist/cjs/src/websocket.js.map +1 -1
- package/dist/esm/src/backoff/constantbackoff.js.map +1 -1
- package/dist/esm/src/backoff/exponentialbackoff.js.map +1 -1
- package/dist/esm/src/backoff/linearbackoff.js.map +1 -1
- package/dist/esm/src/queue/ring_queue.js.map +1 -1
- package/dist/esm/src/websocket.d.ts +1 -1
- package/dist/esm/src/websocket.d.ts.map +1 -1
- package/dist/esm/src/websocket.js +4 -3
- package/dist/esm/src/websocket.js.map +1 -1
- package/eslint.config.mjs +43 -0
- package/package.json +27 -20
- package/src/queue/ring_queue.ts +2 -2
- package/src/websocket.ts +5 -4
- package/tsconfig.cjs.json +74 -71
- package/tsconfig.esm.json +74 -71
- package/websocket-ts-2.2.0.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ring_queue.js","sourceRoot":"","sources":["../../../../src/queue/ring_queue.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAKpB,YAAY,QAAgB;QAC1B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"ring_queue.js","sourceRoot":"","sources":["../../../../src/queue/ring_queue.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAKpB,YAAY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;YAC5B,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI;gBACrB,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI;gBACvB,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACrD,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI;QACF,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QACrD,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
|
|
@@ -58,7 +58,7 @@ export declare class Websocket {
|
|
|
58
58
|
*/
|
|
59
59
|
get backoff(): Backoff | undefined;
|
|
60
60
|
/**
|
|
61
|
-
* Whether the websocket was closed by the user. A websocket is closed by the user
|
|
61
|
+
* Whether the websocket was closed by the user. A websocket is closed by the user by calling close().
|
|
62
62
|
*
|
|
63
63
|
* @return true if the websocket was closed by the user, false otherwise.
|
|
64
64
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../../src/websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBA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AC,EACnC,OAAO,CAAC,EAAE,6BAA6B,GACtC,IAAI;IASP;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAsBlB;;OAEG;IACH,OAAO,CAAC,cAAc;IAoBtB;;;OAGG;IACH,OAAO,CAAC,eAAe,CACwB;IAE/C;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CACwB;IAEhD;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CACwB;IAEhD;;;OAGG;IACH,OAAO,CAAC,kBAAkB,CACwB;IAElD;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAuBrB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAyCnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAwCvC;;OAEG;IACH,OAAO,CAAC,8BAA8B;CAGvC"}
|
|
@@ -103,7 +103,7 @@ export class Websocket {
|
|
|
103
103
|
return this._options.retry.backoff;
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
|
-
* Whether the websocket was closed by the user. A websocket is closed by the user
|
|
106
|
+
* Whether the websocket was closed by the user. A websocket is closed by the user by calling close().
|
|
107
107
|
*
|
|
108
108
|
* @return true if the websocket was closed by the user, false otherwise.
|
|
109
109
|
*/
|
|
@@ -328,6 +328,7 @@ export class Websocket {
|
|
|
328
328
|
if (this.backoff === undefined) {
|
|
329
329
|
return; // no backoff defined, no retry
|
|
330
330
|
}
|
|
331
|
+
// handler dispatches the retry event to all listeners of the retry event-type
|
|
331
332
|
const handleRetryEvent = (detail) => {
|
|
332
333
|
const event = new CustomEvent(WebsocketEvent.retry, { detail });
|
|
333
334
|
this.handleEvent(WebsocketEvent.retry, event);
|
|
@@ -343,14 +344,14 @@ export class Websocket {
|
|
|
343
344
|
// schedule a new connection-retry if the maximum number of retries is not reached yet
|
|
344
345
|
if (this._options.retry.maxRetries === undefined ||
|
|
345
346
|
retryEventDetail.retries <= this._options.retry.maxRetries) {
|
|
346
|
-
this.retryTimeout =
|
|
347
|
+
this.retryTimeout = globalThis.setTimeout(() => handleRetryEvent(retryEventDetail), retryEventDetail.backoff);
|
|
347
348
|
}
|
|
348
349
|
}
|
|
349
350
|
/**
|
|
350
351
|
* Cancels the scheduled connection-retry, if there is one.
|
|
351
352
|
*/
|
|
352
353
|
cancelScheduledConnectionRetry() {
|
|
353
|
-
|
|
354
|
+
globalThis.clearTimeout(this.retryTimeout);
|
|
354
355
|
}
|
|
355
356
|
}
|
|
356
357
|
//# sourceMappingURL=websocket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/websocket.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,cAAc,GAMf,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,MAAM,OAAO,SAAS;IAYpB;;;;;;OAMG;IACH,YACE,GAAW,EACX,SAA6B,EAC7B,OAA0B;;QAlBpB,kBAAa,GAAY,KAAK,CAAC,CAAC,+CAA+C;QAwSvF;;;WAGG;QACK,oBAAe,GAAG,CAAC,KAAY,EAAE,EAAE,CACzC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE/C;;;WAGG;QACK,qBAAgB,GAAG,CAAC,KAAY,EAAE,EAAE,CAC1C,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAEhD;;;WAGG;QACK,qBAAgB,GAAG,CAAC,KAAiB,EAAE,EAAE,CAC/C,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAEhD;;;WAGG;QACK,uBAAkB,GAAG,CAAC,KAAmB,EAAE,EAAE,CACnD,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QA9ShD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,SAAS,CAA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"eslint-plugin-prettier";
|
|
3
|
+
import globals from "globals";
|
|
4
|
+
import tsParser from "@typescript-eslint/parser";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import js from "@eslint/js";
|
|
8
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = path.dirname(__filename);
|
|
12
|
+
const compat = new FlatCompat({
|
|
13
|
+
baseDirectory: __dirname,
|
|
14
|
+
recommendedConfig: js.configs.recommended,
|
|
15
|
+
allConfig: js.configs.all,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export default [
|
|
19
|
+
...compat.extends(
|
|
20
|
+
"eslint:recommended",
|
|
21
|
+
"plugin:@typescript-eslint/recommended",
|
|
22
|
+
"plugin:prettier/recommended",
|
|
23
|
+
),
|
|
24
|
+
{
|
|
25
|
+
plugins: {
|
|
26
|
+
"@typescript-eslint": typescriptEslint,
|
|
27
|
+
prettier,
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
languageOptions: {
|
|
31
|
+
globals: {
|
|
32
|
+
...globals.browser,
|
|
33
|
+
...globals.node,
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
parser: tsParser,
|
|
37
|
+
ecmaVersion: 2021,
|
|
38
|
+
sourceType: "module",
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
rules: {},
|
|
42
|
+
},
|
|
43
|
+
];
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "websocket-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"main": "dist/cjs/src/index.js",
|
|
5
5
|
"types": "dist/cjs/src/index.d.ts",
|
|
6
6
|
"module": "dist/esm/src/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": "./dist/esm/src/index.js",
|
|
10
|
+
"require": "./dist/cjs/src/index.js"
|
|
11
|
+
},
|
|
7
12
|
"license": "MIT",
|
|
8
13
|
"keywords": [
|
|
9
14
|
"websocket",
|
|
@@ -18,29 +23,31 @@
|
|
|
18
23
|
"url": "github:jjxxs/websocket-ts"
|
|
19
24
|
},
|
|
20
25
|
"scripts": {
|
|
26
|
+
"build": "npm run build:cjs && npm run build:esm",
|
|
21
27
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
22
28
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
23
|
-
"build": "npm run build:cjs && npm run build:esm",
|
|
24
|
-
"test": "jest",
|
|
25
|
-
"test:coverage": "jest --coverage",
|
|
26
29
|
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
|
27
|
-
"lint": "cross-env-shell eslint
|
|
30
|
+
"lint": "cross-env-shell eslint",
|
|
31
|
+
"test": "vitest",
|
|
32
|
+
"test:coverage": "vitest --coverage"
|
|
28
33
|
},
|
|
29
34
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"eslint-plugin
|
|
35
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
36
|
+
"@eslint/js": "^9.20.0",
|
|
37
|
+
"@types/ws": "^8.5.14",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
|
39
|
+
"@typescript-eslint/parser": "^8.24.0",
|
|
40
|
+
"@vitest/coverage-v8": "^3.0.5",
|
|
34
41
|
"coveralls": "^3.1.1",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
42
|
+
"cross-env": "^7.0.3",
|
|
43
|
+
"eslint": "^9.20.1",
|
|
44
|
+
"eslint-config-prettier": "^10.0.1",
|
|
45
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
46
|
+
"globals": "^15.15.0",
|
|
47
|
+
"jsdom": "^26.0.0",
|
|
48
|
+
"ts-node": "^10.9.2",
|
|
49
|
+
"typescript": "^5.7.3",
|
|
50
|
+
"vitest": "^3.0.5",
|
|
51
|
+
"ws": "^8.18.0"
|
|
45
52
|
}
|
|
46
|
-
}
|
|
53
|
+
}
|
package/src/queue/ring_queue.ts
CHANGED
|
@@ -47,8 +47,8 @@ export class RingQueue<E> implements Queue<E> {
|
|
|
47
47
|
return this.tail === this.head
|
|
48
48
|
? 0
|
|
49
49
|
: this.tail < this.head
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
? this.head - this.tail
|
|
51
|
+
: this.elements.length - this.tail + this.head;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
isEmpty(): boolean {
|
package/src/websocket.ts
CHANGED
|
@@ -22,7 +22,7 @@ export class Websocket {
|
|
|
22
22
|
private _closedByUser: boolean = false; // whether the websocket was closed by the user
|
|
23
23
|
private _lastConnection?: Date; // timestamp of the last connection
|
|
24
24
|
private _underlyingWebsocket: WebSocket; // the underlying websocket, e.g. native browser websocket
|
|
25
|
-
private retryTimeout?:
|
|
25
|
+
private retryTimeout?: ReturnType<typeof globalThis.setTimeout>; // timeout for the next retry, if any
|
|
26
26
|
|
|
27
27
|
private _options: WebsocketOptions &
|
|
28
28
|
Required<Pick<WebsocketOptions, "listeners" | "retry">>; // options/config for the websocket
|
|
@@ -118,7 +118,7 @@ export class Websocket {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
* Whether the websocket was closed by the user. A websocket is closed by the user
|
|
121
|
+
* Whether the websocket was closed by the user. A websocket is closed by the user by calling close().
|
|
122
122
|
*
|
|
123
123
|
* @return true if the websocket was closed by the user, false otherwise.
|
|
124
124
|
*/
|
|
@@ -447,6 +447,7 @@ export class Websocket {
|
|
|
447
447
|
return; // no backoff defined, no retry
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
+
// handler dispatches the retry event to all listeners of the retry event-type
|
|
450
451
|
const handleRetryEvent = (detail: RetryEventDetail) => {
|
|
451
452
|
const event: CustomEvent<RetryEventDetail> = new CustomEvent(
|
|
452
453
|
WebsocketEvent.retry,
|
|
@@ -471,7 +472,7 @@ export class Websocket {
|
|
|
471
472
|
this._options.retry.maxRetries === undefined ||
|
|
472
473
|
retryEventDetail.retries <= this._options.retry.maxRetries
|
|
473
474
|
) {
|
|
474
|
-
this.retryTimeout =
|
|
475
|
+
this.retryTimeout = globalThis.setTimeout(
|
|
475
476
|
() => handleRetryEvent(retryEventDetail),
|
|
476
477
|
retryEventDetail.backoff,
|
|
477
478
|
);
|
|
@@ -482,6 +483,6 @@ export class Websocket {
|
|
|
482
483
|
* Cancels the scheduled connection-retry, if there is one.
|
|
483
484
|
*/
|
|
484
485
|
private cancelScheduledConnectionRetry() {
|
|
485
|
-
|
|
486
|
+
globalThis.clearTimeout(this.retryTimeout);
|
|
486
487
|
}
|
|
487
488
|
}
|
package/tsconfig.cjs.json
CHANGED
|
@@ -1,71 +1,74 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Basic Options */
|
|
6
|
-
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
-
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
-
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
-
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
-
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
-
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
-
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
-
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
-
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
-
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
-
"outDir": "./dist/cjs", /* Redirect output structure to the directory. */
|
|
18
|
-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
-
// "composite": true, /* Enable project compilation */
|
|
20
|
-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
-
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
-
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
-
|
|
27
|
-
/* Strict Type-Checking Options */
|
|
28
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
-
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
-
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
-
|
|
37
|
-
/* Additional Checks */
|
|
38
|
-
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
-
|
|
43
|
-
/* Module Resolution Options */
|
|
44
|
-
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
45
|
-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// "
|
|
51
|
-
"
|
|
52
|
-
// "
|
|
53
|
-
// "
|
|
54
|
-
|
|
55
|
-
/*
|
|
56
|
-
// "
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// "
|
|
60
|
-
|
|
61
|
-
/*
|
|
62
|
-
// "
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/*
|
|
66
|
-
// "
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Basic Options */
|
|
6
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
+
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
+
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
+
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
+
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
+
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
+
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
+
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
+
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
+
"outDir": "./dist/cjs", /* Redirect output structure to the directory. */
|
|
18
|
+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
+
// "composite": true, /* Enable project compilation */
|
|
20
|
+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
+
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
+
|
|
27
|
+
/* Strict Type-Checking Options */
|
|
28
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
+
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
+
|
|
37
|
+
/* Additional Checks */
|
|
38
|
+
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
+
|
|
43
|
+
/* Module Resolution Options */
|
|
44
|
+
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
45
|
+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
46
|
+
"paths": {
|
|
47
|
+
// workaround for: https://github.com/vitest-dev/vitest/issues/4567
|
|
48
|
+
"rollup/parseAst": ["./node_modules/rollup/dist/parseAst"]
|
|
49
|
+
}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
50
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
51
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
52
|
+
// "types": [], /* Type declaration files to be included in compilation. */
|
|
53
|
+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
54
|
+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
55
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
56
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
57
|
+
|
|
58
|
+
/* Source Map Options */
|
|
59
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
60
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
61
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
62
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
63
|
+
|
|
64
|
+
/* Experimental Options */
|
|
65
|
+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
66
|
+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
67
|
+
|
|
68
|
+
/* Advanced Options */
|
|
69
|
+
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
70
|
+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
71
|
+
},
|
|
72
|
+
"include": ["src", "tests"],
|
|
73
|
+
"exclude": ["node_modules", "dist"]
|
|
74
|
+
}
|
package/tsconfig.esm.json
CHANGED
|
@@ -1,71 +1,74 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Basic Options */
|
|
6
|
-
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
-
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
-
"module": "es6", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
-
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
-
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
-
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
-
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
-
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
-
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
-
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
-
"outDir": "./dist/esm", /* Redirect output structure to the directory. */
|
|
18
|
-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
-
// "composite": true, /* Enable project compilation */
|
|
20
|
-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
-
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
-
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
-
|
|
27
|
-
/* Strict Type-Checking Options */
|
|
28
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
-
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
-
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
-
|
|
37
|
-
/* Additional Checks */
|
|
38
|
-
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
-
|
|
43
|
-
/* Module Resolution Options */
|
|
44
|
-
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
45
|
-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// "
|
|
51
|
-
"
|
|
52
|
-
// "
|
|
53
|
-
// "
|
|
54
|
-
|
|
55
|
-
/*
|
|
56
|
-
// "
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// "
|
|
60
|
-
|
|
61
|
-
/*
|
|
62
|
-
// "
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/*
|
|
66
|
-
// "
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Basic Options */
|
|
6
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
+
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
+
"module": "es6", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
+
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
+
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
+
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
+
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
+
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
+
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
+
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
+
"outDir": "./dist/esm", /* Redirect output structure to the directory. */
|
|
18
|
+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
+
// "composite": true, /* Enable project compilation */
|
|
20
|
+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
+
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
+
|
|
27
|
+
/* Strict Type-Checking Options */
|
|
28
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
+
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
+
|
|
37
|
+
/* Additional Checks */
|
|
38
|
+
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
+
|
|
43
|
+
/* Module Resolution Options */
|
|
44
|
+
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
45
|
+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
46
|
+
"paths": {
|
|
47
|
+
// workaround for: https://github.com/vitest-dev/vitest/issues/4567
|
|
48
|
+
"rollup/parseAst": ["./node_modules/rollup/dist/parseAst"]
|
|
49
|
+
}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
50
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
51
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
52
|
+
// "types": [], /* Type declaration files to be included in compilation. */
|
|
53
|
+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
54
|
+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
55
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
56
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
57
|
+
|
|
58
|
+
/* Source Map Options */
|
|
59
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
60
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
61
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
62
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
63
|
+
|
|
64
|
+
/* Experimental Options */
|
|
65
|
+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
66
|
+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
67
|
+
|
|
68
|
+
/* Advanced Options */
|
|
69
|
+
// "skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
70
|
+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
71
|
+
},
|
|
72
|
+
"include": ["src", "tests"],
|
|
73
|
+
"exclude": ["node_modules", "dist"]
|
|
74
|
+
}
|
|
Binary file
|