Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Typings for Node Platform #766

Merged
merged 8 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"lib"
],
"main": "platform/node/index.js",
"types": "platform/node/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/maplibre/maplibre-gl-native.git"
Expand Down
49 changes: 49 additions & 0 deletions platform/node/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
declare module '@maplibre/maplibre-gl-native' {
enum Resource {
Unknown = 0,
Style = 1,
Source = 2,
Tile = 3,
Glyphs = 4,
SpriteImage = 5,
SpriteJSON = 6,
}

type RequestResponse = {
data: ArrayBuffer;
modified?: Date;
expires?: Date;
etag?: string;
};

type MapOptions = {
request: (
request: { url: string; kind: Resource },
callback: (error?: Error, response?: RequestResponse) => void,
) => void;
ratio?: number;
KiwiKilian marked this conversation as resolved.
Show resolved Hide resolved
};

type RenderOptions = {
zoom?: number; // defaults to 0
HarelM marked this conversation as resolved.
Show resolved Hide resolved
width?: number; // px, defaults to 512
height?: number; // px, defaults to 512
center?: [number, number]; // coordinates, defaults to [0,0]
bearing?: number; // degrees, counter-clockwise from north, defaults to 0
pitch?: number; // degrees, arcing towards the horizon, defaults to 0
classes?: string[]; // array of strings
};

class Map {
constructor(mapOptions: MapOptions);

load: (style: any) => void;

render: (
renderOptions: RenderOptions,
callback: (...args: [error: Error, buffer: undefined] | [error: undefined, buffer: Uint8Array]) => void,
KiwiKilian marked this conversation as resolved.
Show resolved Hide resolved
) => void;

release: () => void;
}
}