Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FileReaderSync to dom.experimental #424

Merged
merged 4 commits into from
Aug 25, 2021

Conversation

catap
Copy link
Contributor

@catap catap commented Sep 30, 2020

No description provided.

catap added a commit to catap/udash-core that referenced this pull request Sep 30, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Array[Byte]` from frontend to URL
as simple call `FileService.asURL`, create an anchor to download it as
`FileService.asAnchor` and asynchronously convert any uploaded `File` to
`Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via
`FileService.asInputStream`.

Unfortunately scalatags doesn't support `download` attribute and I need to make
it by hand. I've opened a PR: com-lihaoyi/scalatags#212 to
introduce it, but it might be a while until it is included to release.

`FileService.asInputStream` is using `FileReaderSync` that is also missed inside
scala-js-dom. I've opened a PR:
scala-js/scala-js-dom#424 but it might be a while. Also,
this is draft API but it is supported by majority of modern browsers:
https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync#Browser_Compatibility
catap added a commit to catap/udash-core that referenced this pull request Oct 1, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to
URL as simple call `FileService.asURL`, create an anchor to download it as
`FileService.asAnchor` and asynchronously convert any uploaded `File` to
`Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via
`FileService.asInputStream`.

Unfortunately scalatags doesn't support `download` attribute and I need to make
it by hand. I've opened a PR: com-lihaoyi/scalatags#212 to
introduce it, but it might be a while until it is included to release.

`FileService.asInputStream` is using `FileReaderSync` that is also missed inside
scala-js-dom. I've opened a PR:
scala-js/scala-js-dom#424 but it might be a while. Also,
this is draft API but it is supported by majority of modern browsers:
https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync#Browser_Compatibility
catap added a commit to catap/udash-core that referenced this pull request Oct 1, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to
URL as simple call `FileService.asURL`, create an anchor to download it as
`FileService.asAnchor` and asynchronously convert any uploaded `File` to
`Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via
`FileService.asInputStream`.

Unfortunately scalatags doesn't support `download` attribute and I need to make
it by hand. I've opened a PR: com-lihaoyi/scalatags#212 to
introduce it, but it might be a while until it is included to release.

