dn-react-router-toolkit 0.2.7 → 0.3.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.
Files changed (276) hide show
  1. package/dist/api/create_handler.d.mts +13 -0
  2. package/dist/api/create_handler.d.ts +13 -0
  3. package/dist/api/create_handler.js +276 -0
  4. package/dist/api/create_handler.mjs +282 -0
  5. package/dist/api/index.d.mts +4 -0
  6. package/dist/api/index.d.ts +4 -0
  7. package/dist/api/index.js +276 -0
  8. package/dist/api/index.mjs +282 -0
  9. package/dist/auth/client/index.d.mts +3 -0
  10. package/dist/auth/client/index.d.ts +3 -0
  11. package/dist/{date.js → auth/client/index.js} +25 -32
  12. package/dist/auth/client/index.mjs +21 -0
  13. package/dist/auth/client/redirect_page.d.mts +1 -0
  14. package/dist/auth/client/redirect_page.d.ts +1 -0
  15. package/dist/auth/index.d.mts +4 -0
  16. package/dist/auth/index.d.ts +4 -0
  17. package/dist/auth/index.js +116 -0
  18. package/dist/auth/index.mjs +89 -0
  19. package/dist/auth/server/index.d.mts +1 -0
  20. package/dist/auth/server/index.d.ts +1 -0
  21. package/dist/{slug.js → auth/server/index.js} +6 -14
  22. package/dist/auth/server/index.mjs +2 -0
  23. package/dist/auth/with_auth.d.mts +2 -6
  24. package/dist/auth/with_auth.d.ts +2 -6
  25. package/dist/auth/with_auth.js +3 -0
  26. package/dist/auth/with_auth.mjs +3 -0
  27. package/dist/{components → client}/client_env.d.mts +1 -1
  28. package/dist/{components → client}/client_env.d.ts +1 -1
  29. package/dist/{components → client}/client_env.js +6 -2
  30. package/dist/{components → client}/client_env.mjs +2 -2
  31. package/dist/client/index.d.mts +3 -0
  32. package/dist/client/index.d.ts +3 -0
  33. package/dist/{auth/client/google_login_button.js → client/index.js} +30 -33
  34. package/dist/client/index.mjs +31 -0
  35. package/dist/client/use_user_agent.d.mts +8 -0
  36. package/dist/client/use_user_agent.d.ts +8 -0
  37. package/dist/{file/client/format_size.js → client/use_user_agent.js} +14 -14
  38. package/dist/client/use_user_agent.mjs +13 -0
  39. package/dist/file/client/index.d.mts +1 -0
  40. package/dist/file/client/index.d.ts +1 -0
  41. package/dist/file/{cdn.js → client/index.js} +6 -16
  42. package/dist/file/client/index.mjs +2 -0
  43. package/dist/file/index.d.mts +1 -0
  44. package/dist/file/index.d.ts +1 -0
  45. package/dist/{cn.js → file/index.js} +6 -14
  46. package/dist/file/index.mjs +2 -0
  47. package/dist/file/server/index.d.mts +1 -0
  48. package/dist/file/server/index.d.ts +1 -0
  49. package/dist/file/server/index.js +24 -0
  50. package/dist/file/server/index.mjs +2 -0
  51. package/dist/http/index.d.mts +1 -1
  52. package/dist/http/index.d.ts +1 -1
  53. package/dist/http/index.js +3 -90
  54. package/dist/http/index.mjs +2 -68
  55. package/dist/index.d.mts +8 -6
  56. package/dist/index.d.ts +8 -6
  57. package/dist/index.js +3 -79
  58. package/dist/index.mjs +2 -58
  59. package/dist/modal/index.d.mts +1 -0
  60. package/dist/modal/index.d.ts +1 -0
  61. package/dist/{sleep.js → modal/index.js} +6 -14
  62. package/dist/modal/index.mjs +2 -0
  63. package/dist/seo/index.d.mts +4 -0
  64. package/dist/seo/index.d.ts +4 -0
  65. package/dist/seo/index.js +304 -0
  66. package/dist/seo/index.mjs +267 -0
  67. package/dist/text_editor/index.d.mts +1 -0
  68. package/dist/text_editor/index.d.ts +1 -0
  69. package/dist/text_editor/index.js +24 -0
  70. package/dist/text_editor/index.mjs +2 -0
  71. package/package.json +58 -32
  72. package/dist/auth/apple_auth.d.mts +0 -38
  73. package/dist/auth/apple_auth.d.ts +0 -38
  74. package/dist/auth/apple_auth.js +0 -88
  75. package/dist/auth/apple_auth.mjs +0 -63
  76. package/dist/auth/auth_repository.d.mts +0 -41
  77. package/dist/auth/auth_repository.d.ts +0 -41
  78. package/dist/auth/auth_repository.js +0 -18
  79. package/dist/auth/auth_repository.mjs +0 -0
  80. package/dist/auth/auth_service.d.mts +0 -63
  81. package/dist/auth/auth_service.d.ts +0 -63
  82. package/dist/auth/auth_service.js +0 -210
  83. package/dist/auth/auth_service.mjs +0 -171
  84. package/dist/auth/client/google_login_button.d.mts +0 -7
  85. package/dist/auth/client/google_login_button.d.ts +0 -7
  86. package/dist/auth/client/google_login_button.mjs +0 -37
  87. package/dist/auth/client/provider.d.mts +0 -24
  88. package/dist/auth/client/provider.d.ts +0 -24
  89. package/dist/auth/client/provider.js +0 -154
  90. package/dist/auth/client/provider.mjs +0 -118
  91. package/dist/auth/google_auth.d.mts +0 -33
  92. package/dist/auth/google_auth.d.ts +0 -33
  93. package/dist/auth/google_auth.js +0 -135
  94. package/dist/auth/google_auth.mjs +0 -108
  95. package/dist/auth/handlers/find_auth.d.mts +0 -13
  96. package/dist/auth/handlers/find_auth.d.ts +0 -13
  97. package/dist/auth/handlers/find_auth.js +0 -82
  98. package/dist/auth/handlers/find_auth.mjs +0 -55
  99. package/dist/auth/handlers/login.d.mts +0 -13
  100. package/dist/auth/handlers/login.d.ts +0 -13
  101. package/dist/auth/handlers/login.js +0 -107
  102. package/dist/auth/handlers/login.mjs +0 -80
  103. package/dist/auth/handlers/login_with_thirdparty.d.mts +0 -15
  104. package/dist/auth/handlers/login_with_thirdparty.d.ts +0 -15
  105. package/dist/auth/handlers/login_with_thirdparty.js +0 -98
  106. package/dist/auth/handlers/login_with_thirdparty.mjs +0 -71
  107. package/dist/auth/handlers/logout.d.mts +0 -13
  108. package/dist/auth/handlers/logout.d.ts +0 -13
  109. package/dist/auth/handlers/logout.js +0 -102
  110. package/dist/auth/handlers/logout.mjs +0 -75
  111. package/dist/auth/handlers/refresh.d.mts +0 -13
  112. package/dist/auth/handlers/refresh.d.ts +0 -13
  113. package/dist/auth/handlers/refresh.js +0 -92
  114. package/dist/auth/handlers/refresh.mjs +0 -65
  115. package/dist/auth/handlers/request_password_reset.d.mts +0 -10
  116. package/dist/auth/handlers/request_password_reset.d.ts +0 -10
  117. package/dist/auth/handlers/request_password_reset.js +0 -87
  118. package/dist/auth/handlers/request_password_reset.mjs +0 -60
  119. package/dist/auth/handlers/reset_password.d.mts +0 -10
  120. package/dist/auth/handlers/reset_password.d.ts +0 -10
  121. package/dist/auth/handlers/reset_password.js +0 -88
  122. package/dist/auth/handlers/reset_password.mjs +0 -61
  123. package/dist/auth/handlers/signup.d.mts +0 -15
  124. package/dist/auth/handlers/signup.d.ts +0 -15
  125. package/dist/auth/handlers/signup.js +0 -147
  126. package/dist/auth/handlers/signup.mjs +0 -112
  127. package/dist/auth/handlers/signup_with_thirdparty.d.mts +0 -17
  128. package/dist/auth/handlers/signup_with_thirdparty.d.ts +0 -17
  129. package/dist/auth/handlers/signup_with_thirdparty.js +0 -123
  130. package/dist/auth/handlers/signup_with_thirdparty.mjs +0 -98
  131. package/dist/auth/handlers/thirdparty_auth_callback.d.mts +0 -16
  132. package/dist/auth/handlers/thirdparty_auth_callback.d.ts +0 -16
  133. package/dist/auth/handlers/thirdparty_auth_callback.js +0 -129
  134. package/dist/auth/handlers/thirdparty_auth_callback.mjs +0 -102
  135. package/dist/auth/jwt_manager.d.mts +0 -38
  136. package/dist/auth/jwt_manager.d.ts +0 -38
  137. package/dist/auth/jwt_manager.js +0 -90
  138. package/dist/auth/jwt_manager.mjs +0 -65
  139. package/dist/auth/kakao_auth.d.mts +0 -27
  140. package/dist/auth/kakao_auth.d.ts +0 -27
  141. package/dist/auth/kakao_auth.js +0 -56
  142. package/dist/auth/kakao_auth.mjs +0 -31
  143. package/dist/auth/password_recovery.d.mts +0 -34
  144. package/dist/auth/password_recovery.d.ts +0 -34
  145. package/dist/auth/password_recovery.js +0 -169
  146. package/dist/auth/password_recovery.mjs +0 -134
  147. package/dist/auth/thirdparty_auth.d.mts +0 -41
  148. package/dist/auth/thirdparty_auth.d.ts +0 -41
  149. package/dist/auth/thirdparty_auth.js +0 -113
  150. package/dist/auth/thirdparty_auth.mjs +0 -86
  151. package/dist/cn.d.mts +0 -3
  152. package/dist/cn.d.ts +0 -3
  153. package/dist/cn.mjs +0 -7
  154. package/dist/components/index.d.mts +0 -5
  155. package/dist/components/index.d.ts +0 -5
  156. package/dist/components/index.js +0 -261
  157. package/dist/components/index.mjs +0 -219
  158. package/dist/components/modal/fullscreen_container.d.mts +0 -7
  159. package/dist/components/modal/fullscreen_container.d.ts +0 -7
  160. package/dist/components/modal/fullscreen_container.js +0 -102
  161. package/dist/components/modal/fullscreen_container.mjs +0 -68
  162. package/dist/components/modal/hooks.d.mts +0 -18
  163. package/dist/components/modal/hooks.d.ts +0 -18
  164. package/dist/components/modal/hooks.js +0 -236
  165. package/dist/components/modal/hooks.mjs +0 -204
  166. package/dist/components/modal/index.d.mts +0 -4
  167. package/dist/components/modal/index.d.ts +0 -4
  168. package/dist/components/modal/index.js +0 -238
  169. package/dist/components/modal/index.mjs +0 -203
  170. package/dist/components/modal/modal.d.mts +0 -13
  171. package/dist/components/modal/modal.d.ts +0 -13
  172. package/dist/components/modal/modal.js +0 -155
  173. package/dist/components/modal/modal.mjs +0 -130
  174. package/dist/components/styles.d.mts +0 -9
  175. package/dist/components/styles.d.ts +0 -9
  176. package/dist/components/styles.js +0 -48
  177. package/dist/components/styles.mjs +0 -17
  178. package/dist/date.d.mts +0 -5
  179. package/dist/date.d.ts +0 -5
  180. package/dist/date.mjs +0 -29
  181. package/dist/file/cdn.d.mts +0 -6
  182. package/dist/file/cdn.d.ts +0 -6
  183. package/dist/file/cdn.mjs +0 -9
  184. package/dist/file/client/drop_file_input.d.mts +0 -36
  185. package/dist/file/client/drop_file_input.d.ts +0 -36
  186. package/dist/file/client/drop_file_input.js +0 -323
  187. package/dist/file/client/drop_file_input.mjs +0 -294
  188. package/dist/file/client/file_upload_button.d.mts +0 -10
  189. package/dist/file/client/file_upload_button.d.ts +0 -10
  190. package/dist/file/client/file_upload_button.js +0 -89
  191. package/dist/file/client/file_upload_button.mjs +0 -58
  192. package/dist/file/client/file_uploader.d.mts +0 -13
  193. package/dist/file/client/file_uploader.d.ts +0 -13
  194. package/dist/file/client/file_uploader.js +0 -163
  195. package/dist/file/client/file_uploader.mjs +0 -136
  196. package/dist/file/client/format_size.d.mts +0 -3
  197. package/dist/file/client/format_size.d.ts +0 -3
  198. package/dist/file/client/format_size.mjs +0 -13
  199. package/dist/file/client/metadata.d.mts +0 -7
  200. package/dist/file/client/metadata.d.ts +0 -7
  201. package/dist/file/client/metadata.js +0 -85
  202. package/dist/file/client/metadata.mjs +0 -60
  203. package/dist/file/file_repository.d.mts +0 -16
  204. package/dist/file/file_repository.d.ts +0 -16
  205. package/dist/file/file_repository.js +0 -18
  206. package/dist/file/file_repository.mjs +0 -0
  207. package/dist/file/file_service.d.mts +0 -32
  208. package/dist/file/file_service.d.ts +0 -32
  209. package/dist/file/file_service.js +0 -66
  210. package/dist/file/file_service.mjs +0 -41
  211. package/dist/file/handlers/delete_file.d.mts +0 -17
  212. package/dist/file/handlers/delete_file.d.ts +0 -17
  213. package/dist/file/handlers/delete_file.js +0 -99
  214. package/dist/file/handlers/delete_file.mjs +0 -72
  215. package/dist/file/handlers/upload_file.d.mts +0 -16
  216. package/dist/file/handlers/upload_file.d.ts +0 -16
  217. package/dist/file/handlers/upload_file.js +0 -106
  218. package/dist/file/handlers/upload_file.mjs +0 -79
  219. package/dist/file/object_storage.d.mts +0 -20
  220. package/dist/file/object_storage.d.ts +0 -20
  221. package/dist/file/object_storage.js +0 -90
  222. package/dist/file/object_storage.mjs +0 -70
  223. package/dist/file/responsive_image.d.mts +0 -20
  224. package/dist/file/responsive_image.d.ts +0 -20
  225. package/dist/file/responsive_image.js +0 -132
  226. package/dist/file/responsive_image.mjs +0 -96
  227. package/dist/http/response.d.mts +0 -19
  228. package/dist/http/response.d.ts +0 -19
  229. package/dist/http/response.js +0 -109
  230. package/dist/http/response.mjs +0 -68
  231. package/dist/route/api.d.mts +0 -21
  232. package/dist/route/api.d.ts +0 -21
  233. package/dist/route/api.js +0 -584
  234. package/dist/route/api.mjs +0 -547
  235. package/dist/singleton.d.mts +0 -3
  236. package/dist/singleton.d.ts +0 -3
  237. package/dist/singleton.js +0 -37
  238. package/dist/singleton.mjs +0 -12
  239. package/dist/sleep.d.mts +0 -3
  240. package/dist/sleep.d.ts +0 -3
  241. package/dist/sleep.mjs +0 -7
  242. package/dist/slug.d.mts +0 -3
  243. package/dist/slug.d.ts +0 -3
  244. package/dist/slug.mjs +0 -7
  245. package/dist/text_editor/attach_media.d.mts +0 -16
  246. package/dist/text_editor/attach_media.d.ts +0 -16
  247. package/dist/text_editor/attach_media.js +0 -237
  248. package/dist/text_editor/attach_media.mjs +0 -210
  249. package/dist/text_editor/plugins/drag_and_drop.d.mts +0 -13
  250. package/dist/text_editor/plugins/drag_and_drop.d.ts +0 -13
  251. package/dist/text_editor/plugins/drag_and_drop.js +0 -59
  252. package/dist/text_editor/plugins/drag_and_drop.mjs +0 -34
  253. package/dist/text_editor/plugins/keymap.d.mts +0 -5
  254. package/dist/text_editor/plugins/keymap.d.ts +0 -5
  255. package/dist/text_editor/plugins/keymap.js +0 -40
  256. package/dist/text_editor/plugins/keymap.mjs +0 -15
  257. package/dist/text_editor/plugins/placehoder.d.mts +0 -5
  258. package/dist/text_editor/plugins/placehoder.d.ts +0 -5
  259. package/dist/text_editor/plugins/placehoder.js +0 -112
  260. package/dist/text_editor/plugins/placehoder.mjs +0 -87
  261. package/dist/text_editor/plugins/trailing_paragraph.d.mts +0 -5
  262. package/dist/text_editor/plugins/trailing_paragraph.d.ts +0 -5
  263. package/dist/text_editor/plugins/trailing_paragraph.js +0 -46
  264. package/dist/text_editor/plugins/trailing_paragraph.mjs +0 -21
  265. package/dist/text_editor/plugins/upload_placeholder.d.mts +0 -7
  266. package/dist/text_editor/plugins/upload_placeholder.d.ts +0 -7
  267. package/dist/text_editor/plugins/upload_placeholder.js +0 -94
  268. package/dist/text_editor/plugins/upload_placeholder.mjs +0 -68
  269. package/dist/text_editor/schema.d.mts +0 -9
  270. package/dist/text_editor/schema.d.ts +0 -9
  271. package/dist/text_editor/schema.js +0 -354
  272. package/dist/text_editor/schema.mjs +0 -319
  273. package/dist/text_editor/text_editor.d.mts +0 -45
  274. package/dist/text_editor/text_editor.d.ts +0 -45
  275. package/dist/text_editor/text_editor.js +0 -834
  276. package/dist/text_editor/text_editor.mjs +0 -806
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
-
3
- type Props<TFile> = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> & {
4
- onUpload?: (files: TFile[]) => Promise<void> | void;
5
- };
6
- declare function createFileUploadButton<TFile>({ uploadFile, }: {
7
- uploadFile: (file: File) => Promise<TFile>;
8
- }): ({ onUpload, children, className, style, ...props }: Props<TFile>) => React.JSX.Element;
9
-
10
- export { createFileUploadButton as default };
@@ -1,89 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/file/client/file_upload_button.tsx
31
- var file_upload_button_exports = {};
32
- __export(file_upload_button_exports, {
33
- default: () => createFileUploadButton
34
- });
35
- module.exports = __toCommonJS(file_upload_button_exports);
36
- var import_react = __toESM(require("react"));
37
- var import_react2 = require("react");
38
- function createFileUploadButton({
39
- uploadFile
40
- }) {
41
- return function FileUploadButton({
42
- onUpload,
43
- children,
44
- className,
45
- style,
46
- ...props
47
- }) {
48
- const inputRef = (0, import_react2.useRef)(null);
49
- const onClick = () => {
50
- inputRef.current?.click();
51
- };
52
- const onChange = async (e) => {
53
- const files = e.target.files;
54
- if (files && files.length > 0) {
55
- if (onUpload) {
56
- try {
57
- const entities = await Promise.all(
58
- Array.from(files).map((file) => uploadFile(file))
59
- );
60
- await onUpload(entities);
61
- } catch (err) {
62
- console.error(err);
63
- alert("\uD30C\uC77C \uC5C5\uB85C\uB4DC \uC911 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.");
64
- }
65
- }
66
- }
67
- e.target.value = "";
68
- };
69
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
70
- "input",
71
- {
72
- ...props,
73
- type: "file",
74
- ref: inputRef,
75
- className: "hidden",
76
- onChange
77
- }
78
- ), /* @__PURE__ */ import_react.default.createElement(
79
- "button",
80
- {
81
- className,
82
- style,
83
- type: "button",
84
- onClick
85
- },
86
- children
87
- ));
88
- };
89
- }
@@ -1,58 +0,0 @@
1
- // src/file/client/file_upload_button.tsx
2
- import React from "react";
3
- import { useRef } from "react";
4
- function createFileUploadButton({
5
- uploadFile
6
- }) {
7
- return function FileUploadButton({
8
- onUpload,
9
- children,
10
- className,
11
- style,
12
- ...props
13
- }) {
14
- const inputRef = useRef(null);
15
- const onClick = () => {
16
- inputRef.current?.click();
17
- };
18
- const onChange = async (e) => {
19
- const files = e.target.files;
20
- if (files && files.length > 0) {
21
- if (onUpload) {
22
- try {
23
- const entities = await Promise.all(
24
- Array.from(files).map((file) => uploadFile(file))
25
- );
26
- await onUpload(entities);
27
- } catch (err) {
28
- console.error(err);
29
- alert("\uD30C\uC77C \uC5C5\uB85C\uB4DC \uC911 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.");
30
- }
31
- }
32
- }
33
- e.target.value = "";
34
- };
35
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
36
- "input",
37
- {
38
- ...props,
39
- type: "file",
40
- ref: inputRef,
41
- className: "hidden",
42
- onChange
43
- }
44
- ), /* @__PURE__ */ React.createElement(
45
- "button",
46
- {
47
- className,
48
- style,
49
- type: "button",
50
- onClick
51
- },
52
- children
53
- ));
54
- };
55
- }
56
- export {
57
- createFileUploadButton as default
58
- };
@@ -1,13 +0,0 @@
1
- type FileUploaderOptions = {
2
- metadata?: Record<string, unknown>;
3
- convertToWebp?: boolean;
4
- };
5
- declare class FileUploader<TFile> {
6
- endpoint: string;
7
- constructor(endpoint?: string);
8
- uploadFile(file: File, options?: FileUploaderOptions): Promise<TFile>;
9
- uploadBlob(blob: Blob, name?: string, options?: FileUploaderOptions): Promise<TFile>;
10
- deleteFile(fileId: string): Promise<boolean>;
11
- }
12
-
13
- export { FileUploader, type FileUploaderOptions };
@@ -1,13 +0,0 @@
1
- type FileUploaderOptions = {
2
- metadata?: Record<string, unknown>;
3
- convertToWebp?: boolean;
4
- };
5
- declare class FileUploader<TFile> {
6
- endpoint: string;
7
- constructor(endpoint?: string);
8
- uploadFile(file: File, options?: FileUploaderOptions): Promise<TFile>;
9
- uploadBlob(blob: Blob, name?: string, options?: FileUploaderOptions): Promise<TFile>;
10
- deleteFile(fileId: string): Promise<boolean>;
11
- }
12
-
13
- export { FileUploader, type FileUploaderOptions };
@@ -1,163 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/file/client/file_uploader.ts
21
- var file_uploader_exports = {};
22
- __export(file_uploader_exports, {
23
- FileUploader: () => FileUploader
24
- });
25
- module.exports = __toCommonJS(file_uploader_exports);
26
-
27
- // src/file/client/metadata.ts
28
- function generateMetadata(blob, {
29
- uploadBlob
30
- } = {}) {
31
- return new Promise((resolve) => {
32
- if (blob.type.startsWith("image/")) {
33
- const img = new Image();
34
- img.src = URL.createObjectURL(blob);
35
- img.onload = () => {
36
- resolve({
37
- width: img.width,
38
- height: img.height
39
- });
40
- };
41
- img.onerror = () => resolve({});
42
- return;
43
- }
44
- if (blob.type.startsWith("video/")) {
45
- const video = document.createElement("video");
46
- video.onloadeddata = () => {
47
- const canvas = document.createElement("canvas");
48
- canvas.width = video.videoWidth;
49
- canvas.height = video.videoHeight;
50
- const context = canvas.getContext("2d");
51
- if (!context || !uploadBlob) {
52
- return resolve({
53
- width: video.videoWidth,
54
- height: video.videoHeight
55
- });
56
- }
57
- video.addEventListener("seeked", () => {
58
- context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
59
- canvas.toBlob((blob2) => {
60
- if (!blob2) {
61
- return resolve({
62
- width: video.videoWidth,
63
- height: video.videoHeight
64
- });
65
- }
66
- uploadBlob(blob2, "poster").then(({ url }) => {
67
- resolve({
68
- width: video.videoWidth,
69
- height: video.videoHeight,
70
- poster: url
71
- });
72
- });
73
- }, "image/jpeg");
74
- });
75
- video.currentTime = 0;
76
- };
77
- video.onerror = () => resolve({});
78
- video.src = URL.createObjectURL(blob);
79
- return;
80
- }
81
- resolve({});
82
- });
83
- }
84
-
85
- // src/file/client/file_uploader.ts
86
- var FileUploader = class {
87
- endpoint;
88
- constructor(endpoint = "/api/files") {
89
- this.endpoint = endpoint;
90
- this.uploadFile = this.uploadFile.bind(this);
91
- this.uploadBlob = this.uploadBlob.bind(this);
92
- this.deleteFile = this.deleteFile.bind(this);
93
- }
94
- uploadFile(file, options = {}) {
95
- return this.uploadBlob(file, file.name, options);
96
- }
97
- async uploadBlob(blob, name = "blob", options = {}) {
98
- if (options.convertToWebp && blob.type.startsWith("image/") && blob.type !== "image/webp") {
99
- const img = document.createElement("img");
100
- img.src = URL.createObjectURL(blob);
101
- await img.decode();
102
- const canvas = document.createElement("canvas");
103
- canvas.width = img.width;
104
- canvas.height = img.height;
105
- const ctx = canvas.getContext("2d");
106
- if (ctx) {
107
- ctx.drawImage(img, 0, 0);
108
- }
109
- const webpBlob = await new Promise((resolve) => {
110
- canvas.toBlob((b) => {
111
- resolve(b);
112
- }, "image/webp");
113
- });
114
- if (webpBlob) {
115
- blob = webpBlob;
116
- name = name.replace(/\.[^/.]+$/, "") + ".webp";
117
- }
118
- }
119
- const { type, size } = blob;
120
- const metadataForMedia = await generateMetadata(blob);
121
- const metadata = {
122
- ...metadataForMedia,
123
- ...options.metadata
124
- };
125
- const res1 = await fetch(this.endpoint, {
126
- method: "POST",
127
- body: JSON.stringify({
128
- name: name.replace(/ /g, "_"),
129
- type,
130
- size,
131
- metadata
132
- })
133
- });
134
- if (!res1.ok) {
135
- const message = await res1.json();
136
- throw new Error(message);
137
- }
138
- const result = await res1.json();
139
- const { signedUrl, file } = result;
140
- const res2 = await fetch(signedUrl, {
141
- method: "PUT",
142
- body: blob
143
- });
144
- if (!res2.ok) {
145
- throw new Error(await res2.text());
146
- }
147
- return file;
148
- }
149
- async deleteFile(fileId) {
150
- const res = await fetch(`${this.endpoint}/${fileId}`, {
151
- method: "DELETE"
152
- });
153
- if (!res.ok) {
154
- const { message } = await res.json();
155
- throw new Error(message);
156
- }
157
- return true;
158
- }
159
- };
160
- // Annotate the CommonJS export names for ESM import in node:
161
- 0 && (module.exports = {
162
- FileUploader
163
- });
@@ -1,136 +0,0 @@
1
- // src/file/client/metadata.ts
2
- function generateMetadata(blob, {
3
- uploadBlob
4
- } = {}) {
5
- return new Promise((resolve) => {
6
- if (blob.type.startsWith("image/")) {
7
- const img = new Image();
8
- img.src = URL.createObjectURL(blob);
9
- img.onload = () => {
10
- resolve({
11
- width: img.width,
12
- height: img.height
13
- });
14
- };
15
- img.onerror = () => resolve({});
16
- return;
17
- }
18
- if (blob.type.startsWith("video/")) {
19
- const video = document.createElement("video");
20
- video.onloadeddata = () => {
21
- const canvas = document.createElement("canvas");
22
- canvas.width = video.videoWidth;
23
- canvas.height = video.videoHeight;
24
- const context = canvas.getContext("2d");
25
- if (!context || !uploadBlob) {
26
- return resolve({
27
- width: video.videoWidth,
28
- height: video.videoHeight
29
- });
30
- }
31
- video.addEventListener("seeked", () => {
32
- context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
33
- canvas.toBlob((blob2) => {
34
- if (!blob2) {
35
- return resolve({
36
- width: video.videoWidth,
37
- height: video.videoHeight
38
- });
39
- }
40
- uploadBlob(blob2, "poster").then(({ url }) => {
41
- resolve({
42
- width: video.videoWidth,
43
- height: video.videoHeight,
44
- poster: url
45
- });
46
- });
47
- }, "image/jpeg");
48
- });
49
- video.currentTime = 0;
50
- };
51
- video.onerror = () => resolve({});
52
- video.src = URL.createObjectURL(blob);
53
- return;
54
- }
55
- resolve({});
56
- });
57
- }
58
-
59
- // src/file/client/file_uploader.ts
60
- var FileUploader = class {
61
- endpoint;
62
- constructor(endpoint = "/api/files") {
63
- this.endpoint = endpoint;
64
- this.uploadFile = this.uploadFile.bind(this);
65
- this.uploadBlob = this.uploadBlob.bind(this);
66
- this.deleteFile = this.deleteFile.bind(this);
67
- }
68
- uploadFile(file, options = {}) {
69
- return this.uploadBlob(file, file.name, options);
70
- }
71
- async uploadBlob(blob, name = "blob", options = {}) {
72
- if (options.convertToWebp && blob.type.startsWith("image/") && blob.type !== "image/webp") {
73
- const img = document.createElement("img");
74
- img.src = URL.createObjectURL(blob);
75
- await img.decode();
76
- const canvas = document.createElement("canvas");
77
- canvas.width = img.width;
78
- canvas.height = img.height;
79
- const ctx = canvas.getContext("2d");
80
- if (ctx) {
81
- ctx.drawImage(img, 0, 0);
82
- }
83
- const webpBlob = await new Promise((resolve) => {
84
- canvas.toBlob((b) => {
85
- resolve(b);
86
- }, "image/webp");
87
- });
88
- if (webpBlob) {
89
- blob = webpBlob;
90
- name = name.replace(/\.[^/.]+$/, "") + ".webp";
91
- }
92
- }
93
- const { type, size } = blob;
94
- const metadataForMedia = await generateMetadata(blob);
95
- const metadata = {
96
- ...metadataForMedia,
97
- ...options.metadata
98
- };
99
- const res1 = await fetch(this.endpoint, {
100
- method: "POST",
101
- body: JSON.stringify({
102
- name: name.replace(/ /g, "_"),
103
- type,
104
- size,
105
- metadata
106
- })
107
- });
108
- if (!res1.ok) {
109
- const message = await res1.json();
110
- throw new Error(message);
111
- }
112
- const result = await res1.json();
113
- const { signedUrl, file } = result;
114
- const res2 = await fetch(signedUrl, {
115
- method: "PUT",
116
- body: blob
117
- });
118
- if (!res2.ok) {
119
- throw new Error(await res2.text());
120
- }
121
- return file;
122
- }
123
- async deleteFile(fileId) {
124
- const res = await fetch(`${this.endpoint}/${fileId}`, {
125
- method: "DELETE"
126
- });
127
- if (!res.ok) {
128
- const { message } = await res.json();
129
- throw new Error(message);
130
- }
131
- return true;
132
- }
133
- };
134
- export {
135
- FileUploader
136
- };
@@ -1,3 +0,0 @@
1
- declare function formatSize(size: number): string;
2
-
3
- export { formatSize };
@@ -1,3 +0,0 @@
1
- declare function formatSize(size: number): string;
2
-
3
- export { formatSize };
@@ -1,13 +0,0 @@
1
- // src/file/client/format_size.ts
2
- function formatSize(size) {
3
- if (size < 1024) {
4
- return `${size} B`;
5
- }
6
- if (size < 1024 * 1024) {
7
- return `${(size / 1024).toFixed(2)} KB`;
8
- }
9
- return `${(size / (1024 * 1024)).toFixed(2)} MB`;
10
- }
11
- export {
12
- formatSize
13
- };
@@ -1,7 +0,0 @@
1
- declare function generateMetadata(blob: Blob | File, { uploadBlob, }?: {
2
- uploadBlob?: (blob: Blob, type: string) => Promise<{
3
- url: string;
4
- }>;
5
- }): Promise<Record<string, unknown>>;
6
-
7
- export { generateMetadata };
@@ -1,7 +0,0 @@
1
- declare function generateMetadata(blob: Blob | File, { uploadBlob, }?: {
2
- uploadBlob?: (blob: Blob, type: string) => Promise<{
3
- url: string;
4
- }>;
5
- }): Promise<Record<string, unknown>>;
6
-
7
- export { generateMetadata };
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/file/client/metadata.ts
21
- var metadata_exports = {};
22
- __export(metadata_exports, {
23
- generateMetadata: () => generateMetadata
24
- });
25
- module.exports = __toCommonJS(metadata_exports);
26
- function generateMetadata(blob, {
27
- uploadBlob
28
- } = {}) {
29
- return new Promise((resolve) => {
30
- if (blob.type.startsWith("image/")) {
31
- const img = new Image();
32
- img.src = URL.createObjectURL(blob);
33
- img.onload = () => {
34
- resolve({
35
- width: img.width,
36
- height: img.height
37
- });
38
- };
39
- img.onerror = () => resolve({});
40
- return;
41
- }
42
- if (blob.type.startsWith("video/")) {
43
- const video = document.createElement("video");
44
- video.onloadeddata = () => {
45
- const canvas = document.createElement("canvas");
46
- canvas.width = video.videoWidth;
47
- canvas.height = video.videoHeight;
48
- const context = canvas.getContext("2d");
49
- if (!context || !uploadBlob) {
50
- return resolve({
51
- width: video.videoWidth,
52
- height: video.videoHeight
53
- });
54
- }
55
- video.addEventListener("seeked", () => {
56
- context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
57
- canvas.toBlob((blob2) => {
58
- if (!blob2) {
59
- return resolve({
60
- width: video.videoWidth,
61
- height: video.videoHeight
62
- });
63
- }
64
- uploadBlob(blob2, "poster").then(({ url }) => {
65
- resolve({
66
- width: video.videoWidth,
67
- height: video.videoHeight,
68
- poster: url
69
- });
70
- });
71
- }, "image/jpeg");
72
- });
73
- video.currentTime = 0;
74
- };
75
- video.onerror = () => resolve({});
76
- video.src = URL.createObjectURL(blob);
77
- return;
78
- }
79
- resolve({});
80
- });
81
- }
82
- // Annotate the CommonJS export names for ESM import in node:
83
- 0 && (module.exports = {
84
- generateMetadata
85
- });
@@ -1,60 +0,0 @@
1
- // src/file/client/metadata.ts
2
- function generateMetadata(blob, {
3
- uploadBlob
4
- } = {}) {
5
- return new Promise((resolve) => {
6
- if (blob.type.startsWith("image/")) {
7
- const img = new Image();
8
- img.src = URL.createObjectURL(blob);
9
- img.onload = () => {
10
- resolve({
11
- width: img.width,
12
- height: img.height
13
- });
14
- };
15
- img.onerror = () => resolve({});
16
- return;
17
- }
18
- if (blob.type.startsWith("video/")) {
19
- const video = document.createElement("video");
20
- video.onloadeddata = () => {
21
- const canvas = document.createElement("canvas");
22
- canvas.width = video.videoWidth;
23
- canvas.height = video.videoHeight;
24
- const context = canvas.getContext("2d");
25
- if (!context || !uploadBlob) {
26
- return resolve({
27
- width: video.videoWidth,
28
- height: video.videoHeight
29
- });
30
- }
31
- video.addEventListener("seeked", () => {
32
- context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
33
- canvas.toBlob((blob2) => {
34
- if (!blob2) {
35
- return resolve({
36
- width: video.videoWidth,
37
- height: video.videoHeight
38
- });
39
- }
40
- uploadBlob(blob2, "poster").then(({ url }) => {
41
- resolve({
42
- width: video.videoWidth,
43
- height: video.videoHeight,
44
- poster: url
45
- });
46
- });
47
- }, "image/jpeg");
48
- });
49
- video.currentTime = 0;
50
- };
51
- video.onerror = () => resolve({});
52
- video.src = URL.createObjectURL(blob);
53
- return;
54
- }
55
- resolve({});
56
- });
57
- }
58
- export {
59
- generateMetadata
60
- };
@@ -1,16 +0,0 @@
1
- interface FileRepository<TFile = unknown> {
2
- findFileById(fileId: string): Promise<TFile | undefined>;
3
- hasPermission(file: TFile, userId?: string): boolean;
4
- createFile(fileData: {
5
- id: string;
6
- userId?: string;
7
- name: string;
8
- type?: string;
9
- size?: number;
10
- metadata?: Record<string, any>;
11
- key: string;
12
- }): Promise<TFile>;
13
- deleteFile(fileId: string): Promise<void>;
14
- }
15
-
16
- export type { FileRepository };