most-box 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/README.md +15 -14
  2. package/electron/main.js +1 -1
  3. package/out/admin/index.html +0 -0
  4. package/out/app/index.html +0 -0
  5. package/out/assets/AccountMenu-D36x3rKH.js +1 -0
  6. package/out/assets/AppTop-qtp-3wqv.js +1 -0
  7. package/out/assets/CopyButton-C00LHzxo.js +1 -0
  8. package/out/assets/FilePreviewOverlay-BvOCftIV.js +1 -0
  9. package/out/assets/{MarketingHeader-7B-OT2XX.js → MarketingHeader-D7AjEmWU.js} +1 -1
  10. package/out/assets/MarketingLayout-BVw4vr-u.js +1 -0
  11. package/out/assets/{MilkdownEditor-WedhCoFH.js → MilkdownEditor-DXVbZsH_.js} +92 -92
  12. package/out/assets/OpenSidebarButton-DI6Ld8um.js +1 -0
  13. package/out/assets/arrow-right-CXzRt0Fp.js +1 -0
  14. package/out/assets/arrow-up-down-B-677ip8.js +1 -0
  15. package/out/assets/chatJoinInvite-aCHhLrlm.js +1 -0
  16. package/out/assets/chatNoteDraft-CYbvcEvC.js +1 -0
  17. package/out/assets/check-iBCQl0yr.js +1 -0
  18. package/out/assets/chevron-right-D75NRNNs.js +1 -0
  19. package/out/assets/circle-alert-dfN4T6Nq.js +1 -0
  20. package/out/assets/cobol-DHLQUbN7.js +1 -0
  21. package/out/assets/copy-B7pPZ2MP.js +1 -0
  22. package/out/assets/{dist-DCX0ws1K.js → dist-1jNICPWO.js} +1 -1
  23. package/out/assets/{dist-BAJKKN4w.js → dist-B3unnv5t.js} +1 -1
  24. package/out/assets/{dist-DJdv-Ma3.js → dist-B5MBMmGa.js} +1 -1
  25. package/out/assets/{dist-CMmmtl3f.js → dist-BAqJdUtV.js} +1 -1
  26. package/out/assets/{dist-C3lbe8SW.js → dist-BBJOmVU3.js} +1 -1
  27. package/out/assets/{dist-IN8WN7NI.js → dist-BV5CqsJD.js} +1 -1
  28. package/out/assets/{dist-DBnWo8ZP.js → dist-Ba7fxbV-.js} +1 -1
  29. package/out/assets/{dist-BzqqCPi2.js → dist-BxxtNKuo.js} +1 -1
  30. package/out/assets/{dist-DvWZsW-D.js → dist-C8Ue2rSs.js} +1 -1
  31. package/out/assets/{dist-C-Tg23jc.js → dist-CIn7Xx5U.js} +1 -1
  32. package/out/assets/{dist-CbTzBiwL.js → dist-CSyRxrry.js} +3 -3
  33. package/out/assets/{dist-DTL5jL08.js → dist-CZIuQqmV.js} +1 -1
  34. package/out/assets/{dist-8QDHqrPN.js → dist-CaaBTHCc.js} +1 -1
  35. package/out/assets/{dist-yZ96GF-e.js → dist-CgReC0ZE.js} +1 -1
  36. package/out/assets/{dist-D94V9Zlh.js → dist-Ct90qYA2.js} +1 -1
  37. package/out/assets/{dist-IGpXmkFm.js → dist-DIFFjNuO.js} +1 -1
  38. package/out/assets/{dist-CqQavSZV.js → dist-DUB2IhWu.js} +1 -1
  39. package/out/assets/{dist-B0JrbG7f.js → dist-DheA_Tyz.js} +1 -1
  40. package/out/assets/{dist-Br_5lLVO.js → dist-DyZh1ncm.js} +1 -1
  41. package/out/assets/{dist-BPs0Xns9.js → dist-E74uGTy3.js} +1 -1
  42. package/out/assets/{dist-BFSyuOuw.js → dist-K2s-Uj08.js} +1 -1
  43. package/out/assets/{dist-zyJb88Zz.js → dist-RU_cpjXQ.js} +1 -1
  44. package/out/assets/{dist-chOCTzB2.js → dist-eIeCvp_6.js} +1 -1
  45. package/out/assets/{dist-CfU9fwWz.js → dist-hEE2Ub__.js} +1 -1
  46. package/out/assets/download-COQOcPqI.js +1 -0
  47. package/out/assets/downloadValidation-UPgpJbKz.js +1 -0
  48. package/out/assets/external-link-D6tHlYgS.js +1 -0
  49. package/out/assets/file-text-DiyIGL1I.js +1 -0
  50. package/out/assets/folder-BS_GbpPQ.js +1 -0
  51. package/out/assets/hard-drive-Cqa7Rstj.js +1 -0
  52. package/out/assets/index-CUzbruyP.js +31 -0
  53. package/out/assets/index-FV6RZlVI.css +1 -0
  54. package/out/assets/index.lazy-08bEbzIk.js +1 -0
  55. package/out/assets/index.lazy-6b-8jxXI.js +1 -0
  56. package/out/assets/index.lazy-B4pxVFWK.js +2 -0
  57. package/out/assets/index.lazy-Bi5KZylP.js +5 -0
  58. package/out/assets/index.lazy-CJnFeoy4.js +1 -0
  59. package/out/assets/index.lazy-CRV2-Y6z.js +3 -0
  60. package/out/assets/index.lazy-CzCHV559.js +1 -0
  61. package/out/assets/index.lazy-DrfZ9XTR.js +1 -0
  62. package/out/assets/index.lazy-DuvCRtpm.js +1 -0
  63. package/out/assets/index.lazy-DxOIgf3c.js +1 -0
  64. package/out/assets/index.lazy-FNVWBYth.js +1 -0
  65. package/out/assets/index.lazy-Itk05ouU.js +1 -0
  66. package/out/assets/index.lazy-_CazgyO7.js +1 -0
  67. package/out/assets/index.lazy-odd8ydDw.js +3 -0
  68. package/out/assets/key-round-JR8M3aHl.js +1 -0
  69. package/out/assets/loader-CwyHYZdX.js +1 -0
  70. package/out/assets/lock-CuwwlXlx.js +1 -0
  71. package/out/assets/message-square-BgsNXPft.js +1 -0
  72. package/out/assets/mp-Dv12gDTx.js +1 -0
  73. package/out/assets/music-Dn9nm9Qb.js +1 -0
  74. package/out/assets/notebook-pen-BzrCXQJE.js +1 -0
  75. package/out/assets/play-CvWKSMwY.js +1 -0
  76. package/out/assets/refresh-cw-D4BsHvhi.js +1 -0
  77. package/out/assets/save-B02sbO9Y.js +1 -0
  78. package/out/assets/scheme-tChLYBuY.js +1 -0
  79. package/out/assets/search-HW4oPOBP.js +1 -0
  80. package/out/assets/send-4dhnJGuS.js +1 -0
  81. package/out/assets/shield-check-Boae7Nc6.js +1 -0
  82. package/out/assets/smartphone-JXH-zQXB.js +1 -0
  83. package/out/assets/textile-CyzeGT9J.js +1 -0
  84. package/out/assets/trash-2-BLwoM0ME.js +1 -0
  85. package/out/assets/triangle-alert-B9sMiA9l.js +1 -0
  86. package/out/assets/upload-DVuXJt_o.js +1 -0
  87. package/out/assets/useAppStore-DOnk608w.js +4 -0
  88. package/out/assets/{useChannelMessages-Bs_RWgO4.js → useChannelMessages-CDvw-f_x.js} +1 -1
  89. package/out/assets/useGameRoom-CATo4XWU.js +1 -0
  90. package/out/assets/userProfile-BZvkCuet.js +1 -0
  91. package/out/assets/wallet-D9Iw4YWE.js +1 -0
  92. package/out/assets/wifi-ljEI_ySA.js +1 -0
  93. package/out/chat/index.html +0 -0
  94. package/out/chat/join/demo/index.html +0 -0
  95. package/out/chat/join/index.html +0 -0
  96. package/out/download/index.html +2 -2
  97. package/out/game/gandengyan/index.html +0 -0
  98. package/out/game/index.html +0 -0
  99. package/out/game/zhajinhua/index.html +0 -0
  100. package/out/index.html +2 -2
  101. package/out/note/index.html +0 -0
  102. package/out/ping/index.html +2 -2
  103. package/out/profile/index.html +0 -0
  104. package/out/web3/index.html +0 -0
  105. package/package.json +30 -26
  106. package/server/index.js +3 -0
  107. package/server/src/config.js +0 -1
  108. package/server/src/core/channelAttachment.js +2 -2
  109. package/server/src/core/gameRoom.js +12 -19
  110. package/server/src/http/routes/noteVaultRoutes.js +70 -0
  111. package/server/src/index.js +17 -8
  112. package/server/src/utils/accountBackup.js +8 -0
  113. package/server/src/utils/api.js +0 -14
  114. package/server/src/utils/auth.js +0 -7
  115. package/server/src/utils/avatar.js +6 -6
  116. package/server/src/utils/noteVault.js +197 -2
  117. package/out/assets/AccountMenu-NjOgag0d.js +0 -1
  118. package/out/assets/FilePreviewOverlay-CZp6F1s_.js +0 -1
  119. package/out/assets/MarketingLayout-CyiSCygk.js +0 -1
  120. package/out/assets/OpenSidebarButton-BoSmO8CY.js +0 -1
  121. package/out/assets/SidebarHomeLink-CkhGDvZ8.js +0 -1
  122. package/out/assets/arrow-right-DUxAoZqb.js +0 -1
  123. package/out/assets/avatar-BZwHW4ll.js +0 -4
  124. package/out/assets/circle-alert-DSZ0bG_3.js +0 -1
  125. package/out/assets/cobol-B_OZ4V-R.js +0 -1
  126. package/out/assets/copy-CK7HMulu.js +0 -1
  127. package/out/assets/download-Q1uCiwif.js +0 -1
  128. package/out/assets/downloadValidation-Ch966YTl.js +0 -1
  129. package/out/assets/external-link-DGzNJOqQ.js +0 -1
  130. package/out/assets/file-text-C3v0L_lQ.js +0 -1
  131. package/out/assets/folder-CwtLO09O.js +0 -1
  132. package/out/assets/hard-drive-B2V5USzR.js +0 -1
  133. package/out/assets/i18n-DZaOYCSO.js +0 -1
  134. package/out/assets/index-CBkHUp3F.css +0 -1
  135. package/out/assets/index-DluhgSHX.js +0 -31
  136. package/out/assets/index.lazy-B5TYRvFJ.js +0 -1
  137. package/out/assets/index.lazy-BeDctVci.js +0 -1
  138. package/out/assets/index.lazy-BjmAkVtV.js +0 -1
  139. package/out/assets/index.lazy-CHJbzlK6.js +0 -1
  140. package/out/assets/index.lazy-CITrkWMQ.js +0 -1
  141. package/out/assets/index.lazy-CTGE5fUt.js +0 -2
  142. package/out/assets/index.lazy-CUxcXUMy.js +0 -2
  143. package/out/assets/index.lazy-D84xQtPb.js +0 -3
  144. package/out/assets/index.lazy-DRqAgqpV.js +0 -1
  145. package/out/assets/index.lazy-DSAmY1q_.js +0 -1
  146. package/out/assets/index.lazy-DvbVQRSL.js +0 -1
  147. package/out/assets/index.lazy-gAJi-rJV.js +0 -1
  148. package/out/assets/index.lazy-rzyMd-Gz.js +0 -1
  149. package/out/assets/key-round-Dn5tud-4.js +0 -1
  150. package/out/assets/loader-CLoDCtNy.js +0 -1
  151. package/out/assets/lock-BEWKuIqK.js +0 -1
  152. package/out/assets/message-square-C8ZiYztG.js +0 -1
  153. package/out/assets/mp-CGBtY36n.js +0 -1
  154. package/out/assets/music-BsTA8b_M.js +0 -1
  155. package/out/assets/notebook-pen-DgWzxf2y.js +0 -1
  156. package/out/assets/play-CVkbAJJU.js +0 -1
  157. package/out/assets/plus-D1kCYb8G.js +0 -1
  158. package/out/assets/save-X5c7jlCg.js +0 -1
  159. package/out/assets/scheme-CyDdOh7e.js +0 -1
  160. package/out/assets/search-DAV9vDOq.js +0 -1
  161. package/out/assets/send-C5JjYo-A.js +0 -1
  162. package/out/assets/shield-check-DuD6OLde.js +0 -1
  163. package/out/assets/smartphone-gVFruyjO.js +0 -1
  164. package/out/assets/textile-DWBqthVk.js +0 -1
  165. package/out/assets/trash-2-CE-3Dc63.js +0 -1
  166. package/out/assets/triangle-alert-DnOxsFpB.js +0 -1
  167. package/out/assets/upload-CsnBv3pd.js +0 -1
  168. package/out/assets/useGameRoom-BxDxm3rp.js +0 -1
  169. package/out/assets/userProfile-UphvP_bG.js +0 -1
  170. package/out/assets/wallet-VDaoXwjI.js +0 -1
  171. package/out/assets/wifi-DfWbmlGE.js +0 -1
