Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 6 additions & 4 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,6 @@
/types/eris-sharder/ @mathletedev
/types/err/ @jimmycuadra
/types/error-cause/ @conartist6 @ljharb
/types/error-subclass/ @fitbit
/types/errorhandler/ @santialbo @peterblazejewicz
/types/es-abstract/ @ljharb @ExE-Boss
/types/es-aggregate-error/ @AverageHelper
Expand Down Expand Up @@ -3937,6 +3936,7 @@
/types/kahoot.js-updated/ @MysteryBlokHed
/types/kakao-js-sdk/ @wooogi123
/types/kakao-pixel/ @hahnlee
/types/kakao.postcode/ @doinki
/types/kakaomaps/ @MinByeongDon @positiveko @yongdamsh
/types/kalmanjs/ @wouterbulten
/types/kaluma/ @jt000
Expand Down Expand Up @@ -4650,6 +4650,7 @@
/types/lzbase62/ @ArthurKa
/types/lzma/ @Goldsmith42
/types/lzma-native/ @leshow
/types/lzwcompress/ @floydpink
/types/m3u8-parser/ @k-yle @dyc3
/types/macaca-circular-json/ @jpevarnek
/types/macrotask/ @BendingBender
Expand Down Expand Up @@ -5147,6 +5148,7 @@
/types/node/v20/ @Microsoft @jkomyno @r3nya @btoueg @touffy @mohsen1 @galkin @eps1lon @WilcoBakker @chyzwar @trivikr @yoursunny @qwelias @ExE-Boss @peterblazejewicz @addaleax @victorperin @NodeJS @LinusU @wafuwafu13 @mcollina @Semigradsky
/types/node/v22/ @Microsoft @jkomyno @r3nya @btoueg @touffy @mohsen1 @galkin @eps1lon @WilcoBakker @chyzwar @trivikr @yoursunny @qwelias @ExE-Boss @peterblazejewicz @addaleax @victorperin @NodeJS @LinusU @wafuwafu13 @mcollina @Semigradsky @Renegade334
/types/node/v24/ @Microsoft @jkomyno @r3nya @btoueg @touffy @mohsen1 @galkin @eps1lon @WilcoBakker @chyzwar @trivikr @yoursunny @qwelias @ExE-Boss @peterblazejewicz @addaleax @victorperin @NodeJS @LinusU @wafuwafu13 @mcollina @Semigradsky @Renegade334 @anonrig
/types/node/v25/ @Microsoft @jkomyno @r3nya @btoueg @touffy @mohsen1 @galkin @eps1lon @WilcoBakker @chyzwar @trivikr @yoursunny @qwelias @ExE-Boss @peterblazejewicz @addaleax @victorperin @NodeJS @LinusU @wafuwafu13 @mcollina @Semigradsky @Renegade334 @anonrig
/types/node-7z/ @erkie @colin969
/types/node-abi/ @ffflorian
/types/node-apple-receipt-verify/ @serinuntius
Expand Down Expand Up @@ -5762,6 +5764,7 @@
/types/polygon-selfintersect/ @mcruss
/types/polygons-intersect/ @Nielio
/types/polylabel/ @DenisCarriere
/types/polylabel/v1/ @DenisCarriere
/types/polyline/ @Kern0
/types/polymer/ @lgrignon
/types/poool-access/ @maximedasilva @dackmin
Expand Down Expand Up @@ -7958,7 +7961,7 @@
/types/turbostatus/ @ffflorian
/types/turndown/ @sergey-zhidkov
/types/tusk-mastodon/ @fishcharlie
/types/tuya-panel-kit/ @youngjuning @ShinyLeee
/types/tuya-panel-kit/ @ShinyLeee
/types/tv4/ @Bartvds @psnider
/types/tween-functions/ @hozblok
/types/tweenjs/ @evilangelist @jcyuan
Expand Down Expand Up @@ -8387,7 +8390,7 @@
/types/websocket-async/ @bigbeno37
/types/websql/ @TeamworkGuy2
/types/webtorrent/ @niieani @tlaziuk @gjuchault @cheeseandcereal
/types/webvis/ @threedy-io @instant3Dhub @tsturm @dbthreed @ErikSpiegelberg @TimLamThreedy
/types/webvis/ @threedy-io @instant3Dhub @tsturm @dbthreed @ErikSpiegelberg @TimLamThreedy @n-fix
/types/webvr-api/ @efokschaner
/types/webvtt-parser/ @dodomorandi
/types/webxr/ @robrohan @RaananW @capnmidnight @sorskoot
Expand Down Expand Up @@ -8469,7 +8472,6 @@
/types/wordpress__block-serialization-spec-parser/ @dsifford
/types/wordpress__customize-browser/ @marekdedic
/types/wordpress__edit-post/ @dsifford
/types/wordpress__server-side-render/ @rafaucau
/types/words-to-time-converter/ @peterblazejewicz
/types/wordwrap/ @ark120202
/types/wordwrapjs/ @stoyan-karev
Expand Down
2 changes: 1 addition & 1 deletion attw.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
"passport-discord",
"phoenix",
"playmusic",
"polylabel",
"polylabel/v1",
"postcss-functions",
"postcss-js",
"posterus",
Expand Down
1 change: 1 addition & 0 deletions types/polylabel/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
/v1/
21 changes: 15 additions & 6 deletions types/polylabel/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
/**
* Polylabel returns the pole of inaccessibility coordinate in [x, y] format.
* Returns the pole of inaccessibility for a polygon — the most distant internal
* point from the polygon outline — as a `[x, y]` coordinate pair. The
* `distance` property on the returned array holds the distance from the pole to
* the nearest polygon edge (the "pole radius").
*
* @param polygon - Given polygon coordinates in GeoJSON-like format
* @param precision - Precision (1.0 by default)
* @param debug - Debugging for Console
* @param polygon - Polygon rings: outer ring first, holes (if any) following.
* Each ring is an array of `[x, y]` coordinate pairs.
* @param precision - Precision of the result in the same units as the polygon
* coordinates. Defaults to `1.0`.
* @param debug - When `true`, logs progress to the console.
* @example
* var p = polylabel(polygon, 1.0);
* const [x, y] = polylabel(polygon, 1.0);
*/
declare function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[] & { distance: number };
declare function polylabel(
polygon: Array<Array<[number, number]>>,
precision?: number,
debug?: boolean,
): [number, number] & { distance: number };
declare namespace polylabel {}
export default polylabel;
3 changes: 2 additions & 1 deletion types/polylabel/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"private": true,
"name": "@types/polylabel",
"version": "1.1.9999",
"version": "2.0.9999",
"type": "module",
"projects": [
"https://github.com/mapbox/polylabel"
],
Expand Down
40 changes: 36 additions & 4 deletions types/polylabel/polylabel-tests.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
import polylabel from "polylabel";

