import { type CompanionPluginOptions, getAllowedHosts, Provider, tokenStorage, } from '@uppy/companion-client' import type { AsyncStore, Body, Meta, UnknownProviderPlugin, UnknownProviderPluginState, UppyFile, } from '@uppy/core' import { UIPlugin, type Uppy } from '@uppy/core' import { ProviderViews } from '@uppy/provider-views' import type { LocaleStrings } from '@uppy/utils' // biome-ignore lint/style/useImportType: h is not a type import { type ComponentChild, h } from 'preact' import packageJson from '../package.json' with { type: 'json' } import locale from './locale.js' export type ZoomOptions = CompanionPluginOptions & { locale?: LocaleStrings } export default class Zoom extends UIPlugin implements UnknownProviderPlugin { static VERSION = packageJson.version icon: () => h.JSX.Element provider: Provider view!: ProviderViews storage: AsyncStore files: UppyFile[] rootFolderId: string | null = null constructor(uppy: Uppy, opts: ZoomOptions) { super(uppy, opts) this.type = 'acquirer' this.files = [] this.storage = this.opts.storage || tokenStorage this.id = this.opts.id || 'Zoom' this.icon = () => ( ) this.opts.companionAllowedHosts = getAllowedHosts( this.opts.companionAllowedHosts, this.opts.companionUrl, ) this.provider = new Provider(uppy, { companionUrl: this.opts.companionUrl, companionHeaders: this.opts.companionHeaders, companionKeysParams: this.opts.companionKeysParams, companionCookiesRule: this.opts.companionCookiesRule, provider: 'zoom', pluginId: this.id, supportsRefreshToken: false, }) this.defaultLocale = locale this.i18nInit() this.title = this.i18n('pluginNameZoom') this.render = this.render.bind(this) } install(): void { this.view = new ProviderViews(this, { provider: this.provider, }) const { target } = this.opts if (target) { this.mount(target, this) } } uninstall(): void { this.view.tearDown() this.unmount() } render(state: unknown): ComponentChild { return this.view.render(state) } } declare module '@uppy/core' { export interface PluginTypeRegistry { Zoom: Zoom } }