@@ -2,7 +2,7 @@ import crypto from 'node:crypto'
2
2
  import fs from 'node:fs/promises'
3
3
  import fsSync from 'node:fs'
4
4
  import path from 'node:path'
5
- import { PathSecurityError, ValidationError } from './errors.js'
5
+ import { ConflictError, PathSecurityError, ValidationError } from './errors.js'
6
6
 
7
7
  const CONFIG_FILE_NAME = 'note-vault.json'
8
8
  const MARKDOWN_EXTENSION = '.md'
@@ -37,6 +37,19 @@ async function pathExists(filePath) {
37
37
  }
38
38
  }
39
39
 
40
+ async function removeEmptyParentDirectories(vaultRealPath, startPath) {
41
+ let currentPath = startPath
42
+
43
+ while (isPathInside(vaultRealPath, currentPath) && currentPath !== vaultRealPath) {
44
+ try {
45
+ await fs.rmdir(currentPath)
46
+ } catch {
47
+ return
48
+ }
49
+ currentPath = path.dirname(currentPath)
50
+ }
51
+ }
52
+
40
53
  async function getVaultDirectoryInfo(vaultPath, options = {}) {
41
54
  const rawPath = String(vaultPath || '').trim()
42
55
  if (!rawPath) {
@@ -277,7 +290,7 @@ export async function readMarkdownFile(vaultPath, relativePath) {
277
290
  }
278
291
  }
279
292
 
280
- export async function writeMarkdownFile(vaultPath, relativePath, content) {
293
+ async function getWritableMarkdownTarget(vaultPath, relativePath) {
281
294
  const info = await getVaultDirectoryInfo(vaultPath, { requireWritable: true })
282
295
  const normalizedPath = normalizeNoteVaultRelativePath(relativePath)
283
296
  const targetPath = path.resolve(info.realPath, toNativePath(normalizedPath))
@@ -308,6 +321,22 @@ export async function writeMarkdownFile(vaultPath, relativePath, content) {
308
321
  }
309
322
  }
310
323
 
324
+ return { info, normalizedPath, targetPath, parentPath }
325
+ }
326
+
327
+ export async function createMarkdownFile(vaultPath, relativePath, content) {
328
+ const { info, normalizedPath, targetPath } =
329
+ await getWritableMarkdownTarget(vaultPath, relativePath)
330
+ if (await pathExists(targetPath)) {
331
+ throw new ConflictError('note vault file already exists')
332
+ }
333
+ return writeMarkdownFile(info.realPath, normalizedPath, content)
334
+ }
335
+
336
+ export async function writeMarkdownFile(vaultPath, relativePath, content) {
337
+ const { info, normalizedPath, targetPath, parentPath } =
338
+ await getWritableMarkdownTarget(vaultPath, relativePath)
339
+
311
340
  const tempPath = path.join(
312
341
  parentPath,
313
342
  `.${path.basename(targetPath)}.${process.pid}.${Date.now()}.${crypto
@@ -325,3 +354,169 @@ export async function writeMarkdownFile(vaultPath, relativePath, content) {
325
354
 
326
355
  return readMarkdownFile(info.realPath, normalizedPath)
327
356
  }
357
+
358
+ export async function moveMarkdownFile(
359
+ vaultPath,
360
+ fromRelativePath,
361
+ toRelativePath
362
+ ) {
363
+ const info = await getVaultDirectoryInfo(vaultPath, { requireWritable: true })
364
+ const fromPath = normalizeNoteVaultRelativePath(fromRelativePath)
365
+ const toPath = normalizeNoteVaultRelativePath(toRelativePath)
366
+ if (fromPath === toPath) return readMarkdownFile(info.realPath, fromPath)
367
+
368
+ const sourcePath = path.resolve(info.realPath, toNativePath(fromPath))
369
+ const targetPath = path.resolve(info.realPath, toNativePath(toPath))
370
+ const targetParentPath = path.dirname(targetPath)
371
+
372
+ let sourceStat
373
+ try {
374
+ sourceStat = await fs.lstat(sourcePath)
375
+ } catch {
376
+ throw new ValidationError(
377
+ 'note vault file not found',
378
+ 'NOTE_VAULT_FILE_NOT_FOUND'
379
+ )
380
+ }
381
+
382
+ if (sourceStat.isSymbolicLink()) {
383
+ throw new PathSecurityError('Symlink Markdown files are not writable')
384
+ }
385
+ if (!sourceStat.isFile()) {
386
+ throw new ValidationError(
387
+ 'note vault path is not a file',
388
+ 'NOTE_VAULT_NOT_FILE'
389
+ )
390
+ }
391
+
392
+ const realSourcePath = await fs.realpath(sourcePath)
393
+ if (!isPathInside(info.realPath, realSourcePath)) {
394
+ throw new PathSecurityError('Note vault file escapes the configured vault')
395
+ }
396
+
397
+ if (await pathExists(targetPath)) {
398
+ throw new ConflictError('note vault target already exists')
399
+ }
400
+
401
+ await fs.mkdir(targetParentPath, { recursive: true })
402
+ const realTargetParentPath = await fs.realpath(targetParentPath)
403
+ if (!isPathInside(info.realPath, realTargetParentPath)) {
404
+ throw new PathSecurityError('Note vault file escapes the configured vault')
405
+ }
406
+
407
+ await fs.rename(realSourcePath, targetPath)
408
+ await removeEmptyParentDirectories(info.realPath, path.dirname(realSourcePath))
409
+ return readMarkdownFile(info.realPath, toPath)
410
+ }
411
+
412
+ export async function deleteMarkdownFile(vaultPath, relativePath) {
413
+ const info = await getVaultDirectoryInfo(vaultPath, { requireWritable: true })
414
+ const normalizedPath = normalizeNoteVaultRelativePath(relativePath)
415
+ const targetPath = path.resolve(info.realPath, toNativePath(normalizedPath))
416
+
417
+ let stat
418
+ try {
419
+ stat = await fs.lstat(targetPath)
420
+ } catch {
421
+ throw new ValidationError(
422
+ 'note vault file not found',
423
+ 'NOTE_VAULT_FILE_NOT_FOUND'
424
+ )
425
+ }
426
+
427
+ if (stat.isSymbolicLink()) {
428
+ throw new PathSecurityError('Symlink Markdown files are not writable')
429
+ }
430
+ if (!stat.isFile()) {
431
+ throw new ValidationError(
432
+ 'note vault path is not a file',
433
+ 'NOTE_VAULT_NOT_FILE'
434
+ )
435
+ }
436
+
437
+ const realFilePath = await fs.realpath(targetPath)
438
+ if (!isPathInside(info.realPath, realFilePath)) {
439
+ throw new PathSecurityError('Note vault file escapes the configured vault')
440
+ }
441
+
442
+ await fs.unlink(realFilePath)
443
+ await removeEmptyParentDirectories(info.realPath, path.dirname(realFilePath))
444
+ return { path: normalizedPath, deleted: true }
445
+ }
446
+
447
+ export async function createNoteVaultSnapshot(vaultPath) {
448
+ const files = await listMarkdownFiles(vaultPath)
449
+ const snapshotFiles = []
450
+
451
+ for (const file of files) {
452
+ const content = await readMarkdownFile(vaultPath, file.path)
453
+ snapshotFiles.push({
454
+ path: content.path,
455
+ content: content.content,
456
+ size: content.size,
457
+ mtimeMs: content.mtimeMs,
458
+ })
459
+ }
460
+
461
+ return { files: snapshotFiles }
462
+ }
463
+
464
+ function normalizeSnapshotFiles(input) {
465
+ const files = Array.isArray(input?.files) ? input.files : []
466
+ const byPath = new Map()
467
+
468
+ for (const file of files) {
469
+ if (!file || typeof file !== 'object') continue
470
+ const normalizedPath = normalizeNoteVaultRelativePath(file.path)
471
+ byPath.set(normalizedPath, {
472
+ path: normalizedPath,
473
+ content: String(file.content ?? ''),
474
+ })
475
+ }
476
+
477
+ return [...byPath.values()].sort((left, right) =>
478
+ left.path.localeCompare(right.path)
479
+ )
480
+ }
481
+
482
+ export async function restoreNoteVaultSnapshot(vaultPath, snapshotInput) {
483
+ const info = await getVaultDirectoryInfo(vaultPath, { requireWritable: true })
484
+ const snapshotFiles = normalizeSnapshotFiles(snapshotInput)
485
+ const snapshotPaths = new Set(snapshotFiles.map(file => file.path))
486
+ const currentFiles = await listMarkdownFiles(info.realPath)
487
+ const result = {
488
+ created: 0,
489
+ updated: 0,
490
+ deleted: 0,
491
+ skipped: 0,
492
+ files: snapshotFiles.length,
493
+ }
494
+
495
+ for (const currentFile of currentFiles) {
496
+ if (snapshotPaths.has(currentFile.path)) continue
497
+ await deleteMarkdownFile(info.realPath, currentFile.path)
498
+ result.deleted += 1
499
+ }
500
+
501
+ for (const snapshotFile of snapshotFiles) {
502
+ let existing = null
503
+ try {
504
+ existing = await readMarkdownFile(info.realPath, snapshotFile.path)
505
+ } catch {}
506
+
507
+ if (existing?.content === snapshotFile.content) {
508
+ result.skipped += 1
509
+ continue
510
+ }
511
+
512
+ await writeMarkdownFile(
513
+ info.realPath,
514
+ snapshotFile.path,
515
+ snapshotFile.content
516
+ )
517
+ if (existing) result.updated += 1
518
+ else result.created += 1
519
+ }
520
+
521
+ return result
522
+ }
@@ -1 +0,0 @@
1
- import{t as e}from"./jsx-runtime-Bt-cYkS5.js";import{$ as t,R as n,f as r,n as i,o as a,rt as o}from"./avatar-BZwHW4ll.js";import{a as s,c,o as l}from"./i18n-DZaOYCSO.js";var u=t(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),d=t(`languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),f=t(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),p=t(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),m=t(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),h=e();function g(){let{locale:e,setLocale:t,t:n}=s(),r=n(`common.locale.choose`);return(0,h.jsx)(a,{ariaLabel:r,className:`language-toggle`,items:l.map(n=>({key:n,label:c[n],icon:n===e?(0,h.jsx)(u,{size:16}):(0,h.jsx)(`span`,{className:`language-toggle-placeholder`,"aria-hidden":`true`}),onSelect:()=>{n!==e&&t(n)}})),renderTrigger:e=>(0,h.jsx)(`button`,{...e,className:`header-tool-btn`,title:r,"aria-label":r,children:(0,h.jsx)(d,{size:16})})})}function _(){let{t:e}=s(),t=r(e=>e.isDarkMode),n=r(e=>e.setIsDarkMode),i=e(`common.theme.toggle`);return(0,h.jsx)(`button`,{type:`button`,className:`header-tool-btn`,title:i,"aria-label":i,"aria-pressed":t,onClick:()=>n(!t),children:t?(0,h.jsx)(p,{size:16}):(0,h.jsx)(f,{size:16})})}function v(){let{t:e}=s(),t=n(e=>e.identity),r=i(t?.address,t?.avatar),a=e(`nav.profile`);return(0,h.jsx)(o,{to:`/profile/`,className:`account-profile-link`,title:a,"aria-label":a,children:t?(0,h.jsx)(`img`,{className:`account-profile-link-avatar`,src:r,alt:``,"aria-hidden":`true`}):(0,h.jsx)(m,{size:18})})}export{u as a,m as i,_ as n,g as r,v as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,Q as i,y as a}from"./avatar-BZwHW4ll.js";import{a as o}from"./i18n-DZaOYCSO.js";import{t as s}from"./file-text-C3v0L_lQ.js";import{t as c}from"./loader-CLoDCtNy.js";import{t as l}from"./music-BsTA8b_M.js";var u=r(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),d=r(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),f=r(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]);function p(e){let t=String(e||``).split(`.`).pop()?.toLowerCase()||``,n=[`jpg`,`jpeg`,`png`,`gif`,`webp`,`svg`,`bmp`,`ico`,`tiff`,`heic`,`heif`],r=[`mp4`,`webm`,`mov`,`avi`,`mkv`,`flv`,`wmv`,`m4v`,`mpeg`,`3gp`],i=[`mp3`,`wav`,`ogg`,`flac`,`aac`,`m4a`,`wma`,`opus`],a=`txt.md.js.ts.jsx.tsx.css.scss.less.json.xml.html.htm.yaml.yml.toml.ini.cfg.conf.log.sh.bash.py.rb.go.rs.java.c.cpp.h.hpp.cs.php.sql.graphql.env.gitignore.dockerfile.readme`.split(`.`);return n.includes(t)?`image`:r.includes(t)?`video`:i.includes(t)?`audio`:a.includes(t)?`text`:`file`}var m=t(e(),1),h=n();function g(e){return e===`image`||e===`video`||e===`audio`}function _({item:e,isBackendReady:t,getFileDownloadUrl:n,onClose:r}){let{t:u}=o(),[d,f]=(0,m.useState)(``),[p,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(``);return(0,m.useEffect)(()=>{if(e.subtype!==`text`)return;let r=!1;if(f(``),x(``),!t){f(u(`preview.loadFailed`));return}return _(!0),(async()=>{try{let t=await fetch(n(e.cid),{headers:{...await a(`GET`,`/api/files/${e.cid}/download`),Range:`bytes=0-9999`}});if(!t.ok)throw Error(u(`preview.loadFailed`));let i=await t.text();r||f(i||u(`preview.emptyFile`))}catch{r||f(u(`preview.loadFailed`))}finally{r||_(!1)}})(),()=>{r=!0}},[n,t,e.cid,e.subtype]),(0,m.useEffect)(()=>{if(!g(e.subtype)){y(``);return}if(y(``),x(``),!t){x(u(`preview.loadFailed`));return}let r=``,i=!1;return(async()=>{try{let t=await fetch(n(e.cid),{headers:await a(`GET`,`/api/files/${e.cid}/download`)});if(!t.ok)throw Error(u(`preview.loadFailed`));let o=URL.createObjectURL(await t.blob());r=o,i||y(o)}catch{i||x(u(`preview.loadFailed`))}})(),()=>{i=!0,r&&URL.revokeObjectURL(r)}},[n,t,e.cid,e.subtype]),(0,h.jsxs)(`div`,{className:`preview-overlay`,onClick:r,children:[(0,h.jsx)(`button`,{type:`button`,className:`preview-close`,onClick:r,"aria-label":u(`preview.close`),children:(0,h.jsx)(i,{size:20})}),(0,h.jsxs)(`div`,{onClick:e=>e.stopPropagation(),children:[e.subtype===`image`&&(0,h.jsx)(`div`,{className:`preview-media-wrapper`,children:v?(0,h.jsx)(`img`,{src:v,alt:e.fileName,translate:`no`}):b?(0,h.jsxs)(`div`,{className:`preview-unsupported`,children:[(0,h.jsx)(s,{size:48,className:`preview-file-icon`}),(0,h.jsx)(`p`,{translate:`no`,children:e.fileName}),(0,h.jsx)(`p`,{className:`preview-unsupported-hint`,children:b})]}):(0,h.jsx)(`div`,{className:`preview-loading`,children:(0,h.jsx)(`div`,{className:`preview-loading-spinner`})})}),e.subtype===`video`&&(0,h.jsx)(`div`,{className:`preview-media-wrapper`,children:v?(0,h.jsx)(`video`,{src:v,controls:!0}):b?(0,h.jsxs)(`div`,{className:`preview-unsupported`,children:[(0,h.jsx)(s,{size:48,className:`preview-file-icon`}),(0,h.jsx)(`p`,{translate:`no`,children:e.fileName}),(0,h.jsx)(`p`,{className:`preview-unsupported-hint`,children:b})]}):(0,h.jsx)(`div`,{className:`preview-loading`,children:(0,h.jsx)(`div`,{className:`preview-loading-spinner`})})}),e.subtype===`audio`&&(0,h.jsxs)(`div`,{className:`preview-audio`,children:[(0,h.jsx)(`div`,{className:`preview-audio-icon`,children:(0,h.jsx)(l,{size:36,color:`var(--accent)`})}),(0,h.jsx)(`p`,{className:`preview-audio-filename`,translate:`no`,children:e.fileName}),v?(0,h.jsx)(`audio`,{className:`preview-audio-player`,src:v,controls:!0}):(0,h.jsx)(`div`,{className:`preview-text-loading`,children:b?(0,h.jsx)(`p`,{children:b}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(c,{size:24,className:`preview-text-spinner`}),(0,h.jsx)(`p`,{children:u(`preview.audioLoading`)})]})})]}),e.subtype===`file`&&(0,h.jsxs)(`div`,{className:`preview-unsupported`,children:[(0,h.jsx)(s,{size:48,className:`preview-file-icon`}),(0,h.jsx)(`p`,{translate:`no`,children:e.fileName}),(0,h.jsx)(`p`,{className:`preview-unsupported-hint`,children:u(`preview.unsupported`)})]}),e.subtype===`text`&&(0,h.jsxs)(`div`,{className:`preview-text-container`,children:[(0,h.jsx)(`div`,{className:`preview-text-header`,children:(0,h.jsx)(`span`,{translate:`no`,children:e.fileName})}),p?(0,h.jsxs)(`div`,{className:`preview-text-loading`,children:[(0,h.jsx)(c,{size:24,className:`preview-text-spinner`}),(0,h.jsx)(`p`,{children:u(`preview.textLoading`)}),(0,h.jsx)(`p`,{className:`preview-text-loading-hint`,children:u(`preview.firstSyncHint`)})]}):(0,h.jsx)(`pre`,{className:`preview-text`,translate:`no`,children:d||u(`preview.emptyFile`)})]})]})]})}export{u as a,d as i,p as n,f as r,_ as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./jsx-runtime-Bt-cYkS5.js";import{d as t,rt as n}from"./avatar-BZwHW4ll.js";import{a as r}from"./i18n-DZaOYCSO.js";import{n as i,r as a,t as o}from"./AccountMenu-NjOgag0d.js";import{t as s}from"./download-Q1uCiwif.js";import"./index-DluhgSHX.js";import{t as c}from"./LogoIcon-B2fFe0l1.js";var l={name:`most-box`,version:`0.3.1`,description:`MostBox - P2P file sharing application`,type:`module`,main:`electron/main.js`,bin:{"most-box":`server/cli.js`},files:[`out`,`public`,`electron`,`server/src`,`server/index.js`,`server/cli.js`],scripts:{start:`vite`,server:`node --watch server/index.js`,desktop:`npm run electron:dev`,build:`vite build && node scripts/prepare-start-static.mjs`,preview:`vite preview`,serve:`npm run build && node server/index.js`,test:`node --test server/tests/**/*.test.js`,"test:unit":`node --test server/tests/unit/*.test.js`,"test:desktop":`node --test electron/*.test.js`,"test:frontend":`node --test src/tests/*.test.js`,"test:protocol":`node --test --test-name-pattern "extracts CID and filename|matches golden CID samples|publishes a file from Buffer|lists published files|pulls through local seed nodes" server/tests/unit/cid.test.js server/tests/integration/cid.test.js server/tests/integration/engine.test.js`,typecheck:`tsc -p tsconfig.typecheck.json`,"typecheck:strict-router":`tsc -p tsconfig.strict-router.json`,"check:static-output":`node scripts/check-static-output.mjs`,format:`npx prettier --write .`,lint:`npx eslint .`,"r2:cors":`node scripts/configure-r2-cors.mjs`,"electron:dev":`concurrently "npm run build" "wait-on out/index.html && electron ."`,"electron:rebuild":`electron-rebuild -f -w sodium-native`,"electron:build":`npm run build && npm run electron:rebuild && electron-builder`,"electron:build:win":`npm run build && npm run electron:rebuild && electron-builder --win`,"electron:build:win:x64":`npm run electron:build:win -- --x64`,"electron:build:win:arm64":`npm run electron:build:win -- --arm64`,"electron:build:mac":`npm run build && npm run electron:rebuild && electron-builder --mac`,"electron:build:linux":`npm run build && npm run electron:rebuild && electron-builder --linux`},keywords:[`p2p`,`file-sharing`,`hyperswarm`,`hyperdrive`],license:`MIT`,dependencies:{"@dicebear/collection":`^9.4.2`,"@dicebear/core":`^9.4.2`,"@hono/node-server":`^2.0.4`,"@tanstack/react-router":`^1.170.15`,"@tanstack/react-start":`^1.168.25`,b4a:`^1.8.1`,busboy:`^1.6.0`,corestore:`^7.10.0`,dayjs:`^1.11.21`,ethers:`^6.16.0`,eventemitter3:`^5.0.4`,hono:`^4.12.23`,hypercore:`^11.33.1`,hyperdrive:`^13.3.2`,hyperswarm:`^4.17.0`,"ipfs-unixfs-importer":`^17.0.1`,multiformats:`^14.0.0`,tweetnacl:`^1.0.3`,ws:`^8.21.0`},devDependencies:{"@electron/rebuild":`^4.0.4`,"@eslint/js":`^10.0.1`,"@iconify/react":`^6.0.2`,"@mantine/hooks":`^9.3.0`,"@milkdown/crepe":`^7.21.2`,"@milkdown/utils":`^7.21.2`,"@types/react":`^19.2.16`,"@vitejs/plugin-react":`^6.0.2`,concurrently:`^10.0.3`,electron:`^42.3.3`,"electron-builder":`^26.8.1`,esbuild:`^0.28.0`,eslint:`^10.4.1`,globals:`^17.6.0`,ky:`^2.0.2`,"lucide-react":`^1.17.0`,prettier:`^3.8.3`,"qrcode.react":`^4.2.0`,react:`^19.2.7`,"react-dom":`^19.2.7`,typescript:`6.0.3`,"typescript-eslint":`^8.60.1`,vite:`^8.0.16`,"wait-on":`^9.0.10`,zustand:`^5.0.14`},overrides:{"brace-expansion":`5.0.6`,postcss:`8.5.15`,ws:`$ws`},build:{appId:`com.mostbox.app`,productName:`MostBox`,publish:[{provider:`github`,releaseType:`release`}],directories:{output:`dist`},afterPack:`electron/afterPack.cjs`,files:[`out/**/*`,`electron/**/*`,`server/src/**/*`,`server/index.js`,`server/cli.js`,`package.json`,`!**/*.map`,`!electron/**/*.test.js`,`!server/tests/**/*`],asarUnpack:[`**/*.node`,`**/sodium-native/**`],protocols:[{name:`MostBox Link`,schemes:[`most`]}],win:{target:[`nsis`],artifactName:"${productName}-${version}-win-${arch}-setup.${ext}",icon:`public/logo.ico`},nsis:{oneClick:!1,allowToChangeInstallationDirectory:!0,createDesktopShortcut:!0,createStartMenuShortcut:!0,shortcutName:`MostBox`},mac:{artifactName:"${productName}-${version}-mac-${arch}.${ext}",target:[{target:`dmg`,arch:[`x64`,`arm64`]}],icon:`public/logo-512.png`,category:`public.app-category.utilities`},dmg:{contents:[{x:130,y:220},{x:410,y:220,type:`link`,path:`/Applications`}]},linux:{artifactName:"${productName}-${version}-linux-${arch}.${ext}",target:[{target:`AppImage`,arch:[`x64`,`arm64`]}],icon:`public/logo-512.png`,category:`Utility`}}},u=e(),d=[{to:`/`,labelKey:`footer.about`},{to:`/ping/`,labelKey:`footer.network`},{href:`https://github.com/most-people/most`,labelKey:null,label:`GitHub`,external:!0}],f=l.version;function p(){let{t:e}=r();return(0,u.jsx)(`footer`,{className:`mkt-footer`,children:(0,u.jsx)(`div`,{className:`mkt-container`,children:(0,u.jsxs)(`div`,{className:`mkt-footer-inner`,children:[(0,u.jsx)(`div`,{className:`mkt-footer-links`,children:d.map(t=>`external`in t?(0,u.jsx)(`a`,{href:t.href,target:`_blank`,rel:`noopener noreferrer`,children:t.label},t.href):(0,u.jsx)(n,{to:t.to,children:e(t.labelKey)},t.to))}),(0,u.jsxs)(`span`,{className:`mkt-footer-copy`,children:[`© `,new Date().getFullYear(),` MOST PEOPLE · MIT License`]}),(0,u.jsxs)(`span`,{className:`mkt-footer-build`,translate:`no`,children:[`v`,f]})]})})})}function m({children:e,header:t}){return(0,u.jsxs)(`div`,{className:`mkt-layout`,children:[t??(0,u.jsx)(h,{}),(0,u.jsx)(`main`,{className:`mkt-layout-main`,children:e}),(0,u.jsx)(p,{})]})}function h(){let{t:e}=r(),l=t();return(0,u.jsx)(`nav`,{className:`mkt-nav`,children:(0,u.jsxs)(`div`,{className:`mkt-nav-inner`,children:[(0,u.jsxs)(n,{to:`/`,className:`mkt-nav-logo`,children:[(0,u.jsx)(c,{}),`MOST PEOPLE`]}),(0,u.jsxs)(`div`,{className:`mkt-nav-cta`,children:[(0,u.jsx)(i,{}),(0,u.jsx)(a,{}),!l&&(0,u.jsxs)(n,{to:`/download/`,className:`btn btn-primary mkt-nav-preview`,children:[(0,u.jsx)(s,{size:16}),e(`nav.downloadClient`)]}),(0,u.jsx)(o,{})]})]})})}export{m as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./jsx-runtime-Bt-cYkS5.js";import{$ as t}from"./avatar-BZwHW4ll.js";import{a as n}from"./i18n-DZaOYCSO.js";import{r}from"./SidebarHomeLink-CkhGDvZ8.js";var i=t(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),a=e();function o({label:e,className:t=``,variant:o=`primary`}){let{isSidebarVisible:s,openSidebar:c}=r(),{t:l}=n(),u=o===`primary`?`btn-primary`:``,d=e||l(`appShell.openSidebar`);return s?null:(0,a.jsxs)(`button`,{type:`button`,className:`btn ${u} sidebar-open-hint ${t}`.trim(),onClick:c,children:[(0,a.jsx)(i,{size:16}),d]})}export{o as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{$ as r,rt as i}from"./avatar-BZwHW4ll.js";import{a}from"./i18n-DZaOYCSO.js";import{n as o,r as s,t as c}from"./AccountMenu-NjOgag0d.js";import{c as l}from"./index-DluhgSHX.js";var u=r(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),d=t(e(),1);function f(e,t){return typeof t==`boolean`?t:typeof window<`u`&&`matchMedia`in window?window.matchMedia(e).matches:!1}function p(e,t,{getInitialValueInEffect:n}={getInitialValueInEffect:!0}){let[r,i]=(0,d.useState)(n?t:f(e));return(0,d.useEffect)(()=>{try{if(`matchMedia`in window){let t=window.matchMedia(e);i(t.matches);let n=e=>i(e.matches);return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}}}catch{return}},[e]),r||!1}function m(e=!1,t={}){let[n,r]=(0,d.useState)(e),i=(0,d.useCallback)(()=>{r(e=>e||(t.onOpen?.(),!0))},[t.onOpen]),a=(0,d.useCallback)(()=>{r(e=>e&&(t.onClose?.(),!1))},[t.onClose]);return[n,{open:i,close:a,toggle:(0,d.useCallback)(()=>{n?a():i()},[a,i,n]),set:r}]}var h=n(),g=(0,d.createContext)(null);function _(){let e=(0,d.useContext)(g);if(!e)throw Error(`useAppShell must be used within AppShell`);return e}function v({sidebar:e,className:t=``,headerTitle:n,headerRight:r,sidebarToggleReplacement:i,defaultHide:l=!1,children:f}){let[_,v]=m(!1),[y,b]=(0,d.useState)(l),x=(0,d.useRef)(l),S=p(`(max-width: 768px)`),{t:C}=a(),w=(0,d.useCallback)((e={})=>{v.close(),e.collapse&&b(!0)},[v]);(0,d.useEffect)(()=>{l!==x.current&&(l?w({collapse:!0}):b(!1),x.current=l)},[l,w]);let T=()=>{S?v.toggle():b(!y)},E=()=>{S?v.open():b(!1)},D=S?_:!y;return(0,h.jsx)(g.Provider,{value:{closeSidebar:w,openSidebar:E,isSidebarVisible:D},children:(0,h.jsxs)(`div`,{className:[`app-layout`,t].filter(Boolean).join(` `),children:[(0,h.jsx)(`div`,{className:`sidebar-overlay ${_?`visible`:``}`,onClick:()=>w()}),(0,h.jsx)(`div`,{className:`sidebar ${_?`open`:``} ${y?`collapsed`:``}`,children:e({closeSidebar:w,openSidebar:E})}),(0,h.jsxs)(`div`,{className:`main-content`,children:[(0,h.jsxs)(`header`,{className:`app-header`,children:[(0,h.jsxs)(`div`,{className:`header-left`,children:[i??(0,h.jsx)(`button`,{onClick:T,className:`btn btn-icon sidebar-toggle-btn`,"aria-label":C(S?`appShell.openMenu`:y?`appShell.expandSidebar`:`appShell.collapseSidebar`),children:(0,h.jsx)(u,{size:16})}),n]}),(0,h.jsxs)(`div`,{className:`header-right`,children:[r,(0,h.jsx)(o,{}),(0,h.jsx)(s,{}),(0,h.jsx)(c,{})]})]}),f]})]})})}function y({onNavigate:e}){let{t}=a(),n=t(`common.brand`);return(0,h.jsxs)(i,{to:`/`,className:`sidebar-header sidebar-header-link`,onClick:e,"aria-label":n,title:n,children:[(0,h.jsx)(l,{size:18}),(0,h.jsx)(`h1`,{children:n})]})}export{m as i,v as n,_ as r,y as t};
@@ -1 +0,0 @@
1
- import{$ as e}from"./avatar-BZwHW4ll.js";var t=e(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]);export{t};