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
No need to export it from index.ts, since it’s already exported through
the export maps. Also, it’s an optional peer dependency, we probably
missed this in #5830 , though this might count as a breaking change now
☹️
it was added in #5935 but no explanation of why.
if you look at the build output of for example
`packages/@uppy/react/lib/headless/generated/Dropzone.js`:
```js
import { jsx as _jsx } from "react/jsx-runtime";
// This file was generated by build-components.mjs
// ANY EDITS WILL BE OVERWRITTEN!
import { Dropzone as PreactDropzone, } from '@uppy/components';
import { h as preactH, render as preactRender } from 'preact';
// biome-ignore lint/correctness/noUnusedImports: it's needed
import { createElement as h, useContext, useEffect, useRef } from 'react';
import { UppyContext } from '../UppyContextProvider.js';
export default function Dropzone(props) {
const ref = useRef(null);
const ctx = useContext(UppyContext);
useEffect(() => {
if (ref.current) {
preactRender(preactH(PreactDropzone, {
...props,
ctx,
}), ref.current);
}
}, [ctx, props]);
return _jsx("div", { ref: ref });
}
```
as can be seen there is no usage of `h`. `import { jsx as _jsx } from
"react/jsx-runtime";` is being injected for React JSX. see also
https://github.com/transloadit/uppy/pull/5896#issuecomment-3169210799
We drag it in unneccesarily in the bundle and it can cause JSX clashes
in React apps with `"jsx": "preserve"` in their `tsconfig.json`
(https://github.com/preactjs/preact/issues/4908)
- Remove `@types/react` from companion (unused)
- Fix tsconfig's for @uppy/utils (build was fine, but editor diagnostics
weren't)
- 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>
This pull request removes the `@uppy/status-bar` plugin and integrates
it directly into the `@uppy/dashboard` plugin.
### Breakdown of the merge
- The `StatusBar` class was refactored from a `UIPlugin` into a Preact
Class component.
- The `locale` strings from status-bar were merged into dashboard's
locale file.
- The Dashboard plugin now integrates the `StatusBar` component
directly, controlling its visibility and passing down all props ( i.e.
options that were specific to StatusBar (like showProgressDetails).
- The standalone StatusBar wrappers for React , Vue , svelte , Angular
were removed.
- every reference to the @uppy/status-bar package from the monorepo
(including in package.json and tsconfig.json files).
- fixed failing tests and removed redundant tests.
---------
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
* main: (22 commits)
@uppy/xhr-upload: refactor to use `fetcher` (#5074)
docs: use StackBlitz for all examples/issue template (#5125)
Update yarn.lock
Add svelte 5 as peer dep (#5122)
Bump docker/setup-buildx-action from 2 to 3 (#5124)
Bump actions/checkout from 3 to 4 (#5123)
Remove JSX global type everywhere (#5117)
Revert "@uppy/core: reference updated i18n in Restricter"
@uppy/core: reference updated i18n in Restricter
@uppy/utils: improve return type of `dataURItoFile` (#5112)
@uppy/drop-target: change drop event type to DragEvent (#5107)
@uppy/image-editor: fix label definitions (#5111)
meta: bump Prettier version (#5114)
@uppy/provider-views: bring back "loaded X files..." (#5097)
@uppy/dashboard: fix type of trigger option (#5106)
meta: fix linter
@uppy/form: fix `submitOnSuccess` and `triggerUploadOnSubmit` combination (#5058)
Bump docker/build-push-action from 3 to 5 (#5105)
Bump akhileshns/heroku-deploy from 3.12.12 to 3.13.15 (#5102)
Bump docker/login-action from 2 to 3 (#5101)
...
- `@uppy/aws/s3-multipart`: remove `client` getter and setter.
- reason: internal usage only
- migrate: use exposed options only
- `@uppy/core`: remove `AggregateError` polyfill
- reason: [should be polyfilled by the user](https://github.com/transloadit/uppy/pull/3532#discussion_r818602636)
- migrate: install `AggregateError` polyfill or use `core-js`
- `@uppy/core`: remove `reset()` method
- reason: it's a duplicate of `cancelAll`, but with a less intention revealing name
- migrate: use `cancelAll`
- `@uppy/core`: remove backwards compatible exports (static properties on `Uppy`)
- reason: transition to ESM
- migrate: import the `Uppy` class by default and/or use named exports for everything else.
- `@uppy/react`: don't expose `validProps`
- reason: internal only
- migrate: do not depend on this
- `@uppy/store-redux`: remove backwards compatible exports (static properties on `ReduxStore`)
- reason: transition to ESM
- migrate: use named imports
- `@uppy/thumbnail-generator`: remove `rotateImage`, `protect`, and `canvasToBlob` from prototype.
- reason: internal only
- migrate: don't depend on this