Flipper export file implementation
Summary: ^ Changelog: add export file implementation for browsers Reviewed By: antonk52 Differential Revision: D46840341 fbshipit-source-id: 8a011f2a7c0ce329286cb8813def8f9c0572d133
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f0ccad9bb3
commit
daa3a38ed3
@@ -10,9 +10,11 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": "https://github.com/facebook/flipper/issues",
|
"bugs": "https://github.com/facebook/flipper/issues",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"file-saver": "^2.0.5",
|
||||||
"reconnecting-websocket": "^4.4.0"
|
"reconnecting-websocket": "^4.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/file-saver": "^2.0.5",
|
||||||
"eventemitter3": "^4.0.7",
|
"eventemitter3": "^4.0.7",
|
||||||
"flipper-common": "0.0.0",
|
"flipper-common": "0.0.0",
|
||||||
"flipper-frontend-core": "0.0.0",
|
"flipper-frontend-core": "0.0.0",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
wrapRequire,
|
wrapRequire,
|
||||||
} from 'flipper-common';
|
} from 'flipper-common';
|
||||||
import type {RenderHost} from 'flipper-ui-core';
|
import type {RenderHost} from 'flipper-ui-core';
|
||||||
|
import FileSaver from 'file-saver';
|
||||||
|
|
||||||
declare module globalThis {
|
declare module globalThis {
|
||||||
let require: any;
|
let require: any;
|
||||||
@@ -44,11 +45,22 @@ export function initializeRenderHost(
|
|||||||
async importFile() {
|
async importFile() {
|
||||||
throw new Error('Not implemented');
|
throw new Error('Not implemented');
|
||||||
},
|
},
|
||||||
async exportFile() {
|
async exportFile(data: string, {defaultPath}: {defaultPath?: string}) {
|
||||||
throw new Error('Not implemented');
|
const file = new File([data], defaultPath ?? 'unknown', {
|
||||||
|
type: 'text/plain;charset=utf-8',
|
||||||
|
});
|
||||||
|
FileSaver.saveAs(file);
|
||||||
|
return defaultPath;
|
||||||
},
|
},
|
||||||
async exportFileBinary() {
|
async exportFileBinary(
|
||||||
throw new Error('Not implemented');
|
data: Uint8Array,
|
||||||
|
{defaultPath}: {defaultPath?: string},
|
||||||
|
) {
|
||||||
|
const file = new File([data], defaultPath ?? 'unknown', {
|
||||||
|
type: 'application/octet-stream',
|
||||||
|
});
|
||||||
|
FileSaver.saveAs(file);
|
||||||
|
return defaultPath;
|
||||||
},
|
},
|
||||||
openLink(url: string) {
|
openLink(url: string) {
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
|
|||||||
@@ -707,7 +707,7 @@ export async function exportEverythingEverywhereAllAtOnce(
|
|||||||
const exportedFilePath = await getRenderHostInstance().exportFileBinary?.(
|
const exportedFilePath = await getRenderHostInstance().exportFileBinary?.(
|
||||||
archiveData,
|
archiveData,
|
||||||
{
|
{
|
||||||
defaultPath: 'flipper_EEAaO_export',
|
defaultPath: 'flipper_EEAaO_export.zip',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -3956,6 +3956,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/fb-watchman/-/fb-watchman-2.0.1.tgz#4f44c7b7ac98463488765d41d269272dd34cb815"
|
resolved "https://registry.yarnpkg.com/@types/fb-watchman/-/fb-watchman-2.0.1.tgz#4f44c7b7ac98463488765d41d269272dd34cb815"
|
||||||
integrity sha512-iJ7/e6drSmuCzAp96/dpksm8YjxbhhyXWV6m1HPbRHvZwUOUZ5vZvZIAUJxKDtI0UpdNfDvLPiai0MTJmmS+HA==
|
integrity sha512-iJ7/e6drSmuCzAp96/dpksm8YjxbhhyXWV6m1HPbRHvZwUOUZ5vZvZIAUJxKDtI0UpdNfDvLPiai0MTJmmS+HA==
|
||||||
|
|
||||||
|
"@types/file-saver@^2.0.5":
|
||||||
|
version "2.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/file-saver/-/file-saver-2.0.5.tgz#9ee342a5d1314bb0928375424a2f162f97c310c7"
|
||||||
|
integrity sha512-zv9kNf3keYegP5oThGLaPk8E081DFDuwfqjtiTzm6PoxChdJ1raSuADf2YGCVIyrSynLrgc8JWv296s7Q7pQSQ==
|
||||||
|
|
||||||
"@types/fs-extra@^9.0.11", "@types/fs-extra@^9.0.12", "@types/fs-extra@^9.0.13":
|
"@types/fs-extra@^9.0.11", "@types/fs-extra@^9.0.12", "@types/fs-extra@^9.0.13":
|
||||||
version "9.0.13"
|
version "9.0.13"
|
||||||
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45"
|
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45"
|
||||||
@@ -4702,7 +4707,12 @@ acorn@^7.4.0:
|
|||||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
|
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
|
||||||
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
|
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
|
||||||
|
|
||||||
acorn@^8.1.0, acorn@^8.4.1, acorn@^8.8.1:
|
acorn@^8.1.0, acorn@^8.8.1:
|
||||||
|
version "8.9.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.9.0.tgz#78a16e3b2bcc198c10822786fa6679e245db5b59"
|
||||||
|
integrity sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==
|
||||||
|
|
||||||
|
acorn@^8.4.1:
|
||||||
version "8.8.2"
|
version "8.8.2"
|
||||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
|
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
|
||||||
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
|
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
|
||||||
@@ -8116,6 +8126,11 @@ file-entry-cache@^6.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flat-cache "^3.0.4"
|
flat-cache "^3.0.4"
|
||||||
|
|
||||||
|
file-saver@^2.0.5:
|
||||||
|
version "2.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/file-saver/-/file-saver-2.0.5.tgz#d61cfe2ce059f414d899e9dd6d4107ee25670c38"
|
||||||
|
integrity sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==
|
||||||
|
|
||||||
file-stream-rotator@^0.6.1:
|
file-stream-rotator@^0.6.1:
|
||||||
version "0.6.1"
|
version "0.6.1"
|
||||||
resolved "https://registry.yarnpkg.com/file-stream-rotator/-/file-stream-rotator-0.6.1.tgz#007019e735b262bb6c6f0197e58e5c87cb96cec3"
|
resolved "https://registry.yarnpkg.com/file-stream-rotator/-/file-stream-rotator-0.6.1.tgz#007019e735b262bb6c6f0197e58e5c87cb96cec3"
|
||||||
@@ -14580,9 +14595,9 @@ toidentifier@1.0.1:
|
|||||||
integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==
|
integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==
|
||||||
|
|
||||||
tough-cookie@^4.1.2:
|
tough-cookie@^4.1.2:
|
||||||
version "4.1.2"
|
version "4.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.2.tgz#e53e84b85f24e0b65dd526f46628db6c85f6b874"
|
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf"
|
||||||
integrity sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==
|
integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==
|
||||||
dependencies:
|
dependencies:
|
||||||
psl "^1.1.33"
|
psl "^1.1.33"
|
||||||
punycode "^2.1.1"
|
punycode "^2.1.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user