winui-svelte 0.0.6 → 0.0.7
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 +390 -3
- package/README.md +4 -0
- 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/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 +595 -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-managed +1 -1
- package/dist/chrome/context-menus/context-menu-schema.d.ts +4 -4
- package/dist/chrome/notifications/notification-schema.d.ts +2 -2
- package/dist/components/hand-written/Window.svelte +2 -0
- 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/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 +1 -0
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +1 -0
- package/dist/enums.js.map +1 -1
- package/dist/forms/form-field-props.d.ts +2 -2
- 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/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 +5 -5
- 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 +6 -1
- package/dist/tray/native.d.ts.map +1 -1
- package/dist/tray/native.js +22 -32
- package/dist/tray/native.js.map +1 -1
- 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/index.d.ts +1 -0
- package/dist/tray/standalone/index.d.ts.map +1 -1
- package/dist/tray/standalone/index.js +1 -0
- package/dist/tray/standalone/index.js.map +1 -1
- 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 +5 -1
- package/dist/tray/standalone/native.d.ts.map +1 -1
- package/dist/tray/standalone/native.js +5 -1
- package/dist/tray/standalone/native.js.map +1 -1
- package/dist/tray/standalone/standalone-tray.d.ts +13 -0
- package/dist/tray/standalone/standalone-tray.d.ts.map +1 -1
- package/dist/tray/standalone/standalone-tray.js +23 -1
- package/dist/tray/standalone/standalone-tray.js.map +1 -1
- package/dist/tray/tray-core.d.ts.map +1 -1
- package/dist/tray/tray-core.js +1 -0
- package/dist/tray/tray-core.js.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/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/win32-foreground.d.ts +14 -0
- package/dist/win32-foreground.d.ts.map +1 -0
- package/dist/win32-foreground.js +71 -0
- package/dist/win32-foreground.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 +1 -0
- package/dist/window/create-window.js.map +1 -1
- 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 +88 -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/window-host.svelte.d.ts +1 -1
- package/dist/window/window-host.svelte.d.ts.map +1 -1
- package/package.json +18 -1
- package/src/app/launch-command.ts +19 -5
- 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 +689 -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/components/window-context.ts +23 -0
- 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 +1 -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/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 +29 -33
- package/src/tray/pointer-share.ts +71 -0
- package/src/tray/standalone/index.ts +1 -0
- package/src/tray/standalone/menu-theme.ts +90 -0
- package/src/tray/standalone/native.ts +5 -1
- package/src/tray/standalone/standalone-tray.ts +43 -1
- package/src/tray/tray-core.ts +1 -0
- 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/file-read.ts +43 -0
- package/src/web-apis/file-system.ts +33 -0
- package/src/win32-foreground.ts +76 -0
- package/src/window/create-window.ts +2 -0
- package/src/window/foreground-filter.ts +167 -0
- package/src/window/foreground-native.ts +93 -0
- package/src/window/foreground.ts +106 -0
- package/src/window/window-host.svelte.ts +1 -1
- package/web-types.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ProgressSnapshot, ProgressState } from "./progress-state.js";
|
|
2
|
+
/** The event both an operation and the registry fire after any change of their snapshot. */
|
|
3
|
+
export declare const CHANGE_EVENT = "change";
|
|
4
|
+
/**
|
|
5
|
+
* Anything with a progress to show: one `ProgressOperation` or a
|
|
6
|
+
* `ProgressRegistry`. It is an `EventTarget` that fires `change`, a Svelte
|
|
7
|
+
* store (`$source`), and its getters are reactive in a component or `$effect`.
|
|
8
|
+
*/
|
|
9
|
+
export interface ProgressSource extends EventTarget {
|
|
10
|
+
/** The latest state; the same object until something changes. */
|
|
11
|
+
readonly snapshot: ProgressSnapshot;
|
|
12
|
+
/**
|
|
13
|
+
* Calls `run` with the snapshot now and after every change.
|
|
14
|
+
*
|
|
15
|
+
* @param run - The listener.
|
|
16
|
+
* @returns Stops the calls.
|
|
17
|
+
*/
|
|
18
|
+
subscribe(run: (snapshot: ProgressSnapshot) => void): () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The `subscribe` of a source: the store contract over its `change` event.
|
|
22
|
+
*
|
|
23
|
+
* @param options - The source and the listener.
|
|
24
|
+
* @returns Stops the calls.
|
|
25
|
+
*/
|
|
26
|
+
export declare function subscribeTo({ source, run }: {
|
|
27
|
+
source: ProgressSource;
|
|
28
|
+
run: (snapshot: ProgressSnapshot) => void;
|
|
29
|
+
}): () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Makes a source getters reactive: call the result inside each getter.
|
|
32
|
+
* Outside an effect, and under Node, it does nothing.
|
|
33
|
+
*
|
|
34
|
+
* @param source - The source whose `change` events invalidate a reader.
|
|
35
|
+
* @returns The function to call before reading.
|
|
36
|
+
*/
|
|
37
|
+
export declare function reactiveReads(source: EventTarget): () => void;
|
|
38
|
+
/** An operation as the registry sees it, whatever it resolves to. */
|
|
39
|
+
export interface TrackedOperation extends ProgressSource {
|
|
40
|
+
readonly group: string | undefined;
|
|
41
|
+
readonly state: ProgressState;
|
|
42
|
+
readonly label: string | undefined;
|
|
43
|
+
/** Stops the operation. */
|
|
44
|
+
cancel(reason?: unknown): void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=progress-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-source.d.ts","sourceRoot":"","sources":["../../src/progress/progress-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG3E,4FAA4F;AAC5F,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC;;;;GAIG;AACH,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAEpC;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAClE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;IAC3C,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC3C,cAQA;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,cAKhD;AAED,qEAAqE;AACrE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC,2BAA2B;IAC3B,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createSubscriber } from "svelte/reactivity";
|
|
2
|
+
/** The event both an operation and the registry fire after any change of their snapshot. */
|
|
3
|
+
export const CHANGE_EVENT = "change";
|
|
4
|
+
/**
|
|
5
|
+
* The `subscribe` of a source: the store contract over its `change` event.
|
|
6
|
+
*
|
|
7
|
+
* @param options - The source and the listener.
|
|
8
|
+
* @returns Stops the calls.
|
|
9
|
+
*/
|
|
10
|
+
export function subscribeTo({ source, run }) {
|
|
11
|
+
function listener() {
|
|
12
|
+
run(source.snapshot);
|
|
13
|
+
}
|
|
14
|
+
source.addEventListener(CHANGE_EVENT, listener);
|
|
15
|
+
run(source.snapshot);
|
|
16
|
+
return () => source.removeEventListener(CHANGE_EVENT, listener);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Makes a source getters reactive: call the result inside each getter.
|
|
20
|
+
* Outside an effect, and under Node, it does nothing.
|
|
21
|
+
*
|
|
22
|
+
* @param source - The source whose `change` events invalidate a reader.
|
|
23
|
+
* @returns The function to call before reading.
|
|
24
|
+
*/
|
|
25
|
+
export function reactiveReads(source) {
|
|
26
|
+
return createSubscriber(update => {
|
|
27
|
+
source.addEventListener(CHANGE_EVENT, update);
|
|
28
|
+
return () => source.removeEventListener(CHANGE_EVENT, update);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=progress-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-source.js","sourceRoot":"","sources":["../../src/progress/progress-source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AAoBrC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,EAGxC;IACC,SAAS,QAAQ;QACf,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAChD,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrB,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAAmB;IAC/C,OAAO,gBAAgB,CAAC,MAAM,CAAC,EAAE;QAC/B,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where an operation is, in the words WinUI's `ProgressBar` and the taskbar
|
|
3
|
+
* button use: running, paused, failed; `idle` before it starts.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ProgressState: {
|
|
6
|
+
readonly IDLE: "idle";
|
|
7
|
+
readonly RUNNING: "running";
|
|
8
|
+
readonly PAUSED: "paused";
|
|
9
|
+
readonly COMPLETE: "complete";
|
|
10
|
+
readonly ERROR: "error";
|
|
11
|
+
readonly CANCELED: "canceled";
|
|
12
|
+
};
|
|
13
|
+
/** One of the values of `ProgressState`. */
|
|
14
|
+
export type ProgressState = (typeof ProgressState)[keyof typeof ProgressState];
|
|
15
|
+
/**
|
|
16
|
+
* What a subscriber reads from an operation or from the registry. The
|
|
17
|
+
* `value`, `isIndeterminate`, `showPaused` and `showError` members have the
|
|
18
|
+
* names and meaning of `ProgressBar`'s properties (with `maximum` of 1).
|
|
19
|
+
*/
|
|
20
|
+
export interface ProgressSnapshot {
|
|
21
|
+
readonly state: ProgressState;
|
|
22
|
+
/** How many operations are unfinished: 0 or 1 for one operation. */
|
|
23
|
+
readonly count: number;
|
|
24
|
+
/** Bytes (or units) done; summed over the operations that know their total, for the registry. */
|
|
25
|
+
readonly loaded: number;
|
|
26
|
+
/** The whole size, or undefined while unknown. */
|
|
27
|
+
readonly total: number | undefined;
|
|
28
|
+
/** How far along, 0 to 1; 1 once complete. */
|
|
29
|
+
readonly value: number;
|
|
30
|
+
/** True while the total is unknown: a marquee, not a bar. */
|
|
31
|
+
readonly isIndeterminate: boolean;
|
|
32
|
+
readonly showPaused: boolean;
|
|
33
|
+
readonly showError: boolean;
|
|
34
|
+
/** What the operation is, when exactly one is unfinished. */
|
|
35
|
+
readonly label: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether an operation has not reached a final state yet.
|
|
39
|
+
*
|
|
40
|
+
* @param state - The state to test.
|
|
41
|
+
* @returns True for idle, running and paused.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isUnfinished(state: ProgressState): state is "idle" | "paused" | "running";
|
|
44
|
+
/**
|
|
45
|
+
* How far along, clamped to 0..1.
|
|
46
|
+
*
|
|
47
|
+
* @param options - The work done and the whole size.
|
|
48
|
+
* @returns 0 when the total is unknown or zero.
|
|
49
|
+
*/
|
|
50
|
+
export declare function fractionOf({ loaded, total }: {
|
|
51
|
+
loaded: number;
|
|
52
|
+
total: number | undefined;
|
|
53
|
+
}): number;
|
|
54
|
+
//# sourceMappingURL=progress-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-state.d.ts","sourceRoot":"","sources":["../../src/progress/progress-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AAEX,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAE9B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,iGAAiG;IACjG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,6DAA6D;IAC7D,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,0CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,UAOA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where an operation is, in the words WinUI's `ProgressBar` and the taskbar
|
|
3
|
+
* button use: running, paused, failed; `idle` before it starts.
|
|
4
|
+
*/
|
|
5
|
+
export const ProgressState = {
|
|
6
|
+
IDLE: "idle",
|
|
7
|
+
RUNNING: "running",
|
|
8
|
+
PAUSED: "paused",
|
|
9
|
+
COMPLETE: "complete",
|
|
10
|
+
ERROR: "error",
|
|
11
|
+
CANCELED: "canceled"
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Whether an operation has not reached a final state yet.
|
|
15
|
+
*
|
|
16
|
+
* @param state - The state to test.
|
|
17
|
+
* @returns True for idle, running and paused.
|
|
18
|
+
*/
|
|
19
|
+
export function isUnfinished(state) {
|
|
20
|
+
return state === ProgressState.IDLE || state === ProgressState.RUNNING || state === ProgressState.PAUSED;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* How far along, clamped to 0..1.
|
|
24
|
+
*
|
|
25
|
+
* @param options - The work done and the whole size.
|
|
26
|
+
* @returns 0 when the total is unknown or zero.
|
|
27
|
+
*/
|
|
28
|
+
export function fractionOf({ loaded, total }) {
|
|
29
|
+
const isUnknown = total === undefined || total <= 0;
|
|
30
|
+
if (isUnknown) {
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
return Math.min(1, Math.max(0, loaded / total));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=progress-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-state.js","sourceRoot":"","sources":["../../src/progress/progress-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;CACZ,CAAC;AAkCX;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAoB;IAC/C,OAAO,KAAK,KAAK,aAAa,CAAC,IAAI,IAAI,KAAK,KAAK,aAAa,CAAC,OAAO,IAAI,KAAK,KAAK,aAAa,CAAC,MAAM,CAAC;AAC3G,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,EAGzC;IACC,MAAM,SAAS,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,IAAI,CAAC,CAAC;IACpD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProgressSnapshot } from "./progress-state.js";
|
|
2
|
+
/**
|
|
3
|
+
* A line for a menu or a status area: "setup.exe - 45%", "3 operations - 12%",
|
|
4
|
+
* "setup.exe - paused", "setup.exe - failed". A marquee has no percent.
|
|
5
|
+
*
|
|
6
|
+
* @param snapshot - The state to describe.
|
|
7
|
+
* @returns The text.
|
|
8
|
+
*/
|
|
9
|
+
export declare function progressText(snapshot: ProgressSnapshot): string;
|
|
10
|
+
//# sourceMappingURL=progress-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-text.d.ts","sourceRoot":"","sources":["../../src/progress/progress-text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI5D;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,UActD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ProgressState } from "./progress-state.js";
|
|
2
|
+
const PERCENT = 100;
|
|
3
|
+
/**
|
|
4
|
+
* A line for a menu or a status area: "setup.exe - 45%", "3 operations - 12%",
|
|
5
|
+
* "setup.exe - paused", "setup.exe - failed". A marquee has no percent.
|
|
6
|
+
*
|
|
7
|
+
* @param snapshot - The state to describe.
|
|
8
|
+
* @returns The text.
|
|
9
|
+
*/
|
|
10
|
+
export function progressText(snapshot) {
|
|
11
|
+
const { count, label, state, value, isIndeterminate } = snapshot;
|
|
12
|
+
const name = count > 1 ? `${count} operations` : label ?? "Working";
|
|
13
|
+
const isFailed = state === ProgressState.ERROR;
|
|
14
|
+
if (isFailed) {
|
|
15
|
+
return `${name} - failed`;
|
|
16
|
+
}
|
|
17
|
+
const isPaused = state === ProgressState.PAUSED;
|
|
18
|
+
if (isPaused) {
|
|
19
|
+
return `${name} - paused`;
|
|
20
|
+
}
|
|
21
|
+
return isIndeterminate ? name : `${name} - ${Math.round(value * PERCENT)}%`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=progress-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-text.js","sourceRoot":"","sources":["../../src/progress/progress-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,QAA0B;IACrD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC;IACjE,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC;IACpE,MAAM,QAAQ,GAAG,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC;IAC/C,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,GAAG,IAAI,WAAW,CAAC;IAC5B,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,KAAK,aAAa,CAAC,MAAM,CAAC;IAChD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,GAAG,IAAI,WAAW,CAAC;IAC5B,CAAC;IAED,OAAO,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ProgressRegistry } from "./progress-registry.js";
|
|
2
|
+
import type { ProgressSource } from "./progress-source.js";
|
|
3
|
+
/**
|
|
4
|
+
* The registry a component lists: `of` when given, else the operations of
|
|
5
|
+
* `group`, else every running operation.
|
|
6
|
+
*
|
|
7
|
+
* @param options - The `of` and `group` props.
|
|
8
|
+
* @returns The registry, and what to call when the component goes away.
|
|
9
|
+
*/
|
|
10
|
+
export declare function scopedRegistry({ of, group }: {
|
|
11
|
+
of: ProgressRegistry | undefined;
|
|
12
|
+
group: string | undefined;
|
|
13
|
+
}): {
|
|
14
|
+
registry: ProgressRegistry;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The source a component shows: `of` when given (one operation or a
|
|
19
|
+
* registry), else the operations of `group`, else every running operation.
|
|
20
|
+
*
|
|
21
|
+
* @param options - The `of` and `group` props.
|
|
22
|
+
* @returns The source, and what to call when the component goes away.
|
|
23
|
+
*/
|
|
24
|
+
export declare function scopedSource({ of, group }: {
|
|
25
|
+
of: ProgressSource | undefined;
|
|
26
|
+
group: string | undefined;
|
|
27
|
+
}): {
|
|
28
|
+
source: ProgressSource;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=scoped-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-source.d.ts","sourceRoot":"","sources":["../../src/progress/scoped-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAC5C,EAAE,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACjC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;;;EAUA;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAC1C,EAAE,EAAE,cAAc,GAAG,SAAS,CAAC;IAC/B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;;;EAmBA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defaultProgressRegistry } from "./progress-registry.js";
|
|
2
|
+
/**
|
|
3
|
+
* The registry a component lists: `of` when given, else the operations of
|
|
4
|
+
* `group`, else every running operation.
|
|
5
|
+
*
|
|
6
|
+
* @param options - The `of` and `group` props.
|
|
7
|
+
* @returns The registry, and what to call when the component goes away.
|
|
8
|
+
*/
|
|
9
|
+
export function scopedRegistry({ of, group }) {
|
|
10
|
+
const registry = of ?? defaultProgressRegistry();
|
|
11
|
+
const isScoped = group !== undefined;
|
|
12
|
+
const scope = isScoped ? registry.where(group) : undefined;
|
|
13
|
+
return {
|
|
14
|
+
registry: scope ?? registry,
|
|
15
|
+
dispose() {
|
|
16
|
+
scope?.dispose();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The source a component shows: `of` when given (one operation or a
|
|
22
|
+
* registry), else the operations of `group`, else every running operation.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The `of` and `group` props.
|
|
25
|
+
* @returns The source, and what to call when the component goes away.
|
|
26
|
+
*/
|
|
27
|
+
export function scopedSource({ of, group }) {
|
|
28
|
+
const isGiven = of !== undefined;
|
|
29
|
+
const scoped = scopedRegistry({
|
|
30
|
+
of: undefined,
|
|
31
|
+
group
|
|
32
|
+
});
|
|
33
|
+
if (isGiven) {
|
|
34
|
+
return {
|
|
35
|
+
source: of,
|
|
36
|
+
dispose() {
|
|
37
|
+
scoped.dispose();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
source: scoped.registry,
|
|
43
|
+
dispose: scoped.dispose
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=scoped-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-source.js","sourceRoot":"","sources":["../../src/progress/scoped-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAIjE;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,EAAE,EAAE,KAAK,EAGzC;IACC,MAAM,QAAQ,GAAG,EAAE,IAAI,uBAAuB,EAAE,CAAC;IACjD,MAAM,QAAQ,GAAG,KAAK,KAAK,SAAS,CAAC;IACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3D,OAAO;QACL,QAAQ,EAAE,KAAK,IAAI,QAAQ;QAC3B,OAAO;YACL,KAAK,EAAE,OAAO,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,EAAE,EAAE,KAAK,EAGvC;IACC,MAAM,OAAO,GAAG,EAAE,KAAK,SAAS,CAAC;IACjC,MAAM,MAAM,GAAG,cAAc,CAAC;QAC5B,EAAE,EAAE,SAAS;QACb,KAAK;KACN,CAAC,CAAC;IACH,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO;YACL,MAAM,EAAE,EAAE;YACV,OAAO;gBACL,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,QAAQ;QACvB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ProgressSource } from "./progress-source.js";
|
|
2
|
+
import type { TaskbarProgressTarget } from "./taskbar-progress.js";
|
|
3
|
+
import type { WindowHandle } from "../window/window-handle.js";
|
|
4
|
+
/** The props of `TaskbarProgress`. */
|
|
5
|
+
export interface TaskbarProgressProps {
|
|
6
|
+
/** What to show: an operation or a registry; every running operation (the app-wide registry) when left out. */
|
|
7
|
+
readonly of?: ProgressSource;
|
|
8
|
+
/** Shows only the operations of this group, when `of` is left out. */
|
|
9
|
+
readonly group?: string;
|
|
10
|
+
/** The window whose taskbar button shows it; the window this is mounted in when left out. */
|
|
11
|
+
readonly window?: WindowHandle;
|
|
12
|
+
/** A taskbar button to drive directly, such as one `handle.taskbar` gave. */
|
|
13
|
+
readonly taskbar?: TaskbarProgressTarget;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=taskbar-progress-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskbar-progress-props.d.ts","sourceRoot":"","sources":["../../src/progress/taskbar-progress-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,sCAAsC;AACtC,MAAM,WAAW,oBAAoB;IACnC,+GAA+G;IAC/G,QAAQ,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC;IAE7B,sEAAsE;IACtE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAE/B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskbar-progress-props.js","sourceRoot":"","sources":["../../src/progress/taskbar-progress-props.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ProgressSource } from "./progress-source.js";
|
|
2
|
+
import type { ProgressSnapshot } from "./progress-state.js";
|
|
3
|
+
import type { TaskbarProgressOptions } from "../window/taskbar-calls.js";
|
|
4
|
+
/** The part of a window taskbar button that a progress drives: `handle.taskbar` fits. */
|
|
5
|
+
export interface TaskbarProgressTarget {
|
|
6
|
+
setProgress(options: TaskbarProgressOptions): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* What the taskbar button shows for a snapshot, with the same meaning as a
|
|
10
|
+
* `ProgressBar`: a bar that fills, a marquee when the total is unknown, yellow
|
|
11
|
+
* when paused, red on error, gone when nothing is left.
|
|
12
|
+
*
|
|
13
|
+
* @param snapshot - The state to show.
|
|
14
|
+
* @returns The options for `setProgress`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function taskbarOptionsOf(snapshot: ProgressSnapshot): {
|
|
17
|
+
state: "error";
|
|
18
|
+
value?: never;
|
|
19
|
+
} | {
|
|
20
|
+
state: "paused";
|
|
21
|
+
value: number;
|
|
22
|
+
} | {
|
|
23
|
+
state: "none";
|
|
24
|
+
value?: never;
|
|
25
|
+
} | {
|
|
26
|
+
state: "indeterminate";
|
|
27
|
+
value?: never;
|
|
28
|
+
} | {
|
|
29
|
+
state: "normal";
|
|
30
|
+
value: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Shows a source on a taskbar button until the returned function is called;
|
|
34
|
+
* the shell is told only when the bar moves by a step (a thousandth) or the
|
|
35
|
+
* state changes. `<TaskbarProgress />` is this in markup.
|
|
36
|
+
*
|
|
37
|
+
* @param options - The operation or registry, and the window taskbar button.
|
|
38
|
+
* @returns Stops following the source and clears the bar.
|
|
39
|
+
*/
|
|
40
|
+
export declare function bindTaskbarProgress({ source, taskbar }: {
|
|
41
|
+
source: ProgressSource;
|
|
42
|
+
taskbar: TaskbarProgressTarget;
|
|
43
|
+
}): () => void;
|
|
44
|
+
//# sourceMappingURL=taskbar-progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskbar-progress.d.ts","sourceRoot":"","sources":["../../src/progress/taskbar-progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAK3E,yFAAyF;AACzF,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACpD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB;;;;;;;;;;;;;;;EA4B1D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IACvD,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,qBAAqB,CAAC;CAChC,cAiBA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ProgressState } from "./progress-state.js";
|
|
2
|
+
import { TaskbarProgressState } from "../window/taskbar-calls.js";
|
|
3
|
+
const PROGRESS_STEPS = 1000;
|
|
4
|
+
/**
|
|
5
|
+
* What the taskbar button shows for a snapshot, with the same meaning as a
|
|
6
|
+
* `ProgressBar`: a bar that fills, a marquee when the total is unknown, yellow
|
|
7
|
+
* when paused, red on error, gone when nothing is left.
|
|
8
|
+
*
|
|
9
|
+
* @param snapshot - The state to show.
|
|
10
|
+
* @returns The options for `setProgress`.
|
|
11
|
+
*/
|
|
12
|
+
export function taskbarOptionsOf(snapshot) {
|
|
13
|
+
const { state, value, isIndeterminate } = snapshot;
|
|
14
|
+
const isFailed = state === ProgressState.ERROR;
|
|
15
|
+
if (isFailed) {
|
|
16
|
+
return { state: TaskbarProgressState.ERROR };
|
|
17
|
+
}
|
|
18
|
+
const isPaused = state === ProgressState.PAUSED;
|
|
19
|
+
if (isPaused) {
|
|
20
|
+
return {
|
|
21
|
+
state: TaskbarProgressState.PAUSED,
|
|
22
|
+
value
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const isNotRunning = state !== ProgressState.RUNNING;
|
|
26
|
+
if (isNotRunning) {
|
|
27
|
+
return { state: TaskbarProgressState.NONE };
|
|
28
|
+
}
|
|
29
|
+
if (isIndeterminate) {
|
|
30
|
+
return { state: TaskbarProgressState.INDETERMINATE };
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
state: TaskbarProgressState.NORMAL,
|
|
34
|
+
value
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Shows a source on a taskbar button until the returned function is called;
|
|
39
|
+
* the shell is told only when the bar moves by a step (a thousandth) or the
|
|
40
|
+
* state changes. `<TaskbarProgress />` is this in markup.
|
|
41
|
+
*
|
|
42
|
+
* @param options - The operation or registry, and the window taskbar button.
|
|
43
|
+
* @returns Stops following the source and clears the bar.
|
|
44
|
+
*/
|
|
45
|
+
export function bindTaskbarProgress({ source, taskbar }) {
|
|
46
|
+
let lastKey = `${TaskbarProgressState.NONE}:0`;
|
|
47
|
+
const stop = source.subscribe(snapshot => {
|
|
48
|
+
const options = taskbarOptionsOf(snapshot);
|
|
49
|
+
const key = `${options.state}:${Math.floor(("value" in options ? options.value : 0) * PROGRESS_STEPS)}`;
|
|
50
|
+
const isSame = key === lastKey;
|
|
51
|
+
if (isSame) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
lastKey = key;
|
|
55
|
+
taskbar.setProgress(options);
|
|
56
|
+
});
|
|
57
|
+
return () => {
|
|
58
|
+
stop();
|
|
59
|
+
taskbar.setProgress({ state: TaskbarProgressState.NONE });
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=taskbar-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskbar-progress.js","sourceRoot":"","sources":["../../src/progress/taskbar-progress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,MAAM,cAAc,GAAG,IAAI,CAAC;AAO5B;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAA0B;IACzD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC;IACnD,MAAM,QAAQ,GAAG,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC;IAC/C,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAmC,CAAC;IAChF,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,KAAK,aAAa,CAAC,MAAM,CAAC;IAChD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,KAAK,EAAE,oBAAoB,CAAC,MAAM;YAClC,KAAK;SAC2B,CAAC;IACrC,CAAC;IAED,MAAM,YAAY,GAAG,KAAK,KAAK,aAAa,CAAC,OAAO,CAAC;IACrD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC,IAAI,EAAmC,CAAC;IAC/E,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC,aAAa,EAAmC,CAAC;IACxF,CAAC;IAED,OAAO;QACL,KAAK,EAAE,oBAAoB,CAAC,MAAM;QAClC,KAAK;KAC2B,CAAC;AACrC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAGpD;IACC,IAAI,OAAO,GAAG,GAAG,oBAAoB,CAAC,IAAI,IAAI,CAAC;IAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;QACvC,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,EAAE,CAAC;QACxG,MAAM,MAAM,GAAG,GAAG,KAAK,OAAO,CAAC;QAC/B,IAAI,MAAM,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QAED,OAAO,GAAG,GAAG,CAAC;QACd,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE;QACV,IAAI,EAAE,CAAC;QACP,OAAO,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ProgressOperation } from "./progress-operation.js";
|
|
2
|
+
import type { ProgressOperationOptions } from "./progress-operation.js";
|
|
3
|
+
/** What `trackOperation` takes: the operation options and the work. */
|
|
4
|
+
export interface TrackOperationOptions<Result> extends ProgressOperationOptions {
|
|
5
|
+
/** The work; report with `operation.update`, stop when `operation.signal` aborts. */
|
|
6
|
+
readonly run: (operation: ProgressOperation<Result>) => Promise<Result>;
|
|
7
|
+
}
|
|
8
|
+
/** The part of an operation that the work reports through. */
|
|
9
|
+
export interface ProgressReporter {
|
|
10
|
+
readonly signal: AbortSignal;
|
|
11
|
+
update(options: {
|
|
12
|
+
loaded: number;
|
|
13
|
+
total?: number | undefined;
|
|
14
|
+
}): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Runs `run` as a tracked operation: it starts at once, completes with what
|
|
18
|
+
* `run` returns, fails with what it throws and is canceled when it throws an
|
|
19
|
+
* `AbortError`. This is the whole lifecycle for any long work (a copy, an OCR
|
|
20
|
+
* pass, a decode), so an app wires it in one call.
|
|
21
|
+
*
|
|
22
|
+
* @param options - The work and the operation options.
|
|
23
|
+
* @returns The operation: await it for the result, bind it to a bar, cancel it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function trackOperation<Result>({ run, ...options }: TrackOperationOptions<Result>): ProgressOperation<Result>;
|
|
26
|
+
/**
|
|
27
|
+
* Passes a stream through and reports the bytes that went by.
|
|
28
|
+
*
|
|
29
|
+
* @param options - The stream and the operation to report to.
|
|
30
|
+
* @returns A stream with the same chunks.
|
|
31
|
+
*/
|
|
32
|
+
export declare function trackStream({ stream, operation }: {
|
|
33
|
+
stream: ReadableStream<Uint8Array>;
|
|
34
|
+
operation: ProgressReporter;
|
|
35
|
+
}): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
36
|
+
//# sourceMappingURL=track-operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-operation.d.ts","sourceRoot":"","sources":["../../src/progress/track-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAIxE,uEAAuE;AACvE,MAAM,WAAW,qBAAqB,CAAC,MAAM,CAAE,SAAQ,wBAAwB;IAC7E,qFAAqF;IACrF,QAAQ,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,iBAAiB,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACzE;AAED,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,MAAM,CAAC,OAAO,EAAE;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,GAAG,IAAI,CAAC;CACV;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,EAAE,qBAAqB,CAAC,MAAM,CAAC,6BAQxF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;IACjD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACnC,SAAS,EAAE,gBAAgB,CAAC;CAC7B,+CAWA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ProgressOperation } from "./progress-operation.js";
|
|
2
|
+
const ABORT_ERROR = "AbortError";
|
|
3
|
+
function isAbortError(error) {
|
|
4
|
+
return error instanceof DOMException && error.name === ABORT_ERROR;
|
|
5
|
+
}
|
|
6
|
+
async function execute({ operation, run }) {
|
|
7
|
+
try {
|
|
8
|
+
operation.complete(await run(operation));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
const isCancel = isAbortError(error);
|
|
12
|
+
if (isCancel) {
|
|
13
|
+
operation.cancel(error);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
operation.fail(error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Runs `run` as a tracked operation: it starts at once, completes with what
|
|
21
|
+
* `run` returns, fails with what it throws and is canceled when it throws an
|
|
22
|
+
* `AbortError`. This is the whole lifecycle for any long work (a copy, an OCR
|
|
23
|
+
* pass, a decode), so an app wires it in one call.
|
|
24
|
+
*
|
|
25
|
+
* @param options - The work and the operation options.
|
|
26
|
+
* @returns The operation: await it for the result, bind it to a bar, cancel it.
|
|
27
|
+
*/
|
|
28
|
+
export function trackOperation({ run, ...options }) {
|
|
29
|
+
const operation = new ProgressOperation(options);
|
|
30
|
+
operation.start();
|
|
31
|
+
void execute({
|
|
32
|
+
operation,
|
|
33
|
+
run
|
|
34
|
+
});
|
|
35
|
+
return operation;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Passes a stream through and reports the bytes that went by.
|
|
39
|
+
*
|
|
40
|
+
* @param options - The stream and the operation to report to.
|
|
41
|
+
* @returns A stream with the same chunks.
|
|
42
|
+
*/
|
|
43
|
+
export function trackStream({ stream, operation }) {
|
|
44
|
+
let loaded = 0;
|
|
45
|
+
return stream.pipeThrough(new TransformStream({
|
|
46
|
+
transform(chunk, controller) {
|
|
47
|
+
loaded += chunk.byteLength;
|
|
48
|
+
operation.update({ loaded });
|
|
49
|
+
controller.enqueue(chunk);
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=track-operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-operation.js","sourceRoot":"","sources":["../../src/progress/track-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,MAAM,WAAW,GAAG,YAAY,CAAC;AAiBjC,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;AACrE,CAAC;AAED,KAAK,UAAU,OAAO,CAAS,EAAE,SAAS,EAAE,GAAG,EAG9C;IACC,IAAI,CAAC;QACH,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,QAAQ,EAAE,CAAC;YACb,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACxB,OAAO;QACT,CAAC;QAED,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAS,EAAE,GAAG,EAAE,GAAG,OAAO,EAAiC;IACvF,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAS,OAAO,CAAC,CAAC;IACzD,SAAS,CAAC,KAAK,EAAE,CAAC;IAClB,KAAK,OAAO,CAAC;QACX,SAAS;QACT,GAAG;KACJ,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAE,SAAS,EAG9C;IACC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,OAAO,MAAM,CAAC,WAAW,CACvB,IAAI,eAAe,CAAyB;QAC1C,SAAS,CAAC,KAAK,EAAE,UAAU;YACzB,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;YAC3B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7B,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TrayMenuOperationsProps } from "./menu-props.ts";
|
|
2
|
+
import type { Component } from "svelte";
|
|
3
|
+
|
|
4
|
+
declare const TrayMenuOperations: Component<TrayMenuOperationsProps, Record<string, never>, "">;
|
|
5
|
+
// eslint-disable-next-line no-restricted-exports -- Svelte declares a component as the default export
|
|
6
|
+
export default TrayMenuOperations;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TrayMenuOperationsProps } from "./menu-props.js";
|
|
3
|
+
import { operationMenuId } from "./operation-ids.js";
|
|
4
|
+
import TrayMenuItem from "./TrayMenuItem.svelte";
|
|
5
|
+
import TrayMenuSubmenu from "./TrayMenuSubmenu.svelte";
|
|
6
|
+
import { progressText } from "../../progress/progress-text.js";
|
|
7
|
+
import { scopedRegistry } from "../../progress/scoped-source.js";
|
|
8
|
+
|
|
9
|
+
// A submenu with a line per running operation; picking a line cancels it.
|
|
10
|
+
const props: TrayMenuOperationsProps = $props();
|
|
11
|
+
const submenu = $derived.by(() => {
|
|
12
|
+
const { of, group, ...others } = props;
|
|
13
|
+
return others;
|
|
14
|
+
});
|
|
15
|
+
const scoped = $derived(
|
|
16
|
+
scopedRegistry({
|
|
17
|
+
of: props.of,
|
|
18
|
+
group: props.group
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
$effect(() => () => scoped.dispose());
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<TrayMenuSubmenu {...submenu}>
|
|
26
|
+
{#each scoped.registry.operations as operation (operation)}
|
|
27
|
+
<TrayMenuItem
|
|
28
|
+
id={operationMenuId(operation)}
|
|
29
|
+
label={() => progressText(operation.snapshot)}
|
|
30
|
+
onselect={() => operation.cancel()}
|
|
31
|
+
/>
|
|
32
|
+
{/each}
|
|
33
|
+
</TrayMenuSubmenu>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TrayMenuProgressProps } from "./menu-props.ts";
|
|
2
|
+
import type { Component } from "svelte";
|
|
3
|
+
|
|
4
|
+
declare const TrayMenuProgress: Component<TrayMenuProgressProps, Record<string, never>, "">;
|
|
5
|
+
// eslint-disable-next-line no-restricted-exports -- Svelte declares a component as the default export
|
|
6
|
+
export default TrayMenuProgress;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TrayMenuProgressProps } from "./menu-props.js";
|
|
3
|
+
import TrayMenuItem from "./TrayMenuItem.svelte";
|
|
4
|
+
import { progressText } from "../../progress/progress-text.js";
|
|
5
|
+
import { scopedSource } from "../../progress/scoped-source.js";
|
|
6
|
+
|
|
7
|
+
// A line of the tray menu that reads "setup.exe - 45%" or "3 operations - 12%"
|
|
8
|
+
// and is left out while nothing runs. Picking it runs onselect, if any.
|
|
9
|
+
const props: TrayMenuProgressProps = $props();
|
|
10
|
+
const item = $derived.by(() => {
|
|
11
|
+
const { of, group, ...others } = props;
|
|
12
|
+
return others;
|
|
13
|
+
});
|
|
14
|
+
const scoped = $derived(
|
|
15
|
+
scopedSource({
|
|
16
|
+
of: props.of,
|
|
17
|
+
group: props.group
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
$effect(() => () => scoped.dispose());
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<TrayMenuItem
|
|
25
|
+
{...item}
|
|
26
|
+
isVisible={() => scoped.source.snapshot.count > 0 || scoped.source.snapshot.showError}
|
|
27
|
+
label={() => progressText(scoped.source.snapshot)}
|
|
28
|
+
/>
|