winui-svelte 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +955 -22
- package/README.md +25 -5
- package/dist/app/activate.d.ts.map +1 -1
- package/dist/app/activate.js +3 -0
- package/dist/app/activate.js.map +1 -1
- package/dist/app/activation/index.d.ts +3 -0
- package/dist/app/activation/index.d.ts.map +1 -1
- package/dist/app/activation/index.js +2 -0
- package/dist/app/activation/index.js.map +1 -1
- package/dist/app/activation/login.d.ts +2 -1
- package/dist/app/activation/login.d.ts.map +1 -1
- package/dist/app/activation/login.js +2 -1
- package/dist/app/activation/login.js.map +1 -1
- package/dist/app/activation/native.js +1 -2
- package/dist/app/activation/native.js.map +1 -1
- package/dist/app/activation/packaged.d.ts +49 -0
- package/dist/app/activation/packaged.d.ts.map +1 -0
- package/dist/app/activation/packaged.js +90 -0
- package/dist/app/activation/packaged.js.map +1 -0
- package/dist/app/activation/receive.d.ts +11 -2
- package/dist/app/activation/receive.d.ts.map +1 -1
- package/dist/app/activation/receive.js +11 -4
- package/dist/app/activation/receive.js.map +1 -1
- package/dist/app/activation/registration.d.ts +3 -3
- package/dist/app/activation/registration.js +7 -7
- package/dist/app/activation/registration.js.map +1 -1
- package/dist/app/activation/scheme.d.ts +10 -0
- package/dist/app/activation/scheme.d.ts.map +1 -1
- package/dist/app/activation/scheme.js +17 -0
- package/dist/app/activation/scheme.js.map +1 -1
- package/dist/app/index.d.ts +4 -2
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +3 -1
- package/dist/app/index.js.map +1 -1
- package/dist/app/instance-running.d.ts +15 -0
- package/dist/app/instance-running.d.ts.map +1 -0
- package/dist/app/instance-running.js +20 -0
- package/dist/app/instance-running.js.map +1 -0
- package/dist/app/jump-list/native.d.ts.map +1 -1
- package/dist/app/jump-list/native.js +1 -2
- package/dist/app/jump-list/native.js.map +1 -1
- package/dist/app/launch-command.d.ts +11 -6
- package/dist/app/launch-command.d.ts.map +1 -1
- package/dist/app/launch-command.js +16 -5
- package/dist/app/launch-command.js.map +1 -1
- package/dist/app/native-messaging/browsers.d.ts +19 -0
- package/dist/app/native-messaging/browsers.d.ts.map +1 -0
- package/dist/app/native-messaging/browsers.js +17 -0
- package/dist/app/native-messaging/browsers.js.map +1 -0
- package/dist/app/native-messaging/index.d.ts +41 -0
- package/dist/app/native-messaging/index.d.ts.map +1 -0
- package/dist/app/native-messaging/index.js +84 -0
- package/dist/app/native-messaging/index.js.map +1 -0
- package/dist/app/native.d.ts +0 -6
- package/dist/app/native.d.ts.map +1 -1
- package/dist/app/native.js +1 -24
- package/dist/app/native.js.map +1 -1
- package/dist/app/notification-source.d.ts.map +1 -1
- package/dist/app/notification-source.js +1 -2
- package/dist/app/notification-source.js.map +1 -1
- package/dist/app/shell/native.js +1 -2
- package/dist/app/shell/native.js.map +1 -1
- package/dist/app/single-instance.d.ts +27 -1
- package/dist/app/single-instance.d.ts.map +1 -1
- package/dist/app/single-instance.js +32 -10
- package/dist/app/single-instance.js.map +1 -1
- package/dist/app/tray-instance.d.ts +4 -3
- package/dist/app/tray-instance.d.ts.map +1 -1
- package/dist/app/tray-instance.js +7 -5
- package/dist/app/tray-instance.js.map +1 -1
- package/dist/automation/backend.d.ts +51 -0
- package/dist/automation/backend.d.ts.map +1 -0
- package/dist/automation/backend.js +5 -0
- package/dist/automation/backend.js.map +1 -0
- package/dist/automation/client.d.ts +97 -0
- package/dist/automation/client.d.ts.map +1 -0
- package/dist/automation/client.js +203 -0
- package/dist/automation/client.js.map +1 -0
- package/dist/automation/ids.d.ts +90 -0
- package/dist/automation/ids.d.ts.map +1 -0
- package/dist/automation/ids.js +84 -0
- package/dist/automation/ids.js.map +1 -0
- package/dist/automation/index.d.ts +13 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +8 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/native.d.ts +11 -0
- package/dist/automation/native.d.ts.map +1 -0
- package/dist/automation/native.js +594 -0
- package/dist/automation/native.js.map +1 -0
- package/dist/automation/text.d.ts +50 -0
- package/dist/automation/text.d.ts.map +1 -0
- package/dist/automation/text.js +110 -0
- package/dist/automation/text.js.map +1 -0
- package/dist/automation/with-client.d.ts +13 -0
- package/dist/automation/with-client.d.ts.map +1 -0
- package/dist/automation/with-client.js +19 -0
- package/dist/automation/with-client.js.map +1 -0
- package/dist/automation/worker-job.d.ts +32 -0
- package/dist/automation/worker-job.d.ts.map +1 -0
- package/dist/automation/worker-job.js +69 -0
- package/dist/automation/worker-job.js.map +1 -0
- package/dist/automation/worker.d.ts +44 -0
- package/dist/automation/worker.d.ts.map +1 -0
- package/dist/automation/worker.js +70 -0
- package/dist/automation/worker.js.map +1 -0
- package/dist/bindings/.dynwinrt-js-types +198 -0
- package/dist/bindings/.dynwinrt-managed +1 -1
- package/dist/bindings/index.d.ts +15 -0
- package/dist/bindings/index.js +20 -0
- package/dist/bindings/index.mjs +2902 -2882
- package/dist/bindings/index.proxy.js +10 -0
- package/dist/bindings/windows/application-model/activation/ActivationKind.d.ts +49 -0
- package/dist/bindings/windows/application-model/activation/ActivationKind.js +50 -0
- package/dist/bindings/windows/application-model/activation/ApplicationExecutionState.d.ts +9 -0
- package/dist/bindings/windows/application-model/activation/ApplicationExecutionState.js +10 -0
- package/dist/bindings/windows/application-model/activation/IActivatedEventArgs.d.ts +36 -0
- package/dist/bindings/windows/application-model/activation/IActivatedEventArgs.js +149 -0
- package/dist/bindings/windows/application-model/activation/IActivatedEventArgsWithUser.d.ts +28 -0
- package/dist/bindings/windows/application-model/activation/IActivatedEventArgsWithUser.js +119 -0
- package/dist/bindings/windows/application-model/activation/IApplicationViewActivatedEventArgs.d.ts +27 -0
- package/dist/bindings/windows/application-model/activation/IApplicationViewActivatedEventArgs.js +116 -0
- package/dist/bindings/windows/application-model/activation/IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData.d.ts +31 -0
- package/dist/bindings/windows/application-model/activation/IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData.js +131 -0
- package/dist/bindings/windows/application-model/activation/IViewSwitcherProvider.d.ts +28 -0
- package/dist/bindings/windows/application-model/activation/IViewSwitcherProvider.js +119 -0
- package/dist/bindings/windows/application-model/activation/ProtocolActivatedEventArgs.d.ts +25 -0
- package/dist/bindings/windows/application-model/activation/ProtocolActivatedEventArgs.js +166 -0
- package/dist/bindings/windows/application-model/activation/SplashScreen.d.ts +35 -0
- package/dist/bindings/windows/application-model/activation/SplashScreen.js +105 -0
- package/dist/bindings/windows/foundation/TypedEventHandler_WindowsApplicationModelActivationSplashScreen_Object_g7a7dbfa699cd28ff.d.ts +7 -0
- package/dist/bindings/windows/foundation/TypedEventHandler_WindowsApplicationModelActivationSplashScreen_Object_g7a7dbfa699cd28ff.js +7 -0
- package/dist/bindings/windows/ui/view-management/ActivationViewSwitcher.d.ts +12 -0
- package/dist/bindings/windows/ui/view-management/ActivationViewSwitcher.js +96 -0
- package/dist/chrome/context-menus/context-menu-schema.d.ts +4 -4
- package/dist/chrome/context-menus/context-menu-schema.d.ts.map +1 -1
- package/dist/chrome/context-menus/context-menu-schema.js +1 -7
- package/dist/chrome/context-menus/context-menu-schema.js.map +1 -1
- package/dist/chrome/notifications/notification-schema.d.ts +2 -2
- package/dist/chrome/parse-or-throw.d.ts +7 -0
- package/dist/chrome/parse-or-throw.d.ts.map +1 -0
- package/dist/chrome/parse-or-throw.js +9 -0
- package/dist/chrome/parse-or-throw.js.map +1 -0
- package/dist/chrome/permissions/permission-schema.d.ts.map +1 -1
- package/dist/chrome/permissions/permission-schema.js +1 -7
- package/dist/chrome/permissions/permission-schema.js.map +1 -1
- package/dist/chrome/windows/chrome-windows.d.ts.map +1 -1
- package/dist/chrome/windows/chrome-windows.js +1 -7
- package/dist/chrome/windows/chrome-windows.js.map +1 -1
- package/dist/components/hand-written/Window.svelte +2 -0
- package/dist/components/hand-written/items/keyed-rows.svelte.d.ts.map +1 -1
- package/dist/components/hand-written/items/keyed-rows.svelte.js +6 -0
- package/dist/components/hand-written/items/keyed-rows.svelte.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/runtime.svelte.d.ts.map +1 -1
- package/dist/components/runtime.svelte.js +7 -0
- package/dist/components/runtime.svelte.js.map +1 -1
- package/dist/components/window-context.d.ts +14 -0
- package/dist/components/window-context.d.ts.map +1 -0
- package/dist/components/window-context.js +20 -0
- package/dist/components/window-context.js.map +1 -0
- package/dist/composition/expression.d.ts +1 -1
- package/dist/css/runtime/containers.d.ts.map +1 -1
- package/dist/css/runtime/containers.js +1 -17
- package/dist/css/runtime/containers.js.map +1 -1
- package/dist/css/runtime/native.d.ts.map +1 -1
- package/dist/css/runtime/native.js +40 -20
- package/dist/css/runtime/native.js.map +1 -1
- package/dist/css/translate/property-kit.d.ts +9 -0
- package/dist/css/translate/property-kit.d.ts.map +1 -1
- package/dist/css/translate/property-kit.js.map +1 -1
- package/dist/css/translate/transition-properties.d.ts +1 -1
- package/dist/css/translate/transition-properties.d.ts.map +1 -1
- package/dist/css/translate/transition-properties.js +32 -5
- package/dist/css/translate/transition-properties.js.map +1 -1
- package/dist/data-transfer/data-transfer.d.ts +3 -3
- package/dist/data-transfer/data-transfer.d.ts.map +1 -1
- package/dist/data-transfer/data-transfer.js.map +1 -1
- package/dist/data-transfer/drag-effects.d.ts +25 -2
- package/dist/data-transfer/drag-effects.d.ts.map +1 -1
- package/dist/data-transfer/drag-effects.js +27 -2
- package/dist/data-transfer/drag-effects.js.map +1 -1
- package/dist/data-transfer/drag-helper.d.ts +50 -0
- package/dist/data-transfer/drag-helper.d.ts.map +1 -0
- package/dist/data-transfer/drag-helper.js +156 -0
- package/dist/data-transfer/drag-helper.js.map +1 -0
- package/dist/data-transfer/drop-target.d.ts +6 -5
- package/dist/data-transfer/drop-target.d.ts.map +1 -1
- package/dist/data-transfer/drop-target.js +68 -20
- package/dist/data-transfer/drop-target.js.map +1 -1
- package/dist/data-transfer/index.d.ts +1 -0
- package/dist/data-transfer/index.d.ts.map +1 -1
- package/dist/data-transfer/index.js.map +1 -1
- package/dist/data-transfer/launcher.d.ts +4 -3
- package/dist/data-transfer/launcher.d.ts.map +1 -1
- package/dist/data-transfer/launcher.js +58 -9
- package/dist/data-transfer/launcher.js.map +1 -1
- package/dist/data-transfer/native.d.ts +66 -0
- package/dist/data-transfer/native.d.ts.map +1 -0
- package/dist/data-transfer/native.js +148 -0
- package/dist/data-transfer/native.js.map +1 -0
- package/dist/data-transfer/ole-data-object.d.ts +62 -0
- package/dist/data-transfer/ole-data-object.d.ts.map +1 -0
- package/dist/data-transfer/ole-data-object.js +162 -0
- package/dist/data-transfer/ole-data-object.js.map +1 -0
- package/dist/data-transfer/ole-drop-target.d.ts +54 -0
- package/dist/data-transfer/ole-drop-target.d.ts.map +1 -0
- package/dist/data-transfer/ole-drop-target.js +192 -0
- package/dist/data-transfer/ole-drop-target.js.map +1 -0
- package/dist/data-transfer/share-interop.d.ts.map +1 -1
- package/dist/data-transfer/share-interop.js +1 -1
- package/dist/data-transfer/share-interop.js.map +1 -1
- package/dist/data-transfer/shell-items.d.ts +10 -0
- package/dist/data-transfer/shell-items.d.ts.map +1 -0
- package/dist/data-transfer/shell-items.js +67 -0
- package/dist/data-transfer/shell-items.js.map +1 -0
- package/dist/data-transfer/window-drop.d.ts +35 -0
- package/dist/data-transfer/window-drop.d.ts.map +1 -0
- package/dist/data-transfer/window-drop.js +311 -0
- package/dist/data-transfer/window-drop.js.map +1 -0
- package/dist/devices/native.js +1 -2
- package/dist/devices/native.js.map +1 -1
- package/dist/downloads/chrome-downloads.d.ts +8 -0
- package/dist/downloads/chrome-downloads.d.ts.map +1 -1
- package/dist/downloads/chrome-downloads.js +35 -6
- package/dist/downloads/chrome-downloads.js.map +1 -1
- package/dist/downloads/download-record.d.ts +3 -2
- package/dist/downloads/download-record.d.ts.map +1 -1
- package/dist/downloads/download-record.js.map +1 -1
- package/dist/downloads/download-transfer.d.ts.map +1 -1
- package/dist/downloads/download-transfer.js +3 -3
- package/dist/downloads/download-transfer.js.map +1 -1
- package/dist/downloads/download-types.d.ts +3 -1
- package/dist/downloads/download-types.d.ts.map +1 -1
- package/dist/downloads/download-types.js.map +1 -1
- package/dist/downloads/fetch-to-file.d.ts +11 -6
- package/dist/downloads/fetch-to-file.d.ts.map +1 -1
- package/dist/downloads/fetch-to-file.js +45 -16
- package/dist/downloads/fetch-to-file.js.map +1 -1
- package/dist/downloads/taskbar-progress.d.ts +3 -18
- package/dist/downloads/taskbar-progress.d.ts.map +1 -1
- package/dist/downloads/taskbar-progress.js +1 -38
- package/dist/downloads/taskbar-progress.js.map +1 -1
- package/dist/enums.d.ts +4 -0
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +4 -0
- package/dist/enums.js.map +1 -1
- package/dist/forms/form-field-props.d.ts +2 -2
- package/dist/input/index.d.ts +2 -0
- package/dist/input/index.d.ts.map +1 -1
- package/dist/input/index.js +1 -0
- package/dist/input/index.js.map +1 -1
- package/dist/input/modifier-keys.d.ts +24 -0
- package/dist/input/modifier-keys.d.ts.map +1 -0
- package/dist/input/modifier-keys.js +20 -0
- package/dist/input/modifier-keys.js.map +1 -0
- package/dist/media/pixel-buffer.d.ts.map +1 -1
- package/dist/media/pixel-buffer.js +1 -1
- package/dist/media/pixel-buffer.js.map +1 -1
- package/dist/messaging/web-view2/core.d.ts +56 -0
- package/dist/messaging/web-view2/core.d.ts.map +1 -1
- package/dist/messaging/web-view2/core.js +6 -0
- package/dist/messaging/web-view2/core.js.map +1 -1
- package/dist/messaging/web-view2/environment.d.ts +41 -0
- package/dist/messaging/web-view2/environment.d.ts.map +1 -0
- package/dist/messaging/web-view2/environment.js +91 -0
- package/dist/messaging/web-view2/environment.js.map +1 -0
- package/dist/messaging/web-view2/index.d.ts +9 -1
- package/dist/messaging/web-view2/index.d.ts.map +1 -1
- package/dist/messaging/web-view2/index.js +5 -0
- package/dist/messaging/web-view2/index.js.map +1 -1
- package/dist/messaging/web-view2/input.d.ts +68 -0
- package/dist/messaging/web-view2/input.d.ts.map +1 -0
- package/dist/messaging/web-view2/input.js +108 -0
- package/dist/messaging/web-view2/input.js.map +1 -0
- package/dist/messaging/web-view2/protocol.d.ts +24 -0
- package/dist/messaging/web-view2/protocol.d.ts.map +1 -0
- package/dist/messaging/web-view2/protocol.js +31 -0
- package/dist/messaging/web-view2/protocol.js.map +1 -0
- package/dist/messaging/web-view2/recovery.d.ts +65 -0
- package/dist/messaging/web-view2/recovery.d.ts.map +1 -0
- package/dist/messaging/web-view2/recovery.js +138 -0
- package/dist/messaging/web-view2/recovery.js.map +1 -0
- package/dist/messaging/web-view2/requests.d.ts +88 -0
- package/dist/messaging/web-view2/requests.d.ts.map +1 -0
- package/dist/messaging/web-view2/requests.js +169 -0
- package/dist/messaging/web-view2/requests.js.map +1 -0
- package/dist/messaging/web-view2/transport.d.ts.map +1 -1
- package/dist/messaging/web-view2/transport.js +1 -4
- package/dist/messaging/web-view2/transport.js.map +1 -1
- package/dist/native-identity.d.ts +10 -0
- package/dist/native-identity.d.ts.map +1 -0
- package/dist/native-identity.js +20 -0
- package/dist/native-identity.js.map +1 -0
- package/dist/progress/TaskbarProgress.d.svelte.ts +6 -0
- package/dist/progress/TaskbarProgress.svelte +32 -0
- package/dist/progress/aggregate.d.ts +23 -0
- package/dist/progress/aggregate.d.ts.map +1 -0
- package/dist/progress/aggregate.js +59 -0
- package/dist/progress/aggregate.js.map +1 -0
- package/dist/progress/core.d.ts +14 -0
- package/dist/progress/core.d.ts.map +1 -0
- package/dist/progress/core.js +8 -0
- package/dist/progress/core.js.map +1 -0
- package/dist/progress/index.d.ts +5 -0
- package/dist/progress/index.d.ts.map +1 -0
- package/dist/progress/index.js +4 -0
- package/dist/progress/index.js.map +1 -0
- package/dist/progress/progress-event.d.ts +18 -0
- package/dist/progress/progress-event.d.ts.map +1 -0
- package/dist/progress/progress-event.js +19 -0
- package/dist/progress/progress-event.js.map +1 -0
- package/dist/progress/progress-operation.d.ts +163 -0
- package/dist/progress/progress-operation.d.ts.map +1 -0
- package/dist/progress/progress-operation.js +356 -0
- package/dist/progress/progress-operation.js.map +1 -0
- package/dist/progress/progress-registry.d.ts +89 -0
- package/dist/progress/progress-registry.d.ts.map +1 -0
- package/dist/progress/progress-registry.js +187 -0
- package/dist/progress/progress-registry.js.map +1 -0
- package/dist/progress/progress-source.d.ts +46 -0
- package/dist/progress/progress-source.d.ts.map +1 -0
- package/dist/progress/progress-source.js +31 -0
- package/dist/progress/progress-source.js.map +1 -0
- package/dist/progress/progress-state.d.ts +54 -0
- package/dist/progress/progress-state.d.ts.map +1 -0
- package/dist/progress/progress-state.js +35 -0
- package/dist/progress/progress-state.js.map +1 -0
- package/dist/progress/progress-text.d.ts +10 -0
- package/dist/progress/progress-text.d.ts.map +1 -0
- package/dist/progress/progress-text.js +23 -0
- package/dist/progress/progress-text.js.map +1 -0
- package/dist/progress/scoped-source.d.ts +31 -0
- package/dist/progress/scoped-source.d.ts.map +1 -0
- package/dist/progress/scoped-source.js +46 -0
- package/dist/progress/scoped-source.js.map +1 -0
- package/dist/progress/taskbar-progress-props.d.ts +15 -0
- package/dist/progress/taskbar-progress-props.d.ts.map +1 -0
- package/dist/progress/taskbar-progress-props.js +2 -0
- package/dist/progress/taskbar-progress-props.js.map +1 -0
- package/dist/progress/taskbar-progress.d.ts +44 -0
- package/dist/progress/taskbar-progress.d.ts.map +1 -0
- package/dist/progress/taskbar-progress.js +62 -0
- package/dist/progress/taskbar-progress.js.map +1 -0
- package/dist/progress/track-operation.d.ts +36 -0
- package/dist/progress/track-operation.d.ts.map +1 -0
- package/dist/progress/track-operation.js +53 -0
- package/dist/progress/track-operation.js.map +1 -0
- package/dist/renderer/host/host.d.ts.map +1 -1
- package/dist/renderer/host/host.js +33 -16
- package/dist/renderer/host/host.js.map +1 -1
- package/dist/renderer/host/structure-sync.d.ts +9 -0
- package/dist/renderer/host/structure-sync.d.ts.map +1 -0
- package/dist/renderer/host/structure-sync.js +24 -0
- package/dist/renderer/host/structure-sync.js.map +1 -0
- package/dist/security/data-protection-error.d.ts +14 -0
- package/dist/security/data-protection-error.d.ts.map +1 -0
- package/dist/security/data-protection-error.js +15 -0
- package/dist/security/data-protection-error.js.map +1 -0
- package/dist/security/index.d.ts +48 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +32 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/native.d.ts +43 -0
- package/dist/security/native.d.ts.map +1 -0
- package/dist/security/native.js +170 -0
- package/dist/security/native.js.map +1 -0
- package/dist/security/protection-scope.d.ts +13 -0
- package/dist/security/protection-scope.d.ts.map +1 -0
- package/dist/security/protection-scope.js +11 -0
- package/dist/security/protection-scope.js.map +1 -0
- package/dist/store/states.d.ts +2 -2
- package/dist/store/windows-identity.d.ts +2 -6
- package/dist/store/windows-identity.d.ts.map +1 -1
- package/dist/store/windows-identity.js +2 -29
- package/dist/store/windows-identity.js.map +1 -1
- package/dist/store/windows-packages.d.ts +2 -2
- package/dist/store/windows-store.d.ts +2 -2
- package/dist/tray/click-detector.d.ts.map +1 -1
- package/dist/tray/click-detector.js.map +1 -1
- package/dist/tray/flyout-model.d.ts +4 -3
- package/dist/tray/flyout-model.d.ts.map +1 -1
- package/dist/tray/flyout-model.js +12 -2
- package/dist/tray/flyout-model.js.map +1 -1
- package/dist/tray/menu/icon.d.ts +17 -0
- package/dist/tray/menu/icon.d.ts.map +1 -0
- package/dist/tray/menu/icon.js +31 -0
- package/dist/tray/menu/icon.js.map +1 -0
- package/dist/tray/menu/index.d.ts +1 -1
- package/dist/tray/menu/index.d.ts.map +1 -1
- package/dist/tray/menu/index.js.map +1 -1
- package/dist/tray/menu/types.d.ts +23 -6
- package/dist/tray/menu/types.d.ts.map +1 -1
- package/dist/tray/menu/types.js.map +1 -1
- package/dist/tray/menu-svelte/TrayMenuOperations.d.svelte.ts +6 -0
- package/dist/tray/menu-svelte/TrayMenuOperations.svelte +33 -0
- package/dist/tray/menu-svelte/TrayMenuProgress.d.svelte.ts +6 -0
- package/dist/tray/menu-svelte/TrayMenuProgress.svelte +28 -0
- package/dist/tray/menu-svelte/index.d.ts +3 -1
- package/dist/tray/menu-svelte/index.d.ts.map +1 -1
- package/dist/tray/menu-svelte/index.js +2 -0
- package/dist/tray/menu-svelte/index.js.map +1 -1
- package/dist/tray/menu-svelte/menu-node.d.ts +9 -9
- package/dist/tray/menu-svelte/menu-props.d.ts +16 -0
- package/dist/tray/menu-svelte/menu-props.d.ts.map +1 -1
- package/dist/tray/menu-svelte/operation-ids.d.ts +8 -0
- package/dist/tray/menu-svelte/operation-ids.d.ts.map +1 -0
- package/dist/tray/menu-svelte/operation-ids.js +20 -0
- package/dist/tray/menu-svelte/operation-ids.js.map +1 -0
- package/dist/tray/native.d.ts +15 -5
- package/dist/tray/native.d.ts.map +1 -1
- package/dist/tray/native.js +27 -45
- package/dist/tray/native.js.map +1 -1
- package/dist/tray/personalize.d.ts +18 -0
- package/dist/tray/personalize.d.ts.map +1 -0
- package/dist/tray/personalize.js +42 -0
- package/dist/tray/personalize.js.map +1 -0
- package/dist/tray/pointer-share.d.ts +27 -0
- package/dist/tray/pointer-share.d.ts.map +1 -0
- package/dist/tray/pointer-share.js +61 -0
- package/dist/tray/pointer-share.js.map +1 -0
- package/dist/tray/standalone/icon-raster.d.ts +72 -0
- package/dist/tray/standalone/icon-raster.d.ts.map +1 -0
- package/dist/tray/standalone/icon-raster.js +161 -0
- package/dist/tray/standalone/icon-raster.js.map +1 -0
- package/dist/tray/standalone/index.d.ts +4 -2
- package/dist/tray/standalone/index.d.ts.map +1 -1
- package/dist/tray/standalone/index.js +2 -0
- package/dist/tray/standalone/index.js.map +1 -1
- package/dist/tray/standalone/menu-icons.d.ts +9 -0
- package/dist/tray/standalone/menu-icons.d.ts.map +1 -0
- package/dist/tray/standalone/menu-icons.js +280 -0
- package/dist/tray/standalone/menu-icons.js.map +1 -0
- package/dist/tray/standalone/menu-theme.d.ts +38 -0
- package/dist/tray/standalone/menu-theme.d.ts.map +1 -0
- package/dist/tray/standalone/menu-theme.js +74 -0
- package/dist/tray/standalone/menu-theme.js.map +1 -0
- package/dist/tray/standalone/native.d.ts +24 -7
- package/dist/tray/standalone/native.d.ts.map +1 -1
- package/dist/tray/standalone/native.js +63 -16
- package/dist/tray/standalone/native.js.map +1 -1
- package/dist/tray/standalone/standalone-tray.d.ts +17 -2
- package/dist/tray/standalone/standalone-tray.d.ts.map +1 -1
- package/dist/tray/standalone/standalone-tray.js +34 -2
- package/dist/tray/standalone/standalone-tray.js.map +1 -1
- package/dist/tray/themed-icon.d.ts.map +1 -1
- package/dist/tray/themed-icon.js +4 -28
- package/dist/tray/themed-icon.js.map +1 -1
- package/dist/tray/tray-core.d.ts.map +1 -1
- package/dist/tray/tray-core.js +6 -1
- package/dist/tray/tray-core.js.map +1 -1
- package/dist/tray/tray-extras.d.ts +26 -2
- package/dist/tray/tray-extras.d.ts.map +1 -1
- package/dist/tray/tray-manifest.d.ts +44 -4
- package/dist/tray/tray-manifest.d.ts.map +1 -1
- package/dist/tray/tray-manifest.js +48 -4
- package/dist/tray/tray-manifest.js.map +1 -1
- package/dist/vite/entrypoints/build-tray.d.ts +3 -1
- package/dist/vite/entrypoints/build-tray.d.ts.map +1 -1
- package/dist/vite/entrypoints/build-tray.js +22 -16
- package/dist/vite/entrypoints/build-tray.js.map +1 -1
- package/dist/vite/entrypoints/extract-tray.d.ts +7 -6
- package/dist/vite/entrypoints/extract-tray.d.ts.map +1 -1
- package/dist/vite/entrypoints/extract-tray.js +35 -15
- package/dist/vite/entrypoints/extract-tray.js.map +1 -1
- package/dist/vite/entrypoints/tray-module.d.ts +2 -1
- package/dist/vite/entrypoints/tray-module.d.ts.map +1 -1
- package/dist/vite/entrypoints/tray-module.js +8 -4
- package/dist/vite/entrypoints/tray-module.js.map +1 -1
- package/dist/web-apis/eye-dropper.d.ts.map +1 -1
- package/dist/web-apis/eye-dropper.js +8 -5
- package/dist/web-apis/eye-dropper.js.map +1 -1
- package/dist/web-apis/file-read.d.ts +14 -0
- package/dist/web-apis/file-read.d.ts.map +1 -0
- package/dist/web-apis/file-read.js +37 -0
- package/dist/web-apis/file-read.js.map +1 -0
- package/dist/web-apis/file-system.d.ts +9 -0
- package/dist/web-apis/file-system.d.ts.map +1 -1
- package/dist/web-apis/file-system.js +24 -0
- package/dist/web-apis/file-system.js.map +1 -1
- package/dist/web-apis/media-devices-source.d.ts +1 -1
- package/dist/web-apis/native.d.ts +0 -7
- package/dist/web-apis/native.d.ts.map +1 -1
- package/dist/web-apis/native.js +0 -19
- package/dist/web-apis/native.js.map +1 -1
- package/dist/win2d/activation-failure.d.ts +10 -0
- package/dist/win2d/activation-failure.d.ts.map +1 -0
- package/dist/win2d/activation-failure.js +30 -0
- package/dist/win2d/activation-failure.js.map +1 -0
- package/dist/win2d/element-lifecycle.d.ts.map +1 -1
- package/dist/win2d/element-lifecycle.js +6 -1
- package/dist/win2d/element-lifecycle.js.map +1 -1
- package/dist/win2d/manifest.d.ts +29 -0
- package/dist/win2d/manifest.d.ts.map +1 -0
- package/dist/win2d/manifest.js +67 -0
- package/dist/win2d/manifest.js.map +1 -0
- package/dist/win32/index.d.ts +3 -0
- package/dist/win32/index.d.ts.map +1 -0
- package/dist/win32/index.js +11 -0
- package/dist/win32/index.js.map +1 -0
- package/dist/win32-calls.d.ts +6 -0
- package/dist/win32-calls.d.ts.map +1 -1
- package/dist/win32-calls.js +6 -1
- package/dist/win32-calls.js.map +1 -1
- package/dist/win32-foreground.d.ts +34 -0
- package/dist/win32-foreground.d.ts.map +1 -0
- package/dist/win32-foreground.js +91 -0
- package/dist/win32-foreground.js.map +1 -0
- package/dist/win32-icons.d.ts.map +1 -1
- package/dist/win32-icons.js +1 -2
- package/dist/win32-icons.js.map +1 -1
- package/dist/win32-key-state.d.ts +31 -0
- package/dist/win32-key-state.d.ts.map +1 -0
- package/dist/win32-key-state.js +41 -0
- package/dist/win32-key-state.js.map +1 -0
- package/dist/window/anchor.d.ts +15 -0
- package/dist/window/anchor.d.ts.map +1 -1
- package/dist/window/anchor.js +23 -0
- package/dist/window/anchor.js.map +1 -1
- package/dist/window/apply-frame.d.ts +4 -2
- package/dist/window/apply-frame.d.ts.map +1 -1
- package/dist/window/apply-frame.js +2 -3
- package/dist/window/apply-frame.js.map +1 -1
- package/dist/window/bootstrap-core.d.ts +69 -0
- package/dist/window/bootstrap-core.d.ts.map +1 -0
- package/dist/window/bootstrap-core.js +93 -0
- package/dist/window/bootstrap-core.js.map +1 -0
- package/dist/window/bootstrap-mode.d.ts +21 -0
- package/dist/window/bootstrap-mode.d.ts.map +1 -0
- package/dist/window/bootstrap-mode.js +17 -0
- package/dist/window/bootstrap-mode.js.map +1 -0
- package/dist/window/bootstrap.d.ts +12 -28
- package/dist/window/bootstrap.d.ts.map +1 -1
- package/dist/window/bootstrap.js +18 -66
- package/dist/window/bootstrap.js.map +1 -1
- package/dist/window/cover.d.ts +43 -0
- package/dist/window/cover.d.ts.map +1 -0
- package/dist/window/cover.js +64 -0
- package/dist/window/cover.js.map +1 -0
- package/dist/window/create-window.d.ts +1 -1
- package/dist/window/create-window.d.ts.map +1 -1
- package/dist/window/create-window.js +2 -0
- package/dist/window/create-window.js.map +1 -1
- package/dist/window/dpi-awareness.d.ts +71 -0
- package/dist/window/dpi-awareness.d.ts.map +1 -0
- package/dist/window/dpi-awareness.js +127 -0
- package/dist/window/dpi-awareness.js.map +1 -0
- package/dist/window/foreground-filter.d.ts +71 -0
- package/dist/window/foreground-filter.d.ts.map +1 -0
- package/dist/window/foreground-filter.js +108 -0
- package/dist/window/foreground-filter.js.map +1 -0
- package/dist/window/foreground-native.d.ts +25 -0
- package/dist/window/foreground-native.d.ts.map +1 -0
- package/dist/window/foreground-native.js +86 -0
- package/dist/window/foreground-native.js.map +1 -0
- package/dist/window/foreground.d.ts +49 -0
- package/dist/window/foreground.d.ts.map +1 -0
- package/dist/window/foreground.js +78 -0
- package/dist/window/foreground.js.map +1 -0
- package/dist/window/index.d.ts +2 -0
- package/dist/window/index.d.ts.map +1 -1
- package/dist/window/index.js +1 -0
- package/dist/window/index.js.map +1 -1
- package/dist/window/native.d.ts.map +1 -1
- package/dist/window/native.js +1 -2
- package/dist/window/native.js.map +1 -1
- package/dist/window/package-identity.d.ts +17 -0
- package/dist/window/package-identity.d.ts.map +1 -0
- package/dist/window/package-identity.js +97 -0
- package/dist/window/package-identity.js.map +1 -0
- package/dist/window/system-dispatcher-queue.d.ts.map +1 -1
- package/dist/window/system-dispatcher-queue.js +1 -2
- package/dist/window/system-dispatcher-queue.js.map +1 -1
- package/dist/window/taskbar-calls.d.ts +1 -1
- package/dist/window/taskbar-native.d.ts.map +1 -1
- package/dist/window/taskbar-native.js +1 -2
- package/dist/window/taskbar-native.js.map +1 -1
- package/dist/window/window-handle.d.ts +25 -1
- package/dist/window/window-handle.d.ts.map +1 -1
- package/dist/window/window-handle.js +27 -1
- package/dist/window/window-handle.js.map +1 -1
- package/dist/window/window-host.svelte.d.ts +11 -2
- package/dist/window/window-host.svelte.d.ts.map +1 -1
- package/dist/window/window-host.svelte.js +38 -4
- package/dist/window/window-host.svelte.js.map +1 -1
- package/package.json +43 -4
- package/src/app/activate.ts +3 -0
- package/src/app/activation/index.ts +3 -0
- package/src/app/activation/login.ts +2 -1
- package/src/app/activation/native.ts +1 -1
- package/src/app/activation/packaged.ts +118 -0
- package/src/app/activation/receive.ts +24 -4
- package/src/app/activation/registration.ts +7 -7
- package/src/app/activation/scheme.ts +19 -0
- package/src/app/index.ts +4 -2
- package/src/app/instance-running.ts +22 -0
- package/src/app/jump-list/native.ts +1 -2
- package/src/app/launch-command.ts +19 -5
- package/src/app/native-messaging/browsers.ts +21 -0
- package/src/app/native-messaging/index.ts +124 -0
- package/src/app/native.ts +1 -32
- package/src/app/notification-source.ts +1 -3
- package/src/app/shell/native.ts +1 -1
- package/src/app/single-instance.ts +34 -10
- package/src/app/tray-instance.ts +7 -5
- package/src/automation/backend.ts +56 -0
- package/src/automation/client.ts +327 -0
- package/src/automation/ids.ts +97 -0
- package/src/automation/index.ts +23 -0
- package/src/automation/native.ts +688 -0
- package/src/automation/text.ts +174 -0
- package/src/automation/with-client.ts +20 -0
- package/src/automation/worker-job.ts +97 -0
- package/src/automation/worker.ts +116 -0
- package/src/chrome/context-menus/context-menu-schema.ts +1 -12
- package/src/chrome/parse-or-throw.ts +14 -0
- package/src/chrome/permissions/permission-schema.ts +1 -12
- package/src/chrome/windows/chrome-windows.ts +1 -13
- package/src/components/hand-written/items/keyed-rows.svelte.ts +6 -0
- package/src/components/index.ts +1 -0
- package/src/components/runtime.svelte.ts +8 -0
- package/src/components/window-context.ts +23 -0
- package/src/css/runtime/containers.ts +1 -20
- package/src/css/runtime/native.ts +46 -21
- package/src/css/translate/property-kit.ts +9 -0
- package/src/css/translate/transition-properties.ts +44 -10
- package/src/data-transfer/data-transfer.ts +3 -3
- package/src/data-transfer/drag-effects.ts +48 -4
- package/src/data-transfer/drag-helper.ts +216 -0
- package/src/data-transfer/drop-target.ts +90 -26
- package/src/data-transfer/index.ts +1 -0
- package/src/data-transfer/launcher.ts +65 -9
- package/src/data-transfer/native.ts +184 -0
- package/src/data-transfer/ole-data-object.ts +200 -0
- package/src/data-transfer/ole-drop-target.ts +263 -0
- package/src/data-transfer/share-interop.ts +1 -1
- package/src/data-transfer/shell-items.ts +81 -0
- package/src/data-transfer/window-drop.ts +411 -0
- package/src/devices/native.ts +1 -1
- package/src/downloads/chrome-downloads.ts +46 -6
- package/src/downloads/download-record.ts +3 -2
- package/src/downloads/download-transfer.ts +3 -3
- package/src/downloads/download-types.ts +3 -0
- package/src/downloads/fetch-to-file.ts +47 -17
- package/src/downloads/taskbar-progress.ts +3 -49
- package/src/enums.ts +4 -0
- package/src/input/index.ts +2 -0
- package/src/input/modifier-keys.ts +30 -0
- package/src/media/pixel-buffer.ts +1 -1
- package/src/messaging/web-view2/core.ts +64 -0
- package/src/messaging/web-view2/environment.ts +131 -0
- package/src/messaging/web-view2/index.ts +11 -0
- package/src/messaging/web-view2/input.ts +154 -0
- package/src/messaging/web-view2/protocol.ts +41 -0
- package/src/messaging/web-view2/recovery.ts +177 -0
- package/src/messaging/web-view2/requests.ts +238 -0
- package/src/messaging/web-view2/transport.ts +1 -5
- package/src/native-identity.ts +22 -0
- package/src/progress/TaskbarProgress.d.svelte.ts +6 -0
- package/src/progress/aggregate.ts +68 -0
- package/src/progress/core.ts +13 -0
- package/src/progress/index.ts +4 -0
- package/src/progress/progress-event.ts +25 -0
- package/src/progress/progress-operation.ts +469 -0
- package/src/progress/progress-registry.ts +224 -0
- package/src/progress/progress-source.ts +66 -0
- package/src/progress/progress-state.ts +72 -0
- package/src/progress/progress-text.ts +27 -0
- package/src/progress/scoped-source.ts +56 -0
- package/src/progress/taskbar-progress-props.ts +18 -0
- package/src/progress/taskbar-progress.ts +80 -0
- package/src/progress/track-operation.ts +81 -0
- package/src/renderer/host/host.ts +39 -17
- package/src/renderer/host/structure-sync.ts +25 -0
- package/src/security/data-protection-error.ts +18 -0
- package/src/security/index.ts +57 -0
- package/src/security/native.ts +234 -0
- package/src/security/protection-scope.ts +13 -0
- package/src/store/windows-identity.ts +3 -35
- package/src/tray/click-detector.ts +6 -7
- package/src/tray/flyout-model.ts +14 -3
- package/src/tray/menu/icon.ts +40 -0
- package/src/tray/menu/index.ts +3 -0
- package/src/tray/menu/types.ts +27 -6
- package/src/tray/menu-svelte/TrayMenuOperations.d.svelte.ts +6 -0
- package/src/tray/menu-svelte/TrayMenuProgress.d.svelte.ts +6 -0
- package/src/tray/menu-svelte/index.ts +4 -0
- package/src/tray/menu-svelte/menu-props.ts +20 -0
- package/src/tray/menu-svelte/operation-ids.ts +21 -0
- package/src/tray/native.ts +44 -49
- package/src/tray/personalize.ts +57 -0
- package/src/tray/pointer-share.ts +71 -0
- package/src/tray/standalone/icon-raster.ts +208 -0
- package/src/tray/standalone/index.ts +5 -1
- package/src/tray/standalone/menu-icons.ts +317 -0
- package/src/tray/standalone/menu-theme.ts +90 -0
- package/src/tray/standalone/native.ts +83 -16
- package/src/tray/standalone/standalone-tray.ts +68 -5
- package/src/tray/themed-icon.ts +4 -36
- package/src/tray/tray-core.ts +7 -1
- package/src/tray/tray-extras.ts +31 -2
- package/src/tray/tray-manifest.ts +53 -4
- package/src/vite/entrypoints/build-tray.ts +23 -16
- package/src/vite/entrypoints/extract-tray.ts +41 -15
- package/src/vite/entrypoints/tray-module.ts +8 -4
- package/src/web-apis/eye-dropper.ts +9 -5
- package/src/web-apis/file-read.ts +43 -0
- package/src/web-apis/file-system.ts +33 -0
- package/src/web-apis/native.ts +0 -20
- package/src/win2d/activation-failure.ts +35 -0
- package/src/win2d/element-lifecycle.ts +6 -1
- package/src/win2d/manifest.ts +78 -0
- package/src/win32/index.ts +19 -0
- package/src/win32-calls.ts +8 -1
- package/src/win32-foreground.ts +100 -0
- package/src/win32-icons.ts +7 -2
- package/src/win32-key-state.ts +48 -0
- package/src/window/anchor.ts +28 -0
- package/src/window/apply-frame.ts +6 -4
- package/src/window/bootstrap-core.ts +165 -0
- package/src/window/bootstrap-mode.ts +23 -0
- package/src/window/bootstrap.ts +20 -103
- package/src/window/cover.ts +100 -0
- package/src/window/create-window.ts +4 -0
- package/src/window/dpi-awareness.ts +162 -0
- package/src/window/foreground-filter.ts +167 -0
- package/src/window/foreground-native.ts +91 -0
- package/src/window/foreground.ts +106 -0
- package/src/window/index.ts +2 -0
- package/src/window/native.ts +1 -1
- package/src/window/package-identity.ts +112 -0
- package/src/window/system-dispatcher-queue.ts +7 -2
- package/src/window/taskbar-native.ts +1 -2
- package/src/window/window-handle.ts +29 -1
- package/src/window/window-host.svelte.ts +59 -6
- package/web-types.json +11 -3
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { OperationProgressEvent } from "./progress-event.ts";
|
|
2
|
+
import { defaultProgressRegistry } from "./progress-registry.ts";
|
|
3
|
+
import type { ProgressRegistry } from "./progress-registry.ts";
|
|
4
|
+
import { CHANGE_EVENT, reactiveReads, subscribeTo } from "./progress-source.ts";
|
|
5
|
+
import type { ProgressSource } from "./progress-source.ts";
|
|
6
|
+
import { fractionOf, isUnfinished, ProgressState } from "./progress-state.ts";
|
|
7
|
+
import type { ProgressSnapshot } from "./progress-state.ts";
|
|
8
|
+
import { HandlerEventTarget } from "#src/web-apis/event-handlers.js";
|
|
9
|
+
|
|
10
|
+
const HANDLED_EVENTS = ["loadstart", "progress", "load", "error", "abort", "loadend"] as const;
|
|
11
|
+
const FINAL_EVENTS = {
|
|
12
|
+
[ProgressState.COMPLETE]: "load",
|
|
13
|
+
[ProgressState.ERROR]: "error",
|
|
14
|
+
[ProgressState.CANCELED]: "abort"
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
/** The event handlers an operation takes in its options, named as the DOM names `onprogress` and its kin. */
|
|
18
|
+
export interface ProgressHandlers {
|
|
19
|
+
readonly onloadstart?: (event: OperationProgressEvent) => void;
|
|
20
|
+
readonly onprogress?: (event: OperationProgressEvent) => void;
|
|
21
|
+
readonly onload?: (event: OperationProgressEvent) => void;
|
|
22
|
+
readonly onerror?: (event: OperationProgressEvent) => void;
|
|
23
|
+
readonly onabort?: (event: OperationProgressEvent) => void;
|
|
24
|
+
readonly onloadend?: (event: OperationProgressEvent) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** What `ProgressOperation` takes. */
|
|
28
|
+
export interface ProgressOperationOptions extends ProgressHandlers {
|
|
29
|
+
/** What the operation is, for a tray line or a window: a file name, "Copying". */
|
|
30
|
+
readonly label?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A name to scope by: `registry.where("sync")`, `<TaskbarProgress group="sync" />`
|
|
34
|
+
* and `<TrayMenuProgress group="sync" />` show only the operations of that group.
|
|
35
|
+
*/
|
|
36
|
+
readonly group?: string;
|
|
37
|
+
|
|
38
|
+
/** The whole size, when known up front; `update` can set it later. */
|
|
39
|
+
readonly total?: number;
|
|
40
|
+
|
|
41
|
+
/** Aborting it cancels the operation, as it cancels a `fetch`. */
|
|
42
|
+
readonly signal?: AbortSignal;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Where the operation lists itself so that `<TaskbarProgress />` and the
|
|
46
|
+
* tray lines see it: the app-wide registry by default, `false` for none.
|
|
47
|
+
*/
|
|
48
|
+
readonly registry?: ProgressRegistry | false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** What `ProgressBar` takes to show an operation. */
|
|
52
|
+
export interface ProgressBarValues {
|
|
53
|
+
readonly value: number;
|
|
54
|
+
readonly maximum: 1;
|
|
55
|
+
readonly isIndeterminate: boolean;
|
|
56
|
+
readonly showPaused: boolean;
|
|
57
|
+
readonly showError: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function markHandled() {
|
|
61
|
+
// Attached to the result so that an operation nobody awaits raises no unhandled rejection
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* One long operation (a download, a file read, a copy, an OCR pass), in one
|
|
66
|
+
* object that is
|
|
67
|
+
* - a promise: `await operation` gives the result and rejects on failure or
|
|
68
|
+
* cancel;
|
|
69
|
+
* - an `EventTarget` with the platform events: `loadstart`, `progress`,
|
|
70
|
+
* `load`, `error`, `abort` and `loadend` as `OperationProgressEvent`s, as
|
|
71
|
+
* `XMLHttpRequest` and `FileReader` fire them (and `onprogress` and kin as
|
|
72
|
+
* properties or options);
|
|
73
|
+
* - observable: `value`, `loaded`, `total`, `state`, `isIndeterminate`,
|
|
74
|
+
* `showPaused` and `showError` are reactive in markup (`barProps` spreads
|
|
75
|
+
* onto a `ProgressBar`), and it is a Svelte store (`$operation`);
|
|
76
|
+
* - cancelable: `cancel()`, or abort the `signal` given to it.
|
|
77
|
+
*
|
|
78
|
+
* It lists itself in the app-wide registry, so a mounted `<TaskbarProgress />`
|
|
79
|
+
* shows it with no setup. An errored operation can `resume` (a retry); the
|
|
80
|
+
* other final states are final.
|
|
81
|
+
*/
|
|
82
|
+
export class ProgressOperation<Result = void> extends HandlerEventTarget
|
|
83
|
+
implements ProgressSource, PromiseLike<Result> {
|
|
84
|
+
/** Aborts when the operation is canceled, or when the `signal` given to the constructor aborts. */
|
|
85
|
+
readonly signal: AbortSignal;
|
|
86
|
+
|
|
87
|
+
/** The group it was given, to scope a registry by. */
|
|
88
|
+
readonly group: string | undefined;
|
|
89
|
+
|
|
90
|
+
/** Settles with the operation: the value given to `complete`, or the reason of `fail` or `cancel`. */
|
|
91
|
+
readonly result: Promise<Result>;
|
|
92
|
+
private readonly controller = new AbortController();
|
|
93
|
+
private readonly reads = reactiveReads(this);
|
|
94
|
+
private readonly resolveResult: (value: Result) => void;
|
|
95
|
+
private readonly rejectResult: (reason: unknown) => void;
|
|
96
|
+
private current: ProgressSnapshot;
|
|
97
|
+
private currentState: ProgressState = ProgressState.IDLE;
|
|
98
|
+
private currentLoaded = 0;
|
|
99
|
+
private currentTotal: number | undefined;
|
|
100
|
+
private currentError: unknown;
|
|
101
|
+
private currentLabel: string | undefined;
|
|
102
|
+
|
|
103
|
+
constructor(options: ProgressOperationOptions = {}) {
|
|
104
|
+
super();
|
|
105
|
+
const deferred = Promise.withResolvers<Result>();
|
|
106
|
+
this.result = deferred.promise;
|
|
107
|
+
this.resolveResult = deferred.resolve;
|
|
108
|
+
this.rejectResult = deferred.reject;
|
|
109
|
+
this.result.catch(markHandled);
|
|
110
|
+
this.group = options.group;
|
|
111
|
+
this.currentLabel = options.label;
|
|
112
|
+
this.currentTotal = options.total;
|
|
113
|
+
const { signal: outside } = options;
|
|
114
|
+
this.signal = outside === undefined ? this.controller.signal : AbortSignal.any([this.controller.signal, outside]);
|
|
115
|
+
this.current = this.build();
|
|
116
|
+
for (const type of HANDLED_EVENTS) {
|
|
117
|
+
const handler = options[`on${type}`];
|
|
118
|
+
const isHandled = handler !== undefined;
|
|
119
|
+
if (isHandled) {
|
|
120
|
+
this.addEventListener(type, event => {
|
|
121
|
+
const isProgressEvent = event instanceof OperationProgressEvent;
|
|
122
|
+
if (isProgressEvent) {
|
|
123
|
+
handler(event);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const isListed = options.registry !== false;
|
|
130
|
+
if (isListed) {
|
|
131
|
+
(options.registry ?? defaultProgressRegistry()).add(this);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (this.signal.aborted) {
|
|
135
|
+
this.settle(ProgressState.CANCELED);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.signal.addEventListener("abort", () => this.settle(ProgressState.CANCELED), { once: true });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get snapshot() {
|
|
143
|
+
return this.current;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
get state() {
|
|
147
|
+
this.reads();
|
|
148
|
+
return this.current.state;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
get loaded() {
|
|
152
|
+
this.reads();
|
|
153
|
+
return this.current.loaded;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get total() {
|
|
157
|
+
this.reads();
|
|
158
|
+
return this.current.total;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** How far along, 0 to 1; `ProgressBar`'s `value` with a `maximum` of 1. Reactive. */
|
|
162
|
+
get value() {
|
|
163
|
+
this.reads();
|
|
164
|
+
return this.current.value;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
get isIndeterminate() {
|
|
168
|
+
this.reads();
|
|
169
|
+
return this.current.isIndeterminate;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
get showPaused() {
|
|
173
|
+
this.reads();
|
|
174
|
+
return this.current.showPaused;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
get showError() {
|
|
178
|
+
this.reads();
|
|
179
|
+
return this.current.showError;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Why it failed, once `state` is `error`. */
|
|
183
|
+
get error() {
|
|
184
|
+
this.reads();
|
|
185
|
+
return this.currentError;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** What the operation is. Reactive. */
|
|
189
|
+
get label() {
|
|
190
|
+
this.reads();
|
|
191
|
+
return this.currentLabel;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
set label(label: string | undefined) {
|
|
195
|
+
this.currentLabel = label;
|
|
196
|
+
this.publish();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** The values a `ProgressBar` takes, for `<ProgressBar {...operation.barProps} />`. Reactive. */
|
|
200
|
+
get barProps() {
|
|
201
|
+
this.reads();
|
|
202
|
+
const { current } = this;
|
|
203
|
+
return {
|
|
204
|
+
value: current.value,
|
|
205
|
+
maximum: 1,
|
|
206
|
+
isIndeterminate: current.isIndeterminate,
|
|
207
|
+
showPaused: current.showPaused,
|
|
208
|
+
showError: current.showError
|
|
209
|
+
} satisfies ProgressBarValues;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
get onloadstart() {
|
|
213
|
+
return this.getHandler("loadstart");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
set onloadstart(handler: EventListener | null) {
|
|
217
|
+
this.setHandler({
|
|
218
|
+
type: "loadstart",
|
|
219
|
+
handler
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
get onprogress() {
|
|
224
|
+
return this.getHandler("progress");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
set onprogress(handler: EventListener | null) {
|
|
228
|
+
this.setHandler({
|
|
229
|
+
type: "progress",
|
|
230
|
+
handler
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
get onload() {
|
|
235
|
+
return this.getHandler("load");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
set onload(handler: EventListener | null) {
|
|
239
|
+
this.setHandler({
|
|
240
|
+
type: "load",
|
|
241
|
+
handler
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
get onerror() {
|
|
246
|
+
return this.getHandler("error");
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
set onerror(handler: EventListener | null) {
|
|
250
|
+
this.setHandler({
|
|
251
|
+
type: "error",
|
|
252
|
+
handler
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
get onabort() {
|
|
257
|
+
return this.getHandler("abort");
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
set onabort(handler: EventListener | null) {
|
|
261
|
+
this.setHandler({
|
|
262
|
+
type: "abort",
|
|
263
|
+
handler
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
get onloadend() {
|
|
268
|
+
return this.getHandler("loadend");
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
set onloadend(handler: EventListener | null) {
|
|
272
|
+
this.setHandler({
|
|
273
|
+
type: "loadend",
|
|
274
|
+
handler
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Makes the operation awaitable: `await operation` is `await operation.result`.
|
|
280
|
+
*
|
|
281
|
+
* @param onfulfilled - Called with the result.
|
|
282
|
+
* @param onrejected - Called with the reason of a failure or cancel.
|
|
283
|
+
* @returns The promise of what the callbacks return.
|
|
284
|
+
*/
|
|
285
|
+
/* eslint-disable no-restricted-syntax -- then() has the two parameters PromiseLike dictates */
|
|
286
|
+
// oxlint-disable-next-line unicorn/no-thenable -- an operation is awaitable on purpose
|
|
287
|
+
then<Fulfilled = Result, Rejected = never>(
|
|
288
|
+
onfulfilled?: ((value: Result) => Fulfilled | PromiseLike<Fulfilled>) | null,
|
|
289
|
+
onrejected?: ((reason: unknown) => Rejected | PromiseLike<Rejected>) | null
|
|
290
|
+
) {
|
|
291
|
+
return this.result.then(onfulfilled, onrejected);
|
|
292
|
+
}
|
|
293
|
+
/* eslint-enable no-restricted-syntax */
|
|
294
|
+
|
|
295
|
+
subscribe(run: (snapshot: ProgressSnapshot) => void) {
|
|
296
|
+
return subscribeTo({
|
|
297
|
+
source: this,
|
|
298
|
+
run
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Marks the work as begun and fires `loadstart`; nothing happens unless the operation is idle. */
|
|
303
|
+
start() {
|
|
304
|
+
const isIdle = this.currentState === ProgressState.IDLE;
|
|
305
|
+
if (!isIdle) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
this.currentState = ProgressState.RUNNING;
|
|
310
|
+
this.publish();
|
|
311
|
+
this.fire("loadstart");
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Reports the work done and fires `progress`. Ignored unless the operation
|
|
316
|
+
* runs.
|
|
317
|
+
*
|
|
318
|
+
* @param options - How much is done, and the whole size when it became known.
|
|
319
|
+
*/
|
|
320
|
+
update({ loaded, total }: {
|
|
321
|
+
loaded: number;
|
|
322
|
+
total?: number | undefined;
|
|
323
|
+
}) {
|
|
324
|
+
const isRunning = this.currentState === ProgressState.RUNNING;
|
|
325
|
+
if (!isRunning) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
this.currentLoaded = loaded;
|
|
330
|
+
|
|
331
|
+
const isTotalKnown = total !== undefined;
|
|
332
|
+
if (isTotalKnown) {
|
|
333
|
+
this.currentTotal = total;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
this.publish();
|
|
337
|
+
this.fire("progress");
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Holds a running operation (the bar shows paused); `resume` continues it. */
|
|
341
|
+
pause() {
|
|
342
|
+
const isRunning = this.currentState === ProgressState.RUNNING;
|
|
343
|
+
if (!isRunning) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
this.currentState = ProgressState.PAUSED;
|
|
348
|
+
this.publish();
|
|
349
|
+
this.fire("pause");
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Continues a paused operation, or retries an errored one. */
|
|
353
|
+
resume() {
|
|
354
|
+
const isResumable = this.currentState === ProgressState.PAUSED || this.currentState === ProgressState.ERROR;
|
|
355
|
+
if (!isResumable) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
this.currentState = ProgressState.RUNNING;
|
|
360
|
+
this.currentError = undefined;
|
|
361
|
+
this.publish();
|
|
362
|
+
this.fire("resume");
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Ends it successfully: `load`, then `loadend`, and `await operation` gives `value`.
|
|
367
|
+
*
|
|
368
|
+
* @param value - The result.
|
|
369
|
+
*/
|
|
370
|
+
complete(value: Result) {
|
|
371
|
+
const isOpen = this.canSettle();
|
|
372
|
+
if (!isOpen) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
this.resolveResult(value);
|
|
377
|
+
this.settle(ProgressState.COMPLETE);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Ends it with a failure: `error`, then `loadend`, and `await operation` throws `reason`.
|
|
382
|
+
*
|
|
383
|
+
* @param reason - What went wrong, kept as `error`.
|
|
384
|
+
*/
|
|
385
|
+
fail(reason: unknown) {
|
|
386
|
+
const isOpen = this.canSettle();
|
|
387
|
+
if (!isOpen) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
this.currentError = reason;
|
|
392
|
+
this.rejectResult(reason);
|
|
393
|
+
this.settle(ProgressState.ERROR);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Ends it by request: aborts `signal`, which fires `abort` and `loadend`,
|
|
398
|
+
* and `await operation` throws the reason (an `AbortError` by default).
|
|
399
|
+
*
|
|
400
|
+
* @param reason - Given to the signal.
|
|
401
|
+
*/
|
|
402
|
+
cancel(reason?: unknown) {
|
|
403
|
+
this.controller.abort(reason);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
private canSettle() {
|
|
407
|
+
return isUnfinished(this.currentState);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
private settle(state: ProgressState) {
|
|
411
|
+
const isCancel = state === ProgressState.CANCELED;
|
|
412
|
+
const isOpen = this.canSettle() || isCancel && this.currentState === ProgressState.ERROR;
|
|
413
|
+
if (!isOpen) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (isCancel) {
|
|
418
|
+
this.rejectResult(this.signal.reason);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
this.currentState = state;
|
|
422
|
+
|
|
423
|
+
const isComplete = state === ProgressState.COMPLETE;
|
|
424
|
+
if (isComplete) {
|
|
425
|
+
this.currentLoaded = this.currentTotal ?? this.currentLoaded;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
this.publish();
|
|
429
|
+
const isFailure = state === ProgressState.ERROR;
|
|
430
|
+
const isFinishing = isComplete || isFailure;
|
|
431
|
+
const finalState = isFinishing ? state : ProgressState.CANCELED;
|
|
432
|
+
this.fire(FINAL_EVENTS[finalState]);
|
|
433
|
+
this.fire("loadend");
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
private fire(type: string) {
|
|
437
|
+
this.dispatchEvent(
|
|
438
|
+
new OperationProgressEvent(type, {
|
|
439
|
+
loaded: this.currentLoaded,
|
|
440
|
+
total: this.currentTotal
|
|
441
|
+
})
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
private publish() {
|
|
446
|
+
this.current = this.build();
|
|
447
|
+
this.dispatchEvent(new Event(CHANGE_EVENT));
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
private build() {
|
|
451
|
+
const state = this.currentState;
|
|
452
|
+
const isMoving = state === ProgressState.RUNNING || state === ProgressState.PAUSED;
|
|
453
|
+
const hasTotal = this.currentTotal !== undefined && this.currentTotal > 0;
|
|
454
|
+
return {
|
|
455
|
+
state,
|
|
456
|
+
count: isUnfinished(state) ? 1 : 0,
|
|
457
|
+
loaded: this.currentLoaded,
|
|
458
|
+
total: this.currentTotal,
|
|
459
|
+
value: state === ProgressState.COMPLETE ? 1 : fractionOf({
|
|
460
|
+
loaded: this.currentLoaded,
|
|
461
|
+
total: this.currentTotal
|
|
462
|
+
}),
|
|
463
|
+
isIndeterminate: isMoving && !hasTotal,
|
|
464
|
+
showPaused: state === ProgressState.PAUSED,
|
|
465
|
+
showError: state === ProgressState.ERROR,
|
|
466
|
+
label: this.currentLabel
|
|
467
|
+
} satisfies ProgressSnapshot;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { aggregateSnapshots } from "./aggregate.ts";
|
|
2
|
+
import { CHANGE_EVENT, reactiveReads, subscribeTo } from "./progress-source.ts";
|
|
3
|
+
import type { ProgressSource, TrackedOperation } from "./progress-source.ts";
|
|
4
|
+
import { ProgressState } from "./progress-state.ts";
|
|
5
|
+
import type { ProgressSnapshot } from "./progress-state.ts";
|
|
6
|
+
|
|
7
|
+
/** What a scope keeps: a group name, or a test of each operation. */
|
|
8
|
+
export type ProgressFilter = string | ((operation: TrackedOperation) => boolean);
|
|
9
|
+
|
|
10
|
+
/** What `ProgressRegistry` takes; `where` makes the scoped kind. */
|
|
11
|
+
interface ProgressRegistryOptions {
|
|
12
|
+
readonly parent?: ProgressRegistry;
|
|
13
|
+
readonly filter?: ProgressFilter;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function matcherOf(filter: ProgressFilter) {
|
|
17
|
+
const isGroup = typeof filter === "string";
|
|
18
|
+
if (isGroup) {
|
|
19
|
+
return (operation: TrackedOperation) => operation.group === filter;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return filter;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The operations that are running now, as one source: the overall bar for a
|
|
27
|
+
* taskbar button and the count for a tray line. Operations list themselves
|
|
28
|
+
* here (the app-wide one, `defaultProgressRegistry()`, unless told otherwise);
|
|
29
|
+
* a finished one leaves, a failed one stays until `clearFailed` or `remove`,
|
|
30
|
+
* so a red bar is not lost. It fires `add`, `remove` and `change`
|
|
31
|
+
* (a `CustomEvent` whose `detail` is the operation, except for `change`).
|
|
32
|
+
*
|
|
33
|
+
* `where` scopes it by group or by test, which is how tray icon A shows the
|
|
34
|
+
* downloads and tray icon B the uploads, and each window's taskbar button
|
|
35
|
+
* shows its own work.
|
|
36
|
+
*/
|
|
37
|
+
export class ProgressRegistry extends EventTarget implements ProgressSource {
|
|
38
|
+
private readonly parent: ProgressRegistry | undefined;
|
|
39
|
+
private readonly matches: ((operation: TrackedOperation) => boolean) | undefined;
|
|
40
|
+
private readonly held = new Set<TrackedOperation>();
|
|
41
|
+
private readonly reads = reactiveReads(this);
|
|
42
|
+
private list: readonly TrackedOperation[] = [];
|
|
43
|
+
private current: ProgressSnapshot = aggregateSnapshots([]);
|
|
44
|
+
private readonly onParentChange = () => this.refresh();
|
|
45
|
+
|
|
46
|
+
/** Made by `where`, or by an app that wants a registry of its own. */
|
|
47
|
+
constructor(options: ProgressRegistryOptions = {}) {
|
|
48
|
+
super();
|
|
49
|
+
this.parent = options.parent;
|
|
50
|
+
this.matches = options.filter === undefined ? undefined : matcherOf(options.filter);
|
|
51
|
+
this.parent?.addEventListener(CHANGE_EVENT, this.onParentChange);
|
|
52
|
+
this.refresh();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The operations in the registry, oldest first. Reactive. */
|
|
56
|
+
get operations() {
|
|
57
|
+
this.reads();
|
|
58
|
+
return this.list;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get snapshot() {
|
|
62
|
+
return this.current;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** How far along, 0 to 1, over the operations that know their total. Reactive. */
|
|
66
|
+
get value() {
|
|
67
|
+
this.reads();
|
|
68
|
+
return this.current.value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** How many operations are unfinished. Reactive. */
|
|
72
|
+
get count() {
|
|
73
|
+
this.reads();
|
|
74
|
+
return this.current.count;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get state() {
|
|
78
|
+
this.reads();
|
|
79
|
+
return this.current.state;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get isIndeterminate() {
|
|
83
|
+
this.reads();
|
|
84
|
+
return this.current.isIndeterminate;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get showPaused() {
|
|
88
|
+
this.reads();
|
|
89
|
+
return this.current.showPaused;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get showError() {
|
|
93
|
+
this.reads();
|
|
94
|
+
return this.current.showError;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The five values a `ProgressBar` takes, for `<ProgressBar {...registry.barProps} />`. Reactive. */
|
|
98
|
+
get barProps() {
|
|
99
|
+
this.reads();
|
|
100
|
+
const { current } = this;
|
|
101
|
+
return {
|
|
102
|
+
value: current.value,
|
|
103
|
+
maximum: 1,
|
|
104
|
+
isIndeterminate: current.isIndeterminate,
|
|
105
|
+
showPaused: current.showPaused,
|
|
106
|
+
showError: current.showError
|
|
107
|
+
} as const;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
subscribe(run: (snapshot: ProgressSnapshot) => void) {
|
|
111
|
+
return subscribeTo({
|
|
112
|
+
source: this,
|
|
113
|
+
run
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A view of the operations that pass `filter`: it follows this registry and
|
|
119
|
+
* is a source of its own. Call `dispose` when it is no longer used.
|
|
120
|
+
*
|
|
121
|
+
* @param filter - A group name, or a test of each operation.
|
|
122
|
+
* @returns The scoped registry.
|
|
123
|
+
*/
|
|
124
|
+
where(filter: ProgressFilter) {
|
|
125
|
+
return new ProgressRegistry({
|
|
126
|
+
parent: this,
|
|
127
|
+
filter
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Lists an operation; a scoped registry lists it in the registry it follows.
|
|
133
|
+
*
|
|
134
|
+
* @param operation - The operation to show.
|
|
135
|
+
* @returns The operation.
|
|
136
|
+
*/
|
|
137
|
+
add(operation: TrackedOperation) {
|
|
138
|
+
const isScoped = this.parent !== undefined;
|
|
139
|
+
if (isScoped) {
|
|
140
|
+
this.parent.add(operation);
|
|
141
|
+
return operation;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const isHeld = this.held.has(operation);
|
|
145
|
+
if (isHeld) {
|
|
146
|
+
return operation;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
this.held.add(operation);
|
|
150
|
+
operation.addEventListener(CHANGE_EVENT, this.onParentChange);
|
|
151
|
+
operation.addEventListener("loadend", this.onEnd);
|
|
152
|
+
this.dispatchEvent(new CustomEvent("add", { detail: operation }));
|
|
153
|
+
this.refresh();
|
|
154
|
+
return operation;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Takes an operation out, whatever its state.
|
|
159
|
+
*
|
|
160
|
+
* @param operation - The operation to forget.
|
|
161
|
+
*/
|
|
162
|
+
remove(operation: TrackedOperation) {
|
|
163
|
+
const isScoped = this.parent !== undefined;
|
|
164
|
+
if (isScoped) {
|
|
165
|
+
this.parent.remove(operation);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const isHeld = this.held.delete(operation);
|
|
170
|
+
if (!isHeld) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
operation.removeEventListener(CHANGE_EVENT, this.onParentChange);
|
|
175
|
+
operation.removeEventListener("loadend", this.onEnd);
|
|
176
|
+
this.dispatchEvent(new CustomEvent("remove", { detail: operation }));
|
|
177
|
+
this.refresh();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Takes the failed operations out, which turns a red bar off. */
|
|
181
|
+
clearFailed() {
|
|
182
|
+
for (const operation of this.list) {
|
|
183
|
+
const isFailed = operation.state === ProgressState.ERROR;
|
|
184
|
+
if (isFailed) {
|
|
185
|
+
this.remove(operation);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Stops following the registry a scoped one was made from. */
|
|
191
|
+
dispose() {
|
|
192
|
+
this.parent?.removeEventListener(CHANGE_EVENT, this.onParentChange);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private readonly onEnd = (event: Event) => {
|
|
196
|
+
const { target } = event;
|
|
197
|
+
const operation = [...this.held].find(candidate => candidate === target);
|
|
198
|
+
const isGone = operation !== undefined && operation.state !== ProgressState.ERROR;
|
|
199
|
+
if (isGone) {
|
|
200
|
+
this.remove(operation);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
private refresh() {
|
|
205
|
+
const source = this.parent === undefined ? [...this.held] : this.parent.list;
|
|
206
|
+
const { matches } = this;
|
|
207
|
+
this.list = matches === undefined ? source : source.filter(matches);
|
|
208
|
+
this.current = aggregateSnapshots(this.list.map(operation => operation.snapshot));
|
|
209
|
+
this.dispatchEvent(new Event(CHANGE_EVENT));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
let shared: ProgressRegistry | undefined;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The app-wide registry, made on first use: every operation lists itself here
|
|
217
|
+
* unless it is given another.
|
|
218
|
+
*
|
|
219
|
+
* @returns The registry.
|
|
220
|
+
*/
|
|
221
|
+
export function defaultProgressRegistry() {
|
|
222
|
+
shared ??= new ProgressRegistry();
|
|
223
|
+
return shared;
|
|
224
|
+
}
|