Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Update typescript to 4.1.2 (#2026)
Browse files Browse the repository at this point in the history
* HARP-13368: update TypeScript to 4.1.2

TypeScript 4.1.2 required the following adjustments:
- adjust types
- remove setter and getter for the "fog" property
- remove setter and getter for the "opacity" property
- remove setter and getter for the "displacementMap" property in MapMeshStandardMaterial

Signed-off-by: Andrii Heonia <andrii.heonia@here.com>
Signed-off-by: Fischer, Thomas <Fischer.Th@gmail.com>

Co-authored-by: Fischer, Thomas <Fischer.Th@gmail.com>
  • Loading branch information
AndriiHeonia and ThFischer committed Jan 12, 2021
1 parent 9d2b004 commit 28e9afd
Show file tree
Hide file tree
Showing 54 changed files with 272 additions and 283 deletions.
2 changes: 1 addition & 1 deletion @here/harp-atlas-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"devDependencies": {
"ts-node": "^8.10.1",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-atlas-tools/src/ImageVectorCoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class ImageVectorEncoder implements ImageEncoder {
if (err) {
reject(new Error("Failed to write and image: " + filePath));
} else {
resolve();
resolve(undefined);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-datasource-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"ts-json-schema-generator": "^0.68.1",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
Expand Down
4 changes: 2 additions & 2 deletions @here/harp-datasource-protocol/test/StyleSetEvaluatorTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ describe("StyleSetEvaluator", function() {

assert.equal(techniquesTileC.length, 2);

// delete _index from result techniques, because it may differ
// reset _index from result techniques, because it may differ
[...techniquesTileA, ...techniquesTileB, ...techniquesTileC].forEach(t => {
delete t._index;
t._index = 0;
});

// Now, respective techniques should have same cache key irrespectively to from
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-debug-datasource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"cross-env": "^7.0.2",
"mocha": "^7.2.0",
"source-map-support": "^0.5.19",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
Expand Down
24 changes: 12 additions & 12 deletions @here/harp-examples/lib/PerformanceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export namespace PerformanceUtils {
waitForFinish !== true || !MapViewUtils.mapViewIsLoading(mapViewApp.mapView);

if (numFrames > 1 || !isFinished) {
return await new Promise<FrameResults>((resolve, reject) => {
return await new Promise<FrameResults | undefined>((resolve, reject) => {
recordFrames(mapViewApp, numFrames - 1, waitForFinish)
.then(results => {
resolve(results);
Expand Down Expand Up @@ -339,13 +339,13 @@ export namespace PerformanceUtils {
frameResults.renderedFrames = numFrames;
}

return await new Promise<FrameResults>((resolve, reject) => {
return await new Promise<FrameResults | undefined>((resolve, reject) => {
resolve(frameResults);
});
}

function recordRendering(mapViewApp: MapViewApp): Promise<SimpleFrameStatistics> {
return new Promise<SimpleFrameStatistics>((resolve, reject) => {
function recordRendering(mapViewApp: MapViewApp): Promise<SimpleFrameStatistics | undefined> {
return new Promise<SimpleFrameStatistics | undefined>((resolve, reject) => {
ensureRenderFinished(mapViewApp).then(() => {
const decodingStatistics: any = {};

Expand Down Expand Up @@ -406,8 +406,8 @@ export namespace PerformanceUtils {
long: number,
height: number,
showLabels: boolean
): Promise<SimpleFrameStatistics> {
return await new Promise<SimpleFrameStatistics>((resolve, reject) => {
): Promise<SimpleFrameStatistics | undefined> {
return await new Promise<SimpleFrameStatistics | undefined>((resolve, reject) => {
setMapCenter(mapViewApp, lat, long, height, true).then(() => {
applyDataFilter(mapViewApp.mapView, showLabels);

Expand Down Expand Up @@ -476,8 +476,8 @@ export namespace PerformanceUtils {
zoomLevel: number,
tilt: number,
showLabels: boolean
): Promise<SimpleFrameStatistics> {
return await new Promise<SimpleFrameStatistics>((resolve, reject) => {
): Promise<SimpleFrameStatistics | undefined> {
return await new Promise<SimpleFrameStatistics | undefined>((resolve, reject) => {
ensureRenderFinished(mapViewApp).then(() => {
PerformanceStatistics.instance.clear();
mapViewApp.mapView.clearTileCache();
Expand Down Expand Up @@ -575,7 +575,7 @@ export namespace PerformanceUtils {
locations: PerformanceTestData.FlyoverLocation[],
waitForFrameLoaded: boolean,
isCancelled?: () => boolean
): Promise<SimpleFrameStatistics> {
): Promise<SimpleFrameStatistics | undefined> {
const mapView = mapViewApp.mapView;
const firstLocation = locations[0];
setCamera(
Expand All @@ -599,7 +599,7 @@ export namespace PerformanceUtils {
);
const startTime = PerformanceTimer.now();

return await new Promise<SimpleFrameStatistics>((resolve, reject) => {
return await new Promise<SimpleFrameStatistics | undefined>((resolve, reject) => {
const renderCallback = () => {
if (isCancelled !== undefined && isCancelled()) {
mapView.endAnimation();
Expand Down Expand Up @@ -715,7 +715,7 @@ export namespace PerformanceUtils {
showLabels: boolean,
laps: number = 1,
isCancelled?: () => boolean
): Promise<SimpleFrameStatistics> {
): Promise<SimpleFrameStatistics | undefined> {
assert(
spline.controlPoints.length / 2 === spline.zoomLevels.length,
"Control points and zoom levels must have same number of entries"
Expand All @@ -727,7 +727,7 @@ export namespace PerformanceUtils {

applyDataFilter(mapViewApp.mapView, showLabels);

return await new Promise<SimpleFrameStatistics>((resolve, reject) => {
return await new Promise<SimpleFrameStatistics | undefined>((resolve, reject) => {
const numberOfDrawPoints =
numFramesOverride !== undefined ? numFramesOverride : spline.numberOfDrawPoints;
const segments = Math.ceil(numberOfDrawPoints / (spline.controlPoints.length / 2 - 1));
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"suncalc": "^1.8.0",
"three": "^0.124.0",
"ts-loader": "^8.0.7",
"typescript": "^3.9.3",
"typescript": "^4.1.2",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0",
"webpack-merge": "^4.1.1",
Expand Down
66 changes: 34 additions & 32 deletions @here/harp-examples/src/performance_benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export namespace PerformanceBenchmark {
let flyoverNumFrames: number | undefined;
let numDecoders: number | undefined;

let latestResult: SimpleFrameStatistics;
let latestResult: SimpleFrameStatistics | undefined;

function startTest(testTitle: string, testLocation: string) {
isCancelled = false;
Expand Down Expand Up @@ -935,37 +935,39 @@ export namespace PerformanceBenchmark {
function saveTable() {
const stats = latestResult;

let resultCSV =
"Name, Avg, Min, Max, Median, Med 75, Med 90, Med 95, Med 97, Med 99, Med 999\n";

const frameStatsStrings = Array.from(stats.frameStats!.keys()).sort();
for (const stat of frameStatsStrings) {
const frameStat = stats.frameStats!.get(stat)!;

const row = `${stat}, ${valueString(frameStat.avg)}, ${valueString(
frameStat.min
)}, ${valueString(frameStat.max)}, ${valueString(frameStat.median)}, ${valueString(
frameStat.median75
)}, ${valueString(frameStat.median90)}, ${valueString(
frameStat.median95
)}, ${valueString(frameStat.median97)}, ${valueString(
frameStat.median99
)}, ${valueString(frameStat.median999)}\n`;
resultCSV += row;
if (stats) {
let resultCSV =
"Name, Avg, Min, Max, Median, Med 75, Med 90, Med 95, Med 97, Med 99, Med 999\n";

const frameStatsStrings = Array.from(stats.frameStats!.keys()).sort();
for (const stat of frameStatsStrings) {
const frameStat = stats.frameStats!.get(stat)!;

const row = `${stat}, ${valueString(frameStat.avg)}, ${valueString(
frameStat.min
)}, ${valueString(frameStat.max)}, ${valueString(frameStat.median)}, ${valueString(
frameStat.median75
)}, ${valueString(frameStat.median90)}, ${valueString(
frameStat.median95
)}, ${valueString(frameStat.median97)}, ${valueString(
frameStat.median99
)}, ${valueString(frameStat.median999)}\n`;
resultCSV += row;
}
const type = "text/csv";
const blob = new Blob([resultCSV], { type });
const a = document.createElement("a");
const url = URL.createObjectURL(blob);
a.download = `results.csv`;
a.href = url;
a.dispatchEvent(
new MouseEvent(`click`, {
bubbles: true,
cancelable: true,
view: window
})
);
}
const type = "text/csv";
const blob = new Blob([resultCSV], { type });
const a = document.createElement("a");
const url = URL.createObjectURL(blob);
a.download = `results.csv`;
a.href = url;
a.dispatchEvent(
new MouseEvent(`click`, {
bubbles: true,
cancelable: true,
view: window
})
);
}

const million = 1024 * 1024;
Expand Down Expand Up @@ -1000,7 +1002,7 @@ export namespace PerformanceBenchmark {
row.appendChild(cell);
}

function createTable(stats: SimpleFrameStatistics) {
function createTable(stats: SimpleFrameStatistics | undefined) {
document.getElementById("testTitle")!.innerHTML = title;
document.getElementById("testLocation")!.innerHTML = location;
document.getElementById("testCanvasSize")!.innerHTML = canvasSize;
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-features-datasource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"mocha": "^7.2.0",
"sinon": "^9.0.2",
"source-map-support": "^0.5.19",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"sinon": "^9.0.2",
"source-map-support": "^0.5.19",
"stream": "0.0.2",
"typescript": "^3.9.3",
"typescript": "^4.1.2",
"zlib": "^1.0.5"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-geojson-datasource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"sinon": "^9.0.2",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-geometry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"sinon": "^9.0.2",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-geoutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"sinon": "^9.0.2",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-lines/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"mocha": "^7.2.0",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-lrucache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"cross-env": "^7.0.2",
"mocha": "^7.2.0",
"source-map-support": "^0.5.19",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-map-controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"sinon": "^9.0.2",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-map-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"source-map-support": "^0.5.19",
"tmp": "^0.2.1",
"ts-node": "^8.10.1",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-mapview-decoder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"mocha": "^7.2.0",
"sinon": "^9.0.2",
"source-map-support": "^0.5.19",
"typescript": "^3.9.3"
"typescript": "^4.1.2"
},
"publishConfig": {
"access": "public"
Expand Down
7 changes: 6 additions & 1 deletion @here/harp-mapview/lib/DecodedTileHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,12 @@ export function applyBaseColorToMaterial(
}

opacity = THREE.MathUtils.clamp(opacity, 0, 1);
material.opacity = opacity;
if (material instanceof RawShaderMaterial) {
material.setOpacity(opacity);
} else {
material.opacity = opacity;
}

materialColor.setRGB(r, g, b);

const opaque = opacity >= 1.0;
Expand Down
10 changes: 8 additions & 2 deletions @here/harp-mapview/lib/MapMaterialAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { ColorUtils, Expr, getPropertyValue, Value } from "@here/harp-datasource-protocol";
import { disableBlending, enableBlending } from "@here/harp-materials";
import { disableBlending, enableBlending, RawShaderMaterial } from "@here/harp-materials";
import * as THREE from "three";

import { evaluateColorProperty } from "./DecodedTileHelpers";
Expand Down Expand Up @@ -237,8 +237,14 @@ export class MapMaterialAdapter {
color = parsed;
}
const { r, g, b, a } = ColorUtils.getRgbaFromHex(color ?? 0xff0000);

const actualOpacity = a * THREE.MathUtils.clamp(opacity ?? 1, 0, 1);
this.material.opacity = actualOpacity;
if (this.material instanceof RawShaderMaterial) {
this.material.setOpacity(actualOpacity);
} else {
this.material.opacity = actualOpacity;
}

(this.material as any).color.setRGB(r, g, b);

const opaque = actualOpacity >= 1.0;
Expand Down
Loading

0 comments on commit 28e9afd

Please sign in to comment.