one 2.0.0-beta.150.1 → 2.0.0-beta.159.1
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/One.podspec +4 -4
- package/android/CMakeLists.txt +7 -2
- package/android/build.gradle +2 -0
- package/android/src/main/cpp/OneStorageDirectory.cpp +21 -0
- package/android/src/main/java/com/margelo/nitro/one/HybridOneAdaptive.kt +13 -6
- package/android/src/main/java/com/margelo/nitro/one/OneStorageDirectory.kt +19 -0
- package/android/src/main/java/dev/onejs/one/OneKotlinHostEvents.kt +39 -0
- package/android/src/main/java/dev/onejs/one/OneKotlinHostManager.kt +79 -0
- package/android/src/main/java/dev/onejs/one/OneKotlinHostView.kt +211 -0
- package/android/src/main/java/dev/onejs/one/OneNativeSourceViewDispatch.kt +13 -0
- package/android/src/main/java/dev/onejs/one/OneNativeSourceViewRegistry.kt +21 -0
- package/android/src/main/java/dev/onejs/one/OnePackage.kt +1 -0
- package/android/src/main/java/dev/onejs/one/sharetarget/OneShareDraftStore.kt +122 -0
- package/android/src/main/java/dev/onejs/one/sharetarget/OneShareIntake.kt +344 -0
- package/android/src/main/java/dev/onejs/one/sharetarget/OneShareModels.kt +36 -0
- package/android/src/main/java/dev/onejs/one/sharetarget/OneShareSessionModel.kt +207 -0
- package/android/src/main/java/dev/onejs/one/sharetarget/OneShareTargetActivity.kt +161 -0
- package/android/src/main/java/dev/onejs/one/sharetarget/OneShareTargetAdapter.kt +13 -0
- package/cpp/HybridOneCrypto.cpp +37 -0
- package/cpp/HybridOneCrypto.hpp +19 -0
- package/cpp/HybridOneStorage.cpp +334 -0
- package/cpp/HybridOneStorage.hpp +23 -0
- package/cpp/OneStorageDirectory.hpp +11 -0
- package/dist/cjs/cli/prebuild.cjs +2 -2
- package/dist/cjs/cli/prebuild.native.cjs +4 -3
- package/dist/cjs/cli/prebuild.native.js +4 -3
- package/dist/cjs/cli/prebuild.native.js.map +1 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.native.cjs +2 -0
- package/dist/cjs/index.native.js +2 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/one.cjs +2 -1
- package/dist/cjs/one.native.cjs +2 -1
- package/dist/cjs/one.native.js +2 -1
- package/dist/cjs/one.native.js.map +1 -1
- package/dist/cjs/platform/Sheet.native.cjs +28 -2
- package/dist/cjs/platform/Sheet.native.js +28 -2
- package/dist/cjs/platform/Sheet.native.js.map +1 -1
- package/dist/cjs/platform/app-intents/index.cjs +29 -0
- package/dist/cjs/platform/app-intents/index.native.cjs +93 -0
- package/dist/cjs/platform/app-intents/index.native.js +95 -0
- package/dist/cjs/platform/app-intents/index.native.js.map +1 -0
- package/dist/cjs/platform/app-intents/validate.cjs +28 -0
- package/dist/cjs/platform/app-intents/validate.native.cjs +30 -0
- package/dist/cjs/platform/app-intents/validate.native.js +32 -0
- package/dist/cjs/platform/app-intents/validate.native.js.map +1 -0
- package/dist/cjs/platform/crypto/index.cjs +10 -6
- package/dist/cjs/platform/crypto/index.native.cjs +9 -13
- package/dist/cjs/platform/crypto/index.native.js +9 -13
- package/dist/cjs/platform/crypto/index.native.js.map +1 -1
- package/dist/cjs/platform/crypto/random.cjs +5 -8
- package/dist/cjs/platform/crypto/random.native.cjs +5 -8
- package/dist/cjs/platform/crypto/random.native.js +5 -8
- package/dist/cjs/platform/crypto/random.native.js.map +1 -1
- package/dist/cjs/platform/index.cjs +4 -2
- package/dist/cjs/platform/index.native.cjs +4 -2
- package/dist/cjs/platform/index.native.js +4 -2
- package/dist/cjs/platform/index.native.js.map +1 -1
- package/dist/cjs/platform/native-source/view.cjs +26 -0
- package/dist/cjs/platform/native-source/view.native.cjs +65 -0
- package/dist/cjs/platform/native-source/view.native.js +67 -0
- package/dist/cjs/platform/native-source/view.native.js.map +1 -0
- package/dist/cjs/platform/{specs/OnePreferences.nitro.cjs → native-source/viewTypes.cjs} +2 -2
- package/dist/cjs/platform/{specs/OnePreferences.nitro.native.cjs → native-source/viewTypes.native.cjs} +2 -2
- package/dist/cjs/platform/{specs/OnePreferences.nitro.native.js → native-source/viewTypes.native.js} +3 -3
- package/dist/cjs/platform/native-source/viewTypes.native.js.map +1 -0
- package/dist/cjs/platform/specs/OneAppIntents.nitro.cjs +16 -0
- package/dist/cjs/platform/specs/OneAppIntents.nitro.native.cjs +18 -0
- package/dist/cjs/platform/specs/OneAppIntents.nitro.native.js +20 -0
- package/dist/cjs/platform/specs/OneAppIntents.nitro.native.js.map +1 -0
- package/dist/cjs/platform/specs/OneKotlinHostNativeComponent.cjs +50 -0
- package/dist/cjs/platform/specs/OneKotlinHostNativeComponent.native.cjs +50 -0
- package/dist/cjs/platform/specs/OneKotlinHostNativeComponent.native.js +51 -0
- package/dist/cjs/platform/specs/OneKotlinHostNativeComponent.native.js.map +7 -0
- package/dist/cjs/platform/specs/OneNativeSheetNativeComponent.cjs +5 -0
- package/dist/cjs/platform/specs/OneNativeSheetNativeComponent.native.cjs +5 -0
- package/dist/cjs/platform/specs/OneNativeSheetNativeComponent.native.js +5 -0
- package/dist/cjs/platform/specs/OneNativeSheetNativeComponent.native.js.map +2 -2
- package/dist/cjs/platform/specs/OneStorage.nitro.cjs +16 -0
- package/dist/cjs/platform/specs/OneStorage.nitro.native.cjs +18 -0
- package/dist/cjs/platform/specs/OneStorage.nitro.native.js +20 -0
- package/dist/cjs/platform/specs/OneStorage.nitro.native.js.map +1 -0
- package/dist/cjs/platform/storage/index.cjs +52 -0
- package/dist/cjs/platform/storage/index.native.cjs +70 -0
- package/dist/cjs/platform/storage/index.native.js +72 -0
- package/dist/cjs/platform/storage/index.native.js.map +1 -0
- package/dist/cjs/platform/{preferences → storage}/validate.cjs +6 -10
- package/dist/cjs/platform/{preferences → storage}/validate.native.cjs +6 -10
- package/dist/cjs/platform/{preferences → storage}/validate.native.js +6 -10
- package/dist/cjs/platform/storage/validate.native.js.map +1 -0
- package/dist/cjs/tamagui.cjs +24 -0
- package/dist/cjs/tamagui.native.cjs +90 -0
- package/dist/cjs/tamagui.native.js +92 -0
- package/dist/cjs/tamagui.native.js.map +1 -0
- package/dist/cjs/useHeaderHeight.cjs +46 -0
- package/dist/cjs/useHeaderHeight.native.cjs +49 -0
- package/dist/cjs/useHeaderHeight.native.js +51 -0
- package/dist/cjs/useHeaderHeight.native.js.map +1 -0
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +4 -7
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.cjs +3 -6
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +3 -6
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/kotlinSourcePlugin.cjs +12 -4
- package/dist/cjs/vite/plugins/kotlinSourcePlugin.native.cjs +14 -4
- package/dist/cjs/vite/plugins/kotlinSourcePlugin.native.js +14 -4
- package/dist/cjs/vite/plugins/kotlinSourcePlugin.native.js.map +1 -1
- package/dist/esm/cli/prebuild.mjs +2 -2
- package/dist/esm/cli/prebuild.mjs.map +1 -1
- package/dist/esm/cli/prebuild.native.js +4 -3
- package/dist/esm/cli/prebuild.native.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.native.js +2 -1
- package/dist/esm/one.mjs +3 -2
- package/dist/esm/one.mjs.map +1 -1
- package/dist/esm/one.native.js +3 -2
- package/dist/esm/one.native.js.map +1 -1
- package/dist/esm/platform/Sheet.native.js +28 -2
- package/dist/esm/platform/Sheet.native.js.map +1 -1
- package/dist/esm/platform/app-intents/index.mjs +10 -0
- package/dist/esm/platform/app-intents/index.mjs.map +1 -0
- package/dist/esm/platform/app-intents/index.native.js +72 -0
- package/dist/esm/platform/app-intents/index.native.js.map +1 -0
- package/dist/esm/platform/app-intents/validate.mjs +8 -0
- package/dist/esm/platform/app-intents/validate.mjs.map +1 -0
- package/dist/esm/platform/app-intents/validate.native.js +8 -0
- package/dist/esm/platform/app-intents/validate.native.js.map +1 -0
- package/dist/esm/platform/crypto/index.mjs +11 -7
- package/dist/esm/platform/crypto/index.mjs.map +1 -1
- package/dist/esm/platform/crypto/index.native.js +10 -14
- package/dist/esm/platform/crypto/index.native.js.map +1 -1
- package/dist/esm/platform/crypto/random.mjs +6 -8
- package/dist/esm/platform/crypto/random.mjs.map +1 -1
- package/dist/esm/platform/crypto/random.native.js +6 -8
- package/dist/esm/platform/crypto/random.native.js.map +1 -1
- package/dist/esm/platform/index.mjs +3 -2
- package/dist/esm/platform/index.mjs.map +1 -1
- package/dist/esm/platform/index.native.js +3 -2
- package/dist/esm/platform/index.native.js.map +1 -1
- package/dist/esm/platform/native-source/view.mjs +6 -0
- package/dist/esm/platform/native-source/view.mjs.map +1 -0
- package/dist/esm/platform/native-source/view.native.js +38 -0
- package/dist/esm/platform/native-source/view.native.js.map +1 -0
- package/dist/esm/platform/specs/OneAppIntents.nitro.mjs +0 -0
- package/dist/esm/platform/specs/OneAppIntents.nitro.native.js +0 -0
- package/dist/esm/platform/specs/OneKotlinHostNativeComponent.mjs +32 -0
- package/dist/esm/platform/specs/OneKotlinHostNativeComponent.mjs.map +7 -0
- package/dist/esm/platform/specs/OneKotlinHostNativeComponent.native.js +32 -0
- package/dist/esm/platform/specs/OneKotlinHostNativeComponent.native.js.map +7 -0
- package/dist/esm/platform/specs/OneNativeSheetNativeComponent.mjs +5 -0
- package/dist/esm/platform/specs/OneNativeSheetNativeComponent.mjs.map +2 -2
- package/dist/esm/platform/specs/OneNativeSheetNativeComponent.native.js +5 -0
- package/dist/esm/platform/specs/OneNativeSheetNativeComponent.native.js.map +2 -2
- package/dist/esm/platform/specs/OneStorage.nitro.mjs +0 -0
- package/dist/esm/platform/specs/OneStorage.nitro.native.js +0 -0
- package/dist/esm/platform/storage/index.mjs +33 -0
- package/dist/esm/platform/storage/index.mjs.map +1 -0
- package/dist/esm/platform/storage/index.native.js +49 -0
- package/dist/esm/platform/storage/index.native.js.map +1 -0
- package/dist/esm/platform/storage/validate.mjs +9 -0
- package/dist/esm/platform/storage/validate.mjs.map +1 -0
- package/dist/esm/platform/storage/validate.native.js +9 -0
- package/dist/esm/platform/storage/validate.native.js.map +1 -0
- package/dist/esm/tamagui.mjs +4 -0
- package/dist/esm/tamagui.mjs.map +1 -0
- package/dist/esm/tamagui.native.js +69 -0
- package/dist/esm/tamagui.native.js.map +1 -0
- package/dist/esm/useHeaderHeight.mjs +27 -0
- package/dist/esm/useHeaderHeight.mjs.map +1 -0
- package/dist/esm/useHeaderHeight.native.js +28 -0
- package/dist/esm/useHeaderHeight.native.js.map +1 -0
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +4 -7
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +3 -6
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/kotlinSourcePlugin.mjs +12 -4
- package/dist/esm/vite/plugins/kotlinSourcePlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/kotlinSourcePlugin.native.js +14 -4
- package/dist/esm/vite/plugins/kotlinSourcePlugin.native.js.map +1 -1
- package/ios/Generated/OneNativeSheetContent.swift +2 -0
- package/ios/Nitro/HybridOneAppIntents.swift +148 -0
- package/ios/Nitro/OneAppIntentsBridge.h +14 -0
- package/ios/Nitro/OneAppIntentsBridge.m +17 -0
- package/ios/Nitro/OneBackgroundTasksBridge.m +2 -4
- package/ios/Nitro/OneHeadlessHost.h +8 -0
- package/ios/Nitro/OneHeadlessHost.m +10 -0
- package/ios/OneNativeComposition.swift +18 -14
- package/ios/OneNativeSheetComponentView.mm +7 -1
- package/ios/OneNativeSheetView.swift +28 -3
- package/ios/OneNativeSlot.swift +9 -0
- package/ios/OneStorageDirectory.mm +28 -0
- package/ios/OneSwiftHostView.swift +6 -1
- package/ios/ShareTarget/OneShareComposeViewController.swift +337 -0
- package/ios/ShareTarget/OneShareTargetAdapter.swift +128 -0
- package/ios/ShareTarget/OneShareTargetConfiguration.swift +38 -0
- package/ios/ShareTarget/OneShareTargetDraftStore.swift +118 -0
- package/ios/ShareTarget/OneShareTargetIntake.swift +344 -0
- package/ios/ShareTarget/OneShareTargetSubmissionCoordinator.swift +249 -0
- package/ios/ShareTarget/OneShareTargetViewController.swift +30 -0
- package/ios/Tests/ShareTarget/Package.swift +34 -0
- package/ios/Tests/ShareTarget/Tests/OneShareTargetHarnessTests/OneShareTargetDraftStoreTests.swift +75 -0
- package/ios/Tests/ShareTarget/Tests/OneShareTargetHarnessTests/OneShareTargetIntakeTests.swift +266 -0
- package/ios/Tests/ShareTarget/Tests/OneShareTargetHarnessTests/OneShareTargetSubmissionCoordinatorTests.swift +234 -0
- package/ios/Tests/ShareTarget/Tests/OneShareTargetHarnessTests/RuntimeRegressionTests.swift +285 -0
- package/ios/Tests/ShareTarget/UIHarness/HostApp/AppDelegate.swift +92 -0
- package/ios/Tests/ShareTarget/UIHarness/HostApp/HostApp.entitlements +10 -0
- package/ios/Tests/ShareTarget/UIHarness/HostApp/Info.plist +43 -0
- package/ios/Tests/ShareTarget/UIHarness/ShareExtension/GeneratedHarnessShareViewController.swift +18 -0
- package/ios/Tests/ShareTarget/UIHarness/ShareExtension/HarnessShareTargetAdapterExtensionOnly.swift +39 -0
- package/ios/Tests/ShareTarget/UIHarness/ShareExtension/Info.plist +45 -0
- package/ios/Tests/ShareTarget/UIHarness/ShareExtension/ShareExtension.entitlements +10 -0
- package/ios/Tests/ShareTarget/UIHarness/Shared/HarnessShareTargetAdapter.swift +82 -0
- package/ios/Tests/ShareTarget/UIHarness/build.sh +60 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/01-host-app.png +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/02-system-share-sheet-with-extension.jpg +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/after-tests.txt +99 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/baseline-tests.txt +109 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/before-caption-draft.json +12 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/before-caption.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/before-send-auto-dismiss.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/configuration-probe.txt +98 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-cancelled-disk.json +50 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-cancelled.ax.json +822 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-cancelled.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-delivered-disk.json +47 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-delivered.ax.json +375 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-delivered.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-destination-error.ax.json +1068 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-destination-error.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-destination-failed-disk.json +61 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-destination-recovered-disk.json +62 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-destination-recovered.ax.json +1068 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-destination-recovered.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-edited.ax.json +1338 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-edited.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-failed-mutations-blocked-disk.json +66 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-failed-send-disk.json +66 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-held-destinations-cancelled-disk.json +50 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-held-destinations-cancelled.ax.json +822 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-held-destinations-cancelled.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-held-destinations-disk.json +61 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-held-destinations.ax.json +1068 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-held-destinations.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-initial.ax.json +1092 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-initial.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-load-edit-preserved-disk.json +62 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-load-edit-preserved.ax.json +1044 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-load-edit-preserved.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-loading-disk.json +61 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-loading.ax.json +2256 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-loading.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-picker.ax.json +1166 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-picker.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-retried-disk.json +54 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-retry-ready.ax.json +1092 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-retry-ready.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-retry-verification.json +30 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-send-error.ax.json +1068 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-send-error.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-sending-disk.json +58 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-sending.ax.json +1215 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/final-sending.webp +0 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/principal-after-log.txt +74 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/share-receipt.json +15 -0
- package/ios/Tests/ShareTarget/UIHarness/evidence/strict-build.txt +8 -0
- package/ios/Tests/ShareTarget/UIHarness/interact.py +61 -0
- package/ios/Tests/ShareTarget/evidence.md +142 -0
- package/nitrogen/generated/android/One+autolinking.cmake +2 -2
- package/nitrogen/generated/android/OneOnLoad.cpp +15 -11
- package/nitrogen/generated/ios/One-Swift-Cxx-Bridge.cpp +25 -34
- package/nitrogen/generated/ios/One-Swift-Cxx-Bridge.hpp +80 -61
- package/nitrogen/generated/ios/One-Swift-Cxx-Umbrella.hpp +8 -10
- package/nitrogen/generated/ios/OneAutolinking.mm +19 -7
- package/nitrogen/generated/ios/OneAutolinking.swift +66 -78
- package/nitrogen/generated/ios/c++/{HybridOneCryptoSpecSwift.cpp → HybridOneAppIntentsSpecSwift.cpp} +2 -2
- package/nitrogen/generated/ios/c++/HybridOneAppIntentsSpecSwift.hpp +101 -0
- package/nitrogen/generated/ios/swift/AppIntentInvocation.swift +52 -0
- package/nitrogen/generated/ios/swift/Func_void_AppIntentInvocation.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridOneAppIntentsSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridOneAppIntentsSpec_cxx.swift +175 -0
- package/nitrogen/generated/shared/c++/AppIntentInvocation.hpp +92 -0
- package/nitrogen/generated/shared/c++/HybridOneAppIntentsSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridOneAppIntentsSpec.hpp +68 -0
- package/nitrogen/generated/shared/c++/HybridOneCryptoSpec.cpp +2 -1
- package/nitrogen/generated/shared/c++/HybridOneCryptoSpec.hpp +4 -2
- package/nitrogen/generated/shared/c++/HybridOneStorageSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridOneStorageSpec.hpp +67 -0
- package/package.json +26 -12
- package/schema.json +11 -0
- package/src/cli/prebuild.ts +4 -2
- package/src/index.ts +1 -0
- package/src/one.ts +7 -8
- package/src/platform/Sheet.native.tsx +29 -0
- package/src/platform/app-intents/index.native.ts +58 -0
- package/src/platform/app-intents/index.ts +10 -0
- package/src/platform/app-intents/validate.ts +5 -0
- package/src/platform/crypto/index.native.ts +14 -17
- package/src/platform/crypto/index.ts +12 -8
- package/src/platform/crypto/random.ts +14 -15
- package/src/platform/generated/sheetTypes.ts +4 -0
- package/src/platform/index.native.ts +3 -1
- package/src/platform/index.ts +3 -1
- package/src/platform/native-source/view.native.tsx +41 -0
- package/src/platform/native-source/view.tsx +8 -0
- package/src/platform/native-source/viewTypes.ts +11 -0
- package/src/platform/specs/OneAppIntents.nitro.ts +13 -0
- package/src/platform/specs/OneCrypto.nitro.ts +7 -6
- package/src/platform/specs/OneKotlinHostNativeComponent.ts +26 -0
- package/src/platform/specs/OneNativeSheetNativeComponent.ts +4 -0
- package/src/platform/specs/OneStorage.nitro.ts +11 -0
- package/src/platform/storage/index.native.ts +59 -0
- package/src/platform/storage/index.ts +32 -0
- package/src/platform/storage/validate.ts +10 -0
- package/src/polyfills-mobile.ts +1 -1
- package/src/tamagui.native.tsx +96 -0
- package/src/tamagui.ts +2 -0
- package/src/useHeaderHeight.ts +40 -0
- package/src/vite/plugins/fileSystemRouterPlugin.test.ts +55 -2
- package/src/vite/plugins/fileSystemRouterPlugin.tsx +8 -11
- package/src/vite/plugins/kotlinSourcePlugin.ts +14 -2
- package/types/cli/prebuild.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/one.d.ts +3 -2
- package/types/one.d.ts.map +1 -1
- package/types/platform/Sheet.native.d.ts +2 -2
- package/types/platform/Sheet.native.d.ts.map +1 -1
- package/types/platform/app-intents/index.d.ts +7 -0
- package/types/platform/app-intents/index.d.ts.map +1 -0
- package/types/platform/app-intents/index.native.d.ts +7 -0
- package/types/platform/app-intents/index.native.d.ts.map +1 -0
- package/types/platform/app-intents/validate.d.ts +2 -0
- package/types/platform/app-intents/validate.d.ts.map +1 -0
- package/types/platform/crypto/index.d.ts.map +1 -1
- package/types/platform/crypto/index.native.d.ts.map +1 -1
- package/types/platform/crypto/random.d.ts +6 -4
- package/types/platform/crypto/random.d.ts.map +1 -1
- package/types/platform/generated/sheetTypes.d.ts +4 -0
- package/types/platform/generated/sheetTypes.d.ts.map +1 -1
- package/types/platform/index.d.ts +3 -1
- package/types/platform/index.d.ts.map +1 -1
- package/types/platform/index.native.d.ts +3 -1
- package/types/platform/index.native.d.ts.map +1 -1
- package/types/platform/native-source/view.d.ts +4 -0
- package/types/platform/native-source/view.d.ts.map +1 -0
- package/types/platform/native-source/view.native.d.ts +4 -0
- package/types/platform/native-source/view.native.d.ts.map +1 -0
- package/types/platform/native-source/viewTypes.d.ts +10 -0
- package/types/platform/native-source/viewTypes.d.ts.map +1 -0
- package/types/platform/specs/OneAppIntents.nitro.d.ts +14 -0
- package/types/platform/specs/OneAppIntents.nitro.d.ts.map +1 -0
- package/types/platform/specs/OneCrypto.nitro.d.ts +4 -3
- package/types/platform/specs/OneCrypto.nitro.d.ts.map +1 -1
- package/types/platform/specs/OneKotlinHostNativeComponent.d.ts +21 -0
- package/types/platform/specs/OneKotlinHostNativeComponent.d.ts.map +1 -0
- package/types/platform/specs/OneNativeSheetNativeComponent.d.ts +5 -0
- package/types/platform/specs/OneNativeSheetNativeComponent.d.ts.map +1 -1
- package/types/platform/specs/OneStorage.nitro.d.ts +11 -0
- package/types/platform/specs/OneStorage.nitro.d.ts.map +1 -0
- package/types/platform/storage/index.d.ts +12 -0
- package/types/platform/storage/index.d.ts.map +1 -0
- package/types/platform/storage/index.native.d.ts +12 -0
- package/types/platform/storage/index.native.d.ts.map +1 -0
- package/types/platform/storage/validate.d.ts +3 -0
- package/types/platform/storage/validate.d.ts.map +1 -0
- package/types/tamagui.d.ts +2 -0
- package/types/tamagui.d.ts.map +1 -0
- package/types/tamagui.native.d.ts +2 -0
- package/types/tamagui.native.d.ts.map +1 -0
- package/types/useHeaderHeight.d.ts +6 -0
- package/types/useHeaderHeight.d.ts.map +1 -0
- package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
- package/types/vite/plugins/kotlinSourcePlugin.d.ts.map +1 -1
- package/android/src/main/java/com/margelo/nitro/one/HybridOneCrypto.kt +0 -23
- package/dist/cjs/platform/preferences/index.cjs +0 -61
- package/dist/cjs/platform/preferences/index.native.cjs +0 -84
- package/dist/cjs/platform/preferences/index.native.js +0 -86
- package/dist/cjs/platform/preferences/index.native.js.map +0 -1
- package/dist/cjs/platform/preferences/validate.native.js.map +0 -1
- package/dist/cjs/platform/specs/OnePreferences.nitro.native.js.map +0 -1
- package/dist/esm/platform/preferences/index.mjs +0 -42
- package/dist/esm/platform/preferences/index.mjs.map +0 -1
- package/dist/esm/platform/preferences/index.native.js +0 -63
- package/dist/esm/platform/preferences/index.native.js.map +0 -1
- package/dist/esm/platform/preferences/validate.mjs +0 -13
- package/dist/esm/platform/preferences/validate.mjs.map +0 -1
- package/dist/esm/platform/preferences/validate.native.js +0 -13
- package/dist/esm/platform/preferences/validate.native.js.map +0 -1
- package/ios/Nitro/HybridOneCrypto.swift +0 -20
- package/ios/Nitro/HybridOnePreferences.swift +0 -64
- package/nitrogen/generated/android/c++/JHybridOneCryptoSpec.cpp +0 -54
- package/nitrogen/generated/android/c++/JHybridOneCryptoSpec.hpp +0 -63
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HybridOneCryptoSpec.kt +0 -57
- package/nitrogen/generated/ios/c++/HybridOneCryptoSpecSwift.hpp +0 -84
- package/nitrogen/generated/ios/c++/HybridOnePreferencesSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridOnePreferencesSpecSwift.hpp +0 -120
- package/nitrogen/generated/ios/swift/HybridOneCryptoSpec.swift +0 -55
- package/nitrogen/generated/ios/swift/HybridOneCryptoSpec_cxx.swift +0 -138
- package/nitrogen/generated/ios/swift/HybridOnePreferencesSpec.swift +0 -60
- package/nitrogen/generated/ios/swift/HybridOnePreferencesSpec_cxx.swift +0 -229
- package/nitrogen/generated/shared/c++/HybridOnePreferencesSpec.cpp +0 -26
- package/nitrogen/generated/shared/c++/HybridOnePreferencesSpec.hpp +0 -69
- package/src/platform/preferences/index.native.ts +0 -66
- package/src/platform/preferences/index.ts +0 -46
- package/src/platform/preferences/validate.ts +0 -12
- package/src/platform/specs/OnePreferences.nitro.ts +0 -10
- package/types/platform/preferences/index.d.ts +0 -16
- package/types/platform/preferences/index.d.ts.map +0 -1
- package/types/platform/preferences/index.native.d.ts +0 -16
- package/types/platform/preferences/index.native.d.ts.map +0 -1
- package/types/platform/preferences/validate.d.ts +0 -3
- package/types/platform/preferences/validate.d.ts.map +0 -1
- package/types/platform/specs/OnePreferences.nitro.d.ts +0 -12
- package/types/platform/specs/OnePreferences.nitro.d.ts.map +0 -1
- /package/dist/esm/platform/{specs/OnePreferences.nitro.mjs → native-source/viewTypes.mjs} +0 -0
- /package/dist/esm/platform/{specs/OnePreferences.nitro.native.js → native-source/viewTypes.native.js} +0 -0
package/One.podspec
CHANGED
|
@@ -35,16 +35,16 @@ Pod::Spec.new do |s|
|
|
|
35
35
|
s.source_files = 'ios/**/*.{h,m,swift,mm,cpp}', 'cpp/**/*.{h,cpp}'
|
|
36
36
|
# c entries the app's bridging header imports without importing the one module.
|
|
37
37
|
# nitrogen appends its own public headers after these.
|
|
38
|
-
s.public_header_files = 'ios/Nitro/OneUpdatesLauncherBridge.h', 'ios/Nitro/OneLaunchScreen.h', 'ios/Nitro/OneBackgroundTasksBridge.h'
|
|
38
|
+
s.public_header_files = 'ios/Nitro/OneUpdatesLauncherBridge.h', 'ios/Nitro/OneLaunchScreen.h', 'ios/Nitro/OneBackgroundTasksBridge.h', 'ios/Nitro/OneAppIntentsBridge.h'
|
|
39
39
|
|
|
40
40
|
# nitro hybrid objects: nitrogen generates the specs and bridges from
|
|
41
41
|
# src/specs/*.nitro.ts into nitrogen/generated (see README).
|
|
42
42
|
load 'nitrogen/generated/ios/One+autolinking.rb'
|
|
43
43
|
add_nitrogen_files(s)
|
|
44
44
|
# objc++ units build without clang modules, so One-Swift.h skips its
|
|
45
|
-
# own @import lines (React, UserNotifications) and never sees the
|
|
46
|
-
# bridge types its c++ section names; every unit gets them first.
|
|
47
|
-
s.prefix_header_contents = "#ifdef __OBJC__\n#import <React/RCTView.h>\n#import <UserNotifications/UserNotifications.h>\n#endif\n#ifdef __cplusplus\n#include \"One-Swift-Cxx-Bridge.hpp\"\n#endif"
|
|
45
|
+
# own @import lines (React, UserNotifications, Social) and never sees the
|
|
46
|
+
# nitro bridge types its c++ section names; every unit gets them first.
|
|
47
|
+
s.prefix_header_contents = "#ifdef __OBJC__\n#import <React/RCTView.h>\n#import <UserNotifications/UserNotifications.h>\n#import <Social/Social.h>\n#endif\n#ifdef __cplusplus\n#include \"One-Swift-Cxx-Bridge.hpp\"\n#endif"
|
|
48
48
|
|
|
49
49
|
s.dependency 'RNWorklets'
|
|
50
50
|
|
package/android/CMakeLists.txt
CHANGED
|
@@ -13,13 +13,18 @@ find_package(ReactAndroid REQUIRED CONFIG)
|
|
|
13
13
|
find_package(react-native-worklets REQUIRED CONFIG)
|
|
14
14
|
|
|
15
15
|
# one library for the package's C++: the sync-state JSI host object (shared
|
|
16
|
-
# with iOS; only the registry trampolines differ, Swift there, JNI here)
|
|
16
|
+
# with iOS; only the registry trampolines differ, Swift there, JNI here), the
|
|
17
|
+
# One.Storage engine (shared; only its directory lookup is per platform), the
|
|
18
|
+
# crypto random source, and
|
|
17
19
|
# the nitrogen-generated Nitro hybrid objects. JNI_OnLoad in
|
|
18
20
|
# OneNativeSyncJni.cpp registers both.
|
|
19
21
|
add_library(
|
|
20
22
|
One SHARED
|
|
21
23
|
${JNI_DIR}/OneNativeSyncJni.cpp
|
|
22
|
-
${
|
|
24
|
+
${JNI_DIR}/OneStorageDirectory.cpp
|
|
25
|
+
${CPP_DIR}/OneNativeSyncHost.cpp
|
|
26
|
+
${CPP_DIR}/HybridOneStorage.cpp
|
|
27
|
+
${CPP_DIR}/HybridOneCrypto.cpp)
|
|
23
28
|
|
|
24
29
|
target_include_directories(One PRIVATE ${CPP_DIR} ${JNI_DIR})
|
|
25
30
|
|
package/android/build.gradle
CHANGED
|
@@ -132,6 +132,8 @@ dependencies {
|
|
|
132
132
|
implementation "androidx.browser:browser:1.9.0"
|
|
133
133
|
implementation "com.google.android.material:material:1.13.0"
|
|
134
134
|
implementation "androidx.activity:activity:1.9.3"
|
|
135
|
+
// setContent and BackHandler for the share-target compose activity.
|
|
136
|
+
implementation "androidx.activity:activity-compose:1.9.3"
|
|
135
137
|
implementation "androidx.core:core:1.13.1"
|
|
136
138
|
// folding features for reserved regions (Jetpack WindowManager).
|
|
137
139
|
implementation "androidx.window:window:1.5.1"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#include <fbjni/fbjni.h>
|
|
2
|
+
|
|
3
|
+
#include "OneStorageDirectory.hpp"
|
|
4
|
+
|
|
5
|
+
#include <stdexcept>
|
|
6
|
+
|
|
7
|
+
namespace margelo::nitro::one {
|
|
8
|
+
|
|
9
|
+
std::string storageDirectory() {
|
|
10
|
+
static const auto directoryClass =
|
|
11
|
+
facebook::jni::findClassStatic("com/margelo/nitro/one/OneStorageDirectory");
|
|
12
|
+
static const auto path =
|
|
13
|
+
directoryClass->getStaticMethod<facebook::jni::local_ref<facebook::jni::JString>()>("path");
|
|
14
|
+
auto directory = path(directoryClass);
|
|
15
|
+
if (!directory) {
|
|
16
|
+
throw std::runtime_error("E_STORAGE_UNAVAILABLE: Storage: React context is not ready");
|
|
17
|
+
}
|
|
18
|
+
return directory->toStdString();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace margelo::nitro::one
|
|
@@ -28,9 +28,10 @@ import com.margelo.nitro.core.Promise
|
|
|
28
28
|
// window-layout changes. hinge status comes from the WindowInfoTracker
|
|
29
29
|
// FoldingFeature (FLAT fullyOpen, HALF_OPENED partiallyOpen) with the angle
|
|
30
30
|
// from the hinge-angle sensor in radians; a hinge sensor with no
|
|
31
|
-
// FoldingFeature in the current window reads closed
|
|
32
|
-
//
|
|
33
|
-
//
|
|
31
|
+
// FoldingFeature in the current window reads closed only on an official
|
|
32
|
+
// 0-degree sensor reading and unknown otherwise, preserving the sensor
|
|
33
|
+
// angle; a device with no hinge sensor reads null. the first listener starts
|
|
34
|
+
// the monitors and the last removal stops them, including the sensor.
|
|
34
35
|
class HybridOneAdaptive : HybridOneAdaptiveSpec() {
|
|
35
36
|
private val sizeClassListeners = mutableMapOf<Int, (SizeClass) -> Unit>()
|
|
36
37
|
private val hingeListeners = mutableMapOf<Int, (HingeState?) -> Unit>()
|
|
@@ -118,8 +119,8 @@ class HybridOneAdaptive : HybridOneAdaptiveSpec() {
|
|
|
118
119
|
|
|
119
120
|
private fun computeHinge(): HingeState? {
|
|
120
121
|
if (!hasHingeSensor()) return null
|
|
121
|
-
val
|
|
122
|
-
|
|
122
|
+
val angleDeg = synchronized(this) { lastAngleDeg }
|
|
123
|
+
val angleRad = angleDeg?.let { (it * Math.PI / 180.0) }
|
|
123
124
|
val features = currentFoldingFeatures()
|
|
124
125
|
val feature = features.firstOrNull()
|
|
125
126
|
return when (feature?.state) {
|
|
@@ -127,7 +128,13 @@ class HybridOneAdaptive : HybridOneAdaptiveSpec() {
|
|
|
127
128
|
HingeState(HingeStatus.FULLYOPEN, angleRad ?: Math.PI)
|
|
128
129
|
FoldingFeature.State.HALF_OPENED ->
|
|
129
130
|
HingeState(HingeStatus.PARTIALLYOPEN, angleRad ?: (Math.PI / 2.0))
|
|
130
|
-
else ->
|
|
131
|
+
else -> {
|
|
132
|
+
if (angleDeg == 0f) {
|
|
133
|
+
HingeState(HingeStatus.CLOSED, 0.0)
|
|
134
|
+
} else {
|
|
135
|
+
HingeState(HingeStatus.UNKNOWN, angleRad ?: 0.0)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
131
138
|
}
|
|
132
139
|
}
|
|
133
140
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.margelo.nitro.one
|
|
2
|
+
|
|
3
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
4
|
+
import com.margelo.nitro.NitroModules
|
|
5
|
+
import java.io.File
|
|
6
|
+
|
|
7
|
+
// hands One.Storage's c++ engine the app's private directory, which only the
|
|
8
|
+
// android context knows. null until react has set the context.
|
|
9
|
+
@DoNotStrip
|
|
10
|
+
object OneStorageDirectory {
|
|
11
|
+
@JvmStatic
|
|
12
|
+
@DoNotStrip
|
|
13
|
+
fun path(): String? {
|
|
14
|
+
val context = NitroModules.applicationContext ?: return null
|
|
15
|
+
val directory = File(context.filesDir, "one")
|
|
16
|
+
directory.mkdirs()
|
|
17
|
+
return directory.absolutePath
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package dev.onejs.one
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.facebook.react.uimanager.events.Event
|
|
6
|
+
|
|
7
|
+
internal class OneKotlinHostEvent(
|
|
8
|
+
surfaceId: Int,
|
|
9
|
+
viewTag: Int,
|
|
10
|
+
private val name: String,
|
|
11
|
+
private val args: String,
|
|
12
|
+
) : Event<OneKotlinHostEvent>(surfaceId, viewTag) {
|
|
13
|
+
override fun getEventName(): String = "topHostEvent"
|
|
14
|
+
|
|
15
|
+
override fun canCoalesce(): Boolean = false
|
|
16
|
+
|
|
17
|
+
override fun getEventData(): WritableMap =
|
|
18
|
+
Arguments.createMap().apply {
|
|
19
|
+
putString("name", name)
|
|
20
|
+
putString("args", args)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
internal class OneKotlinHostSizeEvent(
|
|
25
|
+
surfaceId: Int,
|
|
26
|
+
viewTag: Int,
|
|
27
|
+
private val width: Double,
|
|
28
|
+
private val height: Double,
|
|
29
|
+
) : Event<OneKotlinHostSizeEvent>(surfaceId, viewTag) {
|
|
30
|
+
override fun getEventName(): String = "topHostSizeChange"
|
|
31
|
+
|
|
32
|
+
override fun canCoalesce(): Boolean = false
|
|
33
|
+
|
|
34
|
+
override fun getEventData(): WritableMap =
|
|
35
|
+
Arguments.createMap().apply {
|
|
36
|
+
putDouble("width", width)
|
|
37
|
+
putDouble("height", height)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
package dev.onejs.one
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
6
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
7
|
+
import com.facebook.react.viewmanagers.OneKotlinHostManagerDelegate
|
|
8
|
+
import com.facebook.react.viewmanagers.OneKotlinHostManagerInterface
|
|
9
|
+
|
|
10
|
+
@ReactModule(name = OneKotlinHostManager.REACT_CLASS)
|
|
11
|
+
class OneKotlinHostManager :
|
|
12
|
+
ViewGroupManager<OneKotlinHostView>(),
|
|
13
|
+
OneKotlinHostManagerInterface<OneKotlinHostView> {
|
|
14
|
+
|
|
15
|
+
private val delegate: ViewManagerDelegate<OneKotlinHostView> =
|
|
16
|
+
OneKotlinHostManagerDelegate(this)
|
|
17
|
+
|
|
18
|
+
init {
|
|
19
|
+
setupViewRecycling()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun getName(): String = REACT_CLASS
|
|
23
|
+
|
|
24
|
+
override fun createViewInstance(reactContext: ThemedReactContext): OneKotlinHostView =
|
|
25
|
+
OneKotlinHostView(reactContext)
|
|
26
|
+
|
|
27
|
+
override fun getDelegate(): ViewManagerDelegate<OneKotlinHostView> = delegate
|
|
28
|
+
|
|
29
|
+
override fun needsCustomLayoutForChildren(): Boolean = true
|
|
30
|
+
|
|
31
|
+
override fun onAfterUpdateTransaction(view: OneKotlinHostView) {
|
|
32
|
+
super.onAfterUpdateTransaction(view)
|
|
33
|
+
view.commitPendingProps()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override fun prepareToRecycleView(
|
|
37
|
+
reactContext: ThemedReactContext,
|
|
38
|
+
view: OneKotlinHostView,
|
|
39
|
+
): OneKotlinHostView? {
|
|
40
|
+
val recyclable = super.prepareToRecycleView(reactContext, view) ?: return null
|
|
41
|
+
recyclable.resetForReuse()
|
|
42
|
+
return recyclable
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override fun onDropViewInstance(view: OneKotlinHostView) {
|
|
46
|
+
view.resetForReuse()
|
|
47
|
+
super.onDropViewInstance(view)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun setSource(view: OneKotlinHostView, value: String?) {
|
|
51
|
+
view.stageSource(value)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override fun setView(view: OneKotlinHostView, value: String?) {
|
|
55
|
+
view.stageView(value)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override fun setContractHash(view: OneKotlinHostView, value: String?) {
|
|
59
|
+
view.stageContractHash(value)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
override fun setProps(view: OneKotlinHostView, value: String?) {
|
|
63
|
+
view.stageProps(value)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> {
|
|
67
|
+
val events =
|
|
68
|
+
super.getExportedCustomDirectEventTypeConstants()?.toMutableMap() ?: mutableMapOf()
|
|
69
|
+
events["topHostEvent"] =
|
|
70
|
+
mapOf("registrationName" to "onHostEvent")
|
|
71
|
+
events["topHostSizeChange"] =
|
|
72
|
+
mapOf("registrationName" to "onHostSizeChange")
|
|
73
|
+
return events
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
companion object {
|
|
77
|
+
const val REACT_CLASS = "OneKotlinHost"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
package dev.onejs.one
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.ViewGroup
|
|
5
|
+
import androidx.compose.runtime.getValue
|
|
6
|
+
import androidx.compose.runtime.mutableStateOf
|
|
7
|
+
import androidx.compose.runtime.setValue
|
|
8
|
+
import androidx.compose.ui.platform.ComposeView
|
|
9
|
+
import androidx.compose.ui.platform.ViewCompositionStrategy
|
|
10
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
11
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
12
|
+
|
|
13
|
+
class OneKotlinHostView(context: Context) : ReactViewGroup(context) {
|
|
14
|
+
private val composeView =
|
|
15
|
+
ComposeView(context).apply {
|
|
16
|
+
layoutParams =
|
|
17
|
+
ViewGroup.LayoutParams(
|
|
18
|
+
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
19
|
+
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
20
|
+
)
|
|
21
|
+
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnDetachedFromWindow)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private var stagedSource: String? = null
|
|
25
|
+
private var stagedView: String? = null
|
|
26
|
+
private var stagedContractHash: String? = null
|
|
27
|
+
private var stagedProps: String? = null
|
|
28
|
+
|
|
29
|
+
private var committedSource by mutableStateOf("")
|
|
30
|
+
private var committedView by mutableStateOf("")
|
|
31
|
+
private var committedContractHash by mutableStateOf("")
|
|
32
|
+
private var committedProps by mutableStateOf("{}")
|
|
33
|
+
|
|
34
|
+
private val contentLayout = Runnable { layoutComposeContent() }
|
|
35
|
+
|
|
36
|
+
private var reportedWidth = -1.0
|
|
37
|
+
private var reportedHeight = -1.0
|
|
38
|
+
|
|
39
|
+
init {
|
|
40
|
+
clipChildren = false
|
|
41
|
+
addView(composeView)
|
|
42
|
+
composeView.setContent {
|
|
43
|
+
val source = committedSource
|
|
44
|
+
val view = committedView
|
|
45
|
+
val hash = committedContractHash
|
|
46
|
+
val props = committedProps
|
|
47
|
+
|
|
48
|
+
if (source.isNotEmpty() && view.isNotEmpty()) {
|
|
49
|
+
val dispatch = OneNativeSourceViewRegistry.get(source)
|
|
50
|
+
if (dispatch.contractHash != hash) {
|
|
51
|
+
error(
|
|
52
|
+
"native view $source.$view changed (contract hash mismatch: expected $hash, got ${dispatch.contractHash}); rebuild the app"
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
dispatch.Content(
|
|
56
|
+
view = view,
|
|
57
|
+
propsJson = props,
|
|
58
|
+
emit = { eventName, eventArgs ->
|
|
59
|
+
onHostEvent(source, view, eventName, eventArgs)
|
|
60
|
+
},
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
internal fun stageSource(value: String?) {
|
|
67
|
+
stagedSource = value
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
internal fun stageView(value: String?) {
|
|
71
|
+
stagedView = value
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
internal fun stageContractHash(value: String?) {
|
|
75
|
+
stagedContractHash = value
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
internal fun stageProps(value: String?) {
|
|
79
|
+
stagedProps = value
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
internal fun commitPendingProps() {
|
|
83
|
+
val nextSource = stagedSource ?: ""
|
|
84
|
+
val nextView = stagedView ?: ""
|
|
85
|
+
val nextHash = stagedContractHash ?: ""
|
|
86
|
+
val nextProps = stagedProps ?: "{}"
|
|
87
|
+
|
|
88
|
+
val sourceOrViewChanged = nextSource != committedSource || nextView != committedView
|
|
89
|
+
if (sourceOrViewChanged) {
|
|
90
|
+
reportedWidth = -1.0
|
|
91
|
+
reportedHeight = -1.0
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (sourceOrViewChanged || nextHash != committedContractHash || nextProps != committedProps) {
|
|
95
|
+
committedSource = nextSource
|
|
96
|
+
committedView = nextView
|
|
97
|
+
committedContractHash = nextHash
|
|
98
|
+
committedProps = nextProps
|
|
99
|
+
requestLayout()
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
override fun requestLayout() {
|
|
104
|
+
super.requestLayout()
|
|
105
|
+
if (isAttachedToWindow) {
|
|
106
|
+
removeCallbacks(contentLayout)
|
|
107
|
+
post(contentLayout)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private fun onHostEvent(eventSource: String, eventView: String, name: String, args: String) {
|
|
112
|
+
// discard events from a detached or replaced source/view
|
|
113
|
+
if (!isAttachedToWindow || eventSource != committedSource || eventView != committedView) return
|
|
114
|
+
val reactContext = UIManagerHelper.getReactContext(this) ?: return
|
|
115
|
+
val dispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, id) ?: return
|
|
116
|
+
dispatcher.dispatchEvent(
|
|
117
|
+
OneKotlinHostEvent(
|
|
118
|
+
surfaceId = UIManagerHelper.getSurfaceId(this),
|
|
119
|
+
viewTag = id,
|
|
120
|
+
name = name,
|
|
121
|
+
args = args,
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private fun onContentSizeChanged(
|
|
127
|
+
sizeSource: String,
|
|
128
|
+
sizeView: String,
|
|
129
|
+
widthPx: Int,
|
|
130
|
+
heightPx: Int,
|
|
131
|
+
) {
|
|
132
|
+
if (!isAttachedToWindow || sizeSource != committedSource || sizeView != committedView) return
|
|
133
|
+
val density = resources.displayMetrics.density.toDouble()
|
|
134
|
+
if (density <= 0.0) return
|
|
135
|
+
val widthDp = widthPx / density
|
|
136
|
+
val heightDp = heightPx / density
|
|
137
|
+
if (widthDp == reportedWidth && heightDp == reportedHeight) return
|
|
138
|
+
reportedWidth = widthDp
|
|
139
|
+
reportedHeight = heightDp
|
|
140
|
+
val reactContext = UIManagerHelper.getReactContext(this) ?: return
|
|
141
|
+
val dispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, id) ?: return
|
|
142
|
+
dispatcher.dispatchEvent(
|
|
143
|
+
OneKotlinHostSizeEvent(
|
|
144
|
+
surfaceId = UIManagerHelper.getSurfaceId(this),
|
|
145
|
+
viewTag = id,
|
|
146
|
+
width = widthDp,
|
|
147
|
+
height = heightDp,
|
|
148
|
+
)
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
|
153
|
+
super.onLayout(changed, left, top, right, bottom)
|
|
154
|
+
layoutComposeContent()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
override fun onAttachedToWindow() {
|
|
158
|
+
super.onAttachedToWindow()
|
|
159
|
+
post(contentLayout)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private fun layoutComposeContent() {
|
|
163
|
+
if (!composeView.isAttachedToWindow || committedSource.isEmpty() || committedView.isEmpty()) return
|
|
164
|
+
// measure content before letting yoga apply the outer constraints.
|
|
165
|
+
composeView.measure(
|
|
166
|
+
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
|
|
167
|
+
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
|
|
168
|
+
)
|
|
169
|
+
val naturalWidth = composeView.measuredWidth
|
|
170
|
+
var naturalHeight = composeView.measuredHeight
|
|
171
|
+
if (width > 0 && width != naturalWidth) {
|
|
172
|
+
composeView.measure(
|
|
173
|
+
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
174
|
+
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
|
|
175
|
+
)
|
|
176
|
+
naturalHeight = composeView.measuredHeight
|
|
177
|
+
}
|
|
178
|
+
onContentSizeChanged(
|
|
179
|
+
committedSource,
|
|
180
|
+
committedView,
|
|
181
|
+
naturalWidth,
|
|
182
|
+
naturalHeight,
|
|
183
|
+
)
|
|
184
|
+
composeView.measure(
|
|
185
|
+
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
186
|
+
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
|
|
187
|
+
)
|
|
188
|
+
composeView.layout(0, 0, width, height)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
override fun onDetachedFromWindow() {
|
|
192
|
+
removeCallbacks(contentLayout)
|
|
193
|
+
super.onDetachedFromWindow()
|
|
194
|
+
composeView.disposeComposition()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
internal fun resetForReuse() {
|
|
198
|
+
removeCallbacks(contentLayout)
|
|
199
|
+
reportedWidth = -1.0
|
|
200
|
+
reportedHeight = -1.0
|
|
201
|
+
committedSource = ""
|
|
202
|
+
committedView = ""
|
|
203
|
+
committedContractHash = ""
|
|
204
|
+
committedProps = "{}"
|
|
205
|
+
stagedSource = null
|
|
206
|
+
stagedView = null
|
|
207
|
+
stagedContractHash = null
|
|
208
|
+
stagedProps = null
|
|
209
|
+
composeView.disposeComposition()
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package dev.onejs.one
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Composable
|
|
4
|
+
|
|
5
|
+
// generated per .kt source that declares public @Composable functions: renders
|
|
6
|
+
// one of them from the host's json props. a callback reports its arguments
|
|
7
|
+
// through emit as a json array.
|
|
8
|
+
interface OneNativeSourceViewDispatch {
|
|
9
|
+
val contractHash: String
|
|
10
|
+
|
|
11
|
+
@Composable
|
|
12
|
+
fun Content(view: String, propsJson: String, emit: (String, String) -> Unit)
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package dev.onejs.one
|
|
2
|
+
|
|
3
|
+
import java.util.concurrent.ConcurrentHashMap
|
|
4
|
+
|
|
5
|
+
internal object OneNativeSourceViewRegistry {
|
|
6
|
+
private val instances = ConcurrentHashMap<String, OneNativeSourceViewDispatch>()
|
|
7
|
+
|
|
8
|
+
fun get(sourceId: String): OneNativeSourceViewDispatch {
|
|
9
|
+
return instances.computeIfAbsent(sourceId) { id ->
|
|
10
|
+
val name = "OneNativeSourceViews_$id"
|
|
11
|
+
try {
|
|
12
|
+
val type = Class.forName(name)
|
|
13
|
+
type.getDeclaredConstructor().newInstance() as OneNativeSourceViewDispatch
|
|
14
|
+
} catch (e: ClassNotFoundException) {
|
|
15
|
+
error("native view dispatch $name is not linked; rebuild the app")
|
|
16
|
+
} catch (e: Exception) {
|
|
17
|
+
error("failed to instantiate $name: ${e.message}")
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
package dev.onejs.one.sharetarget
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.net.Uri
|
|
5
|
+
import android.util.AtomicFile
|
|
6
|
+
import java.io.IOException
|
|
7
|
+
import java.io.File
|
|
8
|
+
import java.util.UUID
|
|
9
|
+
import org.json.JSONArray
|
|
10
|
+
import org.json.JSONObject
|
|
11
|
+
|
|
12
|
+
internal data class StoredShareDraft(
|
|
13
|
+
val id: String,
|
|
14
|
+
val destinationId: String?,
|
|
15
|
+
val editedText: String,
|
|
16
|
+
val items: List<ShareItem>,
|
|
17
|
+
val pendingDelivery: Boolean = false,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
// durable store for one in-flight share draft per id, under the app's
|
|
21
|
+
// private files dir. a draft's attachment files live alongside its json so
|
|
22
|
+
// deleting the draft directory on success/cancel reclaims both in one call.
|
|
23
|
+
internal class OneShareDraftStore(private val context: Context) {
|
|
24
|
+
private fun rootDir(): File = File(context.filesDir, "one-sharetarget").apply { mkdirs() }
|
|
25
|
+
|
|
26
|
+
private fun draftDir(id: String): File = File(rootDir(), id)
|
|
27
|
+
|
|
28
|
+
private fun draftFile(id: String): File = File(draftDir(id), "draft.json")
|
|
29
|
+
|
|
30
|
+
fun newDraftId(): String = UUID.randomUUID().toString()
|
|
31
|
+
|
|
32
|
+
fun itemsDirectory(id: String): File = draftDir(id).apply { mkdirs() }
|
|
33
|
+
|
|
34
|
+
fun load(id: String): StoredShareDraft? {
|
|
35
|
+
val file = draftFile(id)
|
|
36
|
+
if (!file.exists() && !File(file.path + ".bak").exists()) return null
|
|
37
|
+
return try {
|
|
38
|
+
val json = JSONObject(AtomicFile(file).openRead().bufferedReader().use { it.readText() })
|
|
39
|
+
val items = mutableListOf<ShareItem>()
|
|
40
|
+
val itemsJson = json.optJSONArray("items") ?: JSONArray()
|
|
41
|
+
for (i in 0 until itemsJson.length()) {
|
|
42
|
+
val entry = itemsJson.getJSONObject(i)
|
|
43
|
+
when (entry.getString("type")) {
|
|
44
|
+
"text" -> items.add(ShareItem.Text(entry.getString("value")))
|
|
45
|
+
"url" -> items.add(ShareItem.Url(entry.getString("value")))
|
|
46
|
+
"file" ->
|
|
47
|
+
items.add(
|
|
48
|
+
ShareItem.File(
|
|
49
|
+
uri = Uri.parse(entry.getString("uri")),
|
|
50
|
+
name = entry.getString("name"),
|
|
51
|
+
mimeType = entry.getString("mimeType"),
|
|
52
|
+
size = entry.getLong("size"),
|
|
53
|
+
)
|
|
54
|
+
)
|
|
55
|
+
else -> continue
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
StoredShareDraft(
|
|
59
|
+
id = id,
|
|
60
|
+
destinationId = json.optString("destinationId", "").takeIf { it.isNotEmpty() },
|
|
61
|
+
editedText = json.optString("editedText", ""),
|
|
62
|
+
items = items,
|
|
63
|
+
pendingDelivery = json.optBoolean("pendingDelivery", false),
|
|
64
|
+
)
|
|
65
|
+
} catch (error: Exception) {
|
|
66
|
+
throw IOException("Could not read share draft $id", error)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
fun save(draft: StoredShareDraft) {
|
|
71
|
+
val itemsJson = JSONArray()
|
|
72
|
+
for (item in draft.items) {
|
|
73
|
+
val entry = JSONObject()
|
|
74
|
+
when (item) {
|
|
75
|
+
is ShareItem.Text -> entry.put("type", "text").put("value", item.value)
|
|
76
|
+
is ShareItem.Url -> entry.put("type", "url").put("value", item.value)
|
|
77
|
+
is ShareItem.File ->
|
|
78
|
+
entry
|
|
79
|
+
.put("type", "file")
|
|
80
|
+
.put("uri", item.uri.toString())
|
|
81
|
+
.put("name", item.name)
|
|
82
|
+
.put("mimeType", item.mimeType)
|
|
83
|
+
.put("size", item.size)
|
|
84
|
+
}
|
|
85
|
+
itemsJson.put(entry)
|
|
86
|
+
}
|
|
87
|
+
val json =
|
|
88
|
+
JSONObject()
|
|
89
|
+
.put("destinationId", draft.destinationId ?: JSONObject.NULL)
|
|
90
|
+
.put("editedText", draft.editedText)
|
|
91
|
+
.put("items", itemsJson)
|
|
92
|
+
.put("pendingDelivery", draft.pendingDelivery)
|
|
93
|
+
|
|
94
|
+
val dir = draftDir(draft.id).apply { mkdirs() }
|
|
95
|
+
val file = File(dir, "draft.json")
|
|
96
|
+
val atomic = AtomicFile(file)
|
|
97
|
+
val output = atomic.startWrite()
|
|
98
|
+
try {
|
|
99
|
+
output.write(json.toString().toByteArray(Charsets.UTF_8))
|
|
100
|
+
atomic.finishWrite(output)
|
|
101
|
+
} catch (error: Exception) {
|
|
102
|
+
atomic.failWrite(output)
|
|
103
|
+
throw error
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
fun delete(id: String) {
|
|
108
|
+
val directory = draftDir(id)
|
|
109
|
+
if (directory.exists() && !directory.deleteRecursively()) throw IOException("Could not discard share draft $id")
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// drops every file under a draft's dir except a pending draft.json, used
|
|
113
|
+
// to clear partial copies left by an intake that never finished (e.g. the
|
|
114
|
+
// process died mid-copy on rotation) before that intake is retried for
|
|
115
|
+
// the same draft id -- otherwise the retry's files pile up alongside the
|
|
116
|
+
// orphaned ones from the killed attempt.
|
|
117
|
+
fun clearItems(id: String) {
|
|
118
|
+
draftDir(id).listFiles()?.forEach { entry ->
|
|
119
|
+
if (entry.name != "draft.json" && entry.name != "draft.json.tmp") entry.deleteRecursively()
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|