@jupyterlite/pyodide-kernel 0.0.9 → 0.1.0

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/lib/_pypi.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * as allJSONUrl from '../pypi/all.json';
2
2
  export * as ipykernelWheelUrl from '../pypi/ipykernel-6.9.2-py3-none-any.whl';
3
- export * as pipliteWheelUrl from '../pypi/piplite-0.0.9-py3-none-any.whl';
4
- export * as pyodide_kernelWheelUrl from '../pypi/pyodide_kernel-0.0.9-py3-none-any.whl';
3
+ export * as pipliteWheelUrl from '../pypi/piplite-0.1.0-py3-none-any.whl';
4
+ export * as pyodide_kernelWheelUrl from '../pypi/pyodide_kernel-0.1.0-py3-none-any.whl';
5
5
  export * as widgetsnbextensionWheelUrl from '../pypi/widgetsnbextension-3.6.4-py3-none-any.whl';
6
6
  export * as widgetsnbextensionWheelUrl1 from '../pypi/widgetsnbextension-4.0.7-py3-none-any.whl';
package/lib/_pypi.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // this file is autogenerated from the wheels described in ../package.json
2
2
  export * as allJSONUrl from '../pypi/all.json';
3
3
  export * as ipykernelWheelUrl from '../pypi/ipykernel-6.9.2-py3-none-any.whl';
4
- export * as pipliteWheelUrl from '../pypi/piplite-0.0.9-py3-none-any.whl';
5
- export * as pyodide_kernelWheelUrl from '../pypi/pyodide_kernel-0.0.9-py3-none-any.whl';
4
+ export * as pipliteWheelUrl from '../pypi/piplite-0.1.0-py3-none-any.whl';
5
+ export * as pyodide_kernelWheelUrl from '../pypi/pyodide_kernel-0.1.0-py3-none-any.whl';
6
6
  export * as widgetsnbextensionWheelUrl from '../pypi/widgetsnbextension-3.6.4-py3-none-any.whl';
7
7
  export * as widgetsnbextensionWheelUrl1 from '../pypi/widgetsnbextension-4.0.7-py3-none-any.whl';
package/lib/worker.js CHANGED
@@ -13,13 +13,14 @@ Arguments: `+Array.prototype.slice.call(a).join("")+`
13
13
  `)}async initKernel(i){await this._pyodide.runPythonAsync(`
14
14
  await piplite.install(['sqlite3'], keep_going=True);
15
15
  await piplite.install(['ipykernel'], keep_going=True);
16
+ await piplite.install(['comm'], keep_going=True);
16
17
  await piplite.install(['pyodide_kernel'], keep_going=True);
17
18
  await piplite.install(['ipython'], keep_going=True);
18
19
  import pyodide_kernel
19
20
  `),i.mountDrive&&this._localPath&&await this._pyodide.runPythonAsync(`
20
21
  import os;
21
22
  os.chdir("${this._localPath}");
