@ultirequiem/drive-link 1.0.1 → 2.0.1

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.
@@ -6,16 +6,17 @@ export interface DriveOptions {
6
6
  }
7
7
  /**
8
8
  Generate a Google Drive direct download link based on the URL or ID.
9
-
9
+
10
10
  @param URLorID The URL or ID of the drive content.
11
-
11
+
12
12
  @example
13
13
  ```javascript
14
14
  driveLink(
15
15
  "https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
16
16
  );
17
-
17
+
18
18
  //=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
19
19
  ```
20
20
  */
21
21
  export declare function driveLink(URLorID: string, { apiKey }?: DriveOptions): string;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,YAAY;IAC3B;;MAEE;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;EAaE;AACF,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,GAAE,YAAiB,UAgBvE"}
@@ -17,15 +17,15 @@ function extractId(urlOrId) {
17
17
  }
18
18
  /**
19
19
  Generate a Google Drive direct download link based on the URL or ID.
20
-
20
+
21
21
  @param URLorID The URL or ID of the drive content.
22
-
22
+
23
23
  @example
24
24
  ```javascript
25
25
  driveLink(
26
26
  "https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
27
27
  );
28
-
28
+
29
29
  //=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
30
30
  ```
31
31
  */
package/package.json CHANGED
@@ -1,39 +1,51 @@
1
1
  {
2
- "module": "./esm/mod.js",
3
- "main": "./script/mod.js",
4
- "types": "./types/mod.d.ts",
5
2
  "name": "@ultirequiem/drive-link",
6
- "description": "Generate a Google Drive direct download link based on the URL or ID.",
7
- "version": "1.0.1",
8
- "homepage": "https://ulti.js.org/drive_link",
9
- "license": "MIT",
10
- "funding": {
11
- "type": "patreon",
12
- "url": "https://www.patreon.com/ultirequiem"
3
+ "version": "2.0.1",
4
+ "description": "Turn a Google Drive share link into a direct download link.",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "import": "./lib/index.js"
12
+ }
13
13
  },
