From 1fe74ecaa4976f1fb9f13d43f24f2b4163451e06 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Fri, 29 Mar 2024 10:56:30 +0000 Subject: [PATCH] [chore] Bump browser-fs-access. (#3277) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR bumps browser-fs-access to the latest version. ### Change Type - [ ] `sdk` — Changes the tldraw SDK - [ ] `dotcom` — Changes the tldraw.com web app - [ ] `docs` — Changes to the documentation, examples, or templates. - [ ] `vs code` — Changes to the vscode plugin - [x] `internal` — Does not affect user-facing stuff - [ ] `bugfix` — Bug fix - [ ] `feature` — New feature - [ ] `improvement` — Improving existing features - [x] `chore` — Updating dependencies, other boring stuff - [ ] `galaxy brain` — Architectural changes - [ ] `tests` — Changes to any test code - [ ] `tools` — Changes to infrastructure, CI, internal scripts, debugging tools, etc. - [ ] `dunno` — I don't know --- apps/dotcom/package.json | 2 +- apps/dotcom/src/utils/useFileSystem.tsx | 43 +++++++++++++------------ yarn.lock | 10 +++--- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/apps/dotcom/package.json b/apps/dotcom/package.json index cbeb0d7c6..bf5700284 100644 --- a/apps/dotcom/package.json +++ b/apps/dotcom/package.json @@ -26,7 +26,7 @@ "@tldraw/tlsync": "workspace:*", "@tldraw/utils": "workspace:*", "@vercel/analytics": "^1.1.1", - "browser-fs-access": "^0.33.0", + "browser-fs-access": "^0.35.0", "idb": "^7.1.1", "nanoid": "4.0.2", "qrcode": "^1.5.1", diff --git a/apps/dotcom/src/utils/useFileSystem.tsx b/apps/dotcom/src/utils/useFileSystem.tsx index c328bb138..c76e1934d 100644 --- a/apps/dotcom/src/utils/useFileSystem.tsx +++ b/apps/dotcom/src/utils/useFileSystem.tsx @@ -108,33 +108,34 @@ export function getSaveFileCopyAction( readonlyOk: true, kbd: '$s', async onSelect(source) { - handleUiEvent('save-project-to-file', { source }) - const documentName = - editor.getDocumentSettings().name === '' - ? defaultDocumentName - : editor.getDocumentSettings().name - const defaultName = - saveFileNames.get(editor.store) || `${documentName}${TLDRAW_FILE_EXTENSION}` - - const blobToSave = serializeTldrawJsonBlob(editor.store) - let handle try { - handle = await fileSave(blobToSave, { + handleUiEvent('save-project-to-file', { source }) + const documentName = + editor.getDocumentSettings().name === '' + ? defaultDocumentName + : editor.getDocumentSettings().name + const defaultName = + saveFileNames.get(editor.store) || `${documentName}${TLDRAW_FILE_EXTENSION}` + + const blobToSave = serializeTldrawJsonBlob(editor.store) + + const handle = await fileSave(blobToSave, { fileName: defaultName, extensions: [TLDRAW_FILE_EXTENSION], description: 'tldraw project', }) - } catch (e) { - // user cancelled - return - } - if (handle) { - // we deliberately don't store the handle for re-use - // next time. we always want to save a copy, but to - // help the user out we'll remember the last name - // they used - saveFileNames.set(editor.store, handle.name) + if (handle) { + // we deliberately don't store the handle for re-use + // next time. we always want to save a copy, but to + // help the user out we'll remember the last name + // they used + saveFileNames.set(editor.store, handle.name) + } else { + throw Error('Could not save file.') + } + } catch (e) { + console.error(e) } }, } diff --git a/yarn.lock b/yarn.lock index c81a8d937..ebb35ebfd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10043,10 +10043,10 @@ __metadata: languageName: node linkType: hard -"browser-fs-access@npm:^0.33.0": - version: 0.33.1 - resolution: "browser-fs-access@npm:0.33.1" - checksum: 1843c6d1190ed448d3f17e767cd6508ef408b0e40530ceb2de37088f0a1bdbd503e05d4d949934d7c9491d550e255c4a214b25781625b57a6724a35a7cdd8b4c +"browser-fs-access@npm:^0.35.0": + version: 0.35.0 + resolution: "browser-fs-access@npm:0.35.0" + checksum: 5fa9876cc10499bfc8e1a3d83261f8966c5687c2d31c1abefed35ecc5a8e1ab8b12a51aed638b48ee4e2109ec48c2cba3bfcd162b9de270a5b5ca08740024eda languageName: node linkType: hard @@ -11688,7 +11688,7 @@ __metadata: "@typescript-eslint/utils": "npm:^5.59.0" "@vercel/analytics": "npm:^1.1.1" "@vitejs/plugin-react-swc": "npm:^3.5.0" - browser-fs-access: "npm:^0.33.0" + browser-fs-access: "npm:^0.35.0" dotenv: "npm:^16.3.1" eslint: "npm:^8.37.0" fast-glob: "npm:^3.3.1"