pytron-kit 0.3.12__py3-none-macosx_11_0_universal2.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.
Files changed (419) hide show
  1. pytron/__init__.py +112 -0
  2. pytron/application.py +562 -0
  3. pytron/apputils/__init__.py +0 -0
  4. pytron/apputils/chrome_ipc.py +203 -0
  5. pytron/apputils/codegen.py +261 -0
  6. pytron/apputils/config.py +303 -0
  7. pytron/apputils/deadmansswitch.py +47 -0
  8. pytron/apputils/extras.py +76 -0
  9. pytron/apputils/native.py +148 -0
  10. pytron/apputils/shell.py +73 -0
  11. pytron/apputils/windows.py +286 -0
  12. pytron/cli.py +384 -0
  13. pytron/commands/__init__.py +0 -0
  14. pytron/commands/android.py +28 -0
  15. pytron/commands/build.py +26 -0
  16. pytron/commands/doctor.py +221 -0
  17. pytron/commands/engine.py +23 -0
  18. pytron/commands/frontend.py +60 -0
  19. pytron/commands/harvest.py +112 -0
  20. pytron/commands/helpers.py +239 -0
  21. pytron/commands/info.py +50 -0
  22. pytron/commands/init.py +521 -0
  23. pytron/commands/install.py +294 -0
  24. pytron/commands/login.py +130 -0
  25. pytron/commands/package.py +228 -0
  26. pytron/commands/plugin.py +442 -0
  27. pytron/commands/run.py +312 -0
  28. pytron/commands/scan.py +210 -0
  29. pytron/commands/show.py +23 -0
  30. pytron/commands/uninstall.py +150 -0
  31. pytron/commands/utils.py +42 -0
  32. pytron/commands/workflow.py +95 -0
  33. pytron/console.py +133 -0
  34. pytron/core.py +18 -0
  35. pytron/dependencies/WebView2Loader.dll +0 -0
  36. pytron/dependencies/__init__.py +1 -0
  37. pytron/dependencies/pytron_native.so +0 -0
  38. pytron/engines/chrome/adapter.py +445 -0
  39. pytron/engines/chrome/engine.py +576 -0
  40. pytron/engines/chrome/forge.py +147 -0
  41. pytron/engines/chrome/shell/package.json +8 -0
  42. pytron/engines/chrome/shell/preload.js +12 -0
  43. pytron/engines/chrome/shell/shell.js +534 -0
  44. pytron/exceptions.py +36 -0
  45. pytron/inspector.py +201 -0
  46. pytron/inspector_ui.py +512 -0
  47. pytron/installer/Installation.nsi +236 -0
  48. pytron/installer/header.bmp +0 -0
  49. pytron/installer/pytron.ico +0 -0
  50. pytron/installer/sidebar.bmp +0 -0
  51. pytron/llms.md +98 -0
  52. pytron/manifests/README.md +29 -0
  53. pytron/manifests/windows-utf8.manifest +44 -0
  54. pytron/menu.py +128 -0
  55. pytron/nsis-setup.exe +0 -0
  56. pytron/pack/__init__.py +0 -0
  57. pytron/pack/assets.py +131 -0
  58. pytron/pack/compilers.py +289 -0
  59. pytron/pack/crystal.py +297 -0
  60. pytron/pack/graph.py +377 -0
  61. pytron/pack/inference.py +157 -0
  62. pytron/pack/installers.py +402 -0
  63. pytron/pack/introspect.py +357 -0
  64. pytron/pack/metadata.py +213 -0
  65. pytron/pack/modules.py +618 -0
  66. pytron/pack/nuitka.py +108 -0
  67. pytron/pack/pipeline.py +107 -0
  68. pytron/pack/pyinstaller.py +176 -0
  69. pytron/pack/rust_engine.py +273 -0
  70. pytron/pack/secure.py +309 -0
  71. pytron/pack/secure_loader/bin/pytron_rust_bootloader +0 -0
  72. pytron/pack/secure_loader/icon.ico +0 -0
  73. pytron/pack/utils.py +110 -0
  74. pytron/pack/virtual_root.py +124 -0
  75. pytron/platforms/__init__.py +0 -0
  76. pytron/platforms/android/__init__.py +3 -0
  77. pytron/platforms/android/android.py +103 -0
  78. pytron/platforms/android/builder.py +736 -0
  79. pytron/platforms/android/ops/build.py +79 -0
  80. pytron/platforms/android/ops/init.py +63 -0
  81. pytron/platforms/android/ops/run.py +79 -0
  82. pytron/platforms/android/ops/sync.py +770 -0
  83. pytron/platforms/android/ops/utils.py +8 -0
  84. pytron/platforms/android/shell/README.md +30 -0
  85. pytron/platforms/android/shell/app/build.gradle +64 -0
  86. pytron/platforms/android/shell/app/src/main/AndroidManifest.xml +29 -0
  87. pytron/platforms/android/shell/app/src/main/assets/python/main.py +86 -0
  88. pytron/platforms/android/shell/app/src/main/assets/python/python314.zip +0 -0
  89. pytron/platforms/android/shell/app/src/main/cpp/CMakeLists.txt +25 -0
  90. pytron/platforms/android/shell/app/src/main/cpp/include/Python.h +155 -0
  91. pytron/platforms/android/shell/app/src/main/cpp/include/abstract.h +915 -0
  92. pytron/platforms/android/shell/app/src/main/cpp/include/audit.h +30 -0
  93. pytron/platforms/android/shell/app/src/main/cpp/include/bltinmodule.h +14 -0
  94. pytron/platforms/android/shell/app/src/main/cpp/include/boolobject.h +54 -0
  95. pytron/platforms/android/shell/app/src/main/cpp/include/bytearrayobject.h +44 -0
  96. pytron/platforms/android/shell/app/src/main/cpp/include/bytesobject.h +66 -0
  97. pytron/platforms/android/shell/app/src/main/cpp/include/ceval.h +145 -0
  98. pytron/platforms/android/shell/app/src/main/cpp/include/codecs.h +176 -0
  99. pytron/platforms/android/shell/app/src/main/cpp/include/compile.h +22 -0
  100. pytron/platforms/android/shell/app/src/main/cpp/include/complexobject.h +30 -0
  101. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/abstract.h +104 -0
  102. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/audit.h +8 -0
  103. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytearrayobject.h +38 -0
  104. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytesobject.h +42 -0
  105. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/cellobject.h +50 -0
  106. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/ceval.h +43 -0
  107. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/classobject.h +71 -0
  108. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/code.h +340 -0
  109. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/compile.h +50 -0
  110. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/complexobject.h +33 -0
  111. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/context.h +107 -0
  112. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/critical_section.h +154 -0
  113. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/descrobject.h +62 -0
  114. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/dictobject.h +105 -0
  115. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileobject.h +16 -0
  116. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileutils.h +16 -0
  117. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/floatobject.h +27 -0
  118. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/frameobject.h +35 -0
  119. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/funcobject.h +185 -0
  120. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/genobject.h +56 -0
  121. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/import.h +30 -0
  122. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/initconfig.h +334 -0
  123. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/listobject.h +53 -0
  124. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/lock.h +74 -0
  125. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longintrepr.h +184 -0
  126. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longobject.h +89 -0
  127. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/memoryobject.h +50 -0
  128. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/methodobject.h +66 -0
  129. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/modsupport.h +26 -0
  130. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/monitoring.h +269 -0
  131. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/object.h +493 -0
  132. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/objimpl.h +104 -0
  133. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/odictobject.h +43 -0
  134. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/picklebufobject.h +31 -0
  135. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pthread_stubs.h +105 -0
  136. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic.h +614 -0
  137. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_gcc.h +615 -0
  138. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_msc.h +1197 -0
  139. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_std.h +1112 -0
  140. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyctype.h +39 -0
  141. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pydebug.h +38 -0
  142. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyerrors.h +132 -0
  143. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyfpe.h +15 -0
  144. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyframe.h +45 -0
  145. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyhash.h +54 -0
  146. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pylifecycle.h +89 -0
  147. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pymem.h +84 -0
  148. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystate.h +275 -0
  149. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystats.h +194 -0
  150. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythonrun.h +96 -0
  151. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythread.h +43 -0
  152. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pytime.h +27 -0
  153. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/setobject.h +71 -0
  154. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/traceback.h +13 -0
  155. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tracemalloc.h +32 -0
  156. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tupleobject.h +40 -0
  157. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/unicodeobject.h +773 -0
  158. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/warnings.h +20 -0
  159. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/weakrefobject.h +66 -0
  160. pytron/platforms/android/shell/app/src/main/cpp/include/critical_section.h +16 -0
  161. pytron/platforms/android/shell/app/src/main/cpp/include/datetime.h +267 -0
  162. pytron/platforms/android/shell/app/src/main/cpp/include/descrobject.h +100 -0
  163. pytron/platforms/android/shell/app/src/main/cpp/include/dictobject.h +108 -0
  164. pytron/platforms/android/shell/app/src/main/cpp/include/dynamic_annotations.h +499 -0
  165. pytron/platforms/android/shell/app/src/main/cpp/include/enumobject.h +17 -0
  166. pytron/platforms/android/shell/app/src/main/cpp/include/errcode.h +45 -0
  167. pytron/platforms/android/shell/app/src/main/cpp/include/exports.h +105 -0
  168. pytron/platforms/android/shell/app/src/main/cpp/include/fileobject.h +41 -0
  169. pytron/platforms/android/shell/app/src/main/cpp/include/fileutils.h +62 -0
  170. pytron/platforms/android/shell/app/src/main/cpp/include/floatobject.h +54 -0
  171. pytron/platforms/android/shell/app/src/main/cpp/include/frameobject.h +20 -0
  172. pytron/platforms/android/shell/app/src/main/cpp/include/genericaliasobject.h +14 -0
  173. pytron/platforms/android/shell/app/src/main/cpp/include/import.h +103 -0
  174. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/atomic.h +392 -0
  175. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/internal.h +969 -0
  176. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/prim.h +329 -0
  177. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/track.h +147 -0
  178. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/types.h +721 -0
  179. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc.h +565 -0
  180. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_abstract.h +61 -0
  181. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_asdl.h +112 -0
  182. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast.h +945 -0
  183. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast_state.h +271 -0
  184. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_atexit.h +31 -0
  185. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_audit.h +35 -0
  186. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_backoff.h +133 -0
  187. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bitutils.h +186 -0
  188. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_blocks_output_buffer.h +321 -0
  189. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_brc.h +73 -0
  190. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytes_methods.h +82 -0
  191. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytesobject.h +149 -0
  192. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_c_array.h +39 -0
  193. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_call.h +206 -0
  194. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_capsule.h +17 -0
  195. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_cell.h +75 -0
  196. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval.h +390 -0
  197. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval_state.h +48 -0
  198. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_code.h +671 -0
  199. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_codecs.h +76 -0
  200. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_compile.h +230 -0
  201. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_complexobject.h +34 -0
  202. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_condvar.h +93 -0
  203. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_context.h +59 -0
  204. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_critical_section.h +237 -0
  205. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp.h +406 -0
  206. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp_data_registry.h +41 -0
  207. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_debug_offsets.h +379 -0
  208. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_descrobject.h +28 -0
  209. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict.h +410 -0
  210. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict_state.h +28 -0
  211. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dtoa.h +40 -0
  212. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_signal.h +30 -0
  213. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_trampoline.h +70 -0
  214. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_exceptions.h +40 -0
  215. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_faulthandler.h +100 -0
  216. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils.h +320 -0
  217. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils_windows.h +98 -0
  218. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_floatobject.h +49 -0
  219. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_flowgraph.h +47 -0
  220. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_format.h +27 -0
  221. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_frame.h +61 -0
  222. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist.h +111 -0
  223. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist_state.h +70 -0
  224. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_function.h +53 -0
  225. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gc.h +378 -0
  226. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_genobject.h +43 -0
  227. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_getopt.h +22 -0
  228. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gil.h +66 -0
  229. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects.h +34 -0
  230. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects_fini_generated.h +1592 -0
  231. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_strings.h +854 -0
  232. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hamt.h +113 -0
  233. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hashtable.h +150 -0
  234. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_import.h +141 -0
  235. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_importdl.h +139 -0
  236. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_index_pool.h +36 -0
  237. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_initconfig.h +197 -0
  238. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruction_sequence.h +83 -0
  239. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruments.h +127 -0
  240. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp.h +109 -0
  241. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp_structs.h +977 -0
  242. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe.h +401 -0
  243. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe_structs.h +95 -0
  244. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpolation.h +26 -0
  245. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_intrinsics.h +51 -0
  246. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_jit.h +29 -0
  247. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_list.h +81 -0
  248. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_llist.h +106 -0
  249. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_lock.h +236 -0
  250. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_long.h +319 -0
  251. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_magic_number.h +305 -0
  252. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_memoryobject.h +20 -0
  253. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_mimalloc.h +69 -0
  254. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_modsupport.h +99 -0
  255. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_moduleobject.h +62 -0
  256. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_namespace.h +21 -0
  257. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object.h +1029 -0
  258. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_alloc.h +71 -0
  259. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_deferred.h +32 -0
  260. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_stack.h +95 -0
  261. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_state.h +49 -0
  262. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc.h +702 -0
  263. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc_init.h +66 -0
  264. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_metadata.h +2117 -0
  265. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_utils.h +90 -0
  266. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_optimizer.h +318 -0
  267. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parking_lot.h +97 -0
  268. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parser.h +78 -0
  269. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pathconfig.h +26 -0
  270. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyarena.h +68 -0
  271. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyatomic_ft_wrappers.h +174 -0
  272. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pybuffer.h +21 -0
  273. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyerrors.h +213 -0
  274. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyhash.h +91 -0
  275. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pylifecycle.h +136 -0
  276. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymath.h +205 -0
  277. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem.h +145 -0
  278. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem_init.h +103 -0
  279. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystate.h +339 -0
  280. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystats.h +21 -0
  281. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythonrun.h +68 -0
  282. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythread.h +172 -0
  283. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_qsbr.h +172 -0
  284. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_range.h +21 -0
  285. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime.h +63 -0
  286. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init.h +239 -0
  287. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init_generated.h +1589 -0
  288. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_structs.h +310 -0
  289. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_semaphore.h +67 -0
  290. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_setobject.h +41 -0
  291. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_signal.h +108 -0
  292. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sliceobject.h +20 -0
  293. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stackref.h +791 -0
  294. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stats.h +97 -0
  295. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_strhex.h +39 -0
  296. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structs.h +88 -0
  297. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structseq.h +40 -0
  298. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_symtable.h +201 -0
  299. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sysmodule.h +32 -0
  300. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_template.h +26 -0
  301. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_time.h +334 -0
  302. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_token.h +110 -0
  303. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_traceback.h +111 -0
  304. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tracemalloc.h +164 -0
  305. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tstate.h +88 -0
  306. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tuple.h +75 -0
  307. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typedefs.h +18 -0
  308. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typeobject.h +155 -0
  309. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typevarobject.h +28 -0
  310. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ucnhash.h +36 -0
  311. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject.h +308 -0
  312. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject_generated.h +3132 -0
  313. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unionobject.h +26 -0
  314. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uniqueid.h +57 -0
  315. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_ids.h +335 -0
  316. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_metadata.h +1204 -0
  317. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_warnings.h +21 -0
  318. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_weakref.h +133 -0
  319. pytron/platforms/android/shell/app/src/main/cpp/include/intrcheck.h +23 -0
  320. pytron/platforms/android/shell/app/src/main/cpp/include/iterobject.h +24 -0
  321. pytron/platforms/android/shell/app/src/main/cpp/include/listobject.h +55 -0
  322. pytron/platforms/android/shell/app/src/main/cpp/include/lock.h +16 -0
  323. pytron/platforms/android/shell/app/src/main/cpp/include/longobject.h +178 -0
  324. pytron/platforms/android/shell/app/src/main/cpp/include/marshal.h +31 -0
  325. pytron/platforms/android/shell/app/src/main/cpp/include/memoryobject.h +34 -0
  326. pytron/platforms/android/shell/app/src/main/cpp/include/methodobject.h +146 -0
  327. pytron/platforms/android/shell/app/src/main/cpp/include/modsupport.h +146 -0
  328. pytron/platforms/android/shell/app/src/main/cpp/include/moduleobject.h +122 -0
  329. pytron/platforms/android/shell/app/src/main/cpp/include/monitoring.h +18 -0
  330. pytron/platforms/android/shell/app/src/main/cpp/include/object.h +828 -0
  331. pytron/platforms/android/shell/app/src/main/cpp/include/objimpl.h +211 -0
  332. pytron/platforms/android/shell/app/src/main/cpp/include/opcode.h +43 -0
  333. pytron/platforms/android/shell/app/src/main/cpp/include/opcode_ids.h +259 -0
  334. pytron/platforms/android/shell/app/src/main/cpp/include/osdefs.h +57 -0
  335. pytron/platforms/android/shell/app/src/main/cpp/include/osmodule.h +17 -0
  336. pytron/platforms/android/shell/app/src/main/cpp/include/patchlevel.h +49 -0
  337. pytron/platforms/android/shell/app/src/main/cpp/include/py_curses.h +117 -0
  338. pytron/platforms/android/shell/app/src/main/cpp/include/pyatomic.h +16 -0
  339. pytron/platforms/android/shell/app/src/main/cpp/include/pybuffer.h +145 -0
  340. pytron/platforms/android/shell/app/src/main/cpp/include/pycapsule.h +58 -0
  341. pytron/platforms/android/shell/app/src/main/cpp/include/pyconfig.h +2088 -0
  342. pytron/platforms/android/shell/app/src/main/cpp/include/pydtrace.h +59 -0
  343. pytron/platforms/android/shell/app/src/main/cpp/include/pyerrors.h +335 -0
  344. pytron/platforms/android/shell/app/src/main/cpp/include/pyexpat.h +62 -0
  345. pytron/platforms/android/shell/app/src/main/cpp/include/pyframe.h +26 -0
  346. pytron/platforms/android/shell/app/src/main/cpp/include/pyhash.h +59 -0
  347. pytron/platforms/android/shell/app/src/main/cpp/include/pylifecycle.h +80 -0
  348. pytron/platforms/android/shell/app/src/main/cpp/include/pymacconfig.h +91 -0
  349. pytron/platforms/android/shell/app/src/main/cpp/include/pymacro.h +243 -0
  350. pytron/platforms/android/shell/app/src/main/cpp/include/pymath.h +65 -0
  351. pytron/platforms/android/shell/app/src/main/cpp/include/pymem.h +110 -0
  352. pytron/platforms/android/shell/app/src/main/cpp/include/pyport.h +710 -0
  353. pytron/platforms/android/shell/app/src/main/cpp/include/pystate.h +132 -0
  354. pytron/platforms/android/shell/app/src/main/cpp/include/pystats.h +28 -0
  355. pytron/platforms/android/shell/app/src/main/cpp/include/pystrcmp.h +23 -0
  356. pytron/platforms/android/shell/app/src/main/cpp/include/pystrtod.h +37 -0
  357. pytron/platforms/android/shell/app/src/main/cpp/include/pythonrun.h +42 -0
  358. pytron/platforms/android/shell/app/src/main/cpp/include/pythread.h +131 -0
  359. pytron/platforms/android/shell/app/src/main/cpp/include/pytypedefs.h +30 -0
  360. pytron/platforms/android/shell/app/src/main/cpp/include/rangeobject.h +27 -0
  361. pytron/platforms/android/shell/app/src/main/cpp/include/refcount.h +555 -0
  362. pytron/platforms/android/shell/app/src/main/cpp/include/setobject.h +49 -0
  363. pytron/platforms/android/shell/app/src/main/cpp/include/sliceobject.h +69 -0
  364. pytron/platforms/android/shell/app/src/main/cpp/include/structmember.h +56 -0
  365. pytron/platforms/android/shell/app/src/main/cpp/include/structseq.h +46 -0
  366. pytron/platforms/android/shell/app/src/main/cpp/include/sysmodule.h +27 -0
  367. pytron/platforms/android/shell/app/src/main/cpp/include/traceback.h +26 -0
  368. pytron/platforms/android/shell/app/src/main/cpp/include/tupleobject.h +46 -0
  369. pytron/platforms/android/shell/app/src/main/cpp/include/typeslots.h +96 -0
  370. pytron/platforms/android/shell/app/src/main/cpp/include/unicodeobject.h +1029 -0
  371. pytron/platforms/android/shell/app/src/main/cpp/include/warnings.h +45 -0
  372. pytron/platforms/android/shell/app/src/main/cpp/include/weakrefobject.h +46 -0
  373. pytron/platforms/android/shell/app/src/main/cpp/pytron_bridge.cpp +224 -0
  374. pytron/platforms/android/shell/app/src/main/java/com/pytron/shell/MainActivity.kt +208 -0
  375. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  376. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  377. pytron/platforms/android/shell/build.gradle +11 -0
  378. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.jar +0 -0
  379. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.properties +5 -0
  380. pytron/platforms/android/shell/gradle.properties +2 -0
  381. pytron/platforms/android/shell/gradlew.bat +85 -0
  382. pytron/platforms/android/shell/settings.gradle +16 -0
  383. pytron/platforms/darwin.py +82 -0
  384. pytron/platforms/darwin_ops/libs.py +31 -0
  385. pytron/platforms/darwin_ops/system.py +182 -0
  386. pytron/platforms/darwin_ops/utils.py +85 -0
  387. pytron/platforms/darwin_ops/webview.py +5 -0
  388. pytron/platforms/darwin_ops/window.py +102 -0
  389. pytron/platforms/interface.py +152 -0
  390. pytron/platforms/linux.py +82 -0
  391. pytron/platforms/linux_ops/libs.py +49 -0
  392. pytron/platforms/linux_ops/system.py +316 -0
  393. pytron/platforms/linux_ops/utils.py +19 -0
  394. pytron/platforms/linux_ops/webview.py +5 -0
  395. pytron/platforms/linux_ops/window.py +115 -0
  396. pytron/platforms/windows.py +136 -0
  397. pytron/platforms/windows_ops/__init__.py +0 -0
  398. pytron/platforms/windows_ops/constants.py +126 -0
  399. pytron/platforms/windows_ops/system.py +518 -0
  400. pytron/platforms/windows_ops/utils.py +3 -0
  401. pytron/platforms/windows_ops/webview.py +5 -0
  402. pytron/platforms/windows_ops/window.py +361 -0
  403. pytron/plugin.py +467 -0
  404. pytron/rcedit-x64.exe +0 -0
  405. pytron/router.py +146 -0
  406. pytron/serializer.py +240 -0
  407. pytron/shortcuts.py +279 -0
  408. pytron/state.py +76 -0
  409. pytron/tray.py +399 -0
  410. pytron/updater.py +181 -0
  411. pytron/utf8_hook.py +112 -0
  412. pytron/utils.py +44 -0
  413. pytron/webview.py +722 -0
  414. pytron_kit-0.3.12.dist-info/METADATA +131 -0
  415. pytron_kit-0.3.12.dist-info/RECORD +419 -0
  416. pytron_kit-0.3.12.dist-info/WHEEL +5 -0
  417. pytron_kit-0.3.12.dist-info/entry_points.txt +2 -0
  418. pytron_kit-0.3.12.dist-info/licenses/LICENSE +201 -0
  419. pytron_kit-0.3.12.dist-info/top_level.txt +1 -0
