code-playpad 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -18
- package/dist/COMPILER-LICENSE-AUDIT.md +2 -2
- package/dist/cdn.js +2 -2
- package/dist/compiler-license-manifest.json +6 -1
- package/dist/config-CT3H6Oum.js +6 -0
- package/dist/{cpp-D2TrExLz.js → cpp-CO2abWii.js} +1 -1
- package/dist/{cpp-DakNa4ys.js → cpp-Cs32J8JC.js} +1 -1
- package/dist/{element-BQWrbSEp.js → element-CQGYVEF7.js} +1 -1
- package/dist/element.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{java-Xf1xYcVv.js → java-8qjVCjsN.js} +1 -1
- package/dist/{javascript-CTY3U1Mc.js → javascript-B1tVx7AD.js} +1 -1
- package/dist/{javascript-DkarEcEB.js → javascript-DLPaJJzf.js} +1 -1
- package/dist/{pyodide-B1U3JD9Z.js → pyodide-BOoYEfX1.js} +1 -1
- package/dist/{pyodide-BGBI232i.js → pyodide-C8ImkXdD.js} +1 -1
- package/dist/react.js +1 -1
- package/dist/runtime/config.d.ts +2 -0
- package/dist/standalone.js +1 -1
- package/dist/{worker-runtime-Dq71SbjR.js → worker-runtime-sUPz1J56.js} +1 -1
- package/package.json +1 -1
- package/dist/config-cwuPIQ48.js +0 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as e}from"./config-
|
|
1
|
+
import{s as e}from"./config-CT3H6Oum.js";import{t}from"./worker-runtime-sUPz1J56.js";var n=`let currentId=null,stdinLines=[],stdinExhausted=!1,nextRequest=1,inputWaitMs=0;const pendingLines=new Map;let sucrasePromise=null,sucraseURL=null;const pendingModules=new Map;class TransformLoadError extends Error{}function requestModule(t){return new Promise((e,r)=>{pendingModules.set(t,{resolve:e,reject:r}),post({type:"module-request",id:currentId,name:t})})}function post(t){self.postMessage(t)}let functionLineOffset=0;try{new Function('throw new Error("probe")')()}catch(t){const e=/<anonymous>:(\\d+):/.exec(t.stack||"");e&&(functionLineOffset=Number(e[1])-1)}let currentFiles=[];const FLUSH_BYTES=8192,FLUSH_MS=16,EAGER_POSTS=32;let outputQueue=[],queuedChars=0,windowStart=-1/0,windowPosts=0;function writeOutput(t,e){const r=outputQueue[outputQueue.length-1];r&&r.type===t?r.text+=e:outputQueue.push({type:t,text:e}),queuedChars+=e.length;const i=performance.now();i-windowStart>=FLUSH_MS&&(windowStart=i,windowPosts=0),(windowPosts<EAGER_POSTS||queuedChars>=FLUSH_BYTES)&&flushOutput()}function flushOutput(){if(!outputQueue.length)return;windowPosts++;const t=outputQueue;outputQueue=[],queuedChars=0;for(const e of t)post({type:e.type,id:currentId,text:e.text})}function format(t,e,r){if(e=e||new Set,typeof t=="string")return r?t:JSON.stringify(t);if(typeof t=="bigint")return String(t)+"n";if(typeof t=="function")return"[Function"+(t.name?": "+t.name:"")+"]";if(typeof t=="symbol"||t==null||typeof t!="object")return String(t);if(e.has(t))return"[Circular]";e.add(t);try{if(t instanceof Error)return t.stack||t.name+": "+t.message;if(Array.isArray(t))return"[ "+t.map(n=>format(n,e)).join(", ")+" ]";if(t instanceof Map)return"Map("+t.size+") { "+[...t].map(([n,o])=>format(n,e)+" => "+format(o,e)).join(", ")+" }";if(t instanceof Set)return"Set("+t.size+") { "+[...t].map(n=>format(n,e)).join(", ")+" }";if(t instanceof Date)return t.toISOString();if(t instanceof Promise)return"Promise { \\u2026 }";const i=Object.entries(t).map(([n,o])=>n+": "+format(o,e)),a=t.constructor&&t.constructor.name;return(a&&a!=="Object"?a+" ":"")+"{ "+i.join(", ")+" }"}finally{e.delete(t)}}function formatArgs(t){return t.map(e=>format(e,null,!0)).join(" ")+\`
|
|
2
2
|
\`}const nativeConsole=self.console;self.console=Object.assign(Object.create(nativeConsole),{log:(...t)=>writeOutput("stdout",formatArgs(t)),info:(...t)=>writeOutput("stdout",formatArgs(t)),debug:(...t)=>writeOutput("stdout",formatArgs(t)),warn:(...t)=>writeOutput("stderr",formatArgs(t)),error:(...t)=>writeOutput("stderr",formatArgs(t))}),self._ppReadLine=async()=>{if(stdinLines.length){const i=stdinLines.shift();return writeOutput("echo",i+\`
|
|
3
3
|
\`),i}const t=nextRequest++;flushOutput();const e=performance.now(),r=await new Promise(i=>{pendingLines.set(t,i),post({type:"stdin-request",id:currentId,request:t})});return inputWaitMs+=performance.now()-e,typeof r!="string"&&(stdinExhausted=!0),typeof r=="string"?r:null};async function input(t){t!==void 0&&writeOutput("stdout",String(t));const e=await self._ppReadLine();if(e===null)throw new Error("EOF: no more input");return e}self.input=input;async function loadSucrase(){return sucrasePromise||(sucrasePromise=(async()=>{try{if(sucraseURL)return await import(sucraseURL);const t=await requestModule("sucrase"),e=URL.createObjectURL(new Blob([t],{type:"text/javascript"}));try{return await import(e)}finally{URL.revokeObjectURL(e)}}catch(t){const e=sucraseURL?" from "+sucraseURL:"";throw new TransformLoadError("Could not load the TypeScript transform (Sucrase)"+e+": "+(t&&t.message?t.message:String(t)))}})(),sucrasePromise.catch(()=>{sucrasePromise=null})),sucrasePromise}function isModule(t,e){return Object.keys(t).length>1?!0:/^\\s*(import|export)\\s/m.test(t[e]||"")}function needsTypeScript(t){return/\\.(ts|tsx|jsx|mts|cts)$/.test(t)}function transformsFor(t){const e=["imports"];return/\\.tsx?$|\\.mts$|\\.cts$/.test(t)&&e.push("typescript"),/\\.[jt]sx$/.test(t)&&e.push("jsx"),e}async function runAsModules(t,e){const{transform:r}=await loadSucrase(),i=new Map,a=(n,o)=>{if(!o.startsWith("."))return null;const u=((n.includes("/")?n.slice(0,n.lastIndexOf("/")+1):"")+o).split("/"),d=[];for(const p of u)p==="."||p===""||(p===".."?d.pop():d.push(p));const c=d.join("/");return[c,c+".js",c+".ts",c+".tsx",c+".jsx",c+".json",c+"/index.js",c+"/index.ts"].find(p=>p in t)||null};function s(n){if(i.has(n))return i.get(n).exports;const o={exports:{}};if(i.set(n,o),n.endsWith(".json")){try{o.exports=JSON.parse(t[n])}catch(c){throw new SyntaxError("Invalid JSON in "+n+": "+c.message)}return o.exports}const{code:f}=r(t[n],{transforms:transformsFor(n),filePath:n,preserveDynamicImport:!0}),u=c=>{const l=a(n,c);if(!l)throw new Error('Cannot find module "'+c+'" from "'+n+'"');return s(l)};return new Function("exports","require","module","__filename","input","console",f+\`
|
|
4
4
|
//# sourceURL=\`+n)(o.exports,u,o,n,input,self.console),o.exports}s(e)}async function run(t){currentId=t.id,stdinLines=t.stdin?String(t.stdin).replace(/\\n$/,"").split(\`
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
|
|
4
4
|
* Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
|
|
5
5
|
*/
|
|
6
|
-
import{s as e}from"./config-
|
|
6
|
+
import{s as e}from"./config-CT3H6Oum.js";import{t}from"./worker-runtime-DfYet3xy.js";var n=`let currentId=null,stdinLines=[],stdinExhausted=!1,nextRequest=1,inputWaitMs=0;const pendingLines=new Map;let sucrasePromise=null,sucraseURL=null;const pendingModules=new Map;class TransformLoadError extends Error{}function requestModule(t){return new Promise((e,r)=>{pendingModules.set(t,{resolve:e,reject:r}),post({type:"module-request",id:currentId,name:t})})}function post(t){self.postMessage(t)}let functionLineOffset=0;try{new Function('throw new Error("probe")')()}catch(t){const e=/<anonymous>:(\\d+):/.exec(t.stack||"");e&&(functionLineOffset=Number(e[1])-1)}let currentFiles=[];const FLUSH_BYTES=8192,FLUSH_MS=16,EAGER_POSTS=32;let outputQueue=[],queuedChars=0,windowStart=-1/0,windowPosts=0;function writeOutput(t,e){const r=outputQueue[outputQueue.length-1];r&&r.type===t?r.text+=e:outputQueue.push({type:t,text:e}),queuedChars+=e.length;const i=performance.now();i-windowStart>=FLUSH_MS&&(windowStart=i,windowPosts=0),(windowPosts<EAGER_POSTS||queuedChars>=FLUSH_BYTES)&&flushOutput()}function flushOutput(){if(!outputQueue.length)return;windowPosts++;const t=outputQueue;outputQueue=[],queuedChars=0;for(const e of t)post({type:e.type,id:currentId,text:e.text})}function format(t,e,r){if(e=e||new Set,typeof t=="string")return r?t:JSON.stringify(t);if(typeof t=="bigint")return String(t)+"n";if(typeof t=="function")return"[Function"+(t.name?": "+t.name:"")+"]";if(typeof t=="symbol"||t==null||typeof t!="object")return String(t);if(e.has(t))return"[Circular]";e.add(t);try{if(t instanceof Error)return t.stack||t.name+": "+t.message;if(Array.isArray(t))return"[ "+t.map(n=>format(n,e)).join(", ")+" ]";if(t instanceof Map)return"Map("+t.size+") { "+[...t].map(([n,o])=>format(n,e)+" => "+format(o,e)).join(", ")+" }";if(t instanceof Set)return"Set("+t.size+") { "+[...t].map(n=>format(n,e)).join(", ")+" }";if(t instanceof Date)return t.toISOString();if(t instanceof Promise)return"Promise { \\u2026 }";const i=Object.entries(t).map(([n,o])=>n+": "+format(o,e)),a=t.constructor&&t.constructor.name;return(a&&a!=="Object"?a+" ":"")+"{ "+i.join(", ")+" }"}finally{e.delete(t)}}function formatArgs(t){return t.map(e=>format(e,null,!0)).join(" ")+\`
|
|
7
7
|
\`}const nativeConsole=self.console;self.console=Object.assign(Object.create(nativeConsole),{log:(...t)=>writeOutput("stdout",formatArgs(t)),info:(...t)=>writeOutput("stdout",formatArgs(t)),debug:(...t)=>writeOutput("stdout",formatArgs(t)),warn:(...t)=>writeOutput("stderr",formatArgs(t)),error:(...t)=>writeOutput("stderr",formatArgs(t))}),self._ppReadLine=async()=>{if(stdinLines.length){const i=stdinLines.shift();return writeOutput("echo",i+\`
|
|
8
8
|
\`),i}const t=nextRequest++;flushOutput();const e=performance.now(),r=await new Promise(i=>{pendingLines.set(t,i),post({type:"stdin-request",id:currentId,request:t})});return inputWaitMs+=performance.now()-e,typeof r!="string"&&(stdinExhausted=!0),typeof r=="string"?r:null};async function input(t){t!==void 0&&writeOutput("stdout",String(t));const e=await self._ppReadLine();if(e===null)throw new Error("EOF: no more input");return e}self.input=input;async function loadSucrase(){return sucrasePromise||(sucrasePromise=(async()=>{try{if(sucraseURL)return await import(sucraseURL);const t=await requestModule("sucrase"),e=URL.createObjectURL(new Blob([t],{type:"text/javascript"}));try{return await import(e)}finally{URL.revokeObjectURL(e)}}catch(t){const e=sucraseURL?" from "+sucraseURL:"";throw new TransformLoadError("Could not load the TypeScript transform (Sucrase)"+e+": "+(t&&t.message?t.message:String(t)))}})(),sucrasePromise.catch(()=>{sucrasePromise=null})),sucrasePromise}function isModule(t,e){return Object.keys(t).length>1?!0:/^\\s*(import|export)\\s/m.test(t[e]||"")}function needsTypeScript(t){return/\\.(ts|tsx|jsx|mts|cts)$/.test(t)}function transformsFor(t){const e=["imports"];return/\\.tsx?$|\\.mts$|\\.cts$/.test(t)&&e.push("typescript"),/\\.[jt]sx$/.test(t)&&e.push("jsx"),e}async function runAsModules(t,e){const{transform:r}=await loadSucrase(),i=new Map,a=(n,o)=>{if(!o.startsWith("."))return null;const u=((n.includes("/")?n.slice(0,n.lastIndexOf("/")+1):"")+o).split("/"),d=[];for(const p of u)p==="."||p===""||(p===".."?d.pop():d.push(p));const c=d.join("/");return[c,c+".js",c+".ts",c+".tsx",c+".jsx",c+".json",c+"/index.js",c+"/index.ts"].find(p=>p in t)||null};function s(n){if(i.has(n))return i.get(n).exports;const o={exports:{}};if(i.set(n,o),n.endsWith(".json")){try{o.exports=JSON.parse(t[n])}catch(c){throw new SyntaxError("Invalid JSON in "+n+": "+c.message)}return o.exports}const{code:f}=r(t[n],{transforms:transformsFor(n),filePath:n,preserveDynamicImport:!0}),u=c=>{const l=a(n,c);if(!l)throw new Error('Cannot find module "'+c+'" from "'+n+'"');return s(l)};return new Function("exports","require","module","__filename","input","console",f+\`
|
|
9
9
|
//# sourceURL=\`+n)(o.exports,u,o,n,input,self.console),o.exports}s(e)}async function run(t){currentId=t.id,stdinLines=t.stdin?String(t.stdin).replace(/\\n$/,"").split(\`
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
|
|
4
4
|
* Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
|
|
5
5
|
*/
|
|
6
|
-
import{o as e}from"./config-
|
|
6
|
+
import{o as e}from"./config-CT3H6Oum.js";import{t}from"./worker-runtime-DfYet3xy.js";var n=`let pyodide=null,stdinLines=[],stdinExhausted=!1,currentId=null,interactive=!1,inputWaitMs=0,nextRequest=1;const pendingLines=new Map,MOUNT="/home/pyodide/playground";let written=new Set,internals=null;const REFRESH=["import importlib, os, sys","MOUNT = "+JSON.stringify(MOUNT),"os.makedirs(MOUNT, exist_ok=True)","sys.path.insert(0, MOUNT) if MOUNT not in sys.path else None","os.chdir(MOUNT)","for _name, _mod in list(sys.modules.items()):",' _file = getattr(_mod, "__file__", None) or ""',' _paths = list(getattr(_mod, "__path__", None) or [])'," if _file.startswith(MOUNT) or any(str(p).startswith(MOUNT) for p in _paths):"," del sys.modules[_name]","importlib.invalidate_caches()"].join(\`
|
|
7
7
|
\`);function flushStreams(){try{pyodide.runPython(\`import sys
|
|
8
8
|
sys.stdout.flush()
|
|
9
9
|
sys.stderr.flush()\`,{globals:internals})}catch{}flushOutput()}const INPUT_OVERRIDE=["import builtins, sys, js","from pyodide.ffi import run_sync","",'def _pg_input(prompt=""):',' if prompt != "":'," sys.stdout.write(str(prompt))"," sys.stdout.flush()"," line = run_sync(js._pgReadLine())"," # Pyodide maps JS null to its own JsNull singleton, not None, so test"," # for what we want rather than for the several ways EOF can arrive."," if not isinstance(line, str):",' raise EOFError("EOF when reading a line")'," return line","",'_pg_input.__name__ = "input"','_pg_input.__qualname__ = "input"',"_pg_input.__doc__ = builtins.input.__doc__","builtins.input = _pg_input"].join(\`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./config-
|
|
1
|
+
import{o as e}from"./config-CT3H6Oum.js";import{t}from"./worker-runtime-sUPz1J56.js";var n=`let pyodide=null,stdinLines=[],stdinExhausted=!1,currentId=null,interactive=!1,inputWaitMs=0,nextRequest=1;const pendingLines=new Map,MOUNT="/home/pyodide/playground";let written=new Set,internals=null;const REFRESH=["import importlib, os, sys","MOUNT = "+JSON.stringify(MOUNT),"os.makedirs(MOUNT, exist_ok=True)","sys.path.insert(0, MOUNT) if MOUNT not in sys.path else None","os.chdir(MOUNT)","for _name, _mod in list(sys.modules.items()):",' _file = getattr(_mod, "__file__", None) or ""',' _paths = list(getattr(_mod, "__path__", None) or [])'," if _file.startswith(MOUNT) or any(str(p).startswith(MOUNT) for p in _paths):"," del sys.modules[_name]","importlib.invalidate_caches()"].join(\`
|
|
2
2
|
\`);function flushStreams(){try{pyodide.runPython(\`import sys
|
|
3
3
|
sys.stdout.flush()
|
|
4
4
|
sys.stderr.flush()\`,{globals:internals})}catch{}flushOutput()}const INPUT_OVERRIDE=["import builtins, sys, js","from pyodide.ffi import run_sync","",'def _pg_input(prompt=""):',' if prompt != "":'," sys.stdout.write(str(prompt))"," sys.stdout.flush()"," line = run_sync(js._pgReadLine())"," # Pyodide maps JS null to its own JsNull singleton, not None, so test"," # for what we want rather than for the several ways EOF can arrive."," if not isinstance(line, str):",' raise EOFError("EOF when reading a line")'," return line","",'_pg_input.__name__ = "input"','_pg_input.__qualname__ = "input"',"_pg_input.__doc__ = builtins.input.__doc__","builtins.input = _pg_input"].join(\`
|
package/dist/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./element-
|
|
1
|
+
import{n as e}from"./element-CQGYVEF7.js";import{useEffect as t,useRef as n}from"react";import{jsx as r}from"react/jsx-runtime";e();function i({code:e=``,files:i,entry:a,stdin:o,language:s=`python`,height:c,minHeight:l,maxHeight:u,theme:d=`auto`,readOnly:f,autoRun:p,persist:m,practice:h,className:g,style:_,onReady:v,onRun:y,onOutput:b,onError:x}){let S=n(null),C=n({onReady:v,onRun:y,onOutput:b,onError:x});C.current={onReady:v,onRun:y,onOutput:b,onError:x},t(()=>{let e=S.current;if(!e)return;let t=(t,n)=>{let r=e=>n(C.current)?.(e.detail);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)},n=[t(`py-ready`,e=>e.onReady),t(`py-run`,e=>e.onRun),t(`py-output`,e=>e.onOutput),t(`py-error`,e=>e.onError)];return()=>n.forEach(e=>e())},[]);let w=i?JSON.stringify(i):null;t(()=>{let t=S.current;t&&(w?t.files=JSON.parse(w):e!==t.code&&(t.code=e))},[e,w]),t(()=>{S.current&&o!==void 0&&(S.current.stdin=o)},[o]);let T=h?JSON.stringify(h):null;return t(()=>{S.current&&(S.current.practice=T?JSON.parse(T):null)},[T]),/* @__PURE__ */ r(`code-playpad`,{ref:S,language:s,theme:d,class:g,style:_,...c===void 0?{}:{height:String(c)},...l===void 0?{}:{"min-height":String(l)},...u===void 0?{}:{"max-height":String(u)},...f?{readonly:``}:{},...p?{autorun:``}:{},...m?{persist:m}:{},...a?{entry:a}:{},children:i?null:e})}export{i as CodePlayPad,i as default};
|
package/dist/runtime/config.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export declare function pyodideAssetUrls(): {
|
|
|
31
31
|
as: 'script' | 'fetch';
|
|
32
32
|
}[];
|
|
33
33
|
/** External immutable compiler assets, loaded on the first C/C++ Run only. */
|
|
34
|
+
/** Pinned, so the CDN response is immutable. Every file is still checked by SHA-256. */
|
|
35
|
+
export declare const CPP_TOOLCHAIN_URL = "https://cdn.jsdelivr.net/npm/@code-playpad/cpp-toolchain@1.0.0/dist/";
|
|
34
36
|
declare let cppConfig: {
|
|
35
37
|
indexURL?: string;
|
|
36
38
|
timeoutMs: number;
|
package/dist/standalone.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
|
|
4
4
|
* Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
|
|
5
5
|
*/
|
|
6
|
-
import{n as e,r as t,t as n}from"./hints-CCMgezw9.js";import{c as r,i,n as a,r as o,t as s}from"./config-
|
|
6
|
+
import{n as e,r as t,t as n}from"./hints-CCMgezw9.js";import{c as r,i,n as a,r as o,t as s}from"./config-CT3H6Oum.js";async function c(e){try{return await l(e)}catch(t){return console.warn(`[code-playpad] CodeMirror unavailable, using plain textarea:`,t),u(e)}}async function l(e){let[t,n,r,i,a,o]=await Promise.all([import(`./dist-Vr-fb58P.js`).then(e=>e.s),import(`./dist-D25hs99E.js`).then(e=>e.x),import(`./dist-D2igTc4m.js`),import(`./dist-DfFrsBkU.js`),import(`./dist-BNvM_BAY.js`),import(`./dist-DXjodKfp.js`)]),{EditorView:s,keymap:c,lineNumbers:l,highlightActiveLine:u,highlightActiveLineGutter:d,highlightSpecialChars:f,drawSelection:p,rectangularSelection:m,crosshairCursor:h}=t,{EditorState:g,Compartment:_}=n,{defaultKeymap:v,history:y,historyKeymap:b,indentWithTab:x}=r,{syntaxHighlighting:S,defaultHighlightStyle:C,indentOnInput:w,bracketMatching:T,foldGutter:E,foldKeymap:D}=i,{autocompletion:O,closeBrackets:k,closeBracketsKeymap:A,completionKeymap:j}=a,M=new _,N=new _,P=new _,F=[s.theme({"&":{color:`#1f2328`,backgroundColor:`#ffffff`},".cm-gutters":{backgroundColor:`#f6f8fa`,color:`#8b949e`,border:`none`},".cm-activeLine":{backgroundColor:`#f6f8fa88`},".cm-activeLineGutter":{backgroundColor:`#eaeef2`},".cm-cursor":{borderLeftColor:`#1f2328`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`#cfe3ff`}}),S(C,{fallback:!0})],I=e=>e?o.oneDark:F,L=c.of([{key:`Mod-Enter`,preventDefault:!0,run:()=>(e.onRun?.(),!0)},{key:`Shift-Enter`,preventDefault:!0,run:()=>(e.onRun?.(),!0)}]),R=e.dark,z=e.readOnly,B=e.language??[],V=t=>g.create({doc:t,extensions:[l(),d(),f(),y(),E(),p(),g.allowMultipleSelections.of(!0),w(),T(),k(),O(),m(),h(),u(),L,c.of([...A,...v,...b,...D,...j,x]),s.lineWrapping,P.of(B),M.of(I(R)),N.of(g.readOnly.of(z)),s.updateListener.of(t=>{t.docChanged&&e.onChange?.(t.state.doc.toString())})]}),H=new s({parent:e.parent,state:V(e.doc)}),U=/* @__PURE__ */ new Map,W=e.name??``;return{fallback:!1,getCode:()=>H.state.doc.toString(),setCode(e){H.dispatch({changes:{from:0,to:H.state.doc.length,insert:e}})},openFile(e,t){if(e===W)return;U.set(W,H.state);let n=U.get(e);H.setState(n??V(t)),W=e,n&&H.dispatch({effects:[M.reconfigure(I(R)),N.reconfigure(g.readOnly.of(z)),P.reconfigure(B)]})},fileCode(e,t){if(e===W)return H.state.doc.toString();let n=U.get(e);return n?n.doc.toString():t},forgetFiles(e){for(let t of[...U.keys()])e.includes(t)||U.delete(t)},setTheme(e){R=e,H.dispatch({effects:M.reconfigure(I(R))})},setReadOnly(e){z=e,H.dispatch({effects:N.reconfigure(g.readOnly.of(z))})},setLanguage(e){B=e,H.dispatch({effects:P.reconfigure(B)})},focus:()=>H.focus(),destroy:()=>H.destroy()}}function u(e){let t=document.createElement(`textarea`);t.className=`cp-fallback-editor`,t.spellcheck=!1,t.value=e.doc,t.readOnly=e.readOnly,t.addEventListener(`input`,()=>e.onChange?.(t.value)),t.addEventListener(`keydown`,t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&(t.preventDefault(),e.onRun?.())}),e.parent.appendChild(t);let n=/* @__PURE__ */ new Map,r=e.name??``;return{fallback:!0,getCode:()=>t.value,setCode:e=>{t.value=e},openFile(e,i){e!==r&&(n.set(r,t.value),t.value=n.get(e)??i,r=e)},fileCode(e,i){return e===r?t.value:n.get(e)??i},forgetFiles(e){for(let t of[...n.keys()])e.includes(t)||n.delete(t)},setTheme:()=>{},setReadOnly:e=>{t.readOnly=e},setLanguage:()=>{},focus:()=>t.focus(),destroy:()=>t.remove()}}var d=/* @__PURE__ */ new Map,f=/* @__PURE__ */ new Map;function p(e,t){d.set(e,t)}function m(){return[...d.keys()]}function h(e){let t=f.get(e);if(t)return t;let n=d.get(e);if(!n)return Promise.reject(/* @__PURE__ */ Error(`Unknown runtime "${e}". Registered: ${m().join(`, `)||`none`}`));let r=n().catch(t=>{throw f.delete(e),t});return f.set(e,r),r}p(`python`,()=>import(`./pyodide-BOoYEfX1.js`).then(e=>e.pythonRuntime)),p(`javascript`,()=>import(`./javascript-DLPaJJzf.js`).then(e=>e.javascriptRuntime)),p(`typescript`,()=>import(`./javascript-DLPaJJzf.js`).then(e=>e.typescriptRuntime)),p(`java`,()=>import(`./java-DeBiVPXO.js`).then(e=>e.javaRuntime)),p(`c`,()=>import(`./cpp-Cs32J8JC.js`).then(e=>e.cRuntime)),p(`cpp`,()=>import(`./cpp-Cs32J8JC.js`).then(e=>e.cppRuntime));var g=String.raw`
|
|
7
7
|
:host {
|
|
8
8
|
--cp-bg: #ffffff;
|
|
9
9
|
--cp-fg: #1f2328;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,l as t,u as n}from"./element-
|
|
1
|
+
import{d as e,l as t,u as n}from"./element-CQGYVEF7.js";var r=1,i=class{#e=null;#t=null;#n=`module`;#r=null;#i=null;#a=!1;#o=!1;#s=``;#c=/* @__PURE__ */ new Set;#l=[];#u=null;#d=!1;initPayload(){return{}}loadModule(e){return Promise.reject(/* @__PURE__ */ Error(`no module named ${e}`))}get ready(){return this.#a}get interactiveStdin(){return this.#o}get version(){return this.#s}load(t){t&&this.#c.add(t);let n=()=>{t&&this.#c.delete(t)};if(!this.#r){let t=new Promise((t,n)=>{this.#i={resolve:t,reject:n};let r;try{if(typeof Worker>`u`)throw Error(`Worker constructor missing`);let e=new Blob([this.source],{type:`text/javascript`});this.#t=URL.createObjectURL(e),r=new Worker(this.#t,{type:this.#n})}catch(t){this.#i=null,n(new e(`Could not start a Web Worker: ${t.message}`));return}this.#e=r,r.onmessage=e=>{let r=e.data;r.type===`ready`?(this.#s=r.version,this.#o=r.interactiveStdin===!0,this.#a=!0,this.#i=null,this.#h({phase:`ready`,message:`${this.label} ready`}),t()):r.type===`fatal`&&!this.#a?this.#p(r.message,t,n):this.#g(r)},r.onerror=e=>{let r=e.message||`Worker failed to start`;this.#a?this.#u&&this.#y(this.#u,Error(r)):this.#p(r,t,n)},r.postMessage({type:`init`,...this.initPayload()})});this.#r=t,t.catch(()=>{this.#r===t&&(this.#r=null)})}return this.#r.then(n,e=>{throw n(),e})}run(e,t={}){let n,i,a=new Promise((e,t)=>{n=e,i=t}),o,s=new Promise(e=>{o=e}),c={id:r++,code:e,options:t,stdout:``,stderr:``,resolve:n,reject:i,promise:a,started:!1,settled:!1,done:s,markDone:()=>{clearTimeout(c.timer),c.settled=!0,o()}};return this.#l.push(c),this.#b(),a}stop(e){if(e){let t=this.#l.findIndex(t=>t.promise===e);if(t!==-1){this.#y(this.#l.splice(t,1)[0],new n);return}let r=this.#u;if(!r||r.promise!==e||r.settled)return;if(!r.started){this.#y(r,new n);return}}this.#f()}#f(){let e=this.#e!==null,t=this.#i;if(this.#m(),this.#u&&this.#y(this.#u,new n),e){let e=this.load();t&&e.then(t.resolve,t.reject),e.catch(()=>{})}}#p(e,t,n){this.#m(),this.#n===`module`?(this.#n=`classic`,this.load().then(t,n)):n(Error(e))}#m(){this.#e?.terminate(),this.#e=null,this.#t&&=(URL.revokeObjectURL(this.#t),null),this.#r=null,this.#i=null,this.#a=!1}#h(e){for(let t of this.#c)t(e)}#g(e){if(e.type===`progress`){this.#h({phase:e.phase,message:e.message}),this.#u&&e.id===this.#u.id&&!this.#u.settled&&this.#u.options.onProgress?.({phase:e.phase,message:e.message});return}let n=this.#u;if(n&&`id`in e&&e.id===n.id)switch(e.type){case`stdout`:n.stdout+=e.text,n.options.onStdout?.(e.text);break;case`echo`:n.options.onEcho?.(e.text);break;case`stdin-request`:this.#v(n,e.request);break;case`module-request`:this.#_(n,e.name);break;case`stderr`:n.stderr+=e.text,n.options.onStderr?.(e.text);break;case`result`:n.resolve({stdout:n.stdout,stderr:n.stderr||void 0,value:e.value,durationMs:Math.round(e.durationMs),failed:!1,...e.memory?{memory:e.memory}:{},...e.cases?{cases:e.cases,passed:e.passed,total:e.total}:{}}),n.markDone();break;case`error`:case`fatal`:{let r=(n.stderr&&!n.stderr.endsWith(`
|
|
2
2
|
`)?`
|
|
3
3
|
`:``)+e.message+`
|
|
4
4
|
`;n.stderr+=r,n.options.onStderr?.(r);let i={stdout:n.stdout,stderr:n.stderr,hint:`hint`in e?e.hint:void 0,durationMs:Math.round(`durationMs`in e?e.durationMs:0),failed:!0,...`cases`in e&&e.cases?{cases:e.cases,passed:0,total:e.cases.length}:{}};`hintAbout`in e&&e.hintAbout===`stdin`&&t.add(i),n.resolve(i),n.markDone();break}}}#_(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`module`,name:t,...r})};this.loadModule(t).then(e=>r({code:e}),e=>r({error:e instanceof Error?e.message:String(e)}))}#v(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`stdin-response`,request:t,text:r})},i=e.options.onStdinRequest;i?i().then(r,()=>r(null)):r(null)}#y(e,t){e.reject(t),e.markDone()}async#b(){if(!this.#d){this.#d=!0;try{for(;this.#l.length;){let e=this.#l.shift();this.#u=e;try{if(await this.load(),e.settled)continue;e.started=!0,e.options.onStart?.(),e.options.timeoutMs&&Number.isFinite(e.options.timeoutMs)&&e.options.timeoutMs>0&&(e.timer=setTimeout(()=>{this.#u!==e||e.settled||(this.#g({type:`error`,id:e.id,message:`Run exceeded its wall-clock time limit.`,durationMs:e.options.timeoutMs}),this.#m())},e.options.timeoutMs)),this.#e.postMessage({type:`run`,id:e.id,code:e.code,stdin:e.options.stdin,files:e.options.files,entry:e.options.entry,...e.options.compilerLanguage?{compilerLanguage:e.options.compilerLanguage}:{},...e.options.practice?{practice:e.options.practice}:{}}),await e.done}catch(t){this.#y(e,t)}finally{this.#u=null}}}finally{this.#d=!1}}}};export{i as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-playpad",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Embeddable browser code playground: a CodeMirror editor that runs Python, JavaScript, TypeScript, a subset of Java and experimental C/C++ in the browser. No backend. One shared worker per page, blocking input(), multi-file projects, lazy per-language loading.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/dist/config-cwuPIQ48.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* code-playpad — MIT © 2026 Seung Hun Lee
|
|
3
|
-
* Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
|
|
4
|
-
* Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
|
|
5
|
-
*/
|
|
6
|
-
var e=`314.0.5`,t=`https://cdn.jsdelivr.net/pyodide/v${e}/full/`,n=null;function r(e){t=e.indexURL.endsWith(`/`)?e.indexURL:e.indexURL+`/`}function i(e){n=e.sucraseURL}function a(){return t}function o(){return n}function s(){return[{url:t+`pyodide.js`,as:`script`},{url:t+`pyodide.asm.wasm`,as:`fetch`},{url:t+`python_stdlib.zip`,as:`fetch`}]}var c={timeoutMs:12e4};function l(e){let t={...c};if(e.indexURL!==void 0){let n=new URL(e.indexURL);if(![`https:`,`http:`].includes(n.protocol))throw Error(`C/C++ asset URL must use HTTP or HTTPS.`);t.indexURL=n.href.endsWith(`/`)?n.href:n.href+`/`}if(e.timeoutMs!==void 0){if(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0)throw Error(`timeoutMs must be a positive finite number.`);t.timeoutMs=e.timeoutMs}c=t}function u(){return{...c}}export{u as a,s as c,i,l as n,a as o,r,o as s,e as t};
|