@johnnycubides/micropython-esp32-plugin-catalejo-editor 0.1.0 → 0.1.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.
@@ -142,7 +142,7 @@ function P(e, t) {
142
142
  };
143
143
  }
144
144
  const b = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20version='1.1'%20id='svg4'%20sodipodi:docname='temperature-low-svgrepo-com-light.svg'%20inkscape:version='1.2.2%20(b0a8486541,%202022-12-01)'%20xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape'%20xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:svg='http://www.w3.org/2000/svg'%3e%3cdefs%20id='defs8'%20/%3e%3csodipodi:namedview%20id='namedview6'%20pagecolor='%23ffffff'%20bordercolor='%23000000'%20borderopacity='0.25'%20inkscape:showpageshadow='2'%20inkscape:pageopacity='0.0'%20inkscape:pagecheckerboard='0'%20inkscape:deskcolor='%23d1d1d1'%20showgrid='false'%20inkscape:zoom='0.295'%20inkscape:cx='150.84746'%20inkscape:cy='405.08475'%20inkscape:window-width='1918'%20inkscape:window-height='1150'%20inkscape:window-x='1440'%20inkscape:window-y='24'%20inkscape:window-maximized='1'%20inkscape:current-layer='svg4'%20/%3e%3cpath%20d='M8%2015.9998C7.44772%2015.9998%207%2016.4475%207%2016.9998C7%2017.5521%207.44772%2017.9998%208%2017.9998C8.55228%2017.9998%209%2017.5521%209%2016.9998C9%2016.4475%208.55228%2015.9998%208%2015.9998ZM8%2015.9998L8.00707%2012M8%2016.9998L8.00707%2017.0069M20%205C20%206.10457%2019.1046%207%2018%207C16.8954%207%2016%206.10457%2016%205C16%203.89543%2016.8954%203%2018%203C19.1046%203%2020%203.89543%2020%205ZM12%2016.9998C12%2019.209%2010.2091%2020.9998%208%2020.9998C5.79086%2020.9998%204%2019.209%204%2016.9998C4%2015.9854%204.37764%2015.0591%205%2014.354L5%206C5%204.34315%206.34315%203%208%203C9.65685%203%2011%204.34315%2011%206V14.354C11.6224%2015.0591%2012%2015.9854%2012%2016.9998Z'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20id='path2'%20style='fill:none;stroke:%23ffffff'%20/%3e%3c/svg%3e";
