refac: migrated to pyodide from pyscript

This commit is contained in:
Timothy J. Baek 2024-05-16 19:21:08 -10:00
parent 0a9092156c
commit 8f8ce26948
60 changed files with 273 additions and 255 deletions

11
package-lock.json generated
View File

@ -24,7 +24,7 @@
"js-sha256": "^0.10.1",
"katex": "^0.16.9",
"marked": "^9.1.0",
"pyodide": "^0.25.1",
"pyodide": "^0.26.0-alpha.4",
"svelte-sonner": "^0.3.19",
"tippy.js": "^6.3.7",
"uuid": "^9.0.1"
@ -6277,12 +6277,15 @@
}
},
"node_modules/pyodide": {
"version": "0.25.1",
"resolved": "https://registry.npmjs.org/pyodide/-/pyodide-0.25.1.tgz",
"integrity": "sha512-y0nJ/fLA3bxD2iZRzvVTbP2O+wp4Ewm2wThfV4HF0BytQ6hsoqTJFLNY4usLOcCVBrK8TTWqFqrmsVPzHe4rsw==",
"version": "0.26.0-alpha.4",
"resolved": "https://registry.npmjs.org/pyodide/-/pyodide-0.26.0-alpha.4.tgz",
"integrity": "sha512-Ixuczq99DwhQlE+Bt0RaS6Ln9MHSZOkbU6iN8azwaeorjHtr7ukaxh+FeTxViFrp2y+ITyKgmcobY+JnBPcULw==",
"dependencies": {
"base-64": "^1.0.0",
"ws": "^8.5.0"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/qs": {

View File

@ -63,7 +63,7 @@
"js-sha256": "^0.10.1",
"katex": "^0.16.9",
"marked": "^9.1.0",
"pyodide": "^0.25.1",
"pyodide": "^0.26.0-alpha.4",
"svelte-sonner": "^0.3.19",
"tippy.js": "^6.3.7",
"uuid": "^9.0.1"

3
pyodide.sh Normal file
View File

@ -0,0 +1,3 @@
mkdir -p ./static/pyodide
cp ./node_modules/pyodide/pyodide* ./static/pyodide/
cp ./node_modules/pyodide/python_stdlib.zip ./static/pyodide/

View File

@ -1,8 +0,0 @@
cp -R ./node_modules/@pyscript/core/dist ./static/pyscript
# mkdir -p ./static/micropython
# cp -R ./node_modules/@micropython/micropython-webassembly-pyscript/micropython.* ./static/micropython
mkdir -p ./static/pyodide
cp ./node_modules/pyodide/pyodide* ./static/pyodide/
cp ./node_modules/pyodide/python_stdlib.zip ./static/pyodide/

View File

@ -1,20 +0,0 @@
function execute(id, text) {
// pyscript
let div = document.createElement('div');
let html = `
<py-script type="mpy">
${text}
</py-script>
`;
div.innerHTML = html;
const pyScript = div.firstElementChild;
try {
document.body.appendChild(pyScript);
setTimeout(() => {
document.body.removeChild(pyScript);
}, 0);
} catch (error) {
console.error('Python error:');
console.error(error);
}
}

View File

@ -13,9 +13,6 @@
href="/opensearch.xml"
/>
<script type="module" src="/pyscript/core.js"></script>
<link rel="stylesheet" href="/pyscript/core.css" />
<script>
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
(() => {
@ -58,11 +55,6 @@
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<py-config> interpreter = "/pyodide/pyodide.mjs" </py-config>
<script type="py">
print('pyscript:loaded')
</script>
<div style="display: contents">%sveltekit.body%</div>
<div

View File

@ -2,6 +2,7 @@
import { copyToClipboard } from '$lib/utils';
import hljs from 'highlight.js';
import 'highlight.js/styles/github-dark.min.css';
import { loadPyodide } from 'pyodide';
import { tick } from 'svelte';
export let id = '';
@ -10,6 +11,11 @@
export let code = '';
let executed = false;
let stdout = null;
let stderr = null;
let result = null;
let copied = false;
const copyCode = async () => {
@ -131,72 +137,35 @@
return false;
};
const executePython = async (text) => {
const executePython = async (code) => {
executed = true;
await tick();
const outputDiv = document.getElementById(`code-output-${id}`);
let pyodide = await loadPyodide({
indexURL: '/pyodide/',
stderr: (text) => {
console.log('An error occured:', text);
if (stderr) {
stderr += `${text}\n`;
} else {
stderr = `${text}\n`;
}
},
stdout: (text) => {
console.log('Python output:', text);
if (outputDiv) {
outputDiv.innerText = 'Running...';
}
if (stdout) {
stdout += `${text}\n`;
} else {
stdout = `${text}\n`;
}
}
});
text = text
.split('\n')
.map((line, index) => (index === 0 ? line : ' ' + line))
.join('\n');
result = pyodide.runPython(code);
// pyscript
let div = document.createElement('div');
let html = `
<py-script type="py" worker>
import js
import sys
import io
# Create a StringIO object to capture the output
output_capture = io.StringIO()
# Save the current standard output
original_stdout = sys.stdout
# Replace the standard output with the StringIO object
sys.stdout = output_capture
try:
${text}
except Exception as e:
# Capture any errors and write them to the output capture
print(f"Error: {e}", file=output_capture)
# Restore the original standard output
sys.stdout = original_stdout
# Retrieve the captured output
captured_output = "[NO OUTPUT]"
captured_output = output_capture.getvalue()
# Print the captured output
print(captured_output)
def display_message():
output_div = js.document.getElementById("code-output-${id}")
output_div.innerText = captured_output
display_message()
</py-script>`;
div.innerHTML = html;
const pyScript = div.firstElementChild;
try {
document.body.appendChild(pyScript);
setTimeout(() => {
document.body.removeChild(pyScript);
}, 0);
} catch (error) {
console.error('Python error:');
console.error(error);
}
console.log(result);
console.log(stderr);
console.log(stdout);
};
$: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : '';
@ -234,7 +203,17 @@ display_message()
{#if executed}
<div class="bg-[#202123] text-white px-4 py-4 rounded-b-lg">
<div class=" text-gray-500 text-xs mb-1">STDOUT/STDERR</div>
<div id="code-output-{id}" class="text-sm" />
<div class="text-sm">
{#if stdout}
{stdout}
{:else if result}
{result}
{:else if stderr}
{stderr}
{:else}
Running...
{/if}
</div>
</div>
{/if}
</div>

View File

@ -6,15 +6,15 @@ import { getLiteLLMModels } from '$lib/apis/litellm';
export const getModels = async (token: string) => {
let models = await Promise.all([
await getOllamaModels(token).catch((error) => {
getOllamaModels(token).catch((error) => {
console.log(error);
return null;
}),
await getOpenAIModels(token).catch((error) => {
console.log(error);
return null;
}),
await getLiteLLMModels(token).catch((error) => {
// getOpenAIModels(token).catch((error) => {
// console.log(error);
// return null;
// }),
getLiteLLMModels(token).catch((error) => {
console.log(error);
return null;
})

134
static/pyodide/package.json Normal file
View File

@ -0,0 +1,134 @@
{
"name": "pyodide",
"version": "0.25.1",
"description": "The Pyodide JavaScript package",
"keywords": [
"python",
"webassembly"
],
"homepage": "https://github.com/pyodide/pyodide",
"repository": {
"type": "git",
"url": "https://github.com/pyodide/pyodide"
},
"bugs": {
"url": "https://github.com/pyodide/pyodide/issues"
},
"license": "Apache-2.0",
"devDependencies": {
"@types/assert": "^1.5.6",
"@types/expect": "^24.3.0",
"@types/mocha": "^9.1.0",
"@types/node": "^20.8.4",
"@types/ws": "^8.5.3",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"cross-env": "^7.0.3",
"dts-bundle-generator": "^8.1.1",
"error-stack-parser": "^2.1.4",
"esbuild": "^0.17.12",
"express": "^4.17.3",
"mocha": "^9.0.2",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"ts-mocha": "^9.0.2",
"tsd": "^0.24.1",
"typedoc": "^0.25.1",
"typescript": "^4.6.4",
"wabt": "^1.0.32"
},
"main": "pyodide.js",
"exports": {
".": {
"require": "./pyodide.js",
"import": "./pyodide.mjs",
"types": "./pyodide.d.ts"
},
"./ffi": {
"types": "./ffi.d.ts"
},
"./pyodide.asm.wasm": "./pyodide.asm.wasm",
"./pyodide.asm.js": "./pyodide.asm.js",
"./python_stdlib.zip": "./python_stdlib.zip",
"./pyodide.mjs": "./pyodide.mjs",
"./pyodide.js": "./pyodide.js",
"./package.json": "./package.json",
"./pyodide-lock.json": "./pyodide-lock.json"
},
"files": [
"pyodide.asm.js",
"pyodide.asm.wasm",
"python_stdlib.zip",
"pyodide.mjs",
"pyodide.js.map",
"pyodide.mjs.map",
"pyodide.d.ts",
"ffi.d.ts",
"pyodide-lock.json",
"console.html"
],
"browser": {
"child_process": false,
"crypto": false,
"fs": false,
"fs/promises": false,
"path": false,
"url": false,
"vm": false,
"ws": false
},
"scripts": {
"build": "tsc --noEmit && node esbuild.config.mjs",
"test": "npm-run-all test:*",
"test:unit": "cross-env TEST_NODE=1 ts-mocha --node-option=experimental-loader=./test/loader.mjs --node-option=experimental-wasm-stack-switching -p tsconfig.test.json test/unit/**/*.test.*",
"test:node": "cross-env TEST_NODE=1 mocha test/integration/**/*.test.js",
"test:browser": "mocha test/integration/**/*.test.js",
"tsc": "tsc --noEmit",
"coverage": "cross-env TEST_NODE=1 npm-run-all coverage:*",
"coverage:build": "nyc npm run test:node"
},
"mocha": {
"bail": false,
"timeout": 30000,
"full-trace": true,
"inline-diffs": true,
"check-leaks": false,
"global": [
"pyodide",
"page",
"chai"
]
},
"nyc": {
"reporter": [
"html",
"text-summary"
],
"include": [
"*.ts"
],
"all": true,
"clean": true,
"cache": false,
"instrument": false,
"checkCoverage": true,
"statements": 95,
"functions": 95,
"branches": 80,
"lines": 95
},
"tsd": {
"compilerOptions": {
"lib": [
"ES2017",
"DOM"
]
}
},
"dependencies": {
"base-64": "^1.0.0",
"ws": "^8.5.0"
},
"types": "./pyodide.d.ts"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -653,10 +653,36 @@ declare class PyCallableMethods {
*/
call(thisArg: any, ...jsargs: any): any;
/**
* Call the function with key word arguments. The last argument must be an
* Call the function with keyword arguments. The last argument must be an
* object with the keyword arguments.
*/
callKwargs(...jsargs: any): any;
/**
* Call the function in a "relaxed" manner. Any extra arguments will be
* ignored. This matches the behavior of JavaScript functions more accurately.
*
* Any extra arguments will be ignored. This matches the behavior of
* JavaScript functions more accurately. Missing arguments are **NOT** filled
* with `None`. If too few arguments are passed, this will still raise a
* TypeError.
*
* This uses :py:func:`pyodide.code.relaxed_call`.
*/
callRelaxed(...jsargs: any): any;
/**
* Call the function with keyword arguments in a "relaxed" manner. The last
* argument must be an object with the keyword arguments. Any extra arguments
* will be ignored. This matches the behavior of JavaScript functions more
* accurately.
*
* Missing arguments are **NOT** filled with `None`. If too few arguments are
* passed, this will still raise a TypeError. Also, if the same argument is
* passed as both a keyword argument and a positional argument, it will raise
* an error.
*
* This uses :py:func:`pyodide.code.relaxed_call`.
*/
callKwargsRelaxed(...jsargs: any): any;
/**
* Call the function with stack switching enabled. Functions called this way
* can use
@ -911,7 +937,7 @@ interface CanvasInterface {
declare class PythonError extends Error {
/**
* The address of the error we are wrapping. We may later compare this
* against sys.last_value.
* against sys.last_exc.
* WARNING: we don't own a reference to this pointer, dereferencing it
* may be a use-after-free error!
* @private
@ -1128,36 +1154,6 @@ declare class PyodideAPI {
locals?: PyProxy;
filename?: string;
}): Promise<any>;
/**
* Runs a Python code string like :js:func:`pyodide.runPython` but with stack
* switching enabled. Code executed in this way can use
* :py:meth:`PyodideFuture.syncify() <pyodide.webloop.PyodideFuture.syncify>`
* to block until a :py:class:`~asyncio.Future` or :js:class:`Promise` is
* resolved. Only works in runtimes with JS Promise Integration enabled.
*
* .. admonition:: Experimental
* :class: warning
*
* This feature is not yet stable.
*
* @experimental
* @param code The Python code to run
* @param options
* @param options.globals An optional Python dictionary to use as the globals.
* Defaults to :js:attr:`pyodide.globals`.
* @param options.locals An optional Python dictionary to use as the locals.
* Defaults to the same as ``globals``.
* @param options.filename An optional string to use as the file name.
* Defaults to ``"<exec>"``. If a custom file name is given, the
* traceback for any exception that is thrown will show source lines
* (unless the given file name starts with ``<`` and ends with ``>``).
* @returns The result of the Python code translated to JavaScript.
*/
static runPythonSyncifying(code: string, options?: {
globals?: PyProxy;
locals?: PyProxy;
filename?: string;
}): Promise<any>;
/**
* Registers the JavaScript object ``module`` as a JavaScript module named
* ``name``. This module can then be imported from Python using the standard
@ -1232,30 +1228,25 @@ declare class PyodideAPI {
/**
* Imports a module and returns it.
*
* .. admonition:: Warning
* :class: warning
*
* This function has a completely different behavior than the old removed pyimport function!
*
* ``pyimport`` is roughly equivalent to:
*
* .. code-block:: js
*
* pyodide.runPython(`import ${pkgname}; ${pkgname}`);
*
* except that the global namespace will not change.
*
* Example:
*
* .. code-block:: js
*
* let sysmodule = pyodide.pyimport("sys");
* let recursionLimit = sysmodule.getrecursionlimit();
* If `name` has no dot in it, then `pyimport(name)` is approximately
* equivalent to:
* ```js
* pyodide.runPython(`import ${name}; ${name}`)
* ```
* except that `name` is not introduced into the Python global namespace. If
* the name has one or more dots in it, say it is of the form `path.name`
* where `name` has no dots but path may have zero or more dots. Then it is
* approximately the same as:
* ```js
* pyodide.runPython(`from ${path} import ${name}; ${name}`);
* ```
*
* @param mod_name The name of the module to import
* @returns A PyProxy for the imported module
*
* @example
* pyodide.pyimport("math.comb")(4, 2) // returns 4 choose 2 = 6
*/
static pyimport(mod_name: string): PyProxy;
static pyimport(mod_name: string): any;
/**
* Unpack an archive into a target directory.
*
@ -1277,14 +1268,26 @@ declare class PyodideAPI {
}): void;
/**
* Mounts a :js:class:`FileSystemDirectoryHandle` into the target directory.
* Currently it's only possible to acquire a
* :js:class:`FileSystemDirectoryHandle` in Chrome.
*
* @param path The absolute path in the Emscripten file system to mount the
* native directory. If the directory does not exist, it will be created. If it
* does exist, it must be empty.
* @param fileSystemHandle A handle returned by :js:func:`navigator.storage.getDirectory() <getDirectory>`
* or :js:func:`window.showDirectoryPicker() <showDirectoryPicker>`.
* native directory. If the directory does not exist, it will be created. If
* it does exist, it must be empty.
* @param fileSystemHandle A handle returned by
* :js:func:`navigator.storage.getDirectory() <getDirectory>` or
* :js:func:`window.showDirectoryPicker() <showDirectoryPicker>`.
*/
static mountNativeFS(path: string, fileSystemHandle: FileSystemDirectoryHandle): Promise<NativeFS>;
/**
* Mounts a host directory into Pyodide file system. Only works in node.
*
* @param emscriptenPath The absolute path in the Emscripten file system to
* mount the native directory. If the directory does not exist, it will be
* created. If it does exist, it must be empty.
* @param hostPath The host path to mount. It must be a directory that exists.
*/
static mountNodeFS(emscriptenPath: string, hostPath: string): void;
/**
* Tell Pyodide about Comlink.
* Necessary to enable importing Comlink proxies into Python.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
mpy-config,mpy-script,py-config,py-script{display:none}.mpy-editor-box,.py-editor-box{padding:.5rem}.mpy-editor-input,.py-editor-input{position:relative}.mpy-editor-box:before,.py-editor-box:before{content:attr(data-env);display:block;font-size:x-small;text-align:end}.mpy-editor-output,.py-editor-output{white-space:pre}.mpy-editor-run-button,.py-editor-run-button{bottom:.5rem;opacity:0;position:absolute;right:.5rem;transition:opacity .25s;z-index:1}.mpy-editor-box:hover .mpy-editor-run-button,.mpy-editor-run-button:disabled,.mpy-editor-run-button:focus,.py-editor-box:hover .py-editor-run-button,.py-editor-run-button:disabled,.py-editor-run-button:focus{opacity:1}

View File

@ -1,2 +0,0 @@
export{g as MPWorker,f as PyWorker,T as TYPES,h as config,e as hooks,o as offline_interpreter,b as optional,s as stdlib,i as whenDefined}from"./core-CPpjJT4b.js";
//# sourceMappingURL=core.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"core.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}

View File

@ -1,2 +0,0 @@
import{e}from"./core-CPpjJT4b.js";import{notify as o}from"./error-BfnovtqK.js";function r(){const e=document.querySelectorAll("script");for(const o of e)s(o.src)}function s(e){/\/pyscript\.net\/latest/.test(e)&&o("Loading scripts from latest is deprecated and will be removed soon. Please use a specific version instead.")}e.main.onReady.add(r),e.main.onWorker.add(r);
//# sourceMappingURL=deprecations-manager-CQ0oxKrq.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"deprecations-manager-CQ0oxKrq.js","sources":["../src/plugins/deprecations-manager.js"],"sourcesContent":["// PyScript Derepcations Plugin\nimport { hooks } from \"../core.js\";\nimport { notify } from \"./error.js\";\n\n// react lazily on PyScript bootstrap\nhooks.main.onReady.add(checkDeprecations);\nhooks.main.onWorker.add(checkDeprecations);\n\n/**\n * Check that there are no scripts loading from pyscript.net/latest\n */\nfunction checkDeprecations() {\n const scripts = document.querySelectorAll(\"script\");\n for (const script of scripts) checkLoadingScriptsFromLatest(script.src);\n}\n\n/**\n * Check if src being loaded from pyscript.net/latest and display a notification if true\n * * @param {string} src\n */\nfunction checkLoadingScriptsFromLatest(src) {\n if (/\\/pyscript\\.net\\/latest/.test(src)) {\n notify(\n \"Loading scripts from latest is deprecated and will be removed soon. Please use a specific version instead.\",\n );\n }\n}\n"],"names":["checkDeprecations","scripts","document","querySelectorAll","script","checkLoadingScriptsFromLatest","src","test","notify","hooks","main","onReady","add","onWorker"],"mappings":"+EAWA,SAASA,IACL,MAAMC,EAAUC,SAASC,iBAAiB,UAC1C,IAAK,MAAMC,KAAUH,EAASI,EAA8BD,EAAOE,IACvE,CAMA,SAASD,EAA8BC,GAC/B,0BAA0BC,KAAKD,IAC/BE,EACI,6GAGZ,CArBAC,EAAMC,KAAKC,QAAQC,IAAIZ,GACvBS,EAAMC,KAAKG,SAASD,IAAIZ"}

View File

@ -1,2 +0,0 @@
import{e}from"./core-CPpjJT4b.js";function n(e){const n=document.createElement("div");n.className="py-error",n.textContent=e,n.style.cssText="\n border: 1px solid red;\n background: #ffdddd;\n color: black;\n font-family: courier, monospace;\n white-space: pre;\n overflow-x: auto;\n padding: 8px;\n margin-top: 8px;\n ",document.body.append(n)}e.main.onReady.add((function o(r){e.main.onReady.delete(o);const{stderr:t}=r.io;r.io.stderr=(e,...o)=>(n(e.message||e),t(e,...o)),addEventListener("error",(({message:e})=>{e.startsWith("Uncaught PythonError")&&n(e)}))}));export{n as notify};
//# sourceMappingURL=error-BfnovtqK.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"error-BfnovtqK.js","sources":["../src/plugins/error.js"],"sourcesContent":["// PyScript Error Plugin\nimport { hooks } from \"../core.js\";\n\nhooks.main.onReady.add(function override(pyScript) {\n // be sure this override happens only once\n hooks.main.onReady.delete(override);\n\n // trap generic `stderr` to propagate to it regardless\n const { stderr } = pyScript.io;\n\n // override it with our own logic\n pyScript.io.stderr = (error, ...rest) => {\n notify(error.message || error);\n // let other plugins or stderr hook, if any, do the rest\n return stderr(error, ...rest);\n };\n\n // be sure uncaught Python errors are also visible\n addEventListener(\"error\", ({ message }) => {\n if (message.startsWith(\"Uncaught PythonError\")) notify(message);\n });\n});\n\n// Error hook utilities\n\n// Custom function to show notifications\n\n/**\n * Add a banner to the top of the page, notifying the user of an error\n * @param {string} message\n */\nexport function notify(message) {\n const div = document.createElement(\"div\");\n div.className = \"py-error\";\n div.textContent = message;\n div.style.cssText = `\n border: 1px solid red;\n background: #ffdddd;\n color: black;\n font-family: courier, monospace;\n white-space: pre;\n overflow-x: auto;\n padding: 8px;\n margin-top: 8px;\n `;\n document.body.append(div);\n}\n"],"names":["notify","message","div","document","createElement","className","textContent","style","cssText","body","append","hooks","main","onReady","add","override","pyScript","delete","stderr","io","error","rest","addEventListener","startsWith"],"mappings":"kCA+BO,SAASA,EAAOC,GACnB,MAAMC,EAAMC,SAASC,cAAc,OACnCF,EAAIG,UAAY,WAChBH,EAAII,YAAcL,EAClBC,EAAIK,MAAMC,QAAU,6MAUpBL,SAASM,KAAKC,OAAOR,EACzB,CA3CAS,EAAMC,KAAKC,QAAQC,KAAI,SAASC,EAASC,GAErCL,EAAMC,KAAKC,QAAQI,OAAOF,GAG1B,MAAMG,OAAEA,GAAWF,EAASG,GAG5BH,EAASG,GAAGD,OAAS,CAACE,KAAUC,KAC5BrB,EAAOoB,EAAMnB,SAAWmB,GAEjBF,EAAOE,KAAUC,IAI5BC,iBAAiB,SAAS,EAAGrB,cACrBA,EAAQsB,WAAW,yBAAyBvB,EAAOC,EAAQ,GAEvE"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
import{T as t,d as e,a as r,o as n,X as o,H as s,s as i}from"./core-CPpjJT4b.js";let a=0;const c=t=>`${t}-editor-${a++}`,l=new Map,u=new Map,d={worker:{codeBeforeRun:()=>i,onReady:({runAsync:t,io:e},{sync:r})=>{e.stdout=e.buffered(r.write),e.stderr=e.buffered(r.writeErr),r.revoke(),r.runAsync=t}}};async function m({currentTarget:t}){const{env:e,pySrc:r,outDiv:i}=this,a=!!t;if(a&&(t.disabled=!0,i.innerHTML=""),!l.has(e)){const t=URL.createObjectURL(new Blob([""])),r={type:this.interpreter},{config:i}=this;if(i){r.configURL=i;const{parse:t}=i.endsWith(".toml")?await import("./toml-CvAfdf9_.js"):JSON;r.config=t(await fetch(i).then((t=>t.text()))),r.version=n(r.config)}else r.config={};const a=o.call(new s(null,d),t,r),{sync:c}=a,{promise:u,resolve:m}=Promise.withResolvers();l.set(e,u),c.revoke=()=>{URL.revokeObjectURL(t),m(a)}}return l.get(e).then((e=>{e.onerror=({error:t})=>{a&&(i.innerHTML+=`<span style='color:red'>${t.message||t}</span>\n`),console.error(t)};const n=()=>{a&&(t.disabled=!1)},{sync:o}=e;o.write=t=>{a&&(i.innerText+=`${t}\n`)},o.writeErr=t=>{a&&(i.innerHTML+=`<span style='color:red'>${t}</span>\n`)},o.runAsync(r).then(n,n)}))}const p=(t,e)=>{const r=document.createElement("div");r.className=`${e}-editor-input`,r.setAttribute("aria-label","Python Script Area");const n=((t,e)=>{const r=document.createElement("button");return r.className=`absolute ${e}-editor-run-button`,r.innerHTML='<svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg>',r.setAttribute("aria-label","Python Script Run Button"),r.addEventListener("click",t),r})(t,e),o=document.createElement("div");return o.addEventListener("keydown",(t=>{t.stopPropagation()})),r.append(n,o),r},f=(t,e)=>{const r=document.createElement("div");r.className=`${e}-editor-box`;const n=p(t,e),o=(t=>{const e=document.createElement("div");return e.className=`${t}-editor-output`,e.id=`${c(t)}-output`,e})(e);return r.append(n,o),[r,o]},g=async(t,n,o)=>{const[{basicSetup:s,EditorView:i},{Compartment:a},{python:l},{indentUnit:d},{keymap:p},{defaultKeymap:g}]=await Promise.all([import("./codemirror-Dr2Hgejs.js"),import("./codemirror_state-BKbyfKsm.js"),import("./codemirror_lang-python-Cxoc-ydj.js"),import("./codemirror_language-_XiX6II0.js").then((function(t){return t.x})),import("./codemirror_view-C0PMO2z_.js").then((function(t){return t.q})),import("./codemirror_commands-MgxtVkrD.js")]);let h=t.hasAttribute("setup");const v=t.hasAttribute("config"),b=`${o}-${t.getAttribute("env")||c(n)}`;if(v&&u.has(b))throw new SyntaxError(u.get(b)?`duplicated config for env: ${b}`:`unable to add a config to the env: ${b}`);u.set(b,v);let w=t.src?await fetch(t.src).then((t=>t.text())):t.textContent;const y={interpreter:o,env:b,config:v&&new URL(t.getAttribute("config"),location.href).href,get pySrc(){return h?w:T.state.doc.toString()},get outDiv(){return h?null:C}};let E;e(t,{target:{get:()=>E},process:{value(t){const e=h,r=w;h=!0,w=t;const n=()=>{h=e,w=r};return m.call(y,{currentTarget:null}).then(n,n)}}});const $=()=>{const e=new Event(`${n}-editor`,{bubbles:!0});t.dispatchEvent(e)};if(h)return await m.call(y,{currentTarget:null}),void $();const x=t.getAttribute("target");if(x){if(E=document.getElementById(x)||document.querySelector(x),!E)throw new Error(`Unknown target ${x}`)}else E=document.createElement(`${n}-editor`),E.style.display="block",t.after(E);E.id||(E.id=c(n)),E.hasAttribute("exec-id")||E.setAttribute("exec-id",0),E.hasAttribute("root")||E.setAttribute("root",E.id);const A=m.bind(y),[L,C]=f(A,n);L.dataset.env=t.hasAttribute("env")?b:o;const S=L.querySelector(`.${n}-editor-input > div`).attachShadow({mode:"open"});S.innerHTML="<style> :host { all: initial; }</style>",E.appendChild(L);const k=r(t.textContent).trim(),R=/^(\s+)/m.test(k)?RegExp.$1:" ",T=new i({extensions:[d.of(R),(new a).of(l()),p.of([...g,{key:"Ctrl-Enter",run:A,preventDefault:!0},{key:"Cmd-Enter",run:A,preventDefault:!0},{key:"Shift-Enter",run:A,preventDefault:!0}]),s],parent:S,doc:k});T.focus(),$()};let h=0,v=Promise.resolve();const b=()=>{h=0,w()},w=()=>{if(!h){h=setTimeout(b,250);for(const[e,r]of t){const t=`script[type="${e}-editor"]`;for(const n of document.querySelectorAll(t))n.type+="-active",v=v.then((()=>g(n,e,r)))}return v}};new MutationObserver(w).observe(document,{childList:!0,subtree:!0});var y=w();export{y as default};
//# sourceMappingURL=py-editor-CmqzUo2Z.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
import{T as e,c as t,e as r,d as n}from"./core-CPpjJT4b.js";import{notify as o}from"./error-BfnovtqK.js";const i=[],s=e=>{throw o(e),new Error(e)},a=({attributes:{worker:e}})=>!e,d=new WeakSet;let l=!0;const c=({interpreter:e,io:t,run:r,type:n},{sync:o})=>{if(!o.is_pyterminal())return;r("from polyscript import currentScript as _; __terminal__ = _.terminal; del _");let i="";const{pyterminal_read:s,pyterminal_write:a}=o,d=new TextDecoder,l={isatty:!1,write:e=>(i=d.decode(e),a(i),e.length)};if(t.stderr=e=>{a(String(e.message||e))},"mpy"===n){e.registerJsModule("_pyscript_input",{input:s}),r("from _pyscript_input import input");const n=e=>{const t=[];let r=0;return n=>{let o=0;for(const i of n)t.push(i),r?r--:194<=i&&i<=223?r=1:224<=i&&i<=239?r=2:240<=i&&i<=244&&(r=3),r||(o+=t.length,e(new Uint8Array(t.splice(0))));return o}};t.stdout=n(l.write),e.registerJsModule("code",{interact(){let r="",o=1;const i=new TextEncoder,l=[],c=n((e=>{l.push(...e),a(d.decode(e))}));t.stdout=e=>o++>r.length?c(e):0,e.replInit(),function t(){const n=d.decode(new Uint8Array(l.splice(0))),a=`${s(n.split("\n").at(-1))}\r`;o=0,r=i.encode(a);for(const t of r)e.replProcessChar(t);t()}()}})}else e.setStdout(l),e.setStderr(l),e.setStdin({isatty:!1,stdin:()=>s(i)})},m=async e=>{const[{Terminal:t},{Readline:o},{FitAddon:i},{WebLinksAddon:s}]=await Promise.all([import("./xterm-DqawCVsv.js"),import("./xterm-readline-D247p8vq.js"),import("./xterm_addon-fit--gyF3PcZ.js"),import("./xterm_addon-web-links-Cnej-nJ6.js")]),a=new o,l=r=>{let o=e;const d=e.getAttribute("target");if(d){if(o=document.getElementById(d)||document.querySelector(d),!o)throw new Error(`Unknown target ${d}`)}else o=document.createElement("py-terminal"),o.style.display="block",e.after(o);const l=new t({theme:{background:"#191A19",foreground:"#F5F2E7"},...r}),c=new i;return l.loadAddon(c),l.loadAddon(a),l.loadAddon(new s),l.open(o),c.fit(),l.focus(),n(e,{terminal:{value:l},process:{value:async e=>{for(const t of e.split(/(?:\r|\n|\r\n)/)){l.paste(`${t}\n`);do{await new Promise((e=>setTimeout(e,0)))}while(!a.activeRead?.resolve);a.activeRead.resolve(t)}}}}),l};e.hasAttribute("worker")?(r.main.onWorker.add((function e(t,n){d.has(n)||(d.add(n),r.main.onWorker.delete(e),l({disableStdin:!1,cursorBlink:!0,cursorStyle:"block"}),n.sync.is_pyterminal=()=>!0,n.sync.pyterminal_read=a.read.bind(a),n.sync.pyterminal_write=a.write.bind(a))})),r.worker.onReady.add(c)):r.main.onReady.add((function e({interpreter:t,io:n,run:o,type:i}){console.warn("py-terminal is read only on main thread"),r.main.onReady.delete(e),globalThis.__py_terminal__=l({disableStdin:!0,cursorBlink:!1,cursorStyle:"underline"}),o("from js import __py_terminal__ as __terminal__"),delete globalThis.__py_terminal__,n.stderr=e=>{a.write(String(e.message||e))},"mpy"===i&&(t.setStdin=Object,t.setStderr=Object,t.setStdout=({write:e})=>{n.stdout=e});let s="";const d=new TextDecoder,c={isatty:!1,write:e=>(s=d.decode(e),a.write(s),e.length)};t.setStdout(c),t.setStderr(c),t.setStdin({isatty:!1,stdin:()=>a.read(s)})}))};for(const r of e.keys()){const e=`script[type="${r}"][terminal],${r}-script[terminal]`;i.push(e),t.set(e,(async e=>{const t=document.querySelectorAll(i.join(","));[].filter.call(t,a).length>1&&s("You can use at most 1 main terminal"),l&&(l=!1,document.head.append(Object.assign(document.createElement("link"),{rel:"stylesheet",href:new URL("./xterm.css",import.meta.url)}))),await m(e)}))}
//# sourceMappingURL=py-terminal-CgcHH2nx.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +0,0 @@
/*! (c) Andrea Giammarchi - ISC */
const{isArray:e}=Array,{parse:r}=JSON,s=(e,{s:r})=>e.replace(/"s(\d+)"/g,((e,s)=>r[s])),t=(e,s)=>r(e.replace(/(\S+?)\s*=/g,'"$1":'),((e,r)=>"string"==typeof r?s[r[0]][r.slice(1)]:r)),p=(r,t,p,l)=>{for(let n=0,{length:a}=r,c=a-1;n<a;n++){const a=s(r[n],t);p=p[a]||(p[a]=l&&n===c?[]:{}),e(p)&&(n!==c&&p.length||p.push({}),p=p.at(-1))}return p},l=e=>{const[r,l]=((e,r,s)=>[e.replace(/(["'])(?:(?=(\\?))\2.)*?\1/g,(e=>`"s${r.push(e.slice(1,-1))-1}"`)).replace(/\d{2,}([:-]\d{2}){2}([ T:-][\dZ:-]+)?/g,(e=>`"d${s.push(new Date(e))-1}"`)).replace(/,\s*[\r\n]+/g,", ").replace(/\[\s*[\r\n]+/g,"[").replace(/[\r\n]+\s*]/g,"]"),{s:r,d:s}])(e,[],[]),n={};let a=n;for(let e of r.split(/[\r\n]+/))if((e=e.trim())&&!e.startsWith("#"))if(/^(\[+)(.*?)\]+/.test(e))a=p(RegExp.$2.trim().split("."),l,n,"["!==RegExp.$1);else if(/^(\S+?)\s*=([^#]+)/.test(e)){const{$1:e,$2:r}=RegExp;a[s(e,l)]=t(r.trim(),l)}return n};export{l as parse};
//# sourceMappingURL=toml-DiUM0_qs.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +0,0 @@
/**
* Minified by jsDelivr using clean-css v5.3.2.
* Original file: /npm/xterm@5.3.0/css/xterm.css
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:0}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm .xterm-cursor-pointer,.xterm.xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility,.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}

View File

@ -1,2 +0,0 @@
var e,t,r={exports:{}},s=r.exports=(e=t={},Object.defineProperty(e,"__esModule",{value:!0}),e.FitAddon=void 0,e.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),o=Math.max(0,parseInt(s.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),l=i-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),a=o-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-r;return{cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}},t),i=r.exports.FitAddon,o=r.exports.__esModule;export{i as FitAddon,o as __esModule,s as default};
//# sourceMappingURL=xterm_addon-fit--gyF3PcZ.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"xterm_addon-fit--gyF3PcZ.js","sources":["../src/3rd-party/xterm_addon-fit.js"],"sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2.\n * Original file: /npm/@xterm/addon-fit@0.10.0/lib/addon-fit.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\nvar e,t,r={exports:{}};self;var s=r.exports=(e=t={},Object.defineProperty(e,\"__esModule\",{value:!0}),e.FitAddon=void 0,e.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue(\"height\")),o=Math.max(0,parseInt(s.getPropertyValue(\"width\"))),n=window.getComputedStyle(this._terminal.element),l=i-(parseInt(n.getPropertyValue(\"padding-top\"))+parseInt(n.getPropertyValue(\"padding-bottom\"))),a=o-(parseInt(n.getPropertyValue(\"padding-right\"))+parseInt(n.getPropertyValue(\"padding-left\")))-r;return{cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}},t),i=r.exports.FitAddon,o=r.exports.__esModule;export{i as FitAddon,o as __esModule,s as default};\n"],"names":["e","t","r","exports","s","Object","defineProperty","value","FitAddon","activate","this","_terminal","dispose","fit","proposeDimensions","isNaN","cols","rows","_core","_renderService","clear","resize","element","parentElement","dimensions","css","cell","width","height","options","scrollback","viewport","scrollBarWidth","window","getComputedStyle","i","parseInt","getPropertyValue","o","Math","max","n","l","a","floor","__esModule"],"mappings":"AAMA,IAAIA,EAAEC,EAAEC,EAAE,CAACC,QAAQ,CAAE,GAAWC,EAAEF,EAAEC,SAASH,EAAEC,EAAE,CAAA,EAAGI,OAAOC,eAAeN,EAAE,aAAa,CAACO,OAAM,IAAKP,EAAEQ,cAAS,EAAOR,EAAEQ,SAAS,MAAM,QAAAC,CAAST,GAAGU,KAAKC,UAAUX,CAAC,CAAC,OAAAY,IAAW,GAAAC,GAAM,MAAMb,EAAEU,KAAKI,oBAAoB,IAAId,IAAIU,KAAKC,WAAWI,MAAMf,EAAEgB,OAAOD,MAAMf,EAAEiB,MAAM,OAAO,MAAMhB,EAAES,KAAKC,UAAUO,MAAMR,KAAKC,UAAUM,OAAOjB,EAAEiB,MAAMP,KAAKC,UAAUK,OAAOhB,EAAEgB,OAAOf,EAAEkB,eAAeC,QAAQV,KAAKC,UAAUU,OAAOrB,EAAEgB,KAAKhB,EAAEiB,MAAM,CAAC,iBAAAH,GAAoB,IAAIJ,KAAKC,UAAU,OAAO,IAAID,KAAKC,UAAUW,UAAUZ,KAAKC,UAAUW,QAAQC,cAAc,OAAO,MAAMvB,EAAEU,KAAKC,UAAUO,MAAMjB,EAAED,EAAEmB,eAAeK,WAAW,GAAG,IAAIvB,EAAEwB,IAAIC,KAAKC,OAAO,IAAI1B,EAAEwB,IAAIC,KAAKE,OAAO,OAAO,MAAM1B,EAAE,IAAIQ,KAAKC,UAAUkB,QAAQC,WAAW,EAAE9B,EAAE+B,SAASC,eAAe5B,EAAE6B,OAAOC,iBAAiBxB,KAAKC,UAAUW,QAAQC,eAAeY,EAAEC,SAAShC,EAAEiC,iBAAiB,WAAWC,EAAEC,KAAKC,IAAI,EAAEJ,SAAShC,EAAEiC,iBAAiB,WAAWI,EAAER,OAAOC,iBAAiBxB,KAAKC,UAAUW,SAASoB,EAAEP,GAAGC,SAASK,EAAEJ,iBAAiB,gBAAgBD,SAASK,EAAEJ,iBAAiB,oBAAoBM,EAAEL,GAAGF,SAASK,EAAEJ,iBAAiB,kBAAkBD,SAASK,EAAEJ,iBAAiB,kBAAkBnC,EAAE,MAAM,CAACc,KAAKuB,KAAKC,IAAI,EAAED,KAAKK,MAAMD,EAAE1C,EAAEwB,IAAIC,KAAKC,QAAQV,KAAKsB,KAAKC,IAAI,EAAED,KAAKK,MAAMF,EAAEzC,EAAEwB,IAAIC,KAAKE,SAAS,GAAG3B,GAAGkC,EAAEjC,EAAEC,QAAQK,SAAS8B,EAAEpC,EAAEC,QAAQ0C"}

View File

@ -1,2 +0,0 @@
var e={exports:{}},t=e.exports=(()=>{var e={6:(e,t)=>{function r(e){try{const t=new URL(e),r=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(r.toLocaleLowerCase())}catch(e){return!1}}Object.defineProperty(t,"__esModule",{value:!0}),t.LinkComputer=t.WebLinkProvider=void 0,t.WebLinkProvider=class{constructor(e,t,r,n={}){this._terminal=e,this._regex=t,this._handler=r,this._options=n}provideLinks(e,t){const r=n.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(r))}_addCallbacks(e){return e.map((e=>(e.leave=this._options.leave,e.hover=(t,r)=>{if(this._options.hover){const{range:n}=e;this._options.hover(t,r,n)}},e)))}};class n{static computeLink(e,t,s,o){const i=new RegExp(t.source,(t.flags||"")+"g"),[a,l]=n._getWindowedLineStrings(e-1,s),c=a.join("");let d;const p=[];for(;d=i.exec(c);){const e=d[0];if(!r(e))continue;const[t,i]=n._mapStrIdx(s,l,0,d.index),[a,c]=n._mapStrIdx(s,t,i,e.length);if(-1===t||-1===i||-1===a||-1===c)continue;const h={start:{x:i+1,y:t+1},end:{x:c,y:a+1}};p.push({range:h,text:e,activate:o})}return p}static _getWindowedLineStrings(e,t){let r,n=e,s=e,o=0,i="";const a=[];if(r=t.buffer.active.getLine(e)){const e=r.translateToString(!0);if(r.isWrapped&&" "!==e[0]){for(o=0;(r=t.buffer.active.getLine(--n))&&o<2048&&(i=r.translateToString(!0),o+=i.length,a.push(i),r.isWrapped&&-1===i.indexOf(" ")););a.reverse()}for(a.push(e),o=0;(r=t.buffer.active.getLine(++s))&&r.isWrapped&&o<2048&&(i=r.translateToString(!0),o+=i.length,a.push(i),-1===i.indexOf(" ")););}return[a,n]}static _mapStrIdx(e,t,r,n){const s=e.buffer.active,o=s.getNullCell();let i=r;for(;n;){const e=s.getLine(t);if(!e)return[-1,-1];for(let r=i;r<e.length;++r){e.getCell(r,o);const i=o.getChars();if(o.getWidth()&&(n-=i.length||1,r===e.length-1&&""===i)){const e=s.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,o),2===o.getWidth()&&(n+=1))}if(n<0)return[t,r]}t++,i=0}return[t,i]}}t.LinkComputer=n}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.WebLinksAddon=void 0;const t=r(6),s=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function o(e,t){const r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}e.WebLinksAddon=class{constructor(e=o,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;const r=this._options,n=r.urlRegex||s;this._linkProvider=this._terminal.registerLinkProvider(new t.WebLinkProvider(this._terminal,n,this._handler,r))}dispose(){this._linkProvider?.dispose()}}})(),n})(),r=e.exports.WebLinksAddon,n=e.exports.__esModule;export{r as WebLinksAddon,n as __esModule,t as default};
//# sourceMappingURL=xterm_addon-web-links-Cnej-nJ6.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long