mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 16:16:55 +00:00
Compare commits
19 Commits
aa004dbd18
...
v0.7.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3906ec4371 | ||
|
|
5d130204a6 | ||
|
|
4997b1f38c | ||
|
|
1d3704bfad | ||
|
|
ae1d34fc6b | ||
|
|
f10a0a2da3 | ||
|
|
0eb1d29259 | ||
|
|
cf0f8fe0b9 | ||
|
|
30c56e0926 | ||
|
|
83d595636b | ||
|
|
008c8ad6ba | ||
|
|
5729af380d | ||
|
|
90ac5ba4c3 | ||
|
|
dfffa004ac | ||
|
|
0cd55a413d | ||
|
|
361d966a59 | ||
|
|
aef43b8bfa | ||
|
|
7f128cccf6 | ||
|
|
a198e5f6dc |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "arkvault",
|
"name": "arkvault",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.6.0",
|
"version": "0.7.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
@@ -17,11 +17,12 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^2.0.0",
|
"@eslint/compat": "^2.0.0",
|
||||||
|
"@eslint/js": "^9.39.2",
|
||||||
"@iconify-json/material-symbols": "^1.2.50",
|
"@iconify-json/material-symbols": "^1.2.50",
|
||||||
"@sveltejs/adapter-node": "^5.4.0",
|
"@sveltejs/adapter-node": "^5.4.0",
|
||||||
"@sveltejs/kit": "^2.49.2",
|
"@sveltejs/kit": "^2.49.2",
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
||||||
"@tanstack/svelte-virtual": "^3.13.13",
|
"@tanstack/svelte-virtual": "^3.13.16",
|
||||||
"@trpc/client": "^11.8.1",
|
"@trpc/client": "^11.8.1",
|
||||||
"@types/file-saver": "^2.0.7",
|
"@types/file-saver": "^2.0.7",
|
||||||
"@types/ms": "^0.7.34",
|
"@types/ms": "^0.7.34",
|
||||||
@@ -49,7 +50,7 @@
|
|||||||
"svelte-check": "^4.3.5",
|
"svelte-check": "^4.3.5",
|
||||||
"tailwindcss": "^3.4.19",
|
"tailwindcss": "^3.4.19",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"typescript-eslint": "^8.50.1",
|
"typescript-eslint": "^8.51.0",
|
||||||
"unplugin-icons": "^22.5.0",
|
"unplugin-icons": "^22.5.0",
|
||||||
"vite": "^7.3.0"
|
"vite": "^7.3.0"
|
||||||
},
|
},
|
||||||
@@ -63,7 +64,7 @@
|
|||||||
"pg": "^8.16.3",
|
"pg": "^8.16.3",
|
||||||
"superjson": "^2.2.6",
|
"superjson": "^2.2.6",
|
||||||
"uuid": "^13.0.0",
|
"uuid": "^13.0.0",
|
||||||
"zod": "^4.2.1"
|
"zod": "^4.3.5"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^22.0.0",
|
"node": "^22.0.0",
|
||||||
|
|||||||
201
pnpm-lock.yaml
generated
201
pnpm-lock.yaml
generated
@@ -36,12 +36,15 @@ importers:
|
|||||||
specifier: ^13.0.0
|
specifier: ^13.0.0
|
||||||
version: 13.0.0
|
version: 13.0.0
|
||||||
zod:
|
zod:
|
||||||
specifier: ^4.2.1
|
specifier: ^4.3.5
|
||||||
version: 4.2.1
|
version: 4.3.5
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@eslint/compat':
|
'@eslint/compat':
|
||||||
specifier: ^2.0.0
|
specifier: ^2.0.0
|
||||||
version: 2.0.0(eslint@9.39.2(jiti@1.21.7))
|
version: 2.0.0(eslint@9.39.2(jiti@1.21.7))
|
||||||
|
'@eslint/js':
|
||||||
|
specifier: ^9.39.2
|
||||||
|
version: 9.39.2
|
||||||
'@iconify-json/material-symbols':
|
'@iconify-json/material-symbols':
|
||||||
specifier: ^1.2.50
|
specifier: ^1.2.50
|
||||||
version: 1.2.50
|
version: 1.2.50
|
||||||
@@ -55,8 +58,8 @@ importers:
|
|||||||
specifier: ^6.2.1
|
specifier: ^6.2.1
|
||||||
version: 6.2.1(svelte@5.46.1)(vite@7.3.0(@types/node@25.0.3)(jiti@1.21.7)(yaml@2.8.0))
|
version: 6.2.1(svelte@5.46.1)(vite@7.3.0(@types/node@25.0.3)(jiti@1.21.7)(yaml@2.8.0))
|
||||||
'@tanstack/svelte-virtual':
|
'@tanstack/svelte-virtual':
|
||||||
specifier: ^3.13.13
|
specifier: ^3.13.16
|
||||||
version: 3.13.13(svelte@5.46.1)
|
version: 3.13.16(svelte@5.46.1)
|
||||||
'@trpc/client':
|
'@trpc/client':
|
||||||
specifier: ^11.8.1
|
specifier: ^11.8.1
|
||||||
version: 11.8.1(@trpc/server@11.8.1(typescript@5.9.3))(typescript@5.9.3)
|
version: 11.8.1(@trpc/server@11.8.1(typescript@5.9.3))(typescript@5.9.3)
|
||||||
@@ -139,8 +142,8 @@ importers:
|
|||||||
specifier: ^5.9.3
|
specifier: ^5.9.3
|
||||||
version: 5.9.3
|
version: 5.9.3
|
||||||
typescript-eslint:
|
typescript-eslint:
|
||||||
specifier: ^8.50.1
|
specifier: ^8.51.0
|
||||||
version: 8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
version: 8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
||||||
unplugin-icons:
|
unplugin-icons:
|
||||||
specifier: ^22.5.0
|
specifier: ^22.5.0
|
||||||
version: 22.5.0(svelte@5.46.1)
|
version: 22.5.0(svelte@5.46.1)
|
||||||
@@ -316,8 +319,8 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
'@eslint-community/eslint-utils@4.9.0':
|
'@eslint-community/eslint-utils@4.9.1':
|
||||||
resolution: {integrity: sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==}
|
resolution: {integrity: sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==}
|
||||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
|
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
|
||||||
@@ -617,13 +620,13 @@ packages:
|
|||||||
svelte: ^5.0.0
|
svelte: ^5.0.0
|
||||||
vite: ^6.3.0 || ^7.0.0
|
vite: ^6.3.0 || ^7.0.0
|
||||||
|
|
||||||
'@tanstack/svelte-virtual@3.13.13':
|
'@tanstack/svelte-virtual@3.13.16':
|
||||||
resolution: {integrity: sha512-VDOvbRw3R+XBQdFodEJ4E7AOmEyo3Bmr4zL4DLVnJ0fxICdbvY5F5t8zSwJ4f7lqjckXi0yKFzY8WBtjaNbsGQ==}
|
resolution: {integrity: sha512-LRDPRzAPTIiDjiCA9lhNlFnZRLj/XsNhzNRsT5JEA8hzcBmZw8avdYYVjydPAy0ObFJgG1zBAm9Dtvwqju36sg==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
svelte: ^3.48.0 || ^4.0.0 || ^5.0.0
|
svelte: ^3.48.0 || ^4.0.0 || ^5.0.0
|
||||||
|
|
||||||
'@tanstack/virtual-core@3.13.13':
|
'@tanstack/virtual-core@3.13.16':
|
||||||
resolution: {integrity: sha512-uQFoSdKKf5S8k51W5t7b2qpfkyIbdHMzAn+AMQvHPxKUPeo1SsGaA4JRISQT87jm28b7z8OEqPcg1IOZagQHcA==}
|
resolution: {integrity: sha512-njazUC8mDkrxWmyZmn/3eXrDcP8Msb3chSr4q6a65RmwdSbMlMCdnOphv6/8mLO7O3Fuza5s4M4DclmvAO5w0w==}
|
||||||
|
|
||||||
'@trpc/client@11.8.1':
|
'@trpc/client@11.8.1':
|
||||||
resolution: {integrity: sha512-L/SJFGanr9xGABmuDoeXR4xAdHJmsXsiF9OuH+apecJ+8sUITzVT1EPeqp0ebqA6lBhEl5pPfg3rngVhi/h60Q==}
|
resolution: {integrity: sha512-L/SJFGanr9xGABmuDoeXR4xAdHJmsXsiF9OuH+apecJ+8sUITzVT1EPeqp0ebqA6lBhEl5pPfg3rngVhi/h60Q==}
|
||||||
@@ -663,63 +666,63 @@ packages:
|
|||||||
'@types/resolve@1.20.2':
|
'@types/resolve@1.20.2':
|
||||||
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
|
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
|
||||||
|
|
||||||
'@typescript-eslint/eslint-plugin@8.50.1':
|
'@typescript-eslint/eslint-plugin@8.51.0':
|
||||||
resolution: {integrity: sha512-PKhLGDq3JAg0Jk/aK890knnqduuI/Qj+udH7wCf0217IGi4gt+acgCyPVe79qoT+qKUvHMDQkwJeKW9fwl8Cyw==}
|
resolution: {integrity: sha512-XtssGWJvypyM2ytBnSnKtHYOGT+4ZwTnBVl36TA4nRO2f4PRNGz5/1OszHzcZCvcBMh+qb7I06uoCmLTRdR9og==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@typescript-eslint/parser': ^8.50.1
|
'@typescript-eslint/parser': ^8.51.0
|
||||||
eslint: ^8.57.0 || ^9.0.0
|
eslint: ^8.57.0 || ^9.0.0
|
||||||
typescript: '>=4.8.4 <6.0.0'
|
typescript: '>=4.8.4 <6.0.0'
|
||||||
|
|
||||||
'@typescript-eslint/parser@8.50.1':
|
'@typescript-eslint/parser@8.51.0':
|
||||||
resolution: {integrity: sha512-hM5faZwg7aVNa819m/5r7D0h0c9yC4DUlWAOvHAtISdFTc8xB86VmX5Xqabrama3wIPJ/q9RbGS1worb6JfnMg==}
|
resolution: {integrity: sha512-3xP4XzzDNQOIqBMWogftkwxhg5oMKApqY0BAflmLZiFYHqyhSOxv/cd/zPQLTcCXr4AkaKb25joocY0BD1WC6A==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: ^8.57.0 || ^9.0.0
|
eslint: ^8.57.0 || ^9.0.0
|
||||||
typescript: '>=4.8.4 <6.0.0'
|
typescript: '>=4.8.4 <6.0.0'
|
||||||
|
|
||||||
'@typescript-eslint/project-service@8.50.1':
|
'@typescript-eslint/project-service@8.51.0':
|
||||||
resolution: {integrity: sha512-E1ur1MCVf+YiP89+o4Les/oBAVzmSbeRB0MQLfSlYtbWU17HPxZ6Bhs5iYmKZRALvEuBoXIZMOIRRc/P++Ortg==}
|
resolution: {integrity: sha512-Luv/GafO07Z7HpiI7qeEW5NW8HUtZI/fo/kE0YbtQEFpJRUuR0ajcWfCE5bnMvL7QQFrmT/odMe8QZww8X2nfQ==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: '>=4.8.4 <6.0.0'
|
typescript: '>=4.8.4 <6.0.0'
|
||||||
|
|
||||||
'@typescript-eslint/scope-manager@8.50.1':
|
'@typescript-eslint/scope-manager@8.51.0':
|
||||||
resolution: {integrity: sha512-mfRx06Myt3T4vuoHaKi8ZWNTPdzKPNBhiblze5N50//TSHOAQQevl/aolqA/BcqqbJ88GUnLqjjcBc8EWdBcVw==}
|
resolution: {integrity: sha512-JhhJDVwsSx4hiOEQPeajGhCWgBMBwVkxC/Pet53EpBVs7zHHtayKefw1jtPaNRXpI9RA2uocdmpdfE7T+NrizA==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
'@typescript-eslint/tsconfig-utils@8.50.1':
|
'@typescript-eslint/tsconfig-utils@8.51.0':
|
||||||
resolution: {integrity: sha512-ooHmotT/lCWLXi55G4mvaUF60aJa012QzvLK0Y+Mp4WdSt17QhMhWOaBWeGTFVkb2gDgBe19Cxy1elPXylslDw==}
|
resolution: {integrity: sha512-Qi5bSy/vuHeWyir2C8u/uqGMIlIDu8fuiYWv48ZGlZ/k+PRPHtaAu7erpc7p5bzw2WNNSniuxoMSO4Ar6V9OXw==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: '>=4.8.4 <6.0.0'
|
typescript: '>=4.8.4 <6.0.0'
|
||||||
|
|
||||||
'@typescript-eslint/type-utils@8.50.1':
|
'@typescript-eslint/type-utils@8.51.0':
|
||||||
resolution: {integrity: sha512-7J3bf022QZE42tYMO6SL+6lTPKFk/WphhRPe9Tw/el+cEwzLz1Jjz2PX3GtGQVxooLDKeMVmMt7fWpYRdG5Etg==}
|
resolution: {integrity: sha512-0XVtYzxnobc9K0VU7wRWg1yiUrw4oQzexCG2V2IDxxCxhqBMSMbjB+6o91A+Uc0GWtgjCa3Y8bi7hwI0Tu4n5Q==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: ^8.57.0 || ^9.0.0
|
eslint: ^8.57.0 || ^9.0.0
|
||||||
typescript: '>=4.8.4 <6.0.0'
|
typescript: '>=4.8.4 <6.0.0'
|
||||||
|
|
||||||
'@typescript-eslint/types@8.50.1':
|
'@typescript-eslint/types@8.51.0':
|
||||||
resolution: {integrity: sha512-v5lFIS2feTkNyMhd7AucE/9j/4V9v5iIbpVRncjk/K0sQ6Sb+Np9fgYS/63n6nwqahHQvbmujeBL7mp07Q9mlA==}
|
resolution: {integrity: sha512-TizAvWYFM6sSscmEakjY3sPqGwxZRSywSsPEiuZF6d5GmGD9Gvlsv0f6N8FvAAA0CD06l3rIcWNbsN1e5F/9Ag==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
'@typescript-eslint/typescript-estree@8.50.1':
|
'@typescript-eslint/typescript-estree@8.51.0':
|
||||||
resolution: {integrity: sha512-woHPdW+0gj53aM+cxchymJCrh0cyS7BTIdcDxWUNsclr9VDkOSbqC13juHzxOmQ22dDkMZEpZB+3X1WpUvzgVQ==}
|
resolution: {integrity: sha512-1qNjGqFRmlq0VW5iVlcyHBbCjPB7y6SxpBkrbhNWMy/65ZoncXCEPJxkRZL8McrseNH6lFhaxCIaX+vBuFnRng==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: '>=4.8.4 <6.0.0'
|
typescript: '>=4.8.4 <6.0.0'
|
||||||
|
|
||||||
'@typescript-eslint/utils@8.50.1':
|
'@typescript-eslint/utils@8.51.0':
|
||||||
resolution: {integrity: sha512-lCLp8H1T9T7gPbEuJSnHwnSuO9mDf8mfK/Nion5mZmiEaQD9sWf9W4dfeFqRyqRjF06/kBuTmAqcs9sewM2NbQ==}
|
resolution: {integrity: sha512-11rZYxSe0zabiKaCP2QAwRf/dnmgFgvTmeDTtZvUvXG3UuAdg/GU02NExmmIXzz3vLGgMdtrIosI84jITQOxUA==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: ^8.57.0 || ^9.0.0
|
eslint: ^8.57.0 || ^9.0.0
|
||||||
typescript: '>=4.8.4 <6.0.0'
|
typescript: '>=4.8.4 <6.0.0'
|
||||||
|
|
||||||
'@typescript-eslint/visitor-keys@8.50.1':
|
'@typescript-eslint/visitor-keys@8.51.0':
|
||||||
resolution: {integrity: sha512-IrDKrw7pCRUR94zeuCSUWQ+w8JEf5ZX5jl/e6AHGSLi1/zIr0lgutfn/7JpfCey+urpgQEdrZVYzCaVVKiTwhQ==}
|
resolution: {integrity: sha512-mM/JRQOzhVN1ykejrvwnBRV3+7yTKK8tVANVN3o1O0t0v7o+jqdVu9crPy5Y9dov15TJk/FTIgoUGHrTOVL3Zg==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
'@xmldom/xmldom@0.9.8':
|
'@xmldom/xmldom@0.9.8':
|
||||||
@@ -827,8 +830,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==}
|
resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==}
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
|
|
||||||
caniuse-lite@1.0.30001761:
|
caniuse-lite@1.0.30001762:
|
||||||
resolution: {integrity: sha512-JF9ptu1vP2coz98+5051jZ4PwQgd2ni8A+gYSN7EA7dPKIMf0pDlSUxhdmVOaV3/fYK5uWBkgSXJaRLr4+3A6g==}
|
resolution: {integrity: sha512-PxZwGNvH7Ak8WX5iXzoK1KPZttBXNPuaOvI2ZYU7NrlM+d9Ov+TUvlLOBNGzVXAntMSMMlJPd+jY6ovrVjSmUw==}
|
||||||
|
|
||||||
chalk@4.1.2:
|
chalk@4.1.2:
|
||||||
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
|
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
|
||||||
@@ -1039,8 +1042,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==}
|
resolution: {integrity: sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
esquery@1.6.0:
|
esquery@1.7.0:
|
||||||
resolution: {integrity: sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==}
|
resolution: {integrity: sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==}
|
||||||
engines: {node: '>=0.10'}
|
engines: {node: '>=0.10'}
|
||||||
|
|
||||||
esrap@2.2.1:
|
esrap@2.2.1:
|
||||||
@@ -1854,8 +1857,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==}
|
resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
ts-api-utils@2.1.0:
|
ts-api-utils@2.4.0:
|
||||||
resolution: {integrity: sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==}
|
resolution: {integrity: sha512-3TaVTaAv2gTiMB35i3FiGJaRfwb3Pyn/j3m/bfAvGe8FB7CF6u+LMYqYlDh7reQf7UNvoTvdfAqHGmPGOSsPmA==}
|
||||||
engines: {node: '>=18.12'}
|
engines: {node: '>=18.12'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: '>=4.8.4'
|
typescript: '>=4.8.4'
|
||||||
@@ -1877,8 +1880,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
|
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
|
|
||||||
typescript-eslint@8.50.1:
|
typescript-eslint@8.51.0:
|
||||||
resolution: {integrity: sha512-ytTHO+SoYSbhAH9CrYnMhiLx8To6PSSvqnvXyPUgPETCvB6eBKmTI9w6XMPS3HsBRGkwTVBX+urA8dYQx6bHfQ==}
|
resolution: {integrity: sha512-jh8ZuM5oEh2PSdyQG9YAEM1TCGuWenLSuSUhf/irbVUNW9O5FhbFVONviN2TgMTBnUmyHv7E56rYnfLZK6TkiA==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: ^8.57.0 || ^9.0.0
|
eslint: ^8.57.0 || ^9.0.0
|
||||||
@@ -2022,8 +2025,8 @@ packages:
|
|||||||
zimmerframe@1.1.4:
|
zimmerframe@1.1.4:
|
||||||
resolution: {integrity: sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==}
|
resolution: {integrity: sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==}
|
||||||
|
|
||||||
zod@4.2.1:
|
zod@4.3.5:
|
||||||
resolution: {integrity: sha512-0wZ1IRqGGhMP76gLqz8EyfBXKk0J2qo2+H3fi4mcUP/KtTocoX08nmIAHl1Z2kJIZbZee8KOpBCSNPRgauucjw==}
|
resolution: {integrity: sha512-k7Nwx6vuWx1IJ9Bjuf4Zt1PEllcwe7cls3VNzm4CQ1/hgtFUK2bRNG3rvnpPUhFjmqJKAKtjV576KnUkHocg/g==}
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
|
|
||||||
@@ -2114,7 +2117,7 @@ snapshots:
|
|||||||
'@esbuild/win32-x64@0.27.2':
|
'@esbuild/win32-x64@0.27.2':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@eslint-community/eslint-utils@4.9.0(eslint@9.39.2(jiti@1.21.7))':
|
'@eslint-community/eslint-utils@4.9.1(eslint@9.39.2(jiti@1.21.7))':
|
||||||
dependencies:
|
dependencies:
|
||||||
eslint: 9.39.2(jiti@1.21.7)
|
eslint: 9.39.2(jiti@1.21.7)
|
||||||
eslint-visitor-keys: 3.4.3
|
eslint-visitor-keys: 3.4.3
|
||||||
@@ -2386,12 +2389,12 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@tanstack/svelte-virtual@3.13.13(svelte@5.46.1)':
|
'@tanstack/svelte-virtual@3.13.16(svelte@5.46.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tanstack/virtual-core': 3.13.13
|
'@tanstack/virtual-core': 3.13.16
|
||||||
svelte: 5.46.1
|
svelte: 5.46.1
|
||||||
|
|
||||||
'@tanstack/virtual-core@3.13.13': {}
|
'@tanstack/virtual-core@3.13.16': {}
|
||||||
|
|
||||||
'@trpc/client@11.8.1(@trpc/server@11.8.1(typescript@5.9.3))(typescript@5.9.3)':
|
'@trpc/client@11.8.1(@trpc/server@11.8.1(typescript@5.9.3))(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -2428,95 +2431,95 @@ snapshots:
|
|||||||
|
|
||||||
'@types/resolve@1.20.2': {}
|
'@types/resolve@1.20.2': {}
|
||||||
|
|
||||||
'@typescript-eslint/eslint-plugin@8.50.1(@typescript-eslint/parser@8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
|
'@typescript-eslint/eslint-plugin@8.51.0(@typescript-eslint/parser@8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint-community/regexpp': 4.12.2
|
'@eslint-community/regexpp': 4.12.2
|
||||||
'@typescript-eslint/parser': 8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
'@typescript-eslint/parser': 8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
||||||
'@typescript-eslint/scope-manager': 8.50.1
|
'@typescript-eslint/scope-manager': 8.51.0
|
||||||
'@typescript-eslint/type-utils': 8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
'@typescript-eslint/type-utils': 8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
||||||
'@typescript-eslint/utils': 8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
'@typescript-eslint/utils': 8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
||||||
'@typescript-eslint/visitor-keys': 8.50.1
|
'@typescript-eslint/visitor-keys': 8.51.0
|
||||||
eslint: 9.39.2(jiti@1.21.7)
|
eslint: 9.39.2(jiti@1.21.7)
|
||||||
ignore: 7.0.5
|
ignore: 7.0.5
|
||||||
natural-compare: 1.4.0
|
natural-compare: 1.4.0
|
||||||
ts-api-utils: 2.1.0(typescript@5.9.3)
|
ts-api-utils: 2.4.0(typescript@5.9.3)
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/parser@8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
|
'@typescript-eslint/parser@8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/scope-manager': 8.50.1
|
'@typescript-eslint/scope-manager': 8.51.0
|
||||||
'@typescript-eslint/types': 8.50.1
|
'@typescript-eslint/types': 8.51.0
|
||||||
'@typescript-eslint/typescript-estree': 8.50.1(typescript@5.9.3)
|
'@typescript-eslint/typescript-estree': 8.51.0(typescript@5.9.3)
|
||||||
'@typescript-eslint/visitor-keys': 8.50.1
|
'@typescript-eslint/visitor-keys': 8.51.0
|
||||||
debug: 4.4.3
|
debug: 4.4.3
|
||||||
eslint: 9.39.2(jiti@1.21.7)
|
eslint: 9.39.2(jiti@1.21.7)
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/project-service@8.50.1(typescript@5.9.3)':
|
'@typescript-eslint/project-service@8.51.0(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/tsconfig-utils': 8.50.1(typescript@5.9.3)
|
'@typescript-eslint/tsconfig-utils': 8.51.0(typescript@5.9.3)
|
||||||
'@typescript-eslint/types': 8.50.1
|
'@typescript-eslint/types': 8.51.0
|
||||||
debug: 4.4.3
|
debug: 4.4.3
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/scope-manager@8.50.1':
|
'@typescript-eslint/scope-manager@8.51.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.50.1
|
'@typescript-eslint/types': 8.51.0
|
||||||
'@typescript-eslint/visitor-keys': 8.50.1
|
'@typescript-eslint/visitor-keys': 8.51.0
|
||||||
|
|
||||||
'@typescript-eslint/tsconfig-utils@8.50.1(typescript@5.9.3)':
|
'@typescript-eslint/tsconfig-utils@8.51.0(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
|
|
||||||
'@typescript-eslint/type-utils@8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
|
'@typescript-eslint/type-utils@8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.50.1
|
'@typescript-eslint/types': 8.51.0
|
||||||
'@typescript-eslint/typescript-estree': 8.50.1(typescript@5.9.3)
|
'@typescript-eslint/typescript-estree': 8.51.0(typescript@5.9.3)
|
||||||
'@typescript-eslint/utils': 8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
'@typescript-eslint/utils': 8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
||||||
debug: 4.4.3
|
debug: 4.4.3
|
||||||
eslint: 9.39.2(jiti@1.21.7)
|
eslint: 9.39.2(jiti@1.21.7)
|
||||||
ts-api-utils: 2.1.0(typescript@5.9.3)
|
ts-api-utils: 2.4.0(typescript@5.9.3)
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/types@8.50.1': {}
|
'@typescript-eslint/types@8.51.0': {}
|
||||||
|
|
||||||
'@typescript-eslint/typescript-estree@8.50.1(typescript@5.9.3)':
|
'@typescript-eslint/typescript-estree@8.51.0(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/project-service': 8.50.1(typescript@5.9.3)
|
'@typescript-eslint/project-service': 8.51.0(typescript@5.9.3)
|
||||||
'@typescript-eslint/tsconfig-utils': 8.50.1(typescript@5.9.3)
|
'@typescript-eslint/tsconfig-utils': 8.51.0(typescript@5.9.3)
|
||||||
'@typescript-eslint/types': 8.50.1
|
'@typescript-eslint/types': 8.51.0
|
||||||
'@typescript-eslint/visitor-keys': 8.50.1
|
'@typescript-eslint/visitor-keys': 8.51.0
|
||||||
debug: 4.4.3
|
debug: 4.4.3
|
||||||
minimatch: 9.0.5
|
minimatch: 9.0.5
|
||||||
semver: 7.7.3
|
semver: 7.7.3
|
||||||
tinyglobby: 0.2.15
|
tinyglobby: 0.2.15
|
||||||
ts-api-utils: 2.1.0(typescript@5.9.3)
|
ts-api-utils: 2.4.0(typescript@5.9.3)
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/utils@8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
|
'@typescript-eslint/utils@8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint-community/eslint-utils': 4.9.0(eslint@9.39.2(jiti@1.21.7))
|
'@eslint-community/eslint-utils': 4.9.1(eslint@9.39.2(jiti@1.21.7))
|
||||||
'@typescript-eslint/scope-manager': 8.50.1
|
'@typescript-eslint/scope-manager': 8.51.0
|
||||||
'@typescript-eslint/types': 8.50.1
|
'@typescript-eslint/types': 8.51.0
|
||||||
'@typescript-eslint/typescript-estree': 8.50.1(typescript@5.9.3)
|
'@typescript-eslint/typescript-estree': 8.51.0(typescript@5.9.3)
|
||||||
eslint: 9.39.2(jiti@1.21.7)
|
eslint: 9.39.2(jiti@1.21.7)
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/visitor-keys@8.50.1':
|
'@typescript-eslint/visitor-keys@8.51.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.50.1
|
'@typescript-eslint/types': 8.51.0
|
||||||
eslint-visitor-keys: 4.2.1
|
eslint-visitor-keys: 4.2.1
|
||||||
|
|
||||||
'@xmldom/xmldom@0.9.8':
|
'@xmldom/xmldom@0.9.8':
|
||||||
@@ -2564,7 +2567,7 @@ snapshots:
|
|||||||
autoprefixer@10.4.23(postcss@8.5.6):
|
autoprefixer@10.4.23(postcss@8.5.6):
|
||||||
dependencies:
|
dependencies:
|
||||||
browserslist: 4.28.1
|
browserslist: 4.28.1
|
||||||
caniuse-lite: 1.0.30001761
|
caniuse-lite: 1.0.30001762
|
||||||
fraction.js: 5.3.4
|
fraction.js: 5.3.4
|
||||||
picocolors: 1.1.1
|
picocolors: 1.1.1
|
||||||
postcss: 8.5.6
|
postcss: 8.5.6
|
||||||
@@ -2602,7 +2605,7 @@ snapshots:
|
|||||||
browserslist@4.28.1:
|
browserslist@4.28.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
baseline-browser-mapping: 2.9.11
|
baseline-browser-mapping: 2.9.11
|
||||||
caniuse-lite: 1.0.30001761
|
caniuse-lite: 1.0.30001762
|
||||||
electron-to-chromium: 1.5.267
|
electron-to-chromium: 1.5.267
|
||||||
node-releases: 2.0.27
|
node-releases: 2.0.27
|
||||||
update-browserslist-db: 1.2.3(browserslist@4.28.1)
|
update-browserslist-db: 1.2.3(browserslist@4.28.1)
|
||||||
@@ -2631,7 +2634,7 @@ snapshots:
|
|||||||
|
|
||||||
camelcase-css@2.0.1: {}
|
camelcase-css@2.0.1: {}
|
||||||
|
|
||||||
caniuse-lite@1.0.30001761: {}
|
caniuse-lite@1.0.30001762: {}
|
||||||
|
|
||||||
chalk@4.1.2:
|
chalk@4.1.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -2795,7 +2798,7 @@ snapshots:
|
|||||||
|
|
||||||
eslint-plugin-svelte@3.13.1(eslint@9.39.2(jiti@1.21.7))(svelte@5.46.1):
|
eslint-plugin-svelte@3.13.1(eslint@9.39.2(jiti@1.21.7))(svelte@5.46.1):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint-community/eslint-utils': 4.9.0(eslint@9.39.2(jiti@1.21.7))
|
'@eslint-community/eslint-utils': 4.9.1(eslint@9.39.2(jiti@1.21.7))
|
||||||
'@jridgewell/sourcemap-codec': 1.5.5
|
'@jridgewell/sourcemap-codec': 1.5.5
|
||||||
eslint: 9.39.2(jiti@1.21.7)
|
eslint: 9.39.2(jiti@1.21.7)
|
||||||
esutils: 2.0.3
|
esutils: 2.0.3
|
||||||
@@ -2828,7 +2831,7 @@ snapshots:
|
|||||||
|
|
||||||
eslint@9.39.2(jiti@1.21.7):
|
eslint@9.39.2(jiti@1.21.7):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint-community/eslint-utils': 4.9.0(eslint@9.39.2(jiti@1.21.7))
|
'@eslint-community/eslint-utils': 4.9.1(eslint@9.39.2(jiti@1.21.7))
|
||||||
'@eslint-community/regexpp': 4.12.2
|
'@eslint-community/regexpp': 4.12.2
|
||||||
'@eslint/config-array': 0.21.1
|
'@eslint/config-array': 0.21.1
|
||||||
'@eslint/config-helpers': 0.4.2
|
'@eslint/config-helpers': 0.4.2
|
||||||
@@ -2848,7 +2851,7 @@ snapshots:
|
|||||||
eslint-scope: 8.4.0
|
eslint-scope: 8.4.0
|
||||||
eslint-visitor-keys: 4.2.1
|
eslint-visitor-keys: 4.2.1
|
||||||
espree: 10.4.0
|
espree: 10.4.0
|
||||||
esquery: 1.6.0
|
esquery: 1.7.0
|
||||||
esutils: 2.0.3
|
esutils: 2.0.3
|
||||||
fast-deep-equal: 3.1.3
|
fast-deep-equal: 3.1.3
|
||||||
file-entry-cache: 8.0.0
|
file-entry-cache: 8.0.0
|
||||||
@@ -2875,7 +2878,7 @@ snapshots:
|
|||||||
acorn-jsx: 5.3.2(acorn@8.15.0)
|
acorn-jsx: 5.3.2(acorn@8.15.0)
|
||||||
eslint-visitor-keys: 4.2.1
|
eslint-visitor-keys: 4.2.1
|
||||||
|
|
||||||
esquery@1.6.0:
|
esquery@1.7.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
estraverse: 5.3.0
|
estraverse: 5.3.0
|
||||||
|
|
||||||
@@ -3601,7 +3604,7 @@ snapshots:
|
|||||||
|
|
||||||
totalist@3.0.1: {}
|
totalist@3.0.1: {}
|
||||||
|
|
||||||
ts-api-utils@2.1.0(typescript@5.9.3):
|
ts-api-utils@2.4.0(typescript@5.9.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
|
|
||||||
@@ -3615,12 +3618,12 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
prelude-ls: 1.2.1
|
prelude-ls: 1.2.1
|
||||||
|
|
||||||
typescript-eslint@8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3):
|
typescript-eslint@8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/eslint-plugin': 8.50.1(@typescript-eslint/parser@8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
'@typescript-eslint/eslint-plugin': 8.51.0(@typescript-eslint/parser@8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
||||||
'@typescript-eslint/parser': 8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
'@typescript-eslint/parser': 8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
||||||
'@typescript-eslint/typescript-estree': 8.50.1(typescript@5.9.3)
|
'@typescript-eslint/typescript-estree': 8.51.0(typescript@5.9.3)
|
||||||
'@typescript-eslint/utils': 8.50.1(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
'@typescript-eslint/utils': 8.51.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
|
||||||
eslint: 9.39.2(jiti@1.21.7)
|
eslint: 9.39.2(jiti@1.21.7)
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -3704,4 +3707,4 @@ snapshots:
|
|||||||
|
|
||||||
zimmerframe@1.1.4: {}
|
zimmerframe@1.1.4: {}
|
||||||
|
|
||||||
zod@4.2.1: {}
|
zod@4.3.5: {}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
count,
|
count,
|
||||||
estimateSize: itemHeight,
|
estimateSize: itemHeight,
|
||||||
gap: itemGap,
|
gap: itemGap,
|
||||||
overscan: 5,
|
|
||||||
scrollMargin,
|
scrollMargin,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -35,7 +34,7 @@
|
|||||||
if (!element) return;
|
if (!element) return;
|
||||||
|
|
||||||
const observer = new ResizeObserver(() => {
|
const observer = new ResizeObserver(() => {
|
||||||
scrollMargin = element!.getBoundingClientRect().top + window.scrollY;
|
scrollMargin = Math.round(element!.getBoundingClientRect().top + window.scrollY);
|
||||||
});
|
});
|
||||||
observer.observe(element.parentElement!);
|
observer.observe(element.parentElement!);
|
||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
@@ -55,7 +54,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{#if placeholder && $virtualizer.getVirtualItems().length === 0}
|
{#if placeholder && count === 0}
|
||||||
{@render placeholder()}
|
{@render placeholder()}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from "$app/environment";
|
import { getFileThumbnail } from "$lib/modules/file";
|
||||||
import type { SummarizedFileInfo } from "$lib/modules/filesystem";
|
import type { SummarizedFileInfo } from "$lib/modules/filesystem";
|
||||||
import { requestFileThumbnailDownload } from "$lib/services/file";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
info: SummarizedFileInfo;
|
info: SummarizedFileInfo;
|
||||||
@@ -10,25 +9,16 @@
|
|||||||
|
|
||||||
let { info, onclick }: Props = $props();
|
let { info, onclick }: Props = $props();
|
||||||
|
|
||||||
let showThumbnail = $derived(
|
let thumbnail = $derived(getFileThumbnail(info));
|
||||||
browser && (info.contentType.startsWith("image/") || info.contentType.startsWith("video/")),
|
|
||||||
);
|
|
||||||
let thumbnailPromise = $derived(
|
|
||||||
showThumbnail ? requestFileThumbnailDownload(info.id, info.dataKey?.key) : null,
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onclick={onclick && (() => setTimeout(() => onclick(info), 100))}
|
onclick={onclick && (() => setTimeout(() => onclick(info), 100))}
|
||||||
class="aspect-square overflow-hidden rounded transition active:scale-95 active:brightness-90"
|
class="aspect-square overflow-hidden rounded transition active:scale-95 active:brightness-90"
|
||||||
>
|
>
|
||||||
{#await thumbnailPromise}
|
{#if $thumbnail}
|
||||||
|
<img src={$thumbnail} alt={info.name} class="h-full w-full object-cover" />
|
||||||
|
{:else}
|
||||||
<div class="h-full w-full bg-gray-100"></div>
|
<div class="h-full w-full bg-gray-100"></div>
|
||||||
{:then thumbnail}
|
{/if}
|
||||||
{#if thumbnail}
|
|
||||||
<img src={thumbnail} alt={info.name} class="h-full w-full object-cover" />
|
|
||||||
{:else}
|
|
||||||
<div class="h-full w-full bg-gray-100"></div>
|
|
||||||
{/if}
|
|
||||||
{/await}
|
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
let { categories, categoryMenuIcon, onCategoryClick, onCategoryMenuClick }: Props = $props();
|
let { categories, categoryMenuIcon, onCategoryClick, onCategoryMenuClick }: Props = $props();
|
||||||
|
|
||||||
let categoriesWithName = $derived(sortEntries($state.snapshot(categories)));
|
let categoriesWithName = $derived(sortEntries([...categories]));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if categoriesWithName.length > 0}
|
{#if categoriesWithName.length > 0}
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { CheckBox, RowVirtualizer } from "$lib/components/atoms";
|
|
||||||
import { SubCategories, type SelectedCategory } from "$lib/components/molecules";
|
|
||||||
import { updateCategoryInfo } from "$lib/indexedDB";
|
|
||||||
import type { CategoryInfo } from "$lib/modules/filesystem";
|
|
||||||
import { sortEntries } from "$lib/utils";
|
|
||||||
import File from "./File.svelte";
|
|
||||||
import type { SelectedFile } from "./service";
|
|
||||||
|
|
||||||
import IconMoreVert from "~icons/material-symbols/more-vert";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
info: CategoryInfo;
|
|
||||||
isFileRecursive: boolean | undefined;
|
|
||||||
onFileClick: (file: SelectedFile) => void;
|
|
||||||
onFileRemoveClick: (file: SelectedFile) => void;
|
|
||||||
onSubCategoryClick: (subCategory: SelectedCategory) => void;
|
|
||||||
onSubCategoryCreateClick: () => void;
|
|
||||||
onSubCategoryMenuClick: (subCategory: SelectedCategory) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
info,
|
|
||||||
onFileClick,
|
|
||||||
onFileRemoveClick,
|
|
||||||
onSubCategoryClick,
|
|
||||||
onSubCategoryCreateClick,
|
|
||||||
onSubCategoryMenuClick,
|
|
||||||
isFileRecursive = $bindable(),
|
|
||||||
}: Props = $props();
|
|
||||||
|
|
||||||
let lastCategoryId = $state<CategoryInfo["id"] | undefined>();
|
|
||||||
let lastIsFileRecursive = $state<boolean | undefined>();
|
|
||||||
|
|
||||||
let files = $derived(
|
|
||||||
sortEntries(
|
|
||||||
info.files
|
|
||||||
?.map((file) => ({ name: file.name, details: file }))
|
|
||||||
.filter(({ details }) => isFileRecursive || !details.isRecursive) ?? [],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (info.id === "root" || isFileRecursive === undefined) return;
|
|
||||||
if (lastCategoryId !== info.id) {
|
|
||||||
lastCategoryId = info.id;
|
|
||||||
lastIsFileRecursive = isFileRecursive;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (lastIsFileRecursive === isFileRecursive) return;
|
|
||||||
|
|
||||||
lastIsFileRecursive = isFileRecursive;
|
|
||||||
void updateCategoryInfo(info.id, { isFileRecursive });
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="space-y-4">
|
|
||||||
<div class="space-y-4 bg-white p-4">
|
|
||||||
{#if info.id !== "root"}
|
|
||||||
<p class="text-lg font-bold text-gray-800">하위 카테고리</p>
|
|
||||||
{/if}
|
|
||||||
<SubCategories
|
|
||||||
{info}
|
|
||||||
{onSubCategoryClick}
|
|
||||||
{onSubCategoryCreateClick}
|
|
||||||
{onSubCategoryMenuClick}
|
|
||||||
subCategoryMenuIcon={IconMoreVert}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{#if info.id !== "root"}
|
|
||||||
<div class="space-y-4 bg-white p-4">
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<p class="text-lg font-bold text-gray-800">파일</p>
|
|
||||||
<CheckBox bind:checked={isFileRecursive}>
|
|
||||||
<p class="font-medium">하위 카테고리의 파일</p>
|
|
||||||
</CheckBox>
|
|
||||||
</div>
|
|
||||||
<RowVirtualizer count={files.length} itemHeight={() => 48} itemGap={4}>
|
|
||||||
{#snippet item(index)}
|
|
||||||
{@const { details } = files[index]!}
|
|
||||||
<File
|
|
||||||
info={details}
|
|
||||||
onclick={onFileClick}
|
|
||||||
onRemoveClick={!details.isRecursive ? onFileRemoveClick : undefined}
|
|
||||||
/>
|
|
||||||
{/snippet}
|
|
||||||
{#snippet placeholder()}
|
|
||||||
<p class="text-center text-gray-500">이 카테고리에 추가된 파일이 없어요.</p>
|
|
||||||
{/snippet}
|
|
||||||
</RowVirtualizer>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
export { default } from "./Category.svelte";
|
|
||||||
export * from "./service";
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
export interface SelectedFile {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { FileThumbnailButton, RowVirtualizer } from "$lib/components/atoms";
|
|
||||||
import type { SummarizedFileInfo } from "$lib/modules/filesystem";
|
|
||||||
import { formatDate, formatDateSortable, SortBy, sortEntries } from "$lib/utils";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
files: SummarizedFileInfo[];
|
|
||||||
onFileClick?: (file: SummarizedFileInfo) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { files, onFileClick }: Props = $props();
|
|
||||||
|
|
||||||
type Row =
|
|
||||||
| { type: "header"; label: string }
|
|
||||||
| { type: "items"; files: SummarizedFileInfo[]; isLast: boolean };
|
|
||||||
|
|
||||||
let rows = $derived.by(() => {
|
|
||||||
const groups = Map.groupBy(
|
|
||||||
files.filter(
|
|
||||||
(file) => file.contentType.startsWith("image/") || file.contentType.startsWith("video/"),
|
|
||||||
),
|
|
||||||
(file) => formatDateSortable(file.createdAt ?? file.lastModifiedAt),
|
|
||||||
);
|
|
||||||
return Array.from(groups.entries())
|
|
||||||
.sort(([dateA], [dateB]) => dateB.localeCompare(dateA))
|
|
||||||
.flatMap(([_, entries]) => {
|
|
||||||
const sortedEntries = [...entries];
|
|
||||||
sortEntries(sortedEntries, SortBy.DATE_DESC);
|
|
||||||
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
type: "header",
|
|
||||||
label: formatDate(sortedEntries[0]!.createdAt ?? sortedEntries[0]!.lastModifiedAt),
|
|
||||||
},
|
|
||||||
...Array.from({ length: Math.ceil(sortedEntries.length / 4) }, (_, i) => {
|
|
||||||
const start = i * 4;
|
|
||||||
const end = start + 4;
|
|
||||||
return {
|
|
||||||
type: "items" as const,
|
|
||||||
files: sortedEntries.slice(start, end),
|
|
||||||
isLast: end >= sortedEntries.length,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
] satisfies Row[];
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<RowVirtualizer
|
|
||||||
count={rows.length}
|
|
||||||
itemHeight={(index) =>
|
|
||||||
rows[index]!.type === "header" ? 28 : 185 + (rows[index]!.isLast ? 16 : 0)}
|
|
||||||
class="flex flex-grow flex-col"
|
|
||||||
>
|
|
||||||
{#snippet item(index)}
|
|
||||||
{@const row = rows[index]!}
|
|
||||||
{#if row.type === "header"}
|
|
||||||
<p class="pb-2 text-sm font-medium">{row.label}</p>
|
|
||||||
{:else}
|
|
||||||
<div class={["grid grid-cols-4 gap-x-1", row.isLast ? "pb-4" : "pb-1"]}>
|
|
||||||
{#each row.files as file (file.id)}
|
|
||||||
<FileThumbnailButton info={file} onclick={onFileClick} />
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
{/snippet}
|
|
||||||
{#snippet placeholder()}
|
|
||||||
<div class="flex h-full flex-grow items-center justify-center">
|
|
||||||
<p class="text-gray-500">
|
|
||||||
{#if files.length === 0}
|
|
||||||
업로드된 파일이 없어요.
|
|
||||||
{:else}
|
|
||||||
사진 또는 동영상이 없어요.
|
|
||||||
{/if}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{/snippet}
|
|
||||||
</RowVirtualizer>
|
|
||||||
@@ -1,4 +1 @@
|
|||||||
export * from "./Category";
|
|
||||||
export { default as Category } from "./Category";
|
|
||||||
export { default as Gallery } from "./Gallery.svelte";
|
|
||||||
export * from "./modals";
|
export * from "./modals";
|
||||||
|
|||||||
@@ -13,15 +13,15 @@ interface FileInfo {
|
|||||||
contentType: string;
|
contentType: string;
|
||||||
createdAt?: Date;
|
createdAt?: Date;
|
||||||
lastModifiedAt: Date;
|
lastModifiedAt: Date;
|
||||||
categoryIds: number[];
|
categoryIds?: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CategoryInfo {
|
interface CategoryInfo {
|
||||||
id: number;
|
id: number;
|
||||||
parentId: CategoryId;
|
parentId: CategoryId;
|
||||||
name: string;
|
name: string;
|
||||||
files: { id: number; isRecursive: boolean }[];
|
files?: { id: number; isRecursive: boolean }[];
|
||||||
isFileRecursive: boolean;
|
isFileRecursive?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filesystem = new Dexie("filesystem") as Dexie & {
|
const filesystem = new Dexie("filesystem") as Dexie & {
|
||||||
@@ -55,13 +55,23 @@ export const getDirectoryInfo = async (id: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const storeDirectoryInfo = async (directoryInfo: DirectoryInfo) => {
|
export const storeDirectoryInfo = async (directoryInfo: DirectoryInfo) => {
|
||||||
await filesystem.directory.put(directoryInfo);
|
await filesystem.directory.upsert(directoryInfo.id, { ...directoryInfo });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteDirectoryInfo = async (id: number) => {
|
export const deleteDirectoryInfo = async (id: number) => {
|
||||||
await filesystem.directory.delete(id);
|
await filesystem.directory.delete(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const deleteDanglingDirectoryInfos = async (
|
||||||
|
parentId: DirectoryId,
|
||||||
|
validIds: Set<number>,
|
||||||
|
) => {
|
||||||
|
await filesystem.directory
|
||||||
|
.where({ parentId })
|
||||||
|
.and((directory) => !validIds.has(directory.id))
|
||||||
|
.delete();
|
||||||
|
};
|
||||||
|
|
||||||
export const getAllFileInfos = async () => {
|
export const getAllFileInfos = async () => {
|
||||||
return await filesystem.file.toArray();
|
return await filesystem.file.toArray();
|
||||||
};
|
};
|
||||||
@@ -79,13 +89,24 @@ export const bulkGetFileInfos = async (ids: number[]) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const storeFileInfo = async (fileInfo: FileInfo) => {
|
export const storeFileInfo = async (fileInfo: FileInfo) => {
|
||||||
await filesystem.file.put(fileInfo);
|
await filesystem.file.upsert(fileInfo.id, { ...fileInfo });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteFileInfo = async (id: number) => {
|
export const deleteFileInfo = async (id: number) => {
|
||||||
await filesystem.file.delete(id);
|
await filesystem.file.delete(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const bulkDeleteFileInfos = async (ids: number[]) => {
|
||||||
|
await filesystem.file.bulkDelete(ids);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteDanglingFileInfos = async (parentId: DirectoryId, validIds: Set<number>) => {
|
||||||
|
await filesystem.file
|
||||||
|
.where({ parentId })
|
||||||
|
.and((file) => !validIds.has(file.id))
|
||||||
|
.delete();
|
||||||
|
};
|
||||||
|
|
||||||
export const getCategoryInfos = async (parentId: CategoryId) => {
|
export const getCategoryInfos = async (parentId: CategoryId) => {
|
||||||
return await filesystem.category.where({ parentId }).toArray();
|
return await filesystem.category.where({ parentId }).toArray();
|
||||||
};
|
};
|
||||||
@@ -95,7 +116,7 @@ export const getCategoryInfo = async (id: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const storeCategoryInfo = async (categoryInfo: CategoryInfo) => {
|
export const storeCategoryInfo = async (categoryInfo: CategoryInfo) => {
|
||||||
await filesystem.category.put(categoryInfo);
|
await filesystem.category.upsert(categoryInfo.id, { ...categoryInfo });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateCategoryInfo = async (id: number, changes: { isFileRecursive?: boolean }) => {
|
export const updateCategoryInfo = async (id: number, changes: { isFileRecursive?: boolean }) => {
|
||||||
@@ -106,6 +127,13 @@ export const deleteCategoryInfo = async (id: number) => {
|
|||||||
await filesystem.category.delete(id);
|
await filesystem.category.delete(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const deleteDanglingCategoryInfos = async (parentId: CategoryId, validIds: Set<number>) => {
|
||||||
|
await filesystem.category
|
||||||
|
.where({ parentId })
|
||||||
|
.and((category) => !validIds.has(category.id))
|
||||||
|
.delete();
|
||||||
|
};
|
||||||
|
|
||||||
export const cleanupDanglingInfos = async () => {
|
export const cleanupDanglingInfos = async () => {
|
||||||
const validDirectoryIds: number[] = [];
|
const validDirectoryIds: number[] = [];
|
||||||
const validFileIds: number[] = [];
|
const validFileIds: number[] = [];
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
import { LRUCache } from "lru-cache";
|
|
||||||
import {
|
import {
|
||||||
getFileCacheIndex as getFileCacheIndexFromIndexedDB,
|
getFileCacheIndex as getFileCacheIndexFromIndexedDB,
|
||||||
storeFileCacheIndex,
|
storeFileCacheIndex,
|
||||||
deleteFileCacheIndex,
|
deleteFileCacheIndex,
|
||||||
type FileCacheIndex,
|
type FileCacheIndex,
|
||||||
} from "$lib/indexedDB";
|
} from "$lib/indexedDB";
|
||||||
import { readFile, writeFile, deleteFile, deleteDirectory } from "$lib/modules/opfs";
|
import { readFile, writeFile, deleteFile } from "$lib/modules/opfs";
|
||||||
import { getThumbnailUrl } from "$lib/modules/thumbnail";
|
|
||||||
|
|
||||||
const fileCacheIndex = new Map<number, FileCacheIndex>();
|
const fileCacheIndex = new Map<number, FileCacheIndex>();
|
||||||
const loadedThumbnails = new LRUCache<number, string>({ max: 100 });
|
|
||||||
|
|
||||||
export const prepareFileCache = async () => {
|
export const prepareFileCache = async () => {
|
||||||
for (const cache of await getFileCacheIndexFromIndexedDB()) {
|
for (const cache of await getFileCacheIndexFromIndexedDB()) {
|
||||||
@@ -51,30 +48,3 @@ export const deleteFileCache = async (fileId: number) => {
|
|||||||
await deleteFile(`/cache/${fileId}`);
|
await deleteFile(`/cache/${fileId}`);
|
||||||
await deleteFileCacheIndex(fileId);
|
await deleteFileCacheIndex(fileId);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFileThumbnailCache = async (fileId: number) => {
|
|
||||||
const thumbnail = loadedThumbnails.get(fileId);
|
|
||||||
if (thumbnail) return thumbnail;
|
|
||||||
|
|
||||||
const thumbnailBuffer = await readFile(`/thumbnail/file/${fileId}`);
|
|
||||||
if (!thumbnailBuffer) return null;
|
|
||||||
|
|
||||||
const thumbnailUrl = getThumbnailUrl(thumbnailBuffer);
|
|
||||||
loadedThumbnails.set(fileId, thumbnailUrl);
|
|
||||||
return thumbnailUrl;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const storeFileThumbnailCache = async (fileId: number, thumbnailBuffer: ArrayBuffer) => {
|
|
||||||
await writeFile(`/thumbnail/file/${fileId}`, thumbnailBuffer);
|
|
||||||
loadedThumbnails.set(fileId, getThumbnailUrl(thumbnailBuffer));
|
|
||||||
};
|
|
||||||
|
|
||||||
export const deleteFileThumbnailCache = async (fileId: number) => {
|
|
||||||
loadedThumbnails.delete(fileId);
|
|
||||||
await deleteFile(`/thumbnail/file/${fileId}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const deleteAllFileThumbnailCaches = async () => {
|
|
||||||
loadedThumbnails.clear();
|
|
||||||
await deleteDirectory("/thumbnail/file");
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
export * from "./cache";
|
export * from "./cache";
|
||||||
export * from "./download.svelte";
|
export * from "./download.svelte";
|
||||||
|
export * from "./thumbnail";
|
||||||
export * from "./upload.svelte";
|
export * from "./upload.svelte";
|
||||||
|
|||||||
90
src/lib/modules/file/thumbnail.ts
Normal file
90
src/lib/modules/file/thumbnail.ts
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import { LRUCache } from "lru-cache";
|
||||||
|
import { writable, type Writable } from "svelte/store";
|
||||||
|
import { browser } from "$app/environment";
|
||||||
|
import { decryptData } from "$lib/modules/crypto";
|
||||||
|
import type { SummarizedFileInfo } from "$lib/modules/filesystem";
|
||||||
|
import { readFile, writeFile, deleteFile, deleteDirectory } from "$lib/modules/opfs";
|
||||||
|
import { getThumbnailUrl } from "$lib/modules/thumbnail";
|
||||||
|
import { isTRPCClientError, trpc } from "$trpc/client";
|
||||||
|
|
||||||
|
const loadedThumbnails = new LRUCache<number, Writable<string>>({ max: 100 });
|
||||||
|
const loadingThumbnails = new Map<number, Writable<string | undefined>>();
|
||||||
|
|
||||||
|
const fetchFromOpfs = async (fileId: number) => {
|
||||||
|
const thumbnailBuffer = await readFile(`/thumbnail/file/${fileId}`);
|
||||||
|
if (thumbnailBuffer) {
|
||||||
|
return getThumbnailUrl(thumbnailBuffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchFromServer = async (fileId: number, dataKey: CryptoKey) => {
|
||||||
|
try {
|
||||||
|
const [thumbnailEncrypted, { contentIv: thumbnailEncryptedIv }] = await Promise.all([
|
||||||
|
fetch(`/api/file/${fileId}/thumbnail/download`),
|
||||||
|
trpc().file.thumbnail.query({ id: fileId }),
|
||||||
|
]);
|
||||||
|
const thumbnailBuffer = await decryptData(
|
||||||
|
await thumbnailEncrypted.arrayBuffer(),
|
||||||
|
thumbnailEncryptedIv,
|
||||||
|
dataKey,
|
||||||
|
);
|
||||||
|
|
||||||
|
void writeFile(`/thumbnail/file/${fileId}`, thumbnailBuffer);
|
||||||
|
return getThumbnailUrl(thumbnailBuffer);
|
||||||
|
} catch (e) {
|
||||||
|
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getFileThumbnail = (file: SummarizedFileInfo) => {
|
||||||
|
if (
|
||||||
|
!browser ||
|
||||||
|
!(file.contentType.startsWith("image/") || file.contentType.startsWith("video/"))
|
||||||
|
) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const thumbnail = loadedThumbnails.get(file.id);
|
||||||
|
if (thumbnail) return thumbnail;
|
||||||
|
|
||||||
|
let loadingThumbnail = loadingThumbnails.get(file.id);
|
||||||
|
if (loadingThumbnail) return loadingThumbnail;
|
||||||
|
|
||||||
|
loadingThumbnail = writable(undefined);
|
||||||
|
loadingThumbnails.set(file.id, loadingThumbnail);
|
||||||
|
|
||||||
|
fetchFromOpfs(file.id)
|
||||||
|
.then((thumbnail) => thumbnail ?? (file.dataKey && fetchFromServer(file.id, file.dataKey.key)))
|
||||||
|
.then((thumbnail) => {
|
||||||
|
if (thumbnail) {
|
||||||
|
loadingThumbnail.set(thumbnail);
|
||||||
|
loadedThumbnails.set(file.id, loadingThumbnail as Writable<string>);
|
||||||
|
}
|
||||||
|
loadingThumbnails.delete(file.id);
|
||||||
|
});
|
||||||
|
return loadingThumbnail;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const storeFileThumbnailCache = async (fileId: number, thumbnailBuffer: ArrayBuffer) => {
|
||||||
|
await writeFile(`/thumbnail/file/${fileId}`, thumbnailBuffer);
|
||||||
|
|
||||||
|
const oldThumbnail = loadedThumbnails.get(fileId);
|
||||||
|
if (oldThumbnail) {
|
||||||
|
oldThumbnail.set(getThumbnailUrl(thumbnailBuffer));
|
||||||
|
} else {
|
||||||
|
loadedThumbnails.set(fileId, writable(getThumbnailUrl(thumbnailBuffer)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteFileThumbnailCache = async (fileId: number) => {
|
||||||
|
loadedThumbnails.delete(fileId);
|
||||||
|
await deleteFile(`/thumbnail/file/${fileId}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteAllFileThumbnailCaches = async () => {
|
||||||
|
loadedThumbnails.clear();
|
||||||
|
await deleteDirectory(`/thumbnail/file`);
|
||||||
|
};
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
digestMessage,
|
digestMessage,
|
||||||
signMessageHmac,
|
signMessageHmac,
|
||||||
} from "$lib/modules/crypto";
|
} from "$lib/modules/crypto";
|
||||||
|
import { Scheduler } from "$lib/modules/scheduler";
|
||||||
import { generateThumbnail } from "$lib/modules/thumbnail";
|
import { generateThumbnail } from "$lib/modules/thumbnail";
|
||||||
import type {
|
import type {
|
||||||
FileThumbnailUploadRequest,
|
FileThumbnailUploadRequest,
|
||||||
@@ -23,6 +24,7 @@ export interface FileUploadState {
|
|||||||
name: string;
|
name: string;
|
||||||
parentId: DirectoryId;
|
parentId: DirectoryId;
|
||||||
status:
|
status:
|
||||||
|
| "queued"
|
||||||
| "encryption-pending"
|
| "encryption-pending"
|
||||||
| "encrypting"
|
| "encrypting"
|
||||||
| "upload-pending"
|
| "upload-pending"
|
||||||
@@ -36,13 +38,16 @@ export interface FileUploadState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type LiveFileUploadState = FileUploadState & {
|
export type LiveFileUploadState = FileUploadState & {
|
||||||
status: "encryption-pending" | "encrypting" | "upload-pending" | "uploading";
|
status: "queued" | "encryption-pending" | "encrypting" | "upload-pending" | "uploading";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const scheduler = new Scheduler<
|
||||||
|
{ fileId: number; fileBuffer: ArrayBuffer; thumbnailBuffer?: ArrayBuffer } | undefined
|
||||||
|
>();
|
||||||
let uploadingFiles: FileUploadState[] = $state([]);
|
let uploadingFiles: FileUploadState[] = $state([]);
|
||||||
|
|
||||||
const isFileUploading = (status: FileUploadState["status"]) =>
|
const isFileUploading = (status: FileUploadState["status"]) =>
|
||||||
["encryption-pending", "encrypting", "upload-pending", "uploading"].includes(status);
|
["queued", "encryption-pending", "encrypting", "upload-pending", "uploading"].includes(status);
|
||||||
|
|
||||||
export const getUploadingFiles = (parentId?: DirectoryId) => {
|
export const getUploadingFiles = (parentId?: DirectoryId) => {
|
||||||
return uploadingFiles.filter(
|
return uploadingFiles.filter(
|
||||||
@@ -183,80 +188,82 @@ export const uploadFile = async (
|
|||||||
hmacSecret: HmacSecret,
|
hmacSecret: HmacSecret,
|
||||||
masterKey: MasterKey,
|
masterKey: MasterKey,
|
||||||
onDuplicate: () => Promise<boolean>,
|
onDuplicate: () => Promise<boolean>,
|
||||||
): Promise<
|
) => {
|
||||||
{ fileId: number; fileBuffer: ArrayBuffer; thumbnailBuffer?: ArrayBuffer } | undefined
|
|
||||||
> => {
|
|
||||||
uploadingFiles.push({
|
uploadingFiles.push({
|
||||||
name: file.name,
|
name: file.name,
|
||||||
parentId,
|
parentId,
|
||||||
status: "encryption-pending",
|
status: "queued",
|
||||||
});
|
});
|
||||||
const state = uploadingFiles.at(-1)!;
|
const state = uploadingFiles.at(-1)!;
|
||||||
|
|
||||||
try {
|
return await scheduler.schedule(file.size, async () => {
|
||||||
const { fileBuffer, fileSigned } = await requestDuplicateFileScan(
|
state.status = "encryption-pending";
|
||||||
file,
|
|
||||||
hmacSecret,
|
|
||||||
onDuplicate,
|
|
||||||
);
|
|
||||||
if (!fileBuffer || !fileSigned) {
|
|
||||||
state.status = "canceled";
|
|
||||||
uploadingFiles = uploadingFiles.filter((file) => file !== state);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
try {
|
||||||
dataKeyWrapped,
|
const { fileBuffer, fileSigned } = await requestDuplicateFileScan(
|
||||||
dataKeyVersion,
|
file,
|
||||||
fileType,
|
hmacSecret,
|
||||||
fileEncrypted,
|
onDuplicate,
|
||||||
fileEncryptedHash,
|
);
|
||||||
nameEncrypted,
|
if (!fileBuffer || !fileSigned) {
|
||||||
createdAtEncrypted,
|
state.status = "canceled";
|
||||||
lastModifiedAtEncrypted,
|
uploadingFiles = uploadingFiles.filter((file) => file !== state);
|
||||||
thumbnail,
|
return undefined;
|
||||||
} = await encryptFile(state, file, fileBuffer, masterKey);
|
}
|
||||||
|
|
||||||
const form = new FormData();
|
const {
|
||||||
form.set(
|
dataKeyWrapped,
|
||||||
"metadata",
|
dataKeyVersion,
|
||||||
JSON.stringify({
|
fileType,
|
||||||
parent: parentId,
|
fileEncrypted,
|
||||||
mekVersion: masterKey.version,
|
fileEncryptedHash,
|
||||||
dek: dataKeyWrapped,
|
nameEncrypted,
|
||||||
dekVersion: dataKeyVersion.toISOString(),
|
createdAtEncrypted,
|
||||||
hskVersion: hmacSecret.version,
|
lastModifiedAtEncrypted,
|
||||||
contentHmac: fileSigned,
|
thumbnail,
|
||||||
contentType: fileType,
|
} = await encryptFile(state, file, fileBuffer, masterKey);
|
||||||
contentIv: fileEncrypted.iv,
|
|
||||||
name: nameEncrypted.ciphertext,
|
|
||||||
nameIv: nameEncrypted.iv,
|
|
||||||
createdAt: createdAtEncrypted?.ciphertext,
|
|
||||||
createdAtIv: createdAtEncrypted?.iv,
|
|
||||||
lastModifiedAt: lastModifiedAtEncrypted.ciphertext,
|
|
||||||
lastModifiedAtIv: lastModifiedAtEncrypted.iv,
|
|
||||||
} satisfies FileUploadRequest),
|
|
||||||
);
|
|
||||||
form.set("content", new Blob([fileEncrypted.ciphertext]));
|
|
||||||
form.set("checksum", fileEncryptedHash);
|
|
||||||
|
|
||||||
let thumbnailForm = null;
|
const form = new FormData();
|
||||||
if (thumbnail) {
|
form.set(
|
||||||
thumbnailForm = new FormData();
|
|
||||||
thumbnailForm.set(
|
|
||||||
"metadata",
|
"metadata",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
|
parent: parentId,
|
||||||
|
mekVersion: masterKey.version,
|
||||||
|
dek: dataKeyWrapped,
|
||||||
dekVersion: dataKeyVersion.toISOString(),
|
dekVersion: dataKeyVersion.toISOString(),
|
||||||
contentIv: thumbnail.iv,
|
hskVersion: hmacSecret.version,
|
||||||
} satisfies FileThumbnailUploadRequest),
|
contentHmac: fileSigned,
|
||||||
|
contentType: fileType,
|
||||||
|
contentIv: fileEncrypted.iv,
|
||||||
|
name: nameEncrypted.ciphertext,
|
||||||
|
nameIv: nameEncrypted.iv,
|
||||||
|
createdAt: createdAtEncrypted?.ciphertext,
|
||||||
|
createdAtIv: createdAtEncrypted?.iv,
|
||||||
|
lastModifiedAt: lastModifiedAtEncrypted.ciphertext,
|
||||||
|
lastModifiedAtIv: lastModifiedAtEncrypted.iv,
|
||||||
|
} satisfies FileUploadRequest),
|
||||||
);
|
);
|
||||||
thumbnailForm.set("content", new Blob([thumbnail.ciphertext]));
|
form.set("content", new Blob([fileEncrypted.ciphertext]));
|
||||||
}
|
form.set("checksum", fileEncryptedHash);
|
||||||
|
|
||||||
const { fileId } = await requestFileUpload(state, form, thumbnailForm);
|
let thumbnailForm = null;
|
||||||
return { fileId, fileBuffer, thumbnailBuffer: thumbnail?.plaintext };
|
if (thumbnail) {
|
||||||
} catch (e) {
|
thumbnailForm = new FormData();
|
||||||
state.status = "error";
|
thumbnailForm.set(
|
||||||
throw e;
|
"metadata",
|
||||||
}
|
JSON.stringify({
|
||||||
|
dekVersion: dataKeyVersion.toISOString(),
|
||||||
|
contentIv: thumbnail.iv,
|
||||||
|
} satisfies FileThumbnailUploadRequest),
|
||||||
|
);
|
||||||
|
thumbnailForm.set("content", new Blob([thumbnail.ciphertext]));
|
||||||
|
}
|
||||||
|
|
||||||
|
const { fileId } = await requestFileUpload(state, form, thumbnailForm);
|
||||||
|
return { fileId, fileBuffer, thumbnailBuffer: thumbnail?.plaintext };
|
||||||
|
} catch (e) {
|
||||||
|
state.status = "error";
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,164 +1,121 @@
|
|||||||
import * as IndexedDB from "$lib/indexedDB";
|
import * as IndexedDB from "$lib/indexedDB";
|
||||||
import { trpc, isTRPCClientError } from "$trpc/client";
|
import { trpc, isTRPCClientError } from "$trpc/client";
|
||||||
import { FilesystemCache, decryptFileMetadata, decryptCategoryMetadata } from "./internal.svelte";
|
import { FilesystemCache, decryptFileMetadata, decryptCategoryMetadata } from "./internal.svelte";
|
||||||
import type { MaybeCategoryInfo } from "./types";
|
import type { CategoryInfo, MaybeCategoryInfo } from "./types";
|
||||||
|
|
||||||
const cache = new FilesystemCache<CategoryId, MaybeCategoryInfo, Partial<MaybeCategoryInfo>>();
|
const cache = new FilesystemCache<CategoryId, MaybeCategoryInfo>({
|
||||||
|
async fetchFromIndexedDB(id) {
|
||||||
const fetchFromIndexedDB = async (id: CategoryId) => {
|
const [category, subCategories] = await Promise.all([
|
||||||
const [category, subCategories] = await Promise.all([
|
id !== "root" ? IndexedDB.getCategoryInfo(id) : undefined,
|
||||||
id !== "root" ? IndexedDB.getCategoryInfo(id) : undefined,
|
IndexedDB.getCategoryInfos(id),
|
||||||
IndexedDB.getCategoryInfos(id),
|
]);
|
||||||
]);
|
const files = category?.files
|
||||||
const files = category
|
|
||||||
? await Promise.all(
|
|
||||||
category.files.map(async (file) => {
|
|
||||||
const fileInfo = await IndexedDB.getFileInfo(file.id);
|
|
||||||
return fileInfo
|
|
||||||
? {
|
|
||||||
id: file.id,
|
|
||||||
contentType: fileInfo.contentType,
|
|
||||||
name: fileInfo.name,
|
|
||||||
createdAt: fileInfo.createdAt,
|
|
||||||
lastModifiedAt: fileInfo.lastModifiedAt,
|
|
||||||
isRecursive: file.isRecursive,
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
if (id === "root") {
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
exists: true as const,
|
|
||||||
subCategories,
|
|
||||||
};
|
|
||||||
} else if (category) {
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
exists: true as const,
|
|
||||||
name: category.name,
|
|
||||||
subCategories,
|
|
||||||
files: files!.filter((file) => !!file),
|
|
||||||
isFileRecursive: category.isFileRecursive,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchFromServer = async (id: CategoryId, masterKey: CryptoKey) => {
|
|
||||||
try {
|
|
||||||
const {
|
|
||||||
metadata,
|
|
||||||
subCategories: subCategoriesRaw,
|
|
||||||
files: filesRaw,
|
|
||||||
} = await trpc().category.get.query({ id, recurse: true });
|
|
||||||
const subCategories = await Promise.all(
|
|
||||||
subCategoriesRaw.map(async (category) => {
|
|
||||||
const decrypted = await decryptCategoryMetadata(category, masterKey);
|
|
||||||
const existing = await IndexedDB.getCategoryInfo(category.id);
|
|
||||||
await IndexedDB.storeCategoryInfo({
|
|
||||||
id: category.id,
|
|
||||||
parentId: id,
|
|
||||||
name: decrypted.name,
|
|
||||||
files: existing?.files ?? [],
|
|
||||||
isFileRecursive: existing?.isFileRecursive ?? false,
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
id: category.id,
|
|
||||||
...decrypted,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
const existingFiles = filesRaw
|
|
||||||
? await IndexedDB.bulkGetFileInfos(filesRaw.map((file) => file.id))
|
|
||||||
: [];
|
|
||||||
const files = filesRaw
|
|
||||||
? await Promise.all(
|
? await Promise.all(
|
||||||
filesRaw.map(async (file, index) => {
|
category.files.map(async (file) => {
|
||||||
const decrypted = await decryptFileMetadata(file, masterKey);
|
const fileInfo = await IndexedDB.getFileInfo(file.id);
|
||||||
const existing = existingFiles[index];
|
return fileInfo
|
||||||
if (existing) {
|
? {
|
||||||
const categoryIds = file.isRecursive
|
id: file.id,
|
||||||
? existing.categoryIds
|
parentId: fileInfo.parentId,
|
||||||
: Array.from(new Set([...existing.categoryIds, id as number]));
|
contentType: fileInfo.contentType,
|
||||||
await IndexedDB.storeFileInfo({
|
name: fileInfo.name,
|
||||||
id: file.id,
|
createdAt: fileInfo.createdAt,
|
||||||
parentId: existing.parentId,
|
lastModifiedAt: fileInfo.lastModifiedAt,
|
||||||
contentType: file.contentType,
|
isRecursive: file.isRecursive,
|
||||||
name: decrypted.name,
|
}
|
||||||
createdAt: decrypted.createdAt,
|
: undefined;
|
||||||
lastModifiedAt: decrypted.lastModifiedAt,
|
|
||||||
categoryIds,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
id: file.id,
|
|
||||||
contentType: file.contentType,
|
|
||||||
isRecursive: file.isRecursive,
|
|
||||||
...decrypted,
|
|
||||||
};
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const decryptedMetadata = metadata
|
|
||||||
? await decryptCategoryMetadata(metadata, masterKey)
|
|
||||||
: undefined;
|
|
||||||
if (id !== "root" && metadata && decryptedMetadata) {
|
|
||||||
const existingCategory = await IndexedDB.getCategoryInfo(id);
|
|
||||||
await IndexedDB.storeCategoryInfo({
|
|
||||||
id: id as number,
|
|
||||||
parentId: metadata.parent,
|
|
||||||
name: decryptedMetadata.name,
|
|
||||||
files:
|
|
||||||
files?.map((file) => ({
|
|
||||||
id: file.id,
|
|
||||||
isRecursive: file.isRecursive,
|
|
||||||
})) ??
|
|
||||||
existingCategory?.files ??
|
|
||||||
[],
|
|
||||||
isFileRecursive: existingCategory?.isFileRecursive ?? false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id === "root") {
|
if (id === "root") {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
exists: true as const,
|
exists: true,
|
||||||
subCategories,
|
subCategories,
|
||||||
};
|
};
|
||||||
} else {
|
} else if (category) {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
exists: true as const,
|
exists: true,
|
||||||
|
parentId: category.parentId,
|
||||||
|
name: category.name,
|
||||||
subCategories,
|
subCategories,
|
||||||
files,
|
files: files?.filter((file) => !!file) ?? [],
|
||||||
...decryptedMetadata!,
|
isFileRecursive: category.isFileRecursive ?? false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (e) {
|
},
|
||||||
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
|
||||||
await IndexedDB.deleteCategoryInfo(id as number);
|
|
||||||
return { id, exists: false as const };
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getCategoryInfo = async (id: CategoryId, masterKey: CryptoKey) => {
|
async fetchFromServer(id, cachedInfo, masterKey) {
|
||||||
return await cache.get(id, async (isInitial, resolve) => {
|
try {
|
||||||
if (isInitial) {
|
const category = await trpc().category.get.query({ id, recurse: true });
|
||||||
const info = await fetchFromIndexedDB(id);
|
const [subCategories, files, metadata] = await Promise.all([
|
||||||
if (info) {
|
Promise.all(
|
||||||
resolve(info);
|
category.subCategories.map(async (category) => ({
|
||||||
|
id: category.id,
|
||||||
|
parentId: id,
|
||||||
|
...(await decryptCategoryMetadata(category, masterKey)),
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
category.files &&
|
||||||
|
Promise.all(
|
||||||
|
category.files.map(async (file) => ({
|
||||||
|
id: file.id,
|
||||||
|
parentId: file.parent,
|
||||||
|
contentType: file.contentType,
|
||||||
|
isRecursive: file.isRecursive,
|
||||||
|
...(await decryptFileMetadata(file, masterKey)),
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
category.metadata && decryptCategoryMetadata(category.metadata, masterKey),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return storeToIndexedDB(
|
||||||
|
id !== "root"
|
||||||
|
? {
|
||||||
|
id,
|
||||||
|
parentId: category.metadata!.parent,
|
||||||
|
subCategories,
|
||||||
|
files: files!,
|
||||||
|
isFileRecursive: cachedInfo?.isFileRecursive ?? false,
|
||||||
|
...metadata!,
|
||||||
|
}
|
||||||
|
: { id, subCategories },
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||||
|
await IndexedDB.deleteCategoryInfo(id as number);
|
||||||
|
return { id, exists: false };
|
||||||
}
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const info = await fetchFromServer(id, masterKey);
|
const storeToIndexedDB = (info: CategoryInfo) => {
|
||||||
if (info) {
|
if (info.id !== "root") {
|
||||||
resolve(info);
|
void IndexedDB.storeCategoryInfo(info);
|
||||||
}
|
|
||||||
|
// TODO: Bulk Upsert
|
||||||
|
new Map(info.files.map((file) => [file.id, file])).forEach((file) => {
|
||||||
|
void IndexedDB.storeFileInfo(file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Bulk Upsert
|
||||||
|
info.subCategories.forEach((category) => {
|
||||||
|
void IndexedDB.storeCategoryInfo(category);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
void IndexedDB.deleteDanglingCategoryInfos(
|
||||||
|
info.id,
|
||||||
|
new Set(info.subCategories.map(({ id }) => id)),
|
||||||
|
);
|
||||||
|
|
||||||
|
return { ...info, exists: true as const };
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getCategoryInfo = (id: CategoryId, masterKey: CryptoKey) => {
|
||||||
|
return cache.get(id, masterKey);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,121 +1,102 @@
|
|||||||
import * as IndexedDB from "$lib/indexedDB";
|
import * as IndexedDB from "$lib/indexedDB";
|
||||||
import { monotonicResolve } from "$lib/utils";
|
|
||||||
import { trpc, isTRPCClientError } from "$trpc/client";
|
import { trpc, isTRPCClientError } from "$trpc/client";
|
||||||
import { FilesystemCache, decryptDirectoryMetadata, decryptFileMetadata } from "./internal.svelte";
|
import { FilesystemCache, decryptDirectoryMetadata, decryptFileMetadata } from "./internal.svelte";
|
||||||
import type { MaybeDirectoryInfo } from "./types";
|
import type { DirectoryInfo, MaybeDirectoryInfo } from "./types";
|
||||||
|
|
||||||
const cache = new FilesystemCache<DirectoryId, MaybeDirectoryInfo>();
|
const cache = new FilesystemCache<DirectoryId, MaybeDirectoryInfo>({
|
||||||
|
async fetchFromIndexedDB(id) {
|
||||||
const fetchFromIndexedDB = async (id: DirectoryId) => {
|
const [directory, subDirectories, files] = await Promise.all([
|
||||||
const [directory, subDirectories, files] = await Promise.all([
|
id !== "root" ? IndexedDB.getDirectoryInfo(id) : undefined,
|
||||||
id !== "root" ? IndexedDB.getDirectoryInfo(id) : undefined,
|
IndexedDB.getDirectoryInfos(id),
|
||||||
IndexedDB.getDirectoryInfos(id),
|
IndexedDB.getFileInfos(id),
|
||||||
IndexedDB.getFileInfos(id),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (id === "root") {
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
exists: true as const,
|
|
||||||
subDirectories,
|
|
||||||
files,
|
|
||||||
};
|
|
||||||
} else if (directory) {
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
exists: true as const,
|
|
||||||
parentId: directory.parentId,
|
|
||||||
name: directory.name,
|
|
||||||
subDirectories,
|
|
||||||
files,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchFromServer = async (id: DirectoryId, masterKey: CryptoKey) => {
|
|
||||||
try {
|
|
||||||
const {
|
|
||||||
metadata,
|
|
||||||
subDirectories: subDirectoriesRaw,
|
|
||||||
files: filesRaw,
|
|
||||||
} = await trpc().directory.get.query({ id });
|
|
||||||
const existingFiles = await IndexedDB.bulkGetFileInfos(filesRaw.map((file) => file.id));
|
|
||||||
const [subDirectories, files, decryptedMetadata] = await Promise.all([
|
|
||||||
Promise.all(
|
|
||||||
subDirectoriesRaw.map(async (directory) => {
|
|
||||||
const decrypted = await decryptDirectoryMetadata(directory, masterKey);
|
|
||||||
await IndexedDB.storeDirectoryInfo({
|
|
||||||
id: directory.id,
|
|
||||||
parentId: id,
|
|
||||||
name: decrypted.name,
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
id: directory.id,
|
|
||||||
...decrypted,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
Promise.all(
|
|
||||||
filesRaw.map(async (file, index) => {
|
|
||||||
const decrypted = await decryptFileMetadata(file, masterKey);
|
|
||||||
await IndexedDB.storeFileInfo({
|
|
||||||
id: file.id,
|
|
||||||
parentId: id,
|
|
||||||
contentType: file.contentType,
|
|
||||||
name: decrypted.name,
|
|
||||||
createdAt: decrypted.createdAt,
|
|
||||||
lastModifiedAt: decrypted.lastModifiedAt,
|
|
||||||
categoryIds: existingFiles[index]?.categoryIds ?? [],
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
id: file.id,
|
|
||||||
contentType: file.contentType,
|
|
||||||
...decrypted,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
metadata ? decryptDirectoryMetadata(metadata, masterKey) : undefined,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (id !== "root" && metadata && decryptedMetadata) {
|
|
||||||
await IndexedDB.storeDirectoryInfo({
|
|
||||||
id,
|
|
||||||
parentId: metadata.parent,
|
|
||||||
name: decryptedMetadata.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id === "root") {
|
if (id === "root") {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
exists: true as const,
|
exists: true,
|
||||||
subDirectories,
|
subDirectories,
|
||||||
files,
|
files,
|
||||||
};
|
};
|
||||||
} else {
|
} else if (directory) {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
exists: true as const,
|
exists: true,
|
||||||
parentId: metadata!.parent,
|
parentId: directory.parentId,
|
||||||
|
name: directory.name,
|
||||||
subDirectories,
|
subDirectories,
|
||||||
files,
|
files,
|
||||||
...decryptedMetadata!,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (e) {
|
},
|
||||||
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
|
||||||
await IndexedDB.deleteDirectoryInfo(id as number);
|
async fetchFromServer(id, _cachedInfo, masterKey) {
|
||||||
return { id, exists: false as const };
|
try {
|
||||||
|
const directory = await trpc().directory.get.query({ id });
|
||||||
|
const [subDirectories, files, metadata] = await Promise.all([
|
||||||
|
Promise.all(
|
||||||
|
directory.subDirectories.map(async (directory) => ({
|
||||||
|
id: directory.id,
|
||||||
|
parentId: id,
|
||||||
|
...(await decryptDirectoryMetadata(directory, masterKey)),
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
Promise.all(
|
||||||
|
directory.files.map(async (file) => ({
|
||||||
|
id: file.id,
|
||||||
|
parentId: id,
|
||||||
|
contentType: file.contentType,
|
||||||
|
...(await decryptFileMetadata(file, masterKey)),
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
directory.metadata && decryptDirectoryMetadata(directory.metadata, masterKey),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return storeToIndexedDB(
|
||||||
|
id !== "root"
|
||||||
|
? {
|
||||||
|
id,
|
||||||
|
parentId: directory.metadata!.parent,
|
||||||
|
subDirectories,
|
||||||
|
files,
|
||||||
|
...metadata!,
|
||||||
|
}
|
||||||
|
: { id, subDirectories, files },
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||||
|
await IndexedDB.deleteDirectoryInfo(id as number);
|
||||||
|
return { id, exists: false as const };
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
throw e;
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const storeToIndexedDB = (info: DirectoryInfo) => {
|
||||||
|
if (info.id !== "root") {
|
||||||
|
void IndexedDB.storeDirectoryInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Bulk Upsert
|
||||||
|
info.subDirectories.forEach((subDirectory) => {
|
||||||
|
void IndexedDB.storeDirectoryInfo(subDirectory);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Bulk Upsert
|
||||||
|
info.files.forEach((file) => {
|
||||||
|
void IndexedDB.storeFileInfo(file);
|
||||||
|
});
|
||||||
|
|
||||||
|
void IndexedDB.deleteDanglingDirectoryInfos(
|
||||||
|
info.id,
|
||||||
|
new Set(info.subDirectories.map(({ id }) => id)),
|
||||||
|
);
|
||||||
|
void IndexedDB.deleteDanglingFileInfos(info.id, new Set(info.files.map(({ id }) => id)));
|
||||||
|
|
||||||
|
return { ...info, exists: true as const };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDirectoryInfo = async (id: DirectoryId, masterKey: CryptoKey) => {
|
export const getDirectoryInfo = (id: DirectoryId, masterKey: CryptoKey) => {
|
||||||
return await cache.get(id, (isInitial, resolve) =>
|
return cache.get(id, masterKey);
|
||||||
monotonicResolve(
|
|
||||||
[isInitial && fetchFromIndexedDB(id), fetchFromServer(id, masterKey)],
|
|
||||||
resolve,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,175 +1,177 @@
|
|||||||
import * as IndexedDB from "$lib/indexedDB";
|
import * as IndexedDB from "$lib/indexedDB";
|
||||||
import { monotonicResolve } from "$lib/utils";
|
|
||||||
import { trpc, isTRPCClientError } from "$trpc/client";
|
import { trpc, isTRPCClientError } from "$trpc/client";
|
||||||
import { FilesystemCache, decryptFileMetadata, decryptCategoryMetadata } from "./internal.svelte";
|
import { FilesystemCache, decryptFileMetadata, decryptCategoryMetadata } from "./internal.svelte";
|
||||||
import type { MaybeFileInfo } from "./types";
|
import type { FileInfo, MaybeFileInfo } from "./types";
|
||||||
|
|
||||||
const cache = new FilesystemCache<number, MaybeFileInfo>();
|
const cache = new FilesystemCache<number, MaybeFileInfo>({
|
||||||
|
async fetchFromIndexedDB(id) {
|
||||||
|
const file = await IndexedDB.getFileInfo(id);
|
||||||
|
const categories = file?.categoryIds
|
||||||
|
? await Promise.all(
|
||||||
|
file.categoryIds.map(async (categoryId) => {
|
||||||
|
const category = await IndexedDB.getCategoryInfo(categoryId);
|
||||||
|
return category
|
||||||
|
? { id: category.id, parentId: category.parentId, name: category.name }
|
||||||
|
: undefined;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const fetchFromIndexedDB = async (id: number) => {
|
if (file) {
|
||||||
const file = await IndexedDB.getFileInfo(id);
|
return {
|
||||||
const categories = file
|
id,
|
||||||
? await Promise.all(
|
exists: true,
|
||||||
file.categoryIds.map(async (categoryId) => {
|
parentId: file.parentId,
|
||||||
const category = await IndexedDB.getCategoryInfo(categoryId);
|
contentType: file.contentType,
|
||||||
return category ? { id: category.id, name: category.name } : undefined;
|
name: file.name,
|
||||||
}),
|
createdAt: file.createdAt,
|
||||||
)
|
lastModifiedAt: file.lastModifiedAt,
|
||||||
: undefined;
|
categories: categories?.filter((category) => !!category) ?? [],
|
||||||
|
};
|
||||||
if (file) {
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
exists: true as const,
|
|
||||||
parentId: file.parentId,
|
|
||||||
contentType: file.contentType,
|
|
||||||
name: file.name,
|
|
||||||
createdAt: file.createdAt,
|
|
||||||
lastModifiedAt: file.lastModifiedAt,
|
|
||||||
categories: categories!.filter((category) => !!category),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const bulkFetchFromIndexedDB = async (ids: number[]) => {
|
|
||||||
const files = await IndexedDB.bulkGetFileInfos(ids);
|
|
||||||
const categories = await Promise.all(
|
|
||||||
files.map(async (file) =>
|
|
||||||
file
|
|
||||||
? await Promise.all(
|
|
||||||
file.categoryIds.map(async (categoryId) => {
|
|
||||||
const category = await IndexedDB.getCategoryInfo(categoryId);
|
|
||||||
return category ? { id: category.id, name: category.name } : undefined;
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
: undefined,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return new Map(
|
|
||||||
files
|
|
||||||
.map((file, index) =>
|
|
||||||
file
|
|
||||||
? ([
|
|
||||||
file.id,
|
|
||||||
{
|
|
||||||
...file,
|
|
||||||
exists: true,
|
|
||||||
categories: categories[index]!.filter((category) => !!category),
|
|
||||||
},
|
|
||||||
] as const)
|
|
||||||
: undefined,
|
|
||||||
)
|
|
||||||
.filter((file) => !!file),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchFromServer = async (id: number, masterKey: CryptoKey) => {
|
|
||||||
try {
|
|
||||||
const { categories: categoriesRaw, ...metadata } = await trpc().file.get.query({ id });
|
|
||||||
const [categories, decryptedMetadata] = await Promise.all([
|
|
||||||
Promise.all(
|
|
||||||
categoriesRaw.map(async (category) => ({
|
|
||||||
id: category.id,
|
|
||||||
...(await decryptCategoryMetadata(category, masterKey)),
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
decryptFileMetadata(metadata, masterKey),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await IndexedDB.storeFileInfo({
|
|
||||||
id,
|
|
||||||
parentId: metadata.parent,
|
|
||||||
contentType: metadata.contentType,
|
|
||||||
name: decryptedMetadata.name,
|
|
||||||
createdAt: decryptedMetadata.createdAt,
|
|
||||||
lastModifiedAt: decryptedMetadata.lastModifiedAt,
|
|
||||||
categoryIds: categories.map((category) => category.id),
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
exists: true as const,
|
|
||||||
parentId: metadata.parent,
|
|
||||||
contentType: metadata.contentType,
|
|
||||||
contentIv: metadata.contentIv,
|
|
||||||
categories,
|
|
||||||
...decryptedMetadata,
|
|
||||||
};
|
|
||||||
} catch (e) {
|
|
||||||
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
|
||||||
await IndexedDB.deleteFileInfo(id);
|
|
||||||
return { id, exists: false as const };
|
|
||||||
}
|
}
|
||||||
throw e;
|
},
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const bulkFetchFromServer = async (ids: number[], masterKey: CryptoKey) => {
|
async fetchFromServer(id, _cachedInfo, masterKey) {
|
||||||
const filesRaw = await trpc().file.bulkGet.query({ ids });
|
try {
|
||||||
const files = await Promise.all(
|
const file = await trpc().file.get.query({ id });
|
||||||
filesRaw.map(async (file) => {
|
const [categories, metadata] = await Promise.all([
|
||||||
const [categories, decryptedMetadata] = await Promise.all([
|
|
||||||
Promise.all(
|
Promise.all(
|
||||||
file.categories.map(async (category) => ({
|
file.categories.map(async (category) => ({
|
||||||
id: category.id,
|
id: category.id,
|
||||||
|
parentId: category.parent,
|
||||||
...(await decryptCategoryMetadata(category, masterKey)),
|
...(await decryptCategoryMetadata(category, masterKey)),
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
decryptFileMetadata(file, masterKey),
|
decryptFileMetadata(file, masterKey),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await IndexedDB.storeFileInfo({
|
return storeToIndexedDB({
|
||||||
id: file.id,
|
id,
|
||||||
parentId: file.parent,
|
|
||||||
contentType: file.contentType,
|
|
||||||
name: decryptedMetadata.name,
|
|
||||||
createdAt: decryptedMetadata.createdAt,
|
|
||||||
lastModifiedAt: decryptedMetadata.lastModifiedAt,
|
|
||||||
categoryIds: categories.map((category) => category.id),
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
id: file.id,
|
|
||||||
exists: true as const,
|
|
||||||
parentId: file.parent,
|
parentId: file.parent,
|
||||||
|
dataKey: metadata.dataKey,
|
||||||
contentType: file.contentType,
|
contentType: file.contentType,
|
||||||
contentIv: file.contentIv,
|
contentIv: file.contentIv,
|
||||||
|
name: metadata.name,
|
||||||
|
createdAt: metadata.createdAt,
|
||||||
|
lastModifiedAt: metadata.lastModifiedAt,
|
||||||
categories,
|
categories,
|
||||||
...decryptedMetadata,
|
});
|
||||||
};
|
} catch (e) {
|
||||||
}),
|
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||||
);
|
await IndexedDB.deleteFileInfo(id);
|
||||||
|
return { id, exists: false as const };
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
const existingIds = new Set(filesRaw.map(({ id }) => id));
|
async bulkFetchFromIndexedDB(ids) {
|
||||||
return new Map<number, MaybeFileInfo>([
|
const files = await IndexedDB.bulkGetFileInfos([...ids]);
|
||||||
...files.map((file) => [file.id, file] as const),
|
const categories = await Promise.all(
|
||||||
...ids.filter((id) => !existingIds.has(id)).map((id) => [id, { id, exists: false }] as const),
|
files.map(async (file) =>
|
||||||
]);
|
file?.categoryIds
|
||||||
};
|
? await Promise.all(
|
||||||
|
file.categoryIds.map(async (categoryId) => {
|
||||||
|
const category = await IndexedDB.getCategoryInfo(categoryId);
|
||||||
|
return category
|
||||||
|
? { id: category.id, parentId: category.parentId, name: category.name }
|
||||||
|
: undefined;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
: undefined,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
export const getFileInfo = async (id: number, masterKey: CryptoKey) => {
|
return new Map(
|
||||||
return await cache.get(id, (isInitial, resolve) =>
|
files
|
||||||
monotonicResolve(
|
.filter((file) => !!file)
|
||||||
[isInitial && fetchFromIndexedDB(id), fetchFromServer(id, masterKey)],
|
.map((file, index) => [
|
||||||
resolve,
|
file.id,
|
||||||
),
|
{
|
||||||
);
|
...file,
|
||||||
};
|
exists: true,
|
||||||
|
categories: categories[index]?.filter((category) => !!category) ?? [],
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
export const bulkGetFileInfo = async (ids: number[], masterKey: CryptoKey) => {
|
async bulkFetchFromServer(ids, masterKey) {
|
||||||
return await cache.bulkGet(new Set(ids), (keys, resolve) =>
|
const idsArray = [...ids.keys()];
|
||||||
monotonicResolve(
|
|
||||||
[
|
const filesRaw = await trpc().file.bulkGet.query({ ids: idsArray });
|
||||||
bulkFetchFromIndexedDB(
|
const files = await Promise.all(
|
||||||
Array.from(
|
filesRaw.map(async ({ id, categories: categoriesRaw, ...metadataRaw }) => {
|
||||||
keys
|
const [categories, metadata] = await Promise.all([
|
||||||
.entries()
|
Promise.all(
|
||||||
.filter(([, isInitial]) => isInitial)
|
categoriesRaw.map(async (category) => ({
|
||||||
.map(([key]) => key),
|
id: category.id,
|
||||||
|
parentId: category.parent,
|
||||||
|
...(await decryptCategoryMetadata(category, masterKey)),
|
||||||
|
})),
|
||||||
),
|
),
|
||||||
),
|
decryptFileMetadata(metadataRaw, masterKey),
|
||||||
bulkFetchFromServer(Array.from(keys.keys()), masterKey),
|
]);
|
||||||
],
|
|
||||||
resolve,
|
return {
|
||||||
),
|
id,
|
||||||
);
|
exists: true as const,
|
||||||
|
parentId: metadataRaw.parent,
|
||||||
|
contentType: metadataRaw.contentType,
|
||||||
|
contentIv: metadataRaw.contentIv,
|
||||||
|
categories,
|
||||||
|
...metadata,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const existingIds = new Set(filesRaw.map(({ id }) => id));
|
||||||
|
const deletedIds = idsArray.filter((id) => !existingIds.has(id));
|
||||||
|
|
||||||
|
void IndexedDB.bulkDeleteFileInfos(deletedIds);
|
||||||
|
return new Map<number, MaybeFileInfo>([
|
||||||
|
...bulkStoreToIndexedDB(files),
|
||||||
|
...deletedIds.map((id) => [id, { id, exists: false }] as const),
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const storeToIndexedDB = (info: FileInfo) => {
|
||||||
|
void IndexedDB.storeFileInfo({
|
||||||
|
...info,
|
||||||
|
categoryIds: info.categories.map(({ id }) => id),
|
||||||
|
});
|
||||||
|
|
||||||
|
info.categories.forEach((category) => {
|
||||||
|
void IndexedDB.storeCategoryInfo(category);
|
||||||
|
});
|
||||||
|
|
||||||
|
return { ...info, exists: true as const };
|
||||||
|
};
|
||||||
|
|
||||||
|
const bulkStoreToIndexedDB = (infos: FileInfo[]) => {
|
||||||
|
// TODO: Bulk Upsert
|
||||||
|
infos.forEach((info) => {
|
||||||
|
void IndexedDB.storeFileInfo({
|
||||||
|
...info,
|
||||||
|
categoryIds: info.categories.map(({ id }) => id),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Bulk Upsert
|
||||||
|
new Map(
|
||||||
|
infos.flatMap(({ categories }) => categories).map((category) => [category.id, category]),
|
||||||
|
).forEach((category) => {
|
||||||
|
void IndexedDB.storeCategoryInfo(category);
|
||||||
|
});
|
||||||
|
|
||||||
|
return infos.map((info) => [info.id, { ...info, exists: true }] as const);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getFileInfo = (id: number, masterKey: CryptoKey) => {
|
||||||
|
return cache.get(id, masterKey);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const bulkGetFileInfo = (ids: number[], masterKey: CryptoKey) => {
|
||||||
|
return cache.bulkGet(new Set(ids), masterKey);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,82 +1,124 @@
|
|||||||
|
import { untrack } from "svelte";
|
||||||
import { unwrapDataKey, decryptString } from "$lib/modules/crypto";
|
import { unwrapDataKey, decryptString } from "$lib/modules/crypto";
|
||||||
|
|
||||||
export class FilesystemCache<K, V extends RV, RV = V> {
|
interface FilesystemCacheOptions<K, V> {
|
||||||
private map = new Map<K, V | Promise<V>>();
|
fetchFromIndexedDB: (key: K) => Promise<V | undefined>;
|
||||||
|
fetchFromServer: (key: K, cachedValue: V | undefined, masterKey: CryptoKey) => Promise<V>;
|
||||||
|
bulkFetchFromIndexedDB?: (keys: Set<K>) => Promise<Map<K, V>>;
|
||||||
|
bulkFetchFromServer?: (
|
||||||
|
keys: Map<K, { cachedValue: V | undefined }>,
|
||||||
|
masterKey: CryptoKey,
|
||||||
|
) => Promise<Map<K, V>>;
|
||||||
|
}
|
||||||
|
|
||||||
get(key: K, loader: (isInitial: boolean, resolve: (value: RV | undefined) => void) => void) {
|
export class FilesystemCache<K, V extends object> {
|
||||||
const info = this.map.get(key);
|
private map = new Map<K, { value?: V; promise?: Promise<V> }>();
|
||||||
if (info instanceof Promise) {
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { promise, resolve } = Promise.withResolvers<V>();
|
constructor(private readonly options: FilesystemCacheOptions<K, V>) {}
|
||||||
if (!info) {
|
|
||||||
this.map.set(key, promise);
|
|
||||||
}
|
|
||||||
|
|
||||||
loader(!info, (loadedInfo) => {
|
get(key: K, masterKey: CryptoKey) {
|
||||||
if (!loadedInfo) return;
|
return untrack(() => {
|
||||||
|
let state = this.map.get(key);
|
||||||
|
if (state?.promise) return state.value ?? state.promise;
|
||||||
|
|
||||||
const info = this.map.get(key)!;
|
const { promise: newPromise, resolve } = Promise.withResolvers<V>();
|
||||||
if (info instanceof Promise) {
|
|
||||||
const state = $state(loadedInfo);
|
if (!state) {
|
||||||
this.map.set(key, state as V);
|
const newState = $state({});
|
||||||
resolve(state as V);
|
state = newState;
|
||||||
} else {
|
this.map.set(key, newState);
|
||||||
Object.assign(info, loadedInfo);
|
|
||||||
resolve(info);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return info ?? promise;
|
(state.value
|
||||||
|
? Promise.resolve(state.value)
|
||||||
|
: this.options.fetchFromIndexedDB(key).then((loadedInfo) => {
|
||||||
|
if (loadedInfo) {
|
||||||
|
state.value = loadedInfo;
|
||||||
|
resolve(state.value);
|
||||||
|
}
|
||||||
|
return loadedInfo;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then((cachedInfo) => this.options.fetchFromServer(key, cachedInfo, masterKey))
|
||||||
|
.then((loadedInfo) => {
|
||||||
|
if (state.value) {
|
||||||
|
Object.assign(state.value, loadedInfo);
|
||||||
|
} else {
|
||||||
|
state.value = loadedInfo;
|
||||||
|
}
|
||||||
|
resolve(state.value);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
state.promise = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
state.promise = newPromise;
|
||||||
|
return state.value ?? newPromise;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async bulkGet(
|
bulkGet(keys: Set<K>, masterKey: CryptoKey) {
|
||||||
keys: Set<K>,
|
return untrack(() => {
|
||||||
loader: (keys: Map<K, boolean>, resolve: (values: Map<K, RV>) => void) => void,
|
const newPromises = new Map(
|
||||||
) {
|
keys
|
||||||
const states = new Map<K, V>();
|
.keys()
|
||||||
const promises = new Map<K, Promise<V>>();
|
.filter((key) => this.map.get(key)?.promise === undefined)
|
||||||
const resolvers = new Map<K, (value: V) => void>();
|
.map((key) => [key, Promise.withResolvers<V>()]),
|
||||||
|
);
|
||||||
|
newPromises.forEach(({ promise }, key) => {
|
||||||
|
const state = this.map.get(key);
|
||||||
|
if (state) {
|
||||||
|
state.promise = promise;
|
||||||
|
} else {
|
||||||
|
const newState = $state({ promise });
|
||||||
|
this.map.set(key, newState);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
keys.forEach((key) => {
|
const resolve = (loadedInfos: Map<K, V>) => {
|
||||||
const info = this.map.get(key);
|
|
||||||
if (info instanceof Promise) {
|
|
||||||
promises.set(key, info);
|
|
||||||
} else if (info) {
|
|
||||||
states.set(key, info);
|
|
||||||
} else {
|
|
||||||
const { promise, resolve } = Promise.withResolvers<V>();
|
|
||||||
this.map.set(key, promise);
|
|
||||||
promises.set(key, promise);
|
|
||||||
resolvers.set(key, resolve);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
loader(
|
|
||||||
new Map([
|
|
||||||
...states.keys().map((key) => [key, false] as const),
|
|
||||||
...resolvers.keys().map((key) => [key, true] as const),
|
|
||||||
]),
|
|
||||||
(loadedInfos) =>
|
|
||||||
loadedInfos.forEach((loadedInfo, key) => {
|
loadedInfos.forEach((loadedInfo, key) => {
|
||||||
const info = this.map.get(key)!;
|
const state = this.map.get(key)!;
|
||||||
const resolve = resolvers.get(key);
|
if (state.value) {
|
||||||
if (info instanceof Promise) {
|
Object.assign(state.value, loadedInfo);
|
||||||
const state = $state(loadedInfo);
|
|
||||||
this.map.set(key, state as V);
|
|
||||||
resolve?.(state as V);
|
|
||||||
} else {
|
} else {
|
||||||
Object.assign(info, loadedInfo);
|
state.value = loadedInfo;
|
||||||
resolve?.(info);
|
|
||||||
}
|
}
|
||||||
}),
|
newPromises.get(key)!.resolve(state.value);
|
||||||
);
|
});
|
||||||
|
return loadedInfos;
|
||||||
|
};
|
||||||
|
|
||||||
const newStates = await Promise.all(
|
this.options.bulkFetchFromIndexedDB!(
|
||||||
promises.entries().map(async ([key, promise]) => [key, await promise] as const),
|
new Set(newPromises.keys().filter((key) => this.map.get(key)!.value === undefined)),
|
||||||
);
|
)
|
||||||
return new Map([...states, ...newStates]);
|
.then(resolve)
|
||||||
|
.then(() =>
|
||||||
|
this.options.bulkFetchFromServer!(
|
||||||
|
new Map(
|
||||||
|
newPromises.keys().map((key) => [key, { cachedValue: this.map.get(key)!.value }]),
|
||||||
|
),
|
||||||
|
masterKey,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.then(resolve)
|
||||||
|
.finally(() => {
|
||||||
|
newPromises.forEach((_, key) => {
|
||||||
|
this.map.get(key)!.promise = undefined;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const bottleneckPromises = Array.from(
|
||||||
|
keys
|
||||||
|
.keys()
|
||||||
|
.filter((key) => this.map.get(key)!.value === undefined)
|
||||||
|
.map((key) => this.map.get(key)!.promise!),
|
||||||
|
);
|
||||||
|
const makeResult = () =>
|
||||||
|
new Map(keys.keys().map((key) => [key, this.map.get(key)!.value!] as const));
|
||||||
|
return bottleneckPromises.length > 0
|
||||||
|
? Promise.all(bottleneckPromises).then(makeResult)
|
||||||
|
: makeResult();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ interface RootDirectoryInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type DirectoryInfo = LocalDirectoryInfo | RootDirectoryInfo;
|
export type DirectoryInfo = LocalDirectoryInfo | RootDirectoryInfo;
|
||||||
export type SubDirectoryInfo = Omit<LocalDirectoryInfo, "parentId" | "subDirectories" | "files">;
|
|
||||||
export type MaybeDirectoryInfo =
|
export type MaybeDirectoryInfo =
|
||||||
| (DirectoryInfo & { exists: true })
|
| (DirectoryInfo & { exists: true })
|
||||||
| ({ id: DirectoryId; exists: false } & AllUndefined<Omit<DirectoryInfo, "id">>);
|
| ({ id: DirectoryId; exists: false } & AllUndefined<Omit<DirectoryInfo, "id">>);
|
||||||
|
|
||||||
|
export type SubDirectoryInfo = Omit<LocalDirectoryInfo, "subDirectories" | "files">;
|
||||||
|
|
||||||
export interface FileInfo {
|
export interface FileInfo {
|
||||||
id: number;
|
id: number;
|
||||||
parentId: DirectoryId;
|
parentId: DirectoryId;
|
||||||
@@ -34,17 +35,19 @@ export interface FileInfo {
|
|||||||
name: string;
|
name: string;
|
||||||
createdAt?: Date;
|
createdAt?: Date;
|
||||||
lastModifiedAt: Date;
|
lastModifiedAt: Date;
|
||||||
categories: { id: number; name: string }[];
|
categories: FileCategoryInfo[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SummarizedFileInfo = Omit<FileInfo, "parentId" | "contentIv" | "categories">;
|
|
||||||
export type CategoryFileInfo = SummarizedFileInfo & { isRecursive: boolean };
|
|
||||||
export type MaybeFileInfo =
|
export type MaybeFileInfo =
|
||||||
| (FileInfo & { exists: true })
|
| (FileInfo & { exists: true })
|
||||||
| ({ id: number; exists: false } & AllUndefined<Omit<FileInfo, "id">>);
|
| ({ id: number; exists: false } & AllUndefined<Omit<FileInfo, "id">>);
|
||||||
|
|
||||||
|
export type SummarizedFileInfo = Omit<FileInfo, "contentIv" | "categories">;
|
||||||
|
export type CategoryFileInfo = SummarizedFileInfo & { isRecursive: boolean };
|
||||||
|
|
||||||
interface LocalCategoryInfo {
|
interface LocalCategoryInfo {
|
||||||
id: number;
|
id: number;
|
||||||
|
parentId: DirectoryId;
|
||||||
dataKey?: DataKey;
|
dataKey?: DataKey;
|
||||||
name: string;
|
name: string;
|
||||||
subCategories: SubCategoryInfo[];
|
subCategories: SubCategoryInfo[];
|
||||||
@@ -54,6 +57,7 @@ interface LocalCategoryInfo {
|
|||||||
|
|
||||||
interface RootCategoryInfo {
|
interface RootCategoryInfo {
|
||||||
id: "root";
|
id: "root";
|
||||||
|
parentId?: undefined;
|
||||||
dataKey?: undefined;
|
dataKey?: undefined;
|
||||||
name?: undefined;
|
name?: undefined;
|
||||||
subCategories: SubCategoryInfo[];
|
subCategories: SubCategoryInfo[];
|
||||||
@@ -62,10 +66,12 @@ interface RootCategoryInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type CategoryInfo = LocalCategoryInfo | RootCategoryInfo;
|
export type CategoryInfo = LocalCategoryInfo | RootCategoryInfo;
|
||||||
|
export type MaybeCategoryInfo =
|
||||||
|
| (CategoryInfo & { exists: true })
|
||||||
|
| ({ id: CategoryId; exists: false } & AllUndefined<Omit<CategoryInfo, "id">>);
|
||||||
|
|
||||||
export type SubCategoryInfo = Omit<
|
export type SubCategoryInfo = Omit<
|
||||||
LocalCategoryInfo,
|
LocalCategoryInfo,
|
||||||
"subCategories" | "files" | "isFileRecursive"
|
"subCategories" | "files" | "isFileRecursive"
|
||||||
>;
|
>;
|
||||||
export type MaybeCategoryInfo =
|
export type FileCategoryInfo = Omit<SubCategoryInfo, "dataKey">;
|
||||||
| (CategoryInfo & { exists: true })
|
|
||||||
| ({ id: CategoryId; exists: false } & AllUndefined<Omit<CategoryInfo, "id">>);
|
|
||||||
|
|||||||
48
src/lib/modules/scheduler.ts
Normal file
48
src/lib/modules/scheduler.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
export class Scheduler<T = void> {
|
||||||
|
private isEstimating = false;
|
||||||
|
private memoryUsage = 0;
|
||||||
|
private queue: (() => void)[] = [];
|
||||||
|
|
||||||
|
constructor(public readonly memoryLimit = 100 * 1024 * 1024 /* 100 MiB */) {}
|
||||||
|
|
||||||
|
private next() {
|
||||||
|
if (!this.isEstimating && this.memoryUsage < this.memoryLimit) {
|
||||||
|
const resolve = this.queue.shift();
|
||||||
|
if (resolve) {
|
||||||
|
this.isEstimating = true;
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async schedule(
|
||||||
|
estimateMemoryUsage: number | (() => number | Promise<number>),
|
||||||
|
task: () => Promise<T>,
|
||||||
|
) {
|
||||||
|
if (this.isEstimating || this.memoryUsage >= this.memoryLimit) {
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
this.queue.push(resolve);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.isEstimating = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let taskMemoryUsage = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
taskMemoryUsage =
|
||||||
|
typeof estimateMemoryUsage === "number" ? estimateMemoryUsage : await estimateMemoryUsage();
|
||||||
|
this.memoryUsage += taskMemoryUsage;
|
||||||
|
} finally {
|
||||||
|
this.isEstimating = false;
|
||||||
|
this.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return await task();
|
||||||
|
} finally {
|
||||||
|
this.memoryUsage -= taskMemoryUsage;
|
||||||
|
this.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,6 +39,7 @@ export type NewFile = Omit<File, "id">;
|
|||||||
|
|
||||||
interface FileCategory {
|
interface FileCategory {
|
||||||
id: number;
|
id: number;
|
||||||
|
parentId: CategoryId;
|
||||||
mekVersion: number;
|
mekVersion: number;
|
||||||
encDek: string;
|
encDek: string;
|
||||||
dekVersion: Date;
|
dekVersion: Date;
|
||||||
@@ -445,6 +446,7 @@ export const getFilesWithCategories = async (userId: number, fileIds: number[])
|
|||||||
encLastModifiedAt: file.encrypted_last_modified_at,
|
encLastModifiedAt: file.encrypted_last_modified_at,
|
||||||
categories: file.categories.map((category) => ({
|
categories: file.categories.map((category) => ({
|
||||||
id: category.id,
|
id: category.id,
|
||||||
|
parentId: category.parent_id ?? "root",
|
||||||
mekVersion: category.master_encryption_key_version,
|
mekVersion: category.master_encryption_key_version,
|
||||||
encDek: category.encrypted_data_encryption_key,
|
encDek: category.encrypted_data_encryption_key,
|
||||||
dekVersion: new Date(category.data_encryption_key_version),
|
dekVersion: new Date(category.data_encryption_key_version),
|
||||||
@@ -548,6 +550,7 @@ export const getAllFileCategories = async (fileId: number) => {
|
|||||||
(category) =>
|
(category) =>
|
||||||
({
|
({
|
||||||
id: category.id,
|
id: category.id,
|
||||||
|
parentId: category.parent_id ?? "root",
|
||||||
mekVersion: category.master_encryption_key_version,
|
mekVersion: category.master_encryption_key_version,
|
||||||
encDek: category.encrypted_data_encryption_key,
|
encDek: category.encrypted_data_encryption_key,
|
||||||
dekVersion: category.data_encryption_key_version,
|
dekVersion: category.data_encryption_key_version,
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
import { getAllFileInfos } from "$lib/indexedDB/filesystem";
|
import { getAllFileInfos } from "$lib/indexedDB/filesystem";
|
||||||
import { decryptData } from "$lib/modules/crypto";
|
|
||||||
import {
|
import {
|
||||||
getFileCache,
|
getFileCache,
|
||||||
storeFileCache,
|
storeFileCache,
|
||||||
deleteFileCache,
|
deleteFileCache,
|
||||||
getFileThumbnailCache,
|
|
||||||
storeFileThumbnailCache,
|
|
||||||
deleteFileThumbnailCache,
|
|
||||||
downloadFile,
|
downloadFile,
|
||||||
|
deleteFileThumbnailCache,
|
||||||
} from "$lib/modules/file";
|
} from "$lib/modules/file";
|
||||||
import { getThumbnailUrl } from "$lib/modules/thumbnail";
|
|
||||||
import type { FileThumbnailUploadRequest } from "$lib/server/schemas";
|
import type { FileThumbnailUploadRequest } from "$lib/server/schemas";
|
||||||
import { trpc } from "$trpc/client";
|
import { trpc } from "$trpc/client";
|
||||||
|
|
||||||
@@ -44,29 +40,6 @@ export const requestFileThumbnailUpload = async (
|
|||||||
return await fetch(`/api/file/${fileId}/thumbnail/upload`, { method: "POST", body: form });
|
return await fetch(`/api/file/${fileId}/thumbnail/upload`, { method: "POST", body: form });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const requestFileThumbnailDownload = async (fileId: number, dataKey?: CryptoKey) => {
|
|
||||||
const cache = await getFileThumbnailCache(fileId);
|
|
||||||
if (cache || !dataKey) return cache;
|
|
||||||
|
|
||||||
let thumbnailInfo;
|
|
||||||
try {
|
|
||||||
thumbnailInfo = await trpc().file.thumbnail.query({ id: fileId });
|
|
||||||
} catch {
|
|
||||||
// TODO: Error Handling
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const { contentIv: thumbnailEncryptedIv } = thumbnailInfo;
|
|
||||||
|
|
||||||
const res = await fetch(`/api/file/${fileId}/thumbnail/download`);
|
|
||||||
if (!res.ok) return null;
|
|
||||||
|
|
||||||
const thumbnailEncrypted = await res.arrayBuffer();
|
|
||||||
const thumbnailBuffer = await decryptData(thumbnailEncrypted, thumbnailEncryptedIv, dataKey);
|
|
||||||
|
|
||||||
storeFileThumbnailCache(fileId, thumbnailBuffer); // Intended
|
|
||||||
return getThumbnailUrl(thumbnailBuffer);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const requestDeletedFilesCleanup = async () => {
|
export const requestDeletedFilesCleanup = async () => {
|
||||||
let liveFiles;
|
let liveFiles;
|
||||||
try {
|
try {
|
||||||
|
|||||||
93
src/lib/utils/HybridPromise.ts
Normal file
93
src/lib/utils/HybridPromise.ts
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
type MaybePromise<T> = T | Promise<T> | HybridPromise<T>;
|
||||||
|
|
||||||
|
type HybridPromiseState<T> =
|
||||||
|
| { mode: "sync"; status: "fulfilled"; value: T }
|
||||||
|
| { mode: "sync"; status: "rejected"; reason: unknown }
|
||||||
|
| { mode: "async"; promise: Promise<T> };
|
||||||
|
|
||||||
|
export class HybridPromise<T> implements PromiseLike<T> {
|
||||||
|
private isConsumed = false;
|
||||||
|
|
||||||
|
private constructor(private readonly state: HybridPromiseState<T>) {
|
||||||
|
if (state.mode === "sync" && state.status === "rejected") {
|
||||||
|
queueMicrotask(() => {
|
||||||
|
if (!this.isConsumed) {
|
||||||
|
throw state.reason;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isSync(): boolean {
|
||||||
|
return this.state.mode === "sync";
|
||||||
|
}
|
||||||
|
|
||||||
|
toPromise(): Promise<T> {
|
||||||
|
this.isConsumed = true;
|
||||||
|
|
||||||
|
if (this.state.mode === "async") return this.state.promise;
|
||||||
|
return this.state.status === "fulfilled"
|
||||||
|
? Promise.resolve(this.state.value)
|
||||||
|
: Promise.reject(this.state.reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
static resolve<T>(value: MaybePromise<T>): HybridPromise<T> {
|
||||||
|
if (value instanceof HybridPromise) return value;
|
||||||
|
return new HybridPromise(
|
||||||
|
value instanceof Promise
|
||||||
|
? { mode: "async", promise: value }
|
||||||
|
: { mode: "sync", status: "fulfilled", value },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static reject<T = never>(reason?: unknown): HybridPromise<T> {
|
||||||
|
return new HybridPromise({ mode: "sync", status: "rejected", reason });
|
||||||
|
}
|
||||||
|
|
||||||
|
then<TResult1 = T, TResult2 = never>(
|
||||||
|
onfulfilled?: ((value: T) => MaybePromise<TResult1>) | null | undefined,
|
||||||
|
onrejected?: ((reason: unknown) => MaybePromise<TResult2>) | null | undefined,
|
||||||
|
): HybridPromise<TResult1 | TResult2> {
|
||||||
|
this.isConsumed = true;
|
||||||
|
|
||||||
|
if (this.state.mode === "async") {
|
||||||
|
return new HybridPromise({
|
||||||
|
mode: "async",
|
||||||
|
promise: this.state.promise.then(onfulfilled, onrejected) as any,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (this.state.status === "fulfilled") {
|
||||||
|
if (!onfulfilled) return HybridPromise.resolve(this.state.value as any);
|
||||||
|
return HybridPromise.resolve(onfulfilled(this.state.value));
|
||||||
|
} else {
|
||||||
|
if (!onrejected) return HybridPromise.reject(this.state.reason);
|
||||||
|
return HybridPromise.resolve(onrejected(this.state.reason));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return HybridPromise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch<TResult = never>(
|
||||||
|
onrejected?: ((reason: unknown) => MaybePromise<TResult>) | null | undefined,
|
||||||
|
): HybridPromise<T | TResult> {
|
||||||
|
return this.then<T, TResult>(null, onrejected);
|
||||||
|
}
|
||||||
|
|
||||||
|
finally(onfinally?: (() => void) | null | undefined): HybridPromise<T> {
|
||||||
|
this.isConsumed = true;
|
||||||
|
|
||||||
|
if (this.state.mode === "async") {
|
||||||
|
return new HybridPromise({ mode: "async", promise: this.state.promise.finally(onfinally) });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
onfinally?.();
|
||||||
|
return new HybridPromise(this.state);
|
||||||
|
} catch (e) {
|
||||||
|
return HybridPromise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
export * from "./format";
|
export * from "./format";
|
||||||
export * from "./gotoStateful";
|
export * from "./gotoStateful";
|
||||||
export * from "./promise";
|
export * from "./HybridPromise";
|
||||||
export * from "./sort";
|
export * from "./sort";
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
export const monotonicResolve = <T>(
|
|
||||||
promises: (Promise<T> | false)[],
|
|
||||||
callback: (value: T) => void,
|
|
||||||
) => {
|
|
||||||
let latestResolvedIndex = -1;
|
|
||||||
promises
|
|
||||||
.filter((promise) => !!promise)
|
|
||||||
.forEach((promise, index) => {
|
|
||||||
promise.then((value) => {
|
|
||||||
if (index > latestResolvedIndex) {
|
|
||||||
latestResolvedIndex = index;
|
|
||||||
callback(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -48,9 +48,10 @@ export const sortEntries = <T extends SortEntry>(entries: T[], sortBy = SortBy.N
|
|||||||
case SortBy.DATE_DESC:
|
case SortBy.DATE_DESC:
|
||||||
sortFunc = sortByDateDesc;
|
sortFunc = sortByDateDesc;
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
const exhaustive: never = sortBy;
|
const exhaustive: never = sortBy;
|
||||||
sortFunc = exhaustive;
|
sortFunc = exhaustive;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.sort(sortFunc);
|
entries.sort(sortFunc);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
import { captureVideoThumbnail } from "$lib/modules/thumbnail";
|
import { captureVideoThumbnail } from "$lib/modules/thumbnail";
|
||||||
import { getFileDownloadState } from "$lib/modules/file";
|
import { getFileDownloadState } from "$lib/modules/file";
|
||||||
import { masterKeyStore } from "$lib/stores";
|
import { masterKeyStore } from "$lib/stores";
|
||||||
|
import { HybridPromise } from "$lib/utils";
|
||||||
import AddToCategoryBottomSheet from "./AddToCategoryBottomSheet.svelte";
|
import AddToCategoryBottomSheet from "./AddToCategoryBottomSheet.svelte";
|
||||||
import DownloadStatus from "./DownloadStatus.svelte";
|
import DownloadStatus from "./DownloadStatus.svelte";
|
||||||
import {
|
import {
|
||||||
@@ -26,8 +27,7 @@
|
|||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
let infoPromise: Promise<MaybeFileInfo> | undefined = $state();
|
let info: MaybeFileInfo | undefined = $state();
|
||||||
let info: FileInfo | null = $state(null);
|
|
||||||
let downloadState = $derived(getFileDownloadState(data.id));
|
let downloadState = $derived(getFileDownloadState(data.id));
|
||||||
|
|
||||||
let isMenuOpen = $state(false);
|
let isMenuOpen = $state(false);
|
||||||
@@ -65,22 +65,20 @@
|
|||||||
const addToCategory = async (categoryId: number) => {
|
const addToCategory = async (categoryId: number) => {
|
||||||
await requestFileAdditionToCategory(data.id, categoryId);
|
await requestFileAdditionToCategory(data.id, categoryId);
|
||||||
isAddToCategoryBottomSheetOpen = false;
|
isAddToCategoryBottomSheetOpen = false;
|
||||||
infoPromise = getFileInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
void getFileInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeFromCategory = async (categoryId: number) => {
|
const removeFromCategory = async (categoryId: number) => {
|
||||||
await requestFileRemovalFromCategory(data.id, categoryId);
|
await requestFileRemovalFromCategory(data.id, categoryId);
|
||||||
infoPromise = getFileInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
void getFileInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
};
|
};
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
infoPromise = getFileInfo(data.id, $masterKeyStore?.get(1)?.key!).then((fileInfo) => {
|
HybridPromise.resolve(getFileInfo(data.id, $masterKeyStore?.get(1)?.key!)).then((result) => {
|
||||||
if (fileInfo.exists) {
|
if (data.id === result.id) {
|
||||||
info = fileInfo;
|
info = result;
|
||||||
}
|
}
|
||||||
return fileInfo;
|
|
||||||
});
|
});
|
||||||
info = null;
|
|
||||||
isDownloadRequested = false;
|
isDownloadRequested = false;
|
||||||
viewerType = undefined;
|
viewerType = undefined;
|
||||||
});
|
});
|
||||||
@@ -111,8 +109,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (info && downloadState?.status === "decrypted") {
|
if (info?.exists && downloadState?.status === "decrypted") {
|
||||||
untrack(() => !isDownloadRequested && updateViewer(downloadState.result!, info!.contentType));
|
untrack(() => !isDownloadRequested && updateViewer(downloadState.result!, info!.contentIv!));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -123,88 +121,85 @@
|
|||||||
<title>파일</title>
|
<title>파일</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
{#if info}
|
<TopBar title={info?.name}>
|
||||||
<TopBar title={info.name}>
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
<div onclick={(e) => e.stopPropagation()}>
|
||||||
<div onclick={(e) => e.stopPropagation()}>
|
<button
|
||||||
<button
|
onclick={() => (isMenuOpen = !isMenuOpen)}
|
||||||
onclick={() => (isMenuOpen = !isMenuOpen)}
|
class="w-[2.3rem] flex-shrink-0 rounded-full p-1 active:bg-black active:bg-opacity-[0.04]"
|
||||||
class="w-[2.3rem] flex-shrink-0 rounded-full p-1 active:bg-black active:bg-opacity-[0.04]"
|
>
|
||||||
>
|
<IconMoreVert class="text-2xl" />
|
||||||
<IconMoreVert class="text-2xl" />
|
</button>
|
||||||
</button>
|
<TopBarMenu
|
||||||
<TopBarMenu
|
bind:isOpen={isMenuOpen}
|
||||||
bind:isOpen={isMenuOpen}
|
directoryId={["category", "gallery"].includes(page.url.searchParams.get("from") ?? "")
|
||||||
directoryId={["category", "gallery"].includes(page.url.searchParams.get("from") ?? "")
|
? info?.parentId
|
||||||
? info.parentId
|
: undefined}
|
||||||
: undefined}
|
{fileBlob}
|
||||||
{fileBlob}
|
filename={info?.name}
|
||||||
filename={info.name}
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
</TopBar>
|
||||||
</TopBar>
|
<FullscreenDiv>
|
||||||
<FullscreenDiv>
|
<div class="space-y-4 pb-4">
|
||||||
<div class="space-y-4 pb-4">
|
{#if downloadState}
|
||||||
{#if downloadState}
|
<DownloadStatus state={downloadState} />
|
||||||
<DownloadStatus state={downloadState} />
|
{/if}
|
||||||
{/if}
|
{#if info && viewerType}
|
||||||
{#if viewerType}
|
<div class="flex w-full justify-center">
|
||||||
<div class="flex w-full justify-center">
|
{#snippet viewerLoading(message: string)}
|
||||||
{#snippet viewerLoading(message: string)}
|
<p class="text-gray-500">{message}</p>
|
||||||
<p class="text-gray-500">{message}</p>
|
{/snippet}
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#if viewerType === "image"}
|
{#if viewerType === "image"}
|
||||||
{#if fileBlobUrl}
|
{#if fileBlobUrl}
|
||||||
<img src={fileBlobUrl} alt={info.name} onerror={convertHeicToJpeg} />
|
<img src={fileBlobUrl} alt={info.name} onerror={convertHeicToJpeg} />
|
||||||
{:else}
|
{:else}
|
||||||
{@render viewerLoading("이미지를 불러오고 있어요.")}
|
{@render viewerLoading("이미지를 불러오고 있어요.")}
|
||||||
{/if}
|
|
||||||
{:else if viewerType === "video"}
|
|
||||||
{#if fileBlobUrl}
|
|
||||||
<div class="flex flex-col space-y-2">
|
|
||||||
<!-- svelte-ignore a11y_media_has_caption -->
|
|
||||||
<video bind:this={videoElement} src={fileBlobUrl} controls muted></video>
|
|
||||||
<IconEntryButton
|
|
||||||
icon={IconCamera}
|
|
||||||
onclick={() => updateThumbnail(info?.dataKey?.key!, info?.dataKey?.version!)}
|
|
||||||
class="w-full"
|
|
||||||
>
|
|
||||||
이 장면을 썸네일로 설정하기
|
|
||||||
</IconEntryButton>
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
{@render viewerLoading("비디오를 불러오고 있어요.")}
|
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
{:else if viewerType === "video"}
|
||||||
{/if}
|
{#if fileBlobUrl}
|
||||||
<div class="space-y-2">
|
<div class="flex flex-col space-y-2">
|
||||||
<p class="text-lg font-bold">카테고리</p>
|
<video bind:this={videoElement} src={fileBlobUrl} controls muted></video>
|
||||||
<div class="space-y-1">
|
<IconEntryButton
|
||||||
<Categories
|
icon={IconCamera}
|
||||||
categories={info.categories}
|
onclick={() => updateThumbnail(info?.dataKey?.key!, info?.dataKey?.version!)}
|
||||||
categoryMenuIcon={IconClose}
|
class="w-full"
|
||||||
onCategoryClick={({ id }) => goto(`/category/${id}`)}
|
>
|
||||||
onCategoryMenuClick={({ id }) => removeFromCategory(id)}
|
이 장면을 썸네일로 설정하기
|
||||||
/>
|
</IconEntryButton>
|
||||||
<IconEntryButton
|
</div>
|
||||||
icon={IconAddCircle}
|
{:else}
|
||||||
onclick={() => (isAddToCategoryBottomSheetOpen = true)}
|
{@render viewerLoading("비디오를 불러오고 있어요.")}
|
||||||
class="h-12 w-full"
|
{/if}
|
||||||
iconClass="text-gray-600"
|
{/if}
|
||||||
textClass="text-gray-700"
|
</div>
|
||||||
>
|
{/if}
|
||||||
카테고리에 추가하기
|
<div class="space-y-2">
|
||||||
</IconEntryButton>
|
<p class="text-lg font-bold">카테고리</p>
|
||||||
</div>
|
<div class="space-y-1">
|
||||||
|
<Categories
|
||||||
|
categories={info?.categories ?? []}
|
||||||
|
categoryMenuIcon={IconClose}
|
||||||
|
onCategoryClick={({ id }) => goto(`/category/${id}`)}
|
||||||
|
onCategoryMenuClick={({ id }) => removeFromCategory(id)}
|
||||||
|
/>
|
||||||
|
<IconEntryButton
|
||||||
|
icon={IconAddCircle}
|
||||||
|
onclick={() => (isAddToCategoryBottomSheetOpen = true)}
|
||||||
|
class="h-12 w-full"
|
||||||
|
iconClass="text-gray-600"
|
||||||
|
textClass="text-gray-700"
|
||||||
|
>
|
||||||
|
카테고리에 추가하기
|
||||||
|
</IconEntryButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</FullscreenDiv>
|
</div>
|
||||||
|
</FullscreenDiv>
|
||||||
|
|
||||||
<AddToCategoryBottomSheet
|
<AddToCategoryBottomSheet
|
||||||
bind:isOpen={isAddToCategoryBottomSheetOpen}
|
bind:isOpen={isAddToCategoryBottomSheetOpen}
|
||||||
onAddToCategoryClick={addToCategory}
|
onAddToCategoryClick={addToCategory}
|
||||||
/>
|
/>
|
||||||
{/if}
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import { CategoryCreateModal } from "$lib/components/organisms";
|
import { CategoryCreateModal } from "$lib/components/organisms";
|
||||||
import { getCategoryInfo, type MaybeCategoryInfo } from "$lib/modules/filesystem";
|
import { getCategoryInfo, type MaybeCategoryInfo } from "$lib/modules/filesystem";
|
||||||
import { masterKeyStore } from "$lib/stores";
|
import { masterKeyStore } from "$lib/stores";
|
||||||
|
import { HybridPromise } from "$lib/utils";
|
||||||
import { requestCategoryCreation } from "./service";
|
import { requestCategoryCreation } from "./service";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -13,48 +14,50 @@
|
|||||||
|
|
||||||
let { onAddToCategoryClick, isOpen = $bindable() }: Props = $props();
|
let { onAddToCategoryClick, isOpen = $bindable() }: Props = $props();
|
||||||
|
|
||||||
let categoryInfoPromise: Promise<MaybeCategoryInfo> | undefined = $state();
|
let categoryInfo: MaybeCategoryInfo | undefined = $state();
|
||||||
|
|
||||||
let isCategoryCreateModalOpen = $state(false);
|
let isCategoryCreateModalOpen = $state(false);
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
categoryInfoPromise = getCategoryInfo("root", $masterKeyStore?.get(1)?.key!);
|
HybridPromise.resolve(getCategoryInfo("root", $masterKeyStore?.get(1)?.key!)).then(
|
||||||
|
(result) => (categoryInfo = result),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await categoryInfoPromise then categoryInfo}
|
{#if categoryInfo?.exists}
|
||||||
{#if categoryInfo?.exists}
|
<BottomSheet bind:isOpen class="flex flex-col">
|
||||||
<BottomSheet bind:isOpen class="flex flex-col">
|
<FullscreenDiv>
|
||||||
<FullscreenDiv>
|
<SubCategories
|
||||||
<SubCategories
|
class="py-4"
|
||||||
class="py-4"
|
info={categoryInfo}
|
||||||
info={categoryInfo}
|
onSubCategoryClick={({ id }) =>
|
||||||
onSubCategoryClick={({ id }) =>
|
HybridPromise.resolve(getCategoryInfo(id, $masterKeyStore?.get(1)?.key!)).then(
|
||||||
(categoryInfoPromise = getCategoryInfo(id, $masterKeyStore?.get(1)?.key!))}
|
(result) => (categoryInfo = result),
|
||||||
onSubCategoryCreateClick={() => (isCategoryCreateModalOpen = true)}
|
)}
|
||||||
subCategoryCreatePosition="top"
|
onSubCategoryCreateClick={() => (isCategoryCreateModalOpen = true)}
|
||||||
/>
|
subCategoryCreatePosition="top"
|
||||||
{#if categoryInfo.id !== "root"}
|
/>
|
||||||
<BottomDiv>
|
{#if categoryInfo.id !== "root"}
|
||||||
<Button onclick={() => onAddToCategoryClick(categoryInfo.id)} class="w-full">
|
<BottomDiv>
|
||||||
이 카테고리에 추가하기
|
<Button onclick={() => onAddToCategoryClick(categoryInfo!.id as number)} class="w-full">
|
||||||
</Button>
|
{categoryInfo!.name} 카테고리에 추가하기
|
||||||
</BottomDiv>
|
</Button>
|
||||||
{/if}
|
</BottomDiv>
|
||||||
</FullscreenDiv>
|
{/if}
|
||||||
</BottomSheet>
|
</FullscreenDiv>
|
||||||
|
</BottomSheet>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<CategoryCreateModal
|
<CategoryCreateModal
|
||||||
bind:isOpen={isCategoryCreateModalOpen}
|
bind:isOpen={isCategoryCreateModalOpen}
|
||||||
onCreateClick={async (name: string) => {
|
onCreateClick={async (name: string) => {
|
||||||
if (await requestCategoryCreation(name, categoryInfo.id, $masterKeyStore?.get(1)!)) {
|
if (await requestCategoryCreation(name, categoryInfo!.id, $masterKeyStore?.get(1)!)) {
|
||||||
categoryInfoPromise = getCategoryInfo(categoryInfo.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
void getCategoryInfo(categoryInfo!.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
|
||||||
{/await}
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<div class="flex h-14 items-center gap-x-4 p-2">
|
<div class="flex h-14 items-center gap-x-4 p-2">
|
||||||
<div class="flex-shrink-0 text-lg text-gray-600">
|
<div class="flex-shrink-0 text-lg text-gray-600">
|
||||||
{#if state.status === "encryption-pending"}
|
{#if state.status === "queued" || state.status === "encryption-pending"}
|
||||||
<IconPending />
|
<IconPending />
|
||||||
{:else if state.status === "encrypting"}
|
{:else if state.status === "encrypting"}
|
||||||
<IconLockClock />
|
<IconLockClock />
|
||||||
@@ -37,7 +37,9 @@
|
|||||||
{state.name}
|
{state.name}
|
||||||
</p>
|
</p>
|
||||||
<p class="text-xs text-gray-800">
|
<p class="text-xs text-gray-800">
|
||||||
{#if state.status === "encryption-pending"}
|
{#if state.status === "queued"}
|
||||||
|
대기 중
|
||||||
|
{:else if state.status === "encryption-pending"}
|
||||||
준비 중
|
준비 중
|
||||||
{:else if state.status === "encrypting"}
|
{:else if state.status === "encrypting"}
|
||||||
암호화하는 중
|
암호화하는 중
|
||||||
|
|||||||
@@ -1,15 +1,54 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { FullscreenDiv } from "$lib/components/atoms";
|
import { FileThumbnailButton, FullscreenDiv, RowVirtualizer } from "$lib/components/atoms";
|
||||||
import { TopBar } from "$lib/components/molecules";
|
import { TopBar } from "$lib/components/molecules";
|
||||||
import { Gallery } from "$lib/components/organisms";
|
import {
|
||||||
import { bulkGetFileInfo, type MaybeFileInfo } from "$lib/modules/filesystem";
|
bulkGetFileInfo,
|
||||||
|
type MaybeFileInfo,
|
||||||
|
type SummarizedFileInfo,
|
||||||
|
} from "$lib/modules/filesystem";
|
||||||
import { masterKeyStore } from "$lib/stores";
|
import { masterKeyStore } from "$lib/stores";
|
||||||
|
import { formatDate, formatDateSortable, SortBy, sortEntries } from "$lib/utils";
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
|
type Row =
|
||||||
|
| { type: "header"; label: string }
|
||||||
|
| { type: "items"; files: SummarizedFileInfo[]; isLast: boolean };
|
||||||
|
|
||||||
let files: MaybeFileInfo[] = $state([]);
|
let files: MaybeFileInfo[] = $state([]);
|
||||||
|
let rows: Row[] = $derived.by(() => {
|
||||||
|
const groups = Map.groupBy(
|
||||||
|
files
|
||||||
|
.filter((file) => file.exists)
|
||||||
|
.filter(
|
||||||
|
(file) => file.contentType.startsWith("image/") || file.contentType.startsWith("video/"),
|
||||||
|
)
|
||||||
|
.map((file) => ({ ...file, date: file.createdAt ?? file.lastModifiedAt })),
|
||||||
|
(file) => formatDateSortable(file.date),
|
||||||
|
);
|
||||||
|
return Array.from(groups.entries())
|
||||||
|
.sort(([dateA], [dateB]) => dateB.localeCompare(dateA))
|
||||||
|
.flatMap(([, entries]) => {
|
||||||
|
const sortedEntries = sortEntries([...entries], SortBy.DATE_DESC);
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: "header",
|
||||||
|
label: formatDate(sortedEntries[0]!.date),
|
||||||
|
},
|
||||||
|
...Array.from({ length: Math.ceil(sortedEntries.length / 4) }, (_, i) => {
|
||||||
|
const start = i * 4;
|
||||||
|
const end = start + 4;
|
||||||
|
return {
|
||||||
|
type: "items" as const,
|
||||||
|
files: sortedEntries.slice(start, end),
|
||||||
|
isLast: end >= sortedEntries.length,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
files = Array.from((await bulkGetFileInfo(data.files, $masterKeyStore?.get(1)?.key!)).values());
|
files = Array.from((await bulkGetFileInfo(data.files, $masterKeyStore?.get(1)?.key!)).values());
|
||||||
@@ -22,8 +61,37 @@
|
|||||||
|
|
||||||
<TopBar title="사진 및 동영상" />
|
<TopBar title="사진 및 동영상" />
|
||||||
<FullscreenDiv>
|
<FullscreenDiv>
|
||||||
<Gallery
|
<RowVirtualizer
|
||||||
files={files.filter((file) => file?.exists)}
|
count={rows.length}
|
||||||
onFileClick={({ id }) => goto(`/file/${id}?from=gallery`)}
|
itemHeight={(index) =>
|
||||||
/>
|
rows[index]!.type === "header" ? 28 : 181 + (rows[index]!.isLast ? 16 : 4)}
|
||||||
|
class="flex flex-grow flex-col"
|
||||||
|
>
|
||||||
|
{#snippet item(index)}
|
||||||
|
{@const row = rows[index]!}
|
||||||
|
{#if row.type === "header"}
|
||||||
|
<p class="pb-2 text-sm font-medium">{row.label}</p>
|
||||||
|
{:else}
|
||||||
|
<div class={["grid grid-cols-4 gap-x-1", row.isLast ? "pb-4" : "pb-1"]}>
|
||||||
|
{#each row.files as file (file.id)}
|
||||||
|
<FileThumbnailButton
|
||||||
|
info={file}
|
||||||
|
onclick={() => goto(`/file/${file.id}?from=gallery`)}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/snippet}
|
||||||
|
{#snippet placeholder()}
|
||||||
|
<div class="flex h-full flex-grow items-center justify-center">
|
||||||
|
<p class="text-gray-500">
|
||||||
|
{#if files.length === 0}
|
||||||
|
업로드된 파일이 없어요.
|
||||||
|
{:else}
|
||||||
|
사진 또는 동영상이 없어요.
|
||||||
|
{/if}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
</RowVirtualizer>
|
||||||
</FullscreenDiv>
|
</FullscreenDiv>
|
||||||
|
|||||||
@@ -4,17 +4,36 @@
|
|||||||
import { BottomDiv, Button, FullscreenDiv } from "$lib/components/atoms";
|
import { BottomDiv, Button, FullscreenDiv } from "$lib/components/atoms";
|
||||||
import { IconEntryButton, TopBar } from "$lib/components/molecules";
|
import { IconEntryButton, TopBar } from "$lib/components/molecules";
|
||||||
import { deleteAllFileThumbnailCaches } from "$lib/modules/file";
|
import { deleteAllFileThumbnailCaches } from "$lib/modules/file";
|
||||||
import { bulkGetFileInfo } from "$lib/modules/filesystem";
|
import { bulkGetFileInfo, type MaybeFileInfo } from "$lib/modules/filesystem";
|
||||||
import { masterKeyStore } from "$lib/stores";
|
import { masterKeyStore } from "$lib/stores";
|
||||||
|
import { sortEntries } from "$lib/utils";
|
||||||
import File from "./File.svelte";
|
import File from "./File.svelte";
|
||||||
import { persistentStates, requestThumbnailGeneration } from "./service.svelte";
|
import {
|
||||||
|
getThumbnailGenerationStatus,
|
||||||
|
clearThumbnailGenerationStatuses,
|
||||||
|
requestThumbnailGeneration,
|
||||||
|
type GenerationStatus,
|
||||||
|
} from "./service";
|
||||||
|
|
||||||
import IconDelete from "~icons/material-symbols/delete";
|
import IconDelete from "~icons/material-symbols/delete";
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
|
let fileInfos: MaybeFileInfo[] = $state([]);
|
||||||
|
let files = $derived(
|
||||||
|
fileInfos
|
||||||
|
.map((info) => ({
|
||||||
|
info,
|
||||||
|
status: getThumbnailGenerationStatus(info.id),
|
||||||
|
}))
|
||||||
|
.filter(
|
||||||
|
(file): file is { info: MaybeFileInfo; status: Exclude<GenerationStatus, "uploaded"> } =>
|
||||||
|
file.status !== "uploaded",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
const generateAllThumbnails = () => {
|
const generateAllThumbnails = () => {
|
||||||
persistentStates.files.forEach(({ info }) => {
|
files.forEach(({ info }) => {
|
||||||
if (info.exists) {
|
if (info.exists) {
|
||||||
requestThumbnailGeneration(info);
|
requestThumbnailGeneration(info);
|
||||||
}
|
}
|
||||||
@@ -22,13 +41,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const fileInfos = await bulkGetFileInfo(data.files, $masterKeyStore?.get(1)?.key!);
|
fileInfos = sortEntries(
|
||||||
persistentStates.files = persistentStates.files.map(({ id, status }) => ({
|
Array.from((await bulkGetFileInfo(data.files, $masterKeyStore?.get(1)?.key!)).values()),
|
||||||
id,
|
);
|
||||||
info: fileInfos.get(id)!,
|
|
||||||
status,
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$effect(() => clearThumbnailGenerationStatuses);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -43,19 +61,19 @@
|
|||||||
저장된 썸네일 모두 삭제하기
|
저장된 썸네일 모두 삭제하기
|
||||||
</IconEntryButton>
|
</IconEntryButton>
|
||||||
</div>
|
</div>
|
||||||
{#if persistentStates.files.length > 0}
|
{#if files.length > 0}
|
||||||
<div class="flex-grow space-y-2 bg-white p-4">
|
<div class="flex-grow space-y-2 bg-white p-4">
|
||||||
<p class="text-lg font-bold text-gray-800">썸네일이 누락된 파일</p>
|
<p class="text-lg font-bold text-gray-800">썸네일이 누락된 파일</p>
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<p class="break-keep text-gray-800">
|
<p class="break-keep text-gray-800">
|
||||||
{persistentStates.files.length}개 파일의 썸네일이 존재하지 않아요.
|
{files.length}개 파일의 썸네일이 존재하지 않아요.
|
||||||
</p>
|
</p>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
{#each persistentStates.files as { info, status } (info.id)}
|
{#each files as { info, status } (info.id)}
|
||||||
{#if info.exists}
|
{#if info.exists}
|
||||||
<File
|
<File
|
||||||
{info}
|
{info}
|
||||||
generationStatus={status}
|
{status}
|
||||||
onclick={({ id }) => goto(`/file/${id}`)}
|
onclick={({ id }) => goto(`/file/${id}`)}
|
||||||
onGenerateThumbnailClick={requestThumbnailGeneration}
|
onGenerateThumbnailClick={requestThumbnailGeneration}
|
||||||
/>
|
/>
|
||||||
@@ -66,7 +84,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if persistentStates.files.length > 0}
|
{#if files.length > 0}
|
||||||
<BottomDiv class="px-4">
|
<BottomDiv class="px-4">
|
||||||
<Button onclick={generateAllThumbnails} class="w-full">모두 썸네일 생성하기</Button>
|
<Button onclick={generateAllThumbnails} class="w-full">모두 썸네일 생성하기</Button>
|
||||||
</BottomDiv>
|
</BottomDiv>
|
||||||
|
|||||||
@@ -10,12 +10,11 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Writable } from "svelte/store";
|
|
||||||
import { ActionEntryButton } from "$lib/components/atoms";
|
import { ActionEntryButton } from "$lib/components/atoms";
|
||||||
import { DirectoryEntryLabel } from "$lib/components/molecules";
|
import { DirectoryEntryLabel } from "$lib/components/molecules";
|
||||||
import type { FileInfo } from "$lib/modules/filesystem";
|
import type { FileInfo } from "$lib/modules/filesystem";
|
||||||
import { formatDateTime } from "$lib/utils";
|
import { formatDateTime } from "$lib/utils";
|
||||||
import type { GenerationStatus } from "./service.svelte";
|
import type { GenerationStatus } from "./service";
|
||||||
|
|
||||||
import IconCamera from "~icons/material-symbols/camera";
|
import IconCamera from "~icons/material-symbols/camera";
|
||||||
|
|
||||||
@@ -23,22 +22,21 @@
|
|||||||
info: FileInfo;
|
info: FileInfo;
|
||||||
onclick: (file: FileInfo) => void;
|
onclick: (file: FileInfo) => void;
|
||||||
onGenerateThumbnailClick: (file: FileInfo) => void;
|
onGenerateThumbnailClick: (file: FileInfo) => void;
|
||||||
generationStatus?: Writable<GenerationStatus>;
|
status: Exclude<GenerationStatus, "uploaded"> | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { info, onclick, onGenerateThumbnailClick, generationStatus }: Props = $props();
|
let { info, onclick, onGenerateThumbnailClick, status }: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ActionEntryButton
|
<ActionEntryButton
|
||||||
class="h-14"
|
class="h-14"
|
||||||
onclick={() => onclick(info)}
|
onclick={() => onclick(info)}
|
||||||
actionButtonIcon={!$generationStatus || $generationStatus === "error" ? IconCamera : undefined}
|
actionButtonIcon={!status || status === "error" ? IconCamera : undefined}
|
||||||
onActionButtonClick={() => onGenerateThumbnailClick(info)}
|
onActionButtonClick={() => onGenerateThumbnailClick(info)}
|
||||||
actionButtonClass="text-gray-800"
|
actionButtonClass="text-gray-800"
|
||||||
>
|
>
|
||||||
{@const subtext =
|
{@const subtext = status
|
||||||
$generationStatus && $generationStatus !== "uploaded"
|
? subtexts[status]
|
||||||
? subtexts[$generationStatus]
|
: formatDateTime(info.createdAt ?? info.lastModifiedAt)}
|
||||||
: formatDateTime(info.createdAt ?? info.lastModifiedAt)}
|
|
||||||
<DirectoryEntryLabel type="file" name={info.name} {subtext} />
|
<DirectoryEntryLabel type="file" name={info.name} {subtext} />
|
||||||
</ActionEntryButton>
|
</ActionEntryButton>
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
import { limitFunction } from "p-limit";
|
|
||||||
import { get, writable, type Writable } from "svelte/store";
|
|
||||||
import { encryptData } from "$lib/modules/crypto";
|
|
||||||
import { storeFileThumbnailCache } from "$lib/modules/file";
|
|
||||||
import type { FileInfo, MaybeFileInfo } from "$lib/modules/filesystem";
|
|
||||||
import { generateThumbnail as doGenerateThumbnail } from "$lib/modules/thumbnail";
|
|
||||||
import { requestFileDownload, requestFileThumbnailUpload } from "$lib/services/file";
|
|
||||||
|
|
||||||
export type GenerationStatus =
|
|
||||||
| "queued"
|
|
||||||
| "generation-pending"
|
|
||||||
| "generating"
|
|
||||||
| "upload-pending"
|
|
||||||
| "uploading"
|
|
||||||
| "uploaded"
|
|
||||||
| "error";
|
|
||||||
|
|
||||||
interface File {
|
|
||||||
id: number;
|
|
||||||
info: MaybeFileInfo;
|
|
||||||
status?: Writable<GenerationStatus>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const workingFiles = new Map<number, Writable<GenerationStatus>>();
|
|
||||||
|
|
||||||
let queue: (() => void)[] = [];
|
|
||||||
let memoryUsage = 0;
|
|
||||||
const memoryLimit = 100 * 1024 * 1024; // 100 MiB
|
|
||||||
|
|
||||||
export const persistentStates = $state({
|
|
||||||
files: [] as File[],
|
|
||||||
});
|
|
||||||
|
|
||||||
export const getGenerationStatus = (fileId: number) => {
|
|
||||||
return workingFiles.get(fileId);
|
|
||||||
};
|
|
||||||
|
|
||||||
const generateThumbnail = limitFunction(
|
|
||||||
async (
|
|
||||||
status: Writable<GenerationStatus>,
|
|
||||||
fileBuffer: ArrayBuffer,
|
|
||||||
fileType: string,
|
|
||||||
dataKey: CryptoKey,
|
|
||||||
) => {
|
|
||||||
status.set("generating");
|
|
||||||
|
|
||||||
const thumbnail = await doGenerateThumbnail(fileBuffer, fileType);
|
|
||||||
if (!thumbnail) return null;
|
|
||||||
|
|
||||||
const thumbnailBuffer = await thumbnail.arrayBuffer();
|
|
||||||
const thumbnailEncrypted = await encryptData(thumbnailBuffer, dataKey);
|
|
||||||
status.set("upload-pending");
|
|
||||||
return { plaintext: thumbnailBuffer, ...thumbnailEncrypted };
|
|
||||||
},
|
|
||||||
{ concurrency: 4 },
|
|
||||||
);
|
|
||||||
|
|
||||||
const requestThumbnailUpload = limitFunction(
|
|
||||||
async (
|
|
||||||
status: Writable<GenerationStatus>,
|
|
||||||
fileId: number,
|
|
||||||
dataKeyVersion: Date,
|
|
||||||
thumbnail: { plaintext: ArrayBuffer; ciphertext: ArrayBuffer; iv: string },
|
|
||||||
) => {
|
|
||||||
status.set("uploading");
|
|
||||||
|
|
||||||
const res = await requestFileThumbnailUpload(fileId, dataKeyVersion, thumbnail);
|
|
||||||
if (!res.ok) return false;
|
|
||||||
|
|
||||||
status.set("uploaded");
|
|
||||||
workingFiles.delete(fileId);
|
|
||||||
persistentStates.files = persistentStates.files.filter(({ id }) => id != fileId);
|
|
||||||
|
|
||||||
storeFileThumbnailCache(fileId, thumbnail.plaintext); // Intended
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
{ concurrency: 4 },
|
|
||||||
);
|
|
||||||
|
|
||||||
const enqueue = async (
|
|
||||||
status: Writable<GenerationStatus> | undefined,
|
|
||||||
fileInfo: FileInfo,
|
|
||||||
priority = false,
|
|
||||||
) => {
|
|
||||||
if (status) {
|
|
||||||
status.set("queued");
|
|
||||||
} else {
|
|
||||||
status = writable("queued");
|
|
||||||
workingFiles.set(fileInfo.id, status);
|
|
||||||
persistentStates.files = persistentStates.files.map((file) =>
|
|
||||||
file.id === fileInfo.id ? { ...file, status } : file,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let resolver;
|
|
||||||
const promise = new Promise((resolve) => {
|
|
||||||
resolver = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (priority) {
|
|
||||||
queue = [resolver!, ...queue];
|
|
||||||
} else {
|
|
||||||
queue.push(resolver!);
|
|
||||||
}
|
|
||||||
|
|
||||||
await promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const requestThumbnailGeneration = async (fileInfo: FileInfo) => {
|
|
||||||
let status = workingFiles.get(fileInfo.id);
|
|
||||||
if (status && get(status) !== "error") return;
|
|
||||||
|
|
||||||
if (workingFiles.values().some((status) => get(status) !== "error")) {
|
|
||||||
await enqueue(status, fileInfo);
|
|
||||||
}
|
|
||||||
while (memoryUsage >= memoryLimit) {
|
|
||||||
await enqueue(status, fileInfo, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status) {
|
|
||||||
status.set("generation-pending");
|
|
||||||
} else {
|
|
||||||
status = writable("generation-pending");
|
|
||||||
workingFiles.set(fileInfo.id, status);
|
|
||||||
persistentStates.files = persistentStates.files.map((file) =>
|
|
||||||
file.id === fileInfo.id ? { ...file, status } : file,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let fileSize = 0;
|
|
||||||
try {
|
|
||||||
const file = await requestFileDownload(
|
|
||||||
fileInfo.id,
|
|
||||||
fileInfo.contentIv!,
|
|
||||||
fileInfo.dataKey?.key!,
|
|
||||||
);
|
|
||||||
fileSize = file.byteLength;
|
|
||||||
|
|
||||||
memoryUsage += fileSize;
|
|
||||||
if (memoryUsage < memoryLimit) {
|
|
||||||
queue.shift()?.();
|
|
||||||
}
|
|
||||||
|
|
||||||
const thumbnail = await generateThumbnail(
|
|
||||||
status,
|
|
||||||
file,
|
|
||||||
fileInfo.contentType,
|
|
||||||
fileInfo.dataKey?.key!,
|
|
||||||
);
|
|
||||||
if (
|
|
||||||
!thumbnail ||
|
|
||||||
!(await requestThumbnailUpload(status, fileInfo.id, fileInfo.dataKey?.version!, thumbnail))
|
|
||||||
) {
|
|
||||||
status.set("error");
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
status.set("error");
|
|
||||||
} finally {
|
|
||||||
memoryUsage -= fileSize;
|
|
||||||
queue.shift()?.();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
102
src/routes/(fullscreen)/settings/thumbnail/service.ts
Normal file
102
src/routes/(fullscreen)/settings/thumbnail/service.ts
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import { limitFunction } from "p-limit";
|
||||||
|
import { SvelteMap } from "svelte/reactivity";
|
||||||
|
import { encryptData } from "$lib/modules/crypto";
|
||||||
|
import { storeFileThumbnailCache } from "$lib/modules/file";
|
||||||
|
import type { FileInfo } from "$lib/modules/filesystem";
|
||||||
|
import { Scheduler } from "$lib/modules/scheduler";
|
||||||
|
import { generateThumbnail as doGenerateThumbnail } from "$lib/modules/thumbnail";
|
||||||
|
import { requestFileDownload, requestFileThumbnailUpload } from "$lib/services/file";
|
||||||
|
|
||||||
|
export type GenerationStatus =
|
||||||
|
| "queued"
|
||||||
|
| "generation-pending"
|
||||||
|
| "generating"
|
||||||
|
| "upload-pending"
|
||||||
|
| "uploading"
|
||||||
|
| "uploaded"
|
||||||
|
| "error";
|
||||||
|
|
||||||
|
const scheduler = new Scheduler();
|
||||||
|
const statuses = new SvelteMap<number, GenerationStatus>();
|
||||||
|
|
||||||
|
export const getThumbnailGenerationStatus = (fileId: number) => {
|
||||||
|
return statuses.get(fileId);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const clearThumbnailGenerationStatuses = () => {
|
||||||
|
for (const [id, status] of statuses) {
|
||||||
|
if (status === "uploaded" || status === "error") {
|
||||||
|
statuses.delete(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const generateThumbnail = limitFunction(
|
||||||
|
async (fileId: number, fileBuffer: ArrayBuffer, fileType: string, dataKey: CryptoKey) => {
|
||||||
|
statuses.set(fileId, "generating");
|
||||||
|
|
||||||
|
const thumbnail = await doGenerateThumbnail(fileBuffer, fileType);
|
||||||
|
if (!thumbnail) return null;
|
||||||
|
|
||||||
|
const thumbnailBuffer = await thumbnail.arrayBuffer();
|
||||||
|
const thumbnailEncrypted = await encryptData(thumbnailBuffer, dataKey);
|
||||||
|
statuses.set(fileId, "upload-pending");
|
||||||
|
return { plaintext: thumbnailBuffer, ...thumbnailEncrypted };
|
||||||
|
},
|
||||||
|
{ concurrency: 4 },
|
||||||
|
);
|
||||||
|
|
||||||
|
const requestThumbnailUpload = limitFunction(
|
||||||
|
async (
|
||||||
|
fileId: number,
|
||||||
|
dataKeyVersion: Date,
|
||||||
|
thumbnail: { plaintext: ArrayBuffer; ciphertext: ArrayBuffer; iv: string },
|
||||||
|
) => {
|
||||||
|
statuses.set(fileId, "uploading");
|
||||||
|
|
||||||
|
const res = await requestFileThumbnailUpload(fileId, dataKeyVersion, thumbnail);
|
||||||
|
if (!res.ok) return false;
|
||||||
|
statuses.set(fileId, "uploaded");
|
||||||
|
storeFileThumbnailCache(fileId, thumbnail.plaintext); // Intended
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
{ concurrency: 4 },
|
||||||
|
);
|
||||||
|
|
||||||
|
export const requestThumbnailGeneration = async (fileInfo: FileInfo) => {
|
||||||
|
const status = statuses.get(fileInfo.id);
|
||||||
|
if (status) {
|
||||||
|
if (status !== "error") return;
|
||||||
|
} else {
|
||||||
|
statuses.set(fileInfo.id, "queued");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let file: ArrayBuffer | undefined;
|
||||||
|
|
||||||
|
await scheduler.schedule(
|
||||||
|
async () => {
|
||||||
|
statuses.set(fileInfo.id, "generation-pending");
|
||||||
|
file = await requestFileDownload(fileInfo.id, fileInfo.contentIv!, fileInfo.dataKey?.key!);
|
||||||
|
return file.byteLength;
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
const thumbnail = await generateThumbnail(
|
||||||
|
fileInfo.id,
|
||||||
|
file!,
|
||||||
|
fileInfo.contentType,
|
||||||
|
fileInfo.dataKey?.key!,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
!thumbnail ||
|
||||||
|
!(await requestThumbnailUpload(fileInfo.id, fileInfo.dataKey?.version!, thumbnail))
|
||||||
|
) {
|
||||||
|
statuses.set(fileInfo.id, "error");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
statuses.set(fileInfo.id, "error");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { TopBar } from "$lib/components/molecules";
|
import { CheckBox, RowVirtualizer } from "$lib/components/atoms";
|
||||||
import { Category, CategoryCreateModal } from "$lib/components/organisms";
|
import { SubCategories, TopBar } from "$lib/components/molecules";
|
||||||
|
import { CategoryCreateModal } from "$lib/components/organisms";
|
||||||
|
import { updateCategoryInfo } from "$lib/indexedDB";
|
||||||
import { getCategoryInfo, type MaybeCategoryInfo } from "$lib/modules/filesystem";
|
import { getCategoryInfo, type MaybeCategoryInfo } from "$lib/modules/filesystem";
|
||||||
import { masterKeyStore } from "$lib/stores";
|
import { masterKeyStore } from "$lib/stores";
|
||||||
|
import { HybridPromise, sortEntries } from "$lib/utils";
|
||||||
import CategoryDeleteModal from "./CategoryDeleteModal.svelte";
|
import CategoryDeleteModal from "./CategoryDeleteModal.svelte";
|
||||||
import CategoryMenuBottomSheet from "./CategoryMenuBottomSheet.svelte";
|
import CategoryMenuBottomSheet from "./CategoryMenuBottomSheet.svelte";
|
||||||
import CategoryRenameModal from "./CategoryRenameModal.svelte";
|
import CategoryRenameModal from "./CategoryRenameModal.svelte";
|
||||||
|
import File from "./File.svelte";
|
||||||
import {
|
import {
|
||||||
createContext,
|
createContext,
|
||||||
requestCategoryCreation,
|
requestCategoryCreation,
|
||||||
@@ -15,18 +19,50 @@
|
|||||||
requestCategoryDeletion,
|
requestCategoryDeletion,
|
||||||
} from "./service.svelte";
|
} from "./service.svelte";
|
||||||
|
|
||||||
|
import IconMoreVert from "~icons/material-symbols/more-vert";
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
let context = createContext();
|
let context = createContext();
|
||||||
|
|
||||||
let infoPromise: Promise<MaybeCategoryInfo> | undefined = $state();
|
let info: MaybeCategoryInfo | undefined = $state();
|
||||||
|
|
||||||
let isCategoryCreateModalOpen = $state(false);
|
let isCategoryCreateModalOpen = $state(false);
|
||||||
let isCategoryMenuBottomSheetOpen = $state(false);
|
let isCategoryMenuBottomSheetOpen = $state(false);
|
||||||
let isCategoryRenameModalOpen = $state(false);
|
let isCategoryRenameModalOpen = $state(false);
|
||||||
let isCategoryDeleteModalOpen = $state(false);
|
let isCategoryDeleteModalOpen = $state(false);
|
||||||
|
|
||||||
|
let lastCategoryId: CategoryId | undefined = $state();
|
||||||
|
let lastIsFileRecursive: boolean | undefined = $state();
|
||||||
|
|
||||||
|
let files = $derived(
|
||||||
|
sortEntries(
|
||||||
|
info?.files
|
||||||
|
?.map((file) => ({ name: file.name, details: file }))
|
||||||
|
.filter(({ details }) => info?.isFileRecursive || !details.isRecursive) ?? [],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
infoPromise = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!);
|
if (!info || info.id === "root" || info.isFileRecursive === undefined) return;
|
||||||
|
if (lastCategoryId !== info.id) {
|
||||||
|
lastCategoryId = info.id;
|
||||||
|
lastIsFileRecursive = info.isFileRecursive;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lastIsFileRecursive === info.isFileRecursive) return;
|
||||||
|
|
||||||
|
lastIsFileRecursive = info.isFileRecursive;
|
||||||
|
void updateCategoryInfo(info.id, { isFileRecursive: info.isFileRecursive });
|
||||||
|
});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
HybridPromise.resolve(getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!)).then(
|
||||||
|
(result) => {
|
||||||
|
if (data.id === result.id) {
|
||||||
|
info = result;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -34,70 +70,98 @@
|
|||||||
<title>카테고리</title>
|
<title>카테고리</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
{#await infoPromise then info}
|
{#if info?.id !== "root"}
|
||||||
|
<TopBar title={info?.name} />
|
||||||
|
{/if}
|
||||||
|
<div class="min-h-full bg-gray-100 pb-[5.5em]">
|
||||||
{#if info?.exists}
|
{#if info?.exists}
|
||||||
{#if info.id !== "root"}
|
<div class="space-y-4">
|
||||||
<TopBar title={info.name} />
|
<div class="space-y-4 bg-white p-4">
|
||||||
{/if}
|
{#if info.id !== "root"}
|
||||||
<div class="min-h-full bg-gray-100 pb-[5.5em]">
|
<p class="text-lg font-bold text-gray-800">하위 카테고리</p>
|
||||||
<Category
|
{/if}
|
||||||
bind:isFileRecursive={info.isFileRecursive}
|
<SubCategories
|
||||||
{info}
|
{info}
|
||||||
onFileClick={({ id }) => goto(`/file/${id}?from=category`)}
|
onSubCategoryClick={({ id }) => goto(`/category/${id}`)}
|
||||||
onFileRemoveClick={async ({ id }) => {
|
onSubCategoryCreateClick={() => (isCategoryCreateModalOpen = true)}
|
||||||
await requestFileRemovalFromCategory(id, data.id as number);
|
onSubCategoryMenuClick={(subCategory) => {
|
||||||
infoPromise = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
context.selectedCategory = subCategory;
|
||||||
}}
|
isCategoryMenuBottomSheetOpen = true;
|
||||||
onSubCategoryClick={({ id }) => goto(`/category/${id}`)}
|
}}
|
||||||
onSubCategoryCreateClick={() => (isCategoryCreateModalOpen = true)}
|
subCategoryMenuIcon={IconMoreVert}
|
||||||
onSubCategoryMenuClick={(subCategory) => {
|
/>
|
||||||
context.selectedCategory = subCategory;
|
</div>
|
||||||
isCategoryMenuBottomSheetOpen = true;
|
{#if info.id !== "root"}
|
||||||
}}
|
<div class="space-y-4 bg-white p-4">
|
||||||
/>
|
<div class="flex items-center justify-between">
|
||||||
|
<p class="text-lg font-bold text-gray-800">파일</p>
|
||||||
|
<CheckBox bind:checked={info.isFileRecursive}>
|
||||||
|
<p class="font-medium">하위 카테고리의 파일</p>
|
||||||
|
</CheckBox>
|
||||||
|
</div>
|
||||||
|
<RowVirtualizer count={files.length} itemHeight={() => 48} itemGap={4}>
|
||||||
|
{#snippet item(index)}
|
||||||
|
{@const { details } = files[index]!}
|
||||||
|
<File
|
||||||
|
info={details}
|
||||||
|
onclick={({ id }) => goto(`/file/${id}?from=category`)}
|
||||||
|
onRemoveClick={!details.isRecursive
|
||||||
|
? async ({ id }) => {
|
||||||
|
await requestFileRemovalFromCategory(id, data.id as number);
|
||||||
|
void getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
}
|
||||||
|
: undefined}
|
||||||
|
/>
|
||||||
|
{/snippet}
|
||||||
|
{#snippet placeholder()}
|
||||||
|
<p class="text-center text-gray-500">이 카테고리에 추가된 파일이 없어요.</p>
|
||||||
|
{/snippet}
|
||||||
|
</RowVirtualizer>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CategoryCreateModal
|
|
||||||
bind:isOpen={isCategoryCreateModalOpen}
|
|
||||||
onCreateClick={async (name: string) => {
|
|
||||||
if (await requestCategoryCreation(name, data.id, $masterKeyStore?.get(1)!)) {
|
|
||||||
infoPromise = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<CategoryMenuBottomSheet
|
|
||||||
bind:isOpen={isCategoryMenuBottomSheetOpen}
|
|
||||||
onRenameClick={() => {
|
|
||||||
isCategoryMenuBottomSheetOpen = false;
|
|
||||||
isCategoryRenameModalOpen = true;
|
|
||||||
}}
|
|
||||||
onDeleteClick={() => {
|
|
||||||
isCategoryMenuBottomSheetOpen = false;
|
|
||||||
isCategoryDeleteModalOpen = true;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<CategoryRenameModal
|
|
||||||
bind:isOpen={isCategoryRenameModalOpen}
|
|
||||||
onRenameClick={async (newName: string) => {
|
|
||||||
if (await requestCategoryRename(context.selectedCategory!, newName)) {
|
|
||||||
infoPromise = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<CategoryDeleteModal
|
|
||||||
bind:isOpen={isCategoryDeleteModalOpen}
|
|
||||||
onDeleteClick={async () => {
|
|
||||||
if (await requestCategoryDeletion(context.selectedCategory!)) {
|
|
||||||
infoPromise = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
{/await}
|
</div>
|
||||||
|
|
||||||
|
<CategoryCreateModal
|
||||||
|
bind:isOpen={isCategoryCreateModalOpen}
|
||||||
|
onCreateClick={async (name: string) => {
|
||||||
|
if (await requestCategoryCreation(name, data.id, $masterKeyStore?.get(1)!)) {
|
||||||
|
void getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CategoryMenuBottomSheet
|
||||||
|
bind:isOpen={isCategoryMenuBottomSheetOpen}
|
||||||
|
onRenameClick={() => {
|
||||||
|
isCategoryMenuBottomSheetOpen = false;
|
||||||
|
isCategoryRenameModalOpen = true;
|
||||||
|
}}
|
||||||
|
onDeleteClick={() => {
|
||||||
|
isCategoryMenuBottomSheetOpen = false;
|
||||||
|
isCategoryDeleteModalOpen = true;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<CategoryRenameModal
|
||||||
|
bind:isOpen={isCategoryRenameModalOpen}
|
||||||
|
onRenameClick={async (newName: string) => {
|
||||||
|
if (await requestCategoryRename(context.selectedCategory!, newName)) {
|
||||||
|
void getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<CategoryDeleteModal
|
||||||
|
bind:isOpen={isCategoryDeleteModalOpen}
|
||||||
|
onDeleteClick={async () => {
|
||||||
|
if (await requestCategoryDeletion(context.selectedCategory!)) {
|
||||||
|
void getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from "$app/environment";
|
|
||||||
import { ActionEntryButton } from "$lib/components/atoms";
|
import { ActionEntryButton } from "$lib/components/atoms";
|
||||||
import { DirectoryEntryLabel } from "$lib/components/molecules";
|
import { DirectoryEntryLabel } from "$lib/components/molecules";
|
||||||
|
import { getFileThumbnail } from "$lib/modules/file";
|
||||||
import type { CategoryFileInfo } from "$lib/modules/filesystem";
|
import type { CategoryFileInfo } from "$lib/modules/filesystem";
|
||||||
import { requestFileThumbnailDownload } from "$lib/services/file";
|
import type { SelectedFile } from "./service.svelte";
|
||||||
import type { SelectedFile } from "./service";
|
|
||||||
|
|
||||||
import IconClose from "~icons/material-symbols/close";
|
import IconClose from "~icons/material-symbols/close";
|
||||||
|
|
||||||
@@ -16,12 +15,7 @@
|
|||||||
|
|
||||||
let { info, onclick, onRemoveClick }: Props = $props();
|
let { info, onclick, onRemoveClick }: Props = $props();
|
||||||
|
|
||||||
let showThumbnail = $derived(
|
let thumbnail = $derived(getFileThumbnail(info));
|
||||||
browser && (info.contentType.startsWith("image/") || info.contentType.startsWith("video/")),
|
|
||||||
);
|
|
||||||
let thumbnailPromise = $derived(
|
|
||||||
showThumbnail ? requestFileThumbnailDownload(info.id, info.dataKey?.key) : null,
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ActionEntryButton
|
<ActionEntryButton
|
||||||
@@ -30,9 +24,5 @@
|
|||||||
actionButtonIcon={onRemoveClick && IconClose}
|
actionButtonIcon={onRemoveClick && IconClose}
|
||||||
onActionButtonClick={() => onRemoveClick?.(info)}
|
onActionButtonClick={() => onRemoveClick?.(info)}
|
||||||
>
|
>
|
||||||
{#await thumbnailPromise}
|
<DirectoryEntryLabel type="file" thumbnail={$thumbnail} name={info.name} />
|
||||||
<DirectoryEntryLabel type="file" name={info.name} />
|
|
||||||
{:then thumbnail}
|
|
||||||
<DirectoryEntryLabel type="file" thumbnail={thumbnail ?? undefined} name={info.name} />
|
|
||||||
{/await}
|
|
||||||
</ActionEntryButton>
|
</ActionEntryButton>
|
||||||
@@ -5,6 +5,11 @@ import { trpc } from "$trpc/client";
|
|||||||
|
|
||||||
export { requestCategoryCreation, requestFileRemovalFromCategory } from "$lib/services/category";
|
export { requestCategoryCreation, requestFileRemovalFromCategory } from "$lib/services/category";
|
||||||
|
|
||||||
|
export interface SelectedFile {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
export const createContext = () => {
|
export const createContext = () => {
|
||||||
const context = $state({
|
const context = $state({
|
||||||
selectedCategory: undefined as SelectedCategory | undefined,
|
selectedCategory: undefined as SelectedCategory | undefined,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { TopBar } from "$lib/components/molecules";
|
import { TopBar } from "$lib/components/molecules";
|
||||||
import { getDirectoryInfo, type MaybeDirectoryInfo } from "$lib/modules/filesystem";
|
import { getDirectoryInfo, type MaybeDirectoryInfo } from "$lib/modules/filesystem";
|
||||||
import { masterKeyStore, hmacSecretStore } from "$lib/stores";
|
import { masterKeyStore, hmacSecretStore } from "$lib/stores";
|
||||||
|
import { HybridPromise } from "$lib/utils";
|
||||||
import DirectoryCreateModal from "./DirectoryCreateModal.svelte";
|
import DirectoryCreateModal from "./DirectoryCreateModal.svelte";
|
||||||
import DirectoryEntries from "./DirectoryEntries";
|
import DirectoryEntries from "./DirectoryEntries";
|
||||||
import DownloadStatusCard from "./DownloadStatusCard.svelte";
|
import DownloadStatusCard from "./DownloadStatusCard.svelte";
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
let context = createContext();
|
let context = createContext();
|
||||||
|
|
||||||
let infoPromise: Promise<MaybeDirectoryInfo> | undefined = $state();
|
let info: MaybeDirectoryInfo | undefined = $state();
|
||||||
let fileInput: HTMLInputElement | undefined = $state();
|
let fileInput: HTMLInputElement | undefined = $state();
|
||||||
let duplicatedFile: File | undefined = $state();
|
let duplicatedFile: File | undefined = $state();
|
||||||
let resolveForDuplicateFileModal: ((res: boolean) => void) | undefined = $state();
|
let resolveForDuplicateFileModal: ((res: boolean) => void) | undefined = $state();
|
||||||
@@ -60,7 +61,7 @@
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res) return;
|
if (!res) return;
|
||||||
// TODO: FIXME
|
// TODO: FIXME
|
||||||
infoPromise = getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!);
|
void getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!);
|
||||||
})
|
})
|
||||||
.catch((e: Error) => {
|
.catch((e: Error) => {
|
||||||
// TODO: FIXME
|
// TODO: FIXME
|
||||||
@@ -78,7 +79,13 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
infoPromise = getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!);
|
HybridPromise.resolve(getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!)).then(
|
||||||
|
(result) => {
|
||||||
|
if (data.id === result.id) {
|
||||||
|
info = result;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -88,17 +95,17 @@
|
|||||||
|
|
||||||
<input bind:this={fileInput} onchange={uploadFile} type="file" multiple class="hidden" />
|
<input bind:this={fileInput} onchange={uploadFile} type="file" multiple class="hidden" />
|
||||||
|
|
||||||
{#await infoPromise then info}
|
<div class="flex h-full flex-col">
|
||||||
|
{#if showTopBar}
|
||||||
|
<TopBar title={info?.name} class="flex-shrink-0" />
|
||||||
|
{/if}
|
||||||
{#if info?.exists}
|
{#if info?.exists}
|
||||||
<div class="flex h-full flex-col">
|
<div class={["flex flex-grow flex-col px-4 pb-4", !showTopBar && "pt-4"]}>
|
||||||
{#if showTopBar}
|
<div class="flex gap-x-2">
|
||||||
<TopBar title={info.name} class="flex-shrink-0" />
|
<UploadStatusCard onclick={() => goto("/file/uploads")} />
|
||||||
{/if}
|
<DownloadStatusCard onclick={() => goto("/file/downloads")} />
|
||||||
<div class={["flex flex-grow flex-col px-4 pb-4", !showTopBar && "pt-4"]}>
|
</div>
|
||||||
<div class="flex gap-x-2">
|
{#key info.id}
|
||||||
<UploadStatusCard onclick={() => goto("/file/uploads")} />
|
|
||||||
<DownloadStatusCard onclick={() => goto("/file/downloads")} />
|
|
||||||
</div>
|
|
||||||
<DirectoryEntries
|
<DirectoryEntries
|
||||||
{info}
|
{info}
|
||||||
onEntryClick={({ type, id }) => goto(`/${type}/${id}`)}
|
onEntryClick={({ type, id }) => goto(`/${type}/${id}`)}
|
||||||
@@ -109,85 +116,85 @@
|
|||||||
showParentEntry={isFromFilePage && info.parentId !== undefined}
|
showParentEntry={isFromFilePage && info.parentId !== undefined}
|
||||||
onParentClick={() =>
|
onParentClick={() =>
|
||||||
goto(
|
goto(
|
||||||
info.parentId === "root"
|
info!.parentId === "root"
|
||||||
? "/directory?from=file"
|
? "/directory?from=file"
|
||||||
: `/directory/${info.parentId}?from=file`,
|
: `/directory/${info!.parentId}?from=file`,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
{/key}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<FloatingButton
|
|
||||||
icon={IconAdd}
|
|
||||||
onclick={() => {
|
|
||||||
isEntryCreateBottomSheetOpen = true;
|
|
||||||
}}
|
|
||||||
class="bottom-24 right-4"
|
|
||||||
/>
|
|
||||||
<EntryCreateBottomSheet
|
|
||||||
bind:isOpen={isEntryCreateBottomSheetOpen}
|
|
||||||
onDirectoryCreateClick={() => {
|
|
||||||
isEntryCreateBottomSheetOpen = false;
|
|
||||||
isDirectoryCreateModalOpen = true;
|
|
||||||
}}
|
|
||||||
onFileUploadClick={() => {
|
|
||||||
isEntryCreateBottomSheetOpen = false;
|
|
||||||
fileInput?.click();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<DirectoryCreateModal
|
|
||||||
bind:isOpen={isDirectoryCreateModalOpen}
|
|
||||||
onCreateClick={async (name) => {
|
|
||||||
if (await requestDirectoryCreation(name, data.id, $masterKeyStore?.get(1)!)) {
|
|
||||||
infoPromise = getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<DuplicateFileModal
|
|
||||||
bind:isOpen={isDuplicateFileModalOpen}
|
|
||||||
file={duplicatedFile}
|
|
||||||
onbeforeclose={() => {
|
|
||||||
resolveForDuplicateFileModal?.(false);
|
|
||||||
isDuplicateFileModalOpen = false;
|
|
||||||
}}
|
|
||||||
onUploadClick={() => {
|
|
||||||
resolveForDuplicateFileModal?.(true);
|
|
||||||
isDuplicateFileModalOpen = false;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EntryMenuBottomSheet
|
|
||||||
bind:isOpen={isEntryMenuBottomSheetOpen}
|
|
||||||
onRenameClick={() => {
|
|
||||||
isEntryMenuBottomSheetOpen = false;
|
|
||||||
isEntryRenameModalOpen = true;
|
|
||||||
}}
|
|
||||||
onDeleteClick={() => {
|
|
||||||
isEntryMenuBottomSheetOpen = false;
|
|
||||||
isEntryDeleteModalOpen = true;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<EntryRenameModal
|
|
||||||
bind:isOpen={isEntryRenameModalOpen}
|
|
||||||
onRenameClick={async (newName: string) => {
|
|
||||||
if (await requestEntryRename(context.selectedEntry!, newName)) {
|
|
||||||
infoPromise = getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<EntryDeleteModal
|
|
||||||
bind:isOpen={isEntryDeleteModalOpen}
|
|
||||||
onDeleteClick={async () => {
|
|
||||||
if (await requestEntryDeletion(context.selectedEntry!)) {
|
|
||||||
infoPromise = getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
{/await}
|
</div>
|
||||||
|
|
||||||
|
<FloatingButton
|
||||||
|
icon={IconAdd}
|
||||||
|
onclick={() => {
|
||||||
|
isEntryCreateBottomSheetOpen = true;
|
||||||
|
}}
|
||||||
|
class="bottom-24 right-4"
|
||||||
|
/>
|
||||||
|
<EntryCreateBottomSheet
|
||||||
|
bind:isOpen={isEntryCreateBottomSheetOpen}
|
||||||
|
onDirectoryCreateClick={() => {
|
||||||
|
isEntryCreateBottomSheetOpen = false;
|
||||||
|
isDirectoryCreateModalOpen = true;
|
||||||
|
}}
|
||||||
|
onFileUploadClick={() => {
|
||||||
|
isEntryCreateBottomSheetOpen = false;
|
||||||
|
fileInput?.click();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<DirectoryCreateModal
|
||||||
|
bind:isOpen={isDirectoryCreateModalOpen}
|
||||||
|
onCreateClick={async (name) => {
|
||||||
|
if (await requestDirectoryCreation(name, data.id, $masterKeyStore?.get(1)!)) {
|
||||||
|
void getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<DuplicateFileModal
|
||||||
|
bind:isOpen={isDuplicateFileModalOpen}
|
||||||
|
file={duplicatedFile}
|
||||||
|
onbeforeclose={() => {
|
||||||
|
resolveForDuplicateFileModal?.(false);
|
||||||
|
isDuplicateFileModalOpen = false;
|
||||||
|
}}
|
||||||
|
onUploadClick={() => {
|
||||||
|
resolveForDuplicateFileModal?.(true);
|
||||||
|
isDuplicateFileModalOpen = false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<EntryMenuBottomSheet
|
||||||
|
bind:isOpen={isEntryMenuBottomSheetOpen}
|
||||||
|
onRenameClick={() => {
|
||||||
|
isEntryMenuBottomSheetOpen = false;
|
||||||
|
isEntryRenameModalOpen = true;
|
||||||
|
}}
|
||||||
|
onDeleteClick={() => {
|
||||||
|
isEntryMenuBottomSheetOpen = false;
|
||||||
|
isEntryDeleteModalOpen = true;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<EntryRenameModal
|
||||||
|
bind:isOpen={isEntryRenameModalOpen}
|
||||||
|
onRenameClick={async (newName: string) => {
|
||||||
|
if (await requestEntryRename(context.selectedEntry!, newName)) {
|
||||||
|
void getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<EntryDeleteModal
|
||||||
|
bind:isOpen={isEntryDeleteModalOpen}
|
||||||
|
onDeleteClick={async () => {
|
||||||
|
if (await requestEntryDeletion(context.selectedEntry!)) {
|
||||||
|
void getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from "$app/environment";
|
|
||||||
import { ActionEntryButton } from "$lib/components/atoms";
|
import { ActionEntryButton } from "$lib/components/atoms";
|
||||||
import { DirectoryEntryLabel } from "$lib/components/molecules";
|
import { DirectoryEntryLabel } from "$lib/components/molecules";
|
||||||
|
import { getFileThumbnail } from "$lib/modules/file";
|
||||||
import type { SummarizedFileInfo } from "$lib/modules/filesystem";
|
import type { SummarizedFileInfo } from "$lib/modules/filesystem";
|
||||||
import { requestFileThumbnailDownload } from "$lib/services/file";
|
|
||||||
import { formatDateTime } from "$lib/utils";
|
import { formatDateTime } from "$lib/utils";
|
||||||
import type { SelectedEntry } from "../service.svelte";
|
import type { SelectedEntry } from "../service.svelte";
|
||||||
|
|
||||||
@@ -17,12 +16,7 @@
|
|||||||
|
|
||||||
let { info, onclick, onOpenMenuClick }: Props = $props();
|
let { info, onclick, onOpenMenuClick }: Props = $props();
|
||||||
|
|
||||||
let showThumbnail = $derived(
|
let thumbnail = $derived(getFileThumbnail(info));
|
||||||
browser && (info.contentType.startsWith("image/") || info.contentType.startsWith("video/")),
|
|
||||||
);
|
|
||||||
let thumbnailPromise = $derived(
|
|
||||||
showThumbnail ? requestFileThumbnailDownload(info.id, info.dataKey?.key) : null,
|
|
||||||
);
|
|
||||||
|
|
||||||
const action = (callback: typeof onclick) => {
|
const action = (callback: typeof onclick) => {
|
||||||
callback({ type: "file", id: info.id, dataKey: info.dataKey, name: info.name });
|
callback({ type: "file", id: info.id, dataKey: info.dataKey, name: info.name });
|
||||||
@@ -35,18 +29,10 @@
|
|||||||
actionButtonIcon={IconMoreVert}
|
actionButtonIcon={IconMoreVert}
|
||||||
onActionButtonClick={() => action(onOpenMenuClick)}
|
onActionButtonClick={() => action(onOpenMenuClick)}
|
||||||
>
|
>
|
||||||
{#await thumbnailPromise}
|
<DirectoryEntryLabel
|
||||||
<DirectoryEntryLabel
|
type="file"
|
||||||
type="file"
|
thumbnail={$thumbnail}
|
||||||
name={info.name}
|
name={info.name}
|
||||||
subtext={formatDateTime(info.createdAt ?? info.lastModifiedAt)}
|
subtext={formatDateTime(info.createdAt ?? info.lastModifiedAt)}
|
||||||
/>
|
/>
|
||||||
{:then thumbnail}
|
|
||||||
<DirectoryEntryLabel
|
|
||||||
type="file"
|
|
||||||
thumbnail={thumbnail ?? undefined}
|
|
||||||
name={info.name}
|
|
||||||
subtext={formatDateTime(info.createdAt ?? info.lastModifiedAt)}
|
|
||||||
/>
|
|
||||||
{/await}
|
|
||||||
</ActionEntryButton>
|
</ActionEntryButton>
|
||||||
|
|||||||
@@ -20,7 +20,9 @@
|
|||||||
{state.name}
|
{state.name}
|
||||||
</p>
|
</p>
|
||||||
<p class="text-xs">
|
<p class="text-xs">
|
||||||
{#if state.status === "encryption-pending"}
|
{#if state.status === "queued"}
|
||||||
|
대기 중
|
||||||
|
{:else if state.status === "encryption-pending"}
|
||||||
준비 중
|
준비 중
|
||||||
{:else if state.status === "encrypting"}
|
{:else if state.status === "encrypting"}
|
||||||
암호화하는 중
|
암호화하는 중
|
||||||
|
|||||||
@@ -2,22 +2,13 @@
|
|||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import { EntryButton, FileThumbnailButton } from "$lib/components/atoms";
|
import { EntryButton, FileThumbnailButton } from "$lib/components/atoms";
|
||||||
import { bulkGetFileInfo, type MaybeFileInfo } from "$lib/modules/filesystem";
|
import { type SummarizedFileInfo } from "$lib/modules/filesystem";
|
||||||
import { masterKeyStore } from "$lib/stores";
|
|
||||||
import { requestFreshMediaFilesRetrieval } from "./service";
|
import { requestFreshMediaFilesRetrieval } from "./service";
|
||||||
|
|
||||||
let mediaFiles: MaybeFileInfo[] = $state([]);
|
let mediaFiles: SummarizedFileInfo[] = $state([]);
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const files = await requestFreshMediaFilesRetrieval();
|
mediaFiles = await requestFreshMediaFilesRetrieval();
|
||||||
mediaFiles = Array.from(
|
|
||||||
(
|
|
||||||
await bulkGetFileInfo(
|
|
||||||
files.map(({ id }) => id),
|
|
||||||
$masterKeyStore?.get(1)?.key!,
|
|
||||||
)
|
|
||||||
).values(),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -34,9 +25,7 @@
|
|||||||
{#if mediaFiles.length > 0}
|
{#if mediaFiles.length > 0}
|
||||||
<div class="grid grid-cols-4 gap-2 p-2">
|
<div class="grid grid-cols-4 gap-2 p-2">
|
||||||
{#each mediaFiles as file (file.id)}
|
{#each mediaFiles as file (file.id)}
|
||||||
{#if file.exists}
|
<FileThumbnailButton info={file} onclick={({ id }) => goto(`/file/${id}`)} />
|
||||||
<FileThumbnailButton info={file} onclick={({ id }) => goto(`/file/${id}`)} />
|
|
||||||
{/if}
|
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import type { RequestHandler } from "./$types";
|
|||||||
const trpcHandler: RequestHandler = (event) =>
|
const trpcHandler: RequestHandler = (event) =>
|
||||||
fetchRequestHandler({
|
fetchRequestHandler({
|
||||||
endpoint: "/api/trpc",
|
endpoint: "/api/trpc",
|
||||||
|
allowMethodOverride: true,
|
||||||
req: event.request,
|
req: event.request,
|
||||||
router: appRouter,
|
router: appRouter,
|
||||||
createContext: () => createContext(event),
|
createContext: () => createContext(event),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const createClient = (fetch: typeof globalThis.fetch) =>
|
|||||||
httpBatchLink({
|
httpBatchLink({
|
||||||
url: "/api/trpc",
|
url: "/api/trpc",
|
||||||
maxURLLength: 4096,
|
maxURLLength: 4096,
|
||||||
|
methodOverride: "POST",
|
||||||
transformer: superjson,
|
transformer: superjson,
|
||||||
fetch,
|
fetch,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const categoryRouter = router({
|
|||||||
})),
|
})),
|
||||||
files: files?.map((file) => ({
|
files: files?.map((file) => ({
|
||||||
id: file.id,
|
id: file.id,
|
||||||
|
parent: file.parentId,
|
||||||
mekVersion: file.mekVersion,
|
mekVersion: file.mekVersion,
|
||||||
dek: file.encDek,
|
dek: file.encDek,
|
||||||
dekVersion: file.dekVersion,
|
dekVersion: file.dekVersion,
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ const fileRouter = router({
|
|||||||
lastModifiedAtIv: file.encLastModifiedAt.iv,
|
lastModifiedAtIv: file.encLastModifiedAt.iv,
|
||||||
categories: categories.map((category) => ({
|
categories: categories.map((category) => ({
|
||||||
id: category.id,
|
id: category.id,
|
||||||
|
parent: category.parentId,
|
||||||
mekVersion: category.mekVersion,
|
mekVersion: category.mekVersion,
|
||||||
dek: category.encDek,
|
dek: category.encDek,
|
||||||
dekVersion: category.dekVersion,
|
dekVersion: category.dekVersion,
|
||||||
@@ -66,6 +67,7 @@ const fileRouter = router({
|
|||||||
lastModifiedAtIv: file.encLastModifiedAt.iv,
|
lastModifiedAtIv: file.encLastModifiedAt.iv,
|
||||||
categories: file.categories.map((category) => ({
|
categories: file.categories.map((category) => ({
|
||||||
id: category.id,
|
id: category.id,
|
||||||
|
parent: category.parentId,
|
||||||
mekVersion: category.mekVersion,
|
mekVersion: category.mekVersion,
|
||||||
dek: category.encDek,
|
dek: category.encDek,
|
||||||
dekVersion: category.dekVersion,
|
dekVersion: category.dekVersion,
|
||||||
|
|||||||
Reference in New Issue
Block a user