winui-svelte 0.0.7 → 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 +565 -19
- package/README.md +21 -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/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/automation/native.d.ts.map +1 -1
- package/dist/automation/native.js +1 -2
- package/dist/automation/native.js.map +1 -1
- 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.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/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/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/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/enums.d.ts +3 -0
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +3 -0
- package/dist/enums.js.map +1 -1
- 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/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/menu-node.d.ts +4 -4
- package/dist/tray/native.d.ts +9 -4
- package/dist/tray/native.d.ts.map +1 -1
- package/dist/tray/native.js +10 -18
- 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/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 +3 -2
- 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-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/native.d.ts +19 -6
- package/dist/tray/standalone/native.d.ts.map +1 -1
- package/dist/tray/standalone/native.js +58 -15
- package/dist/tray/standalone/native.js.map +1 -1
- package/dist/tray/standalone/standalone-tray.d.ts +4 -2
- package/dist/tray/standalone/standalone-tray.d.ts.map +1 -1
- package/dist/tray/standalone/standalone-tray.js +12 -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 +5 -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/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/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 +20 -0
- package/dist/win32-foreground.d.ts.map +1 -1
- package/dist/win32-foreground.js +24 -4
- package/dist/win32-foreground.js.map +1 -1
- 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 +1 -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-native.d.ts.map +1 -1
- package/dist/window/foreground-native.js +3 -5
- package/dist/window/foreground-native.js.map +1 -1
- 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 +10 -1
- 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 +26 -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/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/automation/native.ts +1 -2
- 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/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/enums.ts +3 -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/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/native.ts +20 -21
- package/src/tray/personalize.ts +57 -0
- package/src/tray/pointer-share.ts +3 -3
- package/src/tray/standalone/icon-raster.ts +208 -0
- package/src/tray/standalone/index.ts +4 -1
- package/src/tray/standalone/menu-icons.ts +317 -0
- package/src/tray/standalone/native.ts +78 -15
- package/src/tray/standalone/standalone-tray.ts +26 -5
- package/src/tray/themed-icon.ts +4 -36
- package/src/tray/tray-core.ts +6 -1
- package/src/tray/tray-extras.ts +31 -2
- package/src/web-apis/eye-dropper.ts +9 -5
- 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 +28 -4
- 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 +2 -0
- package/src/window/dpi-awareness.ts +162 -0
- package/src/window/foreground-native.ts +3 -5
- 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 +58 -5
- package/web-types.json +11 -3
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { messageOf } from "./core.ts";
|
|
2
|
+
import type { CoreWebView2Like, EnvironmentLike, WebView2Like } from "./core.ts";
|
|
3
|
+
import { CoreWebView2Environment } from "#winui/microsoft/web/web-view2/core/CoreWebView2Environment";
|
|
4
|
+
import { CoreWebView2EnvironmentOptions } from "#winui/microsoft/web/web-view2/core/CoreWebView2EnvironmentOptions";
|
|
5
|
+
|
|
6
|
+
const ARGUMENT_SEPARATOR = " ";
|
|
7
|
+
const INVALID_STATE_CODE = /0x?8007139f/i;
|
|
8
|
+
const BUSY_CODE = /0x?800700aa/i;
|
|
9
|
+
const started = new WeakMap<object, Promise<CoreWebView2Like>>();
|
|
10
|
+
|
|
11
|
+
/** How an environment is built; every member is optional. */
|
|
12
|
+
export interface WebView2EnvironmentInit {
|
|
13
|
+
/** A fixed-version runtime's folder; the installed runtime when empty or absent. */
|
|
14
|
+
browserExecutableFolder?: string;
|
|
15
|
+
|
|
16
|
+
/** The profile folder of this environment; one browser process runs per folder. */
|
|
17
|
+
userDataFolder?: string;
|
|
18
|
+
|
|
19
|
+
/** Chromium switches, joined with spaces, such as `--autoplay-policy=no-user-gesture-required`. */
|
|
20
|
+
additionalBrowserArguments?: string[];
|
|
21
|
+
|
|
22
|
+
/** The browser's language, such as `en-US`. */
|
|
23
|
+
language?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// WebView2 answers two different causes with 0x8007139F; the message names both
|
|
27
|
+
function explainFailure({ error, userDataFolder }: {
|
|
28
|
+
error: unknown;
|
|
29
|
+
userDataFolder: string;
|
|
30
|
+
}) {
|
|
31
|
+
const text = messageOf(error);
|
|
32
|
+
if (INVALID_STATE_CODE.test(text)) {
|
|
33
|
+
return new Error(
|
|
34
|
+
`WebView2 refused to start (0x8007139F): either this process cannot launch a browser (run it in an ordinary desktop session), or ${userDataFolder} is already in use with different environment options`,
|
|
35
|
+
{ cause: error }
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (BUSY_CODE.test(text)) {
|
|
40
|
+
return new Error(`WebView2 profile folder ${userDataFolder} is open in another browser (0x800700AA); use one folder per running app`, { cause: error });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return error;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Builds a WebView2 environment: a profile folder of its own and the Chromium
|
|
48
|
+
* switches of its browser; pass it to `startWebView2`
|
|
49
|
+
* `WEBVIEW2_USER_DATA_FOLDER` overrides `userDataFolder` when it is set, so
|
|
50
|
+
* start the app with `initWindowsAppSdk({ webViewUserDataFolder: false })`
|
|
51
|
+
*
|
|
52
|
+
* @param init - The folder, the switches and the language.
|
|
53
|
+
* @returns The environment.
|
|
54
|
+
*/
|
|
55
|
+
export async function createWebView2Environment(init: WebView2EnvironmentInit = {}) {
|
|
56
|
+
const { browserExecutableFolder = "", userDataFolder = "", additionalBrowserArguments = [], language = "" } = init;
|
|
57
|
+
const options = CoreWebView2EnvironmentOptions.create();
|
|
58
|
+
options.additionalBrowserArguments = additionalBrowserArguments.join(ARGUMENT_SEPARATOR);
|
|
59
|
+
const isLanguageSet = language !== "";
|
|
60
|
+
if (isLanguageSet) {
|
|
61
|
+
options.language = language;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
return await CoreWebView2Environment.createWithOptionsAsync(browserExecutableFolder, userDataFolder, options);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw explainFailure({
|
|
68
|
+
error,
|
|
69
|
+
userDataFolder
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function start({ control, environment, profileName, isInPrivateMode }: {
|
|
75
|
+
control: WebView2Like;
|
|
76
|
+
environment: EnvironmentLike;
|
|
77
|
+
profileName: string | undefined;
|
|
78
|
+
isInPrivateMode: boolean;
|
|
79
|
+
}) {
|
|
80
|
+
const controllerOptions = environment.createCoreWebView2ControllerOptions();
|
|
81
|
+
const hasProfileName = profileName !== undefined;
|
|
82
|
+
if (hasProfileName) {
|
|
83
|
+
controllerOptions.profileName = profileName;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
controllerOptions.isInPrivateModeEnabled = isInPrivateMode;
|
|
87
|
+
try {
|
|
88
|
+
await control.ensureCoreWebView2Async(environment, controllerOptions);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
throw explainFailure({
|
|
91
|
+
error,
|
|
92
|
+
userDataFolder: environment.userDataFolder
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return control.coreWebView2;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Starts the control's browser in `environment`, with the profile
|
|
101
|
+
* `profileName` of its folder, and resolves with the `CoreWebView2`
|
|
102
|
+
* The first start of a control wins: call this before anything that starts it
|
|
103
|
+
* with the default environment (`waitForCoreWebView2` and every helper that
|
|
104
|
+
* calls it); a second call resolves with the same core and starts nothing
|
|
105
|
+
* The control must be in a window for the browser to start
|
|
106
|
+
*
|
|
107
|
+
* @param options - The control, its environment, the profile and the private mode.
|
|
108
|
+
* @returns The control's `CoreWebView2`.
|
|
109
|
+
*/
|
|
110
|
+
export function startWebView2({ control, environment, profileName, isInPrivateMode = false }: {
|
|
111
|
+
control: WebView2Like;
|
|
112
|
+
environment: EnvironmentLike;
|
|
113
|
+
profileName?: string;
|
|
114
|
+
isInPrivateMode?: boolean;
|
|
115
|
+
}) {
|
|
116
|
+
const existing = started.get(control);
|
|
117
|
+
const isStarted = existing !== undefined;
|
|
118
|
+
if (isStarted) {
|
|
119
|
+
return existing;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const pending = start({
|
|
123
|
+
control,
|
|
124
|
+
environment,
|
|
125
|
+
profileName,
|
|
126
|
+
isInPrivateMode
|
|
127
|
+
});
|
|
128
|
+
started.set(control, pending);
|
|
129
|
+
pending.catch(() => started.delete(control));
|
|
130
|
+
return pending;
|
|
131
|
+
}
|
|
@@ -2,13 +2,24 @@
|
|
|
2
2
|
// Opt-in: nothing here loads until it is imported.
|
|
3
3
|
|
|
4
4
|
export type {
|
|
5
|
+
ControllerOptionsLike,
|
|
5
6
|
CoreWebView2Like,
|
|
7
|
+
EnvironmentLike,
|
|
8
|
+
ProcessFailedArguments,
|
|
6
9
|
WebView2Like
|
|
7
10
|
} from "./core.ts";
|
|
8
11
|
export { addDocumentCreatedScript, executeScript, openDevTools, waitForCoreWebView2 } from "./core.ts";
|
|
12
|
+
export type { WebView2EnvironmentInit } from "./environment.ts";
|
|
13
|
+
export { createWebView2Environment, startWebView2 } from "./environment.ts";
|
|
9
14
|
export type { Cookie, CookieInit } from "./cookies.ts";
|
|
10
15
|
export { CookieSameSite, deleteCookie, getCookies, setCookie } from "./cookies.ts";
|
|
11
16
|
export type { PermissionRequest } from "./policy.ts";
|
|
12
17
|
export { onDownloadStarting, onNavigationStarting, onPermissionRequested, PermissionKind, PermissionState } from "./policy.ts";
|
|
13
18
|
export type { WebView2Transport } from "./transport.ts";
|
|
14
19
|
export { webView2Transport } from "./transport.ts";
|
|
20
|
+
export type { RequestFilter, WebRequest, WebResponse } from "./requests.ts";
|
|
21
|
+
export { blockRequests, onWebResourceRequested, ResourceContext, StatusCode } from "./requests.ts";
|
|
22
|
+
export { callDevToolsMethod, onDevToolsEvent } from "./protocol.ts";
|
|
23
|
+
export { dispatchKey, dispatchMouseClick, keyEventParameters, KeyEventType, MouseButton, TypeMode, typeText } from "./input.ts";
|
|
24
|
+
export type { WebView2Guard } from "./recovery.ts";
|
|
25
|
+
export { keepWebView2Alive, ProcessFailureKind } from "./recovery.ts";
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { WebView2Like } from "./core.ts";
|
|
2
|
+
import { callDevToolsMethod } from "./protocol.ts";
|
|
3
|
+
|
|
4
|
+
/** The kind of a key event. */
|
|
5
|
+
export const KeyEventType = {
|
|
6
|
+
KEY_DOWN: "keyDown",
|
|
7
|
+
KEY_UP: "keyUp",
|
|
8
|
+
RAW_KEY_DOWN: "rawKeyDown",
|
|
9
|
+
CHAR: "char"
|
|
10
|
+
} as const;
|
|
11
|
+
/** One of the values of `KeyEventType`. */
|
|
12
|
+
export type KeyEventType = (typeof KeyEventType)[keyof typeof KeyEventType];
|
|
13
|
+
|
|
14
|
+
/** The mouse button of a click. */
|
|
15
|
+
export const MouseButton = {
|
|
16
|
+
LEFT: "left",
|
|
17
|
+
MIDDLE: "middle",
|
|
18
|
+
RIGHT: "right"
|
|
19
|
+
} as const;
|
|
20
|
+
/** One of the values of `MouseButton`. */
|
|
21
|
+
export type MouseButton = (typeof MouseButton)[keyof typeof MouseButton];
|
|
22
|
+
|
|
23
|
+
/** How `typeText` enters the text. */
|
|
24
|
+
export const TypeMode = {
|
|
25
|
+
/** A key down and a key up for every character. */
|
|
26
|
+
KEYS: "keys",
|
|
27
|
+
/** The first character as keys, the rest in one `Input.insertText`. */
|
|
28
|
+
INSERT_AFTER_FIRST: "insertAfterFirst"
|
|
29
|
+
} as const;
|
|
30
|
+
/** One of the values of `TypeMode`. */
|
|
31
|
+
export type TypeMode = (typeof TypeMode)[keyof typeof TypeMode];
|
|
32
|
+
|
|
33
|
+
const DISPATCH_KEY_EVENT = "Input.dispatchKeyEvent";
|
|
34
|
+
const DISPATCH_MOUSE_EVENT = "Input.dispatchMouseEvent";
|
|
35
|
+
const INSERT_TEXT = "Input.insertText";
|
|
36
|
+
const TEXT_KEY_TYPES = new Set<KeyEventType>([KeyEventType.KEY_DOWN, KeyEventType.CHAR]);
|
|
37
|
+
|
|
38
|
+
/** The parameters of `Input.dispatchKeyEvent`, built in one place. */
|
|
39
|
+
export function keyEventParameters({ type, key, text, modifiers = 0 }: {
|
|
40
|
+
type: KeyEventType;
|
|
41
|
+
key: string;
|
|
42
|
+
text?: string;
|
|
43
|
+
modifiers?: number;
|
|
44
|
+
}) {
|
|
45
|
+
const isSingleCharacter = Array.from(key).length === 1;
|
|
46
|
+
const typed = text ?? (isSingleCharacter ? key : undefined);
|
|
47
|
+
const hasText = typed !== undefined && TEXT_KEY_TYPES.has(type);
|
|
48
|
+
return {
|
|
49
|
+
type,
|
|
50
|
+
key,
|
|
51
|
+
modifiers,
|
|
52
|
+
...hasText ? { text: typed } : {}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The parameters of `Input.dispatchMouseEvent`. */
|
|
57
|
+
function mouseEventParameters({ type, x, y, button, clickCount }: {
|
|
58
|
+
type: "mousePressed" | "mouseReleased" | "mouseMoved";
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
button: MouseButton;
|
|
62
|
+
clickCount: number;
|
|
63
|
+
}) {
|
|
64
|
+
return {
|
|
65
|
+
type,
|
|
66
|
+
x,
|
|
67
|
+
y,
|
|
68
|
+
button,
|
|
69
|
+
clickCount
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Sends one trusted key event to the page; `text` defaults to `key` when it is
|
|
75
|
+
* one character
|
|
76
|
+
*/
|
|
77
|
+
export async function dispatchKey({ control, key, type, text, modifiers }: {
|
|
78
|
+
control: WebView2Like;
|
|
79
|
+
key: string;
|
|
80
|
+
type: KeyEventType;
|
|
81
|
+
text?: string;
|
|
82
|
+
modifiers?: number;
|
|
83
|
+
}) {
|
|
84
|
+
await callDevToolsMethod({
|
|
85
|
+
control,
|
|
86
|
+
method: DISPATCH_KEY_EVENT,
|
|
87
|
+
parameters: keyEventParameters({
|
|
88
|
+
type,
|
|
89
|
+
key,
|
|
90
|
+
...text === undefined ? {} : { text },
|
|
91
|
+
...modifiers === undefined ? {} : { modifiers }
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Sends a trusted mouse click (press and release) at a point of the page, in CSS pixels. */
|
|
97
|
+
export async function dispatchMouseClick({ control, x, y, button = MouseButton.LEFT, clickCount = 1 }: {
|
|
98
|
+
control: WebView2Like;
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
button?: MouseButton;
|
|
102
|
+
clickCount?: number;
|
|
103
|
+
}) {
|
|
104
|
+
function send(type: "mousePressed" | "mouseReleased") {
|
|
105
|
+
return callDevToolsMethod({
|
|
106
|
+
control,
|
|
107
|
+
method: DISPATCH_MOUSE_EVENT,
|
|
108
|
+
parameters: mouseEventParameters({
|
|
109
|
+
type,
|
|
110
|
+
x,
|
|
111
|
+
y,
|
|
112
|
+
button,
|
|
113
|
+
clickCount
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await Promise.all([send("mousePressed"), send("mouseReleased")]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Types `text` into the focused element with trusted key events, a character
|
|
123
|
+
* at a time (the key down and up go out together, in order)
|
|
124
|
+
*/
|
|
125
|
+
export async function typeText({ control, text, mode = TypeMode.KEYS }: {
|
|
126
|
+
control: WebView2Like;
|
|
127
|
+
text: string;
|
|
128
|
+
mode?: TypeMode;
|
|
129
|
+
}) {
|
|
130
|
+
const characters = Array.from(text);
|
|
131
|
+
const isInsertingRest = mode === TypeMode.INSERT_AFTER_FIRST;
|
|
132
|
+
const keyed = isInsertingRest ? characters.slice(0, 1) : characters;
|
|
133
|
+
for (const character of keyed) {
|
|
134
|
+
await Promise.all(
|
|
135
|
+
[KeyEventType.KEY_DOWN, KeyEventType.KEY_UP].map(type => dispatchKey({
|
|
136
|
+
control,
|
|
137
|
+
key: character,
|
|
138
|
+
type
|
|
139
|
+
}))
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const rest = characters.slice(1).join("");
|
|
144
|
+
const hasRest = isInsertingRest && rest !== "";
|
|
145
|
+
if (hasRest) {
|
|
146
|
+
await callDevToolsMethod({
|
|
147
|
+
control,
|
|
148
|
+
method: INSERT_TEXT,
|
|
149
|
+
parameters: {
|
|
150
|
+
text: rest
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { messageOf, waitForCoreWebView2 } from "./core.ts";
|
|
2
|
+
import type { WebView2Like } from "./core.ts";
|
|
3
|
+
import { jsonSchema } from "#src/messaging/json.js";
|
|
4
|
+
import type { Json } from "#src/messaging/json.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Calls a DevTools protocol method on the page and resolves with its result
|
|
8
|
+
* as JSON, checked; rejects with the protocol's error text
|
|
9
|
+
*/
|
|
10
|
+
export async function callDevToolsMethod({ control, method, parameters = {} }: {
|
|
11
|
+
control: WebView2Like;
|
|
12
|
+
method: string;
|
|
13
|
+
parameters?: Readonly<Record<string, unknown>>;
|
|
14
|
+
}) {
|
|
15
|
+
const core = await waitForCoreWebView2(control);
|
|
16
|
+
try {
|
|
17
|
+
const text = await core.callDevToolsProtocolMethodAsync(method, JSON.stringify(parameters));
|
|
18
|
+
return jsonSchema.parse(JSON.parse(text));
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new Error(`${method}: ${messageOf(error)}`, { cause: error });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Hands the parameters of every `event` of the DevTools protocol to `handler`
|
|
26
|
+
* as JSON, checked; resolves with the function that stops it
|
|
27
|
+
* The browser raises an event only after its domain is enabled
|
|
28
|
+
* (`callDevToolsMethod({ method: "Network.enable" })`), and an event still
|
|
29
|
+
* subscribed keeps the process from exiting
|
|
30
|
+
*/
|
|
31
|
+
export async function onDevToolsEvent({ control, event, handler }: {
|
|
32
|
+
control: WebView2Like;
|
|
33
|
+
event: string;
|
|
34
|
+
handler(parameters: Json): void;
|
|
35
|
+
}) {
|
|
36
|
+
const core = await waitForCoreWebView2(control);
|
|
37
|
+
const receiver = core.getDevToolsProtocolEventReceiver(event);
|
|
38
|
+
return receiver.onDevToolsProtocolEventReceived((_sender, args) => {
|
|
39
|
+
handler(jsonSchema.parse(JSON.parse(args.parameterObjectAsJson)));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { messageOf, waitForCoreWebView2 } from "./core.ts";
|
|
2
|
+
import type { CoreWebView2Like, WebView2Like } from "./core.ts";
|
|
3
|
+
import { CoreWebView2ProcessFailedKind } from "#winui/microsoft/web/web-view2/core/CoreWebView2ProcessFailedKind";
|
|
4
|
+
|
|
5
|
+
/** What went wrong in the browser, as `keepWebView2Alive` tells the app. */
|
|
6
|
+
export const ProcessFailureKind = {
|
|
7
|
+
BROWSER_EXITED: "browserExited",
|
|
8
|
+
RENDER_EXITED: "renderExited",
|
|
9
|
+
UNRESPONSIVE: "unresponsive",
|
|
10
|
+
OTHER: "other"
|
|
11
|
+
} as const;
|
|
12
|
+
/** One of the values of `ProcessFailureKind`. */
|
|
13
|
+
export type ProcessFailureKind = (typeof ProcessFailureKind)[keyof typeof ProcessFailureKind];
|
|
14
|
+
|
|
15
|
+
const KINDS = new Map<number, ProcessFailureKind>([
|
|
16
|
+
[CoreWebView2ProcessFailedKind.BrowserProcessExited, ProcessFailureKind.BROWSER_EXITED],
|
|
17
|
+
[CoreWebView2ProcessFailedKind.RenderProcessExited, ProcessFailureKind.RENDER_EXITED],
|
|
18
|
+
[CoreWebView2ProcessFailedKind.FrameRenderProcessExited, ProcessFailureKind.RENDER_EXITED],
|
|
19
|
+
[CoreWebView2ProcessFailedKind.RenderProcessUnresponsive, ProcessFailureKind.UNRESPONSIVE]
|
|
20
|
+
]);
|
|
21
|
+
const DEFAULT_MAX_CRASHES = 3;
|
|
22
|
+
const DEFAULT_WINDOW_MILLISECONDS = 30_000;
|
|
23
|
+
|
|
24
|
+
/** The control that `keepWebView2Alive` watches, and the means to stop or restart it. */
|
|
25
|
+
export interface WebView2Guard {
|
|
26
|
+
/**
|
|
27
|
+
* Tries again after the guard gave up (`onGaveUp`): forgets the failures
|
|
28
|
+
* so far and rebuilds the control, as for a browser that exited
|
|
29
|
+
* Does nothing while a recovery is running or after `dispose`
|
|
30
|
+
*/
|
|
31
|
+
retry(): Promise<void>;
|
|
32
|
+
/** Stops listening; a recovery already running finishes. */
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function quietly(action: () => void) {
|
|
37
|
+
try {
|
|
38
|
+
action();
|
|
39
|
+
} catch {
|
|
40
|
+
// A dead core may throw while its handler is removed; there is nothing left to undo
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Keeps a `WebView2` working through the browser's crashes, with no action
|
|
46
|
+
* from the user
|
|
47
|
+
*
|
|
48
|
+
* It runs `setup` with the core of `control`, then watches the control's
|
|
49
|
+
* `CoreProcessFailed`:
|
|
50
|
+
*
|
|
51
|
+
* - the browser process exiting leaves the control dead, so it calls
|
|
52
|
+
* `rebuild`, which must resolve with a new control that is already
|
|
53
|
+
* started (`startWebView2`), then runs `setup` with the new core
|
|
54
|
+
* - any other process failing (a renderer, a utility process) reloads the
|
|
55
|
+
* page in place
|
|
56
|
+
* - more than `maxCrashes` failures within `windowMilliseconds` stop the
|
|
57
|
+
* loop: `onGaveUp` is called once, and nothing more happens until
|
|
58
|
+
* `retry()`
|
|
59
|
+
* - a failure while a recovery is running is ignored, so one is never run twice
|
|
60
|
+
*
|
|
61
|
+
* Everything bound to the old core is lost with it: scripts from
|
|
62
|
+
* `addDocumentCreatedScript`, the handlers (`onNavigationStarting`,
|
|
63
|
+
* `onPermissionRequested`, `onWebResourceRequested`), a `webView2Transport`
|
|
64
|
+
* and its messaging; put them in `setup`, which runs again after every rebuild
|
|
65
|
+
* Cookies and storage live in the profile folder and survive; a page that is
|
|
66
|
+
* only reloaded keeps the scripts and handlers, and loses its own state
|
|
67
|
+
*
|
|
68
|
+
* A failure of `rebuild` or `setup` gives up, with the error's text as the
|
|
69
|
+
* reason
|
|
70
|
+
*
|
|
71
|
+
* @param options - The control and the policy.
|
|
72
|
+
* @returns The guard.
|
|
73
|
+
*/
|
|
74
|
+
export function keepWebView2Alive({
|
|
75
|
+
control,
|
|
76
|
+
setup,
|
|
77
|
+
rebuild,
|
|
78
|
+
maxCrashes = DEFAULT_MAX_CRASHES,
|
|
79
|
+
windowMilliseconds = DEFAULT_WINDOW_MILLISECONDS,
|
|
80
|
+
onRecovering,
|
|
81
|
+
onGaveUp
|
|
82
|
+
}: {
|
|
83
|
+
control: WebView2Like;
|
|
84
|
+
setup(core: CoreWebView2Like): void | Promise<void>;
|
|
85
|
+
rebuild(): Promise<WebView2Like>;
|
|
86
|
+
maxCrashes?: number;
|
|
87
|
+
windowMilliseconds?: number;
|
|
88
|
+
onRecovering?(failure: { readonly kind: ProcessFailureKind }): void;
|
|
89
|
+
onGaveUp?(failure: { readonly reason: string }): void;
|
|
90
|
+
}) {
|
|
91
|
+
let current = control;
|
|
92
|
+
let unsubscribe: (() => void) | undefined;
|
|
93
|
+
let failures: number[] = [];
|
|
94
|
+
let isRecovering = false;
|
|
95
|
+
let isGivenUp = false;
|
|
96
|
+
let isDisposed = false;
|
|
97
|
+
|
|
98
|
+
function giveUp(reason: string) {
|
|
99
|
+
isGivenUp = true;
|
|
100
|
+
onGaveUp?.({ reason });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function watch(next: WebView2Like) {
|
|
104
|
+
current = next;
|
|
105
|
+
unsubscribe = next.onCoreProcessFailed((_sender, args) => {
|
|
106
|
+
void recover(KINDS.get(args.processFailedKind) ?? ProcessFailureKind.OTHER);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function run(kind: ProcessFailureKind) {
|
|
111
|
+
const isRebuild = kind === ProcessFailureKind.BROWSER_EXITED;
|
|
112
|
+
if (!isRebuild) {
|
|
113
|
+
(await waitForCoreWebView2(current)).reload();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
quietly(() => unsubscribe?.());
|
|
118
|
+
watch(await rebuild());
|
|
119
|
+
await setup(await waitForCoreWebView2(current));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function recover(kind: ProcessFailureKind) {
|
|
123
|
+
const isIgnored = isDisposed || isGivenUp || isRecovering;
|
|
124
|
+
if (isIgnored) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const now = Date.now();
|
|
129
|
+
failures = [...failures.filter(failedAt => now - failedAt < windowMilliseconds), now];
|
|
130
|
+
const isStreak = failures.length > maxCrashes;
|
|
131
|
+
if (isStreak) {
|
|
132
|
+
giveUp(`${failures.length} failures within ${windowMilliseconds} ms`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
isRecovering = true;
|
|
137
|
+
onRecovering?.({ kind });
|
|
138
|
+
try {
|
|
139
|
+
await run(kind);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
giveUp(messageOf(error));
|
|
142
|
+
} finally {
|
|
143
|
+
isRecovering = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function start() {
|
|
148
|
+
isRecovering = true;
|
|
149
|
+
watch(control);
|
|
150
|
+
try {
|
|
151
|
+
await setup(await waitForCoreWebView2(control));
|
|
152
|
+
} catch (error) {
|
|
153
|
+
giveUp(messageOf(error));
|
|
154
|
+
} finally {
|
|
155
|
+
isRecovering = false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
void start();
|
|
160
|
+
const guard: WebView2Guard = {
|
|
161
|
+
async retry() {
|
|
162
|
+
const isBusy = isDisposed || isRecovering;
|
|
163
|
+
if (isBusy) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
isGivenUp = false;
|
|
168
|
+
failures = [];
|
|
169
|
+
await recover(ProcessFailureKind.BROWSER_EXITED);
|
|
170
|
+
},
|
|
171
|
+
dispose() {
|
|
172
|
+
isDisposed = true;
|
|
173
|
+
quietly(() => unsubscribe?.());
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
return guard;
|
|
177
|
+
}
|