@@ -0,0 +1,576 @@
1
+ import os
2
+ import sys
3
+ import json
4
+ import logging
5
+ import ctypes
6
+ import platform
7
+ import subprocess
8
+ import urllib.parse
9
+ from ...webview import Webview
10
+ from .adapter import ChromeAdapter
11
+ from ...serializer import pytron_serialize
12
+
13
+
14
+ def _to_str(b):
15
+ if isinstance(b, bytes):
16
+ return b.decode("utf-8")
17
+ if hasattr(b, "value") and isinstance(b.value, bytes): # ctypes.c_char_p
18
+ return b.value.decode("utf-8")
19
+ return str(b)
20
+
21
+
22
+ class ChromeBridge:
23
+ """Mocks the native 'lib' DLL interface but redirects to Chrome Shell via IPC."""
24
+
25
+ def __init__(self, adapter):
26
+ self.adapter = adapter
27
+ self._callbacks = {}
28
+ self.real_hwnd = 0
29
+
30
+ def webview_create(self, debug, window, root_path=None):
31
+ self.adapter.send(
32
+ {
33
+ "action": "init",
34
+ "options": {
35
+ "debug": bool(debug),
36
+ "root": root_path, # Pass the root path!
37
+ "frameless": self.adapter.config.get("frameless", False),
38
+ "icon": self.adapter.config.get("icon", ""),
39
+ "width": self.adapter.config.get("width", 1024),
40
+ "height": self.adapter.config.get("height", 768),
41
+ "title": self.adapter.config.get("title", "Pytron"),
42
+ "min_size": self.adapter.config.get("min_size"),
43
+ "max_size": self.adapter.config.get("max_size"),
44
+ "resizable": self.adapter.config.get("resizable", True),
45
+ "fullscreen": self.adapter.config.get("fullscreen", False),
46
+ "always_on_top": self.adapter.config.get("always_on_top", False),
47
+ "background_color": self.adapter.config.get(
48
+ "background_color", "#ffffff"
49
+ ),
50
+ "start_hidden": self.adapter.config.get("start_hidden", False),
51
+ "start_maximized": self.adapter.config.get(
52
+ "start_maximized", False
53
+ ),
54
+ "start_minimized": self.adapter.config.get(
55
+ "start_minimized", False
56
+ ),
57
+ "transparent": self.adapter.config.get("transparent", False),
58
+ "center": self.adapter.config.get("center", True),
59
+ },
60
+ }
61
+ )
62
+ return 1
63
+
64
+ def webview_show(self, w):
65
+ self.adapter.send({"action": "show"})
66
+
67
+ def webview_hide(self, w):
68
+ self.adapter.send({"action": "hide"})
69
+
70
+ def webview_set_title(self, w, title):
71
+ self.adapter.send({"action": "set_title", "title": _to_str(title)})
72
+
73
+ def webview_set_size(self, w, width, height, hints):
74
+ self.adapter.send({"action": "set_size", "width": width, "height": height})
75
+
76
+ def webview_navigate(self, w, url):
77
+ self.adapter.send({"action": "navigate", "url": _to_str(url)})
78
+
79
+ def webview_eval(self, w, js):
80
+ self.adapter.send({"action": "eval", "code": _to_str(js)})
81
+
82
+ def webview_init(self, w, js):
83
+ self.adapter.send({"action": "init_script", "js": _to_str(js)})
84
+
85
+ def webview_run(self, w):
86
+ if self.adapter.process:
87
+ self.adapter.process.wait()
88
+
89
+ def webview_destroy(self, w):
90
+ self.adapter.send({"action": "close"})
91
+
92
+ def webview_bind(self, w, name, fn, arg):
93
+ n = _to_str(name)
94
+ self._callbacks[n] = fn
95
+ self.adapter.send({"action": "bind", "name": n})
96
+
97
+ def webview_return(self, w, seq, status, result):
98
+ try:
99
+ if result is None:
100
+ res_obj = None
101
+ else:
102
+ res_obj = json.loads(_to_str(result))
103
+ except:
104
+ res_obj = _to_str(result)
105
+
106
+ self.adapter.send(
107
+ {"action": "reply", "id": _to_str(seq), "status": status, "result": res_obj}
108
+ )
109
+
110
+ def webview_get_window(self, w):
111
+ # On Windows, returning the real HWND allows native features (Taskbar, Menus) to work.
112
+ if platform.system() == "Windows":
113
+ return self.real_hwnd
114
+ return 0
115
+
116
+ def create_tray(self, icon_path, tooltip="Pytron App"):
117
+ self.adapter.send(
118
+ {"action": "create_tray", "icon": str(icon_path), "tooltip": tooltip}
119
+ )
120
+
121
+ def webview_dispatch(self, w, fn, arg):
122
+ try:
123
+ js_code = _to_str(ctypes.cast(arg, ctypes.c_char_p))
124
+ self.webview_eval(w, js_code)
125
+ except:
126
+ pass
127
+
128
+
129
+ from .forge import ChromeForge
130
+
131
+
132
+ class ChromeWebView(Webview):
133
+ """
134
+ Electronic Mojo Engine for Pytron.
135
+ A professional, Chromium-based alternative to the native webview.
136
+ """
137
+
138
+ def __init__(self, config):
139
+ self.logger = logging.getLogger("Pytron.ChromeWebView")
140
+
141
+ # --- Replicate Webview Basic Init ---
142
+ self.config = config
143
+ self.id = config.get("id") or str(int(__import__("time").time() * 1000))
144
+
145
+ # 1. Resolve Root
146
+ if getattr(sys, "frozen", False):
147
+ self._app_root = __import__("pathlib").Path(sys.executable).parent
148
+ if hasattr(sys, "_MEIPASS"):
149
+ self._app_root = __import__("pathlib").Path(sys._MEIPASS)
150
+ else:
151
+ self._app_root = __import__("pathlib").Path.cwd()
152
+
153
+ # 2. Performance Init
154
+ self.app = config.get("__app__")
155
+ if self.app:
156
+ self.thread_pool = self.app.thread_pool
157
+ else:
158
+ self.thread_pool = __import__(
159
+ "concurrent.futures"
160
+ ).futures.ThreadPoolExecutor(max_workers=5)
161
+
162
+ self._bound_functions = {}
163
+ self._served_data = {}
164
+
165
+ # 3. Resolve Chrome Binary
166
+ shell_path = config.get("engine_path")
167
+ if not shell_path:
168
+ renamed_engine = None
169
+ if getattr(sys, "frozen", False):
170
+ exe_name = os.path.splitext(os.path.basename(sys.executable))[0]
171
+ candidates = [
172
+ f"{exe_name}.exe",
173
+ f"{exe_name}-Renderer.exe",
174
+ f"{exe_name}-Engine.exe",
175
+ "electron.exe",
176
+ ]
177
+ base_dir = os.path.dirname(sys.executable)
178
+ std_dir = os.path.join(base_dir, "pytron", "dependencies", "chrome")
179
+ mei_dir = getattr(sys, "_MEIPASS", None)
180
+ search_roots = [base_dir]
181
+ if std_dir:
182
+ search_roots.append(std_dir)
183
+ if mei_dir:
184
+ search_roots.append(
185
+ os.path.join(mei_dir, "pytron", "dependencies", "chrome")
186
+ )
187
+ for root in search_roots:
188
+ if not os.path.exists(root):
189
+ continue
190
+ for candidate in candidates:
191
+ candidate_path = os.path.join(root, candidate)
192
+ if os.path.exists(candidate_path):
193
+ if os.path.abspath(candidate_path) == os.path.abspath(
194
+ sys.executable
195
+ ):
196
+ continue
197
+ renamed_engine = candidate_path
198
+ break
199
+ if renamed_engine:
200
+ break
201
+
202
+ if renamed_engine:
203
+ shell_path = renamed_engine
204
+ else:
205
+ global_path = os.path.expanduser(
206
+ "~/.pytron/engines/chrome/electron.exe"
207
+ )
208
+ if os.path.exists(global_path):
209
+ shell_path = global_path
210
+ else:
211
+ search_path = os.path.abspath(
212
+ os.path.join(
213
+ os.getcwd(),
214
+ "..",
215
+ "pytron-electron-engine",
216
+ "bin",
217
+ "electron.exe",
218
+ )
219
+ )
220
+ if os.path.exists(search_path):
221
+ shell_path = search_path
222
+ else:
223
+ self.logger.warning(
224
+ "Chrome Engine not found. Auto-provisioning..."
225
+ )
226
+ forge = ChromeForge()
227
+ shell_path = forge.provision()
228
+
229
+ # 4. Resolve Root Path (Robust Common Ancestor Logic)
230
+ # We need a root that covers both 'frontend/dist' and 'plugins'
231
+ raw_url = config.get("url", "")
232
+ root_path = str(self._app_root) # Default fallback
233
+ navigate_url = raw_url
234
+
235
+ if not raw_url.startswith(("http:", "https:", "pytron:")):
236
+ p = __import__("pathlib").Path(raw_url).resolve()
237
+ # Assume standard structure: <root>/frontend/dist/index.html
238
+ # We want <root> to be the base.
239
+ # Heuristic: Go up until we find 'plugins' folder or hit root
240
+ candidate = p.parent
241
+ found_root = None
242
+ for _ in range(4): # Check up to 4 levels up
243
+ if (candidate / "plugins").exists():
244
+ found_root = candidate
245
+ break
246
+ candidate = candidate.parent
247
+
248
+ if found_root:
249
+ root_path = str(found_root)
250
+ try:
251
+ rel = os.path.relpath(str(p), str(found_root))
252
+ navigate_url = (
253
+ f"pytron://app/{urllib.parse.quote(rel.replace(os.sep, '/'))}"
254
+ )
255
+ except ValueError:
256
+ pass
257
+ else:
258
+ root_path = str(p.parent)
259
+ navigate_url = f"pytron://app/{urllib.parse.quote(p.name)}"
260
+
261
+ self.logger.info(f"Target Root: {root_path}")
262
+ self.logger.info(f"Navigating to: {navigate_url}")
263
+
264
+ if "cwd" not in config:
265
+ config["cwd"] = root_path
266
+
267
+ # 5. Initialize Bridge & Start Adapter
268
+ self.logger.info(f"Using Chrome Shell (v3): {shell_path}")
269
+ self.adapter = ChromeAdapter(shell_path, config)
270
+ self.bridge = ChromeBridge(self.adapter)
271
+
272
+ self.adapter.start()
273
+ self.adapter.bind_raw(self._handle_ipc_message)
274
+
275
+ # Mock Window Object
276
+ if "resizable" not in config:
277
+ config["resizable"] = True
278
+
279
+ self.w = self.bridge.webview_create(
280
+ config.get("debug", False), None, root_path=root_path
281
+ )
282
+
283
+ # Safety Net
284
+ self.native = None
285
+
286
+ # 5. Bindings & Init
287
+ self._init_bindings()
288
+
289
+ # 6. Window Settings
290
+ self.set_title(config.get("title", "Pytron App"))
291
+ w, h = config.get("dimensions", [800, 600])
292
+ self.set_size(w, h)
293
+ if not config.get("start_hidden", False):
294
+ self.show()
295
+
296
+ # Navigate
297
+ self.navigate(navigate_url)
298
+
299
+ # --- Platform Helpers (All Platforms) ---
300
+ self._platform = None
301
+ current_sys = platform.system()
302
+ try:
303
+ if current_sys == "Windows":
304
+ from ...platforms.windows import WindowsImplementation
305
+
306
+ self._platform = WindowsImplementation()
307
+ elif current_sys == "Darwin":
308
+ from ...platforms.darwin import DarwinImplementation
309
+
310
+ self._platform = DarwinImplementation()
311
+ elif current_sys == "Linux":
312
+ from ...platforms.linux import LinuxImplementation
313
+
314
+ self._platform = LinuxImplementation()
315
+ except Exception as e:
316
+ self.logger.warning(f"Failed to load {current_sys} Platform helpers: {e}")
317
+
318
+ # 7. JS Init Shim (With Proxy for Dynamic Methods)
319
+ init_js = f"""
320
+ (function() {{
321
+ try {{
322
+ if (!window.pytron) {{
323
+ window.pytron = {{ is_ready: true, id: "{self.id}" }};
324
+ }} else {{
325
+ window.pytron.is_ready = true;
326
+ window.pytron.id = "{self.id}";
327
+ }}
328
+ }} catch (e) {{
329
+ // Already read-only or handled by bridge
330
+ }}
331
+
332
+ window.pytron_is_native = true;
333
+
334
+ // --- DE-BROWSERIFY CORE ---
335
+ (function() {{
336
+ const isDebug = {str(self.config.get("debug", False)).lower()};
337
+
338
+ // 1. Kill Context Menu (Unless debugging)
339
+ if (!isDebug) {{
340
+ document.addEventListener('contextmenu', e => e.preventDefault());
341
+ }}
342
+
343
+ // 2. Kill "Ghost" Drags (images/links flying around)
344
+ document.addEventListener('dragstart', e => {{
345
+ if (e.target.tagName === 'IMG' || e.target.tagName === 'A') e.preventDefault();
346
+ }});
347
+
348
+ // 3. Kill Browser Shortcuts
349
+ window.addEventListener('keydown', e => {{
350
+ const forbidden = ['r', 'p', 's', 'j', 'u', 'f'];
351
+ if (e.ctrlKey && forbidden.includes(e.key.toLowerCase())) e.preventDefault();
352
+ if (e.key === 'F5' || e.key === 'F3' || (e.ctrlKey && e.key === 'f')) e.preventDefault();
353
+ // Block Zoom
354
+ if (e.ctrlKey && (e.key === '=' || e.key === '-' || e.key === '0')) e.preventDefault();
355
+ }}, true);
356
+
357
+ // 4. Kill System UI Styles (Selection, Outlines, Rubber-banding)
358
+ const style = document.createElement('style');
359
+ style.textContent = `
360
+ * {{
361
+ -webkit-user-select: none;
362
+ user-select: none;
363
+ -webkit-user-drag: none;
364
+ -webkit-tap-highlight-color: transparent;
365
+ outline: none !important;
366
+ }}
367
+ input, textarea, [contenteditable], [contenteditable] * {{
368
+ -webkit-user-select: text !important;
369
+ user-select: text !important;
370
+ }}
371
+ html, body {{
372
+ overscroll-behavior: none !important;
373
+ cursor: default;
374
+ }}
375
+ a, button, input[type="button"], input[type="submit"] {{
376
+ cursor: pointer;
377
+ }}
378
+ `;
379
+ document.head ? document.head.appendChild(style) : document.addEventListener('DOMContentLoaded', () => document.head.appendChild(style));
380
+ }})();
381
+
382
+ // Universal IPC Bridge
383
+ if (!window.__pytron_native_bridge) {{
384
+ window.__pytron_native_bridge = (method, args) => {{
385
+ const seq = Math.random().toString(36).substring(2, 10);
386
+ if (window.ipc) {{
387
+ window.ipc.postMessage(JSON.stringify({{id: seq, method: method, params: args}}));
388
+ }}
389
+ return new Promise((resolve, reject) => {{
390
+ window._rpc = window._rpc || {{}};
391
+ window._rpc[seq] = {{resolve, reject}};
392
+ }});
393
+ }};
394
+ }}
395
+
396
+ // Dynamic Proxy to handle ANY method call from frontend (hide, center, etc.)
397
+ try {{
398
+ const existing = window.pytron;
399
+ window.pytron = new Proxy(existing || {{}}, {{
400
+ get: function(target, prop) {{
401
+ if (prop in target) return target[prop];
402
+ // If not found, assume it's a bridge call
403
+ return (...args) => window.__pytron_native_bridge(prop, args);
404
+ }}
405
+ }});
406
+ }} catch (e) {{
407
+ // Skip proxy if window.pytron is read-only
408
+ }}
409
+
410
+ // Standard Pollys & Asset Bridge
411
+ window.pytron_drag = () => window.__pytron_native_bridge('pytron_drag', []);
412
+ window.pytron_minimize = () => window.__pytron_native_bridge('pytron_minimize', []);
413
+ window.pytron_get_asset = (key) => window.__pytron_native_bridge('pytron_get_asset', [key]);
414
+
415
+ window['pytron_drag'] = window.pytron_drag;
416
+ window['pytron_minimize'] = window.pytron_minimize;
417
+ window['pytron_get_asset'] = window.pytron_get_asset;
418
+ window['__pytron_vap_get'] = window.pytron_get_asset;
419
+
420
+ }})();
421
+ """
422
+ self.eval(init_js)
423
+
424
+ # Force Resizable Update (Fix gray maximize button)
425
+ # Sometimes init flag is overridden by window style defaults in Electron
426
+ self.bridge.adapter.send({"action": "set_resizable", "resizable": True})
427
+
428
+ @property
429
+ def hwnd(self):
430
+ """Override to return Electron HWND instead of native engine HWND."""
431
+ if hasattr(self.bridge, "real_hwnd"):
432
+ return self.bridge.real_hwnd
433
+ return 0
434
+
435
+ def _handle_ipc_message(self, msg):
436
+ import inspect
437
+ import asyncio
438
+
439
+ msg_type = msg.get("type")
440
+ payload = msg.get("payload")
441
+
442
+ # DEBUG: Log all lifecycle events to trace HWND
443
+ if msg_type == "lifecycle":
444
+ self.logger.info(f"Chrome Lifecycle Event: {payload}")
445
+
446
+ # HWND Sync
447
+ if (
448
+ msg_type == "lifecycle"
449
+ and isinstance(payload, dict)
450
+ and payload.get("event") == "window_created"
451
+ ):
452
+ hwnd_str = payload.get("hwnd")
453
+ try:
454
+ self.bridge.real_hwnd = int(hwnd_str)
455
+ self.logger.info(f"Acquired Electron HWND: {self.bridge.real_hwnd}")
456
+ except:
457
+ pass
458
+ return
459
+
460
+ if msg_type == "ipc":
461
+ event = payload.get("event")
462
+ inner_payload = payload.get("data", {})
463
+ if isinstance(inner_payload, dict) and "data" in inner_payload:
464
+ args = inner_payload.get("data", [])
465
+ seq = inner_payload.get("id")
466
+ else:
467
+ args = inner_payload
468
+ seq = None
469
+
470
+ if event in self._bound_functions:
471
+ func = self._bound_functions[event]
472
+ try:
473
+ result = func(*args) if isinstance(args, list) else func(args)
474
+
475
+ if inspect.iscoroutine(result):
476
+ try:
477
+ result = asyncio.run(result)
478
+ except RuntimeError:
479
+ pass
480
+
481
+ safe_obj = pytron_serialize(result, None)
482
+ serialized_json = json.dumps(safe_obj)
483
+
484
+ if seq:
485
+ self.bridge.webview_return(
486
+ self.w, seq.encode("utf-8"), 0, serialized_json
487
+ )
488
+ except Exception as e:
489
+ self.logger.error(f"Mojo IPC Error in {event}: {e}")
490
+ if seq:
491
+ safe_err = pytron_serialize(str(e), None)
492
+ self.bridge.webview_return(
493
+ self.w, seq.encode("utf-8"), 1, json.dumps(safe_err)
494
+ )
495
+
496
+ def bind(self, name, func, run_in_thread=True, secure=False):
497
+ self._bound_functions[name] = func
498
+ self.bridge.webview_bind(self.w, name.encode("utf-8"), None, None)
499
+
500
+ # --- Feature Overrides (Compatibility Layer) ---
501
+
502
+ def center(self):
503
+ self.bridge.adapter.send({"action": "center"})
504
+
505
+ def serve_data(self, key, data, mime="application/octet-stream"):
506
+ """Sends binary data to the Node process for pytron:// serving."""
507
+ import base64
508
+
509
+ try:
510
+ b64_data = base64.b64encode(data).decode("utf-8")
511
+ self.bridge.adapter.send(
512
+ {
513
+ "action": "serve_data",
514
+ "key": key,
515
+ "data": b64_data,
516
+ "mime": mime,
517
+ }
518
+ )
519
+ except Exception as e:
520
+ self.logger.error(f"Failed to serve data for key {key}: {e}")
521
+
522
+ def unserve_data(self, key):
523
+ self.bridge.adapter.send({"action": "unserve_data", "key": key})
524
+
525
+ def set_icon(self, icon_path):
526
+ pass
527
+
528
+ def minimize(self):
529
+ self.bridge.adapter.send({"action": "minimize"})
530
+
531
+ def show(self):
532
+ self.bridge.webview_show(self.w)
533
+
534
+ def hide(self):
535
+ self.bridge.webview_hide(self.w)
536
+
537
+ def close(self, force=False):
538
+ self.bridge.webview_destroy(self.w)
539
+
540
+ def set_title(self, title):
541
+ self.bridge.webview_set_title(self.w, title.encode("utf-8"))
542
+
543
+ def set_size(self, w, h):
544
+ self.bridge.webview_set_size(self.w, w, h, 0)
545
+
546
+ def navigate(self, url):
547
+ self.bridge.webview_navigate(self.w, url.encode("utf-8"))
548
+
549
+ def eval(self, js):
550
+ self.bridge.webview_eval(self.w, js)
551
+
552
+ def toggle_maximize(self):
553
+ self.bridge.adapter.send({"action": "toggle_maximize"})
554
+
555
+ def make_frameless(self):
556
+ self.bridge.adapter.send({"action": "set_frameless", "frameless": True})
557
+
558
+ def start_drag(self):
559
+ pass
560
+
561
+ def set_menu(self, menu_bar):
562
+ pass
563
+
564
+ def start(self):
565
+ try:
566
+ if self.adapter.process:
567
+ # Use a loop with timeout to allow for signal processing (like Ctrl+C)
568
+ while self.adapter.process.poll() is None:
569
+ try:
570
+ self.adapter.process.wait(timeout=0.5)
571
+ except subprocess.TimeoutExpired:
572
+ continue
573
+ except KeyboardInterrupt:
574
+ self.close()
575
+ finally:
576
+ self.logger.info("Chrome Engine stopped.")