const polygon = [[[3116, 3071], [3118, 3068], [3108, 3102], [3751, 927]]];
// Simple polygon (outer ring only)
const polygon: Array<Array<[number, number]>> = [
[
[3116, 3071],
[3118, 3068],
[3108, 3102],
[3751, 927],
],
];

// Polygon with a hole (outer ring + one inner ring)
const polygonWithHole: Array<Array<[number, number]>> = [
[
[0, 0],
[100, 0],
[100, 100],
[0, 100],
[0, 0],
],
[
[20, 20],
[20, 80],
[80, 80],
[80, 20],
[20, 20],
],
];

polylabel(polygon);
polylabel(polygon, 1.0);
polylabel(polygon, 1.0, true);
polylabel(polygon, 1.0, false);
polylabel(polygonWithHole, 0.1);

// $ExpectType [number, number] & { distance: number; }
const result = polylabel(polygon);

// $ExpectType number
polylabel(polygon)[0];
result[0];
// $ExpectType number
polylabel(polygon)[1];
result[1];
// $ExpectType number
polylabel(polygon).distance;
result.distance;

// Tuple destructuring
const [x, y] = polylabel(polygon);
// $ExpectType number
x;
Expand Down
5 changes: 5 additions & 0 deletions types/polylabel/v1/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
12 changes: 12 additions & 0 deletions types/polylabel/v1/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Polylabel returns the pole of inaccessibility coordinate in [x, y] format.
*
* @param polygon - Given polygon coordinates in GeoJSON-like format
* @param precision - Precision (1.0 by default)
* @param debug - Debugging for Console
* @example
* var p = polylabel(polygon, 1.0);
*/
declare function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[] & { distance: number };
declare namespace polylabel {}
export default polylabel;
17 changes: 17 additions & 0 deletions types/polylabel/v1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"private": true,
"name": "@types/polylabel",
"version": "1.1.9999",
"projects": [
"https://github.com/mapbox/polylabel"
],
"devDependencies": {
"@types/polylabel": "workspace:."
},
"owners": [
{
"name": "Denis Carriere",
"githubUsername": "DenisCarriere"
}
]
}
20 changes: 20 additions & 0 deletions types/polylabel/v1/polylabel-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import polylabel from "polylabel";

const polygon = [[[3116, 3071], [3118, 3068], [3108, 3102], [3751, 927]]];
polylabel(polygon);
polylabel(polygon, 1.0);
polylabel(polygon, 1.0, true);
polylabel(polygon, 1.0, false);

// $ExpectType number
polylabel(polygon)[0];
// $ExpectType number
polylabel(polygon)[1];
// $ExpectType number
polylabel(polygon).distance;

const [x, y] = polylabel(polygon);
// $ExpectType number
x;
// $ExpectType number
y;
19 changes: 19 additions & 0 deletions types/polylabel/v1/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "node16",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"polylabel-tests.ts"
]
}