地理坐标系转换工具

Overview

Gcoord

npm version codecov gzip size LICENSE 996.icu

gcoord(geographic coordinates)是一个处理地理坐标系的JS库,用来修正百度地图、高德地图及其它互联网地图坐标系不统一的问题。

支持转换坐标数组和GeoJSON数据,能在node环境以及所有现代浏览器(IE8+)中运行,gzip后仅3kb。

更多信息可以阅读地理坐标系

🚨 注意

在发布、展示、传播数据时,请务必遵守相关法律规定

(禁止)未经批准,在测绘活动中擅自采用国际坐标系统
— 中华人民共和国测绘法,40 (1)

导航电子地图在公开出版、销售、传播、展示和使用前,必须进行空间位置技术处理。
— GB 20263―2006《导航电子地图安全处理技术基本要求》,4.1

Install

通过npm安装:

npm install gcoord --save

或者直接在页面中引入:

<script src="https://unpkg.com/gcoord/dist/gcoord.js"></script>

Import

CommonJS:

const gcoord = require('gcoord');

ES Module:

import gcoord from 'gcoord';

同时也支持AMD和CMD规范

Usage

例如从手机的GPS得到一个经纬度坐标,需要将其展示在百度地图上,则应该将当前坐标从WGS-84坐标系转换为BD-09坐标系

var result = gcoord.transform(
  [116.403988, 39.914266],    // 经纬度坐标
  gcoord.WGS84,               // 当前坐标系
  gcoord.BD09                 // 目标坐标系
);

console.log(result);  // [116.41661560068297, 39.92196580126834]

同时gcoord还可以转换GeoJSON对象的坐标系,详细使用方式可以参考API

API

transform(input, from, to)

进行坐标转换

参数

返回值

GeoJSON | Array<number>

示例

// 将GCJ02坐标转换为WGS84坐标
var result = gcoord.transform([123, 45], gcoord.GCJ02, gcoord.WGS84);
console.log(result);  // [122.99395597, 44.99804071]
// 转换GeoJSON坐标
var geojson = {
  "type": "Point",
  "coordinates": [123, 45]
}
gcoord.transform(geojson, gcoord.GCJ02, gcoord.WGS84);
console.log(geojson.coordinates); // [122.99395597, 44.99804071]

返回数组或GeoJSON对象(由输入决定),注意:当输入为GeoJSON时,transform会改变输入对象

CRS

CRS为坐标系,目标支持以下几种坐标系

CRS             坐标格式 说明  
gcoord.WGS84 [lng,lat] WGS-84坐标系,GPS设备获取的经纬度坐标
gcoord.GCJ02 [lng,lat] GCJ-02坐标系,google中国地图、soso地图、aliyun地图、mapabc地图和高德地图所用的经纬度坐标
gcoord.BD09 [lng,lat] BD-09坐标系,百度地图采用的经纬度坐标
gcoord.BD09LL [lng,lat] 同BD09
gcoord.BD09MC [x,y] BD-09米制坐标,百度地图采用的米制坐标,单位:米
gcoord.BD09Meter [x,y] 同BD09MC
gcoord.Baidu [lng,lat] 百度坐标系,BD-09坐标系别名,同BD-09
gcoord.BMap [lng,lat] 百度地图,BD-09坐标系别名,同BD-09
gcoord.AMap [lng,lat] 高德地图,同GCJ-02
gcoord.WebMercator [x,y] Web Mercator投影,墨卡托投影,同EPSG3857,单位:米
gcoord.WGS1984 [lng,lat] WGS-84坐标系别名,同WGS-84
gcoord.EPSG4326 [lng,lat] WGS-84坐标系别名,同WGS-84
gcoord.EPSG3857 [x,y] Web Mercator投影,同WebMercator,单位:米
gcoord.EPSG900913 [x,y] Web Mercator投影,同WebMercator,单位:米

支持更多坐标系? gcoord的目标是处理web地图中的坐标,目前支持的坐标系已经能满足绝大部分要求了,同时gcoord也能保持轻量。如果需要更专业的坐标系处理工具,可以使用proj4js等开源库

LICENSE

MIT