14
- "repository": "github:ultirequiem/drive_link",
15
- "bugs": {
16
- "url": "https://github.com/ultirequiem/drive_link/issues",
17
- "email": "eliaz.bobadilladev@gmail.com"
14
+ "files": [
15
+ "lib/**/*"
16
+ ],
17
+ "engines": {
18
+ "node": ">=20"
18
19
  },
19
20
  "keywords": [
20
- "drive",
21
- "google"
21
+ "google-drive",
22
+ "download",
23
+ "link",
24
+ "esm",
25
+ "typescript"
22
26
  ],
23
- "exports": {
24
- ".": {
25
- "import": "./esm/mod.js",
26
- "require": "./script/mod.js",
27
- "types": "./types/mod.d.ts"
28
- }
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/UltiRequiem/drive_link.git"
29
31
  },
30
32
  "scripts": {
31
- "test": "node test_runner.js"
33
+ "build": "tsc",
34
+ "lint": "eslint 'src/**/*.ts' && prettier --check 'src/**/*.ts'",
35
+ "fmt": "prettier --write 'src/**/*.ts'",
36
+ "test": "vitest run",
37
+ "test:coverage": "vitest run --coverage"
32
38
  },
33
- "dependencies": {},
34
39
  "devDependencies": {
35
- "@types/node": "16.11.26",
36
- "chalk": "4.1.2",
37
- "@deno/shim-deno": "~0.4.3"
38
- }
39
- }
40
+ "@types/node": "^26.6.5",
41
+ "@vitest/coverage-v8": "^5.0.5",
42
+ "eslint": "^10.13.0",
43
+ "eslint-plugin-tsdoc": "^0.5.4",
44
+ "eslint-plugin-unicorn": "^78.0.0",
45
+ "prettier": "^3.9.10",
46
+ "typescript": "^6.0.3",
47
+ "typescript-eslint": "^8.72.0",
48
+ "vitest": "^5.0.5"
49
+ },
50
+ "packageManager": "pnpm@12.6.0"
51
+ }
package/readme.md ADDED
@@ -0,0 +1,48 @@
1
+ # Drive Link
2
+
3
+ Generate a [Google Drive](https://google.com/drive) direct download link based
4
+
5
+ [![npm](https://img.shields.io/npm/v/@ultirequiem/drive-link?logo=npm&color=cb3837)](https://www.npmjs.com/package/@ultirequiem/drive-link)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@ultirequiem/drive-link?color=cb3837)](https://www.npmjs.com/package/@ultirequiem/drive-link)
7
+ [![CI](https://github.com/UltiRequiem/drive_link/actions/workflows/ci.yaml/badge.svg)](https://github.com/UltiRequiem/drive_link/actions/workflows/ci.yaml)
8
+ [![codecov](https://codecov.io/gh/UltiRequiem/drive_link/graph/badge.svg)](https://codecov.io/gh/UltiRequiem/drive_link)
9
+
10
+ on the URL or ID.
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ npm install @ultirequiem/drive-link
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ESM only, types included: the same import works in Node.js, Bun and browsers.
21
+
22
+ > Check [platforms](./platforms.md) for other runtime options.
23
+
24
+ ## Support
25
+
26
+ Open an Issue, I will check it as soon as possible 👀
27
+
28
+ If you want to hurry me up a bit
29
+ [send me a tweet](https://twitter.com/UltiRequiem) 😆
30
+
31
+ Don't forget to star the repo ⭐
32
+
33
+ ## Authors
34
+
35
+ [Eliaz Bobadilla](https://ultirequiem.com) - Creator and Maintainer 💪
36
+
37
+ See also the full list of
38
+ [contributors](https://github.com/UltiRequiem/drive_link/contributors) who
39
+ participated in this project ✨
40
+
41
+ ## Versioning
42
+
43
+ We use [Semantic Versioning](http://semver.org). For the versions available, see
44
+ the [tags](https://github.com/UltiRequiem/drive_link/tags) 🏷️
45
+
46
+ ## Licence
47
+
48
+ Licensed under the MIT License 📄
package/README.md DELETED
@@ -1,72 +0,0 @@
1
- # Drive Link
2
-
3
- [![Code Coverage](https://codecov.io/gh/UltiRequiem/drive_link/branch/main/graph/badge.svg)](https://codecov.io/gh/UltiRequiem/drive_link)
4
- [![Deno Doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/drive_link/mod.ts)
5
-
6
- Generate a [Google Drive](https://google.com/drive) direct download link based
7
- on the URL or ID.
8
-
9
- ## Usage
10
-
11
- The API is the same on all this platforms ✔️
12
-
13
- ### [Deno 🦕](https://deno.land/x/drive_link)
14
-
15
- ```javascript
16
- import { driveLink } from "https://deno.land/x/drive_link/mod.ts";
17
-
18
- driveLink(
19
- "https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
20
- );
21
- //=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
22
- ```
23
-
24
- ### [Node.js 🐢🚀](https://npmjs.com/package/@ultirequiem/drive-link)
25
-
26
- ```javascript
27
- import { driveLink } from "@ultirequiem/drive-link";
28
- ```
29
-
30
- ### [Browser 🌐](https://developer.mozilla.org/en-US/docs/Glossary/Browser)
31
-
32
- You can use any [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) 🔥
33
-
34
- Eg 👉
35
- [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) ↔️
36
- [SkyPack](https://cdn.skypack.dev/@ultirequiem/drive_link) 🆚
37
- [Script Tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
38
- ↔️ [JSDelivr](https://cdn.jsdelivr.net/npm/@ultirequiem/drive_link)
39
-
40
- ## Documentation
41
-
42
- Is hosted on
43
- [Deno Doc](https://doc.deno.land/https://deno.land/x/drive_link/mod.ts) 📄
44
-
45
- ## Support
46
-
47
- Open an Issue, I will check it a soon as possible 👀
48
-
49
- If you want to hurry me up a bit
50
- [send me a tweet](https://twitter.com/UltiRequiem) 😆
51
-
52
- Consider [supporting me on Patreon](https://patreon.com/UltiRequiem) if you like
53
- my work 🙏
54
-
55
- Don't forget to start the repo ⭐
56
-
57
- ## Authors
58
-
59
- [Eliaz Bobadilla](https://ultirequiem.com) - Creator and Maintainer 💪
60
-
61
- See also the full list of
62
- [contributors](https://github.com/UltiRequiem/drive_link/contributors) who
63
- participated in this project ✨
64
-
65
- ## Versioning
66
-
67
- We use [Semantic Versioning](http://semver.org). For the versions available, see
68
- the [tags](https://github.com/UltiRequiem/drive_link/tags) 🏷️
69
-
70
- ## Licence
71
-
72
- Licensed under the MIT License 📄
package/esm/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
package/script/mod.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.driveLink = void 0;
4
- const formatRegexes = [
5
- /https:\/\/drive\.google\.com\/file\/d\/(?<id>.*?)\/(?:edit|view)\?usp=sharing/,
6
- /https:\/\/drive\.google\.com\/open\?id=(?<id>.*?)$/,
7
- ];
8
- const alphanumericRegex = /^[\w-]+$/;
9
- function extractId(urlOrId) {
10
- for (const format of formatRegexes) {
11
- if (format.test(urlOrId)) {
12
- const result = format.exec(urlOrId);
13
- return result?.groups?.id;
14
- }
15
- }
16
- if (alphanumericRegex.test(urlOrId)) {
17
- return urlOrId;
18
- }
19
- throw new Error("Invalid URL provided.");
20
- }
21
- /**
22
- Generate a Google Drive direct download link based on the URL or ID.
23
-
24
- @param URLorID The URL or ID of the drive content.
25
-
26
- @example
27
- ```javascript
28
- driveLink(
29
- "https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
30
- );
31
-
32
- //=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
33
- ```
34
- */
35
- function driveLink(URLorID, { apiKey } = {}) {
36
- if (typeof URLorID !== "string") {
37
- throw new TypeError("Invalid URL provided.");
38
- }
39
- if (typeof apiKey === "string" && !alphanumericRegex.test(apiKey)) {
40
- throw new TypeError("Invalid API key provided.");
41
- }
42
- const id = extractId(URLorID.trim());
43
- const parsedKey = apiKey?.trim();
44
- return parsedKey
45
- ? `https://www.googleapis.com/drive/v3/files/${id}?alt=media&key=${parsedKey}`
46
- : `https://drive.google.com/uc?export=download&id=${id}`;
47
- }
48
- exports.driveLink = driveLink;
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
File without changes