@mduan/paseo-cli 0.11.0-fork.39 → 0.11.0-fork.40

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 (48) hide show
  1. package/node_modules/@getpaseo/client/dist/daemon-client.d.ts +9 -0
  2. package/node_modules/@getpaseo/client/dist/daemon-client.js +13 -0
  3. package/node_modules/@getpaseo/client/package.json +3 -3
  4. package/node_modules/@getpaseo/highlight/package.json +1 -1
  5. package/node_modules/@getpaseo/plugin/package.json +3 -3
  6. package/node_modules/@getpaseo/protocol/dist/generated/validation/ws-outbound.aot.js +6863 -6631
  7. package/node_modules/@getpaseo/protocol/dist/messages.d.ts +259 -0
  8. package/node_modules/@getpaseo/protocol/dist/messages.js +20 -0
  9. package/node_modules/@getpaseo/protocol/dist/validation/ws-outbound-schema-metadata.d.ts +56 -0
  10. package/node_modules/@getpaseo/protocol/package.json +1 -1
  11. package/node_modules/@getpaseo/relay/package.json +1 -1
  12. package/node_modules/@getpaseo/server/dist/server/builtin-plugins/package.json +1 -1
  13. package/node_modules/@getpaseo/server/dist/server/server/authorization/operation-permissions.js +2 -0
  14. package/node_modules/@getpaseo/server/dist/server/server/session/checkout/checkout-session.d.ts +2 -1
  15. package/node_modules/@getpaseo/server/dist/server/server/session/checkout/checkout-session.js +40 -2
  16. package/node_modules/@getpaseo/server/dist/server/server/session.js +2 -0
  17. package/node_modules/@getpaseo/server/dist/server/server/websocket-server.js +2 -0
  18. package/node_modules/@getpaseo/server/dist/server/utils/checkout-git.d.ts +15 -3
  19. package/node_modules/@getpaseo/server/dist/server/utils/checkout-git.js +149 -46
  20. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/{desktop-attachment-bridge-9f8115d584725a280c0334788152118e.js → desktop-attachment-bridge-033b357b5b3b822d4c1b8daa262768f7.js} +1 -1
  21. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-bridge-033b357b5b3b822d4c1b8daa262768f7.js.br +0 -0
  22. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-bridge-033b357b5b3b822d4c1b8daa262768f7.js.gz +0 -0
  23. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/{desktop-attachment-store-97325a18e4df847b34f0f393227301fb.js → desktop-attachment-store-458d14dda83d8704346c02725cc150e4.js} +1 -1
  24. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-store-458d14dda83d8704346c02725cc150e4.js.br +0 -0
  25. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-store-458d14dda83d8704346c02725cc150e4.js.gz +0 -0
  26. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/{index-741733179ad64039fff446da9e5b6f11.js → index-6d882b7db3a7114b61c60c86271607c6.js} +580 -585
  27. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/index-6d882b7db3a7114b61c60c86271607c6.js.br +0 -0
  28. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/{index-741733179ad64039fff446da9e5b6f11.js.gz → index-6d882b7db3a7114b61c60c86271607c6.js.gz} +0 -0
  29. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/{indexeddb-attachment-store-a7e99fce0fb2b70e580ec405b0818b22.js → indexeddb-attachment-store-a49382dd48253a14305777a72b6c5032.js} +1 -1
  30. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/indexeddb-attachment-store-a49382dd48253a14305777a72b6c5032.js.br +0 -0
  31. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/indexeddb-attachment-store-a49382dd48253a14305777a72b6c5032.js.gz +0 -0
  32. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/{native-file-attachment-store-4490341794e4b3a3274b82a322c6baa6.js → native-file-attachment-store-5a3f6f1479b4732de3f0e0d0d2e3e783.js} +3 -3
  33. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/native-file-attachment-store-5a3f6f1479b4732de3f0e0d0d2e3e783.js.br +0 -0
  34. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/native-file-attachment-store-5a3f6f1479b4732de3f0e0d0d2e3e783.js.gz +0 -0
  35. package/node_modules/@getpaseo/server/dist/server/web-ui/index.html +1 -1
  36. package/node_modules/@getpaseo/server/dist/server/web-ui/index.html.br +0 -0
  37. package/node_modules/@getpaseo/server/dist/server/web-ui/index.html.gz +0 -0
  38. package/node_modules/@getpaseo/server/package.json +6 -6
  39. package/package.json +7 -7
  40. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-bridge-9f8115d584725a280c0334788152118e.js.br +0 -0
  41. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-bridge-9f8115d584725a280c0334788152118e.js.gz +0 -0
  42. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-store-97325a18e4df847b34f0f393227301fb.js.br +0 -0
  43. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-store-97325a18e4df847b34f0f393227301fb.js.gz +0 -0
  44. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/index-741733179ad64039fff446da9e5b6f11.js.br +0 -0
  45. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/indexeddb-attachment-store-a7e99fce0fb2b70e580ec405b0818b22.js.br +0 -0
  46. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/indexeddb-attachment-store-a7e99fce0fb2b70e580ec405b0818b22.js.gz +0 -0
  47. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/native-file-attachment-store-4490341794e4b3a3274b82a322c6baa6.js.br +0 -0
  48. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/native-file-attachment-store-4490341794e4b3a3274b82a322c6baa6.js.gz +0 -0
