From f385ba3459da926adad635cbffc91880f5b05f7a Mon Sep 17 00:00:00 2001 From: Biplob Sutradhar Date: Fri, 11 Aug 2023 13:55:12 +0600 Subject: [PATCH] takeout read --- global.d.ts | 10 ++++ package-lock.json | 34 ++++++++++++- package.json | 2 + src/components/data/Zip_Reader.svelte | 71 +++++++++++++++++++++++++++ src/components/pages/Home.svelte | 19 +++++++ tsconfig.json | 3 +- 6 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 global.d.ts create mode 100644 src/components/data/Zip_Reader.svelte diff --git a/global.d.ts b/global.d.ts new file mode 100644 index 0000000..f01addd --- /dev/null +++ b/global.d.ts @@ -0,0 +1,10 @@ +// declaring module will allow typescript to import the module +declare module "csv-iter-parse" { + // typing module default export as `any` will allow you to access its members without compiler warning + type Apps = { + csv_async_iter: any; + }; + + const ts: Apps; + export = ts; +} diff --git a/package-lock.json b/package-lock.json index e2d01b7..031f7df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "youtube-subscriptions-transfer", - "version": "1.3", + "version": "1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "youtube-subscriptions-transfer", - "version": "1.3", + "version": "1.4", "devDependencies": { "@crxjs/vite-plugin": "2.0.0-beta.18", "@sveltejs/vite-plugin-svelte": "^2.4.2", @@ -14,9 +14,11 @@ "@tsconfig/svelte": "5.0.0", "@types/chrome": "0.0.239", "@types/node": "^20.4.0", + "async-zip-reader": "^0.1.0", "autoprefixer": "^10.4.14", "axios": "^1.4.0", "copy-text-to-clipboard": "^3.1.0", + "csv-iter-parse": "^0.0.4", "daisyui": "^3.1.7", "detect-browser": "^5.3.0", "pino": "^8.14.1", @@ -722,6 +724,22 @@ "dequal": "^2.0.3" } }, + "node_modules/async-zip-reader": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/async-zip-reader/-/async-zip-reader-0.1.0.tgz", + "integrity": "sha512-xrBHswYklwl/qxSe5x9U2L3LKQZmJGXk4dV9I0dg9bf9KpTFZpqg58ZYw1UzzyqBBuPzs3rw5k1q4EY3+Ny3XQ==", + "dev": true, + "dependencies": { + "binarin": "^0.2.1", + "pako": "^2.0.4" + } + }, + "node_modules/async-zip-reader/node_modules/pako": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==", + "dev": true + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -816,6 +834,12 @@ } ] }, + "node_modules/binarin": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/binarin/-/binarin-0.2.1.tgz", + "integrity": "sha512-KmCRupLittdaTUGLFd+h6sxEI1WMBnvqkS9nnixnGbHFfD4nb7J+q9EFtK/NbSrE3V0lb/2jubDt398qX9PUUQ==", + "dev": true + }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -1192,6 +1216,12 @@ "node": ">=4" } }, + "node_modules/csv-iter-parse": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/csv-iter-parse/-/csv-iter-parse-0.0.4.tgz", + "integrity": "sha512-cq3ySIyR6UNgna0AL5kHW1yci59HuWDLli/jujxr9XLEgk0Zqng5duF9QzC4mMMKnoa/PG4hZOYWJo/0vTHq1g==", + "dev": true + }, "node_modules/daisyui": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-3.2.1.tgz", diff --git a/package.json b/package.json index 7c2f7e6..6559746 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,11 @@ "@tsconfig/svelte": "5.0.0", "@types/chrome": "0.0.239", "@types/node": "^20.4.0", + "async-zip-reader": "^0.1.0", "autoprefixer": "^10.4.14", "axios": "^1.4.0", "copy-text-to-clipboard": "^3.1.0", + "csv-iter-parse": "^0.0.4", "daisyui": "^3.1.7", "detect-browser": "^5.3.0", "pino": "^8.14.1", diff --git a/src/components/data/Zip_Reader.svelte b/src/components/data/Zip_Reader.svelte new file mode 100644 index 0000000..9014024 --- /dev/null +++ b/src/components/data/Zip_Reader.svelte @@ -0,0 +1,71 @@ + + +
+
Takeout import
+
+ {#if isLoading} +
+
+
+ {/if} + +
+
diff --git a/src/components/pages/Home.svelte b/src/components/pages/Home.svelte index 8bbccf9..bbefba6 100644 --- a/src/components/pages/Home.svelte +++ b/src/components/pages/Home.svelte @@ -19,6 +19,7 @@ import copy from "copy-text-to-clipboard"; import Timer from "../Timer.svelte"; import { channelPathsSchema } from "src/utils/schema"; + import ZipReader from "../data/Zip_Reader.svelte"; let channelPaths: string[] = []; let xpathValues: XPathModel | undefined = undefined; @@ -369,6 +370,23 @@ }); } + function channelsIdsTakeoutSave(channelIDs: string[]) { + const toastId = toast.loading("Saving..."); + const l = channelsIdsParse(channelIDs); + if (l === undefined) { + toast.error("Save unsuccessful", { + id: toastId, + }); + return; + } + + channelPaths = l; + channelPathsWritable.set(l); + toast.success("Save successful", { + id: toastId, + }); + } + async function readySignalSend() { // Ready signal await runtime.send({ @@ -496,6 +514,7 @@ >Save +
diff --git a/tsconfig.json b/tsconfig.json index b72eb17..6dbae36 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,7 +25,8 @@ "src/**/*.ts", "src/**/*.js", "src/**/*.svelte", - "storage.ts" + "storage.ts", + "global.d.ts" ], "references": [{ "path": "./tsconfig.node.json" }] }