pytron-kit 0.3.12__py3-none-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.
- pytron/__init__.py +112 -0
- pytron/application.py +562 -0
- pytron/apputils/__init__.py +0 -0
- pytron/apputils/chrome_ipc.py +203 -0
- pytron/apputils/codegen.py +261 -0
- pytron/apputils/config.py +303 -0
- pytron/apputils/deadmansswitch.py +47 -0
- pytron/apputils/extras.py +76 -0
- pytron/apputils/native.py +148 -0
- pytron/apputils/shell.py +73 -0
- pytron/apputils/windows.py +286 -0
- pytron/cli.py +384 -0
- pytron/commands/__init__.py +0 -0
- pytron/commands/android.py +28 -0
- pytron/commands/build.py +26 -0
- pytron/commands/doctor.py +221 -0
- pytron/commands/engine.py +23 -0
- pytron/commands/frontend.py +60 -0
- pytron/commands/harvest.py +112 -0
- pytron/commands/helpers.py +239 -0
- pytron/commands/info.py +50 -0
- pytron/commands/init.py +521 -0
- pytron/commands/install.py +294 -0
- pytron/commands/login.py +130 -0
- pytron/commands/package.py +228 -0
- pytron/commands/plugin.py +442 -0
- pytron/commands/run.py +312 -0
- pytron/commands/scan.py +210 -0
- pytron/commands/show.py +23 -0
- pytron/commands/uninstall.py +150 -0
- pytron/commands/utils.py +42 -0
- pytron/commands/workflow.py +95 -0
- pytron/console.py +133 -0
- pytron/core.py +18 -0
- pytron/dependencies/WebView2Loader.dll +0 -0
- pytron/dependencies/__init__.py +1 -0
- pytron/dependencies/pytron_native.pyd +0 -0
- pytron/engines/chrome/adapter.py +445 -0
- pytron/engines/chrome/engine.py +576 -0
- pytron/engines/chrome/forge.py +147 -0
- pytron/engines/chrome/shell/package.json +8 -0
- pytron/engines/chrome/shell/preload.js +12 -0
- pytron/engines/chrome/shell/shell.js +534 -0
- pytron/exceptions.py +36 -0
- pytron/inspector.py +201 -0
- pytron/inspector_ui.py +512 -0
- pytron/installer/Installation.nsi +236 -0
- pytron/installer/header.bmp +0 -0
- pytron/installer/pytron.ico +0 -0
- pytron/installer/sidebar.bmp +0 -0
- pytron/llms.md +98 -0
- pytron/manifests/README.md +29 -0
- pytron/manifests/windows-utf8.manifest +44 -0
- pytron/menu.py +128 -0
- pytron/nsis-setup.exe +0 -0
- pytron/pack/__init__.py +0 -0
- pytron/pack/assets.py +131 -0
- pytron/pack/compilers.py +289 -0
- pytron/pack/crystal.py +297 -0
- pytron/pack/graph.py +377 -0
- pytron/pack/inference.py +157 -0
- pytron/pack/installers.py +402 -0
- pytron/pack/introspect.py +357 -0
- pytron/pack/metadata.py +213 -0
- pytron/pack/modules.py +618 -0
- pytron/pack/nuitka.py +108 -0
- pytron/pack/pipeline.py +107 -0
- pytron/pack/pyinstaller.py +176 -0
- pytron/pack/rust_engine.py +273 -0
- pytron/pack/secure.py +309 -0
- pytron/pack/secure_loader/bin/pytron_rust_bootloader.exe +0 -0
- pytron/pack/secure_loader/icon.ico +0 -0
- pytron/pack/utils.py +110 -0
- pytron/pack/virtual_root.py +124 -0
- pytron/platforms/__init__.py +0 -0
- pytron/platforms/android/__init__.py +3 -0
- pytron/platforms/android/android.py +103 -0
- pytron/platforms/android/builder.py +736 -0
- pytron/platforms/android/ops/build.py +79 -0
- pytron/platforms/android/ops/init.py +63 -0
- pytron/platforms/android/ops/run.py +79 -0
- pytron/platforms/android/ops/sync.py +770 -0
- pytron/platforms/android/ops/utils.py +8 -0
- pytron/platforms/android/shell/README.md +30 -0
- pytron/platforms/android/shell/app/build.gradle +64 -0
- pytron/platforms/android/shell/app/src/main/AndroidManifest.xml +29 -0
- pytron/platforms/android/shell/app/src/main/assets/python/main.py +86 -0
- pytron/platforms/android/shell/app/src/main/assets/python/python314.zip +0 -0
- pytron/platforms/android/shell/app/src/main/cpp/CMakeLists.txt +25 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/Python.h +155 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/abstract.h +915 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/audit.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bltinmodule.h +14 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/boolobject.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bytearrayobject.h +44 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bytesobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/ceval.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/codecs.h +176 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/compile.h +22 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/complexobject.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/abstract.h +104 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/audit.h +8 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytearrayobject.h +38 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytesobject.h +42 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/cellobject.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/ceval.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/classobject.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/code.h +340 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/compile.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/complexobject.h +33 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/context.h +107 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/critical_section.h +154 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/descrobject.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/dictobject.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileobject.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileutils.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/floatobject.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/frameobject.h +35 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/funcobject.h +185 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/genobject.h +56 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/import.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/initconfig.h +334 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/listobject.h +53 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/lock.h +74 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longintrepr.h +184 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longobject.h +89 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/memoryobject.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/methodobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/modsupport.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/monitoring.h +269 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/object.h +493 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/objimpl.h +104 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/odictobject.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/picklebufobject.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pthread_stubs.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic.h +614 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_gcc.h +615 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_msc.h +1197 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_std.h +1112 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyctype.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pydebug.h +38 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyerrors.h +132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyfpe.h +15 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyframe.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyhash.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pylifecycle.h +89 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pymem.h +84 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystate.h +275 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystats.h +194 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythonrun.h +96 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythread.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pytime.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/setobject.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/traceback.h +13 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tracemalloc.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tupleobject.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/unicodeobject.h +773 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/warnings.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/weakrefobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/critical_section.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/datetime.h +267 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/descrobject.h +100 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/dictobject.h +108 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/dynamic_annotations.h +499 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/enumobject.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/errcode.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/exports.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/fileobject.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/fileutils.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/floatobject.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/frameobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/genericaliasobject.h +14 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/import.h +103 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/atomic.h +392 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/internal.h +969 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/prim.h +329 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/track.h +147 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/types.h +721 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc.h +565 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_abstract.h +61 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_asdl.h +112 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast.h +945 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast_state.h +271 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_atexit.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_audit.h +35 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_backoff.h +133 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bitutils.h +186 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_blocks_output_buffer.h +321 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_brc.h +73 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytes_methods.h +82 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytesobject.h +149 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_c_array.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_call.h +206 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_capsule.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_cell.h +75 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval.h +390 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval_state.h +48 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_code.h +671 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_codecs.h +76 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_compile.h +230 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_complexobject.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_condvar.h +93 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_context.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_critical_section.h +237 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp.h +406 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp_data_registry.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_debug_offsets.h +379 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_descrobject.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict.h +410 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict_state.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dtoa.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_signal.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_trampoline.h +70 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_exceptions.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_faulthandler.h +100 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils.h +320 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils_windows.h +98 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_floatobject.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_flowgraph.h +47 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_format.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_frame.h +61 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist.h +111 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist_state.h +70 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_function.h +53 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gc.h +378 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_genobject.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_getopt.h +22 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gil.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects_fini_generated.h +1592 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_strings.h +854 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hamt.h +113 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hashtable.h +150 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_import.h +141 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_importdl.h +139 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_index_pool.h +36 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_initconfig.h +197 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruction_sequence.h +83 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruments.h +127 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp.h +109 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp_structs.h +977 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe.h +401 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe_structs.h +95 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpolation.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_intrinsics.h +51 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_jit.h +29 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_list.h +81 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_llist.h +106 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_lock.h +236 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_long.h +319 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_magic_number.h +305 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_memoryobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_mimalloc.h +69 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_modsupport.h +99 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_moduleobject.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_namespace.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object.h +1029 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_alloc.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_deferred.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_stack.h +95 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_state.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc.h +702 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc_init.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_metadata.h +2117 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_utils.h +90 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_optimizer.h +318 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parking_lot.h +97 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parser.h +78 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pathconfig.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyarena.h +68 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyatomic_ft_wrappers.h +174 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pybuffer.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyerrors.h +213 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyhash.h +91 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pylifecycle.h +136 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymath.h +205 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem_init.h +103 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystate.h +339 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystats.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythonrun.h +68 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythread.h +172 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_qsbr.h +172 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_range.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime.h +63 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init.h +239 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init_generated.h +1589 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_structs.h +310 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_semaphore.h +67 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_setobject.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_signal.h +108 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sliceobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stackref.h +791 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stats.h +97 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_strhex.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structs.h +88 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structseq.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_symtable.h +201 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sysmodule.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_template.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_time.h +334 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_token.h +110 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_traceback.h +111 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tracemalloc.h +164 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tstate.h +88 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tuple.h +75 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typedefs.h +18 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typeobject.h +155 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typevarobject.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ucnhash.h +36 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject.h +308 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject_generated.h +3132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unionobject.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uniqueid.h +57 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_ids.h +335 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_metadata.h +1204 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_warnings.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_weakref.h +133 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/intrcheck.h +23 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/iterobject.h +24 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/listobject.h +55 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/lock.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/longobject.h +178 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/marshal.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/memoryobject.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/methodobject.h +146 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/modsupport.h +146 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/moduleobject.h +122 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/monitoring.h +18 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/object.h +828 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/objimpl.h +211 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/opcode.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/opcode_ids.h +259 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/osdefs.h +57 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/osmodule.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/patchlevel.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/py_curses.h +117 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyatomic.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pybuffer.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pycapsule.h +58 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyconfig.h +2088 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pydtrace.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyerrors.h +335 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyexpat.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyframe.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyhash.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pylifecycle.h +80 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymacconfig.h +91 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymacro.h +243 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymath.h +65 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymem.h +110 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyport.h +710 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystate.h +132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystats.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystrcmp.h +23 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystrtod.h +37 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pythonrun.h +42 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pythread.h +131 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pytypedefs.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/rangeobject.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/refcount.h +555 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/setobject.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/sliceobject.h +69 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/structmember.h +56 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/structseq.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/sysmodule.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/traceback.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/tupleobject.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/typeslots.h +96 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/unicodeobject.h +1029 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/warnings.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/weakrefobject.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/pytron_bridge.cpp +224 -0
- pytron/platforms/android/shell/app/src/main/java/com/pytron/shell/MainActivity.kt +208 -0
- pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- pytron/platforms/android/shell/build.gradle +11 -0
- pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.jar +0 -0
- pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.properties +5 -0
- pytron/platforms/android/shell/gradle.properties +2 -0
- pytron/platforms/android/shell/gradlew.bat +85 -0
- pytron/platforms/android/shell/settings.gradle +16 -0
- pytron/platforms/darwin.py +82 -0
- pytron/platforms/darwin_ops/libs.py +31 -0
- pytron/platforms/darwin_ops/system.py +182 -0
- pytron/platforms/darwin_ops/utils.py +85 -0
- pytron/platforms/darwin_ops/webview.py +5 -0
- pytron/platforms/darwin_ops/window.py +102 -0
- pytron/platforms/interface.py +152 -0
- pytron/platforms/linux.py +82 -0
- pytron/platforms/linux_ops/libs.py +49 -0
- pytron/platforms/linux_ops/system.py +316 -0
- pytron/platforms/linux_ops/utils.py +19 -0
- pytron/platforms/linux_ops/webview.py +5 -0
- pytron/platforms/linux_ops/window.py +115 -0
- pytron/platforms/windows.py +136 -0
- pytron/platforms/windows_ops/__init__.py +0 -0
- pytron/platforms/windows_ops/constants.py +126 -0
- pytron/platforms/windows_ops/system.py +518 -0
- pytron/platforms/windows_ops/utils.py +3 -0
- pytron/platforms/windows_ops/webview.py +5 -0
- pytron/platforms/windows_ops/window.py +361 -0
- pytron/plugin.py +467 -0
- pytron/rcedit-x64.exe +0 -0
- pytron/router.py +146 -0
- pytron/serializer.py +240 -0
- pytron/shortcuts.py +279 -0
- pytron/state.py +76 -0
- pytron/tray.py +399 -0
- pytron/updater.py +181 -0
- pytron/utf8_hook.py +112 -0
- pytron/utils.py +44 -0
- pytron/webview.py +722 -0
- pytron_kit-0.3.12.dist-info/METADATA +131 -0
- pytron_kit-0.3.12.dist-info/RECORD +419 -0
- pytron_kit-0.3.12.dist-info/WHEEL +5 -0
- pytron_kit-0.3.12.dist-info/entry_points.txt +2 -0
- pytron_kit-0.3.12.dist-info/licenses/LICENSE +201 -0
- pytron_kit-0.3.12.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import json
|
|
4
|
+
import logging
|
|
5
|
+
import threading
|
|
6
|
+
import subprocess
|
|
7
|
+
import struct
|
|
8
|
+
import tempfile
|
|
9
|
+
import platform
|
|
10
|
+
import uuid
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger("Pytron.ChromeIPC")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ChromeIPCServer:
|
|
16
|
+
"""
|
|
17
|
+
A robust Named Pipe server for Windows (or UDS for Unix).
|
|
18
|
+
Uses length-prefixed binary framing (Mojo-style) for maximum reliability.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, pipe_name):
|
|
22
|
+
self.pipe_name = pipe_name
|
|
23
|
+
self.handle = None
|
|
24
|
+
self.connected = False
|
|
25
|
+
self._lock = threading.Lock()
|
|
26
|
+
|
|
27
|
+
def listen(self):
|
|
28
|
+
if platform.system() == "Windows":
|
|
29
|
+
import ctypes
|
|
30
|
+
from ctypes import windll
|
|
31
|
+
|
|
32
|
+
# Constants
|
|
33
|
+
PIPE_ACCESS_DUPLEX = 0x00000003
|
|
34
|
+
PIPE_TYPE_BYTE = 0x00000000
|
|
35
|
+
PIPE_READMODE_BYTE = 0x00000000
|
|
36
|
+
PIPE_WAIT = 0x00000000
|
|
37
|
+
PIPE_UNLIMITED_INSTANCES = 255
|
|
38
|
+
|
|
39
|
+
self.handle = windll.kernel32.CreateNamedPipeW(
|
|
40
|
+
f"\\\\.\\pipe\\{self.pipe_name}",
|
|
41
|
+
PIPE_ACCESS_DUPLEX,
|
|
42
|
+
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
|
|
43
|
+
PIPE_UNLIMITED_INSTANCES,
|
|
44
|
+
1024 * 1024,
|
|
45
|
+
1024 * 1024, # 1MB buffers
|
|
46
|
+
0,
|
|
47
|
+
None,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if self.handle == -1:
|
|
51
|
+
raise Exception(f"Failed to create Named Pipe: {ctypes.GetLastError()}")
|
|
52
|
+
|
|
53
|
+
logger.debug(f"Mojo Pipe created: {self.pipe_name}")
|
|
54
|
+
|
|
55
|
+
# Blocking Connect
|
|
56
|
+
connected = windll.kernel32.ConnectNamedPipe(self.handle, None)
|
|
57
|
+
if (
|
|
58
|
+
not connected and windll.kernel32.GetLastError() != 535
|
|
59
|
+
): # ERROR_PIPE_CONNECTED
|
|
60
|
+
raise Exception(f"Failed to connect pipe: {ctypes.GetLastError()}")
|
|
61
|
+
|
|
62
|
+
self.connected = True
|
|
63
|
+
logger.debug("Chrome Shell established Mojo connection.")
|
|
64
|
+
|
|
65
|
+
else:
|
|
66
|
+
import socket
|
|
67
|
+
|
|
68
|
+
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
69
|
+
sock_path = os.path.join(tempfile.gettempdir(), self.pipe_name)
|
|
70
|
+
if os.path.exists(sock_path):
|
|
71
|
+
os.remove(sock_path)
|
|
72
|
+
self.sock.bind(sock_path)
|
|
73
|
+
self.sock.listen(1)
|
|
74
|
+
self.conn, _ = self.sock.accept()
|
|
75
|
+
self.connected = True
|
|
76
|
+
|
|
77
|
+
def read_loop(self, callback):
|
|
78
|
+
"""Reads length-prefixed messages."""
|
|
79
|
+
|
|
80
|
+
while self.connected:
|
|
81
|
+
try:
|
|
82
|
+
# 1. Read 4-byte Header (Length)
|
|
83
|
+
header = self._raw_read(4)
|
|
84
|
+
if not header or len(header) < 4:
|
|
85
|
+
break
|
|
86
|
+
|
|
87
|
+
msg_len = struct.unpack("<I", header)[0]
|
|
88
|
+
|
|
89
|
+
# 2. Read Body
|
|
90
|
+
body = self._raw_read(msg_len)
|
|
91
|
+
if not body:
|
|
92
|
+
break
|
|
93
|
+
|
|
94
|
+
# 3. Dispatch
|
|
95
|
+
msg = json.loads(body.decode("utf-8"))
|
|
96
|
+
callback(msg)
|
|
97
|
+
|
|
98
|
+
except Exception as e:
|
|
99
|
+
logger.error(f"IPC Read Error: {e}")
|
|
100
|
+
break
|
|
101
|
+
|
|
102
|
+
self.connected = False
|
|
103
|
+
|
|
104
|
+
def _raw_read(self, n):
|
|
105
|
+
from ctypes import windll, byref, c_ulong, create_string_buffer
|
|
106
|
+
|
|
107
|
+
if platform.system() == "Windows":
|
|
108
|
+
buf = create_string_buffer(n)
|
|
109
|
+
bytes_read = c_ulong(0)
|
|
110
|
+
success = windll.kernel32.ReadFile(
|
|
111
|
+
self.handle, buf, n, byref(bytes_read), None
|
|
112
|
+
)
|
|
113
|
+
if not success or bytes_read.value == 0:
|
|
114
|
+
return None
|
|
115
|
+
return buf.raw[: bytes_read.value]
|
|
116
|
+
else:
|
|
117
|
+
return self.conn.recv(n)
|
|
118
|
+
|
|
119
|
+
def send(self, data_dict):
|
|
120
|
+
"""Sends a length-prefixed JSON message."""
|
|
121
|
+
with self._lock:
|
|
122
|
+
body = json.dumps(data_dict).encode("utf-8")
|
|
123
|
+
header = struct.pack("<I", len(body))
|
|
124
|
+
full_msg = header + body
|
|
125
|
+
|
|
126
|
+
if platform.system() == "Windows":
|
|
127
|
+
from ctypes import windll, byref, c_ulong
|
|
128
|
+
|
|
129
|
+
bytes_written = c_ulong(0)
|
|
130
|
+
windll.kernel32.WriteFile(
|
|
131
|
+
self.handle, full_msg, len(full_msg), byref(bytes_written), None
|
|
132
|
+
)
|
|
133
|
+
windll.kernel32.FlushFileBuffers(self.handle)
|
|
134
|
+
else:
|
|
135
|
+
self.conn.sendall(full_msg)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class ChromeAdapter:
|
|
139
|
+
def __init__(self, binary_path, config=None):
|
|
140
|
+
self.binary_path = binary_path
|
|
141
|
+
self.config = config or {}
|
|
142
|
+
self.process = None
|
|
143
|
+
self.ipc = None
|
|
144
|
+
self.ready = False
|
|
145
|
+
self.pipe_name = f"pytron-mojo-{uuid.uuid4().hex[:8]}"
|
|
146
|
+
self._raw_callback = None
|
|
147
|
+
|
|
148
|
+
def start(self):
|
|
149
|
+
self.ipc = ChromeIPCServer(self.pipe_name)
|
|
150
|
+
|
|
151
|
+
def _server_thread():
|
|
152
|
+
self.ipc.listen()
|
|
153
|
+
self.ipc.read_loop(self._on_message)
|
|
154
|
+
|
|
155
|
+
threading.Thread(target=_server_thread, daemon=True).start()
|
|
156
|
+
|
|
157
|
+
# Launch Shell
|
|
158
|
+
full_pipe_path = (
|
|
159
|
+
f"\\\\.\\pipe\\{self.pipe_name}"
|
|
160
|
+
if platform.system() == "Windows"
|
|
161
|
+
else os.path.join(tempfile.gettempdir(), self.pipe_name)
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
cmd = [self.binary_path, f"--pytron-pipe={full_pipe_path}"]
|
|
165
|
+
|
|
166
|
+
# Pass configuration flags to the shell process
|
|
167
|
+
if self.config.get("debug"):
|
|
168
|
+
cmd.append("--debug")
|
|
169
|
+
|
|
170
|
+
if self.config.get("frameless"):
|
|
171
|
+
cmd.append("--frameless")
|
|
172
|
+
|
|
173
|
+
if self.config.get("transparent"):
|
|
174
|
+
cmd.append("--transparent")
|
|
175
|
+
|
|
176
|
+
# Pass initial dimensions
|
|
177
|
+
dims = self.config.get("dimensions")
|
|
178
|
+
if dims and len(dims) == 2:
|
|
179
|
+
cmd.append(f"--width={dims[0]}")
|
|
180
|
+
cmd.append(f"--height={dims[1]}")
|
|
181
|
+
|
|
182
|
+
logger.info(f"Launching Chrome Shell: {cmd}")
|
|
183
|
+
|
|
184
|
+
self.process = subprocess.Popen(
|
|
185
|
+
cmd,
|
|
186
|
+
stdout=sys.stdout,
|
|
187
|
+
stderr=sys.stderr,
|
|
188
|
+
cwd=os.path.dirname(self.binary_path),
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
def _on_message(self, msg):
|
|
192
|
+
if msg.get("type") == "lifecycle" and msg.get("payload") == "app_ready":
|
|
193
|
+
self.ready = True
|
|
194
|
+
|
|
195
|
+
if self._raw_callback:
|
|
196
|
+
self._raw_callback(msg)
|
|
197
|
+
|
|
198
|
+
def send(self, payload):
|
|
199
|
+
if self.ipc and self.ipc.connected:
|
|
200
|
+
self.ipc.send(payload)
|
|
201
|
+
|
|
202
|
+
def bind_raw(self, callback):
|
|
203
|
+
self._raw_callback = callback
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import inspect
|
|
3
|
+
import typing
|
|
4
|
+
from ..webview import Webview
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
import pydantic
|
|
8
|
+
except ImportError:
|
|
9
|
+
pydantic = None
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CodegenMixin:
|
|
13
|
+
"""
|
|
14
|
+
Mixin class to handle TypeScript generation.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def generate_types(self, output_path="frontend/src/pytron.d.ts"):
|
|
18
|
+
"""
|
|
19
|
+
Generates TypeScript definitions for all exposed functions.
|
|
20
|
+
"""
|
|
21
|
+
ts_lines = [
|
|
22
|
+
"// Auto-generated by Pytron. Do not edit manually.",
|
|
23
|
+
"// This file provides type definitions for the Pytron client.",
|
|
24
|
+
"",
|
|
25
|
+
"declare module 'pytron-client' {",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
# 0. Add Pydantic Interfaces
|
|
29
|
+
processed_models = set()
|
|
30
|
+
while True:
|
|
31
|
+
current_models = set(self._pydantic_models.keys())
|
|
32
|
+
new_models = current_models - processed_models
|
|
33
|
+
if not new_models:
|
|
34
|
+
break
|
|
35
|
+
|
|
36
|
+
for model_name in new_models:
|
|
37
|
+
model_cls = self._pydantic_models[model_name]
|
|
38
|
+
ts_lines.append(
|
|
39
|
+
self._generate_pydantic_interface(model_name, model_cls)
|
|
40
|
+
)
|
|
41
|
+
processed_models.add(model_name)
|
|
42
|
+
|
|
43
|
+
ts_lines.append("")
|
|
44
|
+
ts_lines.append(" export interface PytronClient {")
|
|
45
|
+
ts_lines.append(" /**")
|
|
46
|
+
ts_lines.append(" * Local state cache synchronized with the backend.")
|
|
47
|
+
ts_lines.append(" */")
|
|
48
|
+
ts_lines.append(" state: Record<string, any>;")
|
|
49
|
+
ts_lines.append("")
|
|
50
|
+
ts_lines.append(" /**")
|
|
51
|
+
ts_lines.append(" * Listen for an event sent from the Python backend.")
|
|
52
|
+
ts_lines.append(" */")
|
|
53
|
+
ts_lines.append(" on(event: string, callback: (data: any) => void): void;")
|
|
54
|
+
ts_lines.append("")
|
|
55
|
+
ts_lines.append(" /**")
|
|
56
|
+
ts_lines.append(" * Remove an event listener.")
|
|
57
|
+
ts_lines.append(" */")
|
|
58
|
+
ts_lines.append(" off(event: string, callback: (data: any) => void): void;")
|
|
59
|
+
ts_lines.append("")
|
|
60
|
+
ts_lines.append(" /**")
|
|
61
|
+
ts_lines.append(" * Wait for the backend to be connected.")
|
|
62
|
+
ts_lines.append(" */")
|
|
63
|
+
ts_lines.append(" waitForBackend(timeout?: number): Promise<void>;")
|
|
64
|
+
ts_lines.append("")
|
|
65
|
+
ts_lines.append(" /**")
|
|
66
|
+
ts_lines.append(" * Log a message to the Python console.")
|
|
67
|
+
ts_lines.append(" */")
|
|
68
|
+
ts_lines.append(" log(message: string): Promise<void>;")
|
|
69
|
+
ts_lines.append("")
|
|
70
|
+
|
|
71
|
+
# 1. Add User Exposed Functions (pre-calculated in expose)
|
|
72
|
+
for def_str in self._exposed_ts_defs.values():
|
|
73
|
+
ts_lines.append(def_str)
|
|
74
|
+
|
|
75
|
+
# 3. Add Window methods
|
|
76
|
+
# Map exposed name to Window class method name
|
|
77
|
+
win_map = {
|
|
78
|
+
"minimize": "minimize",
|
|
79
|
+
"toggle_maximize": "toggle_maximize",
|
|
80
|
+
"close": "close",
|
|
81
|
+
"hide": "hide",
|
|
82
|
+
"show": "show",
|
|
83
|
+
"notify": "notify",
|
|
84
|
+
"start_drag": "start_drag",
|
|
85
|
+
"set_title": "set_title",
|
|
86
|
+
"set_size": "set_size",
|
|
87
|
+
"center": "center",
|
|
88
|
+
"system_notification": "system_notification",
|
|
89
|
+
"set_bounds": "set_bounds",
|
|
90
|
+
}
|
|
91
|
+
for exposed_name, method_name in win_map.items():
|
|
92
|
+
method = getattr(Webview, method_name, None)
|
|
93
|
+
if method:
|
|
94
|
+
ts_lines.append(self._get_ts_definition(exposed_name, method))
|
|
95
|
+
# 4. Add dynamic methods that are not on Window class
|
|
96
|
+
ts_lines.append(" trigger_shortcut(combo: string): Promise<boolean>;")
|
|
97
|
+
ts_lines.append(" get_registered_shortcuts(): Promise<string[]>;")
|
|
98
|
+
|
|
99
|
+
ts_lines.append(" }")
|
|
100
|
+
ts_lines.append("")
|
|
101
|
+
ts_lines.append(" const pytron: PytronClient;")
|
|
102
|
+
ts_lines.append(" export default pytron;")
|
|
103
|
+
ts_lines.append("}")
|
|
104
|
+
|
|
105
|
+
# Ensure directory exists
|
|
106
|
+
dirname = os.path.dirname(output_path)
|
|
107
|
+
if dirname and not os.path.exists(dirname):
|
|
108
|
+
try:
|
|
109
|
+
os.makedirs(dirname)
|
|
110
|
+
except Exception as e:
|
|
111
|
+
self.logger.error(
|
|
112
|
+
f"Failed to create directory for typescript definitions: {e}"
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
with open(output_path, "w") as f:
|
|
117
|
+
f.write("\n".join(ts_lines))
|
|
118
|
+
self.logger.info(f"Generated TypeScript definitions at {output_path}")
|
|
119
|
+
except Exception as e:
|
|
120
|
+
self.logger.error(f"Failed to write TypeScript definitions: {e}")
|
|
121
|
+
|
|
122
|
+
def _get_ts_definition(self, name, func):
|
|
123
|
+
"""
|
|
124
|
+
Generate TypeScript definition for a given function.
|
|
125
|
+
"""
|
|
126
|
+
try:
|
|
127
|
+
sig = inspect.signature(func)
|
|
128
|
+
params = []
|
|
129
|
+
|
|
130
|
+
for param_name, param in sig.parameters.items():
|
|
131
|
+
if param_name == "self":
|
|
132
|
+
continue
|
|
133
|
+
|
|
134
|
+
py_type = param.annotation
|
|
135
|
+
ts_type = self._python_type_to_ts(py_type)
|
|
136
|
+
if py_type == inspect.Parameter.empty:
|
|
137
|
+
ts_type = "any"
|
|
138
|
+
|
|
139
|
+
params.append(f"{param_name}: {ts_type}")
|
|
140
|
+
|
|
141
|
+
param_str = ", ".join(params)
|
|
142
|
+
|
|
143
|
+
return_annotation = sig.return_annotation
|
|
144
|
+
ts_return = self._python_type_to_ts(return_annotation)
|
|
145
|
+
if return_annotation == inspect.Parameter.empty:
|
|
146
|
+
ts_return = "any"
|
|
147
|
+
|
|
148
|
+
lines = []
|
|
149
|
+
doc = inspect.getdoc(func)
|
|
150
|
+
if doc:
|
|
151
|
+
lines.append(" /**")
|
|
152
|
+
for line in doc.split("\n"):
|
|
153
|
+
lines.append(f" * {line}")
|
|
154
|
+
lines.append(" */")
|
|
155
|
+
|
|
156
|
+
lines.append(f" {name}({param_str}): Promise<{ts_return}>;")
|
|
157
|
+
return "\n".join(lines)
|
|
158
|
+
|
|
159
|
+
except Exception as e:
|
|
160
|
+
self.logger.warning(f"Could not generate types for {name}: {e}")
|
|
161
|
+
return f" {name}(...args: any[]): Promise<any>;"
|
|
162
|
+
|
|
163
|
+
def _generate_pydantic_interface(self, model_name, model_cls):
|
|
164
|
+
"""
|
|
165
|
+
Generate TypeScript interface for a Pydantic model.
|
|
166
|
+
"""
|
|
167
|
+
lines = [f" export interface {model_name} {{"]
|
|
168
|
+
|
|
169
|
+
# Pydantic v1 vs v2
|
|
170
|
+
fields = {}
|
|
171
|
+
if hasattr(model_cls, "model_fields"): # v2
|
|
172
|
+
fields = model_cls.model_fields
|
|
173
|
+
elif hasattr(model_cls, "__fields__"): # v1
|
|
174
|
+
fields = model_cls.__fields__
|
|
175
|
+
|
|
176
|
+
for field_name, field in fields.items():
|
|
177
|
+
# Get type annotation
|
|
178
|
+
if hasattr(field, "annotation"): # v2
|
|
179
|
+
py_type = field.annotation
|
|
180
|
+
elif hasattr(field, "type_"): # v1
|
|
181
|
+
py_type = field.type_
|
|
182
|
+
else:
|
|
183
|
+
py_type = typing.Any
|
|
184
|
+
|
|
185
|
+
ts_type = self._python_type_to_ts(py_type)
|
|
186
|
+
|
|
187
|
+
# Check if optional
|
|
188
|
+
is_optional = False
|
|
189
|
+
if hasattr(field, "is_required"): # v2
|
|
190
|
+
is_optional = not field.is_required()
|
|
191
|
+
elif hasattr(field, "required"): # v1
|
|
192
|
+
is_optional = not field.required
|
|
193
|
+
|
|
194
|
+
suffix = "?" if is_optional else ""
|
|
195
|
+
lines.append(f" {field_name}{suffix}: {ts_type};")
|
|
196
|
+
|
|
197
|
+
lines.append(" }")
|
|
198
|
+
return "\n".join(lines)
|
|
199
|
+
|
|
200
|
+
def _python_type_to_ts(self, py_type):
|
|
201
|
+
if py_type == str:
|
|
202
|
+
return "string"
|
|
203
|
+
if py_type == int:
|
|
204
|
+
return "number"
|
|
205
|
+
if py_type == float:
|
|
206
|
+
return "number"
|
|
207
|
+
if py_type == bool:
|
|
208
|
+
return "boolean"
|
|
209
|
+
if py_type == type(None):
|
|
210
|
+
return "void"
|
|
211
|
+
if py_type == list:
|
|
212
|
+
return "any[]"
|
|
213
|
+
if py_type == dict:
|
|
214
|
+
return "Record<string, any>"
|
|
215
|
+
|
|
216
|
+
# Handle Pydantic Models
|
|
217
|
+
if (
|
|
218
|
+
pydantic
|
|
219
|
+
and isinstance(py_type, type)
|
|
220
|
+
and issubclass(py_type, pydantic.BaseModel)
|
|
221
|
+
):
|
|
222
|
+
model_name = py_type.__name__
|
|
223
|
+
self._pydantic_models[model_name] = py_type
|
|
224
|
+
return model_name
|
|
225
|
+
|
|
226
|
+
# Handle typing module
|
|
227
|
+
origin = getattr(py_type, "__origin__", None)
|
|
228
|
+
args = getattr(py_type, "__args__", ())
|
|
229
|
+
|
|
230
|
+
if origin is list or origin is typing.List:
|
|
231
|
+
if args:
|
|
232
|
+
return f"{self._python_type_to_ts(args[0])}[]"
|
|
233
|
+
return "any[]"
|
|
234
|
+
|
|
235
|
+
if origin is dict or origin is typing.Dict:
|
|
236
|
+
if args and len(args) == 2:
|
|
237
|
+
k = self._python_type_to_ts(args[0])
|
|
238
|
+
v = self._python_type_to_ts(args[1])
|
|
239
|
+
if k == "number":
|
|
240
|
+
return f"Record<number, {v}>"
|
|
241
|
+
return f"Record<string, {v}>"
|
|
242
|
+
return "Record<string, any>"
|
|
243
|
+
|
|
244
|
+
if origin is typing.Union:
|
|
245
|
+
non_none = [t for t in args if t != type(None)]
|
|
246
|
+
# Check for pydantic models inside Union
|
|
247
|
+
if pydantic:
|
|
248
|
+
for t in non_none:
|
|
249
|
+
if isinstance(t, type) and issubclass(t, pydantic.BaseModel):
|
|
250
|
+
self._pydantic_models[t.__name__] = t
|
|
251
|
+
|
|
252
|
+
if len(non_none) == len(args):
|
|
253
|
+
return " | ".join([self._python_type_to_ts(t) for t in args])
|
|
254
|
+
else:
|
|
255
|
+
if len(non_none) == 1:
|
|
256
|
+
return f"{self._python_type_to_ts(non_none[0])} | null"
|
|
257
|
+
return (
|
|
258
|
+
" | ".join([self._python_type_to_ts(t) for t in non_none])
|
|
259
|
+
+ " | null"
|
|
260
|
+
)
|
|
261
|
+
return "any"
|