Comments
  •  BD09转换GCJ02坐标

    BD09转换GCJ02坐标

    BD09转换GCJ02坐标后,大概会有15-30米左右的一个偏移,这是一个正常的偏移量么? [{ "longitude": 112.95516973717, "latitude": 27.110248315429 }, { "longitude": 112.95514967002, "latitude": 27.110209045353 }, { "longitude": 112.9552696853, "latitude": 27.110439072645 }, { "longitude": 112.95538827008, "latitude": 27.11055600291 }, { "longitude": 112.95552789901, "latitude": 27.110607549457 }, { "longitude": 112.95563435193, "latitude": 27.110608671425 }, { "longitude": 112.95591453403, "latitude": 27.110596723704 }, { "longitude": 112.95625794057, "latitude": 27.110520645541 }, { "longitude": 112.95637142166, "latitude": 27.110518640771 }, { "longitude": 112.9565491395, "latitude": 27.110464491862 }, { "longitude": 112.95693074252, "latitude": 27.11043674701 }, { "longitude": 112.95795897797, "latitude": 27.110248575302 }, { "longitude": 112.95866190586, "latitude": 27.110180202997 }, { "longitude": 112.95943518443, "latitude": 27.110209670777 }, { "longitude": 112.96032802743, "latitude": 27.110363173252 }, { "longitude": 112.96197014333, "latitude": 27.11084511094 }, { "longitude": 112.96234773516, "latitude": 27.110922743543 }, { "longitude": 112.96382982801, "latitude": 27.111144138779 }, { "longitude": 112.96614400844, "latitude": 27.111540288631 }, { "longitude": 112.96689684702, "latitude": 27.111625778344 }, { "longitude": 112.96737860852, "latitude": 27.111681353588 }] map

    opened by puwenwan 4
  • 我用C重写了WGS84和GCJ02的转换代码,发现和你的结果有偏差

    我用C重写了WGS84和GCJ02的转换代码,发现和你的结果有偏差

    #include<stdio.h>
    #include<math.h>
    #include<stdlib.h>
    #define PI 3.1415926535897932384626
    
    double a = 6378245;
    double ee = 0.006693421622965823;
    
    // roughly check whether coordinates are in China.
    int isInChinaBbox(double lon, double lat){
      	return lon >= 72.004 && lon <= 137.8347 && lat >= 0.8293 && lat <= 55.8271;
    }
    
    double transformLat(double x, double y){
    	double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * sqrt(fabs(x));
    	ret += ((20.0 * sin(6.0 * x * PI) + 20.0 * sin(2.0 * x * PI)) * 2.0) / 3.0;
    	ret += ((20.0 * sin(y * PI) + 40.0 * sin((y / 3.0) * PI)) * 2.0) / 3.0;
    	ret += ((160.0 * sin((y / 12.0) * PI) + 320.0 * sin((y * PI) / 30.0)) * 2.0) / 3.0;
    	return ret;
    }
    
    double transformLon(double x, double y){
    	double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * sqrt(fabs(x));
    	ret += ((20.0 * sin(6.0 * x * PI) + 20.0 * sin(2.0 * x * PI)) * 2.0) / 3.0;
    	ret += ((20.0 * sin(x * PI) + 40.0 * sin((x / 3.0) * PI)) * 2.0) / 3.0;
    	ret += ((150.0 * sin((x / 12.0) * PI) + 300.0 * sin((x / 30.0) * PI)) * 2.0) / 3.0;
    	return ret;
    }
    
    double* delta(double lon, double lat){
    	double *d = (double *)malloc(2*sizeof(double));
    	double dLon = transformLon(lon - 105.0, lat - 35.0);
        double dLat = transformLat(lon - 105.0, lat - 35.0);
    	
    	double radLat = (lat / 180.0) * PI;
    	double magic = sin(radLat);
    	
    	magic = 1.0 - ee * magic * magic;
    	
    	double sqrtMagic = sqrt(magic);
    	d[0] = (dLon * 180.0) / (a / sqrtMagic * cos(radLat) * PI);
    	d[1] = (dLat * 180.0) / ((a * (1.0 - ee)) / (magic * sqrtMagic) * PI);
    	return d;
    }
    
    double* WGS84ToGCJ02(double lon_WGS, double lat_WGS){
    	double *GCJ = (double *)malloc(2*sizeof(double));
    	if (!isInChinaBbox(lon_WGS, lat_WGS)){
    		GCJ[0] = lon_WGS;
    		GCJ[1] = lat_WGS;
    		return GCJ;
    	} 
    	double *d = delta(lon_WGS, lat_WGS);
    	GCJ[0] = lon_WGS + d[0];
    	GCJ[1] = lat_WGS + d[1];
    	return GCJ;
    }
    
    double* GCJ02ToWGS84(double lon_GCJ, double lat_GCJ) {
    	double *WGS = (double *)malloc(2*sizeof(double));
    	if (!isInChinaBbox(lon_GCJ, lat_GCJ)){
    		WGS[0] = lon_GCJ;
    		WGS[1] = lat_GCJ;
    		return WGS;
    	} 
    	WGS[0] = lon_GCJ; WGS[1] = lat_GCJ;
    	double *temp = WGS84ToGCJ02(WGS[0], WGS[1]);
    	double dx = temp[0] - lon_GCJ;
    	double dy = temp[1] - lat_GCJ;
    	while (fabs(dx) > 1e-6 || fabs(dy) > 1e-6) {
    		WGS[0] -= dx;
    		WGS[1] -= dy;
    		temp = WGS84ToGCJ02(WGS[0], WGS[1]);
    		dx = temp[0] - lon_GCJ;
    		dy = temp[1] - lat_GCJ;
    	}
    	return WGS;
    }
    
    int main(){
    	double lon, lat;
    	double x = 114.5048503, y = 37.0705911; 
    	double *q = GCJ02ToWGS84(x, y);
    	printf("%.10lf %.10lf\n", q[0], q[1]);
    	getchar(); 
    } 
    

    image 在china-cities.json中随机选取一份数据 "WGS84": [114.498916, 37.0700925], "GCJ02": [114.5048503, 37.0705911], 使用我的代码将GCJ02转换为WGS84,结果为[114.4989213554, 37.0700966574] 不知道是不是你的算法写错了,还是我重写的代码出了问题,我反复对照了多遍,没发现有遗漏的地方。希望得到你的回复。

    opened by Lucienxhh 3
  • 使用

    使用"https://unpkg.com/gcoord/dist/gcoord.js"引入不成功

    使用<script src="https://unpkg.com/gcoord/dist/gcoord.js"></script>引入时出现Cannot find "/dist/gcoord.js" in [email protected]的错误。

    opened by LawrenceYep 3
  • chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.4

    chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.4

    Bumps @types/jest from 27.5.2 to 29.2.4.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • chore(deps-dev): bump lint-staged from 11.2.6 to 13.0.4

    chore(deps-dev): bump lint-staged from 11.2.6 to 13.0.4

    Bumps lint-staged from 11.2.6 to 13.0.4.

    Release notes

    Sourced from lint-staged's releases.

    v13.0.4

    13.0.4 (2022-11-25)

    Bug Fixes

    • deps: update all dependencies (336f3b5)
    • deps: update all dependencies (ec995e5)

    v13.0.3

    13.0.3 (2022-06-24)

    Bug Fixes

    • correctly handle git stash when using MSYS2 (#1178) (0d627a5)

    v13.0.2

    13.0.2 (2022-06-16)

    Bug Fixes

    • use new --diff and --diff-filter options when checking task modifications (1a5a66a)

    v13.0.1

    13.0.1 (2022-06-08)

    Bug Fixes

    • correct spelling of "0 files" (f27f1d4)
    • suppress error from process.kill when killing tasks on failure (f2c6bdd)
    • deps: update pidtree@^0.6.0 to fix screen size error in WSL (1a77e42)
    • ignore "No matching pid found" error (cb8a432)
    • prevent possible race condition when killing tasks on failure (bc92aff)

    Performance Improvements

    • use EventsEmitter instead of setInterval for killing tasks on failure (c508b46)

    v13.0.0

    13.0.0 (2022-06-01)

    Bug Fixes

    • deps: update execa@^6.1.0 (659c85c)
    • deps: update yaml@^2.1.1 (2750a3d)

    ... (truncated)

    Commits
    • e2bfce1 test: remove Windows snapshot workaround
    • 81ea7fd test: allow file protocol in git submodule test
    • 3ea9b7e test: update Jest snapshot format
    • 0c635c7 ci: install latest npm for older Node.js versions
    • 5f1a00e ci: bump GitHub Actions' versions
    • 336f3b5 fix(deps): update all dependencies
    • ec995e5 fix(deps): update all dependencies
    • 17c51af ci: set GitHub Actions permissions
    • 3f3e152 chore(deps): bump colorette from 2.0.17 to 2.0.19 (#1177)
    • 0d627a5 fix: correctly handle git stash when using MSYS2 (#1178)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.2

    chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.2

    Bumps @types/jest from 27.5.2 to 29.2.2.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.1

    chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.1

    Bumps @types/jest from 27.5.2 to 29.2.1.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.0

    chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.0

    Bumps @types/jest from 27.5.2 to 29.2.0.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • chore(deps-dev): bump chalk from 4.1.2 to 5.1.2

    chore(deps-dev): bump chalk from 4.1.2 to 5.1.2

    Bumps chalk from 4.1.2 to 5.1.2.

    Release notes

    Sourced from chalk's releases.

    v5.1.2

    • Fix exported styles names (#569) a34bcf6

    https://github.com/chalk/chalk/compare/v5.1.1...v5.1.2

    v5.1.1

    • Improved the names of exports introduced in 5.1.0 (#567) 6e0df05
      • We of course preserved the old names.

    https://github.com/chalk/chalk/compare/v5.1.0...v5.1.1

    v5.1.0

    • Expose style names (#566) d7d7571

    https://github.com/chalk/chalk/compare/v5.0.1...v5.1.0

    v5.0.1

    • Add main field to package.json for backwards compatibility with some developer tools 85f7e96

    https://github.com/chalk/chalk/compare/v5.0.0...v5.0.1

    v5.0.0

    Breaking

    • This package is now pure ESM. Please read this.
      • If you use TypeScript, you need to use TypeScript 4.7 or later. Why.
      • If you use a bundler, make sure it supports ESM and that you have correctly configured it for ESM.
      • The Chalk issue tracker is not a support channel for your favorite build/bundler tool.
      • It's totally fine to stay on Chalk v4. It's been stable for years.
    • Require Node.js 12.20 fa16f4e
    • Move some properties off the default export to individual named exports:
      • chalk.InstanceChalk
      • chalk.supportsColorsupportsColor
      • chalk.stderrchalkStderr
      • chalk.stderr.supportsColorsupportsColorStderr
    • Remove .keyword(), .hsl(), .hsv(), .hwb(), and .ansi() coloring methods (#433) 4cf2e40
      • These were not commonly used and added a lot of bloat to Chalk. You can achieve the same by using the color-convert package.
    • The tagged template literal support moved into a separate package: chalk-template (#524) c987c61
    -import chalk from 'chalk';
    +import chalkTemplate from 'chalk-template';
    

    -chalk2 + 3 = {bold ${2 + 3}}; +chalkTemplate2 + 3 = {bold ${2 + 3}};

    Improvements

    • Bundle dependencies 04fdbd6
      • This means Chalk no longer has any dependencies 🎉

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • chore(deps-dev): bump @types/jest from 27.5.2 to 29.1.2

    chore(deps-dev): bump @types/jest from 27.5.2 to 29.1.2

    Bumps @types/jest from 27.5.2 to 29.1.2.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • chore(deps-dev): bump chalk from 4.1.2 to 5.1.0

    chore(deps-dev): bump chalk from 4.1.2 to 5.1.0

    Bumps chalk from 4.1.2 to 5.1.0.

    Release notes

    Sourced from chalk's releases.

    v5.1.0

    • Expose style names (#566) d7d7571

    https://github.com/chalk/chalk/compare/v5.0.1...v5.1.0

    v5.0.1

    • Add main field to package.json for backwards compatibility with some developer tools 85f7e96

    https://github.com/chalk/chalk/compare/v5.0.0...v5.0.1

    v5.0.0

    Breaking

    • This package is now pure ESM. Please read this.
      • If you use TypeScript, you need to use TypeScript 4.7 or later. Why.
      • If you use a bundler, make sure it supports ESM and that you have correctly configured it for ESM.
      • The Chalk issue tracker is not a support channel for your favorite build/bundler tool.
      • It's totally fine to stay on Chalk v4. It's been stable for years.
    • Require Node.js 12.20 fa16f4e
    • Move some properties off the default export to individual named exports:
      • chalk.InstanceChalk
      • chalk.supportsColorsupportsColor
      • chalk.stderrchalkStderr
      • chalk.stderr.supportsColorsupportsColorStderr
    • Remove .keyword(), .hsl(), .hsv(), .hwb(), and .ansi() coloring methods (#433) 4cf2e40
      • These were not commonly used and added a lot of bloat to Chalk. You can achieve the same by using the color-convert package.
    • The tagged template literal support moved into a separate package: chalk-template (#524) c987c61
    -import chalk from 'chalk';
    +import chalkTemplate from 'chalk-template';
    

    -chalk2 + 3 = {bold ${2 + 3}}; +chalkTemplate2 + 3 = {bold ${2 + 3}};

    Improvements

    https://github.com/chalk/chalk/compare/v4.1.0...v5.0.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • typescript 引用报错

    typescript 引用报错

    在 ts 工程中,这么写会报错

    import gcoord from 'gcoord';
    

    编译出来的代码会发现 gcoord 找不到

    Cannot read properties of undefined (reading 'transform')
    

    必须改成这样才行

    import * as gcoord from 'gcoord';
    

    改成这样后,语法提示又出错了。比较别扭,不知道是哪里的问题。

    opened by zzswang 3
  • chore(deps-dev): bump eslint from 7.32.0 to 8.31.0

    chore(deps-dev): bump eslint from 7.32.0 to 8.31.0

    Bumps eslint from 7.32.0 to 8.31.0.

    Release notes

    Sourced from eslint's releases.

    v8.31.0

    Features

    • 52c7c73 feat: check assignment patterns in no-underscore-dangle (#16693) (Milos Djermanovic)
    • b401cde feat: add options to check destructuring in no-underscore-dangle (#16006) (Morten Kaltoft)
    • 30d0daf feat: group properties with values in parentheses in key-spacing (#16677) (Francesco Trotta)

    Bug Fixes

    • 35439f1 fix: correct syntax error in prefer-arrow-callback autofix (#16722) (Francesco Trotta)
    • 87b2470 fix: new instance of FlatESLint should load latest config file version (#16608) (Milos Djermanovic)

    Documentation

    • 4339dc4 docs: Update README (GitHub Actions Bot)
    • 4e4049c docs: optimize code block structure (#16669) (Sam Chen)
    • 54a7ade docs: do not escape code blocks of formatters examples (#16719) (Sam Chen)
    • e5ecfef docs: Add function call example for no-undefined (#16712) (Elliot Huffman)
    • a3262f0 docs: Add mastodon link (#16638) (Amaresh S M)
    • a14ccf9 docs: clarify files property (#16709) (Sam Chen)
    • 3b29eb1 docs: fix npm link (#16710) (Abdullah Osama)
    • a638673 docs: fix search bar focus on Esc (#16700) (Shanmughapriyan S)
    • f62b722 docs: country flag missing in windows (#16698) (Shanmughapriyan S)
    • 4d27ec6 docs: display zh-hans in the docs language switcher (#16686) (Percy Ma)
    • 8bda20e docs: remove manually maintained anchors (#16685) (Percy Ma)
    • b68440f docs: User Guide Getting Started expansion (#16596) (Ben Perlmutter)

    Chores

    • 65d4e24 chore: Upgrade @​eslint/eslintrc@​1.4.1 (#16729) (Brandon Mills)
    • 8d93081 chore: fix CI failure (#16721) (Sam Chen)
    • 8f17247 chore: Set up automatic updating of README (#16717) (Nicholas C. Zakas)
    • 4cd87cb ci: bump actions/stale from 6 to 7 (#16713) (dependabot[bot])
    • fd20c75 chore: sort package.json scripts in alphabetical order (#16705) (Darius Dzien)
    • 10a5c78 chore: update ignore patterns in eslint.config.js (#16678) (Milos Djermanovic)

    v8.30.0

    Features

    • 075ef2c feat: add suggestion for no-return-await (#16637) (Daniel Bartholomae)
    • 7190d98 feat: update globals (#16654) (Sébastien Règne)

    Bug Fixes

    • 1a327aa fix: Ensure flat config unignores work consistently like eslintrc (#16579) (Nicholas C. Zakas)
    • 9b8bb72 fix: autofix recursive functions in no-var (#16611) (Milos Djermanovic)

    Documentation

    • 6a8cd94 docs: Clarify Discord info in issue template config (#16663) (Nicholas C. Zakas)
    • ad44344 docs: CLI documentation standardization (#16563) (Ben Perlmutter)
    • 293573e docs: fix broken line numbers (#16606) (Sam Chen)
    • fa2c64b docs: use relative links for internal links (#16631) (Percy Ma)
    • 75276c9 docs: reorder options in no-unused-vars (#16625) (Milos Djermanovic)
    • 7276fe5 docs: Fix anchor in URL (#16628) (Karl Horky)
    • 6bef135 docs: don't apply layouts to html formatter example (#16591) (Tanuj Kanti)
    • dfc7ec1 docs: Formatters page updates (#16566) (Ben Perlmutter)

    ... (truncated)

    Changelog

    Sourced from eslint's changelog.

    v8.31.0 - December 31, 2022

    • 65d4e24 chore: Upgrade @​eslint/eslintrc@​1.4.1 (#16729) (Brandon Mills)
    • 35439f1 fix: correct syntax error in prefer-arrow-callback autofix (#16722) (Francesco Trotta)
    • 87b2470 fix: new instance of FlatESLint should load latest config file version (#16608) (Milos Djermanovic)
    • 8d93081 chore: fix CI failure (#16721) (Sam Chen)
    • 4339dc4 docs: Update README (GitHub Actions Bot)
    • 8f17247 chore: Set up automatic updating of README (#16717) (Nicholas C. Zakas)
    • 4e4049c docs: optimize code block structure (#16669) (Sam Chen)
    • 54a7ade docs: do not escape code blocks of formatters examples (#16719) (Sam Chen)
    • 52c7c73 feat: check assignment patterns in no-underscore-dangle (#16693) (Milos Djermanovic)
    • e5ecfef docs: Add function call example for no-undefined (#16712) (Elliot Huffman)
    • a3262f0 docs: Add mastodon link (#16638) (Amaresh S M)
    • 4cd87cb ci: bump actions/stale from 6 to 7 (#16713) (dependabot[bot])
    • a14ccf9 docs: clarify files property (#16709) (Sam Chen)
    • 3b29eb1 docs: fix npm link (#16710) (Abdullah Osama)
    • fd20c75 chore: sort package.json scripts in alphabetical order (#16705) (Darius Dzien)
    • a638673 docs: fix search bar focus on Esc (#16700) (Shanmughapriyan S)
    • f62b722 docs: country flag missing in windows (#16698) (Shanmughapriyan S)
    • 4d27ec6 docs: display zh-hans in the docs language switcher (#16686) (Percy Ma)
    • 8bda20e docs: remove manually maintained anchors (#16685) (Percy Ma)
    • b401cde feat: add options to check destructuring in no-underscore-dangle (#16006) (Morten Kaltoft)
    • b68440f docs: User Guide Getting Started expansion (#16596) (Ben Perlmutter)
    • 30d0daf feat: group properties with values in parentheses in key-spacing (#16677) (Francesco Trotta)
    • 10a5c78 chore: update ignore patterns in eslint.config.js (#16678) (Milos Djermanovic)

    v8.30.0 - December 16, 2022

    • f2c4737 chore: upgrade @​eslint/eslintrc@​1.4.0 (#16675) (Milos Djermanovic)
    • 1a327aa fix: Ensure flat config unignores work consistently like eslintrc (#16579) (Nicholas C. Zakas)
    • 075ef2c feat: add suggestion for no-return-await (#16637) (Daniel Bartholomae)
    • ba74253 chore: standardize npm script names per #14827 (#16315) (Patrick McElhaney)
    • 6a8cd94 docs: Clarify Discord info in issue template config (#16663) (Nicholas C. Zakas)
    • 0d9af4c ci: fix npm v9 problem with file: (#16664) (Milos Djermanovic)
    • 7190d98 feat: update globals (#16654) (Sébastien Règne)
    • ad44344 docs: CLI documentation standardization (#16563) (Ben Perlmutter)
    • 90c9219 refactor: migrate off deprecated function-style rules in all tests (#16618) (Bryan Mishkin)
    • 9b8bb72 fix: autofix recursive functions in no-var (#16611) (Milos Djermanovic)
    • 293573e docs: fix broken line numbers (#16606) (Sam Chen)
    • fa2c64b docs: use relative links for internal links (#16631) (Percy Ma)
    • 75276c9 docs: reorder options in no-unused-vars (#16625) (Milos Djermanovic)
    • 7276fe5 docs: Fix anchor in URL (#16628) (Karl Horky)
    • 6bef135 docs: don't apply layouts to html formatter example (#16591) (Tanuj Kanti)
    • dfc7ec1 docs: Formatters page updates (#16566) (Ben Perlmutter)
    • 8ba124c docs: update the prefer-const example (#16607) (Pavel)
    • e6cb05a docs: fix css leaking (#16603) (Sam Chen)

    v8.29.0 - December 2, 2022

    • 0311d81 docs: Configuring Plugins page intro, page tweaks, and rename (#16534) (Ben Perlmutter)

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.5

    chore(deps-dev): bump @types/jest from 27.5.2 to 29.2.5

    Bumps @types/jest from 27.5.2 to 29.2.5.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • chore(deps-dev): bump chalk from 4.1.2 to 5.2.0

    chore(deps-dev): bump chalk from 4.1.2 to 5.2.0

    Bumps chalk from 4.1.2 to 5.2.0.

    Release notes

    Sourced from chalk's releases.

    v5.2.0

    • Improve Deno compatibility (#579) 7443e9f
    • Detect true-color support for GitHub Actions (#579) 7443e9f
    • Detect true-color support for Kitty terminal (#579) 7443e9f
    • Fix test for Azure DevOps environment (#579) 7443e9f

    https://github.com/chalk/chalk/compare/v5.1.2...v5.2.0

    v5.1.2

    • Fix exported styles names (#569) a34bcf6

    https://github.com/chalk/chalk/compare/v5.1.1...v5.1.2

    v5.1.1

    • Improved the names of exports introduced in 5.1.0 (#567) 6e0df05
      • We of course preserved the old names.

    https://github.com/chalk/chalk/compare/v5.1.0...v5.1.1

    v5.1.0

    • Expose style names (#566) d7d7571

    https://github.com/chalk/chalk/compare/v5.0.1...v5.1.0

    v5.0.1

    • Add main field to package.json for backwards compatibility with some developer tools 85f7e96

    https://github.com/chalk/chalk/compare/v5.0.0...v5.0.1

    v5.0.0

    Breaking

    • This package is now pure ESM. Please read this.
      • If you use TypeScript, you need to use TypeScript 4.7 or later. Why.
      • If you use a bundler, make sure it supports ESM and that you have correctly configured it for ESM.
      • The Chalk issue tracker is not a support channel for your favorite build/bundler tool.
      • It's totally fine to stay on Chalk v4. It's been stable for years.
    • Require Node.js 12.20 fa16f4e
    • Move some properties off the default export to individual named exports:
      • chalk.InstanceChalk
      • chalk.supportsColorsupportsColor
      • chalk.stderrchalkStderr
      • chalk.stderr.supportsColorsupportsColorStderr
    • Remove .keyword(), .hsl(), .hsv(), .hwb(), and .ansi() coloring methods (#433) 4cf2e40
      • These were not commonly used and added a lot of bloat to Chalk. You can achieve the same by using the color-convert package.
    • The tagged template literal support moved into a separate package: chalk-template (#524) c987c61
    -import chalk from 'chalk';
    +import chalkTemplate from 'chalk-template';
    

    </tr></table>

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • chore(deps-dev): bump lint-staged from 11.2.6 to 13.1.0

    chore(deps-dev): bump lint-staged from 11.2.6 to 13.1.0

    Bumps lint-staged from 11.2.6 to 13.1.0.

    Release notes

    Sourced from lint-staged's releases.

    v13.1.0

    13.1.0 (2022-12-04)

    Features

    • expose cli entrance from "lint-staged/bin" (#1237) (eabf1d2)

    v13.0.4

    13.0.4 (2022-11-25)

    Bug Fixes

    • deps: update all dependencies (336f3b5)
    • deps: update all dependencies (ec995e5)

    v13.0.3

    13.0.3 (2022-06-24)

    Bug Fixes

    • correctly handle git stash when using MSYS2 (#1178) (0d627a5)

    v13.0.2

    13.0.2 (2022-06-16)

    Bug Fixes

    • use new --diff and --diff-filter options when checking task modifications (1a5a66a)

    v13.0.1

    13.0.1 (2022-06-08)

    Bug Fixes

    • correct spelling of "0 files" (f27f1d4)
    • suppress error from process.kill when killing tasks on failure (f2c6bdd)
    • deps: update pidtree@^0.6.0 to fix screen size error in WSL (1a77e42)
    • ignore "No matching pid found" error (cb8a432)
    • prevent possible race condition when killing tasks on failure (bc92aff)

    Performance Improvements

    • use EventsEmitter instead of setInterval for killing tasks on failure (c508b46)

    ... (truncated)

    Commits
    • eabf1d2 feat: expose cli entrance from "lint-staged/bin" (#1237)
    • a987e6a docs: add note about multiple configs files to README
    • c4fb7b8 docs: add note about git hook TTY to README
    • e2bfce1 test: remove Windows snapshot workaround
    • 81ea7fd test: allow file protocol in git submodule test
    • 3ea9b7e test: update Jest snapshot format
    • 0c635c7 ci: install latest npm for older Node.js versions
    • 5f1a00e ci: bump GitHub Actions' versions
    • 336f3b5 fix(deps): update all dependencies
    • ec995e5 fix(deps): update all dependencies
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • chore(deps-dev): bump rollup-plugin-typescript2 from 0.31.2 to 0.34.1

    chore(deps-dev): bump rollup-plugin-typescript2 from 0.31.2 to 0.34.1

    Bumps rollup-plugin-typescript2 from 0.31.2 to 0.34.1.

    Release notes

    Sourced from rollup-plugin-typescript2's releases.

    0.34.1

    What's Changed

    Full Changelog: https://github.com/ezolenko/rollup-plugin-typescript2/compare/0.34.0...0.34.1

    0.34.0

    Bugfixes

    • fix: handle all type-only imports by piping TS imports by @​agilgur5 in #406
      • If you have ever had issues with some files not being type-checked or not generating declarations, this should conclusively fix all such issues. This type of issue used to occur if you had a type-only / interface-only / emit-less file, i.e. a file with only TS types and interfaces that would produce no JS.
      • NOTE: This requires Rollup version 2.60.0+ as it requires the use of this.load
    • fix(dx): remove extra quote in emitDeclarationOnly log statement by @​agilgur5 in #412

    Docs

    • docs: add a simple CHANGELOG.md that references GH releases by @​agilgur5 in #419
      • i.e. it references this page

    Internal (testing, refactors)

    ... (truncated)

    Commits
    • f6db596 fix: don't resolve filtered files (#428)
    • 3ef3289 fix: add compatibility checks w/ semver (#424)
    • a1ae42b test: increase no-errors integration timeout to 20s (#425)
    • ffb562d clean(deps): remove unused @types/resolve (#423)
    • e8f59ef fix: don't error out while catching a buildStart error (#422)
    • 0b99f8e - build for 34.0
    • ba26293 refactor: consolidate diagnostics funcs into single file (#416)
    • e98e0ed docs: add a simple CHANGELOG.md that references GH releases (#419)
    • 560ed8d fix: handle all type-only imports by piping TS imports (#406)
    • c6be0eb refactor(cache): simplify creating / using the cache var (#415)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
Releases(v0.3.2)
Owner
null