@player-tools/xlr-utils 0.2.1-next.0 → 0.2.1-next.2
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/dist/index.cjs.js +36 -39
- package/dist/index.d.ts +6 -6
- package/dist/index.esm.js +35 -39
- package/package.json +4 -3
- package/src/test-helpers.ts +24 -55
package/dist/index.cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var ts = require('typescript');
|
|
6
|
+
var tsvfs = require('@typescript/vfs');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
9
|
|
|
@@ -26,6 +27,7 @@ function _interopNamespace(e) {
|
|
|
26
27
|
|
|
27
28
|
var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
|
|
28
29
|
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
30
|
+
var tsvfs__default = /*#__PURE__*/_interopDefaultLegacy(tsvfs);
|
|
29
31
|
|
|
30
32
|
var __defProp$1 = Object.defineProperty;
|
|
31
33
|
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
@@ -456,47 +458,42 @@ function applyPartialOrRequiredToNodeType(baseObject, modifier) {
|
|
|
456
458
|
throw new Error(`Error: Can not apply ${modifier ? "Required" : "Partial"} to type ${baseObject.type}`);
|
|
457
459
|
}
|
|
458
460
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
return void 0;
|
|
467
|
-
},
|
|
468
|
-
writeFile(name, text, writeByteOrderMark) {
|
|
469
|
-
},
|
|
470
|
-
getDefaultLibFileName() {
|
|
471
|
-
return "lib.d.ts";
|
|
472
|
-
},
|
|
473
|
-
useCaseSensitiveFileNames() {
|
|
474
|
-
return false;
|
|
475
|
-
},
|
|
476
|
-
getCanonicalFileName(filename) {
|
|
477
|
-
return filename;
|
|
478
|
-
},
|
|
479
|
-
getCurrentDirectory() {
|
|
480
|
-
return "";
|
|
481
|
-
},
|
|
482
|
-
getNewLine() {
|
|
483
|
-
return "\n";
|
|
484
|
-
},
|
|
485
|
-
fileExists(fileName) {
|
|
486
|
-
if (fileName === mockFileName) {
|
|
487
|
-
return true;
|
|
461
|
+
var __async = (__this, __arguments, generator) => {
|
|
462
|
+
return new Promise((resolve, reject) => {
|
|
463
|
+
var fulfilled = (value) => {
|
|
464
|
+
try {
|
|
465
|
+
step(generator.next(value));
|
|
466
|
+
} catch (e) {
|
|
467
|
+
reject(e);
|
|
488
468
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
469
|
+
};
|
|
470
|
+
var rejected = (value) => {
|
|
471
|
+
try {
|
|
472
|
+
step(generator.throw(value));
|
|
473
|
+
} catch (e) {
|
|
474
|
+
reject(e);
|
|
494
475
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
476
|
+
};
|
|
477
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
478
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
479
|
+
});
|
|
480
|
+
};
|
|
481
|
+
function setupTestEnv(sourceCode, mockFileName = "filename.ts") {
|
|
482
|
+
return __async(this, null, function* () {
|
|
483
|
+
const fsMap = yield tsvfs__default["default"].createDefaultMapFromNodeModules({}, ts__default["default"]);
|
|
484
|
+
fsMap.set(mockFileName, sourceCode);
|
|
485
|
+
const system = tsvfs__default["default"].createSystem(fsMap);
|
|
486
|
+
const host = tsvfs__default["default"].createVirtualCompilerHost(system, {}, ts__default["default"]);
|
|
487
|
+
const program = ts__default["default"].createProgram({
|
|
488
|
+
rootNames: [...fsMap.keys()],
|
|
489
|
+
options: {},
|
|
490
|
+
host: host.compilerHost
|
|
491
|
+
});
|
|
492
|
+
return {
|
|
493
|
+
sf: host.compilerHost.getSourceFile(mockFileName, ts__default["default"].ScriptTarget.ES5),
|
|
494
|
+
tc: program.getTypeChecker()
|
|
495
|
+
};
|
|
496
|
+
});
|
|
500
497
|
}
|
|
501
498
|
|
|
502
499
|
exports.applyPartialOrRequiredToNodeType = applyPartialOrRequiredToNodeType;
|
package/dist/index.d.ts
CHANGED
|
@@ -109,18 +109,18 @@ interface SetupReturnType {
|
|
|
109
109
|
/**
|
|
110
110
|
* Virtual source file containing the passed in text
|
|
111
111
|
*/
|
|
112
|
-
sf:
|
|
112
|
+
sf: ts__default.SourceFile;
|
|
113
113
|
/**
|
|
114
114
|
* Type checker for the virtual program
|
|
115
115
|
*/
|
|
116
|
-
tc:
|
|
116
|
+
tc: ts__default.TypeChecker;
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Setups a virtual TS environment for tests
|
|
120
120
|
*/
|
|
121
|
-
declare function setupTestEnv(sourceCode: string, mockFileName?: string): {
|
|
122
|
-
sf:
|
|
123
|
-
tc:
|
|
124
|
-
}
|
|
121
|
+
declare function setupTestEnv(sourceCode: string, mockFileName?: string): Promise<{
|
|
122
|
+
sf: ts__default.SourceFile;
|
|
123
|
+
tc: ts__default.TypeChecker;
|
|
124
|
+
}>;
|
|
125
125
|
|
|
126
126
|
export { PropertyNode, SetupReturnType, TopLevelDeclaration, applyPartialOrRequiredToNodeType, applyPickOrOmitToNodeType, buildTemplateRegex, decorateNode, fillInGenerics, getReferencedType, getStringLiteralsFromUnion, isExportedDeclaration, isGenericInterfaceDeclaration, isGenericNamedType, isGenericNodeType, isGenericTypeDeclaration, isNode, isNodeExported, isNonNullable, isOptionalProperty, isPrimitiveTypeNode, isTopLevelNode, isTypeReferenceGeneric, makePropertyMap, propertyToTuple, resolveConditional, setupTestEnv, tsStripOptionalType };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
import ts__default from 'typescript';
|
|
3
|
+
import tsvfs from '@typescript/vfs';
|
|
3
4
|
|
|
4
5
|
var __defProp$1 = Object.defineProperty;
|
|
5
6
|
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
@@ -430,47 +431,42 @@ function applyPartialOrRequiredToNodeType(baseObject, modifier) {
|
|
|
430
431
|
throw new Error(`Error: Can not apply ${modifier ? "Required" : "Partial"} to type ${baseObject.type}`);
|
|
431
432
|
}
|
|
432
433
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
return void 0;
|
|
441
|
-
},
|
|
442
|
-
writeFile(name, text, writeByteOrderMark) {
|
|
443
|
-
},
|
|
444
|
-
getDefaultLibFileName() {
|
|
445
|
-
return "lib.d.ts";
|
|
446
|
-
},
|
|
447
|
-
useCaseSensitiveFileNames() {
|
|
448
|
-
return false;
|
|
449
|
-
},
|
|
450
|
-
getCanonicalFileName(filename) {
|
|
451
|
-
return filename;
|
|
452
|
-
},
|
|
453
|
-
getCurrentDirectory() {
|
|
454
|
-
return "";
|
|
455
|
-
},
|
|
456
|
-
getNewLine() {
|
|
457
|
-
return "\n";
|
|
458
|
-
},
|
|
459
|
-
fileExists(fileName) {
|
|
460
|
-
if (fileName === mockFileName) {
|
|
461
|
-
return true;
|
|
434
|
+
var __async = (__this, __arguments, generator) => {
|
|
435
|
+
return new Promise((resolve, reject) => {
|
|
436
|
+
var fulfilled = (value) => {
|
|
437
|
+
try {
|
|
438
|
+
step(generator.next(value));
|
|
439
|
+
} catch (e) {
|
|
440
|
+
reject(e);
|
|
462
441
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
442
|
+
};
|
|
443
|
+
var rejected = (value) => {
|
|
444
|
+
try {
|
|
445
|
+
step(generator.throw(value));
|
|
446
|
+
} catch (e) {
|
|
447
|
+
reject(e);
|
|
468
448
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
449
|
+
};
|
|
450
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
451
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
452
|
+
});
|
|
453
|
+
};
|
|
454
|
+
function setupTestEnv(sourceCode, mockFileName = "filename.ts") {
|
|
455
|
+
return __async(this, null, function* () {
|
|
456
|
+
const fsMap = yield tsvfs.createDefaultMapFromNodeModules({}, ts__default);
|
|
457
|
+
fsMap.set(mockFileName, sourceCode);
|
|
458
|
+
const system = tsvfs.createSystem(fsMap);
|
|
459
|
+
const host = tsvfs.createVirtualCompilerHost(system, {}, ts__default);
|
|
460
|
+
const program = ts__default.createProgram({
|
|
461
|
+
rootNames: [...fsMap.keys()],
|
|
462
|
+
options: {},
|
|
463
|
+
host: host.compilerHost
|
|
464
|
+
});
|
|
465
|
+
return {
|
|
466
|
+
sf: host.compilerHost.getSourceFile(mockFileName, ts__default.ScriptTarget.ES5),
|
|
467
|
+
tc: program.getTypeChecker()
|
|
468
|
+
};
|
|
469
|
+
});
|
|
474
470
|
}
|
|
475
471
|
|
|
476
472
|
export { applyPartialOrRequiredToNodeType, applyPickOrOmitToNodeType, buildTemplateRegex, decorateNode, fillInGenerics, getReferencedType, getStringLiteralsFromUnion, isExportedDeclaration, isGenericInterfaceDeclaration, isGenericNamedType, isGenericNodeType, isGenericTypeDeclaration, isNode, isNodeExported, isNonNullable, isOptionalProperty, isPrimitiveTypeNode, isTopLevelNode, isTypeReferenceGeneric, makePropertyMap, propertyToTuple, resolveConditional, setupTestEnv, tsStripOptionalType };
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-tools/xlr-utils",
|
|
3
|
-
"version": "0.2.1-next.
|
|
3
|
+
"version": "0.2.1-next.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"typescript": "4.
|
|
9
|
+
"typescript": "4.8.4",
|
|
10
10
|
"jsonc-parser": "^2.3.1"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@player-tools/xlr": "0.2.1-next.
|
|
13
|
+
"@player-tools/xlr": "0.2.1-next.2",
|
|
14
|
+
"@typescript/vfs": "^1.4.0",
|
|
14
15
|
"@babel/runtime": "7.15.4"
|
|
15
16
|
},
|
|
16
17
|
"main": "dist/index.cjs.js",
|
package/src/test-helpers.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import tsvfs from '@typescript/vfs';
|
|
2
3
|
|
|
3
4
|
export interface SetupReturnType {
|
|
4
5
|
/**
|
|
@@ -14,59 +15,27 @@ export interface SetupReturnType {
|
|
|
14
15
|
/**
|
|
15
16
|
* Setups a virtual TS environment for tests
|
|
16
17
|
*/
|
|
17
|
-
export function setupTestEnv(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return 'lib.d.ts';
|
|
40
|
-
},
|
|
41
|
-
useCaseSensitiveFileNames() {
|
|
42
|
-
return false;
|
|
43
|
-
},
|
|
44
|
-
getCanonicalFileName(filename: any) {
|
|
45
|
-
return filename;
|
|
46
|
-
},
|
|
47
|
-
getCurrentDirectory() {
|
|
48
|
-
return '';
|
|
49
|
-
},
|
|
50
|
-
getNewLine() {
|
|
51
|
-
return '\n';
|
|
52
|
-
},
|
|
53
|
-
fileExists(fileName: string) {
|
|
54
|
-
if (fileName === mockFileName) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return false;
|
|
59
|
-
},
|
|
60
|
-
readFile(fileName: string) {
|
|
61
|
-
if (fileName === mockFileName) {
|
|
62
|
-
return sourceCode;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return undefined;
|
|
66
|
-
},
|
|
18
|
+
export async function setupTestEnv(
|
|
19
|
+
sourceCode: string,
|
|
20
|
+
mockFileName = 'filename.ts'
|
|
21
|
+
) {
|
|
22
|
+
const fsMap = await tsvfs.createDefaultMapFromNodeModules({}, ts);
|
|
23
|
+
fsMap.set(mockFileName, sourceCode);
|
|
24
|
+
|
|
25
|
+
const system = tsvfs.createSystem(fsMap);
|
|
26
|
+
const host = tsvfs.createVirtualCompilerHost(system, {}, ts);
|
|
27
|
+
|
|
28
|
+
const program = ts.createProgram({
|
|
29
|
+
rootNames: [...fsMap.keys()],
|
|
30
|
+
options: {},
|
|
31
|
+
host: host.compilerHost,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
sf: host.compilerHost.getSourceFile(
|
|
36
|
+
mockFileName,
|
|
37
|
+
ts.ScriptTarget.ES5
|
|
38
|
+
) as ts.SourceFile,
|
|
39
|
+
tc: program.getTypeChecker(),
|
|
67
40
|
};
|
|
68
|
-
|
|
69
|
-
const program = ts.createProgram([mockFileName], {}, compilerHost);
|
|
70
|
-
|
|
71
|
-
return { sf: sourceFile, tc: program.getTypeChecker() };
|
|
72
41
|
}
|