@poe-platform/safe-bash 0.1.683 → 0.1.685
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/safe-bash/chunks/chunk-4MPK7VIM.js +519 -0
- package/dist/safe-bash/chunks/chunk-4MPK7VIM.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-6R7IR2MV.js → chunk-BONY6MX5.js} +731 -15
- package/dist/safe-bash/chunks/chunk-BONY6MX5.js.map +7 -0
- package/dist/safe-bash/commands/playwright/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/playwright/index.js +14 -2
- package/dist/safe-bash/commands/playwright/index.js.map +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +12 -2
- package/dist/safe-bash/commands/python/index.d.ts +5 -0
- package/dist/safe-bash/commands/python/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/python/index.js +15 -3
- package/dist/safe-bash/commands/python/index.js.map +1 -1
- package/dist/safe-bash/commands/python/jspi-assets.d.ts +14 -0
- package/dist/safe-bash/commands/python/jspi-assets.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/jspi-assets.js +51 -0
- package/dist/safe-bash/commands/python/jspi-assets.js.map +1 -0
- package/dist/safe-bash/commands/python/jspi-scheduler.d.ts +8 -0
- package/dist/safe-bash/commands/python/jspi-scheduler.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/jspi-scheduler.js +49 -0
- package/dist/safe-bash/commands/python/jspi-scheduler.js.map +1 -0
- package/dist/safe-bash/commands/python/jspi-trampoline.d.ts +5 -0
- package/dist/safe-bash/commands/python/jspi-trampoline.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/jspi-trampoline.js +90 -0
- package/dist/safe-bash/commands/python/jspi-trampoline.js.map +1 -0
- package/dist/safe-bash/commands/python/jspi.d.ts +22 -0
- package/dist/safe-bash/commands/python/jspi.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/jspi.js +295 -0
- package/dist/safe-bash/commands/python/jspi.js.map +1 -0
- package/dist/safe-bash/commands/python/runtime-scripts.d.ts +6 -0
- package/dist/safe-bash/commands/python/runtime-scripts.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/runtime-scripts.js +168 -0
- package/dist/safe-bash/commands/python/runtime-scripts.js.map +1 -0
- package/dist/safe-bash/commands/python/worker.browser.js +13 -368
- package/dist/safe-bash/commands/python/worker.browser.js.map +3 -3
- package/dist/safe-bash/commands/python/worker.d.ts.map +1 -1
- package/dist/safe-bash/commands/python/worker.js +6 -168
- package/dist/safe-bash/commands/python/worker.js.map +1 -1
- package/dist/safe-bash/core.browser.js +12 -2
- package/dist/safe-bash/core.browser.js.map +1 -1
- package/dist/safe-bash/playwright/ability-execution.d.ts +2 -0
- package/dist/safe-bash/playwright/ability-execution.d.ts.map +1 -1
- package/dist/safe-bash/playwright/ability-execution.js +10 -14
- package/dist/safe-bash/playwright/ability-execution.js.map +1 -1
- package/dist/safe-bash/playwright/command-budget.d.ts +5 -0
- package/dist/safe-bash/playwright/command-budget.d.ts.map +1 -0
- package/dist/safe-bash/playwright/command-budget.js +13 -0
- package/dist/safe-bash/playwright/command-budget.js.map +1 -0
- package/dist/safe-bash/playwright/controller.d.ts.map +1 -1
- package/dist/safe-bash/playwright/controller.js +44 -27
- package/dist/safe-bash/playwright/controller.js.map +1 -1
- package/dist/safe-bash/playwright/invocation.d.ts.map +1 -1
- package/dist/safe-bash/playwright/invocation.js +9 -6
- package/dist/safe-bash/playwright/invocation.js.map +1 -1
- package/dist/safe-bash/playwright/native-evaluation.d.ts +10 -0
- package/dist/safe-bash/playwright/native-evaluation.d.ts.map +1 -0
- package/dist/safe-bash/playwright/native-evaluation.js +243 -0
- package/dist/safe-bash/playwright/native-evaluation.js.map +1 -0
- package/dist/safe-bash/playwright/response.d.ts +5 -0
- package/dist/safe-bash/playwright/response.d.ts.map +1 -1
- package/dist/safe-bash/playwright/response.js +8 -3
- package/dist/safe-bash/playwright/response.js.map +1 -1
- package/dist/safe-bash/playwright/route-capabilities.d.ts.map +1 -1
- package/dist/safe-bash/playwright/route-capabilities.js +23 -5
- package/dist/safe-bash/playwright/route-capabilities.js.map +1 -1
- package/dist/safe-bash/playwright/standard-capabilities.d.ts.map +1 -1
- package/dist/safe-bash/playwright/standard-capabilities.js +17 -36
- package/dist/safe-bash/playwright/standard-capabilities.js.map +1 -1
- package/package.json +2 -2
- package/dist/safe-bash/chunks/chunk-3G3EZZ63.js +0 -145
- package/dist/safe-bash/chunks/chunk-3G3EZZ63.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-6R7IR2MV.js.map +0 -7
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { createPythonNativeSyscalls } from "@poe-platform/safe-fs/core";
|
|
2
|
+
import { PythonFailure } from './diagnostics.js';
|
|
3
|
+
import { parsePythonInvocation } from './invocation.js';
|
|
4
|
+
import { pythonExecution } from './execution.js';
|
|
5
|
+
import { pythonJspiSignatures } from './jspi-trampoline.js';
|
|
6
|
+
import { createPythonJspiScheduler } from './jspi-scheduler.js';
|
|
7
|
+
import { pythonRuntimeRelocation, pythonImportMetadata, pythonDirectoryEntries, pythonStatProjection, pythonTreeCleanup } from './runtime-scripts.js';
|
|
8
|
+
export function createPythonJspiExecutor(options) {
|
|
9
|
+
const engine = globalThis.WebAssembly;
|
|
10
|
+
const active = new engine.Global({ value: 'i32', mutable: true }, 0);
|
|
11
|
+
const syncify = new engine.Table({ element: 'anyfunc', initial: 1 });
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const scheduler = createPythonJspiScheduler();
|
|
14
|
+
let admitted = false;
|
|
15
|
+
let running;
|
|
16
|
+
let retirement;
|
|
17
|
+
let cleanup;
|
|
18
|
+
let runtime;
|
|
19
|
+
let native;
|
|
20
|
+
let instanceBound = false;
|
|
21
|
+
let importsBound = false;
|
|
22
|
+
let schedulerBound = false;
|
|
23
|
+
let methodDefinition = 0;
|
|
24
|
+
let methodPointer;
|
|
25
|
+
let statPointer;
|
|
26
|
+
const originals = {};
|
|
27
|
+
const execute = async (start) => {
|
|
28
|
+
const signal = AbortSignal.any([start.signal, controller.signal]);
|
|
29
|
+
const configuration = parsePythonInvocation(start.invocation.args, start.invocation.env);
|
|
30
|
+
let qualified = false;
|
|
31
|
+
let exitCode = 0;
|
|
32
|
+
let finalized = 0;
|
|
33
|
+
try {
|
|
34
|
+
signal.throwIfAborted();
|
|
35
|
+
if (start.packages?.requirements.length || start.installOnly)
|
|
36
|
+
throw new PythonFailure('runtime-assets', { cause: new Error('JSPI runtime requires statically qualified packages') });
|
|
37
|
+
runtime = await options.loadRuntime({ jsglobals: Object.create(null),
|
|
38
|
+
args: configuration.startupArgs, env: configuration.env,
|
|
39
|
+
bindImports(imports) {
|
|
40
|
+
if (importsBound)
|
|
41
|
+
throw new PythonFailure('runtime-abi');
|
|
42
|
+
const namespaces = [...new Set(Object.values(imports))];
|
|
43
|
+
for (const namespace of namespaces) {
|
|
44
|
+
for (const [name, value] of Object.entries(namespace)) {
|
|
45
|
+
if (typeof value !== 'function')
|
|
46
|
+
continue;
|
|
47
|
+
if (name in pythonJspiSignatures)
|
|
48
|
+
originals[name] = value;
|
|
49
|
+
else if (name.startsWith('__syscall_') || name === '_maybe_connect_async')
|
|
50
|
+
namespace[name] = () => -52;
|
|
51
|
+
else if (name === '_emscripten_system')
|
|
52
|
+
namespace[name] = (command) => command === 0 ? 0 : -52;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!originals.fd_read || !originals.fd_write || !originals.__syscall_openat)
|
|
56
|
+
throw new PythonFailure('runtime-abi');
|
|
57
|
+
const original = Object.fromEntries(Object.keys(pythonJspiSignatures).map(name => [name, originals[name] ?? (() => -52)]));
|
|
58
|
+
const request = Object.fromEntries(Object.keys(pythonJspiSignatures).map(name => [name,
|
|
59
|
+
(...args) => native.invoke(name, args)]));
|
|
60
|
+
const shutdown = Object.fromEntries(Object.entries(request).map(([name, dispatch]) => [name, new engine.Suspending(dispatch)]));
|
|
61
|
+
const bridge = new engine.Instance(options.trampoline, { original, request, shutdown, control: { active, syncify } });
|
|
62
|
+
for (const namespace of namespaces)
|
|
63
|
+
for (const name of Object.keys(originals)) {
|
|
64
|
+
if (typeof namespace[name] === 'function')
|
|
65
|
+
namespace[name] = bridge.exports[name];
|
|
66
|
+
}
|
|
67
|
+
importsBound = true;
|
|
68
|
+
},
|
|
69
|
+
bindInstance(instance) {
|
|
70
|
+
if (instanceBound || !importsBound || typeof instance.exports.syscall_syncify !== 'function')
|
|
71
|
+
throw new PythonFailure('runtime-abi');
|
|
72
|
+
syncify.set(0, instance.exports.syscall_syncify);
|
|
73
|
+
instanceBound = true;
|
|
74
|
+
},
|
|
75
|
+
bindScheduler(api) {
|
|
76
|
+
if (schedulerBound)
|
|
77
|
+
throw new PythonFailure('runtime-abi');
|
|
78
|
+
api.scheduleCallback = scheduler.scheduleCallback;
|
|
79
|
+
schedulerBound = true;
|
|
80
|
+
}, });
|
|
81
|
+
if (!importsBound || !instanceBound || !schedulerBound || runtime.version !== '314.0.6' || !runtime._module.jspiSupported)
|
|
82
|
+
throw new PythonFailure('runtime-abi');
|
|
83
|
+
qualified = true;
|
|
84
|
+
signal.throwIfAborted();
|
|
85
|
+
runtime.runPython('import sys, os, json, runpy, traceback, types, warnings, textwrap, io, struct, linecache, importlib.machinery, shutil, stat, pyodide.ffi');
|
|
86
|
+
runtime.globals.set('_safe_runtime_mount', start.runtimeMount);
|
|
87
|
+
const filesystem = runtime.FS;
|
|
88
|
+
const bootstrap = filesystem.root;
|
|
89
|
+
filesystem.root = null;
|
|
90
|
+
filesystem.mount(filesystem.filesystems.MEMFS, {}, '/');
|
|
91
|
+
filesystem.mkdir(start.runtimeMount);
|
|
92
|
+
filesystem.mount({ mount: () => bootstrap }, {}, start.runtimeMount);
|
|
93
|
+
runtime.runPython(pythonRuntimeRelocation);
|
|
94
|
+
filesystem.currentPath = start.invocation.cwd;
|
|
95
|
+
native = createPythonNativeSyscalls({ runtime: runtime._module, cwd: start.invocation.cwd,
|
|
96
|
+
runtimeMount: start.runtimeMount, maxTransferBytes: start.maxTransferBytes, signal,
|
|
97
|
+
dispatch: start.dispatch, original: (name, args) => originals[name](...args) });
|
|
98
|
+
const errno = JSON.parse(runtime.runPython("__import__('json').dumps({name:value for name,value in vars(__import__('errno')).items() if name.startswith('E') and isinstance(value,int)})"));
|
|
99
|
+
const encode = async (operation) => {
|
|
100
|
+
try {
|
|
101
|
+
return JSON.stringify(await operation());
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return JSON.stringify({ errno: signal.aborted ? errno.EINTR : error.errno ?? errno[error.code ?? ''] ?? errno.EIO });
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const absolute = (path) => path.startsWith('/') ? path : filesystem.cwd() + '/' + path;
|
|
108
|
+
const bootstrapPath = (path) => path === start.runtimeMount || path.startsWith(start.runtimeMount + '/');
|
|
109
|
+
const module = runtime._module;
|
|
110
|
+
const send = async (pointer) => {
|
|
111
|
+
let response = await encode(async () => {
|
|
112
|
+
signal.throwIfAborted();
|
|
113
|
+
const [operation, path, follow] = JSON.parse(module.UTF8ToString(pointer, 16384));
|
|
114
|
+
if (operation === 'stat')
|
|
115
|
+
return native.metadata(path, follow);
|
|
116
|
+
if (typeof path !== 'string')
|
|
117
|
+
throw Object.assign(new Error('Invalid native Python path'), { code: 'EINVAL' });
|
|
118
|
+
const target = absolute(path);
|
|
119
|
+
if (operation === 'directory') {
|
|
120
|
+
const entries = bootstrapPath(target) ? filesystem.readdir(target).filter((name) => name !== '.' && name !== '..')
|
|
121
|
+
: (await start.dispatch({ op: 'readdir', args: [target] })).map(entry => entry.name);
|
|
122
|
+
return { entries };
|
|
123
|
+
}
|
|
124
|
+
if (operation === 'tree') {
|
|
125
|
+
if (bootstrapPath(target) || !await start.dispatch({ op: 'rmtreeSupported', args: [target] }))
|
|
126
|
+
return { supported: false };
|
|
127
|
+
try {
|
|
128
|
+
await start.dispatch({ op: 'rmtree', args: [target] });
|
|
129
|
+
return { supported: true };
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
return { supported: true, errno: errno[error.code ?? ''] ?? errno.EIO };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
throw Object.assign(new Error('Invalid native Python operation'), { code: 'EINVAL' });
|
|
136
|
+
});
|
|
137
|
+
if (response.length > 1048576)
|
|
138
|
+
response = JSON.stringify({ errno: errno.EFBIG });
|
|
139
|
+
let bytes = new TextEncoder().encode(response);
|
|
140
|
+
if (bytes.length > 1048576)
|
|
141
|
+
bytes = new TextEncoder().encode(JSON.stringify({ errno: errno.EFBIG }));
|
|
142
|
+
const output = module._malloc(bytes.length + 1);
|
|
143
|
+
if (!output)
|
|
144
|
+
return 0;
|
|
145
|
+
module.HEAPU8.set(bytes, output);
|
|
146
|
+
module.HEAPU8[output + bytes.length] = 0;
|
|
147
|
+
return output;
|
|
148
|
+
};
|
|
149
|
+
const nativeCall = new engine.Instance(options.nativeCall, {
|
|
150
|
+
python: { utf8: module._PyUnicode_AsUTF8, unicode: module._PyUnicode_FromString,
|
|
151
|
+
free: module._free, noMemory: module._PyErr_NoMemory },
|
|
152
|
+
request: { send }, shutdown: { send: new engine.Suspending(send) }, control: { active, syncify },
|
|
153
|
+
});
|
|
154
|
+
methodPointer = module.addFunction(nativeCall.exports.call, 'iii');
|
|
155
|
+
methodDefinition = module._malloc(128);
|
|
156
|
+
if (!methodDefinition)
|
|
157
|
+
throw new PythonFailure('runtime-assets');
|
|
158
|
+
module.HEAPU8.fill(0, methodDefinition, methodDefinition + 128);
|
|
159
|
+
module.HEAPU8.set(new TextEncoder().encode('request\0_safe_native_fs\0'), methodDefinition + 16);
|
|
160
|
+
module.HEAPU32.set([methodDefinition + 16, methodPointer, 8, 0], methodDefinition / 4);
|
|
161
|
+
const extension = module._PyImport_AddModule(methodDefinition + 24);
|
|
162
|
+
const callable = module._PyCFunction_NewEx(methodDefinition, 0, 0);
|
|
163
|
+
if (!extension || !callable || module._PyModule_AddObject(extension, methodDefinition + 16, callable) < 0)
|
|
164
|
+
throw new PythonFailure('runtime-abi');
|
|
165
|
+
const fields = Number(runtime.runPython('os.stat_result.n_fields'));
|
|
166
|
+
const statResult = new engine.Instance(options.statResult, { python: {
|
|
167
|
+
fields: new engine.Global({ value: 'i32' }, fields), create: module._PyStructSequence_New,
|
|
168
|
+
size: module._PyTuple_Size, item: module._PyTuple_GetItem, retain: module._Py_IncRef,
|
|
169
|
+
set: module._PyStructSequence_SetItem, invalid: module._PyErr_BadArgument,
|
|
170
|
+
} });
|
|
171
|
+
statPointer = module.addFunction(statResult.exports.construct, 'iii');
|
|
172
|
+
module.HEAPU8.set(new TextEncoder().encode('stat_result\0os\0'), methodDefinition + 80);
|
|
173
|
+
module.HEAPU32.set([methodDefinition + 80, statPointer, 8, 0], (methodDefinition + 64) / 4);
|
|
174
|
+
const osModule = module._PyImport_AddModule(methodDefinition + 92);
|
|
175
|
+
const statType = module._PyObject_GetAttrString(osModule, methodDefinition + 80);
|
|
176
|
+
const constructStat = module._PyCFunction_NewEx(methodDefinition + 64, statType, 0);
|
|
177
|
+
module._Py_DecRef(statType);
|
|
178
|
+
if (!constructStat || module._PyModule_AddObject(extension, methodDefinition + 80, constructStat) < 0)
|
|
179
|
+
throw new PythonFailure('runtime-abi');
|
|
180
|
+
runtime.runPython(`
|
|
181
|
+
from _safe_native_fs import request as _safe_native_request
|
|
182
|
+
def _safe_stat_projection(path, follow):
|
|
183
|
+
return _safe_native_request(json.dumps(['stat', path, follow]))
|
|
184
|
+
def _safe_import_stat(path):
|
|
185
|
+
return _safe_stat_projection(path, True)
|
|
186
|
+
def _safe_directory_entries(path):
|
|
187
|
+
return _safe_native_request(json.dumps(['directory', path]))
|
|
188
|
+
def _safe_tree_cleanup(path):
|
|
189
|
+
return _safe_native_request(json.dumps(['tree', path]))
|
|
190
|
+
`);
|
|
191
|
+
for (const script of [pythonImportMetadata, pythonDirectoryEntries, pythonStatProjection, pythonTreeCleanup])
|
|
192
|
+
runtime.runPython(script);
|
|
193
|
+
runtime.runPython(`
|
|
194
|
+
from _safe_native_fs import stat_result as _safe_construct_stat
|
|
195
|
+
_safe_stat_fields = os.stat_result.n_fields
|
|
196
|
+
_safe_stat_probe = os.stat_result(tuple(range(_safe_stat_fields)))
|
|
197
|
+
_safe_stat_indexes = {name: getattr(_safe_stat_probe, name) for name in dir(_safe_stat_probe) if name.startswith('st_')}
|
|
198
|
+
def _safe_native_stat_type(values, extras):
|
|
199
|
+
fields = list(values) + [None] * (_safe_stat_fields - len(values))
|
|
200
|
+
for name, value in extras.items():
|
|
201
|
+
if name in _safe_stat_indexes:
|
|
202
|
+
fields[_safe_stat_indexes[name]] = value
|
|
203
|
+
return _safe_construct_stat(tuple(fields))
|
|
204
|
+
_safe_stat_type = _safe_native_stat_type
|
|
205
|
+
`);
|
|
206
|
+
runtime.globals.set('_safe_invocation_json', JSON.stringify(start.invocation));
|
|
207
|
+
runtime.globals.set('_safe_execution_code', pythonExecution);
|
|
208
|
+
runtime.globals.set('_safe_is_cancelled', () => signal.aborted);
|
|
209
|
+
active.value = 1;
|
|
210
|
+
start.onReady();
|
|
211
|
+
exitCode = Number(await runtime.runPythonAsync(`
|
|
212
|
+
try:
|
|
213
|
+
exec(_safe_execution_code)
|
|
214
|
+
except BaseException:
|
|
215
|
+
if not _safe_is_cancelled():
|
|
216
|
+
raise
|
|
217
|
+
_safe_exit = 130
|
|
218
|
+
_safe_exit
|
|
219
|
+
`)) & 255;
|
|
220
|
+
}
|
|
221
|
+
finally {
|
|
222
|
+
try {
|
|
223
|
+
if (qualified) {
|
|
224
|
+
try {
|
|
225
|
+
await runtime.runPythonAsync(`
|
|
226
|
+
import asyncio as _safe_asyncio
|
|
227
|
+
async def _safe_quiesce_tasks():
|
|
228
|
+
current = _safe_asyncio.current_task()
|
|
229
|
+
while True:
|
|
230
|
+
pending = [task for task in _safe_asyncio.all_tasks() if task is not current]
|
|
231
|
+
if not pending:
|
|
232
|
+
break
|
|
233
|
+
for task in pending:
|
|
234
|
+
task.cancel()
|
|
235
|
+
await _safe_asyncio.gather(*pending, return_exceptions=True)
|
|
236
|
+
loop = _safe_asyncio.get_running_loop()
|
|
237
|
+
await loop.shutdown_asyncgens()
|
|
238
|
+
await loop.shutdown_default_executor()
|
|
239
|
+
await _safe_quiesce_tasks()
|
|
240
|
+
`);
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
try {
|
|
244
|
+
await scheduler.close();
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
active.value = native ? 2 : 0;
|
|
248
|
+
finalized = Number(await engine.promising(runtime._module._Py_FinalizeEx)());
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
active.value = 0;
|
|
255
|
+
cleanup = scheduler.close().finally(() => native?.close());
|
|
256
|
+
try {
|
|
257
|
+
await cleanup;
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
if (methodDefinition)
|
|
261
|
+
runtime?._module._free(methodDefinition);
|
|
262
|
+
if (methodPointer !== undefined)
|
|
263
|
+
runtime?._module.removeFunction(methodPointer);
|
|
264
|
+
if (statPointer !== undefined)
|
|
265
|
+
runtime?._module.removeFunction(statPointer);
|
|
266
|
+
runtime = undefined;
|
|
267
|
+
native = undefined;
|
|
268
|
+
syncify.set(0, null);
|
|
269
|
+
for (const name of Object.keys(originals))
|
|
270
|
+
delete originals[name];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
signal.throwIfAborted();
|
|
275
|
+
return finalized < 0 ? 120 : exitCode;
|
|
276
|
+
};
|
|
277
|
+
return {
|
|
278
|
+
run(start) {
|
|
279
|
+
if (admitted || retirement)
|
|
280
|
+
return Promise.reject(new PythonFailure('executor-unavailable'));
|
|
281
|
+
admitted = true;
|
|
282
|
+
running = execute(start);
|
|
283
|
+
return running;
|
|
284
|
+
},
|
|
285
|
+
terminate() {
|
|
286
|
+
retirement ??= (async () => {
|
|
287
|
+
controller.abort();
|
|
288
|
+
await running?.catch(() => { });
|
|
289
|
+
await cleanup;
|
|
290
|
+
})();
|
|
291
|
+
return retirement;
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=jspi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jspi.js","sourceRoot":"","sources":["../../../src/commands/python/jspi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAA2B,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkBtJ,MAAM,UAAU,wBAAwB,CAAC,OAAkC;IACzE,MAAM,MAAM,GAAI,UAAkB,CAAC,WAAW,CAAC;IAC/C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,EAAC,KAAK,EAAC,KAAK,EAAE,OAAO,EAAC,IAAI,EAAC,EAAE,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,EAAC,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,CAAC,EAAC,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,yBAAyB,EAAE,CAAC;IAC9C,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,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AS,CAAC;oBACpB,MAAM,GAAG,SAAS,CAAC;oBACnB,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;oBACrB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;wBAAE,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,OAAO,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxC,CAAC,CAAC;IACF,OAAO;QACL,GAAG,CAAC,KAAK;YACP,IAAI,QAAQ,IAAI,UAAU;gBAAE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,sBAAsB,CAAC,CAAC,CAAC;YAC7F,QAAQ,GAAG,IAAI,CAAC;YAChB,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YACzB,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,SAAS;YACP,UAAU,KAAK,CAAC,KAAK,IAAI,EAAE;gBACzB,UAAU,CAAC,KAAK,EAAE,CAAC;gBACnB,MAAM,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;gBAC/B,MAAM,OAAO,CAAC;YAChB,CAAC,CAAC,EAAE,CAAC;YACL,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const pythonRuntimeRelocation = "\nimport sys, zipimport, importlib.machinery\n\ndef _rebase_runtime_path(value):\n return _safe_runtime_mount + value if isinstance(value, str) and (value == '/lib' or value.startswith('/lib/')) else value\n\ndef _rebase_runtime_loader(loader):\n if isinstance(loader, zipimport.zipimporter):\n archive = _rebase_runtime_path(loader.archive)\n if archive != loader.archive:\n return zipimport.zipimporter(archive + '/' + loader.prefix)\n elif isinstance(loader, (importlib.machinery.SourceFileLoader, importlib.machinery.SourcelessFileLoader, importlib.machinery.ExtensionFileLoader)):\n path = _rebase_runtime_path(loader.path)\n if path != loader.path:\n return type(loader)(loader.name, path)\n return loader\nsys.path[:] = [_rebase_runtime_path(value) for value in sys.path]\nfor _module in list(sys.modules.values()):\n if _module is None:\n continue\n for _attribute in ('__file__', '__cached__'):\n if hasattr(_module, _attribute):\n setattr(_module, _attribute, _rebase_runtime_path(getattr(_module, _attribute)))\n if hasattr(_module, '__path__'):\n _module.__path__ = [_rebase_runtime_path(value) for value in _module.__path__]\n if hasattr(_module, '__loader__'):\n _module.__loader__ = _rebase_runtime_loader(_module.__loader__)\n _spec = getattr(_module, '__spec__', None)\n if _spec is not None:\n _spec.origin = _rebase_runtime_path(_spec.origin)\n _spec.loader = _rebase_runtime_loader(_spec.loader)\n if _spec.submodule_search_locations is not None:\n _spec.submodule_search_locations = [_rebase_runtime_path(value) for value in _spec.submodule_search_locations]\nsys.path_importer_cache.clear()\n";
|
|
2
|
+
export declare const pythonImportMetadata = "\nimport importlib._bootstrap_external, types, json\n_safe_import_stat_callback = _safe_import_stat\n_safe_original_import_stat = importlib._bootstrap_external._path_stat\ndef _safe_import_path_stat(path):\n if path == _safe_runtime_mount or path.startswith(_safe_runtime_mount + '/'):\n return _safe_original_import_stat(path)\n value = json.loads(_safe_import_stat_callback(path))\n if 'errno' in value:\n raise OSError(value['errno'], 'filesystem import metadata unavailable', path)\n return types.SimpleNamespace(st_mode=value['mode'], st_size=value['size'], st_mtime=value['mtimeMs'] / 1000)\nimportlib._bootstrap_external._path_stat = _safe_import_path_stat\n";
|
|
3
|
+
export declare const pythonDirectoryEntries = "\nimport os, json, errno\n_safe_directory_callback = _safe_directory_entries\ndef _safe_listdir(path='.'):\n if isinstance(path, int):\n raise OSError(errno.ENOTSUP, 'retained directory descriptors are unsupported')\n original = os.fspath(path) if path is not None else '.'\n value = json.loads(_safe_directory_callback(os.fsdecode(original)))\n if 'errno' in value:\n raise OSError(value['errno'], 'directory enumeration failed', path)\n return [os.fsencode(name) for name in value['entries']] if isinstance(original, bytes) else value['entries']\nos.listdir = _safe_listdir\n# The frozen importer holds the posix module separately from os.\nimportlib._bootstrap_external._os.listdir = _safe_listdir\n";
|
|
4
|
+
export declare const pythonStatProjection = "\nimport os, json, errno\n_safe_stat_callback = _safe_stat_projection\n_safe_stat_type = os.stat_result\n_safe_fspath = os.fspath\n_safe_fsdecode = os.fsdecode\n\ndef _safe_stat(path, *, dir_fd=None, follow_symlinks=True):\n if dir_fd is not None:\n raise OSError(errno.ENOTSUP, 'dir_fd metadata is unsupported')\n if isinstance(path, int):\n if not follow_symlinks:\n raise ValueError('stat: cannot use fd and follow_symlinks together')\n else:\n path = _safe_fsdecode(_safe_fspath(path))\n value = json.loads(_safe_stat_callback(path, follow_symlinks))\n if 'errno' in value:\n raise OSError(value['errno'], 'filesystem metadata unavailable', path)\n keys = ('mode','ino','dev','nlink','uid','gid','size')\n if any(key not in value for key in keys):\n raise OSError(errno.EOVERFLOW, 'canonical identity or required stat metadata unavailable', path)\n times = [value[key] / 1000 for key in ('atimeMs','mtimeMs','ctimeMs')]\n extras = dict(zip(('st_atime','st_mtime','st_ctime'), times))\n for name, milliseconds in zip(('atime','mtime','ctime'), (value['atimeMs'],value['mtimeMs'],value['ctimeMs'])):\n seconds = int(milliseconds // 1000)\n extras['st_' + name + '_ns'] = seconds * 1000000000 + round((milliseconds - seconds * 1000) * 1000000)\n for key in ('blocks','blksize','rdev'):\n if key in value:\n extras['st_' + key] = value[key]\n return _safe_stat_type(tuple(value[key] for key in keys) + tuple(int(time // 1) for time in times), extras)\n\ndef _safe_lstat(path, *, dir_fd=None):\n return _safe_stat(path, dir_fd=dir_fd, follow_symlinks=False)\n\ndef _safe_fstat(fd):\n if not isinstance(fd, int):\n raise TypeError('file descriptor must be an integer')\n return _safe_stat(fd)\nos.stat = _safe_stat\nos.lstat = _safe_lstat\nos.fstat = _safe_fstat\nimport stat as _safe_stat_module\nclass _SafeDirEntry:\n def __init__(self, root, name):\n self.name = name\n self.path = os.path.join(root, name)\n self._cache = {}\n def __fspath__(self):\n return self.path\n def stat(self, *, follow_symlinks=True):\n if follow_symlinks not in self._cache:\n self._cache[follow_symlinks] = os.stat(self.path, follow_symlinks=follow_symlinks)\n return self._cache[follow_symlinks]\n def inode(self):\n return self.stat(follow_symlinks=False).st_ino\n def is_dir(self, *, follow_symlinks=True):\n try:\n return _safe_stat_module.S_ISDIR(self.stat(follow_symlinks=follow_symlinks).st_mode)\n except FileNotFoundError:\n return False\n def is_file(self, *, follow_symlinks=True):\n try:\n return _safe_stat_module.S_ISREG(self.stat(follow_symlinks=follow_symlinks).st_mode)\n except FileNotFoundError:\n return False\n def is_symlink(self):\n try:\n return _safe_stat_module.S_ISLNK(self.stat(follow_symlinks=False).st_mode)\n except FileNotFoundError:\n return False\nclass _SafeScandir:\n def __init__(self, path):\n self._entries = iter([_SafeDirEntry(path, name) for name in os.listdir(path)])\n def __iter__(self):\n return self\n def __next__(self):\n return next(self._entries)\n def close(self):\n self._entries = iter(())\n def __enter__(self):\n return self\n def __exit__(self, *args):\n self.close()\ndef _safe_scandir(path='.'):\n if isinstance(path, int):\n raise OSError(errno.ENOTSUP, 'retained directory descriptors are unsupported')\n return _SafeScandir(os.fspath(path) if path is not None else '.')\nos.scandir = _safe_scandir\n\n";
|
|
5
|
+
export declare const pythonTreeCleanup = "\nimport shutil, os, json\n_safe_tree_callback = _safe_tree_cleanup\n_safe_original_rmtree_impl = shutil._rmtree_impl\ndef _safe_rmtree_impl(path, dir_fd, onexc):\n if dir_fd is not None:\n return _safe_original_rmtree_impl(path, dir_fd, onexc)\n value = json.loads(_safe_tree_callback(os.fsdecode(path)))\n if not value['supported']:\n return _safe_original_rmtree_impl(path, dir_fd, onexc)\n if 'errno' in value:\n onexc(os.rmdir, path, OSError(value['errno'], 'directory cleanup failed', path))\nshutil._rmtree_impl = _safe_rmtree_impl\n";
|
|
6
|
+
//# sourceMappingURL=runtime-scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-scripts.d.ts","sourceRoot":"","sources":["../../../src/commands/python/runtime-scripts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,smDAkCnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,gqBAYhC,CAAC;AAEF,eAAO,MAAM,sBAAsB,qsBAclC,CAAC;AAEF,eAAO,MAAM,oBAAoB,o0GAyFhC,CAAC;AAEF,eAAO,MAAM,iBAAiB,oiBAa7B,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
export const pythonRuntimeRelocation = `
|
|
2
|
+
import sys, zipimport, importlib.machinery
|
|
3
|
+
|
|
4
|
+
def _rebase_runtime_path(value):
|
|
5
|
+
return _safe_runtime_mount + value if isinstance(value, str) and (value == '/lib' or value.startswith('/lib/')) else value
|
|
6
|
+
|
|
7
|
+
def _rebase_runtime_loader(loader):
|
|
8
|
+
if isinstance(loader, zipimport.zipimporter):
|
|
9
|
+
archive = _rebase_runtime_path(loader.archive)
|
|
10
|
+
if archive != loader.archive:
|
|
11
|
+
return zipimport.zipimporter(archive + '/' + loader.prefix)
|
|
12
|
+
elif isinstance(loader, (importlib.machinery.SourceFileLoader, importlib.machinery.SourcelessFileLoader, importlib.machinery.ExtensionFileLoader)):
|
|
13
|
+
path = _rebase_runtime_path(loader.path)
|
|
14
|
+
if path != loader.path:
|
|
15
|
+
return type(loader)(loader.name, path)
|
|
16
|
+
return loader
|
|
17
|
+
sys.path[:] = [_rebase_runtime_path(value) for value in sys.path]
|
|
18
|
+
for _module in list(sys.modules.values()):
|
|
19
|
+
if _module is None:
|
|
20
|
+
continue
|
|
21
|
+
for _attribute in ('__file__', '__cached__'):
|
|
22
|
+
if hasattr(_module, _attribute):
|
|
23
|
+
setattr(_module, _attribute, _rebase_runtime_path(getattr(_module, _attribute)))
|
|
24
|
+
if hasattr(_module, '__path__'):
|
|
25
|
+
_module.__path__ = [_rebase_runtime_path(value) for value in _module.__path__]
|
|
26
|
+
if hasattr(_module, '__loader__'):
|
|
27
|
+
_module.__loader__ = _rebase_runtime_loader(_module.__loader__)
|
|
28
|
+
_spec = getattr(_module, '__spec__', None)
|
|
29
|
+
if _spec is not None:
|
|
30
|
+
_spec.origin = _rebase_runtime_path(_spec.origin)
|
|
31
|
+
_spec.loader = _rebase_runtime_loader(_spec.loader)
|
|
32
|
+
if _spec.submodule_search_locations is not None:
|
|
33
|
+
_spec.submodule_search_locations = [_rebase_runtime_path(value) for value in _spec.submodule_search_locations]
|
|
34
|
+
sys.path_importer_cache.clear()
|
|
35
|
+
`;
|
|
36
|
+
export const pythonImportMetadata = `
|
|
37
|
+
import importlib._bootstrap_external, types, json
|
|
38
|
+
_safe_import_stat_callback = _safe_import_stat
|
|
39
|
+
_safe_original_import_stat = importlib._bootstrap_external._path_stat
|
|
40
|
+
def _safe_import_path_stat(path):
|
|
41
|
+
if path == _safe_runtime_mount or path.startswith(_safe_runtime_mount + '/'):
|
|
42
|
+
return _safe_original_import_stat(path)
|
|
43
|
+
value = json.loads(_safe_import_stat_callback(path))
|
|
44
|
+
if 'errno' in value:
|
|
45
|
+
raise OSError(value['errno'], 'filesystem import metadata unavailable', path)
|
|
46
|
+
return types.SimpleNamespace(st_mode=value['mode'], st_size=value['size'], st_mtime=value['mtimeMs'] / 1000)
|
|
47
|
+
importlib._bootstrap_external._path_stat = _safe_import_path_stat
|
|
48
|
+
`;
|
|
49
|
+
export const pythonDirectoryEntries = `
|
|
50
|
+
import os, json, errno
|
|
51
|
+
_safe_directory_callback = _safe_directory_entries
|
|
52
|
+
def _safe_listdir(path='.'):
|
|
53
|
+
if isinstance(path, int):
|
|
54
|
+
raise OSError(errno.ENOTSUP, 'retained directory descriptors are unsupported')
|
|
55
|
+
original = os.fspath(path) if path is not None else '.'
|
|
56
|
+
value = json.loads(_safe_directory_callback(os.fsdecode(original)))
|
|
57
|
+
if 'errno' in value:
|
|
58
|
+
raise OSError(value['errno'], 'directory enumeration failed', path)
|
|
59
|
+
return [os.fsencode(name) for name in value['entries']] if isinstance(original, bytes) else value['entries']
|
|
60
|
+
os.listdir = _safe_listdir
|
|
61
|
+
# The frozen importer holds the posix module separately from os.
|
|
62
|
+
importlib._bootstrap_external._os.listdir = _safe_listdir
|
|
63
|
+
`;
|
|
64
|
+
export const pythonStatProjection = `
|
|
65
|
+
import os, json, errno
|
|
66
|
+
_safe_stat_callback = _safe_stat_projection
|
|
67
|
+
_safe_stat_type = os.stat_result
|
|
68
|
+
_safe_fspath = os.fspath
|
|
69
|
+
_safe_fsdecode = os.fsdecode
|
|
70
|
+
|
|
71
|
+
def _safe_stat(path, *, dir_fd=None, follow_symlinks=True):
|
|
72
|
+
if dir_fd is not None:
|
|
73
|
+
raise OSError(errno.ENOTSUP, 'dir_fd metadata is unsupported')
|
|
74
|
+
if isinstance(path, int):
|
|
75
|
+
if not follow_symlinks:
|
|
76
|
+
raise ValueError('stat: cannot use fd and follow_symlinks together')
|
|
77
|
+
else:
|
|
78
|
+
path = _safe_fsdecode(_safe_fspath(path))
|
|
79
|
+
value = json.loads(_safe_stat_callback(path, follow_symlinks))
|
|
80
|
+
if 'errno' in value:
|
|
81
|
+
raise OSError(value['errno'], 'filesystem metadata unavailable', path)
|
|
82
|
+
keys = ('mode','ino','dev','nlink','uid','gid','size')
|
|
83
|
+
if any(key not in value for key in keys):
|
|
84
|
+
raise OSError(errno.EOVERFLOW, 'canonical identity or required stat metadata unavailable', path)
|
|
85
|
+
times = [value[key] / 1000 for key in ('atimeMs','mtimeMs','ctimeMs')]
|
|
86
|
+
extras = dict(zip(('st_atime','st_mtime','st_ctime'), times))
|
|
87
|
+
for name, milliseconds in zip(('atime','mtime','ctime'), (value['atimeMs'],value['mtimeMs'],value['ctimeMs'])):
|
|
88
|
+
seconds = int(milliseconds // 1000)
|
|
89
|
+
extras['st_' + name + '_ns'] = seconds * 1000000000 + round((milliseconds - seconds * 1000) * 1000000)
|
|
90
|
+
for key in ('blocks','blksize','rdev'):
|
|
91
|
+
if key in value:
|
|
92
|
+
extras['st_' + key] = value[key]
|
|
93
|
+
return _safe_stat_type(tuple(value[key] for key in keys) + tuple(int(time // 1) for time in times), extras)
|
|
94
|
+
|
|
95
|
+
def _safe_lstat(path, *, dir_fd=None):
|
|
96
|
+
return _safe_stat(path, dir_fd=dir_fd, follow_symlinks=False)
|
|
97
|
+
|
|
98
|
+
def _safe_fstat(fd):
|
|
99
|
+
if not isinstance(fd, int):
|
|
100
|
+
raise TypeError('file descriptor must be an integer')
|
|
101
|
+
return _safe_stat(fd)
|
|
102
|
+
os.stat = _safe_stat
|
|
103
|
+
os.lstat = _safe_lstat
|
|
104
|
+
os.fstat = _safe_fstat
|
|
105
|
+
import stat as _safe_stat_module
|
|
106
|
+
class _SafeDirEntry:
|
|
107
|
+
def __init__(self, root, name):
|
|
108
|
+
self.name = name
|
|
109
|
+
self.path = os.path.join(root, name)
|
|
110
|
+
self._cache = {}
|
|
111
|
+
def __fspath__(self):
|
|
112
|
+
return self.path
|
|
113
|
+
def stat(self, *, follow_symlinks=True):
|
|
114
|
+
if follow_symlinks not in self._cache:
|
|
115
|
+
self._cache[follow_symlinks] = os.stat(self.path, follow_symlinks=follow_symlinks)
|
|
116
|
+
return self._cache[follow_symlinks]
|
|
117
|
+
def inode(self):
|
|
118
|
+
return self.stat(follow_symlinks=False).st_ino
|
|
119
|
+
def is_dir(self, *, follow_symlinks=True):
|
|
120
|
+
try:
|
|
121
|
+
return _safe_stat_module.S_ISDIR(self.stat(follow_symlinks=follow_symlinks).st_mode)
|
|
122
|
+
except FileNotFoundError:
|
|
123
|
+
return False
|
|
124
|
+
def is_file(self, *, follow_symlinks=True):
|
|
125
|
+
try:
|
|
126
|
+
return _safe_stat_module.S_ISREG(self.stat(follow_symlinks=follow_symlinks).st_mode)
|
|
127
|
+
except FileNotFoundError:
|
|
128
|
+
return False
|
|
129
|
+
def is_symlink(self):
|
|
130
|
+
try:
|
|
131
|
+
return _safe_stat_module.S_ISLNK(self.stat(follow_symlinks=False).st_mode)
|
|
132
|
+
except FileNotFoundError:
|
|
133
|
+
return False
|
|
134
|
+
class _SafeScandir:
|
|
135
|
+
def __init__(self, path):
|
|
136
|
+
self._entries = iter([_SafeDirEntry(path, name) for name in os.listdir(path)])
|
|
137
|
+
def __iter__(self):
|
|
138
|
+
return self
|
|
139
|
+
def __next__(self):
|
|
140
|
+
return next(self._entries)
|
|
141
|
+
def close(self):
|
|
142
|
+
self._entries = iter(())
|
|
143
|
+
def __enter__(self):
|
|
144
|
+
return self
|
|
145
|
+
def __exit__(self, *args):
|
|
146
|
+
self.close()
|
|
147
|
+
def _safe_scandir(path='.'):
|
|
148
|
+
if isinstance(path, int):
|
|
149
|
+
raise OSError(errno.ENOTSUP, 'retained directory descriptors are unsupported')
|
|
150
|
+
return _SafeScandir(os.fspath(path) if path is not None else '.')
|
|
151
|
+
os.scandir = _safe_scandir
|
|
152
|
+
|
|
153
|
+
`;
|
|
154
|
+
export const pythonTreeCleanup = `
|
|
155
|
+
import shutil, os, json
|
|
156
|
+
_safe_tree_callback = _safe_tree_cleanup
|
|
157
|
+
_safe_original_rmtree_impl = shutil._rmtree_impl
|
|
158
|
+
def _safe_rmtree_impl(path, dir_fd, onexc):
|
|
159
|
+
if dir_fd is not None:
|
|
160
|
+
return _safe_original_rmtree_impl(path, dir_fd, onexc)
|
|
161
|
+
value = json.loads(_safe_tree_callback(os.fsdecode(path)))
|
|
162
|
+
if not value['supported']:
|
|
163
|
+
return _safe_original_rmtree_impl(path, dir_fd, onexc)
|
|
164
|
+
if 'errno' in value:
|
|
165
|
+
onexc(os.rmdir, path, OSError(value['errno'], 'directory cleanup failed', path))
|
|
166
|
+
shutil._rmtree_impl = _safe_rmtree_impl
|
|
167
|
+
`;
|
|
168
|
+
//# sourceMappingURL=runtime-scripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-scripts.js","sourceRoot":"","sources":["../../../src/commands/python/runtime-scripts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCtC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;CAYnC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;CAcrC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyFnC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;CAahC,CAAC"}
|