Comments (7)
I don't think it's very feasible. Web workers don't have DOM access, so all our UIs are already problematic. There are also many event listeners in an uploader which can't be set, such as drag & drop but also checks so see whether you are online. I'm not sure you can even read out a file input from a web worker. All our remote providers, which require OAuth flows, wouldn't work either.
It's not as simple as replacing two instances of window
to globalThis
. Perhaps it could be possible to run only @uppy/core
and @uppy/xhr-upload
, but if you need any feedback to the user you would have to write some communication between the threads and build a new UI based on those events, rather than uppy events.
from uppy.
I would accept a PR which replaces the window
instances to globalThis
to make a minimal use case workable for you. But I don't think we can make all of Uppy workable in web workers.
from uppy.
This is a XY Problem, why would you want to run Uppy from a web worker?
from uppy.
I might be missing something. Is there some reason I wouldn't want to run it in a web/service worker? Are there some performance or technical issues I'm missing?
Particularly for offline-first usecases, having the option of organising one's code to make more use of workers can add freedom.
from uppy.
We recently attempted to run Uppy in a Web Worker and encountered the same issue. Our goal was to increase stability by offloading work from the main thread and to prevent issues caused by browser tab throttling when an upload is running in the background.
from uppy.
Closing this as I don't think we can do this at this point. Could've been interesting if you design an uploader from the start with this in mind (might play with this) but at this point I don't think we can with Uppy.
We can reopen if needed.
from uppy.
Thanks for the response but wow, it's also pretty disappointing. I saw uppy
as modular and well-defined... The core and others like xhr and add-file don't seem to need any user interaction or interface, and I can't for the life of me understand why they need document
at all. Obviously there is a good argument for stuff needing user interaction to just have window
and be done with it but I really don't understand actively forcing window
for parts of the application that don't need it... Obviously we can just try and hack a sed
to replace but that is problematic with many libraries so you have to make sure it's only done on uppy
. Particularly given my understanding is that all modern browsers will just treat globalThis
as window
in the window
context, I'm not certain I see a downside... Maybe I'm just an idiot though...
from uppy.
Related Issues (20)
- Can't resolve '@uppy/core/lib/UploaderPlugin.js HOT 10
- Errors in TypeScript definitions when installed with pnpm HOT 5
- Latest version of @uppy/xhr-upload doesn't support PATCH method HOT 11
- aws-s3-multipart + golden retriever HOT 3
- Event listener that fires before file upload process starts HOT 4
- Drag & Drop not working HOT 1
- Uppy Dashboard does not respect the size of the screen HOT 2
- Dashboard progress icon overlaps with `Remove file` button HOT 1
- Allow unique `id` for React `DragDrop` component HOT 1
- Resume failed with aws-s3-multipart and shouldUseMultipart = true option HOT 1
- New provider views + disabling GoogleDrive "shared drives"
- Wrong font in <Dashboard/> example on https://uppy.io/examples
- Support for Angular 17 HOT 2
- Adding COMPANION_SECRET does not pick up the secret value HOT 1
- Minio xml result response ends in new upload retry HOT 4
- [4.x] fa_IR locale missing export default HOT 1
- Implement facebook app secret proof HOT 1
- [4.x] Dashboard doneButtonHandler resets parent state (without re-render) HOT 4
- Documentation - "locale" option for Dashboard HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uppy.