145
- function L(e, t) {
145
+ function S(e, t) {
146
146
  e.Blocks.dht_init = {
147
147
  init: function() {
148
148
  this.appendValueInput("pin").setCheck("Number").appendField(new e.FieldImage(b, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Crear").appendField(new e.FieldDropdown([["DHT11", "DHT11"], ["DHT22", "DHT22"]]), "dht_option").appendField(new e.FieldVariable("variable"), "sensor").appendField("Pin:"), this.setPreviousStatement(!0, null), this.setNextStatement(!0, null), this.setColour(195), this.setTooltip("Instanciar un sensor DHT (Sensor de humedad y temperatura digital), puede seleccionar un DHT11 o DHT22, ambos tienen diferentes características de precisión. Escoja el nombre de la variable que representará al sensor, finalmente, indique el Pin por el cual se leerá el sensor."), this.setHelpUrl("");
@@ -171,8 +171,8 @@ function L(e, t) {
171
171
  return [o, t.ORDER_NONE];
172
172
  };
173
173
  }
174
- function S(e, t) {
175
- V(e, t), I(e, t), M(e, t), P(e, t), L(e, t);
174
+ function L(e, t) {
175
+ V(e, t), I(e, t), M(e, t), P(e, t), S(e, t);
176
176
  }
177
177
  const B = `
178
178
  <xml id="toolbox" style="display: none">
@@ -747,7 +747,7 @@ async function le(e, t) {
747
747
  return e.extension == v ? {
748
748
  typeResult: r.TEXT_PRINT,
749
749
  data: {
750
- title: "Lua",
750
+ title: "Python",
751
751
  content: t()
752
752
  }
753
753
  } : {
@@ -799,7 +799,7 @@ async function de(e) {
799
799
  let g, x, A;
800
800
  const pe = E, ce = U, me = K, ue = X;
801
801
  function he(e, t, i) {
802
- A = e, g = t, x = i, S(A, g);
802
+ A = e, g = t, x = i, L(A, g);
803
803
  }
804
804
  function T() {
805
805
  return H(g, x);
@@ -347,5 +347,5 @@
347
347
  # send: wifi
348
348
  # ip_mpy: 192.168.4.1
349
349
  # serialport:
350
- `;var y=(e=>(e.WIFI="wifi",e.SERIAL="serial",e))(y||{});const z="http://"+location.hostname,q="8080",Y="cors",Z="nodemcu/";async function Q(e,t){try{const n=await(await fetch(e,t)).json();return n.status==l.OK,n}catch(i){return console.error(i),{status:l.FAILED}}}async function J(){const e=Z+"getserialportlist",t=z+":"+q+"/"+e,n={method:"PUT",mode:Y,headers:{"Content-Type":"application/json"},body:JSON.stringify({})};return await Q(t,n)}function m(e){return new Promise(t=>setTimeout(t,e))}async function $(e,t,i){typeof t=="string"?t=new TextEncoder().encode(t):t instanceof Uint8Array||(t=new Uint8Array(t));const n=new WebSocket("ws://"+i.ipPy+":"+i.portPy+"/");return n.binaryType="arraybuffer",new Promise(a=>{n.onmessage=o=>{console.log(o.data)},n.onopen=async function(){console.log("WebSocket connection opened."),await m(100),console.log("This password: "+i.passwordPy),n.send(i.passwordPy+"\r"),await m(100);const o=t.length,c=e;let s=new Uint8Array(82);s[0]=87,s[1]=65,s[2]=1,s[3]=0,s[4]=0,s[5]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=0,s[11]=0,s[12]=o&255,s[13]=o>>8&255,s[14]=o>>16&255,s[15]=o>>24&255,s[16]=c.length&255,s[17]=c.length>>8&255;for(var h=0;h<64;++h)h<c.length?s[18+h]=c.charCodeAt(h):s[18+h]=0;console.log("Send file to micropython: "+e),n.send(s),n.onmessage=async function(){for(let b=0;b<t.length;b+=i.chuckSizePy){const I=t.slice(b,b+i.chuckSizePy);console.log(I),n.send(I),await m(i.sleepTimePy)}n.send(""),m(100),n.close(),a({status:l.OK,data:"File uploaded"})}},n.onerror=function(o){a({status:l.FAILED,data:"WebSocket error"+o})},n.onclose=function(){console.log("WebSocket connection closed.")}})}async function j(e,t){const i=new WebSocket("ws://"+t.ipPy+":"+t.portPy+"/");return new Promise(n=>{i.onopen=async function(){await m(100),i.send(t.passwordPy+"\r"),await m(100),i.send(e),await m(100),i.close(),n({status:l.OK,data:"File uploaded"})},i.onerror=function(a){n({status:l.FAILED,data:"WebSocket error"+a})},i.onclose=function(){console.log("WebSocket connection closed.")},i.onmessage=a=>{console.log(a.data)}})}const u={micropythonSend:{en:"Send",es:"Enviar"},magic:{en:"Translate",es:"Traducir"},getSerialportList:{en:"Get serial ports",es:"Listar puertos seriales"},docs:{en:"Documentation",es:"Documentación"},reset:{en:"Reset micropython",es:"Reiniciar micropython"},play:{en:"Run main",es:"Correr programa principal"},term:{en:"Run terminal",es:"Conectersa a micropython"}},ee={docs:{title:{en:"Micropython documentation",es:"Documentación para Micropython"},description:{en:"Open the next link to get information about Micropython",es:" Abre el siguiente enlace para obtener información sobre Micropython"}}};function p(e,t){return t==v.EN?e.en:t==v.ES?e.es:"noname"}function O(e){return{ipPy:e.ip_mpy!=null&&e.ip_mpy!=""?e.ip_mpy:"",portPy:e.port_mpy!=null&&e.port_mpy!=""?e.port_mpy:"8266",passwordPy:e.password_mpy!=null&&e.password_mpy!=""?e.password_mpy:"0000",sleepTimePy:e.sleepTime_mpy!=null&&e.sleepTime_mpy!=""?parseInt(e.sleepTime_mpy):50,chuckSizePy:e.chuckSize_mpy!=null&&e.chuckSize_mpy!=""?parseInt(e.chuckSize_mpy):1024}}function te(e,t){return e.extension==C?{status:l.OK,data:e.content}:e.extension==E&&e.config.platform==F?{status:l.OK,data:t()}:{status:l.FAILED}}function ie(e){return e.extension==C?e.config.filename!=""&&e.config.filename!=null?{status:l.OK,data:e.config.filename}:{status:l.OK,data:e.filename}:e.extension==E&&e.config.platform==F?e.config.filename!=""&&e.config.filename!=null?{status:l.OK,data:e.config.filename}:{status:l.OK,data:K}:{status:l.FAILED}}async function ne(e,t){const i=O(e.config);if(i.ipPy=="")return{status:l.FAILED};let n;if(n=ie(e),n.status==l.FAILED)return n;const a=n.data;if(n=te(e,t),n.status==l.FAILED)return n;const o=n.data;return n=await $(a,o,i),n}async function ae(e,t){return e.config.send==y.WIFI&&(await ne(e,t)).status==l.OK?{typeResult:r.TOAST,data:{severity:"success",summary:"Code save Ok",detail:"",life:3e3}}:{typeResult:r.TOAST,data:{severity:"warn",summary:"TODO from send on micropython",detail:"",life:3e3}}}async function R(e,t){const i=O(e.config);return i.ipPy==""?{status:l.FAILED}:await j(t,i)}async function oe(e){return e.config.send==y.WIFI&&(await R(e,"from machine import reset\rreset()\r")).status==l.OK?{typeResult:r.TOAST,data:{severity:"success",summary:"Reset command send",detail:"",life:3e3}}:{typeResult:r.TOAST,data:{severity:"warn",summary:"Failed soft reset micropython",detail:"",life:1e3}}}async function le(e){return e.config.send==y.WIFI&&(await R(e,"")).status==l.OK?{typeResult:r.TOAST,data:{severity:"success",summary:"Run main command send",detail:"",life:3e3}}:{typeResult:r.TOAST,data:{severity:"warn",summary:"Failed run main micropython",detail:"",life:1e3}}}async function se(e){const t=e.config.send,i=e.config;if(t==y.WIFI){const n=i.ip_mpy!=null&&i.ip_mpy!=""?i.ip_mpy:"",a=i.port_mpy!=null&&i.port_mpy!=""?i.port_mpy:"8266",o=i.password_mpy!=null&&i.password_mpy!=""?i.password_mpy:"0000";if(n!="")return{typeResult:r.TERM,data:{typeConnection:D.WEBSOCKET,data:{ip:n,port:a,user:"",password:o,endOfCommand:"\r"}}}}return{typeResult:r.TOAST,data:{severity:"warn",summary:"Failed open terminal micropython",detail:"",life:1e3}}}async function re(e,t){return e.extension==E?{typeResult:r.TEXT_PRINT,data:{title:"Lua",content:t()}}:{typeResult:r.TOAST,data:{severity:"warn",summary:"Opción disponible solo con archivos blockly (json)",detail:"",life:5e3}}}async function de(){const e=await J();if(e.status==l.OK){let t="";for(let i=0;i<e.data.length;i++)t+=e.data[i]+`
350
+ `;var y=(e=>(e.WIFI="wifi",e.SERIAL="serial",e))(y||{});const z="http://"+location.hostname,q="8080",Y="cors",Z="nodemcu/";async function Q(e,t){try{const n=await(await fetch(e,t)).json();return n.status==l.OK,n}catch(i){return console.error(i),{status:l.FAILED}}}async function J(){const e=Z+"getserialportlist",t=z+":"+q+"/"+e,n={method:"PUT",mode:Y,headers:{"Content-Type":"application/json"},body:JSON.stringify({})};return await Q(t,n)}function m(e){return new Promise(t=>setTimeout(t,e))}async function $(e,t,i){typeof t=="string"?t=new TextEncoder().encode(t):t instanceof Uint8Array||(t=new Uint8Array(t));const n=new WebSocket("ws://"+i.ipPy+":"+i.portPy+"/");return n.binaryType="arraybuffer",new Promise(a=>{n.onmessage=o=>{console.log(o.data)},n.onopen=async function(){console.log("WebSocket connection opened."),await m(100),console.log("This password: "+i.passwordPy),n.send(i.passwordPy+"\r"),await m(100);const o=t.length,c=e;let s=new Uint8Array(82);s[0]=87,s[1]=65,s[2]=1,s[3]=0,s[4]=0,s[5]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=0,s[11]=0,s[12]=o&255,s[13]=o>>8&255,s[14]=o>>16&255,s[15]=o>>24&255,s[16]=c.length&255,s[17]=c.length>>8&255;for(var h=0;h<64;++h)h<c.length?s[18+h]=c.charCodeAt(h):s[18+h]=0;console.log("Send file to micropython: "+e),n.send(s),n.onmessage=async function(){for(let b=0;b<t.length;b+=i.chuckSizePy){const I=t.slice(b,b+i.chuckSizePy);console.log(I),n.send(I),await m(i.sleepTimePy)}n.send(""),m(100),n.close(),a({status:l.OK,data:"File uploaded"})}},n.onerror=function(o){a({status:l.FAILED,data:"WebSocket error"+o})},n.onclose=function(){console.log("WebSocket connection closed.")}})}async function j(e,t){const i=new WebSocket("ws://"+t.ipPy+":"+t.portPy+"/");return new Promise(n=>{i.onopen=async function(){await m(100),i.send(t.passwordPy+"\r"),await m(100),i.send(e),await m(100),i.close(),n({status:l.OK,data:"File uploaded"})},i.onerror=function(a){n({status:l.FAILED,data:"WebSocket error"+a})},i.onclose=function(){console.log("WebSocket connection closed.")},i.onmessage=a=>{console.log(a.data)}})}const u={micropythonSend:{en:"Send",es:"Enviar"},magic:{en:"Translate",es:"Traducir"},getSerialportList:{en:"Get serial ports",es:"Listar puertos seriales"},docs:{en:"Documentation",es:"Documentación"},reset:{en:"Reset micropython",es:"Reiniciar micropython"},play:{en:"Run main",es:"Correr programa principal"},term:{en:"Run terminal",es:"Conectersa a micropython"}},ee={docs:{title:{en:"Micropython documentation",es:"Documentación para Micropython"},description:{en:"Open the next link to get information about Micropython",es:" Abre el siguiente enlace para obtener información sobre Micropython"}}};function p(e,t){return t==v.EN?e.en:t==v.ES?e.es:"noname"}function O(e){return{ipPy:e.ip_mpy!=null&&e.ip_mpy!=""?e.ip_mpy:"",portPy:e.port_mpy!=null&&e.port_mpy!=""?e.port_mpy:"8266",passwordPy:e.password_mpy!=null&&e.password_mpy!=""?e.password_mpy:"0000",sleepTimePy:e.sleepTime_mpy!=null&&e.sleepTime_mpy!=""?parseInt(e.sleepTime_mpy):50,chuckSizePy:e.chuckSize_mpy!=null&&e.chuckSize_mpy!=""?parseInt(e.chuckSize_mpy):1024}}function te(e,t){return e.extension==C?{status:l.OK,data:e.content}:e.extension==E&&e.config.platform==F?{status:l.OK,data:t()}:{status:l.FAILED}}function ie(e){return e.extension==C?e.config.filename!=""&&e.config.filename!=null?{status:l.OK,data:e.config.filename}:{status:l.OK,data:e.filename}:e.extension==E&&e.config.platform==F?e.config.filename!=""&&e.config.filename!=null?{status:l.OK,data:e.config.filename}:{status:l.OK,data:K}:{status:l.FAILED}}async function ne(e,t){const i=O(e.config);if(i.ipPy=="")return{status:l.FAILED};let n;if(n=ie(e),n.status==l.FAILED)return n;const a=n.data;if(n=te(e,t),n.status==l.FAILED)return n;const o=n.data;return n=await $(a,o,i),n}async function ae(e,t){return e.config.send==y.WIFI&&(await ne(e,t)).status==l.OK?{typeResult:r.TOAST,data:{severity:"success",summary:"Code save Ok",detail:"",life:3e3}}:{typeResult:r.TOAST,data:{severity:"warn",summary:"TODO from send on micropython",detail:"",life:3e3}}}async function R(e,t){const i=O(e.config);return i.ipPy==""?{status:l.FAILED}:await j(t,i)}async function oe(e){return e.config.send==y.WIFI&&(await R(e,"from machine import reset\rreset()\r")).status==l.OK?{typeResult:r.TOAST,data:{severity:"success",summary:"Reset command send",detail:"",life:3e3}}:{typeResult:r.TOAST,data:{severity:"warn",summary:"Failed soft reset micropython",detail:"",life:1e3}}}async function le(e){return e.config.send==y.WIFI&&(await R(e,"")).status==l.OK?{typeResult:r.TOAST,data:{severity:"success",summary:"Run main command send",detail:"",life:3e3}}:{typeResult:r.TOAST,data:{severity:"warn",summary:"Failed run main micropython",detail:"",life:1e3}}}async function se(e){const t=e.config.send,i=e.config;if(t==y.WIFI){const n=i.ip_mpy!=null&&i.ip_mpy!=""?i.ip_mpy:"",a=i.port_mpy!=null&&i.port_mpy!=""?i.port_mpy:"8266",o=i.password_mpy!=null&&i.password_mpy!=""?i.password_mpy:"0000";if(n!="")return{typeResult:r.TERM,data:{typeConnection:D.WEBSOCKET,data:{ip:n,port:a,user:"",password:o,endOfCommand:"\r"}}}}return{typeResult:r.TOAST,data:{severity:"warn",summary:"Failed open terminal micropython",detail:"",life:1e3}}}async function re(e,t){return e.extension==E?{typeResult:r.TEXT_PRINT,data:{title:"Python",content:t()}}:{typeResult:r.TOAST,data:{severity:"warn",summary:"Opción disponible solo con archivos blockly (json)",detail:"",life:5e3}}}async function de(){const e=await J();if(e.status==l.OK){let t="";for(let i=0;i<e.data.length;i++)t+=e.data[i]+`
351
351
  `;return{typeResult:r.TEXT_PRINT,data:{title:"SerialPortList",content:t}}}else return{typeResult:r.TOAST,data:{severity:"warn",summary:"No se pudo obtener información sobre los puertos seriales",detail:"",life:5e3}}}async function ce(e){const a="http://"+location.hostname+":"+8080+"/plugins/nodemcu/docs/index.html";return{typeResult:r.URL_PRINT,data:{title:p(ee.docs.title,e),content:a,description:"Abre el siguiente enlace para obtener infomación sobre la documentación de nodemcu"}}}let T,N,x;const pe=F,me=W,ue=X,he=G;function _e(e,t,i){x=e,T=t,N=i,B(x,T)}function A(){return U(T,N)}const fe=H;function ye(e){return[{label:p(u.magic,e),icon:"pi pi-sparkles",command:"micropython-magic"},{label:p(u.micropythonSend,e),icon:"pi pi-send",command:"micropython-send"},{label:"micropython",icon:"pi pi-microchip",items:[{label:p(u.getSerialportList,e),icon:"pi pi-search",command:"nodemcu-getserialportlist"},{label:p(u.docs,e),icon:"pi pi-book",command:"micropython-docs"},{label:p(u.reset,e),icon:"pi pi-refresh",command:"micropython-reset"},{label:p(u.play,e),icon:"pi pi-play",command:"micropython-play"},{label:p(u.term,e),icon:"pi pi-sync",command:"micropython-term"}]}]}async function we(e,t,i){return t=="micropython-send"?await ae(e,A):t=="micropython-magic"?await re(e,A):t=="nodemcu-getserialportlist"?await de():t=="micropython-docs"?await ce(i):t=="micropython-reset"?await oe(e):t=="micropython-play"?await le(e):t=="micropython-term"?await se(e):{typeResult:r.TOAST,data:{severity:"error",summary:"Función no localizada en el plugin",detail:"",life:3e3}}}d.blockly_template=ue,d.commandEmit=we,d.generateCode=A,d.getItemsToolBarOfPlugin=ye,d.initBlockly=_e,d.lang_template=he,d.platform=pe,d.platformLang=me,d.toolbox=fe,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@johnnycubides/micropython-esp32-plugin-catalejo-editor",
3
3
  "private": false,
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://gitlab.com/catalejo-team/catalejo-dev/micropython-esp32-plugin-catalejo-editor.git"
9
- },
9
+ },
10
10
  "scripts": {
11
11
  "dev": "vite",
12
12
  "build": "tsc && vite build",
@@ -16,13 +16,15 @@
16
16
  "devDependencies": {
17
17
  "@types/node": "^20.12.12",
18
18
  "typescript": "^5.4.5",
19
- "vite": "^5.2.0",
20
- "vite-plugin-dts": "^3.9.1"
19
+ "vite": "^6.2.2",
20
+ "vite-plugin-dts": "^4.5.3"
21
21
  },
22
22
  "dependencies": {
23
23
  "@johnnycubides/blockly-catalejo": "^0.1.0",
24
24
  "@johnnycubides/micropython-esp32-blockly-catalejo": "^0.4.0"
25
25
  },
26
26
  "main": "micropython-esp32/micropython.es.js",
27
- "files": ["micropython-esp32"]
27
+ "files": [
28
+ "micropython-esp32"
29
+ ]
28
30
  }