From 102ecd9b3e3baea115d11990b27fe76fa6fc85a6 Mon Sep 17 00:00:00 2001 From: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Date: Thu, 15 Sep 2022 12:52:24 -0700 Subject: [PATCH] Cleanup and refactoring (#60) * Use production infra * Move theme out of subdirectory * Remove unused example test * Separate webnative module into init and account * Move state off of module global state * Move utils out of common directory * Organize imports consistently * Replace last remaining Toast with a Notification * Rename theme to themeStore Renaming keeps the theme store naming consistent with the other stores. * Replace uuid helper with WebCrypto randomUUID * Enfore minimum node version at >=16.9 * Refactor delegate-account and link-device routes Use component views for consistency with the other routes * Use FilesystemActivity component in Register * Remove console logs * Add extractSearchParam Generalizes extracting a search param from a URL. * Hide app name in header on mobile * Remove deviceStore We weren't using it in the app. Mobile styles are handled with tailwind utility classes. * Add social preview image * Remove navigate event from AreYouSure component The event was unused. * Replace convertUint8ToString with uint8arrays * Add initializeFilesystem Separates out app-specific resource creation from the required registration code * Allow minor webnative version upgrades * Update package-lock.json --- .npmrc | 1 + package-lock.json | 187 ++++++++++++++++- package.json | 6 +- src/components/Header.svelte | 16 +- src/components/auth/backup/AreYouSure.svelte | 10 +- .../ConnectBackupDevice.svelte | 41 ++++ .../delegate-account/DelegateAccount.svelte | 64 ++++++ .../auth/link-device/LinkDevice.svelte | 48 +++++ .../auth/link/DelegateAccount.svelte | 196 ------------------ src/components/auth/link/LinkDevice.svelte | 106 ---------- src/components/auth/register/Register.svelte | 26 +-- src/components/auth/register/Welcome.svelte | 2 +- .../common/FilesystemActivity.svelte | 17 ++ .../gallery/imageGallery/ImageGallery.svelte | 1 + .../gallery/imageGallery/ImageModal.svelte | 3 +- src/components/gallery/upload/Dropzone.svelte | 6 +- .../notifications/Notification.svelte | 4 +- .../notifications/Notifications.svelte | 3 +- src/components/notifications/Toast.svelte | 37 ---- src/lib/app-info.ts | 1 + .../{common/webnative.ts => auth/account.ts} | 86 ++------ src/lib/common/example.test.ts | 5 - src/lib/common/utils.ts | 52 ----- src/lib/device.ts | 3 - src/lib/gallery.ts | 14 +- src/lib/init.ts | 61 ++++++ src/lib/notifications.ts | 3 +- src/lib/{theme/index.ts => theme.ts} | 0 src/lib/utils.ts | 35 ++++ src/lib/views.ts | 6 +- src/routes/__layout.svelte | 61 ++---- src/routes/backup.svelte | 13 +- src/routes/connect.svelte | 3 +- src/routes/delegate-account.svelte | 122 ++++++++++- src/routes/gallery.svelte | 7 +- src/routes/index.svelte | 2 +- src/routes/link-device.svelte | 59 +++++- src/stores.ts | 5 +- static/preview.png | Bin 0 -> 19476 bytes tailwind.config.cjs | 5 + 40 files changed, 720 insertions(+), 597 deletions(-) create mode 100644 .npmrc create mode 100644 src/components/auth/delegate-account/ConnectBackupDevice.svelte create mode 100644 src/components/auth/delegate-account/DelegateAccount.svelte create mode 100644 src/components/auth/link-device/LinkDevice.svelte delete mode 100644 src/components/auth/link/DelegateAccount.svelte delete mode 100644 src/components/auth/link/LinkDevice.svelte create mode 100644 src/components/common/FilesystemActivity.svelte delete mode 100644 src/components/notifications/Toast.svelte rename src/lib/{common/webnative.ts => auth/account.ts} (53%) delete mode 100644 src/lib/common/example.test.ts delete mode 100644 src/lib/common/utils.ts delete mode 100644 src/lib/device.ts create mode 100644 src/lib/init.ts rename src/lib/{theme/index.ts => theme.ts} (100%) create mode 100644 src/lib/utils.ts create mode 100644 static/preview.png diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..4fd0219 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +engine-strict=true \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 60c194a..fb6773a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "dependencies": { "clipboard-copy": "^4.0.1", "qrcode-svg": "^1.1.0", - "webnative": "0.34.1" + "uint8arrays": "^3.1.0", + "webnative": "^0.34.1" }, "devDependencies": { "@sveltejs/adapter-static": "1.0.0-next.36", @@ -37,6 +38,9 @@ "tslib": "^2.0.0", "typescript": "^4.4.4", "vite": "^3.0.0" + }, + "engines": { + "node": ">=16.9" } }, "node_modules/@babel/code-frame": { @@ -47,6 +51,100 @@ "@babel/highlight": "^7.10.4" } }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz", + "integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.18.6", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", @@ -3235,6 +3333,12 @@ "node": ">= 0.8" } }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, "node_modules/js-yaml": { "version": "3.14.1", "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", @@ -5712,6 +5816,81 @@ "@babel/highlight": "^7.10.4" } }, + "@babel/helper-validator-identifier": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz", + "integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==", + "dev": true + }, + "@babel/highlight": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.18.6", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "@cspotcode/source-map-support": { "version": "0.8.1", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", @@ -7996,6 +8175,12 @@ "integrity": "sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==", "dev": true }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, "js-yaml": { "version": "3.14.1", "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", diff --git a/package.json b/package.json index 082dc73..a60c38c 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,10 @@ "dependencies": { "clipboard-copy": "^4.0.1", "qrcode-svg": "^1.1.0", - "webnative": "0.34.1" + "uint8arrays": "^3.1.0", + "webnative": "^0.34.1" + }, + "engines": { + "node": ">=16.9" } } diff --git a/src/components/Header.svelte b/src/components/Header.svelte index 67c6365..5744bc6 100644 --- a/src/components/Header.svelte +++ b/src/components/Header.svelte @@ -1,16 +1,16 @@ @@ -18,7 +18,7 @@