PageSourceSearch

https://sysdba.co.kr/_app/immutable/chunks/CFrvYhlc.js

js sysdba.co.kr collected 2026-10-04 05:45:10 UTC 7,944 bytes, 186 lines download raw bytes

1var d=Object.defineProperty;var p=(r,e,t)=>e in r?d(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>p(r,typeof e!="symbol"?e+"":e,t);import{b5 as l}from"./7a2fV5I9.js";import{c as u}from"./C33EP41Y.js";const c=String.raw`
2(function () {
3	let pyodide = null;
4	let pyodideReady = null;
5	let stdout = null;
6	let stderr = null;
7
8	function post(message, transfer) {
9		parent.postMessage(message, '*', transfer || []);
10	}
11
12	async function loadRuntime(packages) {
13		stdout = null;
14		stderr = null;
15		pyodide = await loadPyodide({
16			indexURL: self.__PYODIDE_INDEX_URL__ || '/pyodide/',
17			stdout: function (text) {
18				stdout = stdout ? stdout + text + '\n' : text + '\n';
19			},
20			stderr: function (text) {
21				stderr = stderr ? stderr + text + '\n' : text + '\n';
22			},
23			packages: ['micropip']
24		});
25		pyodide.FS.mkdirTree('/mnt/uploads');
26		await pyodide.pyimport('micropip').install(packages || []);
27	}
28
29	async function ensureRuntime(packages) {
30		if (!pyodideReady) pyodideReady = loadRuntime(packages || []);
31		await pyodideReady;
32		if (packages && packages.length > 0) {
33			await pyodide.pyimport('micropip').install(packages);
34		}
35	}
36
37	function ensureDir(dir) {
38		try {
39			pyodide.FS.stat(dir);
40		} catch {
41			pyodide.FS.mkdirTree(dir);
42		}
43	}
44
45	function upload(files, dir) {
46		dir = dir || '/mnt/uploads';
47		ensureDir(dir);
48		for (const file of files || []) {
49			pyodide.FS.writeFile(dir + '/' + file.name, new Uint8Array(file.data));
50		}
51	}
52
53	function list(path) {
54		const entries = [];
55		try {
56			const names = pyodide.FS.readdir(path).filter(function (name) {
57				return name !== '.' && name !== '..';
58			});
59			for (const name of names) {
60				try {
61					const stat = pyodide.FS.stat(path + '/' + name);
62					const isDir = pyodide.FS.isDir(stat.mode);
63					entries.push({ name: name, type: isDir ? 'directory' : 'file', size: isDir ? 0 : stat.size });
64				} catch {}
65			}
66		} catch {}
67		return entries;
68	}
69
70	function remove(path) {
71		try {
72			const stat = pyodide.FS.stat(path);
73			if (!pyodide.FS.isDir(stat.mode)) {
74				pyodide.FS.unlink(path);
75				return;
76			}
77			const names = pyodide.FS.readdir(path).filter(function (name) {
78				return name !== '.' && name !== '..';
79			});
80			for (const name of names) remove(path + '/' + name);
81			pyodide.FS.rmdir(path);
82		} catch {}
83	}
84
85	function clean(value) {
86		try {
87			if (value == null) return null;
88			if (['string', 'number', 'boolean'].includes(typeof value)) return value;
89			if (typeof value === 'bigint') return value.toString();
90			if (Array.isArray(value)) return value.map(clean);
91			if (typeof value.toJs === 'function') return clean(value.toJs());
92			if (typeof value === 'object') {
93				const out = {};
94				for (const key in value) {
95					if (Object.prototype.hasOwnProperty.call(value, key)) out[key] = clean(value[key]);
96				}
97				return out;
98			}
99			return JSON.stringify(value);
100		} catch (error) {
101			return '[processResult error]: ' + (error && error.message ? error.message : String(error));
102		}
103	}
104
105	async function patchMatplotlib() {
106		await pyodide.runPythonAsync([
107			'import base64',
108			'import os',
109			'from io import BytesIO',
110			'os.environ["MPLBACKEND"] = "AGG"',
111			'import matplotlib.pyplot',
112			'_old_show = matplotlib.pyplot.show',
113			'assert _old_show, "matplotlib.pyplot.show"',
114			'def show(*, block=None):',
115			// String.raw keeps \t as-is; the sandbox's JS parser turns it into a real tab
116			'\tbuf = BytesIO()',
117			'\tmatplotlib.pyplot.savefig(buf, format="png")',
118			'\tbuf.seek(0)',
119			'\timg_str = base64.b64encode(buf.read()).decode("utf-8")',
120			'\tmatplotlib.pyplot.clf()',
121			'\tbuf.close()',
122			'\tprint(f"data:image/png;base64,{img_str}")',
123			'matplotlib.pyplot.show = show'
124		].join('\n'));
125	}
126
127	async function execute(id, code, files) {
128		stdout = null;
129		stderr = null;
130		let result = null;
131		if (files && files.length > 0) upload(files);
132		try {
133			if (code.includes('matplotlib')) await patchMatplotlib();
134			result = clean(await pyodide.runPythonAsync(code));
135		} catch (error) {
136			stderr = error && error.message ? error.message : String(error);
137		}
138		post({ id: id, result: result, stdout: stdout, stderr: stderr });
139	}
140
141	window.addEventListener('message', async function (event) {
142		if (event.source !== parent) return;
143		const data = event.data || {};
144		const id = data.id;
145		try {
146			if (!data.type || data.type === 'execute') {
147				await ensureRuntime(data.packages || []);
148				await execute(id, data.code, data.files);
149				return;
150			}
151			await ensureRuntime();
152			switch (data.type) {
153				case 'fs:upload':
154					upload(data.files, data.dir);
155					post({ id: id, type: data.type, success: true });
156					break;
157				case 'fs:list':
158					post({ id: id, type: data.type, entries: list(data.path) });
159					break;
160				case 'fs:read':
161					try {
162						const buffer = pyodide.FS.readFile(data.path).buffer;
163						post({ id: id, type: data.type, data: buffer }, [buffer]);
164					} catch (error) {
165						post({ id: id, type: data.type, error: error && error.message ? error.message : 
165String(error) });
166					}
167					break;
168				case 'fs:delete':
169					remove(data.path);
170					post({ id: id, type: data.type, success: true });
171					break;
172				case 'fs:mkdir':
173					pyodide.FS.mkdirTree(data.path);
174					post({ id: id, type: data.type, success: true });
175					break;
176				case 'fs:sync':
177					post({ id: id, type: data.type, success: true });
178					break;
179			}
180		} catch (error) {
181			post({ id: id, stderr: error && error.message ? error.message : String(error) });
182		}
183	});
184})();
185`;var o;const i=`${((o=globalThis.location)==null?void 0:o.origin)??""}/pyodide/`,f=`<!doctype html><html><head><meta charset="utf-8"><script>window.__PYODIDE_INDEX_URL__=${JSON.stringify(i)}<\/script></head><body><script src="${i}pyodide.js"><\/script><script>${c}<\/script></body></html>`;class m{constructor(){s(this,"onmessage",null);s(this,"onerror",null);s(this,"iframe");s(this,"ready",!1);s(this,"queue",[]);s(this,"messageListeners",new Set);s(this,"errorListeners",new Set);s(this,"onWindowMessage");s(this,"onIframeLoad");s(this,"onIframeError");this.iframe=document.createElement("iframe"),this.iframe.setAttribute("sandbox","allow-scripts"),this.iframe.setAttribute("aria-hidden","true"),this.iframe.setAttribute("title","pyodide-sandbox"),this.iframe.style.display="none",this.iframe.srcdoc=f,this.onWindowMessage=e=>{var a;if(e.source!==this.iframe.contentWindow)return;const t={data:e.data};(a=this.onmessage)==null||a.call(this,t);for(const n of this.messageListeners)n(t)},this.onIframeLoad=()=>{this.ready=!0;for(const e of this.queue)this.post(e.message,e.transfer);this.queue=[]},this.onIframeError=e=>{var t;(t=this.onerror)==null||t.call(this,e);for(const a of this.errorListeners)a(e)},window.addEventListener("message",this.onWindowMessage),this.iframe.addEventListener("load",this.onIframeLoad,{once:!0}),this.iframe.addEventListener("error",this.onIframeError),document.body.appendChild(this.iframe)}postMessage(e,t=[]){this.ready?this.post(e,t):this.queue.push({message:e,transfer:t})}addEventListener(e,t){e==="message"?this.messageListeners.add(t):e==="error"&&this.errorListeners.add(t)}removeEventListener(e,t){e==="message"?this.messageListeners.delete(t):e==="error"&&this.errorListeners.delete(t)}terminate(){window.removeEventListener("message",this.onWindowMessage),this.iframe.removeEventListener("load",this.onIframeLoad),this.iframe.removeEventListener("error",this.onIframeError),this.messageListeners.clear(),this.errorListeners.clear(),this.onmessage=null,this.onerror=null,this.iframe.remove()}post(e,t){var a;(a=this.iframe.contentWindow)==null||a.postMessage(e,"*",t)}}function y(r){return new Worker(""+new URL("../workers/pyodide.worker-Dq63i-DV.js",import.meta.url).href,{type:"module",name:r==null?void 0:r.name})}const w=()=>{var r,e;return(e=(r=l(u))==null?void 0:r.features)!=null&&e.enable_pyodide_file_persistence?new y:new m};export{w as c};
186//# sourceMappingURL=CFrvYhlc.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.