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

feat: replace prefer polyfill with preferred methods #60

Open
jimmywarting opened this issue May 3, 2023 · 1 comment
Open

feat: replace prefer polyfill with preferred methods #60

jimmywarting opened this issue May 3, 2023 · 1 comment

Comments

@jimmywarting
Copy link
Owner

jimmywarting commented May 3, 2023

I sometimes get some confusing question on github issues as i most often have to guess what method of choices they use in order to save the files.

there are currently 3 method in place, 1) native 2) service worker 3) building a blob
So it gets a bit hard to trying figuring out the path it takes.

so i want to switch out _preferPolyfill: false to preferedMethods

const fileHandle = await showSaveFilePicker({
- _preferPolyfill: false
+ _preferedMethods: [
+   'native', // req native support for window.showSaveFilePicker
+   'service-worker',  // requires installing a service worker to allow streaming large files
+   'constructing-blob'  // easiest/oldest method that req. more RAM but is fine for smaller file
+ ],
  suggestedName: "Untitled.png",
  types: [
    { accept: { "image/png": ["png"] } },
    { accept: { "image/jpg": ["jpg"] } },
    { accept: { "image/webp": ["webp"] } },
  ],
  excludeAcceptAllOption: false, // default
});

Perhaps later then we could maybe even throw in dropbox and google drive methods into the mix then if something like that ever comes up

Originally posted by @jimmywarting in #59 (comment)

i want service-worker to be explicitly opted out as it requires more things to be set up in order to work correctly.
and i also want this field to be required and not fallback to any default methods. so _preferedMethods will be a required field. But that would maybe perhaps be a too breaking change. perhaps maybe just do a console.warn() and set the default to using ['native', 'constructing-blob']

A problem with not using prefered method are that the service worker solution might not just work if folks install a service worker. cuz we only do feature detection by the occurrences if a service worker is installed or not. not by the fact that they have implemented the push algoritm.

@jimmywarting
Copy link
Owner Author

jimmywarting commented May 3, 2023

I maybe also even want to switch up the service worker to two solutions:
using transferable streams or just the MessageChannel solution

The transferable stream don't require the service worker to stay alive and pinging it with postMessages.

so maybe: ['native', 'sw-transferable-stream', 'sw-message-channel', 'constructing-blob']

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

No branches or pull requests

1 participant