dn-react-router-toolkit 0.1.1 → 0.1.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.
Files changed (284) hide show
  1. package/dist/auth-kit/apple_auth.d.mts +24 -0
  2. package/dist/{esm/auth-kit → auth-kit}/apple_auth.d.ts +11 -2
  3. package/dist/auth-kit/apple_auth.js +75 -0
  4. package/dist/auth-kit/apple_auth.mjs +50 -0
  5. package/dist/auth-kit/auth_service.d.mts +73 -0
  6. package/dist/{esm/auth-kit → auth-kit}/auth_service.d.ts +17 -11
  7. package/dist/auth-kit/auth_service.js +257 -0
  8. package/dist/auth-kit/auth_service.mjs +218 -0
  9. package/dist/auth-kit/client/google_login_button.d.mts +9 -0
  10. package/dist/auth-kit/client/google_login_button.d.ts +9 -0
  11. package/dist/auth-kit/client/google_login_button.js +67 -0
  12. package/dist/auth-kit/client/google_login_button.mjs +32 -0
  13. package/dist/auth-kit/client/redirect_page.d.mts +5 -0
  14. package/dist/auth-kit/client/redirect_page.d.ts +5 -0
  15. package/dist/auth-kit/client/redirect_page.js +53 -0
  16. package/dist/auth-kit/client/redirect_page.mjs +18 -0
  17. package/dist/auth-kit/google_auth.d.mts +27 -0
  18. package/dist/{esm/auth-kit → auth-kit}/google_auth.d.ts +11 -2
  19. package/dist/auth-kit/google_auth.js +144 -0
  20. package/dist/auth-kit/google_auth.mjs +117 -0
  21. package/dist/auth-kit/jwt.d.mts +18 -0
  22. package/dist/{esm/auth-kit → auth-kit}/jwt.d.ts +5 -2
  23. package/dist/auth-kit/jwt.js +76 -0
  24. package/dist/auth-kit/jwt.mjs +51 -0
  25. package/dist/auth-kit/kakao_auth.d.mts +24 -0
  26. package/dist/{esm/auth-kit → auth-kit}/kakao_auth.d.ts +11 -2
  27. package/dist/auth-kit/kakao_auth.js +115 -0
  28. package/dist/auth-kit/kakao_auth.mjs +88 -0
  29. package/dist/auth-kit/repository.d.mts +42 -0
  30. package/dist/{esm/auth-kit → auth-kit}/repository.d.ts +3 -1
  31. package/dist/auth-kit/repository.js +18 -0
  32. package/dist/auth-kit/repository.mjs +0 -0
  33. package/dist/auth-kit/with_auth.d.mts +17 -0
  34. package/dist/auth-kit/with_auth.d.ts +17 -0
  35. package/dist/auth-kit/with_auth.js +108 -0
  36. package/dist/auth-kit/with_auth.mjs +71 -0
  37. package/dist/cn.d.mts +3 -0
  38. package/dist/cn.d.ts +3 -0
  39. package/dist/cn.js +32 -0
  40. package/dist/cn.mjs +7 -0
  41. package/dist/components/index.d.mts +5 -0
  42. package/dist/components/index.d.ts +5 -0
  43. package/dist/components/index.js +261 -0
  44. package/dist/components/index.mjs +219 -0
  45. package/dist/components/modal/fullscreen_container.d.mts +7 -0
  46. package/dist/components/modal/fullscreen_container.d.ts +7 -0
  47. package/dist/components/modal/fullscreen_container.js +102 -0
  48. package/dist/components/modal/fullscreen_container.mjs +68 -0
  49. package/dist/components/modal/hooks.d.mts +18 -0
  50. package/dist/components/modal/hooks.d.ts +18 -0
  51. package/dist/components/modal/hooks.js +236 -0
  52. package/dist/components/modal/hooks.mjs +204 -0
  53. package/dist/components/modal/index.d.mts +4 -0
  54. package/dist/components/modal/index.d.ts +4 -0
  55. package/dist/components/modal/index.js +238 -0
  56. package/dist/components/modal/index.mjs +203 -0
  57. package/dist/components/modal/modal.d.mts +13 -0
  58. package/dist/components/modal/modal.d.ts +13 -0
  59. package/dist/components/modal/modal.js +155 -0
  60. package/dist/components/modal/modal.mjs +130 -0
  61. package/dist/components/styles.d.mts +9 -0
  62. package/dist/components/styles.d.ts +9 -0
  63. package/dist/components/styles.js +48 -0
  64. package/dist/components/styles.mjs +17 -0
  65. package/dist/date.d.mts +3 -0
  66. package/dist/date.d.ts +3 -0
  67. package/dist/date.js +63 -0
  68. package/dist/date.mjs +28 -0
  69. package/dist/file-kit/cdn.d.mts +5 -0
  70. package/dist/file-kit/cdn.d.ts +5 -0
  71. package/dist/file-kit/cdn.js +34 -0
  72. package/dist/file-kit/cdn.mjs +9 -0
  73. package/dist/file-kit/client/drop_file_input.d.mts +33 -0
  74. package/dist/{esm/file-kit → file-kit}/client/drop_file_input.d.ts +10 -8
  75. package/dist/file-kit/client/drop_file_input.js +235 -0
  76. package/dist/file-kit/client/drop_file_input.mjs +205 -0
  77. package/dist/file-kit/client/file_uploader.d.mts +13 -0
  78. package/dist/{esm/file-kit → file-kit}/client/file_uploader.d.ts +4 -2
  79. package/dist/file-kit/client/file_uploader.js +115 -0
  80. package/dist/file-kit/client/file_uploader.mjs +90 -0
  81. package/dist/file-kit/file_service.d.mts +26 -0
  82. package/dist/{esm/file-kit → file-kit}/file_service.d.ts +7 -4
  83. package/dist/file-kit/file_service.js +60 -0
  84. package/dist/file-kit/file_service.mjs +35 -0
  85. package/dist/file-kit/object_storage.d.mts +17 -0
  86. package/dist/{esm/file-kit → file-kit}/object_storage.d.ts +6 -2
  87. package/dist/file-kit/object_storage.js +78 -0
  88. package/dist/file-kit/object_storage.mjs +57 -0
  89. package/dist/file-kit/repository.d.mts +16 -0
  90. package/dist/{esm/file-kit → file-kit}/repository.d.ts +3 -1
  91. package/dist/file-kit/repository.js +18 -0
  92. package/dist/file-kit/repository.mjs +0 -0
  93. package/dist/file-kit/responsive_image.d.mts +20 -0
  94. package/dist/file-kit/responsive_image.d.ts +20 -0
  95. package/dist/file-kit/responsive_image.js +123 -0
  96. package/dist/file-kit/responsive_image.mjs +87 -0
  97. package/dist/http-kit/index.d.mts +1 -0
  98. package/dist/http-kit/index.d.ts +1 -0
  99. package/dist/http-kit/index.js +111 -0
  100. package/dist/http-kit/index.mjs +68 -0
  101. package/dist/http-kit/response.d.mts +19 -0
  102. package/dist/http-kit/response.d.ts +19 -0
  103. package/dist/http-kit/response.js +109 -0
  104. package/dist/http-kit/response.mjs +68 -0
  105. package/dist/index.d.mts +4 -0
  106. package/dist/index.d.ts +4 -0
  107. package/dist/index.js +91 -0
  108. package/dist/index.mjs +51 -0
  109. package/dist/route/api/auth/login/[provider]/route.js +113 -0
  110. package/dist/route/api/auth/login/[provider]/route.mjs +86 -0
  111. package/dist/route/api/auth/login/_provider_/route.d.mts +20 -0
  112. package/dist/route/api/auth/login/_provider_/route.d.ts +20 -0
  113. package/dist/route/api/auth/login/route.d.mts +14 -0
  114. package/dist/route/api/auth/login/route.d.ts +14 -0
  115. package/dist/route/api/auth/login/route.js +107 -0
  116. package/dist/route/api/auth/login/route.mjs +80 -0
  117. package/dist/route/api/auth/logout/route.d.mts +14 -0
  118. package/dist/route/api/auth/logout/route.d.ts +14 -0
  119. package/dist/route/api/auth/logout/route.js +98 -0
  120. package/dist/route/api/auth/logout/route.mjs +71 -0
  121. package/dist/route/api/auth/refresh/route.d.mts +13 -0
  122. package/dist/route/api/auth/refresh/route.d.ts +13 -0
  123. package/dist/route/api/auth/refresh/route.js +92 -0
  124. package/dist/route/api/auth/refresh/route.mjs +65 -0
  125. package/dist/route/api/auth/route.d.mts +13 -0
  126. package/dist/route/api/auth/route.d.ts +13 -0
  127. package/dist/route/api/auth/route.js +82 -0
  128. package/dist/route/api/auth/route.mjs +55 -0
  129. package/dist/route/api/files/[fileId]/route.js +99 -0
  130. package/dist/route/api/files/[fileId]/route.mjs +72 -0
  131. package/dist/route/api/files/_fileId_/route.d.mts +17 -0
  132. package/dist/route/api/files/_fileId_/route.d.ts +17 -0
  133. package/dist/route/api/files/route.d.mts +16 -0
  134. package/dist/route/api/files/route.d.ts +16 -0
  135. package/dist/route/api/files/route.js +106 -0
  136. package/dist/route/api/files/route.mjs +79 -0
  137. package/dist/route/api.d.mts +29 -0
  138. package/dist/route/api.d.ts +29 -0
  139. package/dist/route/api.js +395 -0
  140. package/dist/route/api.mjs +368 -0
  141. package/dist/route/auth/callback/[provider]/route.js +120 -0
  142. package/dist/route/auth/callback/[provider]/route.mjs +93 -0
  143. package/dist/route/auth/callback/_provider_/route.d.mts +20 -0
  144. package/dist/route/auth/callback/_provider_/route.d.ts +20 -0
  145. package/dist/seo-kit/index.d.mts +6 -0
  146. package/dist/seo-kit/index.d.ts +6 -0
  147. package/dist/seo-kit/index.js +321 -0
  148. package/dist/seo-kit/index.mjs +282 -0
  149. package/dist/seo-kit/loader.d.mts +7 -0
  150. package/dist/seo-kit/loader.d.ts +7 -0
  151. package/dist/seo-kit/loader.js +43 -0
  152. package/dist/seo-kit/loader.mjs +18 -0
  153. package/dist/seo-kit/seo.d.mts +103 -0
  154. package/dist/{esm/seo-kit → seo-kit}/seo.d.ts +10 -6
  155. package/dist/seo-kit/seo.js +286 -0
  156. package/dist/seo-kit/seo.mjs +251 -0
  157. package/dist/seo-kit/seo_loader.d.mts +16 -0
  158. package/dist/seo-kit/seo_loader.d.ts +16 -0
  159. package/dist/seo-kit/seo_loader.js +68 -0
  160. package/dist/seo-kit/seo_loader.mjs +31 -0
  161. package/dist/singleton.d.mts +3 -0
  162. package/dist/singleton.d.ts +3 -0
  163. package/dist/singleton.js +37 -0
  164. package/dist/singleton.mjs +12 -0
  165. package/dist/slug.d.mts +3 -0
  166. package/dist/slug.d.ts +3 -0
  167. package/dist/slug.js +32 -0
  168. package/dist/slug.mjs +7 -0
  169. package/package.json +36 -34
  170. package/tsup.config.ts +9 -0
  171. package/dist/cjs/auth-kit/apple_auth.js +0 -61
  172. package/dist/cjs/auth-kit/auth_service.js +0 -204
  173. package/dist/cjs/auth-kit/client/google_login_button.js +0 -19
  174. package/dist/cjs/auth-kit/client/redirect_page.js +0 -18
  175. package/dist/cjs/auth-kit/google_auth.js +0 -69
  176. package/dist/cjs/auth-kit/jwt.js +0 -54
  177. package/dist/cjs/auth-kit/kakao_auth.js +0 -43
  178. package/dist/cjs/auth-kit/repository.js +0 -2
  179. package/dist/cjs/auth-kit/with_auth.js +0 -46
  180. package/dist/cjs/cn.js +0 -6
  181. package/dist/cjs/components/index.js +0 -18
  182. package/dist/cjs/components/modal/fullscreen_container.js +0 -49
  183. package/dist/cjs/components/modal/hooks.js +0 -76
  184. package/dist/cjs/components/modal/index.js +0 -19
  185. package/dist/cjs/components/modal/modal.js +0 -79
  186. package/dist/cjs/components/styles.js +0 -10
  187. package/dist/cjs/date.js +0 -31
  188. package/dist/cjs/file-kit/cdn.js +0 -9
  189. package/dist/cjs/file-kit/client/drop_file_input.js +0 -148
  190. package/dist/cjs/file-kit/client/file_uploader.js +0 -88
  191. package/dist/cjs/file-kit/file_service.js +0 -32
  192. package/dist/cjs/file-kit/object_storage.js +0 -51
  193. package/dist/cjs/file-kit/repository.js +0 -2
  194. package/dist/cjs/file-kit/responsive_image.js +0 -63
  195. package/dist/cjs/http-kit/index.js +0 -17
  196. package/dist/cjs/http-kit/response.js +0 -37
  197. package/dist/cjs/index.js +0 -20
  198. package/dist/cjs/route/api/auth/login/[provider]/route.js +0 -36
  199. package/dist/cjs/route/api/auth/login/route.js +0 -35
  200. package/dist/cjs/route/api/auth/logout/route.js +0 -22
  201. package/dist/cjs/route/api/auth/refresh/route.js +0 -22
  202. package/dist/cjs/route/api/auth/route.js +0 -12
  203. package/dist/cjs/route/api/files/[fileId]/route.js +0 -20
  204. package/dist/cjs/route/api/files/route.js +0 -34
  205. package/dist/cjs/route/auth/callback/[provider]/route.js +0 -38
  206. package/dist/cjs/route/index.js +0 -80
  207. package/dist/cjs/seo-kit/index.js +0 -19
  208. package/dist/cjs/seo-kit/loader.js +0 -17
  209. package/dist/cjs/seo-kit/seo.js +0 -278
  210. package/dist/cjs/seo-kit/seo_loader.js +0 -15
  211. package/dist/cjs/singleton.js +0 -12
  212. package/dist/cjs/slug.js +0 -10
  213. package/dist/esm/auth-kit/apple_auth.js +0 -57
  214. package/dist/esm/auth-kit/auth_service.js +0 -197
  215. package/dist/esm/auth-kit/client/google_login_button.d.ts +0 -5
  216. package/dist/esm/auth-kit/client/google_login_button.js +0 -16
  217. package/dist/esm/auth-kit/client/redirect_page.d.ts +0 -1
  218. package/dist/esm/auth-kit/client/redirect_page.js +0 -15
  219. package/dist/esm/auth-kit/google_auth.js +0 -65
  220. package/dist/esm/auth-kit/jwt.js +0 -50
  221. package/dist/esm/auth-kit/kakao_auth.js +0 -39
  222. package/dist/esm/auth-kit/repository.js +0 -1
  223. package/dist/esm/auth-kit/with_auth.d.ts +0 -12
  224. package/dist/esm/auth-kit/with_auth.js +0 -43
  225. package/dist/esm/cn.d.ts +0 -1
  226. package/dist/esm/cn.js +0 -3
  227. package/dist/esm/components/index.d.ts +0 -2
  228. package/dist/esm/components/index.js +0 -2
  229. package/dist/esm/components/modal/fullscreen_container.d.ts +0 -5
  230. package/dist/esm/components/modal/fullscreen_container.js +0 -45
  231. package/dist/esm/components/modal/hooks.d.ts +0 -15
  232. package/dist/esm/components/modal/hooks.js +0 -67
  233. package/dist/esm/components/modal/index.d.ts +0 -3
  234. package/dist/esm/components/modal/index.js +0 -3
  235. package/dist/esm/components/modal/modal.d.ts +0 -10
  236. package/dist/esm/components/modal/modal.js +0 -43
  237. package/dist/esm/components/styles.d.ts +0 -7
  238. package/dist/esm/components/styles.js +0 -7
  239. package/dist/esm/date.d.ts +0 -1
  240. package/dist/esm/date.js +0 -24
  241. package/dist/esm/file-kit/cdn.d.ts +0 -3
  242. package/dist/esm/file-kit/cdn.js +0 -5
  243. package/dist/esm/file-kit/client/drop_file_input.js +0 -144
  244. package/dist/esm/file-kit/client/file_uploader.js +0 -84
  245. package/dist/esm/file-kit/file_service.js +0 -28
  246. package/dist/esm/file-kit/object_storage.js +0 -47
  247. package/dist/esm/file-kit/repository.js +0 -1
  248. package/dist/esm/file-kit/responsive_image.d.ts +0 -17
  249. package/dist/esm/file-kit/responsive_image.js +0 -58
  250. package/dist/esm/http-kit/index.d.ts +0 -1
  251. package/dist/esm/http-kit/index.js +0 -1
  252. package/dist/esm/http-kit/response.d.ts +0 -17
  253. package/dist/esm/http-kit/response.js +0 -31
  254. package/dist/esm/index.d.ts +0 -4
  255. package/dist/esm/index.js +0 -4
  256. package/dist/esm/route/api/auth/login/[provider]/route.d.ts +0 -10
  257. package/dist/esm/route/api/auth/login/[provider]/route.js +0 -32
  258. package/dist/esm/route/api/auth/login/route.d.ts +0 -6
  259. package/dist/esm/route/api/auth/login/route.js +0 -31
  260. package/dist/esm/route/api/auth/logout/route.d.ts +0 -6
  261. package/dist/esm/route/api/auth/logout/route.js +0 -18
  262. package/dist/esm/route/api/auth/refresh/route.d.ts +0 -4
  263. package/dist/esm/route/api/auth/refresh/route.js +0 -18
  264. package/dist/esm/route/api/auth/route.d.ts +0 -4
  265. package/dist/esm/route/api/auth/route.js +0 -8
  266. package/dist/esm/route/api/files/[fileId]/route.d.ts +0 -8
  267. package/dist/esm/route/api/files/[fileId]/route.js +0 -16
  268. package/dist/esm/route/api/files/route.d.ts +0 -6
  269. package/dist/esm/route/api/files/route.js +0 -30
  270. package/dist/esm/route/auth/callback/[provider]/route.d.ts +0 -11
  271. package/dist/esm/route/auth/callback/[provider]/route.js +0 -34
  272. package/dist/esm/route/index.d.ts +0 -22
  273. package/dist/esm/route/index.js +0 -76
  274. package/dist/esm/seo-kit/index.d.ts +0 -3
  275. package/dist/esm/seo-kit/index.js +0 -3
  276. package/dist/esm/seo-kit/loader.d.ts +0 -5
  277. package/dist/esm/seo-kit/loader.js +0 -14
  278. package/dist/esm/seo-kit/seo.js +0 -275
  279. package/dist/esm/seo-kit/seo_loader.d.ts +0 -12
  280. package/dist/esm/seo-kit/seo_loader.js +0 -12
  281. package/dist/esm/singleton.d.ts +0 -1
  282. package/dist/esm/singleton.js +0 -9
  283. package/dist/esm/slug.d.ts +0 -1
  284. package/dist/esm/slug.js +0 -6
