Skip to content

Commit e610e7e

Browse files
authored
Update libs and update source to latest versions (#680)
1 parent bbcfb09 commit e610e7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+669
-1883
lines changed

package-lock.json

+285-1,525
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+13-15
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,35 @@
5353
"test-kotlin-ci": "cd src.kotlin/alphaTab && gradlew jvmTest"
5454
},
5555
"devDependencies": {
56-
"@rollup/plugin-commonjs": "^19.0.0",
57-
"@types/css-font-loading-module": "0.0.4",
58-
"@types/jasmine": "^3.7.1",
59-
"@types/resize-observer-browser": "^0.1.5",
60-
"concurrently": "^6.1.0",
56+
"@rollup/plugin-commonjs": "^21.0.1",
57+
"@types/jasmine": "^3.10.2",
58+
"@types/resize-observer-browser": "^0.1.6",
59+
"concurrently": "^6.3.0",
6160
"cors": "^2.8.5",
6261
"fs-extra": "^10.0.0",
63-
"git-branch": "^2.0.1",
64-
"karma": "^6.3.2",
62+
"karma": "^6.3.7",
6563
"karma-chrome-launcher": "^3.1.0",
6664
"karma-express-http-server": "0.0.1",
6765
"karma-jasmine": "^4.0.1",
68-
"karma-jasmine-html-reporter": "^1.6.0",
66+
"karma-jasmine-html-reporter": "^1.7.0",
6967
"karma-rollup-preprocessor": "^7.0.7",
7068
"karma-spec-reporter": "0.0.32",
7169
"lodash": "^4.17.21",
72-
"multer": "^1.4.2",
70+
"multer": "^1.4.3",
7371
"rimraf": "^3.0.2",
74-
"rollup": "^2.47.0",
72+
"rollup": "^2.59.0",
7573
"rollup-plugin-copy": "^3.4.0",
76-
"rollup-plugin-dts": "^3.0.1",
77-
"rollup-plugin-license": "^2.3.0",
74+
"rollup-plugin-dts": "^4.0.1",
75+
"rollup-plugin-license": "^2.6.0",
7876
"rollup-plugin-serve": "^1.1.0",
7977
"rollup-plugin-terser": "^7.0.2",
80-
"terser": "^5.7.0",
81-
"ts-node": "^9.1.1",
78+
"terser": "^5.9.0",
79+
"ts-node": "^10.4.0",
8280
"tslint": "^6.1.3",
8381
"tslint-config-prettier": "^1.18.0",
8482
"tslint-config-standard": "^9.0.0",
8583
"ttypescript": "^1.5.12",
86-
"typescript": "^4.2.4"
84+
"typescript": "^4.4.4"
8785
},
8886
"files": [
8987
"/dist/alphaTab.js",

rollup.config.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ const resolve = require('./rollup.resolve');
22
const terser = require('rollup-plugin-terser').terser;
33
const dts = require('rollup-plugin-dts').default;
44
const copy = require('rollup-plugin-copy');
5-
const branch = require('git-branch');
65
const license = require('rollup-plugin-license');
76
const serve = require('rollup-plugin-serve');
7+
const fs = require('fs');
8+
9+
function getGitBranch() {
10+
const filepath = '.git/HEAD';
11+
if (!fs.existsSync(filepath)) {
12+
throw new Error('.git/HEAD does not exist');
13+
}
14+
const buf = fs.readFileSync(filepath);
15+
const match = /ref: refs\/heads\/([^\n]+)/.exec(buf.toString());
16+
return match ? match[1] : '';
17+
}
818

919
const commonOutput = {
1020
name: 'alphaTab',
@@ -57,7 +67,7 @@ module.exports = [
5767
},
5868
data() {
5969
let buildNumber = process.env.GITHUB_RUN_NUMBER || 0;
60-
let gitBranch = branch.sync();
70+
let gitBranch = getGitBranch();
6171
return {
6272
branch: gitBranch,
6373
build: buildNumber

src.compiler/csharp/CSharpAstTransformer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ export default class CSharpAstTransformer {
638638
!!d.initializer.modifiers &&
639639
!!d.initializer.modifiers.find(m => m.kind === ts.SyntaxKind.AsyncKeyword);
640640

641-
const functionType = type.symbol.declarations.find(d =>
641+
const functionType = type.symbol.declarations!.find(d =>
642642
ts.isFunctionTypeNode(d)
643643
) as ts.FunctionTypeNode;
644644

src.compiler/csharp/CSharpEmitterContext.ts

+36-21
Original file line numberDiff line numberDiff line change
@@ -756,20 +756,22 @@ export default class CSharpEmitterContext {
756756

757757
private buildCoreNamespace(aliasSymbol: ts.Symbol) {
758758
let suffix = '';
759-
for (const decl of aliasSymbol.declarations) {
760-
let fileName = path.basename(decl.getSourceFile().fileName).toLowerCase();
761-
if (fileName.startsWith('lib.') && fileName.endsWith('.d.ts')) {
762-
fileName = fileName.substring(4, fileName.length - 5);
763-
if (fileName.length) {
764-
suffix = fileName.split('.').map(s => {
765-
if (s.match(/es[0-9]{4}/)) {
766-
return '.' + this.toPascalCase('ecmaScript');
767-
}
768-
if (s.match(/es[0-9]{1}/)) {
769-
return '.' + this.toPascalCase('ecmaScript');
770-
}
771-
return '.' + this.toPascalCase(s);
772-
})[0];
759+
if (aliasSymbol.declarations) {
760+
for (const decl of aliasSymbol.declarations) {
761+
let fileName = path.basename(decl.getSourceFile().fileName).toLowerCase();
762+
if (fileName.startsWith('lib.') && fileName.endsWith('.d.ts')) {
763+
fileName = fileName.substring(4, fileName.length - 5);
764+
if (fileName.length) {
765+
suffix = fileName.split('.').map(s => {
766+
if (s.match(/es[0-9]{4}/)) {
767+
return '.' + this.toPascalCase('ecmaScript');
768+
}
769+
if (s.match(/es[0-9]{1}/)) {
770+
return '.' + this.toPascalCase('ecmaScript');
771+
}
772+
return '.' + this.toPascalCase(s);
773+
})[0];
774+
}
773775
}
774776
}
775777
}
@@ -935,9 +937,14 @@ export default class CSharpEmitterContext {
935937

936938
// unwrap symbol of expression to get declared type
937939
let symbol = this.typeChecker.getSymbolAtLocation(expression);
938-
if (!symbol || !symbol.declarations || symbol.declarations.length === 0) {
940+
if (!symbol) {
941+
return undefined;
942+
}
943+
const declarations = symbol.declarations;
944+
if (!declarations || declarations.length === 0) {
939945
return undefined;
940946
}
947+
941948
if (symbol.flags & ts.SymbolFlags.Alias) {
942949
symbol = this.typeChecker.getAliasedSymbol(symbol);
943950
}
@@ -946,7 +953,7 @@ export default class CSharpEmitterContext {
946953
}
947954

948955
// declared type must be nullable
949-
let declaredType = this.typeChecker.getTypeAtLocation(symbol.declarations[0]);
956+
let declaredType = this.typeChecker.getTypeAtLocation(declarations[0]);
950957
if (!this.isNullableType(declaredType)) {
951958
return undefined;
952959
}
@@ -991,7 +998,11 @@ export default class CSharpEmitterContext {
991998
// we consider the expression as smart casted if the declared symbol has a different
992999
// contextual type than the declared type.
9931000
let symbol = this.typeChecker.getSymbolAtLocation(expression);
994-
if (!symbol || !symbol.declarations || symbol.declarations.length === 0) {
1001+
if (!symbol) {
1002+
return false;
1003+
}
1004+
const declarations = symbol.declarations;
1005+
if (!declarations || declarations.length === 0) {
9951006
return false;
9961007
}
9971008

@@ -1008,7 +1019,7 @@ export default class CSharpEmitterContext {
10081019
return false;
10091020
}
10101021

1011-
let declaredType = this.typeChecker.getTypeAtLocation(symbol.declarations[0]);
1022+
let declaredType = this.typeChecker.getTypeAtLocation(declarations[0]);
10121023
if (!this.isNullableType(declaredType)) {
10131024
return false;
10141025
}
@@ -1037,7 +1048,11 @@ export default class CSharpEmitterContext {
10371048
// we consider the expression as smart casted if the declared symbol has a different
10381049
// contextual type than the declared type.
10391050
let symbol = this.typeChecker.getSymbolAtLocation(expression);
1040-
if (!symbol || !symbol.declarations || symbol.declarations.length === 0) {
1051+
if (!symbol) {
1052+
return null;
1053+
}
1054+
const declarations = symbol.declarations;
1055+
if(!declarations || declarations.length === 0){
10411056
return null;
10421057
}
10431058

@@ -1057,7 +1072,7 @@ export default class CSharpEmitterContext {
10571072
}
10581073
}
10591074

1060-
let declaredType = this.typeChecker.getTypeAtLocation(symbol.declarations[0]);
1075+
let declaredType = this.typeChecker.getTypeAtLocation(declarations[0]);
10611076

10621077
let contextualTypeNullable = contextualType;
10631078
contextualType = this.typeChecker.getNonNullableType(contextualType);
@@ -1363,7 +1378,7 @@ export default class CSharpEmitterContext {
13631378
public isStaticSymbol(tsSymbol: ts.Symbol) {
13641379
return (
13651380
(tsSymbol.flags & ts.SymbolFlags.EnumMember) !== 0 ||
1366-
!!tsSymbol.declarations.find(
1381+
!!tsSymbol.declarations?.find(
13671382
d => d.modifiers && !!d.modifiers.find(m => m.kind === ts.SyntaxKind.StaticKeyword)
13681383
)
13691384
);

src.compiler/kotlin/KotlinAstPrinter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ export default class KotlinAstPrinter extends AstPrinterBase {
978978

979979
protected isMethodAsDelegate(expr: cs.MemberAccessExpression) {
980980
if (
981-
expr.tsSymbol &&
981+
expr.tsSymbol?.valueDeclaration &&
982982
ts.isMethodDeclaration(expr.tsSymbol.valueDeclaration) &&
983983
!ts.isCallExpression(expr.tsNode!.parent)
984984
) {

src.compiler/kotlin/KotlinEmitterContext.ts

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default class KotlinEmitterContext extends CSharpEmitterContext {
4646
}
4747

4848
if (
49+
classType.symbol.valueDeclaration &&
4950
ts.isClassDeclaration(classType.symbol.valueDeclaration) &&
5051
classType.symbol.valueDeclaration.heritageClauses
5152
) {

0 commit comments

Comments
 (0)