@legendapp/spark 0.0.1-next.2 → 0.0.1-next.4
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/LICENSE +21 -0
- package/README.md +10 -4
- package/ai-codex.ts +1 -0
- package/ai.ts +1 -0
- package/app-documents.ts +1 -0
- package/camera.ts +13 -0
- package/config-plugin.d.cts +2 -0
- package/contracts.ts +2 -0
- package/diagnostics.ts +1 -0
- package/expo-config.d.cts +1 -0
- package/metro.cjs +4 -1
- package/metro.d.cts +12 -0
- package/native.cjs +3 -1
- package/native.d.cts +6 -0
- package/package.json +93 -15
- package/patches/camera/react-native-nitro-image.patch +320 -0
- package/patches/camera/react-native-nitro-modules.patch +50 -0
- package/patches/camera/react-native-vision-camera.patch +2662 -0
- package/patches/camera/upstream.json +22 -0
- package/patches/dependencies.json +8 -0
- package/patches/react-native-enriched-markdown@1.0.2.patch +8684 -0
- package/postinstall.cjs +1 -0
- package/schema.json +276 -58
- package/settings-observable.ts +1 -0
- package/settings-window.ts +1 -0
- package/shortcuts-commands.ts +1 -0
- package/shortcuts-keyboard.ts +3 -0
- package/ui-classnames.ts +1 -0
- package/ui-glass.ts +1 -0
- package/ui-search.ts +1 -0
- package/ui-sidebar.ts +1 -0
- package/ui-split-view.ts +1 -0
- package/ui-swipe.ts +1 -0
- package/ui-symbol.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +19 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/availability.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/index.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/invocations.ts +34 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/output.ts +62 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/run.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/types.ts +16 -0
- package/vendor/node_modules/@legendapp/spark-audio/macos/RNSparkAudio.h +2 -1
- package/vendor/node_modules/@legendapp/spark-audio/macos/RNSparkAudio.mm +126 -24
- package/vendor/node_modules/@legendapp/spark-audio/package.json +5 -2
- package/vendor/node_modules/@legendapp/spark-audio/src/NativeSparkAudio.ts +5 -1
- package/vendor/node_modules/@legendapp/spark-audio/src/desktop.ts +36 -32
- package/vendor/node_modules/@legendapp/spark-audio/src/events.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/hooks.ts +65 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/index.web.ts +92 -33
- package/vendor/node_modules/@legendapp/spark-audio/src/media-session-unavailable.ts +6 -4
- package/vendor/node_modules/@legendapp/spark-audio/src/media-session.ts +52 -19
- package/vendor/node_modules/@legendapp/spark-audio/src/media-session.web.ts +18 -10
- package/vendor/node_modules/@legendapp/spark-audio/src/media-types.ts +40 -13
- package/vendor/node_modules/@legendapp/spark-audio/src/mobile.ts +40 -32
- package/vendor/node_modules/@legendapp/spark-audio/src/player.ts +97 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/status-listeners.ts +21 -15
- package/vendor/node_modules/@legendapp/spark-audio/src/types.ts +9 -4
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.h +67 -20
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-auth-session/src/core.ts +60 -42
- package/vendor/node_modules/@legendapp/spark-auth-session/src/index.ts +28 -12
- package/vendor/node_modules/@legendapp/spark-auth-session/src/mobile.ts +97 -41
- package/vendor/node_modules/@legendapp/spark-auth-session/src/types.ts +20 -9
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +50 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/build-mode.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +145 -59
- package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +61 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +10 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +37 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/credentials.js +86 -25
- package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +132 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +13 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +13 -10
- package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +100 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/examples.js +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-patch.cjs +4 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-metro.cjs +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-native.cjs +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-node.js +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/helpers.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +52 -44
- package/vendor/node_modules/@legendapp/spark-cli/dist/json.js +16 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/local.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +26 -5
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-metadata.js +26 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +86 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-preparation.js +88 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/notary-profiles.js +75 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/package.js +4 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/platform.js +16 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/process.js +7 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +90 -32
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.js +86 -5
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +23 -18
- package/vendor/node_modules/@legendapp/spark-cli/dist/runner-install.js +145 -31
- package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +4 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/universal.cjs +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/updates.js +41 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +5 -9
- package/vendor/node_modules/@legendapp/spark-cli/package.json +7 -6
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/App.tsx +6 -12
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/desktop.config.json +5 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +12 -10
- package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/Git.macos.tsx +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.macos.tsx +23 -21
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.windows.tsx +23 -21
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.desktop.ts +11 -8
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.macos.ts +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.desktop.tsx +8 -14
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.desktop.tsx +5 -10
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.desktop.ts +11 -8
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.macos.ts +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.desktop.ts +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.desktop.tsx +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.desktop.ts +37 -15
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/session.ts +5 -6
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/window-session.ts +5 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/desktop.config.json +5 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/metro.config.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +14 -12
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/react-native.config.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +14 -12
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/react-native.config.js +1 -1
- package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +10 -16
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-clipboard/src/NativeDesktopClipboard.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +55 -31
- package/vendor/node_modules/@legendapp/spark-clipboard/src/expo.ts +21 -11
- package/vendor/node_modules/@legendapp/spark-clipboard/src/options.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/types.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.h +38 -15
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.vcxproj +2 -0
- package/vendor/node_modules/@legendapp/spark-codex/RNCodex.podspec +22 -0
- package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.hpp +23 -0
- package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.mm +1529 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitro.json +21 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/.gitattributes +1 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex+autolinking.rb +62 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Bridge.cpp +17 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Bridge.hpp +27 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Umbrella.hpp +38 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodexAutolinking.mm +35 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodexAutolinking.swift +16 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/CodexAvailability.hpp +95 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/CodexRunResult.hpp +99 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/HybridCodexAppServerSpec.cpp +24 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/HybridCodexAppServerSpec.hpp +71 -0
- package/vendor/node_modules/@legendapp/spark-codex/package.json +35 -0
- package/vendor/node_modules/@legendapp/spark-codex/react-native.config.js +11 -0
- package/vendor/node_modules/@legendapp/spark-codex/src/Codex.nitro.ts +30 -0
- package/vendor/node_modules/@legendapp/spark-codex/src/index.ts +65 -0
- package/vendor/node_modules/@legendapp/spark-codex/src/native.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-commands/package.json +21 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/bindings.ts +90 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/index.tsx +400 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/router.ts +138 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/storage.ts +20 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/macos/RNContextMenu.mm +7 -8
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-context-menu/src/NativeContextMenu.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-context-menu/src/index.ts +26 -26
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.h +3 -2
- package/vendor/node_modules/@legendapp/spark-desktop-app/RNDesktopApp.podspec +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/cpp/SparkBinaryJSI.hpp +89 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/cpp/SparkBinaryWindows.hpp +22 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +13 -7
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkBinaryJSI.h +48 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +33 -33
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktopError.h +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkLifecycle.h +26 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkLifecycle.mm +49 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkQuitCoordinator.h +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkQuitCoordinator.mm +70 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkWindow.mm +9 -6
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/recent-documents/RNRecentDocumentController.mm +55 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +5 -3
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/NativeDesktopApp.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/api.ts +86 -40
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/accelerator.ts +40 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/index.ts +56 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/menu.ts +116 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/native-buffer.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/path.ts +24 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/events.ts +75 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/index.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/index.windows.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/open-requests.ts +43 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/restoration.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/transport.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +10 -5
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.d.cts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +35 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +18 -3
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +89 -9
- package/vendor/node_modules/@legendapp/spark-desktop-config/expo.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/expo.d.cts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +3 -2
- package/vendor/node_modules/@legendapp/spark-desktop-config/lifecycle.cjs +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +106 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +7 -5
- package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +276 -58
- package/vendor/node_modules/@legendapp/spark-desktop-config/updates.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +35 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +129 -11
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/application.inc +277 -121
- package/vendor/node_modules/@legendapp/spark-desktop-links/common/AuthLoopback.h +5 -7
- package/vendor/node_modules/@legendapp/spark-desktop-links/macos/RNDesktopLinks.mm +10 -9
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/NativeDesktopLinks.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/api.ts +27 -33
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/expo.ts +3 -4
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/native.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.h +22 -22
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/RNDesktopShortcuts.podspec +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/RNDesktopShortcuts.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.h +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.mm +307 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +8 -5
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/NativeDesktopShortcuts.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/api.ts +39 -14
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/NativeKeyboardManager.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/codes.ts +108 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/index.ts +99 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/RNDesktopWindows.podspec +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +229 -103
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/SparkWindowGeometry.h +63 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/LegendWindowRegistry.h +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/LegendWindowRegistry.mm +27 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.h +12 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +3169 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManagerStartup.mm +31 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/SidebarStartupFallbacks.mm +14 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +10 -6
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/NativeDesktopWindowManager.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +146 -70
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/diagnostics.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/index.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/index.windows.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +53 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos.ts +51 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/transport.ts +41 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +140 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +162 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/window-manager/NativeWindowManager.ts +28 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/WindowProvider.tsx +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +78 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/index.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +34 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/types.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +18 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-documents/package.json +22 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/controller.ts +97 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/documentTransition.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/hooks.ts +139 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/index.tsx +50 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/reload.ts +39 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/requests.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +73 -18
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +58 -15
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +14 -8
- package/vendor/node_modules/@legendapp/spark-file-dialog/ios/RNFileDialog.mm +34 -121
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +12 -5
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/NativeFileDialog.ts +1 -5
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/index.ts +19 -84
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/native.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +34 -14
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +26 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.h +42 -58
- package/vendor/node_modules/@legendapp/spark-file-system/RNDesktopFileSystem.podspec +1 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +32 -21
- package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.h +24 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.mm +215 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScanner.h +9 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScanner.mm +82 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScannerCore.h +47 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScannerCore.mm +306 -0
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +8 -6
- package/vendor/node_modules/@legendapp/spark-file-system/src/NativeDesktopFileSystem.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-file-system/src/file-scanner/NativeFileScanner.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/file-scanner/index.ts +93 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/handles.ts +48 -14
- package/vendor/node_modules/@legendapp/spark-file-system/src/index.ts +134 -45
- package/vendor/node_modules/@legendapp/spark-file-system/src/path.ts +1 -9
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.h +102 -26
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.vcxproj +2 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/RNDesktopGlobalShortcuts.podspec +1 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/macos/RNDesktopGlobalShortcuts.mm +7 -4
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/NativeDesktopGlobalShortcuts.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/index.ts +39 -10
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.h +5 -4
- package/vendor/node_modules/@legendapp/spark-message-dialog/macos/RNDesktopMessageDialog.mm +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/NativeDesktopMessageDialog.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +48 -11
- package/vendor/node_modules/@legendapp/spark-native-menu/ios/RNNativeMenu.mm +141 -609
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +9 -4
- package/vendor/node_modules/@legendapp/spark-native-menu/src/NativeMenu.ts +2 -7
- package/vendor/node_modules/@legendapp/spark-native-menu/src/api.ts +76 -121
- package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +97 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/src/windows-menus.ts +43 -37
- package/vendor/node_modules/@legendapp/spark-notifications/macos/RNDesktopNotifications.mm +75 -30
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-notifications/src/NativeDesktopNotifications.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-notifications/src/index.ts +130 -42
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.h +51 -8
- package/vendor/node_modules/@legendapp/spark-processes/macos/RNDesktopProcesses.mm +94 -21
- package/vendor/node_modules/@legendapp/spark-processes/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-processes/src/NativeDesktopProcesses.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-processes/src/index.ts +124 -28
- package/vendor/node_modules/@legendapp/spark-processes/src/types.ts +34 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.h +83 -34
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.vcxproj +2 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/macos/RNDesktopSecureStorage.mm +49 -40
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/NativeDesktopSecureStorage.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/desktop.ts +16 -14
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/expo.ts +0 -1
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/options.ts +3 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/unavailable.ts +6 -3
- package/vendor/node_modules/@legendapp/spark-settings/package.json +10 -3
- package/vendor/node_modules/@legendapp/spark-settings/src/fileStorage.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/index.ts +7 -9
- package/vendor/node_modules/@legendapp/spark-settings/src/storage/index.ts +142 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/store.ts +63 -21
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +20 -0
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +436 -0
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/options.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-sqlite/src/database.ts +182 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/src/index.ts +19 -6
- package/vendor/node_modules/@legendapp/spark-sqlite/src/types.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/RNDesktopSystem.mm +36 -11
- package/vendor/node_modules/@legendapp/spark-system/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-system/src/NativeDesktopSystem.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-system/src/index.ts +89 -32
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.h +8 -4
- package/vendor/node_modules/@legendapp/spark-tray/macos/RNDesktopTray.mm +20 -8
- package/vendor/node_modules/@legendapp/spark-tray/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-tray/src/NativeDesktopTray.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +91 -34
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.h +45 -15
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +10 -2
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +1419 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/glass-effect-view/RNGlassEffectView.mm +72 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +194 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +180 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +155 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.h +18 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +645 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.h +10 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.mm +422 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.mm +164 -0
- package/vendor/node_modules/@legendapp/spark-ui/package.json +17 -4
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkSelectNativeComponent.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +6 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +37 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +86 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/classnames/index.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +42 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +56 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/glass-effect-view/index.tsx +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +35 -21
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +55 -26
- package/vendor/node_modules/@legendapp/spark-ui/src/index.tsx +1 -27
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +45 -14
- package/vendor/node_modules/@legendapp/spark-ui/src/index.windows.tsx +1 -42
- package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +11 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSelectNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/select.ts +5 -3
- package/vendor/node_modules/@legendapp/spark-ui/src/sf-symbol/SFSymbolNativeComponent.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sf-symbol/index.tsx +27 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +25 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +24 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +104 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/specialized.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/SwipeActionsNativeComponent.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/index.tsx +41 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/text-input-search/TextInputSearchNativeComponent.ts +33 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/text-input-search/index.tsx +34 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +30 -19
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +16 -11
- package/vendor/node_modules/@legendapp/spark-updates/macos/RNDesktopUpdates.mm +21 -8
- package/vendor/node_modules/@legendapp/spark-updates/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-updates/src/NativeDesktopUpdates.ts +3 -2
- package/vendor/node_modules/@legendapp/spark-updates/src/index.ts +71 -15
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-webview/src/WebView.tsx +11 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/adapter.ts +55 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/index.ts +2 -2
- package/vendor/node_modules/@legendapp/spark-webview/src/types.ts +32 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/view-props.ts +28 -0
- package/vendor/node_modules/@legendapp/spark-window-options/index.cjs +51 -14
- package/vendor/node_modules/@legendapp/spark-window-options/index.d.ts +21 -8
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
- package/windows-macos.ts +1 -0
- package/expo-metro.cjs +0 -1
- package/message-dialog.ts +0 -1
- package/universal.cjs +0 -1
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/accelerator.ts +0 -22
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows-options.ts +0 -11
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/index.windows.ts +0 -15
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/accelerator.ts +0 -22
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkSelect.h +0 -4
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkSelect.mm +0 -53
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-desktop-shortcuts",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"react-native": "src/index",
|
|
@@ -19,14 +19,17 @@
|
|
|
19
19
|
"jsSrcsDir": "src",
|
|
20
20
|
"ios": {
|
|
21
21
|
"modulesProvider": {
|
|
22
|
-
"NativeDesktopShortcuts": "RNDesktopShortcuts"
|
|
23
|
-
|
|
22
|
+
"NativeDesktopShortcuts": "RNDesktopShortcuts",
|
|
23
|
+
"NativeKeyboardManager": "RNKeyboardManager"
|
|
24
|
+
},
|
|
25
|
+
"componentProvider": {}
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
"spark": {
|
|
27
29
|
"sdk": true,
|
|
28
30
|
"nativeModules": [
|
|
29
|
-
"NativeDesktopShortcuts"
|
|
31
|
+
"NativeDesktopShortcuts",
|
|
32
|
+
"NativeKeyboardManager"
|
|
30
33
|
],
|
|
31
34
|
"pod": "RNDesktopShortcuts",
|
|
32
35
|
"platforms": [
|
|
@@ -37,7 +40,7 @@
|
|
|
37
40
|
]
|
|
38
41
|
},
|
|
39
42
|
"dependencies": {
|
|
40
|
-
"@legendapp/spark-desktop-app": "0.0.1-next.
|
|
43
|
+
"@legendapp/spark-desktop-app": "0.0.1-next.4"
|
|
41
44
|
},
|
|
42
45
|
"private": true
|
|
43
46
|
}
|
package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/NativeDesktopShortcuts.ts
CHANGED
|
@@ -5,4 +5,4 @@ export interface Spec extends TurboModule {
|
|
|
5
5
|
addListener(eventName: string): void;
|
|
6
6
|
removeListeners(count: number): void;
|
|
7
7
|
}
|
|
8
|
-
export default TurboModuleRegistry.
|
|
8
|
+
export default TurboModuleRegistry.get<Spec>("NativeDesktopShortcuts");
|
|
@@ -1,20 +1,45 @@
|
|
|
1
1
|
import { NativeEventEmitter, Platform } from "react-native";
|
|
2
2
|
import Native from "./NativeDesktopShortcuts";
|
|
3
|
-
import { parseAccelerator } from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
export
|
|
3
|
+
import { parseAccelerator } from "@legendapp/spark-desktop-app/src/contracts/accelerator";
|
|
4
|
+
import { SparkError, invokeNative, parseNativeResult, asyncRegistration, type AsyncRegistration, type Availability } from "@legendapp/spark-desktop-app/src/contracts";
|
|
5
|
+
export type { AsyncRegistration } from "@legendapp/spark-desktop-app/src/contracts";
|
|
6
|
+
export { parseAccelerator, type Accelerator } from "@legendapp/spark-desktop-app/src/contracts/accelerator";
|
|
7
|
+
export interface ShortcutOptions { windowId?: string; repeat?: boolean }
|
|
8
|
+
export function getShortcutAvailability(): Availability {
|
|
9
|
+
if (Platform.OS !== "macos" && Platform.OS !== "windows") return { available: false, reason: "unsupported-platform" };
|
|
10
|
+
return Native ? { available: true } : { available: false, reason: "missing-module" };
|
|
11
|
+
}
|
|
12
|
+
function native() {
|
|
13
|
+
const availability = getShortcutAvailability();
|
|
14
|
+
if (!availability.available) throw new SparkError(availability.reason === "unsupported-platform" ? "E_UNSUPPORTED_PLATFORM" : "E_MODULE_UNAVAILABLE", "Application shortcuts are unavailable");
|
|
15
|
+
return Native!;
|
|
16
|
+
}
|
|
17
|
+
async function call(method: string, args: object) {
|
|
18
|
+
parseNativeResult(await invokeNative(() => native().call(method, JSON.stringify(args))), (value): value is null => value === null);
|
|
19
|
+
}
|
|
20
|
+
/** Focused-app shortcuts, consumed before insertion into text fields. Repeat defaults to false. */
|
|
21
|
+
export async function registerShortcut(accelerator: string, handler: () => void, options: ShortcutOptions = {}): Promise<AsyncRegistration> {
|
|
22
|
+
if (typeof handler !== "function" || !options || typeof options !== "object" || Array.isArray(options)) throw new SparkError("E_INVALID_ARGUMENT", "Expected shortcut handler and options");
|
|
23
|
+
for (const key of Object.keys(options)) if (!["windowId", "repeat"].includes(key)) throw new SparkError("E_UNSUPPORTED_OPTION", `Unsupported shortcut option: ${key}`);
|
|
24
|
+
if (options.windowId !== undefined && (typeof options.windowId !== "string" || !/^[a-zA-Z0-9_-]{1,100}$/.test(options.windowId))) throw new SparkError("E_INVALID_ARGUMENT", "Invalid shortcut windowId");
|
|
25
|
+
if (options.repeat !== undefined && typeof options.repeat !== "boolean") throw new SparkError("E_INVALID_ARGUMENT", "Shortcut repeat must be boolean");
|
|
26
|
+
const parsed = parseAccelerator(accelerator, Platform.OS === "windows" ? "windows" : "macos");
|
|
9
27
|
const id = `shortcut-${Date.now()}-${++nextID}`;
|
|
10
|
-
const parsed = parseAccelerator(Platform.OS === "windows" ? accelerator.replace(/commandorcontrol|cmdorctrl/ig, "Control") : accelerator);
|
|
11
28
|
let removed = false;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
29
|
+
const module = native();
|
|
30
|
+
const subscription = new NativeEventEmitter(module).addListener("shortcut", (event: unknown) => {
|
|
31
|
+
if (!removed && event && typeof event === "object" && (event as { id?: unknown }).id === id) {
|
|
32
|
+
try { handler(); }
|
|
33
|
+
catch (cause) { console.error(new SparkError("E_NATIVE", "Shortcut handler failed", { cause })); }
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
try { await call("register", { id, ...parsed, ...options }); }
|
|
37
|
+
catch (cause) {
|
|
38
|
+
removed = true; subscription.remove();
|
|
39
|
+
try { await call("remove", { id }); }
|
|
40
|
+
catch (cleanup) { throw new SparkError("E_NATIVE", "Shortcut registration and cleanup failed", { cause: new AggregateError([cause, cleanup]) }); }
|
|
41
|
+
throw cause;
|
|
42
|
+
}
|
|
43
|
+
return asyncRegistration(() => { removed = true; subscription.remove(); }, async () => { await call("remove", { id }); });
|
|
19
44
|
}
|
|
20
45
|
let nextID = 0;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TurboModule } from "react-native";
|
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
startMonitoringKeyboard(): Promise<boolean>;
|
|
6
|
+
stopMonitoringKeyboard(): Promise<boolean>;
|
|
7
|
+
setConsumption(ownerId: string, rulesJson: string, capture: boolean): Promise<boolean>;
|
|
8
|
+
addListener(eventName: string): void;
|
|
9
|
+
removeListeners(count: number): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default TurboModuleRegistry.get<Spec>("NativeKeyboardManager");
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export const KeyCodes = {
|
|
2
|
+
KEY_A: 0,
|
|
3
|
+
KEY_S: 1,
|
|
4
|
+
KEY_D: 2,
|
|
5
|
+
KEY_F: 3,
|
|
6
|
+
KEY_H: 4,
|
|
7
|
+
KEY_G: 5,
|
|
8
|
+
KEY_Z: 6,
|
|
9
|
+
KEY_X: 7,
|
|
10
|
+
KEY_C: 8,
|
|
11
|
+
KEY_V: 9,
|
|
12
|
+
KEY_B: 11,
|
|
13
|
+
KEY_Q: 12,
|
|
14
|
+
KEY_W: 13,
|
|
15
|
+
KEY_E: 14,
|
|
16
|
+
KEY_R: 15,
|
|
17
|
+
KEY_Y: 16,
|
|
18
|
+
KEY_T: 17,
|
|
19
|
+
KEY_1: 18,
|
|
20
|
+
KEY_2: 19,
|
|
21
|
+
KEY_3: 20,
|
|
22
|
+
KEY_4: 21,
|
|
23
|
+
KEY_6: 22,
|
|
24
|
+
KEY_5: 23,
|
|
25
|
+
KEY_EQUALS: 24,
|
|
26
|
+
KEY_9: 25,
|
|
27
|
+
KEY_7: 26,
|
|
28
|
+
KEY_MINUS: 27,
|
|
29
|
+
KEY_8: 28,
|
|
30
|
+
KEY_0: 29,
|
|
31
|
+
KEY_RIGHT_BRACKET: 30,
|
|
32
|
+
KEY_O: 31,
|
|
33
|
+
KEY_U: 32,
|
|
34
|
+
KEY_LEFT_BRACKET: 33,
|
|
35
|
+
KEY_I: 34,
|
|
36
|
+
KEY_P: 35,
|
|
37
|
+
KEY_RETURN: 36,
|
|
38
|
+
KEY_L: 37,
|
|
39
|
+
KEY_J: 38,
|
|
40
|
+
KEY_K: 40,
|
|
41
|
+
KEY_COMMA: 43,
|
|
42
|
+
KEY_SLASH: 44,
|
|
43
|
+
KEY_N: 45,
|
|
44
|
+
KEY_M: 46,
|
|
45
|
+
KEY_PERIOD: 47,
|
|
46
|
+
KEY_TAB: 48,
|
|
47
|
+
KEY_SPACE: 49,
|
|
48
|
+
KEY_DELETE: 51,
|
|
49
|
+
KEY_BACKSPACE: 51,
|
|
50
|
+
KEY_ESCAPE: 53,
|
|
51
|
+
KEY_F17: 64,
|
|
52
|
+
KEY_F18: 79,
|
|
53
|
+
KEY_F19: 80,
|
|
54
|
+
KEY_F20: 90,
|
|
55
|
+
KEY_F5: 96,
|
|
56
|
+
KEY_F6: 97,
|
|
57
|
+
KEY_F7: 98,
|
|
58
|
+
KEY_F3: 99,
|
|
59
|
+
KEY_F8: 100,
|
|
60
|
+
KEY_F9: 101,
|
|
61
|
+
KEY_F11: 103,
|
|
62
|
+
KEY_F16: 106,
|
|
63
|
+
KEY_F14: 107,
|
|
64
|
+
KEY_F10: 109,
|
|
65
|
+
KEY_F12: 111,
|
|
66
|
+
KEY_F15: 113,
|
|
67
|
+
KEY_HELP: 114,
|
|
68
|
+
KEY_HOME: 115,
|
|
69
|
+
KEY_PAGE_UP: 116,
|
|
70
|
+
KEY_FORWARD_DELETE: 117,
|
|
71
|
+
KEY_F4: 118,
|
|
72
|
+
KEY_END: 119,
|
|
73
|
+
KEY_F2: 120,
|
|
74
|
+
KEY_PAGE_DOWN: 121,
|
|
75
|
+
KEY_F1: 122,
|
|
76
|
+
KEY_LEFT: 123,
|
|
77
|
+
KEY_RIGHT: 124,
|
|
78
|
+
KEY_DOWN: 125,
|
|
79
|
+
KEY_UP: 126,
|
|
80
|
+
KEY_MEDIA_PLAY_PAUSE: 10001,
|
|
81
|
+
KEY_MEDIA_NEXT: 10002,
|
|
82
|
+
KEY_MEDIA_PREVIOUS: 10003,
|
|
83
|
+
MODIFIER_CAPS_LOCK: 1 << 16,
|
|
84
|
+
MODIFIER_SHIFT: 1 << 17,
|
|
85
|
+
MODIFIER_CONTROL: 1 << 18,
|
|
86
|
+
MODIFIER_OPTION: 1 << 19,
|
|
87
|
+
MODIFIER_COMMAND: 1 << 20,
|
|
88
|
+
MODIFIER_FUNCTION: 1 << 23,
|
|
89
|
+
} as const;
|
|
90
|
+
|
|
91
|
+
export const KeyText: Record<number, string> = {
|
|
92
|
+
[KeyCodes.KEY_RETURN]: "Return",
|
|
93
|
+
[KeyCodes.KEY_TAB]: "Tab",
|
|
94
|
+
[KeyCodes.KEY_SPACE]: "Space",
|
|
95
|
+
[KeyCodes.KEY_DELETE]: "Delete",
|
|
96
|
+
[KeyCodes.KEY_FORWARD_DELETE]: "Forward Delete",
|
|
97
|
+
[KeyCodes.KEY_ESCAPE]: "Esc",
|
|
98
|
+
[KeyCodes.KEY_LEFT_BRACKET]: "[",
|
|
99
|
+
[KeyCodes.KEY_RIGHT_BRACKET]: "]",
|
|
100
|
+
[KeyCodes.KEY_LEFT]: "Left",
|
|
101
|
+
[KeyCodes.KEY_RIGHT]: "Right",
|
|
102
|
+
[KeyCodes.KEY_DOWN]: "Down",
|
|
103
|
+
[KeyCodes.KEY_UP]: "Up",
|
|
104
|
+
[KeyCodes.KEY_MEDIA_PLAY_PAUSE]: "Play/Pause",
|
|
105
|
+
[KeyCodes.KEY_MEDIA_NEXT]: "Next Track",
|
|
106
|
+
[KeyCodes.KEY_MEDIA_PREVIOUS]: "Previous Track",
|
|
107
|
+
};
|
|
108
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { NativeEventEmitter, Platform } from "react-native";
|
|
2
|
+
import Native from "./NativeKeyboardManager";
|
|
3
|
+
import { SparkError, asyncRegistration, invokeNative, type AsyncRegistration, type Availability, type Subscription } from "@legendapp/spark-desktop-app/src/contracts";
|
|
4
|
+
export type { AsyncRegistration } from "@legendapp/spark-desktop-app/src/contracts";
|
|
5
|
+
export { KeyCodes, KeyText } from "./codes";
|
|
6
|
+
export type KeyboardEvent = Readonly<{ repeated: boolean; consumed: boolean; captured: boolean; windowId: string | null; key: string; keyCode: number; modifiers: number }>;
|
|
7
|
+
export type KeyboardEventListener = (event: KeyboardEvent) => void;
|
|
8
|
+
export type KeyboardListenerOptions = { windowIds?: readonly string[] };
|
|
9
|
+
type Entry = { type: "down" | "up"; listener: KeyboardEventListener; windowIds?: readonly string[] };
|
|
10
|
+
const entries = new Set<Entry>(), consumers = new Set<string>();
|
|
11
|
+
let sequence = 0;
|
|
12
|
+
let subscriptions: Subscription[] = [], monitoring = false, transitions = Promise.resolve();
|
|
13
|
+
export function getKeyboardAvailability(): Availability {
|
|
14
|
+
if (Platform.OS !== "macos") return { available: false, reason: "unsupported-platform" };
|
|
15
|
+
return Native ? { available: true } : { available: false, reason: "missing-module" };
|
|
16
|
+
}
|
|
17
|
+
function native() {
|
|
18
|
+
const availability = getKeyboardAvailability();
|
|
19
|
+
if (!availability.available) throw new SparkError(availability.reason === "missing-module" ? "E_MODULE_UNAVAILABLE" : "E_UNSUPPORTED_PLATFORM", "Low-level keyboard monitoring requires a macOS host");
|
|
20
|
+
return Native!;
|
|
21
|
+
}
|
|
22
|
+
function notify(type: Entry["type"], value: unknown) {
|
|
23
|
+
if (!value || typeof value !== "object") return;
|
|
24
|
+
const event = value as KeyboardEvent;
|
|
25
|
+
if (typeof event.key !== "string" || !Number.isInteger(event.keyCode) || !Number.isInteger(event.modifiers) || typeof event.repeated !== "boolean" || typeof event.consumed !== "boolean" || typeof event.captured !== "boolean" || !(event.windowId === null || typeof event.windowId === "string")) return;
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
if (entry.type !== type || (entry.windowIds && !(event.windowId !== null && entry.windowIds.includes(event.windowId)))) continue;
|
|
28
|
+
try { entry.listener(event); } catch (cause) { console.error(new SparkError("E_NATIVE", "Keyboard listener failed", { cause })); }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function synchronize(): Promise<void> {
|
|
32
|
+
const pending = transitions.then(async () => {
|
|
33
|
+
if ((entries.size || consumers.size) && !monitoring) {
|
|
34
|
+
const module = native(), emitter = new NativeEventEmitter(module);
|
|
35
|
+
subscriptions = [emitter.addListener("onKeyDown", event => notify("down", event)), emitter.addListener("onKeyUp", event => notify("up", event))];
|
|
36
|
+
try {
|
|
37
|
+
const started = await invokeNative(() => module.startMonitoringKeyboard());
|
|
38
|
+
if (started !== true) throw new SparkError("E_INVALID_DATA", "Keyboard monitor did not start");
|
|
39
|
+
monitoring = true;
|
|
40
|
+
} catch (error) { for (const subscription of subscriptions) subscription.remove(); subscriptions = []; throw error; }
|
|
41
|
+
} else if (!entries.size && !consumers.size && monitoring) {
|
|
42
|
+
const stopped = await invokeNative(() => native().stopMonitoringKeyboard());
|
|
43
|
+
if (stopped !== true) throw new SparkError("E_INVALID_DATA", "Keyboard monitor did not stop");
|
|
44
|
+
monitoring = false;
|
|
45
|
+
for (const subscription of subscriptions) subscription.remove(); subscriptions = [];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
transitions = pending.catch(() => {}); return pending;
|
|
49
|
+
}
|
|
50
|
+
/** Nonblocking app-scoped observation. Return values never control native propagation. */
|
|
51
|
+
export async function addKeyboardListener(type: "down" | "up", listener: KeyboardEventListener, options: KeyboardListenerOptions = {}): Promise<AsyncRegistration> {
|
|
52
|
+
if ((type !== "down" && type !== "up") || typeof listener !== "function" || !options || typeof options !== "object" || Array.isArray(options)) throw new SparkError("E_INVALID_ARGUMENT", "Expected keyboard event type, listener and options");
|
|
53
|
+
for (const key of Object.keys(options)) if (key !== "windowIds") throw new SparkError("E_UNSUPPORTED_OPTION", `Unknown keyboard option: ${key}`);
|
|
54
|
+
if (options.windowIds !== undefined && (!Array.isArray(options.windowIds) || options.windowIds.some(id => typeof id !== "string" || !id))) throw new SparkError("E_INVALID_ARGUMENT", "Expected window IDs");
|
|
55
|
+
native();
|
|
56
|
+
const entry = { type, listener, windowIds: options.windowIds ? [...options.windowIds] : undefined };
|
|
57
|
+
entries.add(entry);
|
|
58
|
+
try { await synchronize(); } catch (error) { entries.delete(entry); throw error; }
|
|
59
|
+
return asyncRegistration(() => { entries.delete(entry); }, synchronize);
|
|
60
|
+
}
|
|
61
|
+
export function hasModifier(event: Pick<KeyboardEvent, "modifiers">, modifier: number): boolean { return (event.modifiers & modifier) === modifier; }
|
|
62
|
+
export function createModifierMask(...modifiers: number[]): number { return modifiers.reduce((mask, modifier) => mask | modifier, 0); }
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
/** Internal compiled rules, shared by command routing and keyboard capture. */
|
|
66
|
+
export interface KeyboardConsumptionRule {
|
|
67
|
+
key: string; modifiers: number; allowExtraModifiers: boolean; repeat: boolean;
|
|
68
|
+
windowIds?: readonly string[]; excludedWindowIds?: readonly string[];
|
|
69
|
+
}
|
|
70
|
+
export interface KeyboardConsumption extends AsyncRegistration { update(rules: readonly KeyboardConsumptionRule[]): Promise<void> }
|
|
71
|
+
export async function createKeyboardConsumption(rules: readonly KeyboardConsumptionRule[], capture = false): Promise<KeyboardConsumption> {
|
|
72
|
+
const module = native(), id = `keyboard-${++sequence}`;
|
|
73
|
+
const publish = async (value: readonly KeyboardConsumptionRule[], capturing = capture) => {
|
|
74
|
+
const json = JSON.stringify(value);
|
|
75
|
+
const result = await invokeNative(() => module.setConsumption(id, json, capturing));
|
|
76
|
+
if (result !== true) throw new SparkError("E_INVALID_DATA", "Keyboard consumption update was not acknowledged");
|
|
77
|
+
};
|
|
78
|
+
consumers.add(id);
|
|
79
|
+
try { await synchronize(); await publish(rules); }
|
|
80
|
+
catch (error) {
|
|
81
|
+
consumers.delete(id);
|
|
82
|
+
try { await publish([], false); await synchronize(); }
|
|
83
|
+
catch (cleanupError) { throw new AggregateError([error, cleanupError], "Keyboard consumption setup and cleanup failed"); }
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
let closed = false, pending: Promise<unknown> = Promise.resolve();
|
|
87
|
+
const removal = asyncRegistration(() => { closed = true; }, async () => {
|
|
88
|
+
await pending.catch(() => {});
|
|
89
|
+
await publish([], false); consumers.delete(id); await synchronize();
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
remove: removal.remove,
|
|
93
|
+
update(value) {
|
|
94
|
+
if (closed) return Promise.reject(new SparkError("E_CLOSED", "Keyboard consumption has been removed"));
|
|
95
|
+
// Submit now: the module's main queue owns update ordering and snapshots.
|
|
96
|
+
const result = publish(value); pending = result; return result;
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|