From 8e812555db8ee7e08f3653fdf333230d36dce379 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:19:39 -0500 Subject: [PATCH] Bump zustand from 4.1.5 to 5.0.3 (#1270) * Bump zustand from 4.1.5 to 5.0.3 Bumps [zustand](https://github.com/pmndrs/zustand) from 4.1.5 to 5.0.3. - [Release notes](https://github.com/pmndrs/zustand/releases) - [Commits](https://github.com/pmndrs/zustand/compare/v4.1.5...v5.0.3) --- updated-dependencies: - dependency-name: zustand dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * migrate: zustand v5. * migrate(zustand): remove non-existant destroy. * migrate(zustand): set to null instead of destroy (thanks dai-shi!) * migrate(zustand): work through the type consequences of setting StoreApi to null. --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chris Hallberg --- package-lock.json | 85 ++++++++++++++----- package.json | 2 +- .../uv-openseadragon-extension/Extension.ts | 24 ++++-- .../uv-openseadragon-extension/Store.ts | 4 +- .../modules/uv-shared-module/BaseExtension.ts | 6 +- 5 files changed, 85 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index d60a107cb..80133858f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,7 @@ "react-intersection-observer": "^9.13.0", "waveform-panel": "^1.2.0", "xss": "1.0.15", - "zustand": "^4.0.0-rc.0" + "zustand": "^5.0.3" }, "devDependencies": { "@types/jest": "^29", @@ -17485,11 +17485,11 @@ } }, "node_modules/use-sync-external-store": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", - "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.4.0.tgz", + "integrity": "sha512-9WXSPC5fMv61vaupRkCKCxsPxBocVnwakBEkMIHHpkTTg6icbJtg6jzgtLDm4bl3cSHAca52rYWih0k4K3PfHw==", "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "node_modules/util": { @@ -17713,6 +17713,33 @@ "zustand": "^4.1.5" } }, + "node_modules/waveform-panel/node_modules/zustand": { + "version": "4.5.6", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-4.5.6.tgz", + "integrity": "sha512-ibr/n1hBzLLj5Y+yUcU7dYw8p6WnIVzdJbnX+1YpaScvZVF2ziugqHs+LAmHw4lWO9c/zRj+K1ncgWDQuthEdQ==", + "dependencies": { + "use-sync-external-store": "^1.2.2" + }, + "engines": { + "node": ">=12.7.0" + }, + "peerDependencies": { + "@types/react": ">=16.8", + "immer": ">=9.0.6", + "react": ">=16.8" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + } + } + }, "node_modules/wbuf": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/wbuf/-/wbuf-1.7.3.tgz", @@ -18591,25 +18618,30 @@ } }, "node_modules/zustand": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/zustand/-/zustand-4.1.5.tgz", - "integrity": "sha512-PsdRT8Bvq22Yyh1tvpgdHNE7OAeFKqJXUxtJvj1Ixw2B9O2YZ1M34ImQ+xyZah4wZrR4lENMoDUutKPpyXCQ/Q==", - "dependencies": { - "use-sync-external-store": "1.2.0" - }, + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.3.tgz", + "integrity": "sha512-14fwWQtU3pH4dE0dOpdMiWjddcH+QzKIgk1cl8epwSE7yag43k/AD/m4L6+K7DytAOr9gGBe3/EXj9g7cdostg==", "engines": { - "node": ">=12.7.0" + "node": ">=12.20.0" }, "peerDependencies": { - "immer": ">=9.0", - "react": ">=16.8" + "@types/react": ">=18.0.0", + "immer": ">=9.0.6", + "react": ">=18.0.0", + "use-sync-external-store": ">=1.2.0" }, "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, "immer": { "optional": true }, "react": { "optional": true + }, + "use-sync-external-store": { + "optional": true } } } @@ -31436,9 +31468,9 @@ "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==" }, "use-sync-external-store": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", - "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==" + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.4.0.tgz", + "integrity": "sha512-9WXSPC5fMv61vaupRkCKCxsPxBocVnwakBEkMIHHpkTTg6icbJtg6jzgtLDm4bl3cSHAca52rYWih0k4K3PfHw==" }, "util": { "version": "0.12.5", @@ -31620,6 +31652,16 @@ "requires": { "waveform-data": "^4.3.0", "zustand": "^4.1.5" + }, + "dependencies": { + "zustand": { + "version": "4.5.6", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-4.5.6.tgz", + "integrity": "sha512-ibr/n1hBzLLj5Y+yUcU7dYw8p6WnIVzdJbnX+1YpaScvZVF2ziugqHs+LAmHw4lWO9c/zRj+K1ncgWDQuthEdQ==", + "requires": { + "use-sync-external-store": "^1.2.2" + } + } } }, "wbuf": { @@ -32216,12 +32258,9 @@ "dev": true }, "zustand": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/zustand/-/zustand-4.1.5.tgz", - "integrity": "sha512-PsdRT8Bvq22Yyh1tvpgdHNE7OAeFKqJXUxtJvj1Ixw2B9O2YZ1M34ImQ+xyZah4wZrR4lENMoDUutKPpyXCQ/Q==", - "requires": { - "use-sync-external-store": "1.2.0" - } + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.3.tgz", + "integrity": "sha512-14fwWQtU3pH4dE0dOpdMiWjddcH+QzKIgk1cl8epwSE7yag43k/AD/m4L6+K7DytAOr9gGBe3/EXj9g7cdostg==" } } } diff --git a/package.json b/package.json index c520fa586..cad6c508e 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "react-intersection-observer": "^9.13.0", "waveform-panel": "^1.2.0", "xss": "1.0.15", - "zustand": "^4.0.0-rc.0" + "zustand": "^5.0.3" }, "collective": { "type": "opencollective", diff --git a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts index eee4845fc..021e6f5ba 100644 --- a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts @@ -488,20 +488,23 @@ export default class OpenSeadragonExtension extends BaseExtension { this.extensionHost.subscribe( IIIFEvents.SHOW_DOWNLOAD_DIALOGUE, (triggerButton) => { - this.store.getState().openDownloadDialogue(triggerButton[0]); + const state = this.store.getState(); + if (state !== null) { + state.openDownloadDialogue(triggerButton[0]); + } } ); this.extensionHost.subscribe(IIIFEvents.HIDE_DOWNLOAD_DIALOGUE, () => { - this.store.getState().closeDialogue(); + this.closeActiveDialogue(); }); this.extensionHost.subscribe(IIIFEvents.CLOSE_ACTIVE_DIALOGUE, () => { - this.store.getState().closeDialogue(); + this.closeActiveDialogue(); }); this.extensionHost.subscribe(IIIFEvents.ESCAPE, () => { - this.store.getState().closeDialogue(); + this.closeActiveDialogue(); }); // this.component.subscribe(Events.VIEW_PAGE, (e: any, index: number) => { @@ -696,24 +699,31 @@ export default class OpenSeadragonExtension extends BaseExtension { ); }, onClose: () => { - this.store.getState().closeDialogue(); + this.closeActiveDialogue(); }, onDownloadCurrentView: (canvas: Canvas) => { const viewer: any = this.getViewer(); window.open(this.getCroppedImageUri(canvas, viewer)); }, onDownloadSelection: () => { - this.store.getState().closeDialogue(); + this.closeActiveDialogue(); this.extensionHost.publish(IIIFEvents.SHOW_MULTISELECT_DIALOGUE); }, onShowTermsOfUse: () => { - this.store.getState().closeDialogue(); + this.closeActiveDialogue(); this.extensionHost.publish(IIIFEvents.SHOW_TERMS_OF_USE); }, }) ); } + closeActiveDialogue(): void { + const state = this.store.getState(); + if (state !== null) { + state.closeDialogue(); + } + } + checkForTarget(): void { if (this.data.target) { // Split target into canvas id and selector diff --git a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Store.ts b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Store.ts index 55ccf4533..67c7b5559 100644 --- a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Store.ts +++ b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Store.ts @@ -1,5 +1,5 @@ -import create from "zustand/vanilla"; -import { ExtensionState } from "../../modules/uv-shared-module/ExtensionState"; +import { createStore as create } from "zustand/vanilla"; +import type { ExtensionState } from "../../modules/uv-shared-module/ExtensionState"; export interface OpenSeadragonExtensionState extends ExtensionState {} diff --git a/src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts b/src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts index 6d850cfab..c6e278c49 100644 --- a/src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts +++ b/src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts @@ -45,7 +45,7 @@ import { import { defaultLocale, isVisible } from "../../../../Utils"; import { IIIFEvents } from "../../IIIFEvents"; import { Events } from "../../../../Events"; -import { StoreApi } from "zustand/vanilla"; +import type { StoreApi } from "zustand/vanilla"; import { ExtensionState } from "./ExtensionState"; import { BaseConfig, Metric, MetricType } from "../../BaseConfig"; @@ -75,7 +75,7 @@ export class BaseExtension implements IExtension { restrictedDialogue: RestrictedDialogue; shell: Shell; shifted: boolean = false; - store: StoreApi; + store: StoreApi; // null for dispose() tabbing: boolean = false; browserDetect: BrowserDetect; locales = {}; @@ -1172,7 +1172,7 @@ export class BaseExtension implements IExtension { } dispose(): void { - this.store?.destroy(); + this.store?.setState(null); } }