@@ -1,148 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useDropFileInput = useDropFileInput;
4
- exports.DropFileMessageBox = DropFileMessageBox;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- const uuid_1 = require("uuid");
8
- const cn_1 = require("../../cn");
9
- function useDropFileInput({ defaultValue, options, uploadFile, onFileInput, onFileUploaded, limit, } = {}) {
10
- const [files, setFiles] = (0, react_1.useState)(defaultValue
11
- ? (Array.isArray(defaultValue) ? defaultValue : [defaultValue])
12
- .map((v) => {
13
- return {
14
- key: (0, uuid_1.v4)(),
15
- item: v,
16
- };
17
- })
18
- .slice(0, limit ? limit : Infinity)
19
- : []);
20
- const fileRef = (0, react_1.useRef)([]);
21
- (0, react_1.useEffect)(() => {
22
- fileRef.current = files;
23
- }, [files]);
24
- const Component = (0, react_1.useCallback)(function Component({ className, container = "border border-dashed border-neutral-300 rounded flex items-center justify-center", draggingClassName, name, hideMessage = false, children, ...props }) {
25
- const [isDragging, setIsDragging] = (0, react_1.useState)(false);
26
- const handleDragEnter = (0, react_1.useCallback)((e) => {
27
- e.preventDefault();
28
- e.stopPropagation();
29
- setIsDragging(true);
30
- }, []);
31
- const handleDragLeave = (0, react_1.useCallback)((e) => {
32
- e.preventDefault();
33
- e.stopPropagation();
34
- setIsDragging(false);
35
- }, []);
36
- const handleDragOver = (0, react_1.useCallback)((e) => {
37
- e.preventDefault();
38
- e.stopPropagation();
39
- }, []);
40
- const handleFiles = (0, react_1.useCallback)(async (files) => {
41
- if (limit && fileRef.current.length >= limit) {
42
- alert(`파일은 최대 ${limit}개 업로드할 수 있습니다.`);
43
- return;
44
- }
45
- const filteredFiles = files.filter((file) => {
46
- // if (!props.accept) {
47
- // return true;
48
- // }
49
- // const accepts = props.accept.split(",");
50
- // for (const accept of accepts) {
51
- // if (file.type.startsWith(accept)) {
52
- // return true;
53
- // }
54
- // if (file.name.endsWith(accept)) {
55
- // return true;
56
- // }
57
- // }
58
- // return false;
59
- return true;
60
- });
61
- if (files.length !== filteredFiles.length) {
62
- alert(`${props.accept} 형식의 파일만 업로드할 수 있습니다.`);
63
- }
64
- const limitedFiles = filteredFiles.slice(0, limit ? limit - fileRef.current.length : Infinity);
65
- if (limitedFiles.length === 0) {
66
- return;
67
- }
68
- if (onFileInput) {
69
- onFileInput(limitedFiles);
70
- }
71
- for (const file of limitedFiles) {
72
- const fileItem = {
73
- key: (0, uuid_1.v4)(),
74
- };
75
- setFiles((prevFiles) => [...prevFiles, fileItem]);
76
- uploadFile?.(file, options).then(async (item) => {
77
- await onFileUploaded?.(item);
78
- setFiles((prevFiles) => prevFiles.map((f) => {
79
- if (f.key === fileItem.key) {
80
- return {
81
- ...f,
82
- item,
83
- };
84
- }
85
- return f;
86
- }));
87
- });
88
- }
89
- }, [props.accept]);
90
- const handleDrop = (0, react_1.useCallback)((e) => {
91
- e.preventDefault();
92
- e.stopPropagation();
93
- setIsDragging(false);
94
- if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
95
- handleFiles(Array.from(e.dataTransfer.files));
96
- e.dataTransfer.clearData();
97
- }
98
- }, [handleFiles]);
99
- const inputRef = (0, react_1.useRef)(null);
100
- const handleClick = (0, react_1.useCallback)(() => {
101
- inputRef.current?.click();
102
- }, []);
103
- const handleKeyDown = (0, react_1.useCallback)((e) => {
104
- if (e.key === "Enter" || e.key === " ") {
105
- handleClick();
106
- }
107
- }, [handleClick]);
108
- const handleChange = (0, react_1.useCallback)((e) => {
109
- if (e.target.files && e.target.files.length > 0) {
110
- handleFiles(Array.from(e.target.files));
111
- e.target.value = "";
112
- }
113
- }, [handleFiles]);
114
- return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)(className, container, draggingClassName?.(isDragging) ||
115
- (isDragging ? "bg-neutral-300/25" : "hover:bg-neutral-300/25"), "transition-colors cursor-pointer"), onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: handleClick, onChange: handleChange, onKeyDown: handleKeyDown, tabIndex: 0, role: "button", children: [(0, jsx_runtime_1.jsx)("input", { ...props, defaultValue: "", type: "file", hidden: true, ref: inputRef }), (0, jsx_runtime_1.jsx)("input", { name: name, hidden: true, readOnly: true, value: files
116
- .map((file) => {
117
- if (file.item &&
118
- typeof file.item === "object" &&
119
- "id" in file.item) {
120
- return file.item.id;
121
- }
122
- return null;
123
- })
124
- .filter(Boolean)
125
- .join(",") }), children ||
126
- (!(hideMessage && !isDragging) && (0, jsx_runtime_1.jsx)(DropFileMessageBox, {}))] }));
127
- }, [limit, fileRef, files, options, uploadFile, onFileInput, onFileUploaded]);
128
- const loadedFileIds = files
129
- .map((file) => {
130
- if (file.item && typeof file.item === "object" && "id" in file.item) {
131
- return file.item.id;
132
- }
133
- return null;
134
- })
135
- .filter(Boolean);
136
- const loadedFileIdsString = loadedFileIds.join(",");
137
- const fileIds = (0, react_1.useMemo)(() => loadedFileIdsString.split(",").filter(Boolean), [loadedFileIdsString]);
138
- return {
139
- fileIds,
140
- files,
141
- setFiles,
142
- Component,
143
- };
144
- }
145
- function DropFileMessageBox() {
146
- return ((0, jsx_runtime_1.jsx)("div", { className: "text-sm pointer-events-none flex justify-center items-center", children: (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-center", children: (0, jsx_runtime_1.jsx)("span", { children: "\uD30C\uC77C\uC744 \uC5EC\uAE30\uB85C \uB04C\uC5B4\uB2E4 \uB193\uAC70\uB098 \uD074\uB9AD\uD574\uC11C \uC120\uD0DD\uD574 \uC8FC\uC138\uC694" }) }) }));
147
- }
148
- exports.default = useDropFileInput;
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileUploader = void 0;
4
- class FileUploader {
5
- endpoint;
6
- constructor(endpoint = "/api/files") {
7
- this.endpoint = endpoint;
8
- }
9
- formatSize = (size) => {
10
- if (size < 1024) {
11
- return `${size} B`;
12
- }
13
- if (size < 1024 * 1024) {
14
- return `${(size / 1024).toFixed(2)} KB`;
15
- }
16
- return `${(size / (1024 * 1024)).toFixed(2)} MB`;
17
- };
18
- uploadFile(file, options = {}) {
19
- return this.uploadBlob(file, file.name, options);
20
- }
21
- async uploadBlob(blob, name = "blob", options = {}) {
22
- const { type, size } = blob;
23
- const metadataForMedia = await new Promise((resolve, reject) => {
24
- if (blob.type.startsWith("image/")) {
25
- const img = new Image();
26
- img.src = URL.createObjectURL(blob);
27
- img.onload = () => {
28
- resolve({
29
- ...options.metadata,
30
- width: img.width,
31
- height: img.height,
32
- });
33
- };
34
- img.onerror = reject;
35
- return;
36
- }
37
- if (blob.type.startsWith("video/")) {
38
- const video = document.createElement("video");
39
- video.src = URL.createObjectURL(blob);
40
- video.onloadedmetadata = () => {
41
- resolve({
42
- ...options.metadata,
43
- width: video.videoWidth,
44
- height: video.videoHeight,
45
- duration: video.duration,
46
- });
47
- };
48
- video.onerror = reject;
49
- return;
50
- }
51
- resolve(options.metadata || {});
52
- });
53
- const res1 = await fetch(this.endpoint, {
54
- method: "POST",
55
- body: JSON.stringify({
56
- name: name.replace(/ /g, "_"),
57
- type,
58
- size,
59
- metadata: metadataForMedia,
60
- }),
61
- });
62
- if (!res1.ok) {
63
- const message = await res1.json();
64
- throw new Error(message);
65
- }
66
- const result = await res1.json();
67
- const { signedUrl, file } = result;
68
- const res2 = await fetch(signedUrl, {
69
- method: "PUT",
70
- body: blob,
71
- });
72
- if (!res2.ok) {
73
- throw new Error(await res2.text());
74
- }
75
- return file;
76
- }
77
- async deleteFile(fileId) {
78
- const res = await fetch(`${this.endpoint}/${fileId}`, {
79
- method: "DELETE",
80
- });
81
- if (!res.ok) {
82
- const { message } = await res.json();
83
- throw new Error(message);
84
- }
85
- return true;
86
- }
87
- }
88
- exports.FileUploader = FileUploader;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileService = void 0;
4
- const uuid_1 = require("uuid");
5
- class FileService {
6
- prefix;
7
- repository;
8
- OBJECT_STORAGE;
9
- constructor(prefix = "user", { repository, OBJECT_STORAGE, }) {
10
- this.prefix = prefix;
11
- this.repository = repository;
12
- this.OBJECT_STORAGE = OBJECT_STORAGE;
13
- }
14
- async generateSignedUrl({ userId, name, type, size, metadata = {} }) {
15
- const id = (0, uuid_1.v4)();
16
- const key = `${this.prefix}/${id}/${name}`;
17
- const file = await this.repository.createFile({
18
- id,
19
- userId,
20
- name,
21
- type,
22
- size,
23
- metadata,
24
- key,
25
- });
26
- const signedUrl = await this.OBJECT_STORAGE.generateSignedUrl(key, {
27
- contentType: type,
28
- });
29
- return { file, signedUrl };
30
- }
31
- }
32
- exports.FileService = FileService;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectStorage = void 0;
4
- const client_s3_1 = require("@aws-sdk/client-s3");
5
- const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
6
- class ObjectStorage {
7
- client = new client_s3_1.S3Client({
8
- region: "ap-northeast-2",
9
- });
10
- bucketName;
11
- constructor(bucketName) {
12
- this.bucketName = bucketName;
13
- }
14
- async generateSignedUrl(key, { contentType, expiresIn = 3600, } = {}) {
15
- const command = new client_s3_1.PutObjectCommand({
16
- Bucket: this.bucketName,
17
- Key: key,
18
- ContentType: contentType,
19
- });
20
- const signedUrl = await (0, s3_request_presigner_1.getSignedUrl)(this.client, command, {
21
- expiresIn,
22
- });
23
- return signedUrl;
24
- }
25
- async find(key) {
26
- try {
27
- const command = new client_s3_1.GetObjectCommand({
28
- Bucket: this.bucketName,
29
- Key: key,
30
- });
31
- const { Body } = await this.client.send(command);
32
- if (!Body) {
33
- return;
34
- }
35
- return Body.transformToByteArray();
36
- }
37
- catch (error) {
38
- return;
39
- }
40
- }
41
- async put(key, buffer, { contentType } = {}) {
42
- const command = new client_s3_1.PutObjectCommand({
43
- Bucket: this.bucketName,
44
- Key: key,
45
- ContentType: contentType,
46
- Body: buffer,
47
- });
48
- return await this.client.send(command);
49
- }
50
- }
51
- exports.ObjectStorage = ObjectStorage;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createResponsiveImage = void 0;
4
- exports.generateSrcSet = generateSrcSet;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const sizes = [
7
- 64, 128, 256, 320, 480, 640, 768, 1080, 1200, 1536, 1920, 2560, 3840,
8
- ];
9
- const createResponsiveImage = (cdn) => {
10
- const Component = ({ alt, file, ratio, ...props }) => {
11
- const src = cdn(file?.key) || props.src || "#";
12
- return ((0, jsx_runtime_1.jsx)("img", { ...props, src: src, alt: alt, srcSet: generateSrcSet(src, ratio, props) }));
13
- };
14
- return Component;
15
- };
16
- exports.createResponsiveImage = createResponsiveImage;
17
- exports.default = exports.createResponsiveImage;
18
- const generateSrc = (src, width, height, ratio, image = {}) => {
19
- const searchParams = new URLSearchParams();
20
- if (image.width) {
21
- searchParams.set("w", image.width.toString());
22
- }
23
- if (width) {
24
- searchParams.set("w", width.toString());
25
- if (ratio) {
26
- searchParams.set("h", Math.round(width / ratio).toString());
27
- }
28
- }
29
- if (image.height) {
30
- searchParams.set("h", image.height.toString());
31
- }
32
- if (height) {
33
- searchParams.set("h", height.toString());
34
- }
35
- const search = searchParams.toString() ? `?${searchParams.toString()}` : "";
36
- const origin = process.env.NEXT_PUBLIC_CDN_ORIGIN || "";
37
- if (!src.includes(origin)) {
38
- return src;
39
- }
40
- return `${encodeURI(decodeURI(src))}${search}`;
41
- };
42
- function generateSrcSet(image, ratio, props = {}) {
43
- const src = typeof image === "string" ? image : image.src;
44
- const isGif = src.endsWith(".gif");
45
- if (isGif) {
46
- return undefined;
47
- }
48
- if (props.width) {
49
- return [1, 2, 3]
50
- .map((scale) => {
51
- const genWidth = Number(props.width) * scale;
52
- return `${generateSrc(src, genWidth, props.height
53
- ? Number(props.height) * scale
54
- : ratio
55
- ? Math.round(genWidth / ratio)
56
- : undefined)} ${scale}x`;
57
- })
58
- .join(", ");
59
- }
60
- return sizes
61
- .map((size) => `${generateSrc(src, size, undefined, ratio, props)} ${size}w`)
62
- .join(", ");
63
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./response"), exports);
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INTERNAL_SERVER_ERROR = exports.TOO_MANY_REQUESTS = exports.UNPROCESSABLE_ENTITY = exports.CONFLICT = exports.REQUEST_TIMEOUT = exports.NOT_ACCEPTABLE = exports.METHOD_NOT_ALLOWED = exports.NOT_FOUND = exports.FORBIDDEN = exports.UNAUTHORIZED = exports.BAD_REQUEST = exports.createException = exports.NO_CONTENT = exports.ACCEPTED = exports.CREATED = exports.OK = exports.createJsonResponse = void 0;
4
- const createJsonResponse = (status) => {
5
- return (data = {}, init) => {
6
- return Response.json(data, { status, ...init });
7
- };
8
- };
9
- exports.createJsonResponse = createJsonResponse;
10
- Response;
11
- exports.OK = (0, exports.createJsonResponse)(200);
12
- exports.CREATED = (0, exports.createJsonResponse)(201);
13
- exports.ACCEPTED = (0, exports.createJsonResponse)(202);
14
- const NO_CONTENT = (init) => {
15
- return new Response(null, {
16
- ...init,
17
- status: 204,
18
- });
19
- };
20
- exports.NO_CONTENT = NO_CONTENT;
21
- const createException = (status, defaultMessage = "오류가 발생했습니다.") => {
22
- return (message = defaultMessage, init) => {
23
- return (0, exports.createJsonResponse)(status)({ message }, init);
24
- };
25
- };
26
- exports.createException = createException;
27
- exports.BAD_REQUEST = (0, exports.createException)(400, "요청이 올바르지 않습니다.");
28
- exports.UNAUTHORIZED = (0, exports.createException)(401, "인증이 필요합니다.");
29
- exports.FORBIDDEN = (0, exports.createException)(403, "권한이 없습니다.");
30
- exports.NOT_FOUND = (0, exports.createException)(404, "요청한 리소스를 찾을 수 없습니다.");
31
- exports.METHOD_NOT_ALLOWED = (0, exports.createException)(405, "메서드를 사용할 수 없습니다.");
32
- exports.NOT_ACCEPTABLE = (0, exports.createException)(406, "요청한 형식을 사용할 수 없습니다.");
33
- exports.REQUEST_TIMEOUT = (0, exports.createException)(408, "요청 시간이 초과되었습니다.");
34
- exports.CONFLICT = (0, exports.createException)(409, "요청이 충돌했습니다.");
35
- exports.UNPROCESSABLE_ENTITY = (0, exports.createException)(422, "처리할 수 없는 엔티티입니다.");
36
- exports.TOO_MANY_REQUESTS = (0, exports.createException)(429, "요청이 너무 많습니다.");
37
- exports.INTERNAL_SERVER_ERROR = (0, exports.createException)(500, "예기치 못한 오류가 발생했습니다.");
package/dist/cjs/index.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./cn"), exports);
18
- __exportStar(require("./date"), exports);
19
- __exportStar(require("./singleton"), exports);
20
- __exportStar(require("./slug"), exports);
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loginThirdPartyHandler = void 0;
4
- const http_kit_1 = require("../../../../../http-kit");
5
- const loginThirdPartyHandler = async (request, { provider, }, { GOOGLE_AUTH, APPLE_AUTH, KAKAO_AUTH, }) => {
6
- const { code } = await request.json();
7
- if (!code) {
8
- return (0, http_kit_1.BAD_REQUEST)("코드가 없습니다.");
9
- }
10
- const getThirdPartyAuth = (provider) => {
11
- switch (provider) {
12
- case "google":
13
- return GOOGLE_AUTH;
14
- case "apple":
15
- return APPLE_AUTH;
16
- case "kakao":
17
- return KAKAO_AUTH;
18
- default:
19
- throw (0, http_kit_1.BAD_REQUEST)("지원하지 않는 인증 제공자입니다.");
20
- }
21
- };
22
- try {
23
- const { accessToken, refreshToken } = await getThirdPartyAuth(provider).signIn(code);
24
- return (0, http_kit_1.CREATED)({
25
- accessToken,
26
- refreshToken,
27
- });
28
- }
29
- catch (error) {
30
- if (error instanceof Response) {
31
- return error;
32
- }
33
- throw (0, http_kit_1.INTERNAL_SERVER_ERROR)();
34
- }
35
- };
36
- exports.loginThirdPartyHandler = loginThirdPartyHandler;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loginCredentialHandler = void 0;
4
- const http_kit_1 = require("../../../../http-kit");
5
- const loginCredentialHandler = async (request, { AUTH, JWT_MANAGER, }) => {
6
- const searchParams = new URL(request.url).searchParams;
7
- const { id, password } = await request.json();
8
- try {
9
- const { accessToken, refreshToken } = await AUTH.signIn({
10
- id,
11
- password,
12
- });
13
- if (searchParams.get("type") === "json") {
14
- return (0, http_kit_1.CREATED)({ accessToken, refreshToken });
15
- }
16
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
17
- AUTH.getAccessTokenSetCookie(accessToken),
18
- AUTH.getRefreshTokenSetCookie(refreshToken),
19
- ]);
20
- const payload = JWT_MANAGER.decode(accessToken);
21
- const headers = new Headers();
22
- headers.append("Set-Cookie", accessTokenSetCookie);
23
- headers.append("Set-Cookie", refreshTokenSetCookie);
24
- return (0, http_kit_1.CREATED)(payload, {
25
- headers,
26
- });
27
- }
28
- catch (e) {
29
- if (e instanceof Error) {
30
- return (0, http_kit_1.UNAUTHORIZED)(e.message);
31
- }
32
- throw e;
33
- }
34
- };
35
- exports.loginCredentialHandler = loginCredentialHandler;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logoutHandler = void 0;
4
- const http_kit_1 = require("../../../../http-kit");
5
- const logoutHandler = async (request, { AUTH, repository }) => {
6
- const auth = await AUTH.verifyOrRefresh(request);
7
- if (!auth) {
8
- return (0, http_kit_1.UNAUTHORIZED)();
9
- }
10
- await repository.updateUserRefreshToken(auth.userId, null);
11
- const headers = new Headers();
12
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
13
- AUTH.getAccessTokenSetCookie(null),
14
- AUTH.getRefreshTokenSetCookie(null),
15
- ]);
16
- headers.append("Set-Cookie", accessTokenSetCookie);
17
- headers.append("Set-Cookie", refreshTokenSetCookie);
18
- return (0, http_kit_1.NO_CONTENT)({
19
- headers,
20
- });
21
- };
22
- exports.logoutHandler = logoutHandler;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.authRefreshHandler = void 0;
4
- const http_kit_1 = require("../../../../http-kit");
5
- const authRefreshHandler = async (request, { AUTH, }) => {
6
- const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") ||
7
- (await AUTH.getRefreshTokenFromCookies(request));
8
- if (!refreshToken) {
9
- return (0, http_kit_1.BAD_REQUEST)();
10
- }
11
- try {
12
- const accessToken = await AUTH.refreshAccessToken(refreshToken);
13
- return (0, http_kit_1.CREATED)({ accessToken });
14
- }
15
- catch (e) {
16
- if (e instanceof Error) {
17
- return (0, http_kit_1.UNAUTHORIZED)(e.message);
18
- }
19
- throw e;
20
- }
21
- };
22
- exports.authRefreshHandler = authRefreshHandler;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAuthHandler = void 0;
4
- const http_kit_1 = require("../../../http-kit");
5
- const getAuthHandler = async (request, { AUTH }) => {
6
- const auth = await AUTH.verifyOrRefresh(request);
7
- if (!auth) {
8
- return (0, http_kit_1.UNAUTHORIZED)();
9
- }
10
- return (0, http_kit_1.OK)(auth);
11
- };
12
- exports.getAuthHandler = getAuthHandler;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fileDeleteHandler = void 0;
4
- const http_kit_1 = require("../../../../http-kit");
5
- const fileDeleteHandler = async (request, { fileId }, { AUTH, repository, }) => {
6
- const auth = await AUTH.verifyOrRefresh(request);
7
- const file = await repository.findFileById(fileId);
8
- const headers = {
9
- "Access-Control-Allow-Origin": "*",
10
- };
11
- if (!file) {
12
- return (0, http_kit_1.NOT_FOUND)("파일을 찾을 수 없습니다.", { headers });
13
- }
14
- if (!repository.hasPermission(file, auth?.userId)) {
15
- return (0, http_kit_1.FORBIDDEN)("파일을 삭제할 권한이 없습니다.", { headers });
16
- }
17
- await repository.deleteFile(fileId);
18
- return (0, http_kit_1.NO_CONTENT)({ headers });
19
- };
20
- exports.fileDeleteHandler = fileDeleteHandler;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fileUploadHandler = void 0;
4
- const http_kit_1 = require("../../../http-kit");
5
- const fileUploadHandler = async (request, { AUTH, FILE_SERVICE, }) => {
6
- const auth = await AUTH.verifyOrRefresh(request);
7
- const { name, type, size, metadata } = await request.json();
8
- const headers = {
9
- "Access-Control-Allow-Origin": "*",
10
- };
11
- if (typeof name !== "string") {
12
- return (0, http_kit_1.BAD_REQUEST)("파일 이름이 필요해요.", { headers });
13
- }
14
- if (typeof type !== "string") {
15
- return (0, http_kit_1.BAD_REQUEST)("파일 타입이 필요해요.", { headers });
16
- }
17
- try {
18
- const result = await FILE_SERVICE.generateSignedUrl({
19
- userId: auth?.userId,
20
- name,
21
- type,
22
- size,
23
- metadata,
24
- });
25
- return (0, http_kit_1.CREATED)(result, { headers });
26
- }
27
- catch (e) {
28
- if (e instanceof Error) {
29
- return (0, http_kit_1.INTERNAL_SERVER_ERROR)(e.message, { headers });
30
- }
31
- return (0, http_kit_1.INTERNAL_SERVER_ERROR)(e, { headers });
32
- }
33
- };
34
- exports.fileUploadHandler = fileUploadHandler;