pythonnative 0.40.0__cp313-cp313-win_amd64.whl
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.
- pythonnative/__init__.py +411 -0
- pythonnative/_ios_log.py +92 -0
- pythonnative/_yoga.cp313-win_amd64.pyd +0 -0
- pythonnative/alerts.py +236 -0
- pythonnative/animated.py +1687 -0
- pythonnative/animation_graph.py +78 -0
- pythonnative/appearance.py +124 -0
- pythonnative/bootstrap.py +100 -0
- pythonnative/bridge/__init__.py +302 -0
- pythonnative/bridge/android.py +78 -0
- pythonnative/bridge/codec.py +170 -0
- pythonnative/bridge/commits.py +114 -0
- pythonnative/bridge/fake.py +243 -0
- pythonnative/bridge/ios.py +138 -0
- pythonnative/bridge/web.py +489 -0
- pythonnative/cli/__init__.py +7 -0
- pythonnative/cli/pn.py +1214 -0
- pythonnative/component.py +271 -0
- pythonnative/components/__init__.py +111 -0
- pythonnative/components/_base.py +166 -0
- pythonnative/components/controls.py +521 -0
- pythonnative/components/layout.py +518 -0
- pythonnative/components/lists.py +785 -0
- pythonnative/components/media.py +204 -0
- pythonnative/components/overlays.py +107 -0
- pythonnative/components/pressable.py +252 -0
- pythonnative/components/structural.py +167 -0
- pythonnative/components/text.py +291 -0
- pythonnative/devclient.py +824 -0
- pythonnative/devserver/__init__.py +34 -0
- pythonnative/devserver/server.py +718 -0
- pythonnative/devserver/static/animation_graph.js +82 -0
- pythonnative/devserver/static/bridge.js +147 -0
- pythonnative/devserver/static/colors.js +70 -0
- pythonnative/devserver/static/host.js +552 -0
- pythonnative/devserver/static/index.html +60 -0
- pythonnative/devserver/static/layout.js +85 -0
- pythonnative/devserver/static/preview.css +415 -0
- pythonnative/devserver/static/renderer.js +1994 -0
- pythonnative/devserver/static/shell.js +345 -0
- pythonnative/devserver/static/yoga/LICENSE +21 -0
- pythonnative/devserver/static/yoga/binaries/yoga-wasm-base64-esm.js +75 -0
- pythonnative/devserver/static/yoga/src/generated/YGEnums.d.ts +189 -0
- pythonnative/devserver/static/yoga/src/generated/YGEnums.js +211 -0
- pythonnative/devserver/static/yoga/src/generated/YGEnums.js.map +1 -0
- pythonnative/devserver/static/yoga/src/index.d.ts +12 -0
- pythonnative/devserver/static/yoga/src/index.js +16 -0
- pythonnative/devserver/static/yoga/src/index.js.map +1 -0
- pythonnative/devserver/static/yoga/src/load.d.ts +11 -0
- pythonnative/devserver/static/yoga/src/load.js +17 -0
- pythonnative/devserver/static/yoga/src/load.js.map +1 -0
- pythonnative/devserver/static/yoga/src/wrapAssembly.d.ts +155 -0
- pythonnative/devserver/static/yoga/src/wrapAssembly.js +125 -0
- pythonnative/devserver/static/yoga/src/wrapAssembly.js.map +1 -0
- pythonnative/devserver/watcher.py +267 -0
- pythonnative/devserver/ws.py +421 -0
- pythonnative/diagnostics.py +241 -0
- pythonnative/element.py +159 -0
- pythonnative/equality.py +19 -0
- pythonnative/events.py +231 -0
- pythonnative/gestures.py +1333 -0
- pythonnative/hooks.py +1621 -0
- pythonnative/hosts/__init__.py +63 -0
- pythonnative/hosts/base.py +596 -0
- pythonnative/hosts/native.py +302 -0
- pythonnative/hot_reload.py +585 -0
- pythonnative/layout.py +328 -0
- pythonnative/mutations.py +142 -0
- pythonnative/native/android/build.gradle +52 -0
- pythonnative/native/android/gradle.properties +3 -0
- pythonnative/native/android/settings.gradle +12 -0
- pythonnative/native/android/src/main/AndroidManifest.xml +11 -0
- pythonnative/native/android/src/main/cpp/CMakeLists.txt +9 -0
- pythonnative/native/android/src/main/cpp/yoga_jni.cpp +52 -0
- pythonnative/native/android/src/main/java/com/pythonnative/generated/NativeModules.kt +5 -0
- pythonnative/native/android/src/main/java/com/pythonnative/generated/NativeProps.kt +3705 -0
- pythonnative/native/android/src/main/java/com/pythonnative/generated/PNContracts.kt +129 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/PNBridge.kt +261 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/PythonHost.kt +20 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/animation/AnimationGraph.kt +108 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/animation/AnimationSpecs.kt +141 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/animation/PNAnimator.kt +257 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/bridge/CommitState.kt +106 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/bridge/JsonUtil.kt +175 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/bridge/MainThread.kt +40 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/bridge/PNLog.kt +33 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/bridge/PNRegistry.kt +82 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/bridge/PNTransaction.kt +80 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/bridge/TransactionApplier.kt +117 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/bridge/ViewRegistry.kt +74 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/BuiltinComponents.kt +37 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ButtonManager.kt +32 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ComponentManager.kt +213 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ContainerManagers.kt +69 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ControlManagers.kt +186 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/DatePickerManager.kt +123 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ImageLoader.kt +141 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ImageManager.kt +162 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ModalManager.kt +134 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/PNColor.kt +201 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/PickerManager.kt +86 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/PortalManager.kt +55 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/PressableManager.kt +122 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ScreenStackManager.kt +110 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ScrollViewManager.kt +214 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/SegmentedControlManager.kt +113 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/StatusBarManager.kt +52 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/TabBarManager.kt +131 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/TextInputManager.kt +250 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/TextManager.kt +233 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/ViewStyler.kt +355 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/VirtualListManager.kt +159 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/components/WebViewManager.kt +149 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/gestures/GestureArbiter.kt +233 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/gestures/GestureCoordinator.kt +127 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/gestures/GestureRecognizers.kt +527 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/layout/NativeLayout.kt +145 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/layout/YogaNode.kt +29 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/modules/BuiltinModules.kt +73 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/modules/DeviceModules.kt +316 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/modules/HostModule.kt +61 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/modules/MediaModules.kt +200 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/modules/NativeModule.kt +158 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/modules/NotificationsModule.kt +100 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/modules/PermissionsModule.kt +99 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/modules/StorageModules.kt +89 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/modules/SystemModules.kt +178 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/plugins/GeneratedPlugins.kt +16 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/screens/PNScreenFragment.kt +188 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/screens/ScreenRegistry.kt +80 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/views/PNAccessibilityDelegate.kt +48 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/views/PNBorderDrawable.kt +76 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/views/PNEditText.kt +18 -0
- pythonnative/native/android/src/main/java/com/pythonnative/runtime/views/PNFrameLayout.kt +49 -0
- pythonnative/native/android/src/test/java/com/pythonnative/runtime/AnimationSpecsTest.kt +75 -0
- pythonnative/native/android/src/test/java/com/pythonnative/runtime/GestureArbiterTest.kt +197 -0
- pythonnative/native/android/src/test/java/com/pythonnative/runtime/PNColorTest.kt +47 -0
- pythonnative/native/android/src/test/java/com/pythonnative/runtime/PNTransactionTest.kt +78 -0
- pythonnative/native/android/src/test/java/com/pythonnative/runtime/PromiseTest.kt +89 -0
- pythonnative/native/ios/Package.swift +23 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Animation/PNAnimationGraph.swift +199 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Animation/PNAnimator.swift +312 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Bridge/PNBridge.swift +255 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Bridge/PNCommit.swift +104 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Bridge/PNRegistry.swift +142 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Bridge/PNTransaction.swift +166 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Bridge/PNViewRegistry.swift +53 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNButtonManagers.swift +207 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNColor.swift +173 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNComponentManager.swift +183 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNContainerView.swift +56 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNControlManagers.swift +281 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNImageManager.swift +222 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNOverlayManagers.swift +243 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNPressableManager.swift +114 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNScreenStackManager.swift +107 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNScrollViewManager.swift +197 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNTabBarManager.swift +106 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNTextInputManager.swift +297 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNTextManager.swift +230 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNTransform.swift +82 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNViewManager.swift +86 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNViewState.swift +87 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNViewStyler.swift +340 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNVirtualListManager.swift +155 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Components/PNWebViewManager.swift +124 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Generated/NativeModules.swift +1 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Generated/NativeProps.swift +3775 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Generated/PNContracts.swift +46 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Gestures/PNGestureCoordinator.swift +260 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Layout/PNLayout.swift +173 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Modules/AlertModule.swift +92 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Modules/HostModule.swift +80 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Modules/LifecycleModules.swift +174 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Modules/MediaModules.swift +177 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Modules/PNNativeModule.swift +168 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Modules/PermissionModules.swift +266 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Modules/SystemModules.swift +251 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Plugins/PNPluginRegistration.swift +8 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Screens/PNScreenRegistry.swift +46 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Screens/PNViewController.swift +237 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Support/PNCompat.swift +46 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Support/PNJSON.swift +173 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Support/PNLog.swift +47 -0
- pythonnative/native/ios/Sources/PythonNativeKit/Support/PNWindow.swift +51 -0
- pythonnative/native/ios/Tests/PythonNativeKitTests/PNAnimationGraphTests.swift +26 -0
- pythonnative/native/ios/Tests/PythonNativeKitTests/PNColorTests.swift +50 -0
- pythonnative/native/ios/Tests/PythonNativeKitTests/PNCommitTests.swift +86 -0
- pythonnative/native/ios/Tests/PythonNativeKitTests/PNGestureTests.swift +101 -0
- pythonnative/native/ios/Tests/PythonNativeKitTests/PNManagerTests.swift +126 -0
- pythonnative/native/ios/Tests/PythonNativeKitTests/PNModuleTests.swift +111 -0
- pythonnative/native/ios/Tests/PythonNativeKitTests/PNTransactionTests.swift +91 -0
- pythonnative/native/yoga/LICENSE +21 -0
- pythonnative/native/yoga/Package.swift +9 -0
- pythonnative/native/yoga/VENDORED.md +2 -0
- pythonnative/native/yoga/include/PNStyle.h +10 -0
- pythonnative/native/yoga/include/module.modulemap +5 -0
- pythonnative/native/yoga/include/yoga/YGConfig.h +158 -0
- pythonnative/native/yoga/include/yoga/YGEnums.h +142 -0
- pythonnative/native/yoga/include/yoga/YGMacros.h +99 -0
- pythonnative/native/yoga/include/yoga/YGNode.h +304 -0
- pythonnative/native/yoga/include/yoga/YGNodeLayout.h +35 -0
- pythonnative/native/yoga/include/yoga/YGNodeStyle.h +130 -0
- pythonnative/native/yoga/include/yoga/YGPixelGrid.h +29 -0
- pythonnative/native/yoga/include/yoga/YGValue.h +84 -0
- pythonnative/native/yoga/include/yoga/Yoga.h +21 -0
- pythonnative/native/yoga/python.cpp +16 -0
- pythonnative/native/yoga/style.cpp +272 -0
- pythonnative/native/yoga/yoga/CMakeLists.txt +41 -0
- pythonnative/native/yoga/yoga/YGConfig.cpp +92 -0
- pythonnative/native/yoga/yoga/YGConfig.h +158 -0
- pythonnative/native/yoga/yoga/YGEnums.cpp +262 -0
- pythonnative/native/yoga/yoga/YGEnums.h +142 -0
- pythonnative/native/yoga/yoga/YGMacros.h +99 -0
- pythonnative/native/yoga/yoga/YGNode.cpp +366 -0
- pythonnative/native/yoga/yoga/YGNode.h +304 -0
- pythonnative/native/yoga/yoga/YGNodeLayout.cpp +92 -0
- pythonnative/native/yoga/yoga/YGNodeLayout.h +35 -0
- pythonnative/native/yoga/yoga/YGNodeStyle.cpp +405 -0
- pythonnative/native/yoga/yoga/YGNodeStyle.h +130 -0
- pythonnative/native/yoga/yoga/YGPixelGrid.cpp +22 -0
- pythonnative/native/yoga/yoga/YGPixelGrid.h +29 -0
- pythonnative/native/yoga/yoga/YGValue.cpp +20 -0
- pythonnative/native/yoga/yoga/YGValue.h +84 -0
- pythonnative/native/yoga/yoga/Yoga.h +21 -0
- pythonnative/native/yoga/yoga/algorithm/AbsoluteLayout.cpp +563 -0
- pythonnative/native/yoga/yoga/algorithm/AbsoluteLayout.h +41 -0
- pythonnative/native/yoga/yoga/algorithm/Align.h +72 -0
- pythonnative/native/yoga/yoga/algorithm/Baseline.cpp +78 -0
- pythonnative/native/yoga/yoga/algorithm/Baseline.h +21 -0
- pythonnative/native/yoga/yoga/algorithm/BoundAxis.h +79 -0
- pythonnative/native/yoga/yoga/algorithm/Cache.cpp +121 -0
- pythonnative/native/yoga/yoga/algorithm/Cache.h +30 -0
- pythonnative/native/yoga/yoga/algorithm/CalculateLayout.cpp +2428 -0
- pythonnative/native/yoga/yoga/algorithm/CalculateLayout.h +38 -0
- pythonnative/native/yoga/yoga/algorithm/FlexDirection.h +120 -0
- pythonnative/native/yoga/yoga/algorithm/FlexLine.cpp +124 -0
- pythonnative/native/yoga/yoga/algorithm/FlexLine.h +75 -0
- pythonnative/native/yoga/yoga/algorithm/PixelGrid.cpp +132 -0
- pythonnative/native/yoga/yoga/algorithm/PixelGrid.h +29 -0
- pythonnative/native/yoga/yoga/algorithm/SizingMode.h +73 -0
- pythonnative/native/yoga/yoga/algorithm/TrailingPosition.h +44 -0
- pythonnative/native/yoga/yoga/config/Config.cpp +135 -0
- pythonnative/native/yoga/yoga/config/Config.h +92 -0
- pythonnative/native/yoga/yoga/debug/AssertFatal.cpp +53 -0
- pythonnative/native/yoga/yoga/debug/AssertFatal.h +29 -0
- pythonnative/native/yoga/yoga/debug/Log.cpp +107 -0
- pythonnative/native/yoga/yoga/debug/Log.h +34 -0
- pythonnative/native/yoga/yoga/enums/Align.h +47 -0
- pythonnative/native/yoga/yoga/enums/BoxSizing.h +40 -0
- pythonnative/native/yoga/yoga/enums/Dimension.h +40 -0
- pythonnative/native/yoga/yoga/enums/Direction.h +41 -0
- pythonnative/native/yoga/yoga/enums/Display.h +41 -0
- pythonnative/native/yoga/yoga/enums/Edge.h +47 -0
- pythonnative/native/yoga/yoga/enums/Errata.h +41 -0
- pythonnative/native/yoga/yoga/enums/ExperimentalFeature.h +39 -0
- pythonnative/native/yoga/yoga/enums/FlexDirection.h +42 -0
- pythonnative/native/yoga/yoga/enums/Gutter.h +41 -0
- pythonnative/native/yoga/yoga/enums/Justify.h +44 -0
- pythonnative/native/yoga/yoga/enums/LogLevel.h +44 -0
- pythonnative/native/yoga/yoga/enums/MeasureMode.h +41 -0
- pythonnative/native/yoga/yoga/enums/NodeType.h +40 -0
- pythonnative/native/yoga/yoga/enums/Overflow.h +41 -0
- pythonnative/native/yoga/yoga/enums/PhysicalEdge.h +21 -0
- pythonnative/native/yoga/yoga/enums/PositionType.h +41 -0
- pythonnative/native/yoga/yoga/enums/Unit.h +42 -0
- pythonnative/native/yoga/yoga/enums/Wrap.h +41 -0
- pythonnative/native/yoga/yoga/enums/YogaEnums.h +85 -0
- pythonnative/native/yoga/yoga/event/event.cpp +87 -0
- pythonnative/native/yoga/yoga/event/event.h +130 -0
- pythonnative/native/yoga/yoga/module.modulemap +21 -0
- pythonnative/native/yoga/yoga/node/CachedMeasurement.h +53 -0
- pythonnative/native/yoga/yoga/node/LayoutResults.cpp +48 -0
- pythonnative/native/yoga/yoga/node/LayoutResults.h +122 -0
- pythonnative/native/yoga/yoga/node/LayoutableChildren.h +148 -0
- pythonnative/native/yoga/yoga/node/Node.cpp +443 -0
- pythonnative/native/yoga/yoga/node/Node.h +337 -0
- pythonnative/native/yoga/yoga/numeric/Comparison.h +81 -0
- pythonnative/native/yoga/yoga/numeric/FloatOptional.h +93 -0
- pythonnative/native/yoga/yoga/style/SmallValueBuffer.h +133 -0
- pythonnative/native/yoga/yoga/style/Style.h +757 -0
- pythonnative/native/yoga/yoga/style/StyleLength.h +107 -0
- pythonnative/native/yoga/yoga/style/StyleValueHandle.h +98 -0
- pythonnative/native/yoga/yoga/style/StyleValuePool.h +127 -0
- pythonnative/native_modules/__init__.py +124 -0
- pythonnative/native_modules/app_state.py +99 -0
- pythonnative/native_modules/battery.py +75 -0
- pythonnative/native_modules/biometrics.py +42 -0
- pythonnative/native_modules/camera.py +65 -0
- pythonnative/native_modules/clipboard.py +46 -0
- pythonnative/native_modules/fallback.py +324 -0
- pythonnative/native_modules/file_system.py +145 -0
- pythonnative/native_modules/haptics.py +75 -0
- pythonnative/native_modules/linking.py +123 -0
- pythonnative/native_modules/location.py +75 -0
- pythonnative/native_modules/net_info.py +112 -0
- pythonnative/native_modules/notifications.py +129 -0
- pythonnative/native_modules/permissions.py +108 -0
- pythonnative/native_modules/registry.py +526 -0
- pythonnative/native_modules/secure_store.py +52 -0
- pythonnative/native_modules/share.py +51 -0
- pythonnative/native_views/__init__.py +375 -0
- pythonnative/native_views/base.py +316 -0
- pythonnative/native_views/bridge_backend.py +277 -0
- pythonnative/navigation/__init__.py +103 -0
- pythonnative/navigation/container.py +154 -0
- pythonnative/navigation/handle.py +540 -0
- pythonnative/navigation/hooks.py +133 -0
- pythonnative/navigation/host.py +58 -0
- pythonnative/navigation/linking.py +200 -0
- pythonnative/navigation/navigators.py +659 -0
- pythonnative/navigation/screen.py +149 -0
- pythonnative/navigation/state.py +269 -0
- pythonnative/net.py +248 -0
- pythonnative/platform.py +166 -0
- pythonnative/platform_metrics.py +252 -0
- pythonnative/preview.py +287 -0
- pythonnative/profiling.py +101 -0
- pythonnative/project/__init__.py +68 -0
- pythonnative/project/android.py +557 -0
- pythonnative/project/builder.py +817 -0
- pythonnative/project/config.py +773 -0
- pythonnative/project/deps.py +719 -0
- pythonnative/project/devices.py +304 -0
- pythonnative/project/doctor.py +283 -0
- pythonnative/project/fingerprint.py +171 -0
- pythonnative/project/icons.py +247 -0
- pythonnative/project/ios.py +325 -0
- pythonnative/project/lockfile.py +100 -0
- pythonnative/project/permissions.py +361 -0
- pythonnative/project/plugins.py +519 -0
- pythonnative/project/runtime_assets.py +183 -0
- pythonnative/py.typed +0 -0
- pythonnative/query.py +153 -0
- pythonnative/reconciler/__init__.py +29 -0
- pythonnative/reconciler/boundaries.py +375 -0
- pythonnative/reconciler/children.py +88 -0
- pythonnative/reconciler/core.py +1165 -0
- pythonnative/reconciler/layout_pass.py +393 -0
- pythonnative/reconciler/vnode.py +266 -0
- pythonnative/refresh.py +55 -0
- pythonnative/runtime.py +306 -0
- pythonnative/scheduler.py +159 -0
- pythonnative/sdk/__init__.py +153 -0
- pythonnative/sdk/_components.py +427 -0
- pythonnative/sdk/builtins.py +91 -0
- pythonnative/sdk/codegen.py +149 -0
- pythonnative/sdk/module_codegen.py +184 -0
- pythonnative/sdk/schema.py +224 -0
- pythonnative/sdk/templates/contracts.kt +46 -0
- pythonnative/sdk/templates/contracts.swift +46 -0
- pythonnative/storage.py +184 -0
- pythonnative/style.py +841 -0
- pythonnative/suspense.py +183 -0
- pythonnative/templates/android_template/app/build.gradle +75 -0
- pythonnative/templates/android_template/app/proguard-rules.pro +21 -0
- pythonnative/templates/android_template/app/src/androidTest/java/com/pythonnative/android_template/ExampleInstrumentedTest.kt +24 -0
- pythonnative/templates/android_template/app/src/debug/AndroidManifest.xml +7 -0
- pythonnative/templates/android_template/app/src/main/AndroidManifest.xml +32 -0
- pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/MainActivity.kt +130 -0
- pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/ScreenFragment.kt +13 -0
- pythonnative/templates/android_template/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
- pythonnative/templates/android_template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +30 -0
- pythonnative/templates/android_template/app/src/main/res/layout/activity_main.xml +10 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +6 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- pythonnative/templates/android_template/app/src/main/res/navigation/nav_graph.xml +22 -0
- pythonnative/templates/android_template/app/src/main/res/values/colors.xml +5 -0
- pythonnative/templates/android_template/app/src/main/res/values/strings.xml +5 -0
- pythonnative/templates/android_template/app/src/main/res/values/themes.xml +9 -0
- pythonnative/templates/android_template/app/src/main/res/values-night/themes.xml +7 -0
- pythonnative/templates/android_template/app/src/main/res/xml/backup_rules.xml +13 -0
- pythonnative/templates/android_template/app/src/main/res/xml/data_extraction_rules.xml +19 -0
- pythonnative/templates/android_template/app/src/test/java/com/pythonnative/android_template/ExampleUnitTest.kt +17 -0
- pythonnative/templates/android_template/build.gradle +10 -0
- pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.jar +0 -0
- pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.properties +6 -0
- pythonnative/templates/android_template/gradle.properties +23 -0
- pythonnative/templates/android_template/gradlew +185 -0
- pythonnative/templates/android_template/gradlew.bat +89 -0
- pythonnative/templates/android_template/settings.gradle +17 -0
- pythonnative/templates/ios_template/ios_template/AppDelegate.swift +51 -0
- pythonnative/templates/ios_template/ios_template/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- pythonnative/templates/ios_template/ios_template/Assets.xcassets/AppIcon.appiconset/Contents.json +13 -0
- pythonnative/templates/ios_template/ios_template/Assets.xcassets/Contents.json +6 -0
- pythonnative/templates/ios_template/ios_template/Base.lproj/LaunchScreen.storyboard +25 -0
- pythonnative/templates/ios_template/ios_template/BridgingHeader.h +14 -0
- pythonnative/templates/ios_template/ios_template/Info.plist +28 -0
- pythonnative/templates/ios_template/ios_template/PythonRuntime.swift +390 -0
- pythonnative/templates/ios_template/ios_template/SceneDelegate.swift +61 -0
- pythonnative/templates/ios_template/ios_template/ViewController.swift +23 -0
- pythonnative/templates/ios_template/ios_template.xcodeproj/project.pbxproj +745 -0
- pythonnative/templates/ios_template/ios_template.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- pythonnative/templates/ios_template/ios_templateTests/ios_templateTests.swift +36 -0
- pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITests.swift +41 -0
- pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITestsLaunchTests.swift +32 -0
- pythonnative/testing/__init__.py +53 -0
- pythonnative/testing/backend.py +276 -0
- pythonnative/testing/harness.py +369 -0
- pythonnative/utils.py +145 -0
- pythonnative-0.40.0.dist-info/DELVEWHEEL +2 -0
- pythonnative-0.40.0.dist-info/METADATA +150 -0
- pythonnative-0.40.0.dist-info/RECORD +418 -0
- pythonnative-0.40.0.dist-info/WHEEL +5 -0
- pythonnative-0.40.0.dist-info/entry_points.txt +2 -0
- pythonnative-0.40.0.dist-info/licenses/LICENSE +21 -0
- pythonnative-0.40.0.dist-info/top_level.txt +1 -0
- pythonnative.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
pythonnative/suspense.py
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"""Suspense resources backed by standard asyncio tasks."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import inspect
|
|
7
|
+
from typing import Any, Callable, Generic, Optional, Tuple, TypeVar
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T")
|
|
10
|
+
|
|
11
|
+
_UNSET = object()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Suspend(BaseException):
|
|
15
|
+
"""Signal that a render is blocked on pending async work.
|
|
16
|
+
|
|
17
|
+
Raised while a component renders, either by
|
|
18
|
+
[`Resource.read`][pythonnative.suspense.Resource.read] or by an
|
|
19
|
+
``async def`` component body blocking on a pending await. The
|
|
20
|
+
reconciler catches it: the nearest
|
|
21
|
+
[`Suspense`][pythonnative.Suspense] boundary shows its fallback
|
|
22
|
+
(initial mounts), or the component keeps its previous content and
|
|
23
|
+
re-renders when the work finishes (updates).
|
|
24
|
+
|
|
25
|
+
Derives from :class:`BaseException` so
|
|
26
|
+
[`ErrorBoundary`][pythonnative.ErrorBoundary] (which catches
|
|
27
|
+
:class:`Exception`) never mistakes a suspension for a crash.
|
|
28
|
+
|
|
29
|
+
Attributes:
|
|
30
|
+
waitable: The pending work; exposes ``done()`` and
|
|
31
|
+
``add_done_callback(cb)``.
|
|
32
|
+
hook_state: The suspended component's hook state, carried so
|
|
33
|
+
a Suspense boundary can preserve it across retries (its
|
|
34
|
+
cached resources survive, so the retry doesn't refetch).
|
|
35
|
+
key: ``(component identity, element key)`` used to re-match
|
|
36
|
+
``hook_state`` on retry.
|
|
37
|
+
label: Component name for diagnostics.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def __init__(self, waitable: Any, hook_state: Any = None, label: str = "") -> None:
|
|
41
|
+
super().__init__(label or "render suspended")
|
|
42
|
+
self.waitable = waitable
|
|
43
|
+
self.hook_state = hook_state
|
|
44
|
+
self.key: Optional[Tuple[int, Any]] = None
|
|
45
|
+
self.label = label
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Resource(Generic[T]):
|
|
49
|
+
"""A cached async value with Suspense integration.
|
|
50
|
+
|
|
51
|
+
Returned by [`use_resource`][pythonnative.use_resource]. A resource
|
|
52
|
+
starts fetching as soon as the hook runs and remembers its result
|
|
53
|
+
across renders (until its dependencies change), so re-renders never
|
|
54
|
+
refetch.
|
|
55
|
+
|
|
56
|
+
Two ways to consume it:
|
|
57
|
+
|
|
58
|
+
- ``resource.read()`` in a regular component: returns the value
|
|
59
|
+
when ready, re-raises the fetcher's error if it failed, and
|
|
60
|
+
**suspends the render** while pending.
|
|
61
|
+
- ``await resource`` in an ``async def`` component: same
|
|
62
|
+
semantics, expressed as a plain await.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
__slots__ = ("_driver",)
|
|
66
|
+
|
|
67
|
+
def __init__(self, driver: asyncio.Future[T]) -> None:
|
|
68
|
+
self._driver = driver
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def ready(self) -> bool:
|
|
72
|
+
"""Whether the fetch has finished (successfully or not)."""
|
|
73
|
+
return self._driver.done()
|
|
74
|
+
|
|
75
|
+
def read(self) -> T:
|
|
76
|
+
"""Return the fetched value, or suspend the render while pending.
|
|
77
|
+
|
|
78
|
+
Raises:
|
|
79
|
+
Suspend: While the fetch is still in flight (caught by the
|
|
80
|
+
reconciler, never by user code).
|
|
81
|
+
BaseException: Whatever the fetcher raised, re-raised so an
|
|
82
|
+
enclosing [`ErrorBoundary`][pythonnative.ErrorBoundary]
|
|
83
|
+
can catch it.
|
|
84
|
+
"""
|
|
85
|
+
driver = self._driver
|
|
86
|
+
if driver.done():
|
|
87
|
+
return driver.result()
|
|
88
|
+
raise Suspend(driver, label="Resource.read")
|
|
89
|
+
|
|
90
|
+
def __await__(self) -> Any:
|
|
91
|
+
# One consumer's cancellation must not cancel a shared resource.
|
|
92
|
+
return asyncio.shield(self._driver).__await__()
|
|
93
|
+
|
|
94
|
+
def cancel(self) -> None:
|
|
95
|
+
"""Cancel the in-flight fetch (no-op when already done)."""
|
|
96
|
+
self._driver.cancel()
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def start_resource(fetcher: Callable[[], Any]) -> Resource[Any]:
|
|
100
|
+
"""Start ``fetcher`` immediately and wrap it in a [`Resource`][pythonnative.Resource].
|
|
101
|
+
|
|
102
|
+
The fetcher may be an ``async def`` (typical) or a plain function;
|
|
103
|
+
synchronous results resolve the resource immediately, so reading
|
|
104
|
+
it never suspends.
|
|
105
|
+
|
|
106
|
+
This is the non-hook constructor used for module-level resources
|
|
107
|
+
(preloading data before a screen mounts) and by
|
|
108
|
+
[`lazy`][pythonnative.lazy]. Inside components, prefer
|
|
109
|
+
[`use_resource`][pythonnative.use_resource], which caches per
|
|
110
|
+
component instance and re-fetches when dependencies change.
|
|
111
|
+
"""
|
|
112
|
+
from .runtime import get_loop, run_async
|
|
113
|
+
|
|
114
|
+
try:
|
|
115
|
+
value = fetcher()
|
|
116
|
+
except Exception as exc:
|
|
117
|
+
future = get_loop().create_future()
|
|
118
|
+
future.set_exception(exc)
|
|
119
|
+
return Resource(future)
|
|
120
|
+
if inspect.isawaitable(value):
|
|
121
|
+
return Resource(run_async(value))
|
|
122
|
+
future = get_loop().create_future()
|
|
123
|
+
future.set_result(value)
|
|
124
|
+
return Resource(future)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def lazy(loader: Callable[[], Any]) -> Callable[..., Any]:
|
|
128
|
+
"""Define a component that loads its implementation on first render.
|
|
129
|
+
|
|
130
|
+
``loader`` runs once, the first time the returned component
|
|
131
|
+
renders; until it resolves, renders suspend (so wrap usages in a
|
|
132
|
+
[`Suspense`][pythonnative.Suspense] boundary to show a loading
|
|
133
|
+
state). The loaded value must be a component (a ``@component``
|
|
134
|
+
function or any element factory).
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
loader: A zero-arg callable returning the component, or an
|
|
138
|
+
``async def`` resolving to it. Synchronous loaders (a
|
|
139
|
+
deferred ``import``) resolve immediately and never
|
|
140
|
+
suspend.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
A component. Props (and children) pass through to the loaded
|
|
144
|
+
component unchanged.
|
|
145
|
+
|
|
146
|
+
Example:
|
|
147
|
+
```python
|
|
148
|
+
import pythonnative as pn
|
|
149
|
+
|
|
150
|
+
Chart = pn.lazy(lambda: __import__("app.chart", fromlist=["Chart"]).Chart)
|
|
151
|
+
|
|
152
|
+
@pn.component
|
|
153
|
+
def Dashboard():
|
|
154
|
+
return pn.Suspense(
|
|
155
|
+
Chart(points=[1, 2, 3]),
|
|
156
|
+
fallback=pn.ActivityIndicator(),
|
|
157
|
+
)
|
|
158
|
+
```
|
|
159
|
+
"""
|
|
160
|
+
from .component import Component
|
|
161
|
+
|
|
162
|
+
state: dict = {}
|
|
163
|
+
|
|
164
|
+
def Lazy(*children: Any, **props: Any) -> Any:
|
|
165
|
+
resource = state.get("resource")
|
|
166
|
+
if resource is None:
|
|
167
|
+
resource = start_resource(loader)
|
|
168
|
+
state["resource"] = resource
|
|
169
|
+
loaded = resource.read()
|
|
170
|
+
return loaded(*children, **props)
|
|
171
|
+
|
|
172
|
+
name = getattr(loader, "__name__", "Lazy")
|
|
173
|
+
if name == "<lambda>":
|
|
174
|
+
name = "Lazy"
|
|
175
|
+
return Component(Lazy, display_name=name)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
__all__ = [
|
|
179
|
+
"Resource",
|
|
180
|
+
"Suspend",
|
|
181
|
+
"lazy",
|
|
182
|
+
"start_resource",
|
|
183
|
+
]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
id 'com.android.application'
|
|
3
|
+
id 'org.jetbrains.kotlin.android'
|
|
4
|
+
id 'com.chaquo.python'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
android {
|
|
8
|
+
namespace 'com.pythonnative.android_template'
|
|
9
|
+
compileSdk 34
|
|
10
|
+
|
|
11
|
+
defaultConfig {
|
|
12
|
+
applicationId "com.pythonnative.android_template"
|
|
13
|
+
minSdk 24
|
|
14
|
+
targetSdk 34
|
|
15
|
+
versionCode 1
|
|
16
|
+
versionName "1.0"
|
|
17
|
+
|
|
18
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
19
|
+
ndk {
|
|
20
|
+
abiFilters "arm64-v8a", "x86_64"
|
|
21
|
+
}
|
|
22
|
+
python {
|
|
23
|
+
// Rewritten from app.python_version by the pn CLI (project/android.py).
|
|
24
|
+
version "3.13"
|
|
25
|
+
pyc {
|
|
26
|
+
// Rewritten by the pn CLI: debug builds keep the .py sources
|
|
27
|
+
// (tracebacks show code; the dev client can seed its overlay
|
|
28
|
+
// from them), release builds ship bytecode only.
|
|
29
|
+
src false
|
|
30
|
+
}
|
|
31
|
+
pip {
|
|
32
|
+
// `options` lines for [requirements].extra_index_urls are
|
|
33
|
+
// injected above `install` by the pn CLI.
|
|
34
|
+
install "-r", "requirements.txt"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
buildFeatures {
|
|
40
|
+
// MainActivity gates dev-only behavior (hot reload) on BuildConfig.DEBUG.
|
|
41
|
+
buildConfig true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
buildTypes {
|
|
45
|
+
release {
|
|
46
|
+
minifyEnabled false
|
|
47
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
compileOptions {
|
|
51
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
52
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
53
|
+
}
|
|
54
|
+
kotlinOptions {
|
|
55
|
+
jvmTarget = '1.8'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
dependencies {
|
|
60
|
+
|
|
61
|
+
// The PythonNative runtime: component managers, native modules,
|
|
62
|
+
// gestures, animations, and the screen fragment. Its AndroidX and
|
|
63
|
+
// Material dependencies are exposed transitively.
|
|
64
|
+
implementation project(':pythonnative')
|
|
65
|
+
|
|
66
|
+
implementation 'androidx.core:core-ktx:1.8.0'
|
|
67
|
+
implementation 'androidx.appcompat:appcompat:1.4.1'
|
|
68
|
+
implementation 'com.google.android.material:material:1.5.0'
|
|
69
|
+
// AndroidX Navigation for Fragment-based navigation (activity_main.xml)
|
|
70
|
+
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
|
|
71
|
+
implementation 'androidx.navigation:navigation-ui-ktx:2.7.7'
|
|
72
|
+
testImplementation 'junit:junit:4.13.2'
|
|
73
|
+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
|
74
|
+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
|
75
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Add project specific ProGuard rules here.
|
|
2
|
+
# You can control the set of applied configuration files using the
|
|
3
|
+
# proguardFiles setting in build.gradle.
|
|
4
|
+
#
|
|
5
|
+
# For more details, see
|
|
6
|
+
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
7
|
+
|
|
8
|
+
# If your project uses WebView with JS, uncomment the following
|
|
9
|
+
# and specify the fully qualified class name to the JavaScript interface
|
|
10
|
+
# class:
|
|
11
|
+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
12
|
+
# public *;
|
|
13
|
+
#}
|
|
14
|
+
|
|
15
|
+
# Uncomment this to preserve the line number information for
|
|
16
|
+
# debugging stack traces.
|
|
17
|
+
#-keepattributes SourceFile,LineNumberTable
|
|
18
|
+
|
|
19
|
+
# If you keep the line number information, uncomment this to
|
|
20
|
+
# hide the original source file name.
|
|
21
|
+
#-renamesourcefileattribute SourceFile
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.pythonnative.android_template
|
|
2
|
+
|
|
3
|
+
import androidx.test.platform.app.InstrumentationRegistry
|
|
4
|
+
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
5
|
+
|
|
6
|
+
import org.junit.Test
|
|
7
|
+
import org.junit.runner.RunWith
|
|
8
|
+
|
|
9
|
+
import org.junit.Assert.*
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Instrumented test, which will execute on an Android device.
|
|
13
|
+
*
|
|
14
|
+
* See [testing documentation](http://d.android.com/tools/testing).
|
|
15
|
+
*/
|
|
16
|
+
@RunWith(AndroidJUnit4::class)
|
|
17
|
+
class ExampleInstrumentedTest {
|
|
18
|
+
@Test
|
|
19
|
+
fun useAppContext() {
|
|
20
|
+
// Context of the app under test.
|
|
21
|
+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
|
22
|
+
assertEquals("com.pythonnative.android_template", appContext.packageName)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Debug builds are dev clients: they open a WebSocket to `pn start`
|
|
3
|
+
to sync sources and stream logs. Release builds don't merge this
|
|
4
|
+
file, so they gain no network permission the app didn't ask for. -->
|
|
5
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
6
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
7
|
+
</manifest>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
xmlns:tools="http://schemas.android.com/tools">
|
|
4
|
+
|
|
5
|
+
<!-- Runtime-gated on Android 13+ (API 33); requested by the
|
|
6
|
+
pythonnative notifications module before posting. -->
|
|
7
|
+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
|
8
|
+
|
|
9
|
+
<application
|
|
10
|
+
android:allowBackup="true"
|
|
11
|
+
android:dataExtractionRules="@xml/data_extraction_rules"
|
|
12
|
+
android:fullBackupContent="@xml/backup_rules"
|
|
13
|
+
android:icon="@mipmap/ic_launcher"
|
|
14
|
+
android:label="@string/app_name"
|
|
15
|
+
android:roundIcon="@mipmap/ic_launcher_round"
|
|
16
|
+
android:supportsRtl="true"
|
|
17
|
+
android:theme="@style/Theme.Android_template"
|
|
18
|
+
tools:targetApi="31">
|
|
19
|
+
<activity
|
|
20
|
+
android:name=".MainActivity"
|
|
21
|
+
android:exported="true"
|
|
22
|
+
android:launchMode="singleTask"
|
|
23
|
+
android:windowSoftInputMode="adjustResize">
|
|
24
|
+
<intent-filter>
|
|
25
|
+
<action android:name="android.intent.action.MAIN" />
|
|
26
|
+
|
|
27
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
|
28
|
+
</intent-filter>
|
|
29
|
+
</activity>
|
|
30
|
+
</application>
|
|
31
|
+
|
|
32
|
+
</manifest>
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
package com.pythonnative.android_template
|
|
2
|
+
|
|
3
|
+
import android.content.Intent
|
|
4
|
+
import android.graphics.Color
|
|
5
|
+
import android.graphics.Typeface
|
|
6
|
+
import android.os.Bundle
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import android.util.TypedValue
|
|
9
|
+
import android.widget.ScrollView
|
|
10
|
+
import android.widget.TextView
|
|
11
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
12
|
+
import com.chaquo.python.Python
|
|
13
|
+
import com.chaquo.python.android.AndroidPlatform
|
|
14
|
+
import com.pythonnative.runtime.PNBridge
|
|
15
|
+
import com.pythonnative.runtime.PythonHost
|
|
16
|
+
import com.pythonnative.runtime.modules.BuiltinModules
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The single activity. It starts Python, wires the `PNBridge` host
|
|
20
|
+
* callback into `pythonnative.bridge.native_callback`, runs the
|
|
21
|
+
* protocol handshake, and forwards activity callbacks to the Kotlin
|
|
22
|
+
* native modules. Screens live in `ScreenFragment`s inside the
|
|
23
|
+
* `NavHostFragment` from `activity_main.xml`.
|
|
24
|
+
*/
|
|
25
|
+
class MainActivity : AppCompatActivity() {
|
|
26
|
+
private val TAG = javaClass.simpleName
|
|
27
|
+
private var pythonReady = false
|
|
28
|
+
|
|
29
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
30
|
+
super.onCreate(savedInstanceState)
|
|
31
|
+
Log.d(TAG, "onCreate() called")
|
|
32
|
+
|
|
33
|
+
if (!Python.isStarted()) {
|
|
34
|
+
Python.start(AndroidPlatform(this))
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
PNBridge.setContext(this)
|
|
38
|
+
val py = Python.getInstance()
|
|
39
|
+
PNBridge.setHost(object : PythonHost {
|
|
40
|
+
override fun callback(kind: String, tag: Long, name: String, payloadJson: String): String? =
|
|
41
|
+
py.getModule("pythonnative.bridge")
|
|
42
|
+
.callAttr("native_callback", kind, tag, name, payloadJson)
|
|
43
|
+
?.toString()
|
|
44
|
+
})
|
|
45
|
+
if (BuildConfig.DEBUG) {
|
|
46
|
+
// Dev-only: the writable source overlay the dev client syncs
|
|
47
|
+
// into, and the dev server `pn run` asked us to connect to
|
|
48
|
+
// (an intent extra; a remembered server is used otherwise).
|
|
49
|
+
py.getModule("pythonnative.hot_reload").callAttr(
|
|
50
|
+
"configure_dev_environment",
|
|
51
|
+
filesDir.absolutePath,
|
|
52
|
+
intent?.getStringExtra("pn_dev_server")
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
// Handshake with the runtime library (raises on a protocol
|
|
56
|
+
// mismatch, before any screen is created), enable dev mode in
|
|
57
|
+
// debug builds, and warm the asyncio runtime.
|
|
58
|
+
py.getModule("pythonnative.bootstrap").callAttr("start", BuildConfig.DEBUG, true)
|
|
59
|
+
// Import the entry module now so a broken app fails here,
|
|
60
|
+
// with a full traceback, instead of inside the first fragment.
|
|
61
|
+
py.getModule(getString(R.string.pn_entry_module))
|
|
62
|
+
pythonReady = true
|
|
63
|
+
// Set content view to the NavHost layout; the initial screen
|
|
64
|
+
// loads via nav_graph startDestination.
|
|
65
|
+
setContentView(R.layout.activity_main)
|
|
66
|
+
} catch (e: Exception) {
|
|
67
|
+
Log.e("PythonNative", "Bootstrap failed", e)
|
|
68
|
+
showBootstrapError(e)
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
override fun onDestroy() {
|
|
74
|
+
super.onDestroy()
|
|
75
|
+
BuiltinModules.onActivityDestroyed(this)
|
|
76
|
+
PNBridge.clearContext(this)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Deprecated("Deprecated in Java")
|
|
80
|
+
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
81
|
+
@Suppress("DEPRECATION")
|
|
82
|
+
super.onActivityResult(requestCode, resultCode, data)
|
|
83
|
+
BuiltinModules.onActivityResult(requestCode, resultCode, data)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
override fun onRequestPermissionsResult(
|
|
87
|
+
requestCode: Int,
|
|
88
|
+
permissions: Array<out String>,
|
|
89
|
+
grantResults: IntArray
|
|
90
|
+
) {
|
|
91
|
+
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
|
92
|
+
BuiltinModules.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
override fun onNewIntent(intent: Intent) {
|
|
96
|
+
super.onNewIntent(intent)
|
|
97
|
+
setIntent(intent)
|
|
98
|
+
BuiltinModules.onNewIntent(intent)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
override fun onResume() {
|
|
102
|
+
super.onResume()
|
|
103
|
+
if (pythonReady) BuiltinModules.onActivityResumed()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
override fun onPause() {
|
|
107
|
+
super.onPause()
|
|
108
|
+
if (pythonReady) BuiltinModules.onActivityPaused()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
override fun onStop() {
|
|
112
|
+
super.onStop()
|
|
113
|
+
if (pythonReady) BuiltinModules.onActivityStopped()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private fun showBootstrapError(error: Exception) {
|
|
117
|
+
val text = TextView(this)
|
|
118
|
+
text.text = "PythonNative could not start\n\n" + Log.getStackTraceString(error)
|
|
119
|
+
text.setTextColor(Color.WHITE)
|
|
120
|
+
text.setBackgroundColor(Color.rgb(191, 26, 26))
|
|
121
|
+
text.typeface = Typeface.MONOSPACE
|
|
122
|
+
text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
|
|
123
|
+
val pad = (16 * resources.displayMetrics.density).toInt()
|
|
124
|
+
text.setPadding(pad, pad * 3, pad, pad * 2)
|
|
125
|
+
val scroll = ScrollView(this)
|
|
126
|
+
scroll.setBackgroundColor(Color.rgb(191, 26, 26))
|
|
127
|
+
scroll.addView(text)
|
|
128
|
+
setContentView(scroll)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package com.pythonnative.android_template
|
|
2
|
+
|
|
3
|
+
import com.pythonnative.runtime.screens.PNScreenFragment
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The app's screen fragment (named by `nav_graph.xml`). The start
|
|
7
|
+
* destination has no `screen_path` argument, so it shows the entry
|
|
8
|
+
* module from `pythonnative.toml` (staged into `R.string.pn_entry_module`);
|
|
9
|
+
* pushed screens carry an explicit path.
|
|
10
|
+
*/
|
|
11
|
+
class ScreenFragment : PNScreenFragment() {
|
|
12
|
+
override fun defaultPath(): String = getString(R.string.pn_entry_module)
|
|
13
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
android:width="108dp"
|
|
4
|
+
android:height="108dp"
|
|
5
|
+
android:viewportWidth="108"
|
|
6
|
+
android:viewportHeight="108">
|
|
7
|
+
<path
|
|
8
|
+
android:fillColor="#3DDC84"
|
|
9
|
+
android:pathData="M0,0h108v108h-108z" />
|
|
10
|
+
<path
|
|
11
|
+
android:fillColor="#00000000"
|
|
12
|
+
android:pathData="M9,0L9,108"
|
|
13
|
+
android:strokeWidth="0.8"
|
|
14
|
+
android:strokeColor="#33FFFFFF" />
|
|
15
|
+
<path
|
|
16
|
+
android:fillColor="#00000000"
|
|
17
|
+
android:pathData="M19,0L19,108"
|
|
18
|
+
android:strokeWidth="0.8"
|
|
19
|
+
android:strokeColor="#33FFFFFF" />
|
|
20
|
+
<path
|
|
21
|
+
android:fillColor="#00000000"
|
|
22
|
+
android:pathData="M29,0L29,108"
|
|
23
|
+
android:strokeWidth="0.8"
|
|
24
|
+
android:strokeColor="#33FFFFFF" />
|
|
25
|
+
<path
|
|
26
|
+
android:fillColor="#00000000"
|
|
27
|
+
android:pathData="M39,0L39,108"
|
|
28
|
+
android:strokeWidth="0.8"
|
|
29
|
+
android:strokeColor="#33FFFFFF" />
|
|
30
|
+
<path
|
|
31
|
+
android:fillColor="#00000000"
|
|
32
|
+
android:pathData="M49,0L49,108"
|
|
33
|
+
android:strokeWidth="0.8"
|
|
34
|
+
android:strokeColor="#33FFFFFF" />
|
|
35
|
+
<path
|
|
36
|
+
android:fillColor="#00000000"
|
|
37
|
+
android:pathData="M59,0L59,108"
|
|
38
|
+
android:strokeWidth="0.8"
|
|
39
|
+
android:strokeColor="#33FFFFFF" />
|
|
40
|
+
<path
|
|
41
|
+
android:fillColor="#00000000"
|
|
42
|
+
android:pathData="M69,0L69,108"
|
|
43
|
+
android:strokeWidth="0.8"
|
|
44
|
+
android:strokeColor="#33FFFFFF" />
|
|
45
|
+
<path
|
|
46
|
+
android:fillColor="#00000000"
|
|
47
|
+
android:pathData="M79,0L79,108"
|
|
48
|
+
android:strokeWidth="0.8"
|
|
49
|
+
android:strokeColor="#33FFFFFF" />
|
|
50
|
+
<path
|
|
51
|
+
android:fillColor="#00000000"
|
|
52
|
+
android:pathData="M89,0L89,108"
|
|
53
|
+
android:strokeWidth="0.8"
|
|
54
|
+
android:strokeColor="#33FFFFFF" />
|
|
55
|
+
<path
|
|
56
|
+
android:fillColor="#00000000"
|
|
57
|
+
android:pathData="M99,0L99,108"
|
|
58
|
+
android:strokeWidth="0.8"
|
|
59
|
+
android:strokeColor="#33FFFFFF" />
|
|
60
|
+
<path
|
|
61
|
+
android:fillColor="#00000000"
|
|
62
|
+
android:pathData="M0,9L108,9"
|
|
63
|
+
android:strokeWidth="0.8"
|
|
64
|
+
android:strokeColor="#33FFFFFF" />
|
|
65
|
+
<path
|
|
66
|
+
android:fillColor="#00000000"
|
|
67
|
+
android:pathData="M0,19L108,19"
|
|
68
|
+
android:strokeWidth="0.8"
|
|
69
|
+
android:strokeColor="#33FFFFFF" />
|
|
70
|
+
<path
|
|
71
|
+
android:fillColor="#00000000"
|
|
72
|
+
android:pathData="M0,29L108,29"
|
|
73
|
+
android:strokeWidth="0.8"
|
|
74
|
+
android:strokeColor="#33FFFFFF" />
|
|
75
|
+
<path
|
|
76
|
+
android:fillColor="#00000000"
|
|
77
|
+
android:pathData="M0,39L108,39"
|
|
78
|
+
android:strokeWidth="0.8"
|
|
79
|
+
android:strokeColor="#33FFFFFF" />
|
|
80
|
+
<path
|
|
81
|
+
android:fillColor="#00000000"
|
|
82
|
+
android:pathData="M0,49L108,49"
|
|
83
|
+
android:strokeWidth="0.8"
|
|
84
|
+
android:strokeColor="#33FFFFFF" />
|
|
85
|
+
<path
|
|
86
|
+
android:fillColor="#00000000"
|
|
87
|
+
android:pathData="M0,59L108,59"
|
|
88
|
+
android:strokeWidth="0.8"
|
|
89
|
+
android:strokeColor="#33FFFFFF" />
|
|
90
|
+
<path
|
|
91
|
+
android:fillColor="#00000000"
|
|
92
|
+
android:pathData="M0,69L108,69"
|
|
93
|
+
android:strokeWidth="0.8"
|
|
94
|
+
android:strokeColor="#33FFFFFF" />
|
|
95
|
+
<path
|
|
96
|
+
android:fillColor="#00000000"
|
|
97
|
+
android:pathData="M0,79L108,79"
|
|
98
|
+
android:strokeWidth="0.8"
|
|
99
|
+
android:strokeColor="#33FFFFFF" />
|
|
100
|
+
<path
|
|
101
|
+
android:fillColor="#00000000"
|
|
102
|
+
android:pathData="M0,89L108,89"
|
|
103
|
+
android:strokeWidth="0.8"
|
|
104
|
+
android:strokeColor="#33FFFFFF" />
|
|
105
|
+
<path
|
|
106
|
+
android:fillColor="#00000000"
|
|
107
|
+
android:pathData="M0,99L108,99"
|
|
108
|
+
android:strokeWidth="0.8"
|
|
109
|
+
android:strokeColor="#33FFFFFF" />
|
|
110
|
+
<path
|
|
111
|
+
android:fillColor="#00000000"
|
|
112
|
+
android:pathData="M19,29L89,29"
|
|
113
|
+
android:strokeWidth="0.8"
|
|
114
|
+
android:strokeColor="#33FFFFFF" />
|
|
115
|
+
<path
|
|
116
|
+
android:fillColor="#00000000"
|
|
117
|
+
android:pathData="M19,39L89,39"
|
|
118
|
+
android:strokeWidth="0.8"
|
|
119
|
+
android:strokeColor="#33FFFFFF" />
|
|
120
|
+
<path
|
|
121
|
+
android:fillColor="#00000000"
|
|
122
|
+
android:pathData="M19,49L89,49"
|
|
123
|
+
android:strokeWidth="0.8"
|
|
124
|
+
android:strokeColor="#33FFFFFF" />
|
|
125
|
+
<path
|
|
126
|
+
android:fillColor="#00000000"
|
|
127
|
+
android:pathData="M19,59L89,59"
|
|
128
|
+
android:strokeWidth="0.8"
|
|
129
|
+
android:strokeColor="#33FFFFFF" />
|
|
130
|
+
<path
|
|
131
|
+
android:fillColor="#00000000"
|
|
132
|
+
android:pathData="M19,69L89,69"
|
|
133
|
+
android:strokeWidth="0.8"
|
|
134
|
+
android:strokeColor="#33FFFFFF" />
|
|
135
|
+
<path
|
|
136
|
+
android:fillColor="#00000000"
|
|
137
|
+
android:pathData="M19,79L89,79"
|
|
138
|
+
android:strokeWidth="0.8"
|
|
139
|
+
android:strokeColor="#33FFFFFF" />
|
|
140
|
+
<path
|
|
141
|
+
android:fillColor="#00000000"
|
|
142
|
+
android:pathData="M29,19L29,89"
|
|
143
|
+
android:strokeWidth="0.8"
|
|
144
|
+
android:strokeColor="#33FFFFFF" />
|
|
145
|
+
<path
|
|
146
|
+
android:fillColor="#00000000"
|
|
147
|
+
android:pathData="M39,19L39,89"
|
|
148
|
+
android:strokeWidth="0.8"
|
|
149
|
+
android:strokeColor="#33FFFFFF" />
|
|
150
|
+
<path
|
|
151
|
+
android:fillColor="#00000000"
|
|
152
|
+
android:pathData="M49,19L49,89"
|
|
153
|
+
android:strokeWidth="0.8"
|
|
154
|
+
android:strokeColor="#33FFFFFF" />
|
|
155
|
+
<path
|
|
156
|
+
android:fillColor="#00000000"
|
|
157
|
+
android:pathData="M59,19L59,89"
|
|
158
|
+
android:strokeWidth="0.8"
|
|
159
|
+
android:strokeColor="#33FFFFFF" />
|
|
160
|
+
<path
|
|
161
|
+
android:fillColor="#00000000"
|
|
162
|
+
android:pathData="M69,19L69,89"
|
|
163
|
+
android:strokeWidth="0.8"
|
|
164
|
+
android:strokeColor="#33FFFFFF" />
|
|
165
|
+
<path
|
|
166
|
+
android:fillColor="#00000000"
|
|
167
|
+
android:pathData="M79,19L79,89"
|
|
168
|
+
android:strokeWidth="0.8"
|
|
169
|
+
android:strokeColor="#33FFFFFF" />
|
|
170
|
+
</vector>
|