@quantavoxel/latlng-extract 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +148 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/tes.d.ts +2 -0
- package/dist/tes.d.ts.map +1 -0
- package/dist/tes.js +36 -0
- package/dist/tes.js.map +1 -0
- package/dist/type.d.ts +19 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +2 -0
- package/dist/type.js.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wawan Julianto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# @quantavoxel/latlng-extract
|
|
2
|
+
|
|
3
|
+
Extract latitude and longitude coordinates from Google Maps short links and full URLs.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@quantavoxel/latlng-extract)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { extract } from "@quantavoxel/latlng-extract";
|
|
11
|
+
|
|
12
|
+
const result = await extract("https://maps.app.goo.gl/ETAXbutPiLGMj2bA9");
|
|
13
|
+
// { lat: -5.1477, lng: 119.4327, resolvedUrl: "https://www.google.com/maps/..." }
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Resolves Google Maps short links (`maps.app.goo.gl`, `goo.gl/maps`)
|
|
21
|
+
- Supports full Google Maps URLs (`maps.google.com`, `www.google.com/maps`)
|
|
22
|
+
- Typed error codes for clean error handling
|
|
23
|
+
- Configurable timeout, User-Agent, and max redirects
|
|
24
|
+
- Zero config — works out of the box
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @quantavoxel/latlng-extract
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### Basic
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { extract } from "@quantavoxel/latlng-extract";
|
|
38
|
+
|
|
39
|
+
const result = await extract("https://maps.app.goo.gl/ETAXbutPiLGMj2bA9");
|
|
40
|
+
|
|
41
|
+
console.log(result.lat); // -5.1477
|
|
42
|
+
console.log(result.lng); // 119.4327
|
|
43
|
+
console.log(result.resolvedUrl); // https://www.google.com/maps/...
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### With options
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { extract } from "@quantavoxel/latlng-extract";
|
|
50
|
+
|
|
51
|
+
const result = await extract("https://maps.app.goo.gl/ETAXbutPiLGMj2bA9", {
|
|
52
|
+
timeout: 5000,
|
|
53
|
+
userAgent: "MyApp/1.0",
|
|
54
|
+
maxRedirects: 5,
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Error handling
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { extract } from "@quantavoxel/latlng-extract";
|
|
62
|
+
import type { ExtractError } from "@quantavoxel/latlng-extract";
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const result = await extract("https://maps.app.goo.gl/ETAXbutPiLGMj2bA9");
|
|
66
|
+
console.log(result);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
const e = err as ExtractError;
|
|
69
|
+
|
|
70
|
+
switch (e.code) {
|
|
71
|
+
case "INVALID_URL":
|
|
72
|
+
console.error("URL is not a valid Google Maps link");
|
|
73
|
+
break;
|
|
74
|
+
case "RESOLVE_FAILED":
|
|
75
|
+
console.error("Link is broken or expired");
|
|
76
|
+
break;
|
|
77
|
+
case "COORDS_NOT_FOUND":
|
|
78
|
+
console.error("Could not find coordinates in the resolved URL");
|
|
79
|
+
break;
|
|
80
|
+
case "TIMEOUT":
|
|
81
|
+
console.error("Request timed out");
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## API
|
|
88
|
+
|
|
89
|
+
### `extract(url, options?)`
|
|
90
|
+
|
|
91
|
+
Resolves a Google Maps URL and extracts its coordinates.
|
|
92
|
+
|
|
93
|
+
**Parameters**
|
|
94
|
+
|
|
95
|
+
| Parameter | Type | Required | Description |
|
|
96
|
+
|---|---|---|---|
|
|
97
|
+
| `url` | `string` | ✅ | Google Maps URL (short or full) |
|
|
98
|
+
| `options` | `ExtractOptions` | ❌ | Optional configuration |
|
|
99
|
+
|
|
100
|
+
**Returns** `Promise<ExtractResult>`
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### `ExtractResult`
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
interface ExtractResult {
|
|
108
|
+
lat: number; // Latitude
|
|
109
|
+
lng: number; // Longitude
|
|
110
|
+
resolvedUrl: string; // Final URL after redirect
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### `ExtractOptions`
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
interface ExtractOptions {
|
|
118
|
+
userAgent?: string; // Default: "Mozilla/5.0 (compatible; latlng-extract/1.0)"
|
|
119
|
+
timeout?: number; // In milliseconds. Default: 10000
|
|
120
|
+
maxRedirects?: number; // Default: 10
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `ExtractError`
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
interface ExtractError extends Error {
|
|
128
|
+
code: "INVALID_URL" | "RESOLVE_FAILED" | "COORDS_NOT_FOUND" | "TIMEOUT";
|
|
129
|
+
url: string; // The original URL passed to extract()
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Supported URL formats
|
|
134
|
+
|
|
135
|
+
| Format | Example |
|
|
136
|
+
|---|---|
|
|
137
|
+
| Short link | `https://maps.app.goo.gl/ETAXbutPiLGMj2bA9` |
|
|
138
|
+
| Legacy short link | `https://goo.gl/maps/abc123` |
|
|
139
|
+
| Full URL | `https://maps.google.com/maps?q=-5.1477,119.4327` |
|
|
140
|
+
| Full URL (www) | `https://www.google.com/maps/place/...@-5.1477,119.4327` |
|
|
141
|
+
|
|
142
|
+
## Requirements
|
|
143
|
+
|
|
144
|
+
- Node.js >= 18.0.0
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExtractResult, ExtractOptions, ExtractError } from "./type.ts";
|
|
2
|
+
export declare function extract(url: string, options?: ExtractOptions): Promise<ExtractResult>;
|
|
3
|
+
export type { ExtractResult, ExtractOptions, ExtractError };
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAmD7E,wBAAsB,OAAO,CAC3B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAkDxB;AAED,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
const COORD_PATTERNS = [
|
|
3
|
+
/@(-?\d+\.\d+),(-?\d+\.\d+)/, // @lat,lng
|
|
4
|
+
/!3d(-?\d+\.\d+)!4d(-?\d+\.\d+)/, // !3dLAT!4dLNG
|
|
5
|
+
/ll=(-?\d+\.\d+),(-?\d+\.\d+)/, // ll=lat,lng
|
|
6
|
+
/q=(-?\d+\.\d+),(-?\d+\.\d+)/, // q=lat,lng
|
|
7
|
+
/center=(-?\d+\.\d+),(-?\d+\.\d+)/, // center=lat,lng
|
|
8
|
+
];
|
|
9
|
+
const SUPPORTED_HOSTS = [
|
|
10
|
+
"maps.app.goo.gl",
|
|
11
|
+
"goo.gl",
|
|
12
|
+
"maps.google.com",
|
|
13
|
+
"www.google.com",
|
|
14
|
+
];
|
|
15
|
+
function createError(message, code, url) {
|
|
16
|
+
const err = new Error(message);
|
|
17
|
+
err.code = code;
|
|
18
|
+
err.url = url;
|
|
19
|
+
return err;
|
|
20
|
+
}
|
|
21
|
+
function isValidGoogleMapsUrl(url) {
|
|
22
|
+
try {
|
|
23
|
+
const { hostname, pathname } = new URL(url);
|
|
24
|
+
if (hostname === "goo.gl" && !pathname.startsWith("/maps"))
|
|
25
|
+
return false;
|
|
26
|
+
return SUPPORTED_HOSTS.includes(hostname);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function parseCoords(text) {
|
|
33
|
+
for (const pattern of COORD_PATTERNS) {
|
|
34
|
+
const match = text.match(pattern);
|
|
35
|
+
if (match) {
|
|
36
|
+
return {
|
|
37
|
+
lat: parseFloat(match[1]),
|
|
38
|
+
lng: parseFloat(match[2]),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
export async function extract(url, options = {}) {
|
|
45
|
+
const { userAgent = "Mozilla/5.0 (compatible; latlng-extract/1.0)", timeout = 10000, maxRedirects = 10, } = options;
|
|
46
|
+
if (!isValidGoogleMapsUrl(url)) {
|
|
47
|
+
throw createError(`Invalid or unsupported URL: "${url}"`, "INVALID_URL", url);
|
|
48
|
+
}
|
|
49
|
+
let resolvedUrl;
|
|
50
|
+
let responseText;
|
|
51
|
+
try {
|
|
52
|
+
const response = await axios.get(url, {
|
|
53
|
+
headers: { "User-Agent": userAgent },
|
|
54
|
+
timeout,
|
|
55
|
+
maxRedirects,
|
|
56
|
+
});
|
|
57
|
+
resolvedUrl = response.request?.res?.responseUrl ?? url;
|
|
58
|
+
responseText = typeof response.data === "string" ? response.data : "";
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (axios.isAxiosError(err) && err.code === "ECONNABORTED") {
|
|
62
|
+
throw createError(`Request timed out for "${url}"`, "TIMEOUT", url);
|
|
63
|
+
}
|
|
64
|
+
throw createError(`Failed to resolve URL: ${err.message}`, "RESOLVE_FAILED", url);
|
|
65
|
+
}
|
|
66
|
+
// Try resolved URL first (most reliable), then fallback to HTML body
|
|
67
|
+
const coords = parseCoords(resolvedUrl) ?? parseCoords(responseText);
|
|
68
|
+
if (!coords) {
|
|
69
|
+
throw createError(`Could not extract coordinates from "${resolvedUrl}"`, "COORDS_NOT_FOUND", url);
|
|
70
|
+
}
|
|
71
|
+
return { ...coords, resolvedUrl };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/tes.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tes.d.ts","sourceRoot":"","sources":["../src/tes.ts"],"names":[],"mappings":""}
|
package/dist/tes.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { extract } from "./index.js";
|
|
2
|
+
async function run() {
|
|
3
|
+
const urls = [
|
|
4
|
+
"https://maps.app.goo.gl/ETAXbutPiLGMj2bA9", // valid
|
|
5
|
+
"https://maps.app.goo.gl/123456", // invalid
|
|
6
|
+
"https://invalid-url.com", // not google maps
|
|
7
|
+
];
|
|
8
|
+
for (const url of urls) {
|
|
9
|
+
console.log(`\nTesting: ${url}`);
|
|
10
|
+
try {
|
|
11
|
+
const result = await extract(url);
|
|
12
|
+
console.log("✅ Success:", result);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
const e = err;
|
|
16
|
+
switch (e.code) {
|
|
17
|
+
case "INVALID_URL":
|
|
18
|
+
console.error("❌ Invalid URL:", e.message);
|
|
19
|
+
break;
|
|
20
|
+
case "RESOLVE_FAILED":
|
|
21
|
+
console.error("❌ URL not found or expired:", e.message);
|
|
22
|
+
break;
|
|
23
|
+
case "COORDS_NOT_FOUND":
|
|
24
|
+
console.error("❌ No coordinates found in:", e.url);
|
|
25
|
+
break;
|
|
26
|
+
case "TIMEOUT":
|
|
27
|
+
console.error("❌ Request timed out:", e.url);
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
console.error("❌ Unknown error:", e.message);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
run();
|
|
36
|
+
//# sourceMappingURL=tes.js.map
|
package/dist/tes.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tes.js","sourceRoot":"","sources":["../src/tes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,KAAK,UAAU,GAAG;IAChB,MAAM,IAAI,GAAG;QACX,2CAA2C,EAAE,QAAQ;QACrD,gCAAgC,EAAE,UAAU;QAC5C,yBAAyB,EAAE,kBAAkB;KAC9C,CAAC;IAEF,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC;QAEjC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;YAClC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,GAAmB,CAAC;YAE9B,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;gBACf,KAAK,aAAa;oBAChB,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;oBAC3C,MAAM;gBACR,KAAK,gBAAgB;oBACnB,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;oBACxD,MAAM;gBACR,KAAK,kBAAkB;oBACrB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;oBACnD,MAAM;gBACR,KAAK,SAAS;oBACZ,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;oBAC7C,MAAM;gBACR;oBACE,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,GAAG,EAAE,CAAC"}
|
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ExtractResult {
|
|
2
|
+
lat: number;
|
|
3
|
+
lng: number;
|
|
4
|
+
resolvedUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ExtractOptions {
|
|
7
|
+
/** Custom User-Agent header. Default: Mozilla/5.0 */
|
|
8
|
+
userAgent?: string;
|
|
9
|
+
/** Request timeout in milliseconds. Default: 10000 */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
/** Max redirects to follow. Default: 10 */
|
|
12
|
+
maxRedirects?: number;
|
|
13
|
+
}
|
|
14
|
+
export type SupportedUrl = "maps.app.goo.gl" | "goo.gl/maps" | "maps.google.com" | "www.google.com/maps";
|
|
15
|
+
export interface ExtractError extends Error {
|
|
16
|
+
code: "INVALID_URL" | "RESOLVE_FAILED" | "COORDS_NOT_FOUND" | "TIMEOUT";
|
|
17
|
+
url: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,aAAa,GACb,iBAAiB,GACjB,qBAAqB,CAAC;AAE1B,MAAM,WAAW,YAAa,SAAQ,KAAK;IACzC,IAAI,EAAE,aAAa,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,SAAS,CAAC;IACxE,GAAG,EAAE,MAAM,CAAC;CACb"}
|
package/dist/type.js
ADDED
package/dist/type.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quantavoxel/latlng-extract",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Extract latitude and longitude coordinates from Google Maps short links (maps.app.goo.gl)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"google-maps",
|
|
7
|
+
"coordinates",
|
|
8
|
+
"latitude",
|
|
9
|
+
"longitude",
|
|
10
|
+
"latlng",
|
|
11
|
+
"gps",
|
|
12
|
+
"maps",
|
|
13
|
+
"short-link",
|
|
14
|
+
"goo.gl",
|
|
15
|
+
"geolocation",
|
|
16
|
+
"extract"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://github.com/QuantaVoxel/latlng-extract#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/QuantaVoxel/latlng-extract/issues"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/QuantaVoxel/latlng-extract.git"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"author": "Quantavoxel <developer@quantavoxel.digital>",
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.cjs",
|
|
33
|
+
"types": "./dist/index.d.ts"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"main": "dist/index.cjs",
|
|
37
|
+
"types": "dist/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"dev": "tsx src/tes.ts",
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"lint": "tsc --noEmit"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"axios": "^1.7.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^20.0.0",
|
|
52
|
+
"tsx": "^4.22.4",
|
|
53
|
+
"typescript": "^5.4.0"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18.0.0"
|
|
57
|
+
},
|
|
58
|
+
"module": "dist/index.js",
|
|
59
|
+
"allowScripts": {
|
|
60
|
+
"esbuild@0.28.0": true
|
|
61
|
+
}
|
|
62
|
+
}
|