fixes#6024.
### Problem
- `getPlugin()` defaults to `UnknownPlugin`, so methods like `openModal`
are not visible , since core is not aware of that plugin type
### Proposed change
- Introduce a types-only registry in core:
- `export interface PluginTypeRegistry<M extends Meta, B extends Body>
{}`
- Overload `getPlugin` to return a precise type when the id is a known
key of the registry.
- add `Dashboard` to PluginTypeRegistry through module augmentation:
- `'Dashboard': Dashboard<M, B>`.
- When a project imports from `@uppy/dashboard`, its module augmentation
extends PluginTypeRegistry, adding the correct type into it
- I've added Tests , kept them in a separate file so it's easier to
review , once this approach gets approved I'll add them to
`Uppy.test.ts`
Once this PR gets a positive review I'll add this for other plugins ,
currently only added for `@uppy/dashboard`
**Build with Local tarball can be checked here**
https://stackblitz.com/~/github.com/qxprakash/uppy-type-test?file=type_test.ts
- cleanup `@uppy/utils ` removed unused / redundant modules .
- migrated modules and tests from `.js` to `.ts`
- removed all the nested export paths
- updated `@uppy/utils` import paths for all packages
- `@uppy/angular` is still failing while running`yarn build` , I'm
looking into it.
---------
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
Instead of using `requestSubmit` from the `'submit'` event handler (which was causing a loop), we can call `submit()` after checking `reportValidity` to get the same result without re-emitting the event.
* @uppy/core: move `Uppy` class to its own module
Fixes: https://github.com/transloadit/uppy/issues/3220
* Rename snapshot file
* Update docs
* Update website/src/_posts/2021-08-2.0.md
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
* Update migration guide
* Do not bundle preact with non-UI plugin packages
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
* types: stronger typings
* Remove remaining `declare module` things for uppy.use
* Format types standard-style-like
* Add `target` properties to plugin typings
* Add type for `replaceTargetContent` option
* xhr-upload: allow lowercase method
* opt in to stricter typechecks
* use the strictly typed version in all typings tests
* endtoend: use strict types in typescript test
* Add some comments to the typings file so IDEs will warn about untyped use()
* informer: remove obsolete option from typings
* react: generate prop types based on actual options types
* react: update types
* react: fix import in typings test
* companion-client: add `pluginId` property to ProviderOptions type
Co-Authored-By: Ifedapo .A. Olarewaju <ifedapoolarewaju@gmail.com>
* core: remove some `any` types
* *: add locale string types
* *: generate locale typings
* core: fix LocaleStrings<> type
* dashboard: add locale string type tests
* tus: inherit options typings from tus-js-client
* transloadit: add missing options types
* ci: do the required build steps before testing typings
* Support TokenStorage in types, add `title?: string` options
* form: update typings
* types: put TokenStorage type in dependents
* Document Uppy.StrictTypes
* if we pin at least we should use the latest
* Allow document.querySelector
I think it's a eslint-plugin-compat bug that it's marking querySelector
as not available in Android Chrome 78.
Co-authored-by: Ifedapo .A. Olarewaju <ifedapoolarewaju@gmail.com>
* aws-s3-multipart: fix typo
This was doing a weird thing and probably causing more cancellation
bugs.
Flagged by lgtm.com
* form: fix comparison
* companion-client: fix use strict directive
* exclude meta the the Form plugin itself has added
* append new result to the previous one, instead of overwriting it
* add `replaceResultInFormWithNew` — replace result input value by default, with option to append
* talk about `replaceResultInFormWithNew`
* replaceResultInFormWithNew --> multipleResults