@legendapp/spark 0.0.1-next.2 → 0.0.1-next.3
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/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 +82 -14
- 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-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 +83 -48
- package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +60 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +7 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +31 -5
- package/vendor/node_modules/@legendapp/spark-cli/dist/credentials.js +69 -23
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +12 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +12 -9
- package/vendor/node_modules/@legendapp/spark-cli/dist/examples.js +1 -1
- 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-node.js +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +10 -38
- 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 +84 -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/project.js +66 -13
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.js +84 -4
- 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/updates.js +41 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +4 -1
- 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 +11 -9
- 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 +13 -11
- 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 +13 -11
- 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 +114 -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 +16 -3
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +89 -9
- 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/package.json +6 -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 +3130 -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 +144 -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 +46 -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 +1182 -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/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 +16 -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 +31 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +77 -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/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,19 +1,22 @@
|
|
|
1
|
-
import { openFileDialog, saveFileDialog
|
|
1
|
+
import { openFileDialog, saveFileDialog } from "@legendapp/spark/dialogs";
|
|
2
|
+
import { readText, writeText, writeTextIfUnchanged } from "@legendapp/spark/files";
|
|
2
3
|
import { Alert } from "react-native";
|
|
3
4
|
import type { DocumentIO } from "./document";
|
|
4
5
|
export const io: DocumentIO = {
|
|
5
6
|
async open() {
|
|
6
|
-
const paths = await openFileDialog({
|
|
7
|
-
if (
|
|
8
|
-
const location = paths[0];
|
|
9
|
-
return { file: { location, name: location.split(/[\\/]/).pop()! }, text: await
|
|
7
|
+
const paths = await openFileDialog({ filters: [{ extensions: ["txt", "md", "json"] }], multiple: false });
|
|
8
|
+
if (paths.canceled) return null;
|
|
9
|
+
const location = paths.paths[0];
|
|
10
|
+
return { file: { location, name: location.split(/[\\/]/).pop()! }, text: await readText(location) };
|
|
10
11
|
},
|
|
11
12
|
async save(file, text, expected, saveAs) {
|
|
12
|
-
const
|
|
13
|
+
const result = saveAs || !file.location ? await saveFileDialog({ defaultName: file.name, filters: [{ extensions: ["txt", "md", "json"] }] }) : { canceled: false as const, path: file.location };
|
|
14
|
+
if (result.canceled) return null;
|
|
15
|
+
const location = result.path;
|
|
13
16
|
if (!location) return null;
|
|
14
17
|
if (location === file.location) {
|
|
15
|
-
if (!await
|
|
16
|
-
} else await
|
|
18
|
+
if (!(await writeTextIfUnchanged(location, expected, text)).written) throw new Error("The file changed outside the editor. Use Save As to keep your edits in another file.");
|
|
19
|
+
} else await writeText(location, text);
|
|
17
20
|
return { location, name: location.split(/[\\/]/).pop()! };
|
|
18
21
|
},
|
|
19
22
|
confirmDiscard: name => new Promise(resolve => Alert.alert("Unsaved changes", `Save changes to ${name}?`, [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { io as desktop } from "./io.desktop";
|
|
2
|
-
import { showMessage } from "@legendapp/spark/
|
|
2
|
+
import { showMessage } from "@legendapp/spark/dialogs";
|
|
3
3
|
import type { DocumentIO } from "./document";
|
|
4
4
|
export const io: DocumentIO = { ...desktop, async confirmDiscard(name) {
|
|
5
|
-
const {
|
|
6
|
-
return
|
|
5
|
+
const { buttonId } = await showMessage({ title: "Unsaved changes", message: `Save changes to ${name}?`, buttons: [{ id: "cancel", label: "Cancel" }, { id: "discard", label: "Discard" }, { id: "save", label: "Save" }], cancelButtonId: "cancel", defaultButtonId: "save" });
|
|
6
|
+
return buttonId === "save" ? "save" : buttonId === "discard" ? "discard" : "cancel";
|
|
7
7
|
} };
|
package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.desktop.tsx
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
|
-
import { beforeWindowClose,
|
|
3
|
+
import { beforeWindowClose, setWindowOptions, addWindowListener } from "@legendapp/spark/windows";
|
|
4
4
|
import { beforeQuit } from "@legendapp/spark/app";
|
|
5
|
-
import {
|
|
6
|
-
import { registerShortcut
|
|
5
|
+
import { createMenu, type MenuItem } from "@legendapp/spark/menus";
|
|
6
|
+
import { registerShortcut } from "@legendapp/spark/shortcuts";
|
|
7
7
|
import { mountSerial } from "./lifetime";
|
|
8
8
|
import type { LifecycleProps } from "./lifecycle-types";
|
|
9
|
-
let activeMenuOwner: string | undefined;
|
|
10
9
|
export function Lifecycle({ title, windowId = "main", flush, quit, commands, onError }: LifecycleProps) {
|
|
11
|
-
useEffect(() => { void
|
|
10
|
+
useEffect(() => { void setWindowOptions(windowId, { title: title }).catch(error => onError(String(error))); }, [title, windowId, onError]);
|
|
12
11
|
useEffect(() => mountSerial(`window-${windowId}`, async retain => {
|
|
13
12
|
const owner = `example-${windowId}`;
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
menu();
|
|
20
|
-
await retain(Promise.resolve({ remove: () => { clearMenus(owner); if (activeMenuOwner === owner) activeMenuOwner = undefined; } }));
|
|
21
|
-
await retain(Promise.resolve(addNativeMenuActionListener(event => { if (event.ownerId === owner) commands.find(command => command.id === event.itemId)?.run(); })));
|
|
22
|
-
await retain(Promise.resolve(onWindowEvent(event => { if (event.windowId === windowId && event.type === "focus") menu(); })));
|
|
13
|
+
const items: MenuItem[] = [{ type: "submenu", id: "file", target: { menu: "file" }, label: "File", items: commands.map(({ id, title, key }) => ({ type: "action", id, label: title, shortcut: `CmdOrCtrl+${key}` })) }];
|
|
14
|
+
const menu = await createMenu({ id: owner, items, onAction: event => { commands.find(command => command.id === event.itemId)?.run(); } });
|
|
15
|
+
await retain(Promise.resolve(menu));
|
|
16
|
+
await retain(addWindowListener(windowId, "focusChanged", event => { if (event.focused) void menu.update({ items }).catch(error => onError(String(error))); }));
|
|
23
17
|
const guarded = (save: () => Promise<boolean>) => async () => {
|
|
24
18
|
try { return await save(); } catch (error) { onError(String(error)); return false; }
|
|
25
19
|
};
|
package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.desktop.tsx
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { onOpen } from "@legendapp/spark/links";
|
|
2
|
+
import { subscribeToOpenRequests } from "@legendapp/spark/app/documents";
|
|
4
3
|
import { mountSerial } from "./lifetime";
|
|
5
4
|
import type { OpenFilesProps } from "./OpenFiles";
|
|
6
|
-
//
|
|
5
|
+
// Each subscription replays queued launches to each subscription. Remounts must not import twice.
|
|
7
6
|
const imported = new Set<string>();
|
|
8
7
|
const importing = new Set<string>();
|
|
9
8
|
export function OpenFiles({ windowId = "main", onFile, onError }: OpenFilesProps) {
|
|
10
9
|
useEffect(() => {
|
|
11
10
|
if (windowId !== "main") return;
|
|
12
|
-
return mountSerial("file-activation", async retain => { await retain(
|
|
13
|
-
if (event.type !== "
|
|
11
|
+
return mountSerial("file-activation", async retain => { await retain(subscribeToOpenRequests(event => {
|
|
12
|
+
if (event.type !== "file") return;
|
|
14
13
|
if (imported.has(event.id) || importing.has(event.id)) return;
|
|
15
|
-
const match = /^file:\/\/(?:localhost)?(\/.*)$/.exec(event.url);
|
|
16
|
-
if (!match) { onError("Unsupported file URL"); return; }
|
|
17
14
|
importing.add(event.id);
|
|
18
15
|
void (async () => {
|
|
19
|
-
|
|
20
|
-
if (Platform.OS === "windows") path = path.replace(/^\/([a-z]:)/i, "$1").replace(/\//g, "\\");
|
|
21
|
-
await onFile(path);
|
|
16
|
+
await onFile(event.path);
|
|
22
17
|
imported.add(event.id);
|
|
23
18
|
if (imported.size > 200) imported.delete(imported.values().next().value!);
|
|
24
19
|
})().catch(error => onError(String(error))).finally(() => importing.delete(event.id));
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { openFileDialog, saveFileDialog
|
|
1
|
+
import { openFileDialog, saveFileDialog } from "@legendapp/spark/dialogs";
|
|
2
|
+
import { readText, writeText, writeTextIfUnchanged } from "@legendapp/spark/files";
|
|
2
3
|
import { Alert } from "react-native";
|
|
3
4
|
import type { DocumentIO } from "./document";
|
|
4
5
|
export const io: DocumentIO = {
|
|
5
6
|
async open() {
|
|
6
|
-
const paths = await openFileDialog({
|
|
7
|
-
if (
|
|
8
|
-
const location = paths[0];
|
|
9
|
-
return { file: { location, name: location.split(/[\\/]/).pop()! }, text: await
|
|
7
|
+
const paths = await openFileDialog({ filters: [{ extensions: ["txt", "md", "json"] }], multiple: false });
|
|
8
|
+
if (paths.canceled) return null;
|
|
9
|
+
const location = paths.paths[0];
|
|
10
|
+
return { file: { location, name: location.split(/[\\/]/).pop()! }, text: await readText(location) };
|
|
10
11
|
},
|
|
11
12
|
async save(file, text, expected, saveAs) {
|
|
12
|
-
const
|
|
13
|
+
const result = saveAs || !file.location ? await saveFileDialog({ defaultName: file.name, filters: [{ extensions: ["txt", "md", "json"] }] }) : { canceled: false as const, path: file.location };
|
|
14
|
+
if (result.canceled) return null;
|
|
15
|
+
const location = result.path;
|
|
13
16
|
if (!location) return null;
|
|
14
17
|
if (location === file.location) {
|
|
15
|
-
if (!await
|
|
16
|
-
} else await
|
|
18
|
+
if (!(await writeTextIfUnchanged(location, expected, text)).written) throw new Error("The file changed outside the editor. Use Save As to keep your edits in another file.");
|
|
19
|
+
} else await writeText(location, text);
|
|
17
20
|
return { location, name: location.split(/[\\/]/).pop()! };
|
|
18
21
|
},
|
|
19
22
|
confirmDiscard: name => new Promise(resolve => Alert.alert("Unsaved changes", `Save changes to ${name}?`, [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { io as desktop } from "./io.desktop";
|
|
2
|
-
import { showMessage } from "@legendapp/spark/
|
|
2
|
+
import { showMessage } from "@legendapp/spark/dialogs";
|
|
3
3
|
import type { DocumentIO } from "./document";
|
|
4
4
|
export const io: DocumentIO = { ...desktop, async confirmDiscard(name) {
|
|
5
|
-
const {
|
|
6
|
-
return
|
|
5
|
+
const { buttonId } = await showMessage({ title: "Unsaved changes", message: `Save changes to ${name}?`, buttons: [{ id: "cancel", label: "Cancel" }, { id: "discard", label: "Discard" }, { id: "save", label: "Save" }], cancelButtonId: "cancel", defaultButtonId: "save" });
|
|
6
|
+
return buttonId === "save" ? "save" : buttonId === "discard" ? "discard" : "cancel";
|
|
7
7
|
} };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { openFileDialog } from "@legendapp/spark/dialogs";
|
|
2
2
|
import type { Track } from "./model";
|
|
3
3
|
export async function importTracks(): Promise<Track[]> {
|
|
4
|
-
const paths = await openFileDialog({
|
|
5
|
-
return (paths
|
|
4
|
+
const paths = await openFileDialog({ filters: [{ extensions: ["mp3", "m4a", "wav", "aac", "flac", "ogg"] }], multiple: true });
|
|
5
|
+
return (paths.canceled ? [] : paths.paths).map(uri => ({ id: uri, uri, name: uri.split(/[\\/]/).pop()! }));
|
|
6
6
|
}
|
|
7
7
|
export const resolveTrack = async (track: Track) => ({ uri: track.uri, release() {} });
|
package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.desktop.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readText } from "@legendapp/spark/files";
|
|
2
2
|
import { OpenFiles } from "./shared/OpenFiles";
|
|
3
3
|
import { notes } from "./store";
|
|
4
|
-
const open = async (path: string) => { await notes.load(); if (!notes.getSnapshot().ready) throw new Error("Notes storage is unavailable"); const text = await
|
|
4
|
+
const open = async (path: string) => { await notes.load(); if (!notes.getSnapshot().ready) throw new Error("Notes storage is unavailable"); const text = await readText(path); notes.create(text); };
|
|
5
5
|
export function Activation({ windowId, onError }: { windowId: string; onError(message: string): void }) { return <OpenFiles windowId={windowId} onFile={open} onError={onError} />; }
|
|
@@ -1,25 +1,47 @@
|
|
|
1
|
-
import { getDisplays, listWindows, openWindow,
|
|
1
|
+
import { addWindowListener, getDisplays, listWindows, openWindow, setWindowBounds, showWindow } from "@legendapp/spark/windows";
|
|
2
|
+
import type { AsyncRegistration } from "@legendapp/spark/contracts";
|
|
2
3
|
import { notes } from "./store";
|
|
3
4
|
import { WindowSession } from "./window-session";
|
|
4
5
|
export const desktop = true;
|
|
5
6
|
const session = new WindowSession(notes, {
|
|
6
|
-
list: listWindows,
|
|
7
|
-
workAreas: async () => (await getDisplays()).map(display => display.workArea),
|
|
7
|
+
list: async () => (await listWindows()).map(window => ({ id: window.id, frame: window.bounds })),
|
|
8
|
+
workAreas: async () => (await getDisplays()).sort((a, b) => Number(b.primary) - Number(a.primary)).map(display => ({ ...display.workArea, displayId: display.id })),
|
|
8
9
|
show: showWindow,
|
|
9
|
-
frame:
|
|
10
|
-
open: window => openWindow({ id: window.id, title: window.id === "settings" ? "Notes Settings" : "Notes", width: window.frame.width, height: window.frame.height, props: window.id === "settings" ? { settings: true } : { noteId: window.noteId } }),
|
|
10
|
+
frame: setWindowBounds,
|
|
11
|
+
open: window => openWindow({ id: window.id, component: "main", title: window.id === "settings" ? "Notes Settings" : "Notes", size: { width: window.frame.width, height: window.frame.height }, position: { displayId: window.frame.displayId, x: window.frame.x, y: window.frame.y }, props: { windowId: window.id, windowProps: window.id === "settings" ? { settings: true } : { noteId: window.noteId } } }),
|
|
11
12
|
});
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const watchers = new Set<(message: string) => void>();
|
|
14
|
+
const registrations = new Map<string, AsyncRegistration[]>();
|
|
15
|
+
let generation = 0, timer: ReturnType<typeof setTimeout> | undefined;
|
|
16
|
+
function report(error: unknown) { for (const watcher of watchers) watcher(String(error)); }
|
|
17
|
+
function changed() { clearTimeout(timer); timer = setTimeout(() => { void session.capture().catch(report); }, 150); }
|
|
18
|
+
let pending: Promise<void> = Promise.resolve();
|
|
19
|
+
function observeWindows() {
|
|
20
|
+
const epoch = generation;
|
|
21
|
+
const task = pending.then(async () => {
|
|
22
|
+
if (!watchers.size || epoch !== generation) return;
|
|
23
|
+
for (const window of await listWindows()) {
|
|
24
|
+
if (!session.known(window.id) || registrations.has(window.id)) continue;
|
|
25
|
+
const owned: AsyncRegistration[] = [];
|
|
26
|
+
try {
|
|
27
|
+
owned.push(await addWindowListener(window.id, "boundsChanged", changed));
|
|
28
|
+
owned.push(await addWindowListener(window.id, "closed", () => { registrations.delete(window.id); for (const value of owned) void value.remove().catch(report); changed(); }));
|
|
29
|
+
if (watchers.size && epoch === generation) registrations.set(window.id, owned);
|
|
30
|
+
else for (const value of owned) await value.remove();
|
|
31
|
+
} catch (error) { for (const value of owned) await value.remove(); throw error; }
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
pending = task.catch(() => {}); return task;
|
|
35
|
+
}
|
|
36
|
+
export async function openNote(noteId: string) { await session.openNote(noteId); await observeWindows(); }
|
|
37
|
+
export async function openSettings() { await session.openSettings(); await observeWindows(); }
|
|
14
38
|
export const showNotebook = () => showWindow("main");
|
|
15
|
-
export
|
|
39
|
+
export async function restoreSession() { await session.restore(); await observeWindows(); }
|
|
16
40
|
export const flushSession = session.quit;
|
|
17
41
|
export function watchSession(onError: (message: string) => void) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
clearTimeout(timer);
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
return { remove() { clearTimeout(timer); subscription.remove(); } };
|
|
42
|
+
watchers.add(onError); void observeWindows().catch(report);
|
|
43
|
+
return { remove() {
|
|
44
|
+
watchers.delete(onError);
|
|
45
|
+
if (!watchers.size) { generation++; clearTimeout(timer); for (const owned of registrations.values()) for (const value of owned) void value.remove().catch(console.error); registrations.clear(); }
|
|
46
|
+
} };
|
|
25
47
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
export type Theme = "system" | "light" | "dark";
|
|
2
|
-
export type Frame = { x: number; y: number; width: number; height: number };
|
|
2
|
+
export type Frame = { displayId: string; x: number; y: number; width: number; height: number };
|
|
3
3
|
export type SavedWindow = { id: string; noteId?: string; frame: Frame };
|
|
4
4
|
export function decodeWindows(value: unknown): SavedWindow[] {
|
|
5
5
|
if (value === undefined) return [];
|
|
6
|
-
if (!Array.isArray(value) || !value.every(item => item && typeof item.id === "string" && /^(main|settings|note-[a-zA-Z0-9_-]+)$/.test(item.id) && (item.noteId === undefined || typeof item.noteId === "string") && item.frame && ["x", "y", "width", "height"].every(key => Number.isFinite(item.frame[key])) && item.frame.width >= 100 && item.frame.height >= 100 && item.frame.width <= 20000 && item.frame.height <= 20000) || new Set(value.map(item => item.id)).size !== value.length) throw new Error("Unsupported window session");
|
|
6
|
+
if (!Array.isArray(value) || !value.every(item => item && typeof item.id === "string" && /^(main|settings|note-[a-zA-Z0-9_-]+)$/.test(item.id) && (item.noteId === undefined || typeof item.noteId === "string") && item.frame && typeof item.frame.displayId === "string" && item.frame.displayId.length > 0 && ["x", "y", "width", "height"].every(key => Number.isFinite(item.frame[key])) && item.frame.width >= 100 && item.frame.height >= 100 && item.frame.width <= 20000 && item.frame.height <= 20000) || new Set(value.map(item => item.id)).size !== value.length) throw new Error("Unsupported window session");
|
|
7
7
|
return value;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/** Saved bounds and work areas use the same display-relative logical units. */
|
|
10
10
|
export function fitFrame(frame: Frame, workAreas: Frame[]): Frame {
|
|
11
11
|
if (!workAreas.length) return frame;
|
|
12
|
-
const
|
|
13
|
-
const area = workAreas.reduce((best, current) => overlap(current) > overlap(best) ? current : best);
|
|
12
|
+
const area = workAreas.find(area => area.displayId === frame.displayId) ?? workAreas[0];
|
|
14
13
|
const width = Math.min(frame.width, area.width), height = Math.min(frame.height, area.height);
|
|
15
|
-
return { x: Math.max(area.x, Math.min(frame.x, area.x + area.width - width)), y: Math.max(area.y, Math.min(frame.y, area.y + area.height - height)), width, height };
|
|
14
|
+
return { displayId: area.displayId, x: Math.max(area.x, Math.min(frame.x, area.x + area.width - width)), y: Math.max(area.y, Math.min(frame.y, area.y + area.height - height)), width, height };
|
|
16
15
|
}
|
|
@@ -20,13 +20,13 @@ export class WindowSession {
|
|
|
20
20
|
const id = `note-${noteId}`;
|
|
21
21
|
this.noteIds.set(id, noteId);
|
|
22
22
|
if ((await this.host.list()).some(window => window.id === id)) await this.host.show(id);
|
|
23
|
-
else await this.host.open({ id, noteId, frame: { x: 0, y: 0, width: 700, height: 600 } });
|
|
23
|
+
else await this.host.open({ id, noteId, frame: fitFrame({ displayId: "", x: 0, y: 0, width: 700, height: 600 }, await this.host.workAreas()) });
|
|
24
24
|
await this.capture();
|
|
25
25
|
}
|
|
26
26
|
async openSettings() {
|
|
27
27
|
await this.restore();
|
|
28
28
|
if ((await this.host.list()).some(window => window.id === "settings")) await this.host.show("settings");
|
|
29
|
-
else await this.host.open({ id: "settings", frame: { x: 0, y: 0, width: 460, height: 360 } });
|
|
29
|
+
else await this.host.open({ id: "settings", frame: fitFrame({ displayId: "", x: 0, y: 0, width: 460, height: 360 }, await this.host.workAreas()) });
|
|
30
30
|
await this.capture();
|
|
31
31
|
}
|
|
32
32
|
capture = () => {
|
|
@@ -46,8 +46,9 @@ export class WindowSession {
|
|
|
46
46
|
for (const window of saved) {
|
|
47
47
|
if (window.id !== "main" && window.id !== "settings" && !this.notes.getSnapshot().notes.some(note => note.id === window.noteId && !note.deleted)) continue;
|
|
48
48
|
if (window.noteId) this.noteIds.set(window.id, window.noteId);
|
|
49
|
-
|
|
50
|
-
await this.host.
|
|
49
|
+
const frame = fitFrame(window.frame, areas);
|
|
50
|
+
if (window.id !== "main" && !(await this.host.list()).some(item => item.id === window.id)) await this.host.open({ ...window, frame });
|
|
51
|
+
await this.host.frame(window.id, frame);
|
|
51
52
|
}
|
|
52
53
|
await this.capture();
|
|
53
54
|
})();
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
"name": "HelloWorld",
|
|
4
4
|
"version": "0.0.1",
|
|
5
5
|
"window": {
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"size": {
|
|
7
|
+
"width": 1000,
|
|
8
|
+
"height": 700
|
|
9
|
+
},
|
|
10
|
+
"restoreBounds": true
|
|
9
11
|
},
|
|
10
12
|
"macos": {
|
|
11
13
|
"bundleIdentifier": "so.legend.spark.prototype.helloworld"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { withUniwindConfig } = require("uniwind/metro");
|
|
2
|
-
const { metroConfig } = require("@legendapp/spark/
|
|
2
|
+
const { metroConfig } = require("@legendapp/spark/metro");
|
|
3
3
|
|
|
4
4
|
module.exports = withUniwindConfig(metroConfig(__dirname), {
|
|
5
5
|
cssEntryFile: "./global.css",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"expo": "54.0.37",
|
|
21
|
-
"expo-desktop": "1.0.0
|
|
22
|
-
"expo-desktop-prebuild-config": "1.1.0
|
|
23
|
-
"expo-desktop-config-plugins": "1.2.0
|
|
24
|
-
"expo-desktop-metro-config": "54.81.0
|
|
25
|
-
"expo-desktop-template-bare-minimum": "54.81.1
|
|
21
|
+
"expo-desktop": "1.0.0",
|
|
22
|
+
"expo-desktop-prebuild-config": "1.1.0",
|
|
23
|
+
"expo-desktop-config-plugins": "1.2.0",
|
|
24
|
+
"expo-desktop-metro-config": "54.81.0",
|
|
25
|
+
"expo-desktop-template-bare-minimum": "54.81.1",
|
|
26
26
|
"react": "19.1.4",
|
|
27
27
|
"react-native": "0.81.6",
|
|
28
28
|
"react-native-macos": "0.81.7",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"typescript": "5.9.3",
|
|
31
31
|
"@types/react": "19.1.10",
|
|
32
32
|
"react-native-windows": "0.81.35",
|
|
33
|
-
"expo-desktop-modules-core": "54.0.14
|
|
34
|
-
"expo-desktop-stubs": "54.0.14
|
|
33
|
+
"expo-desktop-modules-core": "54.0.14",
|
|
34
|
+
"expo-desktop-stubs": "54.0.14",
|
|
35
35
|
"@expo/ui": "0.2.0-beta.9",
|
|
36
36
|
"expo-dev-client": "6.0.21",
|
|
37
37
|
"expo-clipboard": "8.0.8",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"react-native-web": "0.21.0",
|
|
42
42
|
"uniwind": "1.6.3",
|
|
43
43
|
"tailwindcss": "4.2.4",
|
|
44
|
-
"@legendapp/spark": "0.0.1-next.
|
|
44
|
+
"@legendapp/spark": "0.0.1-next.3"
|
|
45
45
|
},
|
|
46
46
|
"overrides": {
|
|
47
47
|
"@expo/cli": "54.0.27",
|
|
@@ -54,10 +54,12 @@
|
|
|
54
54
|
"expo-font": "14.0.12",
|
|
55
55
|
"expo-keep-awake": "15.0.8",
|
|
56
56
|
"expo-modules-core": "3.0.30",
|
|
57
|
-
"expo-desktop-modules-core": "54.0.14
|
|
58
|
-
"expo-desktop-stubs": "54.0.14
|
|
57
|
+
"expo-desktop-modules-core": "54.0.14",
|
|
58
|
+
"expo-desktop-stubs": "54.0.14",
|
|
59
59
|
"react": "19.1.4",
|
|
60
|
-
"react-native": "0.81.6"
|
|
60
|
+
"react-native": "0.81.6",
|
|
61
|
+
"react-native-macos": "0.81.7",
|
|
62
|
+
"react-native-windows": "0.81.35"
|
|
61
63
|
},
|
|
62
64
|
"expo": {
|
|
63
65
|
"install": {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by spark; extend with configuration plugins.
|
|
2
|
-
module.exports = require("@legendapp/spark/
|
|
2
|
+
module.exports = require("@legendapp/spark/native").nativeConfig(__dirname);
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"expo": "54.0.37",
|
|
17
|
-
"expo-desktop": "1.0.0
|
|
18
|
-
"expo-desktop-prebuild-config": "1.1.0
|
|
19
|
-
"expo-desktop-config-plugins": "1.2.0
|
|
20
|
-
"expo-desktop-metro-config": "54.81.0
|
|
21
|
-
"expo-desktop-template-bare-minimum": "54.81.1
|
|
17
|
+
"expo-desktop": "1.0.0",
|
|
18
|
+
"expo-desktop-prebuild-config": "1.1.0",
|
|
19
|
+
"expo-desktop-config-plugins": "1.2.0",
|
|
20
|
+
"expo-desktop-metro-config": "54.81.0",
|
|
21
|
+
"expo-desktop-template-bare-minimum": "54.81.1",
|
|
22
22
|
"react": "19.1.4",
|
|
23
23
|
"react-native": "0.81.6",
|
|
24
24
|
"@react-native-community/cli": "20.1.3",
|
|
25
25
|
"typescript": "5.9.3",
|
|
26
26
|
"@types/react": "19.1.10",
|
|
27
27
|
"react-native-windows": "0.81.35",
|
|
28
|
-
"expo-desktop-modules-core": "54.0.14
|
|
29
|
-
"expo-desktop-stubs": "54.0.14
|
|
30
|
-
"@legendapp/spark": "0.0.1-next.
|
|
28
|
+
"expo-desktop-modules-core": "54.0.14",
|
|
29
|
+
"expo-desktop-stubs": "54.0.14",
|
|
30
|
+
"@legendapp/spark": "0.0.1-next.3"
|
|
31
31
|
},
|
|
32
32
|
"overrides": {
|
|
33
33
|
"@expo/cli": "54.0.27",
|
|
@@ -40,10 +40,12 @@
|
|
|
40
40
|
"expo-font": "14.0.12",
|
|
41
41
|
"expo-keep-awake": "15.0.8",
|
|
42
42
|
"expo-modules-core": "3.0.30",
|
|
43
|
-
"expo-desktop-modules-core": "54.0.14
|
|
44
|
-
"expo-desktop-stubs": "54.0.14
|
|
43
|
+
"expo-desktop-modules-core": "54.0.14",
|
|
44
|
+
"expo-desktop-stubs": "54.0.14",
|
|
45
45
|
"react": "19.1.4",
|
|
46
|
-
"react-native": "0.81.6"
|
|
46
|
+
"react-native": "0.81.6",
|
|
47
|
+
"react-native-macos": "0.81.7",
|
|
48
|
+
"react-native-windows": "0.81.35"
|
|
47
49
|
},
|
|
48
50
|
"expo": {
|
|
49
51
|
"install": {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by spark; extend with configuration plugins.
|
|
2
|
-
module.exports = require("@legendapp/spark/
|
|
2
|
+
module.exports = require("@legendapp/spark/native").nativeConfig(__dirname);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#import "RNDesktopClipboard.h"
|
|
2
|
+
#import <RNDesktopApp/SparkBinaryJSI.h>
|
|
2
3
|
#import <RNDesktopApp/SparkDesktop.h>
|
|
3
4
|
@implementation RNDesktopClipboard
|
|
4
5
|
RCT_EXPORT_MODULE(NativeDesktopClipboard)
|
|
5
|
-
- (void)call:(NSString *)method args:(NSString *)json resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
6
|
+
- (void)call:(NSString *)method args:(NSString *)json resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject { [self perform:method args:SparkArgs(json) binary:NO resolve:resolve reject:reject]; }
|
|
7
|
+
- (void)binaryCall:(NSString *)method args:(NSString *)json bytes:(NSData *)bytes resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject { NSMutableDictionary *args = [SparkArgs(json) mutableCopy]; if (bytes) args[@"imagePNG"] = bytes; [self perform:method args:args binary:YES resolve:resolve reject:reject]; }
|
|
8
|
+
- (void)perform:(NSString *)method args:(NSDictionary *)args binary:(BOOL)binary resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
6
9
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
7
10
|
NSPasteboard *board = NSPasteboard.generalPasteboard;
|
|
8
|
-
NSDictionary *args = SparkArgs(json);
|
|
9
11
|
if ([method isEqual:@"hasString"]) {
|
|
10
12
|
resolve(SparkJSON(@([board availableTypeFromArray:@[NSPasteboardTypeString, NSPasteboardTypeHTML, NSPasteboardTypeRTF]] != nil))); return;
|
|
11
13
|
}
|
|
@@ -24,8 +26,7 @@ RCT_EXPORT_MODULE(NativeDesktopClipboard)
|
|
|
24
26
|
if (rich) [item setString:rich.string forType:NSPasteboardTypeString];
|
|
25
27
|
}
|
|
26
28
|
[board clearContents];
|
|
27
|
-
|
|
28
|
-
resolve(@"null"); return;
|
|
29
|
+
resolve(SparkJSON(@([board writeObjects:@[item]]))); return;
|
|
29
30
|
}
|
|
30
31
|
NSString *text = [board stringForType:html ? NSPasteboardTypeHTML : NSPasteboardTypeString];
|
|
31
32
|
if (!text) {
|
|
@@ -50,10 +51,10 @@ RCT_EXPORT_MODULE(NativeDesktopClipboard)
|
|
|
50
51
|
for (NSString *key in types) { NSString *value = [board stringForType:types[key]]; if (value) content[key] = value; }
|
|
51
52
|
NSData *image = [board dataForType:NSPasteboardTypePNG];
|
|
52
53
|
if (!image) { NSData *tiff = [board dataForType:NSPasteboardTypeTIFF]; if (tiff) image = [[NSBitmapImageRep imageRepWithData:tiff] representationUsingType:NSBitmapImageFileTypePNG properties:@{}]; }
|
|
53
|
-
if (image) content[@"imagePNG"] =
|
|
54
|
+
if (image) content[@"imagePNG"] = image;
|
|
54
55
|
NSArray *urls = [board readObjectsForClasses:@[NSURL.class] options:@{ NSPasteboardURLReadingFileURLsOnlyKey: @YES }];
|
|
55
56
|
if (urls.count) content[@"files"] = [urls valueForKey:@"path"];
|
|
56
|
-
resolve(SparkJSON(content)); return;
|
|
57
|
+
resolve(binary ? content : SparkJSON(content)); return;
|
|
57
58
|
}
|
|
58
59
|
if ([method isEqual:@"write"]) {
|
|
59
60
|
NSMutableArray *objects = [NSMutableArray new];
|
|
@@ -62,7 +63,7 @@ RCT_EXPORT_MODULE(NativeDesktopClipboard)
|
|
|
62
63
|
NSPasteboardItem *item = [NSPasteboardItem new];
|
|
63
64
|
for (NSString *key in types) if (args[key]) [item setString:args[key] forType:types[key]];
|
|
64
65
|
if (args[@"imagePNG"]) {
|
|
65
|
-
NSData *image =
|
|
66
|
+
NSData *image = args[@"imagePNG"];
|
|
66
67
|
if (!image || ![NSBitmapImageRep imageRepWithData:image]) { SparkInvalid(reject, @"Invalid clipboard image"); return; }
|
|
67
68
|
[item setData:image forType:NSPasteboardTypePNG];
|
|
68
69
|
}
|
|
@@ -71,17 +72,10 @@ RCT_EXPORT_MODULE(NativeDesktopClipboard)
|
|
|
71
72
|
[board clearContents]; if (objects.count && ![board writeObjects:objects]) { reject(@"E_CLIPBOARD", @"Could not write clipboard", nil); return; }
|
|
72
73
|
resolve(@"null"); return;
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
-
else if ([method isEqual:@"hasText"]) resolve(SparkJSON(@([board availableTypeFromArray:@[NSPasteboardTypeString]] != nil)));
|
|
76
|
-
else if ([method isEqual:@"writeText"]) {
|
|
77
|
-
if (![args[@"text"] isKindOfClass:NSString.class]) { SparkInvalid(reject, @"Expected clipboard text"); return; }
|
|
78
|
-
[board clearContents];
|
|
79
|
-
if (![board setString:args[@"text"] forType:NSPasteboardTypeString]) { reject(@"E_CLIPBOARD", @"Could not write clipboard", nil); return; }
|
|
80
|
-
resolve(@"null");
|
|
81
|
-
} else SparkInvalid(reject, @"Unknown clipboard operation");
|
|
75
|
+
SparkInvalid(reject, @"Unknown clipboard operation");
|
|
82
76
|
});
|
|
83
77
|
}
|
|
84
78
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
85
|
-
return std::make_shared<facebook::react::NativeDesktopClipboardSpecJSI
|
|
79
|
+
return std::make_shared<spark::binary::Module<facebook::react::NativeDesktopClipboardSpecJSI>>(params);
|
|
86
80
|
}
|
|
87
81
|
@end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-clipboard",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"react-native": "src/index",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
]
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@legendapp/spark-desktop-app": "0.0.1-next.
|
|
44
|
+
"@legendapp/spark-desktop-app": "0.0.1-next.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
47
|
"expo-clipboard": {
|
|
@@ -3,4 +3,4 @@ import { TurboModuleRegistry } from "react-native";
|
|
|
3
3
|
export interface Spec extends TurboModule {
|
|
4
4
|
call(method: string, args: string): Promise<string>;
|
|
5
5
|
}
|
|
6
|
-
export default TurboModuleRegistry.
|
|
6
|
+
export default TurboModuleRegistry.get<Spec>("NativeDesktopClipboard");
|