@muhgholy/next-drive 1.0.2 → 1.1.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.
- package/README.md +98 -1
- package/dist/client/index.css +50 -45
- package/dist/client/index.css.map +1 -1
- package/dist/client/index.d.ts +11 -3
- package/dist/client/index.js +78 -43
- package/dist/client/index.js.map +1 -1
- package/dist/client/styles.css +71 -0
- package/dist/{index-CIbbTroj.d.ts → index-C4pw1JjP.d.ts} +3 -1
- package/dist/server/index.d.ts +12 -3
- package/dist/server/index.js +33 -0
- package/dist/server/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
@layer base {
|
|
6
|
+
:root {
|
|
7
|
+
--background: 0 0% 100%;
|
|
8
|
+
--foreground: 222.2 84% 4.9%;
|
|
9
|
+
|
|
10
|
+
--card: 0 0% 100%;
|
|
11
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
12
|
+
|
|
13
|
+
--popover: 0 0% 100%;
|
|
14
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
15
|
+
|
|
16
|
+
--primary: 222.2 47.4% 11.2%;
|
|
17
|
+
--primary-foreground: 210 40% 98%;
|
|
18
|
+
|
|
19
|
+
--secondary: 210 40% 96.1%;
|
|
20
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
21
|
+
|
|
22
|
+
--muted: 210 40% 96.1%;
|
|
23
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
24
|
+
|
|
25
|
+
--accent: 210 40% 96.1%;
|
|
26
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
27
|
+
|
|
28
|
+
--destructive: 0 84.2% 60.2%;
|
|
29
|
+
--destructive-foreground: 210 40% 98%;
|
|
30
|
+
|
|
31
|
+
--border: 214.3 31.8% 91.4%;
|
|
32
|
+
--input: 214.3 31.8% 91.4%;
|
|
33
|
+
--ring: 222.2 84% 4.9%;
|
|
34
|
+
|
|
35
|
+
--radius: 0.5rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.dark {
|
|
39
|
+
--background: 222.2 84% 4.9%;
|
|
40
|
+
--foreground: 210 40% 98%;
|
|
41
|
+
|
|
42
|
+
--card: 222.2 84% 4.9%;
|
|
43
|
+
--card-foreground: 210 40% 98%;
|
|
44
|
+
|
|
45
|
+
--popover: 222.2 84% 4.9%;
|
|
46
|
+
--popover-foreground: 210 40% 98%;
|
|
47
|
+
|
|
48
|
+
--primary: 210 40% 98%;
|
|
49
|
+
--primary-foreground: 222.2 47.4% 11.2%;
|
|
50
|
+
|
|
51
|
+
--secondary: 217.2 32.6% 17.5%;
|
|
52
|
+
--secondary-foreground: 210 40% 98%;
|
|
53
|
+
|
|
54
|
+
--muted: 217.2 32.6% 17.5%;
|
|
55
|
+
--muted-foreground: 215 20.2% 65.1%;
|
|
56
|
+
|
|
57
|
+
--accent: 217.2 32.6% 17.5%;
|
|
58
|
+
--accent-foreground: 210 40% 98%;
|
|
59
|
+
|
|
60
|
+
--destructive: 0 62.8% 30.6%;
|
|
61
|
+
--destructive-foreground: 210 40% 98%;
|
|
62
|
+
|
|
63
|
+
--border: 217.2 32.6% 17.5%;
|
|
64
|
+
--input: 217.2 32.6% 17.5%;
|
|
65
|
+
--ring: 212.7 26.8% 83.9%;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
* {
|
|
69
|
+
border-color: hsl(var(--border));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -65,6 +65,8 @@ type TDriveFile = {
|
|
|
65
65
|
size: number;
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
|
+
type TImageQuality = 'ultralow' | 'low' | 'medium' | 'high' | 'normal';
|
|
69
|
+
type TImageFormat = 'webp' | 'jpeg' | 'png';
|
|
68
70
|
declare const driveFileSchemaZod: z.ZodObject<{
|
|
69
71
|
id: z.ZodString;
|
|
70
72
|
file: z.ZodObject<{
|
|
@@ -116,4 +118,4 @@ type TDriveUploadState = {
|
|
|
116
118
|
error?: string;
|
|
117
119
|
};
|
|
118
120
|
|
|
119
|
-
export { type TDatabaseDriveProvider as T, type TDatabaseDriveMetadata as a, type TDatabaseDriveInformation as b, type TDatabaseDriveStatus as c, type TDatabaseDrive as d, type TDriveFile as e, type
|
|
121
|
+
export { type TDatabaseDriveProvider as T, type TDatabaseDriveMetadata as a, type TDatabaseDriveInformation as b, type TDatabaseDriveStatus as c, type TDatabaseDrive as d, type TDriveFile as e, type TImageQuality as f, type TImageFormat as g, type TDatabaseDriveMetadataFile as h, type TDatabaseDriveMetadataFolder as i, type TDriveAction as j, type TDriveAPIResponse as k, type TDriveThumbnailSize as l, type TDriveImageQuality as m, type TDrivePathItem as n, type TDriveQuota as o, type TDriveUploadState as p, driveFileSchemaZod as q };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
|
-
import { T as TDatabaseDriveProvider, a as TDatabaseDriveMetadata, b as TDatabaseDriveInformation, c as TDatabaseDriveStatus, d as TDatabaseDrive } from '../index-
|
|
4
|
-
export {
|
|
3
|
+
import { T as TDatabaseDriveProvider, a as TDatabaseDriveMetadata, b as TDatabaseDriveInformation, c as TDatabaseDriveStatus, d as TDatabaseDrive, e as TDriveFile, f as TImageQuality, g as TImageFormat } from '../index-C4pw1JjP.js';
|
|
4
|
+
export { h as TDatabaseDriveMetadataFile, i as TDatabaseDriveMetadataFolder, k as TDriveAPIResponse, j as TDriveAction, m as TDriveImageQuality, l as TDriveThumbnailSize } from '../index-C4pw1JjP.js';
|
|
5
5
|
import { Document, Types } from 'mongoose';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
@@ -142,6 +142,15 @@ declare const driveFileSchemaZod: z.ZodObject<{
|
|
|
142
142
|
};
|
|
143
143
|
}>;
|
|
144
144
|
|
|
145
|
+
declare const driveCreateUrl: (driveFile: TDriveFile, apiEndpoint: string, options?: {
|
|
146
|
+
quality?: TImageQuality;
|
|
147
|
+
format?: TImageFormat;
|
|
148
|
+
}) => string;
|
|
149
|
+
declare const driveCreateSrcSet: (driveFile: TDriveFile, apiEndpoint: string, format?: TImageFormat) => {
|
|
150
|
+
srcSet: string;
|
|
151
|
+
sizes: string;
|
|
152
|
+
};
|
|
153
|
+
|
|
145
154
|
declare const driveAPIHandler: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
146
155
|
|
|
147
|
-
export { TDatabaseDrive, TDatabaseDriveInformation, TDatabaseDriveMetadata, TDatabaseDriveProvider, TDatabaseDriveStatus, type TDriveConfigInformation, type TDriveConfiguration, type TDriveDatabase, type TDriveImageConfig, type TDriveSecurityConfig, type TDriveStorageConfig, driveAPIHandler, driveConfiguration, driveFilePath, driveFileSchemaZod, driveGetUrl, driveReadFile, getDriveConfig, getDriveInformation };
|
|
156
|
+
export { TDatabaseDrive, TDatabaseDriveInformation, TDatabaseDriveMetadata, TDatabaseDriveProvider, TDatabaseDriveStatus, type TDriveConfigInformation, type TDriveConfiguration, type TDriveDatabase, TDriveFile, type TDriveImageConfig, type TDriveSecurityConfig, type TDriveStorageConfig, TImageFormat, TImageQuality, driveAPIHandler, driveConfiguration, driveCreateSrcSet, driveCreateUrl, driveFilePath, driveFileSchemaZod, driveGetUrl, driveReadFile, getDriveConfig, getDriveInformation };
|
package/dist/server/index.js
CHANGED
|
@@ -942,6 +942,37 @@ var driveFilePath = async (file) => {
|
|
|
942
942
|
throw new Error(`Unsupported provider: ${providerType}`);
|
|
943
943
|
};
|
|
944
944
|
|
|
945
|
+
// src/client/utils.tsx
|
|
946
|
+
import { clsx } from "clsx";
|
|
947
|
+
import { twMerge } from "tailwind-merge";
|
|
948
|
+
import { File, Folder, Image, Video, Music, FileText, FileCode, FileArchive } from "lucide-react";
|
|
949
|
+
import { jsx } from "react/jsx-runtime";
|
|
950
|
+
var driveCreateUrl = (driveFile, apiEndpoint, options) => {
|
|
951
|
+
const params = new URLSearchParams({
|
|
952
|
+
action: "serve",
|
|
953
|
+
id: driveFile.id
|
|
954
|
+
});
|
|
955
|
+
if (options?.quality) params.set("q", options.quality);
|
|
956
|
+
if (options?.format) params.set("format", options.format);
|
|
957
|
+
return `${apiEndpoint}?${params.toString()}`;
|
|
958
|
+
};
|
|
959
|
+
var driveCreateSrcSet = (driveFile, apiEndpoint, format = "webp") => {
|
|
960
|
+
const qualities = ["ultralow", "low", "medium", "high"];
|
|
961
|
+
const qualityWidthMap = {
|
|
962
|
+
ultralow: 200,
|
|
963
|
+
low: 400,
|
|
964
|
+
medium: 800,
|
|
965
|
+
high: 1200,
|
|
966
|
+
normal: 1600
|
|
967
|
+
};
|
|
968
|
+
const srcSet = qualities.map((quality) => {
|
|
969
|
+
const url = driveCreateUrl(driveFile, apiEndpoint, { quality, format });
|
|
970
|
+
return `${url} ${qualityWidthMap[quality]}w`;
|
|
971
|
+
}).join(", ");
|
|
972
|
+
const sizes = "(max-width: 320px) 200px, (max-width: 480px) 400px, (max-width: 768px) 800px, 1200px";
|
|
973
|
+
return { srcSet, sizes };
|
|
974
|
+
};
|
|
975
|
+
|
|
945
976
|
// src/server/index.ts
|
|
946
977
|
var getProvider = async (req, owner) => {
|
|
947
978
|
const accountId = req.headers["x-drive-account"];
|
|
@@ -1404,6 +1435,8 @@ var driveAPIHandler = async (req, res) => {
|
|
|
1404
1435
|
export {
|
|
1405
1436
|
driveAPIHandler,
|
|
1406
1437
|
driveConfiguration,
|
|
1438
|
+
driveCreateSrcSet,
|
|
1439
|
+
driveCreateUrl,
|
|
1407
1440
|
driveFilePath,
|
|
1408
1441
|
driveFileSchemaZod,
|
|
1409
1442
|
driveGetUrl,
|