@@ -420,9 +420,9 @@ export async function readDiffContextLines(input) {
420
420
  lineCount: input.lineCount,
421
421
  });
422
422
  }
423
- async function tryResolveMergeBase(cwd, baseRef) {
423
+ async function tryResolveMergeBase(cwd, baseRef, ref = "HEAD") {
424
424
  try {
425
- const { stdout } = await runGitCommand(["merge-base", baseRef, "HEAD"], {
425
+ const { stdout } = await runGitCommand(["merge-base", baseRef, ref], {
426
426
  cwd,
427
427
  envOverlay: READ_ONLY_GIT_ENV,
428
428
  });
@@ -506,9 +506,14 @@ async function getTrackedNumstatByPath(cwd, refs, ignoreWhitespace = false) {
506
506
  return stats;
507
507
  }
508
508
  async function getTrackedDiffTextForPath(input) {
509
+ const paths = input.oldPath ? [input.oldPath, input.path] : [input.path];
509
510
  const result = await runGitCommand(buildGitDiffArgs({
510
511
  ignoreWhitespace: input.ignoreWhitespace,
511
- extra: [...getCheckoutDiffRefArgs(input.refsForDiff), "--", `:(literal)${input.path}`],
512
+ extra: [
513
+ ...getCheckoutDiffRefArgs(input.refsForDiff),
514
+ "--",
515
+ ...paths.map((path) => `:(literal)${path}`),
516
+ ],
512
517
  }), {
513
518
  cwd: input.cwd,
514
519
  envOverlay: READ_ONLY_GIT_ENV,
@@ -1732,6 +1737,33 @@ function parseNumstatLine(line, stats) {
1732
1737
  }
1733
1738
  stats.set(path, { additions, deletions });
1734
1739
  }
1740
+ // Merges interleaved `--raw` (status) and `--numstat` (counts) lines by destination path.
1741
+ function parseCommitFiles(lines) {
1742
+ const stats = new Map();
1743
+ const statuses = new Map();
1744
+ for (const line of lines) {
1745
+ if (!line) {
1746
+ continue;
1747
+ }
1748
+ if (line.startsWith(":")) {
1749
+ parseRawStatusLine(line, statuses);
1750
+ }
1751
+ else {
1752
+ parseNumstatLine(line, stats);
1753
+ }
1754
+ }
1755
+ const files = [];
1756
+ for (const [path, stat] of stats) {
1757
+ const status = statuses.get(path);
1758
+ files.push({
1759
+ path,
1760
+ additions: stat.additions,
1761
+ deletions: stat.deletions,
1762
+ ...(status ? { status } : {}),
1763
+ });
1764
+ }
1765
+ return files;
1766
+ }
1735
1767
  // Parses the single combined `git log ... --raw --numstat -M` stream. Each record
1736
1768
  // (split on the record separator) starts with the NUL-field-separated header line,
1737
1769
  // then a blank line, then the interleaved `--raw` (status) and `--numstat` (counts)
@@ -1749,30 +1781,7 @@ function parseCheckoutCommitRecords(stdout) {
1749
1781
  if (!sha) {
1750
1782
  continue;
1751
1783
  }
1752
- const stats = new Map();
1753
- const statuses = new Map();
1754
- for (let index = 1; index < lines.length; index += 1) {
1755
- const line = lines[index] ?? "";
1756
- if (!line) {
1757
- continue;
1758
- }
1759
- if (line.startsWith(":")) {
1760
- parseRawStatusLine(line, statuses);
1761
- }
1762
- else {
1763
- parseNumstatLine(line, stats);
1764
- }
1765
- }
1766
- const files = [];
1767
- for (const [path, stat] of stats) {
1768
- const status = statuses.get(path);
1769
- files.push({
1770
- path,
1771
- additions: stat.additions,
1772
- deletions: stat.deletions,
1773
- ...(status ? { status } : {}),
1774
- });
1775
- }
1784
+ const files = parseCommitFiles(lines.slice(1));
1776
1785
  commits.push({
1777
1786
  sha,
1778
1787
  shortSha: (fields[1] ?? "").trim(),
@@ -1833,7 +1842,8 @@ async function tryResolveCheckoutCommitsBaseRef(cwd, baseRef, currentBranch) {
1833
1842
  return null;
1834
1843
  }
1835
1844
  }
1836
- export async function listCheckoutCommits({ cwd, context, }) {
1845
+ /** The base ref the checkout's own commits are listed and diffed against. */
1846
+ async function resolveCheckoutCommitsBaseRef(cwd, context) {
1837
1847
  // A detached HEAD still has commits ahead of its base; compare from HEAD itself.
1838
1848
  const currentBranch = (await getCurrentBranch(cwd)) ?? "HEAD";
1839
1849
  const { resolvedBaseRef } = await resolveBaseRefForCwd(cwd, context);
@@ -1843,13 +1853,80 @@ export async function listCheckoutCommits({ cwd, context, }) {
1843
1853
  // Saved worktree metadata can outlive a renamed or deleted base branch.
1844
1854
  comparisonBaseRef = await tryResolveCheckoutCommitsBaseRef(cwd, await resolveBaseRef(cwd), currentBranch);
1845
1855
  }
1856
+ return comparisonBaseRef;
1857
+ }
1858
+ /**
1859
+ * The old side of the diff of the commits from `fromSha` through `toSha`: the parent of
1860
+ * `fromSha`, plus the base branch changes that merges in the range brought in. Merging the base
1861
+ * branch into a branch is not the branch's own work, so it should not show up as changes.
1862
+ */
1863
+ async function resolveCommitRangeDiffBase(input) {
1864
+ const { cwd, toSha } = input;
1865
+ const parent = await tryResolveCommit(cwd, `${input.fromSha}^`);
1866
+ // A root commit has no parent, so its changes are against the empty tree.
1867
+ if (!parent)
1868
+ return EMPTY_TREE_OBJECT_ID;
1869
+ const git = (args) => runGitCommand(args, { cwd, envOverlay: READ_ONLY_GIT_ENV });
1870
+ const { stdout: merges } = await git([
1871
+ "rev-list",
1872
+ "--merges",
1873
+ "--max-count=1",
1874
+ `${parent}..${toSha}`,
1875
+ ]);
1876
+ if (!merges.trim())
1877
+ return parent;
1878
+ const baseRef = await input.resolveBaseRef();
1879
+ const mergedBase = baseRef ? await tryResolveMergeBase(cwd, baseRef, toSha) : null;
1880
+ // A commit already on the base branch keeps its first-parent diff.
1881
+ if (!mergedBase || mergedBase === toSha)
1882
+ return parent;
1883
+ try {
1884
+ const { stdout } = await git(["merge-tree", "--write-tree", parent, mergedBase]);
1885
+ return stdout.split("\n")[0]?.trim() || parent;
1886
+ }
1887
+ catch {
1888
+ // ponytail: a conflicting replay falls back to the plain range diff, base changes included.
1889
+ return parent;
1890
+ }
1891
+ }
1892
+ /** A workspace merge commit's own changes: conflict resolutions, not the branch it merged in. */
1893
+ async function listMergeCommitFiles(input) {
1894
+ const { cwd, sha, baseRef } = input;
1895
+ const base = await resolveCommitRangeDiffBase({
1896
+ cwd,
1897
+ fromSha: sha,
1898
+ toSha: sha,
1899
+ resolveBaseRef: async () => baseRef,
1900
+ });
1901
+ const { stdout } = await runGitCommand(["diff", "--raw", "--numstat", "-M", base, sha], {
1902
+ cwd,
1903
+ envOverlay: READ_ONLY_GIT_ENV,
1904
+ });
1905
+ return parseCommitFiles(stdout.split("\n"));
1906
+ }
1907
+ export async function listCheckoutCommits({ cwd, context, }) {
1908
+ const comparisonBaseRef = await resolveCheckoutCommitsBaseRef(cwd, context);
1846
1909
  let workspaceRecords = [];
1847
1910
  let baseRevision = "HEAD";
1848
1911
  if (comparisonBaseRef) {
1849
- const [records, mergeBase] = await Promise.all([
1912
+ const [records, mergeBase, merges] = await Promise.all([
1850
1913
  getCheckoutCommitRecords({ cwd, revision: `${comparisonBaseRef}..HEAD` }),
1851
1914
  tryResolveMergeBase(cwd, comparisonBaseRef),
1915
+ runGitCommand(["rev-list", "--merges", `${comparisonBaseRef}..HEAD`], {
1916
+ cwd,
1917
+ envOverlay: READ_ONLY_GIT_ENV,
1918
+ }),
1852
1919
  ]);
1920
+ const mergeShas = new Set(merges.stdout.split("\n").filter(Boolean));
1921
+ await Promise.all(records
1922
+ .filter((record) => mergeShas.has(record.sha))
1923
+ .map(async (record) => {
1924
+ record.files = await listMergeCommitFiles({
1925
+ cwd,
1926
+ sha: record.sha,
1927
+ baseRef: comparisonBaseRef,
1928
+ });
1929
+ }));
1853
1930
  workspaceRecords = records;
1854
1931
  baseRevision = mergeBase ?? "";
1855
1932
  }
@@ -1878,28 +1955,51 @@ export async function listCheckoutCommits({ cwd, context, }) {
1878
1955
  }));
1879
1956
  return { baseRef: comparisonBaseRef, commits };
1880
1957
  }
1958
+ /** The combined diff of the commits from `fromSha` through `toSha`, both included. */
1959
+ export async function getCommitRangeDiff(input) {
1960
+ const { cwd, fromSha, toSha } = input;
1961
+ const [from, targetRef] = await Promise.all([
1962
+ tryResolveCommit(cwd, fromSha),
1963
+ tryResolveCommit(cwd, toSha),
1964
+ ]);
1965
+ if (!from || !targetRef) {
1966
+ throw new Error(`Unknown commit range: ${fromSha}..${toSha}`);
1967
+ }
1968
+ const baseRef = await resolveCommitRangeDiffBase({
1969
+ cwd,
1970
+ fromSha: from,
1971
+ toSha: targetRef,
1972
+ resolveBaseRef: () => resolveCheckoutCommitsBaseRef(cwd, input.context),
1973
+ });
1974
+ const result = await getCheckoutDiff(cwd, {
1975
+ mode: "range",
1976
+ baseRef,
1977
+ targetRef,
1978
+ ignoreWhitespace: input.ignoreWhitespace,
1979
+ includeStructured: true,
1980
+ });
1981
+ return { ...result, baseRef, targetRef };
1982
+ }
1881
1983
  /**
1882
1984
  * Fetches the unified diff of a single file as introduced by one commit and
1883
1985
  * parses it into the same {@link ParsedDiffFile} shape the diff subscription
1884
1986
  * emits (so the client can reuse its existing renderer).
1885
1987
  *
1886
- * Compares merge commits to their first parent, matching the linear history shown
1887
- * in the explorer. The text is parsed and highlighted by
1988
+ * Compares a merge commit to its first parent plus the base branch changes it merged in, so
1989
+ * only the merge's own changes show. The text is parsed and highlighted by
1888
1990
  * {@link parseAndHighlightDiff} — the exact parser the diff subscription uses.
1889
1991
  * Returns `null` when the file is absent from the commit or the change is
1890
1992
  * binary-only (no textual hunks). Throws on git failure (e.g. an unknown sha),
1891
1993
  * which the caller maps to a typed checkout error.
1892
1994
  */
1893
- export async function getCommitFileDiff({ cwd, sha, path, }) {
1894
- const { stdout } = await runGitCommand([
1895
- "show",
1896
- sha,
1897
- "--format=",
1898
- "--diff-merges=first-parent",
1899
- ...STANDARD_DIFF_PREFIX_ARGS,
1900
- "--",
1901
- path,
1902
- ], {
1995
+ export async function getCommitFileDiff({ cwd, sha, path, context, }) {
1996
+ const base = await resolveCommitRangeDiffBase({
1997
+ cwd,
1998
+ fromSha: sha,
1999
+ toSha: sha,
2000
+ resolveBaseRef: () => resolveCheckoutCommitsBaseRef(cwd, context),
2001
+ });
2002
+ const { stdout } = await runGitCommand(["diff", base, sha, ...STANDARD_DIFF_PREFIX_ARGS, "--", path], {
1903
2003
  cwd,
1904
2004
  envOverlay: READ_ONLY_GIT_ENV,
1905
2005
  });
@@ -1908,7 +2008,7 @@ export async function getCommitFileDiff({ cwd, sha, path, }) {
1908
2008
  }
1909
2009
  const newContents = new Map();
1910
2010
  const parsedFiles = await parseAndHighlightDiff(stdout, cwd, {
1911
- getOldFileContent: (file) => readGitFileContentAtRef(cwd, `${sha}^`, file.path),
2011
+ getOldFileContent: (file) => readGitFileContentAtRef(cwd, base, file.path),
1912
2012
  getNewFileContent: async (file) => {
1913
2013
  const content = await readGitFileContentAtRef(cwd, sha, file.path);
1914
2014
  newContents.set(file.path, content);
@@ -2368,22 +2468,25 @@ async function processTrackedChanges(input) {
2368
2468
  }
2369
2469
  let trackedDiffText = "";
2370
2470
  let trackedDiffBytes = 0;
2371
- const renamedPaths = new Set(trackedChanges.filter((change) => change.oldPath).map((change) => change.path));
2471
+ const oldPathByPath = new Map(trackedChanges
2472
+ .filter((change) => change.oldPath)
2473
+ .map((change) => [change.path, change.oldPath]));
2372
2474
  for (let start = 0; start < trackedDiffPaths.length; start += TRACKED_DIFF_BATCH_SIZE) {
2373
2475
  const paths = trackedDiffPaths.slice(start, start + TRACKED_DIFF_BATCH_SIZE);
2374
- // Keep rename/copy path filtering identical to the existing per-file command.
2476
+ // Git needs both paths to recognize a rename instead of a whole-file addition.
2375
2477
  const ordinary = await getTrackedDiffTexts({
2376
2478
  cwd,
2377
2479
  refsForDiff,
2378
- paths: paths.filter((path) => !renamedPaths.has(path)),
2480
+ paths: paths.filter((path) => !oldPathByPath.has(path)),
2379
2481
  ignoreWhitespace,
2380
2482
  });
2381
2483
  const renamed = await Promise.all(paths
2382
- .filter((path) => renamedPaths.has(path))
2484
+ .filter((path) => oldPathByPath.has(path))
2383
2485
  .map((path) => getTrackedDiffTextForPath({
2384
2486
  cwd,
2385
2487
  refsForDiff,
2386
2488
  path,
2489
+ oldPath: oldPathByPath.get(path),
2387
2490
  ignoreWhitespace,
2388
2491
  })));
2389
2492
  const byPath = new Map([...ordinary, ...renamed].map((file) => [file.path, file]));
@@ -1 +1 @@
1
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createDesktopAttachmentBridge=function(){const l=(0,s.createDesktopPreviewUrlResolver)({reader:(0,s.createDesktopFileReader)(),objectUrls:(0,s.createBrowserObjectUrlMinter)()});return{copyFile:t.copyDesktopAttachmentFile,writeBase64:t.writeDesktopAttachmentBase64,writeBytes:t.writeDesktopAttachmentBytes,deleteFile:t.deleteDesktopAttachmentFile,garbageCollect:t.garbageCollectDesktopAttachmentFiles,readFileBase64:s.readDesktopFileBase64,resolvePreviewUrl:t=>l.resolve(t),releasePreviewUrl:t=>l.release(t)}};var t=r(d[0]),s=r(d[1])},5201,[4426,4427]);
1
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createDesktopAttachmentBridge=function(){const l=(0,s.createDesktopPreviewUrlResolver)({reader:(0,s.createDesktopFileReader)(),objectUrls:(0,s.createBrowserObjectUrlMinter)()});return{copyFile:t.copyDesktopAttachmentFile,writeBase64:t.writeDesktopAttachmentBase64,writeBytes:t.writeDesktopAttachmentBytes,deleteFile:t.deleteDesktopAttachmentFile,garbageCollect:t.garbageCollectDesktopAttachmentFiles,readFileBase64:s.readDesktopFileBase64,resolvePreviewUrl:t=>l.resolve(t),releasePreviewUrl:t=>l.release(t)}};var t=r(d[0]),s=r(d[1])},5196,[4426,4427]);
@@ -1 +1 @@
1
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createDesktopAttachmentStore=function(n){return{storageType:"desktop-file",async save(s){const o=s.id??(0,t.generateAttachmentId)(),l=s.fileName??null;if("file_uri"===s.source.kind)return await c(n,{id:o,uri:s.source.uri,mimeType:s.mimeType,fileName:l});if("data_url"===s.source.kind){const c=(0,t.parseDataUrl)(s.source.dataUrl),p=(0,t.normalizeMimeType)(s.mimeType??c.mimeType);return await y(n,{id:o,base64:c.base64,mimeType:p,fileName:l})}if("bytes"===s.source.kind){const c=(0,t.normalizeMimeType)(s.mimeType);return await p(n,{id:o,bytes:s.source.bytes,mimeType:c,fileName:l})}const f=(0,t.normalizeMimeType)(s.mimeType??s.source.blob.type),u=await(0,t.blobToBase64)(s.source.blob);return await y(n,{id:o,base64:u,mimeType:f,fileName:l})},encodeBase64:async({attachment:t})=>(f(t),await n.readFileBase64(t.storageKey)),resolvePreviewUrl:async({attachment:t})=>(f(t),await n.resolvePreviewUrl(t)),async releasePreviewUrl({attachment:t,url:s}){f(t),await n.releasePreviewUrl({url:s})},async delete({attachment:t}){f(t),await n.deleteFile({path:t.storageKey})},async garbageCollect({referencedIds:t}){await n.garbageCollect({referencedIds:Array.from(t)})}}};var t=r(d[0]);const n={"image/png":".png","image/jpeg":".jpg","image/jpg":".jpg","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/heic":".heic","image/heif":".heif","image/tiff":".tiff","image/bmp":".bmp","image/svg+xml":".svg"};function s(t){const n=t.replace(/\\/g,"/").split("/"),s=n[n.length-1];return s&&s.length>0?s:null}function o(s){const o=(0,t.getFileExtensionFromName)(s.fileName);if(o)return o;const l=(0,t.getFileExtensionFromName)(s.sourcePath);return l||(n[s.mimeType]??".img")}function l(t){return{id:t.id,mimeType:t.mimeType,storageType:"desktop-file",storageKey:t.storagePath,fileName:t.fileName??null,byteSize:t.byteSize,createdAt:Date.now()}}async function c(n,c){const y=(0,t.fileUriToPath)(c.uri),p=c.fileName??s(y),f=(0,t.normalizeMimeType)(c.mimeType),u=o({fileName:p,sourcePath:y,mimeType:f}),T=await n.copyFile({attachmentId:c.id,sourcePath:y,extension:u});return l({id:c.id,mimeType:f,storagePath:T.path,byteSize:T.byteSize,fileName:p})}async function y(t,n){const s=o({fileName:n.fileName,mimeType:n.mimeType}),c=await t.writeBase64({attachmentId:n.id,base64:n.base64,extension:s});return l({id:n.id,mimeType:n.mimeType,storagePath:c.path,byteSize:c.byteSize,fileName:n.fileName})}async function p(t,n){const s=o({fileName:n.fileName,mimeType:n.mimeType}),c=await t.writeBytes({attachmentId:n.id,bytes:n.bytes,extension:s});return l({id:n.id,mimeType:n.mimeType,storagePath:c.path,byteSize:c.byteSize,fileName:n.fileName})}function f(t){if("desktop-file"!==t.storageType)throw new Error(`Unsupported desktop attachment storage type '${t.storageType}'.`)}},5200,[4301]);
1
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createDesktopAttachmentStore=function(n){return{storageType:"desktop-file",async save(s){const o=s.id??(0,t.generateAttachmentId)(),l=s.fileName??null;if("file_uri"===s.source.kind)return await c(n,{id:o,uri:s.source.uri,mimeType:s.mimeType,fileName:l});if("data_url"===s.source.kind){const c=(0,t.parseDataUrl)(s.source.dataUrl),p=(0,t.normalizeMimeType)(s.mimeType??c.mimeType);return await y(n,{id:o,base64:c.base64,mimeType:p,fileName:l})}if("bytes"===s.source.kind){const c=(0,t.normalizeMimeType)(s.mimeType);return await p(n,{id:o,bytes:s.source.bytes,mimeType:c,fileName:l})}const f=(0,t.normalizeMimeType)(s.mimeType??s.source.blob.type),u=await(0,t.blobToBase64)(s.source.blob);return await y(n,{id:o,base64:u,mimeType:f,fileName:l})},encodeBase64:async({attachment:t})=>(f(t),await n.readFileBase64(t.storageKey)),resolvePreviewUrl:async({attachment:t})=>(f(t),await n.resolvePreviewUrl(t)),async releasePreviewUrl({attachment:t,url:s}){f(t),await n.releasePreviewUrl({url:s})},async delete({attachment:t}){f(t),await n.deleteFile({path:t.storageKey})},async garbageCollect({referencedIds:t}){await n.garbageCollect({referencedIds:Array.from(t)})}}};var t=r(d[0]);const n={"image/png":".png","image/jpeg":".jpg","image/jpg":".jpg","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/heic":".heic","image/heif":".heif","image/tiff":".tiff","image/bmp":".bmp","image/svg+xml":".svg"};function s(t){const n=t.replace(/\\/g,"/").split("/"),s=n[n.length-1];return s&&s.length>0?s:null}function o(s){const o=(0,t.getFileExtensionFromName)(s.fileName);if(o)return o;const l=(0,t.getFileExtensionFromName)(s.sourcePath);return l||(n[s.mimeType]??".img")}function l(t){return{id:t.id,mimeType:t.mimeType,storageType:"desktop-file",storageKey:t.storagePath,fileName:t.fileName??null,byteSize:t.byteSize,createdAt:Date.now()}}async function c(n,c){const y=(0,t.fileUriToPath)(c.uri),p=c.fileName??s(y),f=(0,t.normalizeMimeType)(c.mimeType),u=o({fileName:p,sourcePath:y,mimeType:f}),T=await n.copyFile({attachmentId:c.id,sourcePath:y,extension:u});return l({id:c.id,mimeType:f,storagePath:T.path,byteSize:T.byteSize,fileName:p})}async function y(t,n){const s=o({fileName:n.fileName,mimeType:n.mimeType}),c=await t.writeBase64({attachmentId:n.id,base64:n.base64,extension:s});return l({id:n.id,mimeType:n.mimeType,storagePath:c.path,byteSize:c.byteSize,fileName:n.fileName})}async function p(t,n){const s=o({fileName:n.fileName,mimeType:n.mimeType}),c=await t.writeBytes({attachmentId:n.id,bytes:n.bytes,extension:s});return l({id:n.id,mimeType:n.mimeType,storagePath:c.path,byteSize:c.byteSize,fileName:n.fileName})}function f(t){if("desktop-file"!==t.storageType)throw new Error(`Unsupported desktop attachment storage type '${t.storageType}'.`)}},5195,[4301]);