Skip to content

Commit

Permalink
build: fix types defs for geoblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
oterral committed Dec 5, 2024
1 parent f2836aa commit c7dd022
Show file tree
Hide file tree
Showing 9 changed files with 627 additions and 746 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"./types": "./types/index.d.ts"
},
"dependencies": {
"@geoblocks/ol-maplibre-layer": "^1.0.1",
"@geoblocks/ol-maplibre-layer": "^1.0.2",
"@turf/helpers": "7.1.0",
"@turf/transform-rotate": "7.1.0",
"lodash.debounce": "4.0.8",
Expand All @@ -28,7 +28,7 @@
"@babel/preset-typescript": "^7.26.0",
"@commitlint/cli": "19.6.0",
"@commitlint/config-conventional": "19.6.0",
"@geops/eslint-config-react": "^1.2.0",
"@geops/eslint-config-react": "^1.3.2",
"@types/geojson": "7946.0.14",
"@types/lodash": "^4.17.13",
"@types/lodash.debounce": "4.0.9",
Expand All @@ -37,9 +37,9 @@
"@types/offscreencanvas": "2019.7.3",
"@types/topojson": "3.2.6",
"@types/uuid": "10.0.0",
"@typescript-eslint/eslint-plugin": "8.15.0",
"@typescript-eslint/parser": "8.15.0",
"cypress": "13.16.0",
"@typescript-eslint/eslint-plugin": "8.17.0",
"@typescript-eslint/parser": "8.17.0",
"cypress": "13.16.1",
"esbuild": "0.24.0",
"esdoc": "1.1.0",
"esdoc-ecmascript-proposal-plugin": "1.0.0",
Expand Down Expand Up @@ -70,20 +70,20 @@
"mock-socket": "9.3.1",
"next": "15.0.3",
"next-transpile-modules": "10.0.1",
"ol": "10.2.1",
"ol": "10.3.1",
"openapi-typescript": "6.7.5",
"prettier": "3.3.3",
"prettier": "3.4.2",
"raw-loader": "4.0.2",
"sort-json": "2.0.1",
"standard-version": "9.5.0",
"start-server-and-test": "2.0.8",
"stylelint": "16.10.0",
"stylelint": "16.11.0",
"stylelint-config-recommended-scss": "14.1.0",
"stylelint-config-standard": "36.0.1",
"stylelint-scss": "6.10.0",
"ts-jest": "^29.2.5",
"typescript": "5.6.3",
"vite": "^5.4.11"
"typescript": "5.7.2",
"vite": "^6.0.2"
},
"scripts": {
"apidoc": "esdoc && cp apidoc/index.json doc/src/components/Esdoc",
Expand Down
124 changes: 62 additions & 62 deletions src/ol/layers/MaplibreLayer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer/lib';
import debounce from 'lodash.debounce';
import { EventsKey } from 'ol/events';
import Map from 'ol/Map';
Expand All @@ -13,7 +13,7 @@ import { MobilityLayerOptions } from './Layer';
import type {
MapLibreLayerOptions,
MapLibreOptions,
} from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
} from '@geoblocks/ol-maplibre-layer/lib/MapLibreLayer';
import type { QueryRenderedFeaturesOptions } from 'maplibre-gl';

export type MaplibreLayerOptions = {
Expand Down Expand Up @@ -81,6 +81,65 @@ if (
class MaplibreLayer extends MapLibreLayer {
public olEventsKeys: EventsKey[] = [];

set apiKey(newValue: string) {
this.set('apiKey', newValue);
}
get apiKey(): string {
return this.get('apiKey');
}

set apiKeyName(newValue: string) {
this.set('apiKeyName', newValue);
}

get apiKeyName(): string {
return this.get('apiKeyName');
}

/**
* @deprecated Use layer.mapLibreMap.
*/
get maplibreMap(): maplibregl.Map | undefined {
deprecated(
'MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap.',
);
return this.mapLibreMap!;
}

// get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
// return this.get('queryRenderedFeaturesOptions');
// }

// set queryRenderedFeaturesOptions(
// newValue: maplibregl.QueryRenderedFeaturesOptions,
// ) {
// this.set('queryRenderedFeaturesOptions', newValue);
// }

/**
* @deprecated Use layer.mapLibreMap.
*/
get mbMap(): maplibregl.Map | undefined {
deprecated('MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap.');
return this.maplibreMap!;
}

get style(): string {
return this.get('style');
}

set style(newValue: string) {
this.set('style', newValue);
}

get url(): string {
return this.get('url');
}

set url(newValue: string) {
this.set('url', newValue);
}

/**
* Constructor.
*
Expand Down Expand Up @@ -129,6 +188,7 @@ class MaplibreLayer extends MapLibreLayer {
// and to see if the style is defined by the maplibreOptions given by the user.
this.set('options', options);
}

/**
* Initialize the layer and listen to feature clicks.
*/
Expand Down Expand Up @@ -190,16 +250,6 @@ class MaplibreLayer extends MapLibreLayer {
return buildStyleUrl(this.url, this.style, this.apiKey, this.apiKeyName);
}

// get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
// return this.get('queryRenderedFeaturesOptions');
// }

// set queryRenderedFeaturesOptions(
// newValue: maplibregl.QueryRenderedFeaturesOptions,
// ) {
// this.set('queryRenderedFeaturesOptions', newValue);
// }

override setMapInternal(map: Map) {
if (map) {
super.setMapInternal(map);
Expand All @@ -218,56 +268,6 @@ class MaplibreLayer extends MapLibreLayer {
console.error('Error while updating MaplibreMap', e);
}
}

set apiKey(newValue: string) {
this.set('apiKey', newValue);
}

get apiKey(): string {
return this.get('apiKey');
}

set apiKeyName(newValue: string) {
this.set('apiKeyName', newValue);
}

get apiKeyName(): string {
return this.get('apiKeyName');
}

/**
* @deprecated Use layer.mapLibreMap.
*/
get maplibreMap(): maplibregl.Map | undefined {
deprecated(
'MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap.',
);
return this.mapLibreMap!;
}

/**
* @deprecated Use layer.mapLibreMap.
*/
get mbMap(): maplibregl.Map | undefined {
deprecated('MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap.');
return this.maplibreMap!;
}

get style(): string {
return this.get('style');
}

set style(newValue: string) {
this.set('style', newValue);
}

get url(): string {
return this.get('url');
}

set url(newValue: string) {
this.set('url', newValue);
}
}

export default MaplibreLayer;
Loading

0 comments on commit c7dd022

Please sign in to comment.