`FileService.asInputStream` is using `FileReaderSync` that is also missed inside
scala-js-dom. I've opened a PR:
scala-js/scala-js-dom#424 but it might be a while. Also,
this is draft API but it is supported by majority of modern browsers:
https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync#Browser_Compatibility
catap added a commit to catap/udash-core that referenced this pull request Nov 16, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to
URL as simple call `FileService.asURL`, create an anchor to download it as
`FileService.asAnchor` and asynchronously convert any uploaded `File` to
`Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via
`FileService.asInputStream`.

Unfortunately scalatags doesn't support `download` attribute and I need to make
it by hand. I've opened a PR: com-lihaoyi/scalatags#212 to
introduce it, but it might be a while until it is included to release.

`FileService.asInputStream` is using `FileReaderSync` that is also missed inside
scala-js-dom. I've opened a PR:
scala-js/scala-js-dom#424 but it might be a while. Also,
this is draft API but it is supported by majority of modern browsers:
https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync#Browser_Compatibility
catap added a commit to catap/udash-core that referenced this pull request Dec 2, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from
frontend to URL as simple call `FileService.createURL`, asynchronously
convert any uploaded `File` to `Array[Byte]` as
`FileService.asBytesArray`, or to `InputStream` via
`FileService.asInputStream` inside worker.

Unfortunately scalatags doesn't support `download` attribute and I need
to make it by hand. I've opened a PR[^1] to introduce it, but it might be a
while until it is included to release.

`FileService.asInputStream` is using `FileReaderSync` that is also
missed inside scala-js-dom. I've opened a PR[^2] but it might be a
while. Also, this draft API but it is supported by majority of modern
browsers[^3].

[^1]: com-lihaoyi/scalatags#212

[^2]: scala-js/scala-js-dom#424

[^3]: https://caniuse.com/?search=FileReaderSync
catap added a commit to catap/udash-core that referenced this pull request Dec 2, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from
frontend to URL as simple call `FileService.createURL`, asynchronously
convert any uploaded `File` to `Array[Byte]` as
`FileService.asBytesArray`, or to `InputStream` via
`FileService.asInputStream` inside worker.

Unfortunately scalatags doesn't support `download` attribute and I need
to make it by hand. I've opened a PR[^1] to introduce it, but it might be a
while until it is included to release.

`FileService.asInputStream` is using `FileReaderSync` that is also
missed inside scala-js-dom. I've opened a PR[^2] but it might be a
while. Also, this draft API but it is supported by majority of modern
browsers[^3].

[^1]: com-lihaoyi/scalatags#212

[^2]: scala-js/scala-js-dom#424

[^3]: https://caniuse.com/?search=FileReaderSync
catap added a commit to catap/udash-core that referenced this pull request Dec 2, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from
frontend to URL as simple call `FileService.createURL`, asynchronously
convert any uploaded `File` to `Array[Byte]` as
`FileService.asBytesArray`, or to `InputStream` via
`FileService.asInputStream` inside worker.

Unfortunately scalatags doesn't support `download` attribute and I need
to make it by hand. I've opened a PR[^1] to introduce it, but it might be a
while until it is included to release.

`FileService.asInputStream` is using `FileReaderSync` that is also
missed inside scala-js-dom. I've opened a PR[^2] but it might be a
while. Also, this draft API but it is supported by majority of modern
browsers[^3].

[^1]: com-lihaoyi/scalatags#212

[^2]: scala-js/scala-js-dom#424

[^3]: https://caniuse.com/?search=FileReaderSync
catap added a commit to catap/udash-core that referenced this pull request Dec 6, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from
frontend to URL as simple call `FileService.createURL`, asynchronously
convert any uploaded `File` to `Array[Byte]` as
`FileService.asBytesArray`, or to `InputStream` via
`FileService.asInputStream` inside worker.

Unfortunately scalatags doesn't support `download` attribute and I need
to make it by hand. I've opened a PR[^1] to introduce it, but it might be a
while until it is included to release.

`FileService.asInputStream` is using `FileReaderSync` that is also
missed inside scala-js-dom. I've opened a PR[^2] but it might be a
while. Also, this draft API but it is supported by majority of modern
browsers[^3].

[^1]: com-lihaoyi/scalatags#212

[^2]: scala-js/scala-js-dom#424

[^3]: https://caniuse.com/?search=FileReaderSync
catap added a commit to catap/udash-core that referenced this pull request Dec 6, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from
frontend to URL as simple call `FileService.createURL`, asynchronously
convert any uploaded `File` to `Future[Array[Byte]]` as
`FileService.asBytesArray`, or to `Array[Byte]` via
`FileService.asSyncBytesArray` inside worker.

Unfortunately scalatags doesn't support `download` attribute and I need
to make it by hand. I've opened a PR[^1] to introduce it, but it might be a
while until it is included to release.

`FileService.asSyncBytesArray` is using `FileReaderSync` that is also
missed inside scala-js-dom. I've opened a PR[^2] but it might be a
while. Also, this draft API but it is supported by majority of modern
browsers[^3].

[^1]: com-lihaoyi/scalatags#212

[^2]: scala-js/scala-js-dom#424

[^3]: https://caniuse.com/?search=FileReaderSync
catap added a commit to catap/udash-core that referenced this pull request Dec 6, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from
frontend to URL as simple call `FileService.createURL`, asynchronously
convert any uploaded `File` to `Future[Array[Byte]]` as
`FileService.asBytesArray`, or to `Array[Byte]` via
`FileService.asSyncBytesArray` inside worker.

Unfortunately scalatags doesn't support `download` attribute and I need
to make it by hand. I've opened a PR[^1] to introduce it, but it might be a
while until it is included to release.

`FileService.asSyncBytesArray` is using `FileReaderSync` that is also
missed inside scala-js-dom. I've opened a PR[^2] but it might be a
while. Also, this draft API but it is supported by majority of modern
browsers[^3].

[^1]: com-lihaoyi/scalatags#212

[^2]: scala-js/scala-js-dom#424

[^3]: https://caniuse.com/?search=FileReaderSync
catap added a commit to catap/udash-core that referenced this pull request Dec 7, 2020
The usecase of this code is something like this: let image that user is making a
protonmail or any another application where content inside frontend (=browser
storage) some secret user's data that shouldn't be exposed to backend. Secret
key for example or anything like that.

This code allows to developer to convert any `Seq[Array[Byte]]` from
frontend to URL as simple call `FileService.createURL`, asynchronously
convert any uploaded `File` to `Future[Array[Byte]]` as
`FileService.asBytesArray`, or to `Array[Byte]` via
`FileService.asSyncBytesArray` inside worker.

Unfortunately scalatags doesn't support `download` attribute and I need
to make it by hand. I've opened a PR[^1] to introduce it, but it might be a
while until it is included to release.

`FileService.asSyncBytesArray` is using `FileReaderSync` that is also
missed inside scala-js-dom. I've opened a PR[^2] but it might be a
while. Also, this draft API but it is supported by majority of modern
browsers[^3].

[^1]: com-lihaoyi/scalatags#212

[^2]: scala-js/scala-js-dom#424

[^3]: https://caniuse.com/?search=FileReaderSync
@armanbilge armanbilge changed the base branch from master to series/1.x August 10, 2021 01:48
@japgolly japgolly marked this pull request as draft August 12, 2021 23:54
@japgolly japgolly added this to the v1.2.0 milestone Aug 13, 2021
@japgolly
Copy link
Contributor

I'm not up to speed with how experimental stuff is handled in this library yet. Revisit soon'ish....

@catap
Copy link
Contributor Author

catap commented Aug 20, 2021

@japgolly I'm using for more than a year a fork which is contains this branch ;)

@catap
Copy link
Contributor Author

catap commented Aug 20, 2021

Ah, I'm wrong. I'm using only readAsArrayBuffer.

@armanbilge
Copy link
Member

I'm not up to speed with how experimental stuff is handled in this library yet.

@japgolly I think it's fine for this to live in the experimental package for 1.x, won't be lonely anyway :) unless we want to put it in the sharedworker package or something, because this is specifically a worker API.

For 2.x, is this even still considered experimental? I didn't see any indication of such at https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync.

@armanbilge armanbilge marked this pull request as ready for review August 23, 2021 00:59
@armanbilge armanbilge requested a review from japgolly August 23, 2021 00:59
@japgolly
Copy link
Contributor

@japgolly I think it's fine for this to live in the experimental package for 1.x, won't be lonely anyway :) unless we want to put it in the sharedworker package or something, because this is specifically a worker API.

@armanbilge Ok if you're cool with it I'm cool with it. Let's keep it in experimental for now and we'll do a proper reorg in 2.0

@japgolly japgolly merged commit 7ec0faa into scala-js:series/1.x Aug 25, 2021
@japgolly
Copy link
Contributor

Merged, thanks for the PR @catap !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants