pynect 0.0.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +503 -2
  3. package/SECURITY.md +34 -0
  4. package/binding.gyp +67 -0
  5. package/dist/cli/codegen.d.ts +3 -0
  6. package/dist/cli/codegen.d.ts.map +1 -0
  7. package/dist/cli/codegen.js +543 -0
  8. package/dist/cli/codegen.js.map +1 -0
  9. package/dist/cli/sync.d.ts +3 -0
  10. package/dist/cli/sync.d.ts.map +1 -0
  11. package/dist/cli/sync.js +47 -0
  12. package/dist/cli/sync.js.map +1 -0
  13. package/dist/config/project.d.ts +113 -0
  14. package/dist/config/project.d.ts.map +1 -0
  15. package/dist/config/project.js +344 -0
  16. package/dist/config/project.js.map +1 -0
  17. package/dist/core/isolated-worker.d.ts +39 -0
  18. package/dist/core/isolated-worker.d.ts.map +1 -0
  19. package/dist/core/isolated-worker.js +178 -0
  20. package/dist/core/isolated-worker.js.map +1 -0
  21. package/dist/core/py-callable.d.ts +67 -0
  22. package/dist/core/py-callable.d.ts.map +1 -0
  23. package/dist/core/py-callable.js +104 -0
  24. package/dist/core/py-callable.js.map +1 -0
  25. package/dist/core/py-context.d.ts +76 -0
  26. package/dist/core/py-context.d.ts.map +1 -0
  27. package/dist/core/py-context.js +239 -0
  28. package/dist/core/py-context.js.map +1 -0
  29. package/dist/core/py-iterator.d.ts +84 -0
  30. package/dist/core/py-iterator.d.ts.map +1 -0
  31. package/dist/core/py-iterator.js +243 -0
  32. package/dist/core/py-iterator.js.map +1 -0
  33. package/dist/core/py-module.d.ts +53 -0
  34. package/dist/core/py-module.d.ts.map +1 -0
  35. package/dist/core/py-module.js +162 -0
  36. package/dist/core/py-module.js.map +1 -0
  37. package/dist/core/py-proxy.d.ts +75 -0
  38. package/dist/core/py-proxy.d.ts.map +1 -0
  39. package/dist/core/py-proxy.js +563 -0
  40. package/dist/core/py-proxy.js.map +1 -0
  41. package/dist/core/py-runtime.d.ts +113 -0
  42. package/dist/core/py-runtime.d.ts.map +1 -0
  43. package/dist/core/py-runtime.js +528 -0
  44. package/dist/core/py-runtime.js.map +1 -0
  45. package/dist/env/executables.d.ts +3 -0
  46. package/dist/env/executables.d.ts.map +1 -0
  47. package/dist/env/executables.js +14 -0
  48. package/dist/env/executables.js.map +1 -0
  49. package/dist/env/package-installer.d.ts +232 -0
  50. package/dist/env/package-installer.d.ts.map +1 -0
  51. package/dist/env/package-installer.js +615 -0
  52. package/dist/env/package-installer.js.map +1 -0
  53. package/dist/env/project-environment.d.ts +64 -0
  54. package/dist/env/project-environment.d.ts.map +1 -0
  55. package/dist/env/project-environment.js +388 -0
  56. package/dist/env/project-environment.js.map +1 -0
  57. package/dist/env/pyfig-adapter.d.ts +38 -0
  58. package/dist/env/pyfig-adapter.d.ts.map +1 -0
  59. package/dist/env/pyfig-adapter.js +10 -0
  60. package/dist/env/pyfig-adapter.js.map +1 -0
  61. package/dist/env/python-detector.d.ts +48 -0
  62. package/dist/env/python-detector.d.ts.map +1 -0
  63. package/dist/env/python-detector.js +182 -0
  64. package/dist/env/python-detector.js.map +1 -0
  65. package/dist/env/python-provisioner.d.ts +16 -0
  66. package/dist/env/python-provisioner.d.ts.map +1 -0
  67. package/dist/env/python-provisioner.js +42 -0
  68. package/dist/env/python-provisioner.js.map +1 -0
  69. package/dist/env/venv-manager.d.ts +56 -0
  70. package/dist/env/venv-manager.d.ts.map +1 -0
  71. package/dist/env/venv-manager.js +160 -0
  72. package/dist/env/venv-manager.js.map +1 -0
  73. package/dist/index.d.ts +182 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +394 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/native/native-addon-loader.d.ts +13 -0
  78. package/dist/native/native-addon-loader.d.ts.map +1 -0
  79. package/dist/native/native-addon-loader.js +171 -0
  80. package/dist/native/native-addon-loader.js.map +1 -0
  81. package/dist/plugins/builtin/numpy-plugin.d.ts +17 -0
  82. package/dist/plugins/builtin/numpy-plugin.d.ts.map +1 -0
  83. package/dist/plugins/builtin/numpy-plugin.js +41 -0
  84. package/dist/plugins/builtin/numpy-plugin.js.map +1 -0
  85. package/dist/plugins/builtin/pandas-plugin.d.ts +19 -0
  86. package/dist/plugins/builtin/pandas-plugin.d.ts.map +1 -0
  87. package/dist/plugins/builtin/pandas-plugin.js +57 -0
  88. package/dist/plugins/builtin/pandas-plugin.js.map +1 -0
  89. package/dist/plugins/builtin/torch-plugin.d.ts +23 -0
  90. package/dist/plugins/builtin/torch-plugin.d.ts.map +1 -0
  91. package/dist/plugins/builtin/torch-plugin.js +50 -0
  92. package/dist/plugins/builtin/torch-plugin.js.map +1 -0
  93. package/dist/plugins/index.d.ts +7 -0
  94. package/dist/plugins/index.d.ts.map +1 -0
  95. package/dist/plugins/index.js +12 -0
  96. package/dist/plugins/index.js.map +1 -0
  97. package/dist/plugins/plugin-manager.d.ts +26 -0
  98. package/dist/plugins/plugin-manager.d.ts.map +1 -0
  99. package/dist/plugins/plugin-manager.js +174 -0
  100. package/dist/plugins/plugin-manager.js.map +1 -0
  101. package/dist/plugins/plugin.interface.d.ts +41 -0
  102. package/dist/plugins/plugin.interface.d.ts.map +1 -0
  103. package/dist/plugins/plugin.interface.js +12 -0
  104. package/dist/plugins/plugin.interface.js.map +1 -0
  105. package/dist/serialization/data-frame-bridge.d.ts +141 -0
  106. package/dist/serialization/data-frame-bridge.d.ts.map +1 -0
  107. package/dist/serialization/data-frame-bridge.js +355 -0
  108. package/dist/serialization/data-frame-bridge.js.map +1 -0
  109. package/dist/serialization/msg-pack-serializer.d.ts +45 -0
  110. package/dist/serialization/msg-pack-serializer.d.ts.map +1 -0
  111. package/dist/serialization/msg-pack-serializer.js +242 -0
  112. package/dist/serialization/msg-pack-serializer.js.map +1 -0
  113. package/dist/serialization/numpy-bridge.d.ts +96 -0
  114. package/dist/serialization/numpy-bridge.d.ts.map +1 -0
  115. package/dist/serialization/numpy-bridge.js +323 -0
  116. package/dist/serialization/numpy-bridge.js.map +1 -0
  117. package/dist/serialization/serializer.d.ts +78 -0
  118. package/dist/serialization/serializer.d.ts.map +1 -0
  119. package/dist/serialization/serializer.js +281 -0
  120. package/dist/serialization/serializer.js.map +1 -0
  121. package/dist/types/addon.d.ts +131 -0
  122. package/dist/types/addon.d.ts.map +1 -0
  123. package/dist/types/addon.js +32 -0
  124. package/dist/types/addon.js.map +1 -0
  125. package/dist/types/config.d.ts +236 -0
  126. package/dist/types/config.d.ts.map +1 -0
  127. package/dist/types/config.js +61 -0
  128. package/dist/types/config.js.map +1 -0
  129. package/dist/types/index.d.ts +10 -0
  130. package/dist/types/index.d.ts.map +1 -0
  131. package/dist/types/index.js +12 -0
  132. package/dist/types/index.js.map +1 -0
  133. package/dist/types/python.d.ts +235 -0
  134. package/dist/types/python.d.ts.map +1 -0
  135. package/dist/types/python.js +7 -0
  136. package/dist/types/python.js.map +1 -0
  137. package/dist/utils/error-translator.d.ts +83 -0
  138. package/dist/utils/error-translator.d.ts.map +1 -0
  139. package/dist/utils/error-translator.js +210 -0
  140. package/dist/utils/error-translator.js.map +1 -0
  141. package/dist/utils/locking.d.ts +3 -0
  142. package/dist/utils/locking.d.ts.map +1 -0
  143. package/dist/utils/locking.js +10 -0
  144. package/dist/utils/locking.js.map +1 -0
  145. package/dist/utils/logger.d.ts +27 -0
  146. package/dist/utils/logger.d.ts.map +1 -0
  147. package/dist/utils/logger.js +115 -0
  148. package/dist/utils/logger.js.map +1 -0
  149. package/dist/utils/memory-monitor.d.ts +43 -0
  150. package/dist/utils/memory-monitor.d.ts.map +1 -0
  151. package/dist/utils/memory-monitor.js +143 -0
  152. package/dist/utils/memory-monitor.js.map +1 -0
  153. package/package.json +93 -17
  154. package/prebuilds/darwin-arm64/pynect-prebuild.json +8 -0
  155. package/prebuilds/darwin-arm64/pynect_addon.node +0 -0
  156. package/prebuilds/darwin-x64/pynect-prebuild.json +8 -0
  157. package/prebuilds/darwin-x64/pynect_addon.node +0 -0
  158. package/prebuilds/linux-arm64/pynect-prebuild.json +9 -0
  159. package/prebuilds/linux-arm64/pynect_addon.node +0 -0
  160. package/prebuilds/linux-x64/pynect-prebuild.json +9 -0
  161. package/prebuilds/linux-x64/pynect_addon.node +0 -0
  162. package/prebuilds/win32-arm64/pynect-prebuild.json +8 -0
  163. package/prebuilds/win32-arm64/pynect_addon.node +0 -0
  164. package/prebuilds/win32-x64/pynect-prebuild.json +8 -0
  165. package/prebuilds/win32-x64/pynect_addon.node +0 -0
  166. package/python/ast_inspector.py +248 -0
  167. package/python/error_handler.py +432 -0
  168. package/python/isolated_worker.py +94 -0
  169. package/python/pynect_dispatcher.py +382 -0
  170. package/python/pynect_runtime.py +574 -0
  171. package/python/serializer.py +373 -0
  172. package/python/type_inspector.py +315 -0
  173. package/scripts/build-native.js +50 -0
  174. package/scripts/cli.js +21 -0
  175. package/scripts/ensure-native.js +85 -0
  176. package/scripts/postinstall.js +40 -0
  177. package/scripts/pyfig.js +128 -0
  178. package/scripts/python-provisioner.js +23 -0
  179. package/scripts/smoke-python-boundary.js +103 -0
  180. package/src/native/gil_guard.cpp +25 -0
  181. package/src/native/gil_guard.h +174 -0
  182. package/src/native/native-addon-loader.ts +218 -0
  183. package/src/native/pynect_addon.cpp +942 -0
  184. package/src/native/python_bridge.cpp +904 -0
  185. package/src/native/python_bridge.h +263 -0
  186. package/src/native/thread_pool.cpp +375 -0
  187. package/src/native/thread_pool.h +185 -0
  188. package/src/native/type_converter.cpp +906 -0
  189. package/src/native/type_converter.h +271 -0
  190. package/index.d.ts +0 -3
  191. package/index.js +0 -3
