@ultirequiem/drive-link 1.0.0 → 2.0.0

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/lib/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ export interface DriveOptions {
2
+ /**
3
+ A Drive api key that can be used to exceed the download limit of 100MB.
4
+ */
5
+ apiKey?: string;
6
+ }
7
+ /**
8
+ Generate a Google Drive direct download link based on the URL or ID.
9
+
10
+ @param URLorID The URL or ID of the drive content.
11
+
12
+ @example
13
+ ```javascript
14
+ driveLink(
15
+ "https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
16
+ );
17
+
18
+ //=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
19
+ ```
20
+ */
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,13 +17,16 @@ 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
- driveLink('https://drive.google.com/file/d/1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk/view?usp=sharing');
26
- //=> 'https://drive.google.com/uc?export=download&id=1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk'
25
+ driveLink(
26
+ "https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
27
+ );
28
+
29
+ //=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
27
30
  ```
28
31
  */
29
32
  export function driveLink(URLorID, { apiKey } = {}) {
package/package.json CHANGED
@@ -1,39 +1,45 @@
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.0",
8
- "homepage": "https://ulti.js.org/drive_link",
9
- "license": "MIT",
10
- "funding": {
11
- "type": "patreon",
12
- "url": "https://www.patreon.com/ultirequiem"
13
- },
14
- "repository": "github:ultirequiem/drive-link",
15
- "bugs": {
16
- "url": "https://github.com/ultirequiem/drive-link/issues",
17
- "email": "eliaz.bobadilladev@gmail.com"
18
- },
19
- "keywords": [
20
- "drive",
21
- "google"
22
- ],
3
+ "version": "2.0.0",
4
+ "description": "",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
23
8
  "exports": {
24
9
  ".": {
25
- "import": "./esm/mod.js",
26
- "require": "./script/mod.js",
27
- "types": "./types/mod.d.ts"
10
+ "types": "./lib/index.d.ts",
11
+ "import": "./lib/index.js"
28
12
  }
29
13
  },
14
+ "files": [
15
+ "lib/**/*"
16
+ ],
17
+ "engines": {
18
+ "node": ">=20"
19
+ },
20
+ "keywords": [],
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/UltiRequiem/drive_link.git"
25
+ },
30
26
  "scripts": {
31
- "test": "node test_runner.js"
27
+ "build": "tsc",
28
+ "lint": "eslint 'src/**/*.ts' && prettier --check 'src/**/*.ts'",
29
+ "fmt": "prettier --write 'src/**/*.ts'",
30
+ "test": "vitest run",
31
+ "test:coverage": "vitest run --coverage"
32
32
  },
33
- "dependencies": {},
34
33
  "devDependencies": {
35
- "@types/node": "16.11.26",
36
- "chalk": "4.1.2",
37
- "@deno/shim-deno": "~0.4.3"
38
- }
39
- }
34
+ "@types/node": "^26.6.5",
35
+ "@vitest/coverage-v8": "^5.0.5",
36
+ "eslint": "^10.13.0",
37
+ "eslint-plugin-tsdoc": "^0.5.4",
38
+ "eslint-plugin-unicorn": "^78.0.0",
39
+ "prettier": "^3.9.10",
40
+ "typescript": "^6.0.3",
41
+ "typescript-eslint": "^8.72.0",
42
+ "vitest": "^5.0.5"
43
+ },
44
+ "packageManager": "pnpm@12.6.0"
45
+ }
package/readme.md ADDED
@@ -0,0 +1,47 @@
1
+ # Drive Link
2
+
3
+ [![npm](https://img.shields.io/npm/v/@ultirequiem/drive-link?logo=npm&color=cb3837)](https://www.npmjs.com/package/@ultirequiem/drive-link)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@ultirequiem/drive-link?color=cb3837)](https://www.npmjs.com/package/@ultirequiem/drive-link)
5
+ [![CI](https://github.com/UltiRequiem/drive_link/actions/workflows/ci.yaml/badge.svg)](https://github.com/UltiRequiem/drive_link/actions/workflows/ci.yaml)
6
+ [![codecov](https://codecov.io/gh/UltiRequiem/drive_link/graph/badge.svg)](https://codecov.io/gh/UltiRequiem/drive_link)
7
+
8
+ Generate a [Google Drive](https://google.com/drive) direct download link based
9
+ on the URL or ID.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npm install @ultirequiem/drive-link
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ESM only, types included: the same import works in Node.js, Bun and browsers.
20
+
21
+ > Check [platforms](./platforms.md) for other runtime options.
22
+
23
+ ## Support
24
+
25
+ Open an Issue, I will check it as soon as possible 👀
26
+
27
+ If you want to hurry me up a bit
28
+ [send me a tweet](https://twitter.com/UltiRequiem) 😆
29
+
30
+ Don't forget to star the repo ⭐
31
+
32
+ ## Authors
33
+
34
+ [Eliaz Bobadilla](https://ultirequiem.com) - Creator and Maintainer 💪
35
+
36
+ See also the full list of
37
+ [contributors](https://github.com/UltiRequiem/drive_link/contributors) who
38
+ participated in this project ✨
39
+
40
+ ## Versioning
41
+
42
+ We use [Semantic Versioning](http://semver.org). For the versions available, see
43
+ the [tags](https://github.com/UltiRequiem/drive_link/tags) 🏷️
44
+
45
+ ## Licence
46
+
47
+ 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/1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk/view?usp=sharing",
20
- );
21
- //=> 'https://drive.google.com/uc?export=download&id=1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk'
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,45 +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('https://drive.google.com/file/d/1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk/view?usp=sharing');
29
- //=> 'https://drive.google.com/uc?export=download&id=1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk'
30
- ```
31
- */
32
- function driveLink(URLorID, { apiKey } = {}) {
33
- if (typeof URLorID !== "string") {
34
- throw new TypeError("Invalid URL provided.");
35
- }
36
- if (typeof apiKey === "string" && !alphanumericRegex.test(apiKey)) {
37
- throw new TypeError("Invalid API key provided.");
38
- }
39
- const id = extractId(URLorID.trim());
40
- const parsedKey = apiKey?.trim();
41
- return parsedKey
42
- ? `https://www.googleapis.com/drive/v3/files/${id}?alt=media&key=${parsedKey}`
43
- : `https://drive.google.com/uc?export=download&id=${id}`;
44
- }
45
- exports.driveLink = driveLink;
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
package/types/mod.d.ts DELETED
@@ -1,18 +0,0 @@
1
- export interface DriveOptions {
2
- /**
3
- A Drive api key that can be used to exceed the download limit of 100MB.
4
- */
5
- apiKey?: string;
6
- }
7
- /**
8
- Generate a Google Drive direct download link based on the URL or ID.
9
-
10
- @param URLorID The URL or ID of the drive content.
11
-
12
- @example
13
- ```javascript
14
- driveLink('https://drive.google.com/file/d/1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk/view?usp=sharing');
15
- //=> 'https://drive.google.com/uc?export=download&id=1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk'
16
- ```
17
- */
18
- export declare function driveLink(URLorID: string, { apiKey }?: DriveOptions): string;
File without changes