mirror of
https://github.com/open-webui/open-webui
synced 2024-11-21 23:57:51 +00:00
Merge pull request #2325 from open-webui/pyscript
feat: python code execution
This commit is contained in:
commit
4950feded4
@ -117,6 +117,18 @@ app.state.config.WEBHOOK_URL = WEBHOOK_URL
|
||||
origins = ["*"]
|
||||
|
||||
|
||||
# Custom middleware to add security headers
|
||||
class SecurityHeadersMiddleware(BaseHTTPMiddleware):
|
||||
async def dispatch(self, request: Request, call_next):
|
||||
response: Response = await call_next(request)
|
||||
response.headers["Cross-Origin-Opener-Policy"] = "same-origin"
|
||||
response.headers["Cross-Origin-Embedder-Policy"] = "require-corp"
|
||||
return response
|
||||
|
||||
|
||||
app.add_middleware(SecurityHeadersMiddleware)
|
||||
|
||||
|
||||
class RAGMiddleware(BaseHTTPMiddleware):
|
||||
async def dispatch(self, request: Request, call_next):
|
||||
return_citations = False
|
||||
|
148
package-lock.json
generated
148
package-lock.json
generated
@ -8,6 +8,8 @@
|
||||
"name": "open-webui",
|
||||
"version": "0.1.124",
|
||||
"dependencies": {
|
||||
"@micropython/micropython-webassembly-pyscript": "^1.22.0-369",
|
||||
"@pyscript/core": "^0.4.32",
|
||||
"@sveltejs/adapter-node": "^1.3.1",
|
||||
"async": "^3.2.5",
|
||||
"bits-ui": "^0.19.7",
|
||||
@ -22,6 +24,7 @@
|
||||
"js-sha256": "^0.10.1",
|
||||
"katex": "^0.16.9",
|
||||
"marked": "^9.1.0",
|
||||
"pyodide": "^0.25.1",
|
||||
"svelte-sonner": "^0.3.19",
|
||||
"tippy.js": "^6.3.7",
|
||||
"uuid": "^9.0.1"
|
||||
@ -831,6 +834,11 @@
|
||||
"svelte": ">=3 <5"
|
||||
}
|
||||
},
|
||||
"node_modules/@micropython/micropython-webassembly-pyscript": {
|
||||
"version": "1.22.0-369",
|
||||
"resolved": "https://registry.npmjs.org/@micropython/micropython-webassembly-pyscript/-/micropython-webassembly-pyscript-1.22.0-369.tgz",
|
||||
"integrity": "sha512-+wqB6Va0rJtWXUmkthPVIEh1+Xh9Q+eJlBKWgYjjSe/FaRYo9z9U7CbvLaJNOJrb5R9dCTI6P9Ij4BrBxnwyVQ=="
|
||||
},
|
||||
"node_modules/@nodelib/fs.scandir": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||
@ -890,6 +898,19 @@
|
||||
"url": "https://opencollective.com/popperjs"
|
||||
}
|
||||
},
|
||||
"node_modules/@pyscript/core": {
|
||||
"version": "0.4.32",
|
||||
"resolved": "https://registry.npmjs.org/@pyscript/core/-/core-0.4.32.tgz",
|
||||
"integrity": "sha512-WQATzPp1ggf871+PukCmTypzScXkEB1EWD/vg5GNxpM96N6rDPqQ13msuA5XvwU01ZVhL8HHSFDLk4IfaXNGWg==",
|
||||
"dependencies": {
|
||||
"@ungap/with-resolvers": "^0.1.0",
|
||||
"basic-devtools": "^0.1.6",
|
||||
"polyscript": "^0.12.8",
|
||||
"sticky-module": "^0.1.1",
|
||||
"to-json-callback": "^0.1.1",
|
||||
"type-checked-collections": "^0.1.7"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-commonjs": {
|
||||
"version": "25.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-25.0.7.tgz",
|
||||
@ -1605,8 +1626,12 @@
|
||||
"node_modules/@ungap/structured-clone": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz",
|
||||
"integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ=="
|
||||
},
|
||||
"node_modules/@ungap/with-resolvers": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@ungap/with-resolvers/-/with-resolvers-0.1.0.tgz",
|
||||
"integrity": "sha512-g7f0IkJdPW2xhY7H4iE72DAsIyfuwEFc6JWc2tYFwKDMWWAF699vGjrM348cwQuOXgHpe1gWFe+Eiyjx/ewvvw=="
|
||||
},
|
||||
"node_modules/@vitest/expect": {
|
||||
"version": "1.6.0",
|
||||
@ -1713,6 +1738,11 @@
|
||||
"@types/estree": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@webreflection/fetch": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@webreflection/fetch/-/fetch-0.1.5.tgz",
|
||||
"integrity": "sha512-zCcqCJoNLvdeF41asAK71XPlwSPieeRDsE09albBunJEksuYPYNillKNQjf8p5BqSoTKTuKrW3lUm3MNodUC4g=="
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.11.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
||||
@ -2027,6 +2057,11 @@
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/base-64": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz",
|
||||
"integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg=="
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
@ -2047,6 +2082,11 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/basic-devtools": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/basic-devtools/-/basic-devtools-0.1.6.tgz",
|
||||
"integrity": "sha512-g9zJ63GmdUesS3/Fwv0B5SYX6nR56TQXmGr+wE5PRTNCnGQMYWhUx/nZB/mMWnQJVLPPAp89oxDNlasdtNkW5Q=="
|
||||
},
|
||||
"node_modules/bcrypt-pbkdf": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
|
||||
@ -2661,6 +2701,28 @@
|
||||
"@types/estree": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/codedent": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/codedent/-/codedent-0.1.2.tgz",
|
||||
"integrity": "sha512-qEqzcy5viM3UoCN0jYHZeXZoyd4NZQzYFg0kOBj8O1CgoGG9WYYTF+VeQRsN0OSKFjF3G1u4WDUOtOsWEx6N2w==",
|
||||
"dependencies": {
|
||||
"plain-tag": "^0.1.3"
|
||||
}
|
||||
},
|
||||
"node_modules/coincident": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/coincident/-/coincident-1.2.3.tgz",
|
||||
"integrity": "sha512-Uxz3BMTWIslzeWjuQnizGWVg0j6khbvHUQ8+5BdM7WuJEm4ALXwq3wluYoB+uF68uPBz/oUOeJnYURKyfjexlA==",
|
||||
"dependencies": {
|
||||
"@ungap/structured-clone": "^1.2.0",
|
||||
"@ungap/with-resolvers": "^0.1.0",
|
||||
"gc-hook": "^0.3.1",
|
||||
"proxy-target": "^3.0.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"ws": "^8.16.0"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
@ -4001,6 +4063,11 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/gc-hook": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/gc-hook/-/gc-hook-0.3.1.tgz",
|
||||
"integrity": "sha512-E5M+O/h2o7eZzGhzRZGex6hbB3k4NWqO0eA+OzLRLXxhdbYPajZnynPwAtphnh+cRHPwsj5Z80dqZlfI4eK55A=="
|
||||
},
|
||||
"node_modules/get-func-name": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz",
|
||||
@ -4328,6 +4395,11 @@
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/html-escaper": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-3.0.3.tgz",
|
||||
"integrity": "sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ=="
|
||||
},
|
||||
"node_modules/htmlparser2": {
|
||||
"version": "8.0.2",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz",
|
||||
@ -5838,6 +5910,29 @@
|
||||
"pathe": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"node_modules/plain-tag": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/plain-tag/-/plain-tag-0.1.3.tgz",
|
||||
"integrity": "sha512-yyVAOFKTAElc7KdLt2+UKGExNYwYb/Y/WE9i+1ezCQsJE8gbKSjewfpRqK2nQgZ4d4hhAAGgDCOcIZVilqE5UA=="
|
||||
},
|
||||
"node_modules/polyscript": {
|
||||
"version": "0.12.8",
|
||||
"resolved": "https://registry.npmjs.org/polyscript/-/polyscript-0.12.8.tgz",
|
||||
"integrity": "sha512-kcG3W9jU/s1sYjWOTAa2jAh5D2jm3zJRi+glSTsC+lA3D1b/Sd67pEIGpyL9bWNKYSimqAx4se6jAhQjJZ7+jQ==",
|
||||
"dependencies": {
|
||||
"@ungap/structured-clone": "^1.2.0",
|
||||
"@ungap/with-resolvers": "^0.1.0",
|
||||
"@webreflection/fetch": "^0.1.5",
|
||||
"basic-devtools": "^0.1.6",
|
||||
"codedent": "^0.1.2",
|
||||
"coincident": "^1.2.3",
|
||||
"gc-hook": "^0.3.1",
|
||||
"html-escaper": "^3.0.3",
|
||||
"proxy-target": "^3.0.2",
|
||||
"sticky-module": "^0.1.1",
|
||||
"to-json-callback": "^0.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.4.38",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz",
|
||||
@ -6151,6 +6246,11 @@
|
||||
"integrity": "sha512-F2JHgJQ1iqwnHDcQjVBsq3n/uoaFL+iPW/eAeL7kVxy/2RrWaN4WroKjjvbsoRtv0ftelNyC01bjRhn/bhcf4A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/proxy-target": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/proxy-target/-/proxy-target-3.0.2.tgz",
|
||||
"integrity": "sha512-FFE1XNwXX/FNC3/P8HiKaJSy/Qk68RitG/QEcLy/bVnTAPlgTAWPZKh0pARLAnpfXQPKyalBhk009NRTgsk8vQ=="
|
||||
},
|
||||
"node_modules/psl": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
|
||||
@ -6176,6 +6276,15 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/pyodide": {
|
||||
"version": "0.25.1",
|
||||
"resolved": "https://registry.npmjs.org/pyodide/-/pyodide-0.25.1.tgz",
|
||||
"integrity": "sha512-y0nJ/fLA3bxD2iZRzvVTbP2O+wp4Ewm2wThfV4HF0BytQ6hsoqTJFLNY4usLOcCVBrK8TTWqFqrmsVPzHe4rsw==",
|
||||
"dependencies": {
|
||||
"base-64": "^1.0.0",
|
||||
"ws": "^8.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.10.4",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.4.tgz",
|
||||
@ -6858,6 +6967,11 @@
|
||||
"integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/sticky-module": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/sticky-module/-/sticky-module-0.1.1.tgz",
|
||||
"integrity": "sha512-IuYgnyIMUx/m6rtu14l/LR2MaqOLtpXcWkxPmtPsiScRHEo+S4Tojk+DWFHOncSdFX/OsoLOM4+T92yOmI1AMw=="
|
||||
},
|
||||
"node_modules/stream-composer": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/stream-composer/-/stream-composer-1.0.2.tgz",
|
||||
@ -7520,6 +7634,11 @@
|
||||
"node": ">=14.14"
|
||||
}
|
||||
},
|
||||
"node_modules/to-json-callback": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/to-json-callback/-/to-json-callback-0.1.1.tgz",
|
||||
"integrity": "sha512-BzOeinTT3NjE+FJ2iCvWB8HvyuyBzoH3WlSnJ+AYVC4tlePyZWSYdkQIFOARWiq0t35/XhmI0uQsFiUsRksRqg=="
|
||||
},
|
||||
"node_modules/to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
@ -7629,6 +7748,11 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/type-checked-collections": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/type-checked-collections/-/type-checked-collections-0.1.7.tgz",
|
||||
"integrity": "sha512-fLIydlJy7IG9XL4wjRwEcKhxx/ekLXiWiMvcGo01cOMF+TN+5ZqajM1mRNRz2bNNi1bzou2yofhjZEQi7kgl9A=="
|
||||
},
|
||||
"node_modules/type-detect": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
|
||||
@ -8883,6 +9007,26 @@
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.17.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz",
|
||||
"integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
|
@ -47,6 +47,8 @@
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@micropython/micropython-webassembly-pyscript": "^1.22.0-369",
|
||||
"@pyscript/core": "^0.4.32",
|
||||
"@sveltejs/adapter-node": "^1.3.1",
|
||||
"async": "^3.2.5",
|
||||
"bits-ui": "^0.19.7",
|
||||
@ -61,6 +63,7 @@
|
||||
"js-sha256": "^0.10.1",
|
||||
"katex": "^0.16.9",
|
||||
"marked": "^9.1.0",
|
||||
"pyodide": "^0.25.1",
|
||||
"svelte-sonner": "^0.3.19",
|
||||
"tippy.js": "^6.3.7",
|
||||
"uuid": "^9.0.1"
|
||||
|
8
pyscript-mv.sh
Normal file
8
pyscript-mv.sh
Normal file
@ -0,0 +1,8 @@
|
||||
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/
|
20
src/Untitled-1.js
Normal file
20
src/Untitled-1.js
Normal file
@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -12,6 +12,10 @@
|
||||
title="Open WebUI"
|
||||
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
|
||||
(() => {
|
||||
@ -54,6 +58,11 @@
|
||||
%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
|
||||
|
@ -506,6 +506,7 @@
|
||||
>
|
||||
<div class="flex items-center gap-2 text-sm dark:text-gray-500">
|
||||
<img
|
||||
crossorigin="anonymous"
|
||||
alt="model profile"
|
||||
class="size-5 max-w-[28px] object-cover rounded-full"
|
||||
src={$modelfiles.find((modelfile) => modelfile.tagName === selectedModel.id)
|
||||
|
@ -2,10 +2,14 @@
|
||||
import { copyToClipboard } from '$lib/utils';
|
||||
import hljs from 'highlight.js';
|
||||
import 'highlight.js/styles/github-dark.min.css';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
export let id = '';
|
||||
|
||||
export let lang = '';
|
||||
export let code = '';
|
||||
|
||||
let executed = false;
|
||||
let copied = false;
|
||||
|
||||
const copyCode = async () => {
|
||||
@ -17,6 +21,184 @@
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const checkPythonCode = (str) => {
|
||||
// Check if the string contains typical Python keywords, syntax, or functions
|
||||
const pythonKeywords = [
|
||||
'def',
|
||||
'class',
|
||||
'import',
|
||||
'from',
|
||||
'if',
|
||||
'else',
|
||||
'elif',
|
||||
'for',
|
||||
'while',
|
||||
'try',
|
||||
'except',
|
||||
'finally',
|
||||
'return',
|
||||
'yield',
|
||||
'lambda',
|
||||
'assert',
|
||||
'pass',
|
||||
'break',
|
||||
'continue',
|
||||
'global',
|
||||
'nonlocal',
|
||||
'del',
|
||||
'True',
|
||||
'False',
|
||||
'None',
|
||||
'and',
|
||||
'or',
|
||||
'not',
|
||||
'in',
|
||||
'is',
|
||||
'as',
|
||||
'with'
|
||||
];
|
||||
|
||||
for (let keyword of pythonKeywords) {
|
||||
if (str.includes(keyword)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the string contains typical Python syntax characters
|
||||
const pythonSyntax = [
|
||||
'def ',
|
||||
'class ',
|
||||
'import ',
|
||||
'from ',
|
||||
'if ',
|
||||
'else:',
|
||||
'elif ',
|
||||
'for ',
|
||||
'while ',
|
||||
'try:',
|
||||
'except:',
|
||||
'finally:',
|
||||
'return ',
|
||||
'yield ',
|
||||
'lambda ',
|
||||
'assert ',
|
||||
'pass',
|
||||
'break',
|
||||
'continue',
|
||||
'global ',
|
||||
'nonlocal ',
|
||||
'del ',
|
||||
'True',
|
||||
'False',
|
||||
'None',
|
||||
' and ',
|
||||
' or ',
|
||||
' not ',
|
||||
' in ',
|
||||
' is ',
|
||||
' as ',
|
||||
' with ',
|
||||
':',
|
||||
'=',
|
||||
'==',
|
||||
'!=',
|
||||
'>',
|
||||
'<',
|
||||
'>=',
|
||||
'<=',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'%',
|
||||
'**',
|
||||
'//',
|
||||
'(',
|
||||
')',
|
||||
'[',
|
||||
']',
|
||||
'{',
|
||||
'}'
|
||||
];
|
||||
|
||||
for (let syntax of pythonSyntax) {
|
||||
if (str.includes(syntax)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// If none of the above conditions met, it's probably not Python code
|
||||
return false;
|
||||
};
|
||||
|
||||
const executePython = async (text) => {
|
||||
executed = true;
|
||||
|
||||
await tick();
|
||||
const outputDiv = document.getElementById(`code-output-${id}`);
|
||||
|
||||
if (outputDiv) {
|
||||
outputDiv.innerText = 'Running...';
|
||||
}
|
||||
|
||||
text = text
|
||||
.split('\n')
|
||||
.map((line, index) => (index === 0 ? line : ' ' + line))
|
||||
.join('\n');
|
||||
|
||||
// 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);
|
||||
}
|
||||
};
|
||||
|
||||
$: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : '';
|
||||
</script>
|
||||
|
||||
@ -26,15 +208,34 @@
|
||||
class="flex justify-between bg-[#202123] text-white text-xs px-4 pt-1 pb-0.5 rounded-t-lg overflow-x-auto"
|
||||
>
|
||||
<div class="p-1">{@html lang}</div>
|
||||
|
||||
<div class="flex items-center">
|
||||
{#if lang === 'python' || checkPythonCode(code)}
|
||||
<button
|
||||
class="copy-code-button bg-none border-none p-1"
|
||||
on:click={() => {
|
||||
executePython(code);
|
||||
}}>Run</button
|
||||
>
|
||||
{/if}
|
||||
<button class="copy-code-button bg-none border-none p-1" on:click={copyCode}
|
||||
>{copied ? 'Copied' : 'Copy Code'}</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<pre
|
||||
class=" hljs p-4 px-5 overflow-x-auto"
|
||||
style="border-top-left-radius: 0px; border-top-right-radius: 0px;"><code
|
||||
style="border-top-left-radius: 0px; border-top-right-radius: 0px; {executed &&
|
||||
'border-bottom-left-radius: 0px; border-bottom-right-radius: 0px;'}"><code
|
||||
class="language-{lang} rounded-t-none whitespace-pre">{@html highlightedCode || code}</code
|
||||
></pre>
|
||||
|
||||
{#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>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
@ -43,6 +43,7 @@
|
||||
>
|
||||
{#if model in modelfiles}
|
||||
<img
|
||||
crossorigin="anonymous"
|
||||
src={modelfiles[model]?.imageUrl ?? `${WEBUI_BASE_URL}/static/favicon.png`}
|
||||
alt="modelfile"
|
||||
class=" size-[2.7rem] rounded-full border-[1px] border-gray-200 dark:border-none"
|
||||
@ -50,6 +51,7 @@
|
||||
/>
|
||||
{:else}
|
||||
<img
|
||||
crossorigin="anonymous"
|
||||
src={$i18n.language === 'dg-DG'
|
||||
? `/doge.png`
|
||||
: `${WEBUI_BASE_URL}/static/favicon.png`}
|
||||
|
@ -3,5 +3,11 @@
|
||||
</script>
|
||||
|
||||
<div class=" mr-3">
|
||||
<img {src} class=" w-8 object-cover rounded-full" alt="profile" draggable="false" />
|
||||
<img
|
||||
crossorigin="anonymous"
|
||||
{src}
|
||||
class=" w-8 object-cover rounded-full"
|
||||
alt="profile"
|
||||
draggable="false"
|
||||
/>
|
||||
</div>
|
||||
|
@ -437,6 +437,7 @@
|
||||
{#each tokens as token}
|
||||
{#if token.type === 'code'}
|
||||
<CodeBlock
|
||||
id={message.id}
|
||||
lang={token.lang}
|
||||
code={revertSanitizedResponseContent(token.text)}
|
||||
/>
|
||||
|
@ -248,6 +248,7 @@
|
||||
>
|
||||
<div class="self-center mx-1.5">
|
||||
<img
|
||||
crossorigin="anonymous"
|
||||
src="{WEBUI_BASE_URL}/static/favicon.png"
|
||||
class=" size-6 -translate-x-1.5 rounded-full"
|
||||
alt="logo"
|
||||
|
@ -89,7 +89,7 @@
|
||||
|
||||
<svelte:head>
|
||||
<title>{$WEBUI_NAME}</title>
|
||||
<link rel="icon" href="{WEBUI_BASE_URL}/static/favicon.png" />
|
||||
<link crossorigin="anonymous" rel="icon" href="{WEBUI_BASE_URL}/static/favicon.png" />
|
||||
|
||||
<!-- rosepine themes have been disabled as it's not up to date with our latest version. -->
|
||||
<!-- feel free to make a PR to fix if anyone wants to see it return -->
|
||||
|
@ -76,7 +76,12 @@
|
||||
<div class="fixed m-10 z-50">
|
||||
<div class="flex space-x-2">
|
||||
<div class=" self-center">
|
||||
<img src="{WEBUI_BASE_URL}/static/favicon.png" class=" w-8 rounded-full" alt="logo" />
|
||||
<img
|
||||
crossorigin="anonymous"
|
||||
src="{WEBUI_BASE_URL}/static/favicon.png"
|
||||
class=" w-8 rounded-full"
|
||||
alt="logo"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
1
static/pyodide/pyodide-lock.json
Normal file
1
static/pyodide/pyodide-lock.json
Normal file
File diff suppressed because one or more lines are too long
17
static/pyodide/pyodide.asm.js
Normal file
17
static/pyodide/pyodide.asm.js
Normal file
File diff suppressed because one or more lines are too long
BIN
static/pyodide/pyodide.asm.wasm
Executable file
BIN
static/pyodide/pyodide.asm.wasm
Executable file
Binary file not shown.
1476
static/pyodide/pyodide.d.ts
vendored
Normal file
1476
static/pyodide/pyodide.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
12
static/pyodide/pyodide.js
Normal file
12
static/pyodide/pyodide.js
Normal file
File diff suppressed because one or more lines are too long
7
static/pyodide/pyodide.js.map
Normal file
7
static/pyodide/pyodide.js.map
Normal file
File diff suppressed because one or more lines are too long
10
static/pyodide/pyodide.mjs
Normal file
10
static/pyodide/pyodide.mjs
Normal file
File diff suppressed because one or more lines are too long
7
static/pyodide/pyodide.mjs.map
Normal file
7
static/pyodide/pyodide.mjs.map
Normal file
File diff suppressed because one or more lines are too long
BIN
static/pyodide/python_stdlib.zip
Normal file
BIN
static/pyodide/python_stdlib.zip
Normal file
Binary file not shown.
2
static/pyscript/codemirror-Dr2Hgejs.js
Normal file
2
static/pyscript/codemirror-Dr2Hgejs.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/codemirror-Dr2Hgejs.js.map
Normal file
1
static/pyscript/codemirror-Dr2Hgejs.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/codemirror_commands-MgxtVkrD.js
Normal file
2
static/pyscript/codemirror_commands-MgxtVkrD.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/codemirror_commands-MgxtVkrD.js.map
Normal file
1
static/pyscript/codemirror_commands-MgxtVkrD.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/codemirror_lang-python-Cxoc-ydj.js
Normal file
2
static/pyscript/codemirror_lang-python-Cxoc-ydj.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/codemirror_lang-python-Cxoc-ydj.js.map
Normal file
1
static/pyscript/codemirror_lang-python-Cxoc-ydj.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/codemirror_language-_XiX6II0.js
Normal file
2
static/pyscript/codemirror_language-_XiX6II0.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/codemirror_language-_XiX6II0.js.map
Normal file
1
static/pyscript/codemirror_language-_XiX6II0.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/codemirror_state-BKbyfKsm.js
Normal file
2
static/pyscript/codemirror_state-BKbyfKsm.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/codemirror_state-BKbyfKsm.js.map
Normal file
1
static/pyscript/codemirror_state-BKbyfKsm.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/codemirror_view-C0PMO2z_.js
Normal file
2
static/pyscript/codemirror_view-C0PMO2z_.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/codemirror_view-C0PMO2z_.js.map
Normal file
1
static/pyscript/codemirror_view-C0PMO2z_.js.map
Normal file
File diff suppressed because one or more lines are too long
3
static/pyscript/core-CPpjJT4b.js
Normal file
3
static/pyscript/core-CPpjJT4b.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/core-CPpjJT4b.js.map
Normal file
1
static/pyscript/core-CPpjJT4b.js.map
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/core.css
Normal file
1
static/pyscript/core.css
Normal file
@ -0,0 +1 @@
|
||||
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}
|
2
static/pyscript/core.js
Normal file
2
static/pyscript/core.js
Normal file
@ -0,0 +1,2 @@
|
||||
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
|
1
static/pyscript/core.js.map
Normal file
1
static/pyscript/core.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"core.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
2
static/pyscript/deprecations-manager-CQ0oxKrq.js
Normal file
2
static/pyscript/deprecations-manager-CQ0oxKrq.js
Normal file
@ -0,0 +1,2 @@
|
||||
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
|
1
static/pyscript/deprecations-manager-CQ0oxKrq.js.map
Normal file
1
static/pyscript/deprecations-manager-CQ0oxKrq.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
2
static/pyscript/error-BfnovtqK.js
Normal file
2
static/pyscript/error-BfnovtqK.js
Normal file
@ -0,0 +1,2 @@
|
||||
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
|
1
static/pyscript/error-BfnovtqK.js.map
Normal file
1
static/pyscript/error-BfnovtqK.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
2
static/pyscript/index-CTWZX_TW.js
Normal file
2
static/pyscript/index-CTWZX_TW.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/index-CTWZX_TW.js.map
Normal file
1
static/pyscript/index-CTWZX_TW.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/py-editor-CmqzUo2Z.js
Normal file
2
static/pyscript/py-editor-CmqzUo2Z.js
Normal file
@ -0,0 +1,2 @@
|
||||
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
|
1
static/pyscript/py-editor-CmqzUo2Z.js.map
Normal file
1
static/pyscript/py-editor-CmqzUo2Z.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/py-terminal-CgcHH2nx.js
Normal file
2
static/pyscript/py-terminal-CgcHH2nx.js
Normal file
@ -0,0 +1,2 @@
|
||||
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
|
1
static/pyscript/py-terminal-CgcHH2nx.js.map
Normal file
1
static/pyscript/py-terminal-CgcHH2nx.js.map
Normal file
File diff suppressed because one or more lines are too long
3
static/pyscript/toml-CvAfdf9_.js
Normal file
3
static/pyscript/toml-CvAfdf9_.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/toml-CvAfdf9_.js.map
Normal file
1
static/pyscript/toml-CvAfdf9_.js.map
Normal file
File diff suppressed because one or more lines are too long
3
static/pyscript/toml-DiUM0_qs.js
Normal file
3
static/pyscript/toml-DiUM0_qs.js
Normal file
@ -0,0 +1,3 @@
|
||||
/*! (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
|
1
static/pyscript/toml-DiUM0_qs.js.map
Normal file
1
static/pyscript/toml-DiUM0_qs.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/xterm-DqawCVsv.js
Normal file
2
static/pyscript/xterm-DqawCVsv.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/xterm-DqawCVsv.js.map
Normal file
1
static/pyscript/xterm-DqawCVsv.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/xterm-readline-D247p8vq.js
Normal file
2
static/pyscript/xterm-readline-D247p8vq.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/xterm-readline-D247p8vq.js.map
Normal file
1
static/pyscript/xterm-readline-D247p8vq.js.map
Normal file
File diff suppressed because one or more lines are too long
7
static/pyscript/xterm.css
Normal file
7
static/pyscript/xterm.css
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* 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}
|
2
static/pyscript/xterm_addon-fit--gyF3PcZ.js
Normal file
2
static/pyscript/xterm_addon-fit--gyF3PcZ.js
Normal file
@ -0,0 +1,2 @@
|
||||
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
|
1
static/pyscript/xterm_addon-fit--gyF3PcZ.js.map
Normal file
1
static/pyscript/xterm_addon-fit--gyF3PcZ.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
2
static/pyscript/xterm_addon-web-links-Cnej-nJ6.js
Normal file
2
static/pyscript/xterm_addon-web-links-Cnej-nJ6.js
Normal file
@ -0,0 +1,2 @@
|
||||
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
|
1
static/pyscript/xterm_addon-web-links-Cnej-nJ6.js.map
Normal file
1
static/pyscript/xterm_addon-web-links-Cnej-nJ6.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/pyscript/zip-D2yvzXKD.js
Normal file
2
static/pyscript/zip-D2yvzXKD.js
Normal file
File diff suppressed because one or more lines are too long
1
static/pyscript/zip-D2yvzXKD.js.map
Normal file
1
static/pyscript/zip-D2yvzXKD.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -6,7 +6,6 @@ const config = {
|
||||
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
|
||||
// for more information about preprocessors
|
||||
preprocess: vitePreprocess(),
|
||||
|
||||
kit: {
|
||||
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
|
||||
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
|
||||
|
@ -1,8 +1,22 @@
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
/** @type {import('vite').Plugin} */
|
||||
const viteServerConfig = {
|
||||
name: 'log-request-middleware',
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, res, next) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
res.setHeader('Access-Control-Allow-Methods', 'GET');
|
||||
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
|
||||
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
|
||||
next();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [sveltekit()],
|
||||
plugins: [sveltekit(), viteServerConfig],
|
||||
define: {
|
||||
APP_VERSION: JSON.stringify(process.env.npm_package_version)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user