@@ -0,0 +1,182 @@
1
+ /**
2
+ * pynect - Main Entry Point
3
+ *
4
+ * Run Python libraries from Node.js as if they were Native.
5
+ * Embeds CPython in-process via N-API addon with full TypeScript types,
6
+ * Proxy-based API, async/await support, and Next.js integration.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { init, py } from 'pynect';
11
+ *
12
+ * await init({
13
+ * project: {
14
+ * dependencies: ['pandas', 'numpy'],
15
+ * },
16
+ * tool: { pynect: { autoSync: 'if-missing' } },
17
+ * });
18
+ *
19
+ * const pd = await py.import('pandas');
20
+ * const df = await pd.read_csv('data.csv');
21
+ * const result = await df.describe().to_dict('records');
22
+ * ```
23
+ */
24
+ import { PyRuntime } from './core/py-runtime';
25
+ import type { PynectConfig } from './types/config';
26
+ import type { PyProxyInterface } from './types/python';
27
+ import type { IsolatedCallOptions } from './core/isolated-worker';
28
+ /**
29
+ * The main `py` object - a proxy over the PyRuntime singleton.
30
+ * Provides access to all PyRuntime methods after initialization.
31
+ *
32
+ * @throws {PynectNotInitializedError} if accessed before calling `init()`
33
+ */
34
+ export declare const py: PyRuntime;
35
+ /**
36
+ * Initialize the pynect runtime.
37
+ * Must be called before using `py` or any other pynect API.
38
+ *
39
+ * Calling `init()` multiple times is safe - subsequent calls are no-ops
40
+ * unless `shutdown()` was called first, or `force: true` is passed.
41
+ *
42
+ * @param config - pynect configuration options
43
+ * @param options - Additional initialization options
44
+ * @returns Promise that resolves when Python is ready
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * await init({
49
+ * project: { dependencies: ['pandas'] },
50
+ * tool: { pynect: { autoSync: 'if-missing' } },
51
+ * logLevel: 'info',
52
+ * });
53
+ * ```
54
+ */
55
+ export declare function init(config?: PynectConfig, options?: {
56
+ force?: boolean;
57
+ }): Promise<void>;
58
+ /**
59
+ * Shut down the pynect runtime and release all Python resources.
60
+ * After calling this, `py` is no longer accessible until `init()` is called again.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * await shutdown();
65
+ * ```
66
+ */
67
+ export declare function shutdown(): Promise<void>;
68
+ /**
69
+ * Check if pynect is initialized and ready to use.
70
+ */
71
+ export declare function isInitialized(): boolean;
72
+ /**
73
+ * Get the current PyRuntime instance.
74
+ * @throws {PynectNotInitializedError} if not initialized
75
+ */
76
+ export declare function getRuntime(): PyRuntime;
77
+ /**
78
+ * Initialize the default runtime when needed, then import a Python module.
79
+ * Call `init(config)` first when custom runtime settings are required.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const np = await importModule('numpy');
84
+ * const arr = await np.array([1, 2, 3]);
85
+ * ```
86
+ */
87
+ /** Module types contributed by `pynect codegen`. */
88
+ export interface PynectModules {
89
+ }
90
+ export declare function importModule<Name extends keyof PynectModules & string>(moduleName: Name): Promise<PynectModules[Name]>;
91
+ export declare function importModule(moduleName: string): Promise<PyProxyInterface>;
92
+ /** Call a JSON-compatible function through the optional killable Python worker. */
93
+ export declare function callIsolated<T = unknown>(moduleName: string, functionName: string, args?: unknown[], options?: IsolatedCallOptions): Promise<T>;
94
+ /**
95
+ * Evaluate a Python expression and return the result.
96
+ * Shorthand for `py.eval(expression)`.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const result = await evalPython('1 + 2 + 3');
101
+ * // result === 6
102
+ * ```
103
+ */
104
+ export declare function evalPython(expression: string): Promise<unknown>;
105
+ /**
106
+ * Execute Python code (statements, not expressions).
107
+ * Shorthand for `py.exec(code)`.
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * await execPython(`
112
+ * import sys
113
+ * print(f"Python {sys.version}")
114
+ * `);
115
+ * ```
116
+ */
117
+ export declare function execPython(code: string): Promise<void>;
118
+ /**
119
+ * Run a Python script file.
120
+ */
121
+ export declare function runFile(filePath: string): Promise<unknown>;
122
+ /**
123
+ * Install Python packages into the configured virtualenv.
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * await installPackages(['pandas', 'numpy>=1.24.0', 'scikit-learn']);
128
+ * ```
129
+ */
130
+ export declare function installPackages(packages: string[]): Promise<void>;
131
+ /**
132
+ * Get memory statistics for the Python heap.
133
+ */
134
+ export declare function getMemoryStats(): Promise<{
135
+ pythonHeapBytes: number;
136
+ pythonHeapPeakBytes: number;
137
+ trackedObjects: number;
138
+ pendingCallbacks: number;
139
+ }>;
140
+ /**
141
+ * Trigger Python garbage collection.
142
+ */
143
+ export declare function collectGarbage(): Promise<void>;
144
+ export { PyRuntime } from './core/py-runtime';
145
+ export { PyProxy, PYNECT_WITH_OPTIONS } from './core/py-proxy';
146
+ export type { PynectFunction } from './core/py-proxy';
147
+ export { PyModule } from './core/py-module';
148
+ export { PyCallable } from './core/py-callable';
149
+ export { PyIterator } from './core/py-iterator';
150
+ export { PyContext } from './core/py-context';
151
+ export { IsolatedWorker } from './core/isolated-worker';
152
+ export type { IsolatedCallOptions } from './core/isolated-worker';
153
+ export { Serializer } from './serialization/serializer';
154
+ export { NumpyBridge } from './serialization/numpy-bridge';
155
+ export { DataFrameBridge } from './serialization/data-frame-bridge';
156
+ export { PythonError, PythonValueError, PythonTypeError, PythonKeyError, PythonIndexError, PythonAttributeError, PythonImportError, PythonModuleNotFoundError, PythonFileNotFoundError, PythonPermissionError, PythonRuntimeError, PythonMemoryError, PythonStopIteration, PythonTimeoutError, PynectNotInitializedError, PynectShutdownError, translatePythonError, isPythonError, isPythonErrorOfType, } from './utils/error-translator';
157
+ export { PythonDetector } from './env/python-detector';
158
+ export { VenvManager } from './env/venv-manager';
159
+ export { PackageInstaller } from './env/package-installer';
160
+ export { createProjectPlan, discoverPynectContributions, moduleDispatcherIncludes, resolveExposedModule, syncProject, validateProjectEnvironment, } from './env/project-environment';
161
+ export { CURRENT_PYNECT_SCHEMA_VERSION, resolveProjectConfig } from './config/project';
162
+ export { PluginManager } from './plugins/plugin-manager';
163
+ export type { PynectConfig, ResolvedPynectConfig, VirtualenvConfig, IsolationConfig, DispatcherConfig, LogLevel, PyObjectId, PyTypeInfo, PyParamInfo, PyCallableInfo, PyClassInfo, PyModuleInspection, SerializedFormat, SerializedValue, PyCallResult, PyErrorInfo, DataFrameResult, SeriesResult, NumPyArrayResult, PyProxyInterface, AttributePath, NativeAddon, PyCallOptions, } from './types/index';
164
+ export type { AutoSyncMode, CanonicalPynectPackageManifest, PynectModuleManifest, PynectPackageManifest, PynectProjectTable, PynectToolTable, PynectUvTable, ProjectConfigOverrides, ResolvedProjectConfig, } from './config/project';
165
+ export type { ExposedModule, PynectContribution, PynectEnvironmentState, PynectProjectPlan, SyncProjectOptions, SyncProjectResult, } from './env/project-environment';
166
+ declare const _default: {
167
+ init: typeof init;
168
+ shutdown: typeof shutdown;
169
+ isInitialized: typeof isInitialized;
170
+ getRuntime: typeof getRuntime;
171
+ py: PyRuntime;
172
+ import: typeof importModule;
173
+ callIsolated: typeof callIsolated;
174
+ eval: typeof evalPython;
175
+ exec: typeof execPython;
176
+ runFile: typeof runFile;
177
+ installPackages: typeof installPackages;
178
+ getMemoryStats: typeof getMemoryStats;
179
+ collectGarbage: typeof collectGarbage;
180
+ };
181
+ export default _default;
182
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAalE;;;;;GAKG;AACH,eAAO,MAAM,EAAE,EAAE,SAgCf,CAAC;AAIH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,IAAI,CACxB,MAAM,CAAC,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5B,OAAO,CAAC,IAAI,CAAC,CAmBf;AAmBD;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAY9C;AAqBD;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,SAAS,CAKtC;AAID;;;;;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BAA0B,CAAC;AAGzD,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,YAAY,EACZ,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;;;;;;;;;;;;;;;;AAGnC,wBAcE"}
package/dist/index.js ADDED
@@ -0,0 +1,394 @@
1
+ "use strict";
2
+ /**
3
+ * pynect - Main Entry Point
4
+ *
5
+ * Run Python libraries from Node.js as if they were Native.
6
+ * Embeds CPython in-process via N-API addon with full TypeScript types,
7
+ * Proxy-based API, async/await support, and Next.js integration.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { init, py } from 'pynect';
12
+ *
13
+ * await init({
14
+ * project: {
15
+ * dependencies: ['pandas', 'numpy'],
16
+ * },
17
+ * tool: { pynect: { autoSync: 'if-missing' } },
18
+ * });
19
+ *
20
+ * const pd = await py.import('pandas');
21
+ * const df = await pd.read_csv('data.csv');
22
+ * const result = await df.describe().to_dict('records');
23
+ * ```
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.PluginManager = exports.resolveProjectConfig = exports.CURRENT_PYNECT_SCHEMA_VERSION = exports.validateProjectEnvironment = exports.syncProject = exports.resolveExposedModule = exports.moduleDispatcherIncludes = exports.discoverPynectContributions = exports.createProjectPlan = exports.PackageInstaller = exports.VenvManager = exports.PythonDetector = exports.isPythonErrorOfType = exports.isPythonError = exports.translatePythonError = exports.PynectShutdownError = exports.PynectNotInitializedError = exports.PythonTimeoutError = exports.PythonStopIteration = exports.PythonMemoryError = exports.PythonRuntimeError = exports.PythonPermissionError = exports.PythonFileNotFoundError = exports.PythonModuleNotFoundError = exports.PythonImportError = exports.PythonAttributeError = exports.PythonIndexError = exports.PythonKeyError = exports.PythonTypeError = exports.PythonValueError = exports.PythonError = exports.DataFrameBridge = exports.NumpyBridge = exports.Serializer = exports.IsolatedWorker = exports.PyContext = exports.PyIterator = exports.PyCallable = exports.PyModule = exports.PYNECT_WITH_OPTIONS = exports.PyProxy = exports.PyRuntime = exports.py = void 0;
27
+ exports.init = init;
28
+ exports.shutdown = shutdown;
29
+ exports.isInitialized = isInitialized;
30
+ exports.getRuntime = getRuntime;
31
+ exports.importModule = importModule;
32
+ exports.callIsolated = callIsolated;
33
+ exports.evalPython = evalPython;
34
+ exports.execPython = execPython;
35
+ exports.runFile = runFile;
36
+ exports.installPackages = installPackages;
37
+ exports.getMemoryStats = getMemoryStats;
38
+ exports.collectGarbage = collectGarbage;
39
+ const py_runtime_1 = require("./core/py-runtime");
40
+ const logger_1 = require("./utils/logger");
41
+ const error_translator_1 = require("./utils/error-translator");
42
+ const project_environment_1 = require("./env/project-environment");
43
+ const locking_1 = require("./utils/locking");
44
+ // Singleton Runtime Management
45
+ let _runtime = null;
46
+ let _autoShutdownEnabled = true;
47
+ const _logger = new logger_1.Logger('pynect');
48
+ // Main py Object (Proxy over PyRuntime)
49
+ /**
50
+ * The main `py` object - a proxy over the PyRuntime singleton.
51
+ * Provides access to all PyRuntime methods after initialization.
52
+ *
53
+ * @throws {PynectNotInitializedError} if accessed before calling `init()`
54
+ */
55
+ exports.py = new Proxy({}, {
56
+ get(_target, prop) {
57
+ if (!_runtime) {
58
+ // Provide helpful error for common misuse
59
+ if (prop === 'then') {
60
+ // Prevent silent "awaiting py" mistakes
61
+ return undefined;
62
+ }
63
+ throw new error_translator_1.PynectNotInitializedError(`Cannot access py.${String(prop)} because Pynect is not initialized. ` +
64
+ `Call 'await init()' before using 'py'.`);
65
+ }
66
+ const value = _runtime[prop];
67
+ if (typeof value === 'function') {
68
+ return value.bind(_runtime);
69
+ }
70
+ return value;
71
+ },
72
+ set(_target, prop, value) {
73
+ if (!_runtime) {
74
+ throw new error_translator_1.PynectNotInitializedError('Pynect is not initialized.');
75
+ }
76
+ _runtime[prop] = value;
77
+ return true;
78
+ },
79
+ has(_target, prop) {
80
+ if (!_runtime) {
81
+ return false;
82
+ }
83
+ return prop in _runtime;
84
+ },
85
+ });
86
+ // Lifecycle Functions
87
+ /**
88
+ * Initialize the pynect runtime.
89
+ * Must be called before using `py` or any other pynect API.
90
+ *
91
+ * Calling `init()` multiple times is safe - subsequent calls are no-ops
92
+ * unless `shutdown()` was called first, or `force: true` is passed.
93
+ *
94
+ * @param config - pynect configuration options
95
+ * @param options - Additional initialization options
96
+ * @returns Promise that resolves when Python is ready
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * await init({
101
+ * project: { dependencies: ['pandas'] },
102
+ * tool: { pynect: { autoSync: 'if-missing' } },
103
+ * logLevel: 'info',
104
+ * });
105
+ * ```
106
+ */
107
+ async function init(config, options) {
108
+ await (0, locking_1.withPynectLock)({ operation: 'init' }, async () => {
109
+ if (_runtime && !options?.force) {
110
+ _logger.debug('Pynect already initialized; skipping');
111
+ return;
112
+ }
113
+ if (_runtime && options?.force)
114
+ await _doShutdown();
115
+ await _doInit(config);
116
+ }, undefined, {
117
+ key: 'pynect-runtime-lifecycle',
118
+ name: 'Pynect runtime lifecycle',
119
+ namespace: 'pynect',
120
+ scope: 'memory',
121
+ });
122
+ }
123
+ async function _doInit(config) {
124
+ _logger.info('Initializing Pynect runtime');
125
+ const startTime = performance.now();
126
+ try {
127
+ _runtime = await py_runtime_1.PyRuntime.create(config);
128
+ _autoShutdownEnabled = _runtime.getConfig().autoShutdown;
129
+ if (_autoShutdownEnabled) {
130
+ _registerCleanup();
131
+ }
132
+ const elapsed = (performance.now() - startTime).toFixed(0);
133
+ _logger.success(`Pynect runtime ready in ${elapsed}ms`);
134
+ }
135
+ catch (err) {
136
+ _runtime = null;
137
+ _logger.error('Failed to initialize Pynect runtime', err);
138
+ throw err;
139
+ }
140
+ }
141
+ /**
142
+ * Shut down the pynect runtime and release all Python resources.
143
+ * After calling this, `py` is no longer accessible until `init()` is called again.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * await shutdown();
148
+ * ```
149
+ */
150
+ async function shutdown() {
151
+ await (0, locking_1.withPynectLock)({ operation: 'shutdown' }, async () => _doShutdown(), undefined, {
152
+ key: 'pynect-runtime-lifecycle',
153
+ name: 'Pynect runtime lifecycle',
154
+ namespace: 'pynect',
155
+ scope: 'memory',
156
+ });
157
+ }
158
+ async function _doShutdown() {
159
+ if (!_runtime) {
160
+ _logger.debug('Pynect is not initialized; nothing to shut down');
161
+ return;
162
+ }
163
+ _logger.info('Shutting down Pynect runtime');
164
+ const runtime = _runtime;
165
+ try {
166
+ await runtime.shutdown();
167
+ _runtime = null;
168
+ _logger.success('Pynect runtime shut down');
169
+ }
170
+ catch (err) {
171
+ _logger.error('Error during Pynect shutdown', err);
172
+ throw err;
173
+ }
174
+ }
175
+ /**
176
+ * Check if pynect is initialized and ready to use.
177
+ */
178
+ function isInitialized() {
179
+ return _runtime !== null && _runtime.isRunning();
180
+ }
181
+ /**
182
+ * Get the current PyRuntime instance.
183
+ * @throws {PynectNotInitializedError} if not initialized
184
+ */
185
+ function getRuntime() {
186
+ if (!_runtime) {
187
+ throw new error_translator_1.PynectNotInitializedError();
188
+ }
189
+ return _runtime;
190
+ }
191
+ async function importModule(moduleName) {
192
+ if (!_runtime) {
193
+ await init();
194
+ }
195
+ if (!_runtime) {
196
+ throw new error_translator_1.PynectNotInitializedError();
197
+ }
198
+ const exposed = moduleName.includes(':')
199
+ ? (0, project_environment_1.resolveExposedModule)(moduleName, _runtime.getConfig().projectRoot)
200
+ : undefined;
201
+ if (moduleName.includes(':') && !exposed) {
202
+ throw new Error(`Unknown Pynect module id: ${moduleName}`);
203
+ }
204
+ return _runtime.import(exposed?.import ?? moduleName);
205
+ }
206
+ /** Call a JSON-compatible function through the optional killable Python worker. */
207
+ async function callIsolated(moduleName, functionName, args = [], options = {}) {
208
+ if (!_runtime) {
209
+ throw new error_translator_1.PynectNotInitializedError();
210
+ }
211
+ return _runtime.callIsolated(moduleName, functionName, args, options);
212
+ }
213
+ /**
214
+ * Evaluate a Python expression and return the result.
215
+ * Shorthand for `py.eval(expression)`.
216
+ *
217
+ * @example
218
+ * ```typescript
219
+ * const result = await evalPython('1 + 2 + 3');
220
+ * // result === 6
221
+ * ```
222
+ */
223
+ async function evalPython(expression) {
224
+ if (!_runtime) {
225
+ throw new error_translator_1.PynectNotInitializedError();
226
+ }
227
+ return _runtime.eval(expression);
228
+ }
229
+ /**
230
+ * Execute Python code (statements, not expressions).
231
+ * Shorthand for `py.exec(code)`.
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * await execPython(`
236
+ * import sys
237
+ * print(f"Python {sys.version}")
238
+ * `);
239
+ * ```
240
+ */
241
+ async function execPython(code) {
242
+ if (!_runtime) {
243
+ throw new error_translator_1.PynectNotInitializedError();
244
+ }
245
+ return _runtime.exec(code);
246
+ }
247
+ /**
248
+ * Run a Python script file.
249
+ */
250
+ async function runFile(filePath) {
251
+ if (!_runtime) {
252
+ throw new error_translator_1.PynectNotInitializedError();
253
+ }
254
+ return _runtime.runFile(filePath);
255
+ }
256
+ /**
257
+ * Install Python packages into the configured virtualenv.
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * await installPackages(['pandas', 'numpy>=1.24.0', 'scikit-learn']);
262
+ * ```
263
+ */
264
+ async function installPackages(packages) {
265
+ if (!_runtime) {
266
+ throw new error_translator_1.PynectNotInitializedError();
267
+ }
268
+ return _runtime.installPackages(packages);
269
+ }
270
+ /**
271
+ * Get memory statistics for the Python heap.
272
+ */
273
+ async function getMemoryStats() {
274
+ if (!_runtime) {
275
+ throw new error_translator_1.PynectNotInitializedError();
276
+ }
277
+ return _runtime.getMemoryStats();
278
+ }
279
+ /**
280
+ * Trigger Python garbage collection.
281
+ */
282
+ async function collectGarbage() {
283
+ if (!_runtime) {
284
+ throw new error_translator_1.PynectNotInitializedError();
285
+ }
286
+ return _runtime.collectGarbage();
287
+ }
288
+ // Auto-cleanup on process exit
289
+ let _cleanupRegistered = false;
290
+ function _registerCleanup() {
291
+ if (_cleanupRegistered) {
292
+ return;
293
+ }
294
+ _cleanupRegistered = true;
295
+ const cleanup = () => {
296
+ if (!_autoShutdownEnabled || !_runtime) {
297
+ return Promise.resolve();
298
+ }
299
+ return shutdown().catch(() => undefined);
300
+ };
301
+ process.on('beforeExit', cleanup);
302
+ process.on('exit', () => {
303
+ if (_autoShutdownEnabled && _runtime) {
304
+ try {
305
+ _runtime.shutdownSync();
306
+ }
307
+ catch {
308
+ // Process exit cleanup is best-effort.
309
+ }
310
+ }
311
+ });
312
+ }
313
+ // Exports
314
+ // Core
315
+ var py_runtime_2 = require("./core/py-runtime");
316
+ Object.defineProperty(exports, "PyRuntime", { enumerable: true, get: function () { return py_runtime_2.PyRuntime; } });
317
+ var py_proxy_1 = require("./core/py-proxy");
318
+ Object.defineProperty(exports, "PyProxy", { enumerable: true, get: function () { return py_proxy_1.PyProxy; } });
319
+ Object.defineProperty(exports, "PYNECT_WITH_OPTIONS", { enumerable: true, get: function () { return py_proxy_1.PYNECT_WITH_OPTIONS; } });
320
+ var py_module_1 = require("./core/py-module");
321
+ Object.defineProperty(exports, "PyModule", { enumerable: true, get: function () { return py_module_1.PyModule; } });
322
+ var py_callable_1 = require("./core/py-callable");
323
+ Object.defineProperty(exports, "PyCallable", { enumerable: true, get: function () { return py_callable_1.PyCallable; } });
324
+ var py_iterator_1 = require("./core/py-iterator");
325
+ Object.defineProperty(exports, "PyIterator", { enumerable: true, get: function () { return py_iterator_1.PyIterator; } });
326
+ var py_context_1 = require("./core/py-context");
327
+ Object.defineProperty(exports, "PyContext", { enumerable: true, get: function () { return py_context_1.PyContext; } });
328
+ var isolated_worker_1 = require("./core/isolated-worker");
329
+ Object.defineProperty(exports, "IsolatedWorker", { enumerable: true, get: function () { return isolated_worker_1.IsolatedWorker; } });
330
+ // Serialization
331
+ var serializer_1 = require("./serialization/serializer");
332
+ Object.defineProperty(exports, "Serializer", { enumerable: true, get: function () { return serializer_1.Serializer; } });
333
+ var numpy_bridge_1 = require("./serialization/numpy-bridge");
334
+ Object.defineProperty(exports, "NumpyBridge", { enumerable: true, get: function () { return numpy_bridge_1.NumpyBridge; } });
335
+ var data_frame_bridge_1 = require("./serialization/data-frame-bridge");
336
+ Object.defineProperty(exports, "DataFrameBridge", { enumerable: true, get: function () { return data_frame_bridge_1.DataFrameBridge; } });
337
+ // Error types
338
+ var error_translator_2 = require("./utils/error-translator");
339
+ Object.defineProperty(exports, "PythonError", { enumerable: true, get: function () { return error_translator_2.PythonError; } });
340
+ Object.defineProperty(exports, "PythonValueError", { enumerable: true, get: function () { return error_translator_2.PythonValueError; } });
341
+ Object.defineProperty(exports, "PythonTypeError", { enumerable: true, get: function () { return error_translator_2.PythonTypeError; } });
342
+ Object.defineProperty(exports, "PythonKeyError", { enumerable: true, get: function () { return error_translator_2.PythonKeyError; } });
343
+ Object.defineProperty(exports, "PythonIndexError", { enumerable: true, get: function () { return error_translator_2.PythonIndexError; } });
344
+ Object.defineProperty(exports, "PythonAttributeError", { enumerable: true, get: function () { return error_translator_2.PythonAttributeError; } });
345
+ Object.defineProperty(exports, "PythonImportError", { enumerable: true, get: function () { return error_translator_2.PythonImportError; } });
346
+ Object.defineProperty(exports, "PythonModuleNotFoundError", { enumerable: true, get: function () { return error_translator_2.PythonModuleNotFoundError; } });
347
+ Object.defineProperty(exports, "PythonFileNotFoundError", { enumerable: true, get: function () { return error_translator_2.PythonFileNotFoundError; } });
348
+ Object.defineProperty(exports, "PythonPermissionError", { enumerable: true, get: function () { return error_translator_2.PythonPermissionError; } });
349
+ Object.defineProperty(exports, "PythonRuntimeError", { enumerable: true, get: function () { return error_translator_2.PythonRuntimeError; } });
350
+ Object.defineProperty(exports, "PythonMemoryError", { enumerable: true, get: function () { return error_translator_2.PythonMemoryError; } });
351
+ Object.defineProperty(exports, "PythonStopIteration", { enumerable: true, get: function () { return error_translator_2.PythonStopIteration; } });
352
+ Object.defineProperty(exports, "PythonTimeoutError", { enumerable: true, get: function () { return error_translator_2.PythonTimeoutError; } });
353
+ Object.defineProperty(exports, "PynectNotInitializedError", { enumerable: true, get: function () { return error_translator_2.PynectNotInitializedError; } });
354
+ Object.defineProperty(exports, "PynectShutdownError", { enumerable: true, get: function () { return error_translator_2.PynectShutdownError; } });
355
+ Object.defineProperty(exports, "translatePythonError", { enumerable: true, get: function () { return error_translator_2.translatePythonError; } });
356
+ Object.defineProperty(exports, "isPythonError", { enumerable: true, get: function () { return error_translator_2.isPythonError; } });
357
+ Object.defineProperty(exports, "isPythonErrorOfType", { enumerable: true, get: function () { return error_translator_2.isPythonErrorOfType; } });
358
+ // Environment management
359
+ var python_detector_1 = require("./env/python-detector");
360
+ Object.defineProperty(exports, "PythonDetector", { enumerable: true, get: function () { return python_detector_1.PythonDetector; } });
361
+ var venv_manager_1 = require("./env/venv-manager");
362
+ Object.defineProperty(exports, "VenvManager", { enumerable: true, get: function () { return venv_manager_1.VenvManager; } });
363
+ var package_installer_1 = require("./env/package-installer");
364
+ Object.defineProperty(exports, "PackageInstaller", { enumerable: true, get: function () { return package_installer_1.PackageInstaller; } });
365
+ var project_environment_2 = require("./env/project-environment");
366
+ Object.defineProperty(exports, "createProjectPlan", { enumerable: true, get: function () { return project_environment_2.createProjectPlan; } });
367
+ Object.defineProperty(exports, "discoverPynectContributions", { enumerable: true, get: function () { return project_environment_2.discoverPynectContributions; } });
368
+ Object.defineProperty(exports, "moduleDispatcherIncludes", { enumerable: true, get: function () { return project_environment_2.moduleDispatcherIncludes; } });
369
+ Object.defineProperty(exports, "resolveExposedModule", { enumerable: true, get: function () { return project_environment_2.resolveExposedModule; } });
370
+ Object.defineProperty(exports, "syncProject", { enumerable: true, get: function () { return project_environment_2.syncProject; } });
371
+ Object.defineProperty(exports, "validateProjectEnvironment", { enumerable: true, get: function () { return project_environment_2.validateProjectEnvironment; } });
372
+ var project_1 = require("./config/project");
373
+ Object.defineProperty(exports, "CURRENT_PYNECT_SCHEMA_VERSION", { enumerable: true, get: function () { return project_1.CURRENT_PYNECT_SCHEMA_VERSION; } });
374
+ Object.defineProperty(exports, "resolveProjectConfig", { enumerable: true, get: function () { return project_1.resolveProjectConfig; } });
375
+ // Plugins
376
+ var plugin_manager_1 = require("./plugins/plugin-manager");
377
+ Object.defineProperty(exports, "PluginManager", { enumerable: true, get: function () { return plugin_manager_1.PluginManager; } });
378
+ // Default export
379
+ exports.default = {
380
+ init,
381
+ shutdown,
382
+ isInitialized,
383
+ getRuntime,
384
+ py: exports.py,
385
+ import: importModule,
386
+ callIsolated,
387
+ eval: evalPython,
388
+ exec: execPython,
389
+ runFile,
390
+ installPackages,
391
+ getMemoryStats,
392
+ collectGarbage,
393
+ };
394
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAkFH,oBAsBC;AA4BD,4BAYC;AAwBD,sCAEC;AAMD,gCAKC;AAqBD,oCAUC;AAGD,oCAQC;AAYD,gCAGC;AAcD,gCAGC;AAKD,0BAGC;AAUD,0CAGC;AAKD,wCAQC;AAKD,wCAGC;AAvSD,kDAA8C;AAC9C,2CAAwC;AACxC,+DAAqE;AAIrE,mEAAiE;AACjE,6CAAiD;AAEjD,+BAA+B;AAE/B,IAAI,QAAQ,GAAqB,IAAI,CAAC;AACtC,IAAI,oBAAoB,GAAG,IA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OAAA;AACvB,mDAAiD;AAAxC,2GAAA,WAAW,OAAA;AACpB,6DAA2D;AAAlD,qHAAA,gBAAgB,OAAA;AACzB,iEAOmC;AANjC,wHAAA,iBAAiB,OAAA;AACjB,kIAAA,2BAA2B,OAAA;AAC3B,+HAAA,wBAAwB,OAAA;AACxB,2HAAA,oBAAoB,OAAA;AACpB,kHAAA,WAAW,OAAA;AACX,iIAAA,0BAA0B,OAAA;AAE5B,4CAAuF;AAA9E,wHAAA,6BAA6B,OAAA;AAAE,+GAAA,oBAAoB,OAAA;AAE5D,UAAU;AACV,2DAAyD;AAAhD,+GAAA,aAAa,OAAA;AAgDtB,iBAAiB;AACjB,kBAAe;IACb,IAAI;IACJ,QAAQ;IACR,aAAa;IACb,UAAU;IACV,EAAE,EAAF,UAAE;IACF,MAAM,EAAE,YAAY;IACpB,YAAY;IACZ,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,OAAO;IACP,eAAe;IACf,cAAc;IACd,cAAc;CACf,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { NativeAddon } from '../types/addon';
2
+ export interface NativeAddonBuildOptions {
3
+ projectRoot: string;
4
+ pythonExecutable: string;
5
+ pythonLibrary: string;
6
+ pythonVersion: string;
7
+ }
8
+ /**
9
+ * Load a compatible packaged prebuild or exact local addon, compiling through
10
+ * the active JavaScript runtime only when neither can be used.
11
+ */
12
+ export declare function loadOrBuildNativeAddon(options: NativeAddonBuildOptions): NativeAddon;
13
+ //# sourceMappingURL=native-addon-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-addon-loader.d.ts","sourceRoot":"","sources":["../../src/native/native-addon-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,CAgDpF"}