22
- `)}async initGlobals(i){let{globals:r}=this._pyodide;this._kernel=r.get("pyodide_kernel").kernel_instance.copy(),this._stdout_stream=r.get("pyodide_kernel").stdout_stream.copy(),this._stderr_stream=r.get("pyodide_kernel").stderr_stream.copy(),this._interpreter=this._kernel.interpreter.copy(),this._interpreter.send_comm=this.sendComm.bind(this)}async initFilesystem(i){if(i.mountDrive){let r="/drive",{FS:s,PATH:c,ERRNO_CODES:d}=this._pyodide,{baseUrl:f}=i,{DriveFS:u}=await Promise.resolve().then(()=>(qa(),Ha)),v=new u({FS:s,PATH:c,ERRNO_CODES:d,baseUrl:f,driveName:this._driveName,mountpoint:r});s.mkdir(r),s.mount(v,{},r),s.chdir(r),this._driveFS=v}}mapToObject(i){let r=i instanceof Array?[]:{};return i.forEach((s,c)=>{r[c]=s instanceof Map||s instanceof Array?this.mapToObject(s):s}),r}formatResult(i){if(!(i instanceof this._pyodide.ffi.PyProxy))return i;let r=i.toJs();return this.mapToObject(r)}async setup(i){await this._initialized,this._kernel._parent_header=this._pyodide.toPy(i)}async execute(i,r){await this.setup(r);let s=(x,M,C)=>{let D={execution_count:x,data:this.formatResult(M),metadata:this.formatResult(C)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:D,type:"execute_result"})},c=(x,M,C)=>{let D={ename:x,evalue:M,traceback:C};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:D,type:"execute_error"})},d=x=>{let M={wait:this.formatResult(x)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:M,type:"clear_output"})},f=(x,M,C)=>{let D={data:this.formatResult(x),metadata:this.formatResult(M),transient:this.formatResult(C)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:D,type:"display_data"})},u=(x,M,C)=>{let D={data:this.formatResult(x),metadata:this.formatResult(M),transient:this.formatResult(C)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:D,type:"update_display_data"})},v=(x,M)=>{let C={name:this.formatResult(x),text:this.formatResult(M)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:C,type:"stream"})};this._stdout_stream.publish_stream_callback=v,this._stderr_stream.publish_stream_callback=v,this._interpreter.display_pub.clear_output_callback=d,this._interpreter.display_pub.display_data_callback=f,this._interpreter.display_pub.update_display_data_callback=u,this._interpreter.displayhook.publish_execution_result=s,this._interpreter.input=this.input.bind(this),this._interpreter.getpass=this.getpass.bind(this);let w=await this._kernel.run(i.code),k=this.formatResult(w);return k.status==="error"&&c(k.ename,k.evalue,k.traceback),k}async complete(i,r){await this.setup(r);let s=this._kernel.complete(i.code,i.cursor_pos);return this.formatResult(s)}async inspect(i,r){await this.setup(r);let s=this._kernel.inspect(i.code,i.cursor_pos,i.detail_level);return this.formatResult(s)}async isComplete(i,r){await this.setup(r);let s=this._kernel.is_complete(i.code);return this.formatResult(s)}async commInfo(i,r){await this.setup(r);let s=this._kernel.comm_info(i.target_name);return{comms:this.formatResult(s),status:"ok"}}async commOpen(i,r){await this.setup(r);let s=this._kernel.comm_manager.comm_open(this._pyodide.toPy(i));return this.formatResult(s)}async commMsg(i,r){await this.setup(r);let s=this._kernel.comm_manager.comm_msg(this._pyodide.toPy(i));return this.formatResult(s)}async commClose(i,r){await this.setup(r);let s=this._kernel.comm_manager.comm_close(this._pyodide.toPy(i));return this.formatResult(s)}async inputReply(i,r){await this.setup(r),this._resolveInputReply(i)}async sendInputRequest(i,r){let s={prompt:i,password:r};postMessage({type:"input_request",parentHeader:this.formatResult(this._kernel._parent_header).header,content:s})}async getpass(i){return i=typeof i=="undefined"?"":i,await this.sendInputRequest(i,!0),(await new Promise(c=>{this._resolveInputReply=c})).value}async input(i){return i=typeof i=="undefined"?"":i,await this.sendInputRequest(i,!1),(await new Promise(c=>{this._resolveInputReply=c})).value}async sendComm(i,r,s,c,d){postMessage({type:i,content:this.formatResult(r),metadata:this.formatResult(s),ident:this.formatResult(c),buffers:this.formatResult(d),parentHeader:this.formatResult(this._kernel._parent_header).header})}};export{Va as PyodideRemoteKernel};
23
+ `)}async initGlobals(i){let{globals:r}=this._pyodide;this._kernel=r.get("pyodide_kernel").kernel_instance.copy(),this._stdout_stream=r.get("pyodide_kernel").stdout_stream.copy(),this._stderr_stream=r.get("pyodide_kernel").stderr_stream.copy(),this._interpreter=this._kernel.interpreter.copy(),this._interpreter.send_comm=this.sendComm.bind(this)}async initFilesystem(i){if(i.mountDrive){let r="/drive",{FS:s,PATH:c,ERRNO_CODES:d}=this._pyodide,{baseUrl:f}=i,{DriveFS:u}=await Promise.resolve().then(()=>(qa(),Ha)),v=new u({FS:s,PATH:c,ERRNO_CODES:d,baseUrl:f,driveName:this._driveName,mountpoint:r});s.mkdir(r),s.mount(v,{},r),s.chdir(r),this._driveFS=v}}mapToObject(i){let r=i instanceof Array?[]:{};return i.forEach((s,c)=>{r[c]=s instanceof Map||s instanceof Array?this.mapToObject(s):s}),r}formatResult(i){if(!(i instanceof this._pyodide.ffi.PyProxy))return i;let r=i.toJs();return this.mapToObject(r)}async setup(i){await this._initialized,this._kernel._parent_header=this._pyodide.toPy(i)}async execute(i,r){await this.setup(r);let s=(x,M,C)=>{let D={execution_count:x,data:this.formatResult(M),metadata:this.formatResult(C)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:D,type:"execute_result"})},c=(x,M,C)=>{let D={ename:x,evalue:M,traceback:C};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:D,type:"execute_error"})},d=x=>{let M={wait:this.formatResult(x)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:M,type:"clear_output"})},f=(x,M,C)=>{let D={data:this.formatResult(x),metadata:this.formatResult(M),transient:this.formatResult(C)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:D,type:"display_data"})},u=(x,M,C)=>{let D={data:this.formatResult(x),metadata:this.formatResult(M),transient:this.formatResult(C)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:D,type:"update_display_data"})},v=(x,M)=>{let C={name:this.formatResult(x),text:this.formatResult(M)};postMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:C,type:"stream"})};this._stdout_stream.publish_stream_callback=v,this._stderr_stream.publish_stream_callback=v,this._interpreter.display_pub.clear_output_callback=d,this._interpreter.display_pub.display_data_callback=f,this._interpreter.display_pub.update_display_data_callback=u,this._interpreter.displayhook.publish_execution_result=s,this._interpreter.input=this.input.bind(this),this._interpreter.getpass=this.getpass.bind(this);let w=await this._kernel.run(i.code),k=this.formatResult(w);return k.status==="error"&&c(k.ename,k.evalue,k.traceback),k}async complete(i,r){await this.setup(r);let s=this._kernel.complete(i.code,i.cursor_pos);return this.formatResult(s)}async inspect(i,r){await this.setup(r);let s=this._kernel.inspect(i.code,i.cursor_pos,i.detail_level);return this.formatResult(s)}async isComplete(i,r){await this.setup(r);let s=this._kernel.is_complete(i.code);return this.formatResult(s)}async commInfo(i,r){await this.setup(r);let s=this._kernel.comm_info(i.target_name);return{comms:this.formatResult(s),status:"ok"}}async commOpen(i,r){await this.setup(r);let s=this._kernel.comm_manager.comm_open(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(i));return this.formatResult(s)}async commMsg(i,r){await this.setup(r);let s=this._kernel.comm_manager.comm_msg(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(i));return this.formatResult(s)}async commClose(i,r){await this.setup(r);let s=this._kernel.comm_manager.comm_close(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(i));return this.formatResult(s)}async inputReply(i,r){await this.setup(r),this._resolveInputReply(i)}async sendInputRequest(i,r){let s={prompt:i,password:r};postMessage({type:"input_request",parentHeader:this.formatResult(this._kernel._parent_header).header,content:s})}async getpass(i){return i=typeof i=="undefined"?"":i,await this.sendInputRequest(i,!0),(await new Promise(c=>{this._resolveInputReply=c})).value}async input(i){return i=typeof i=="undefined"?"":i,await this.sendInputRequest(i,!1),(await new Promise(c=>{this._resolveInputReply=c})).value}async sendComm(i,r,s,c,d){postMessage({type:i,content:this.formatResult(r),metadata:this.formatResult(s),ident:this.formatResult(c),buffers:this.formatResult(d),parentHeader:this.formatResult(this._kernel._parent_header).header})}};export{Va as PyodideRemoteKernel};
23
24
  /*! Bundled license information:
24
25
 
25
26
  moment/moment.js: