@johnnycubides/micropython-esp32-plugin-catalejo-editor 0.1.1 → 0.2.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.
@@ -1,6 +1,5 @@
1
1
  import { Project, PluginResult } from './types';
2
2
  import { LANG } from './consts';
3
-
4
3
  /** Envío de código de tarjeta de desarrollo en función del método [wifi, serial] */
5
4
  declare function micropythonSend(project: Project, generateCode: Function): Promise<PluginResult>;
6
5
  /** Reset de software */
@@ -1,5 +1,4 @@
1
1
  import { ProgLang } from './types';
2
-
3
2
  export declare enum STATUS {
4
3
  OK = 0,
5
4
  FAILED = 1,
@@ -1,4 +1,7 @@
1
1
  import { Result, SerialOptions } from './types';
2
-
2
+ /** Envío por puerto serial usando el plugin NodeMCU (método "nodemcu.saveCode").
3
+ * Solo funciona si el plugin NodeMCU está instalado. Hoy no se usa: lo llama
4
+ * nodemcuSend (commands.ts), que ningún comando ejecuta. */
3
5
  export declare function saveCode(portName: string, serialOptions: SerialOptions, timeout: number, fileName: string, content: string, blockSize: number): Promise<Result>;
6
+ /** Lista de puertos seriales del equipo donde corre el backend */
4
7
  export declare function getSerialPortList(): Promise<Result>;
@@ -1,5 +1,4 @@
1
1
  import { LANG } from './consts';
2
-
3
2
  declare const itemsToolBarLang: {
4
3
  micropythonSend: {
5
4
  en: string;
@@ -1,6 +1,5 @@
1
1
  import { Project, PluginResult } from './types';
2
2
  import { LANG } from './consts';
3
-
4
3
  /** Valor que representa la plataforma para la cual es presentado este plugin */
5
4
  declare const platform = "micropython-esp32";
6
5
  /** Lenguaje interpretado con el que opera el plugin (indicar la extension en vez del nombre del lenguaje) */
@@ -1 +1,2 @@
1
1
  export * from './main'
2
+ export {}
@@ -57,11 +57,11 @@ function V(e, t) {
57
57
  return o;
58
58
  };
59
59
  }
60
- const h = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!--%20Created%20with%20Inkscape%20(http://www.inkscape.org/)%20--%3e%3csvg%20width='80mm'%20height='80mm'%20viewBox='0%200%2080%2080'%20version='1.1'%20id='svg5'%20sodipodi:docname='adc.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%3csodipodi:namedview%20id='namedview7'%20pagecolor='%23ffffff'%20bordercolor='%23000000'%20borderopacity='0.25'%20inkscape:showpageshadow='2'%20inkscape:pageopacity='0.0'%20inkscape:pagecheckerboard='0'%20inkscape:deskcolor='%23d1d1d1'%20inkscape:document-units='mm'%20showgrid='true'%20inkscape:zoom='2.8284272'%20inkscape:cx='118.97071'%20inkscape:cy='143.01234'%20inkscape:window-width='1918'%20inkscape:window-height='1150'%20inkscape:window-x='1440'%20inkscape:window-y='24'%20inkscape:window-maximized='1'%20inkscape:current-layer='layer1'%3e%3cinkscape:grid%20type='xygrid'%20id='grid483'%20/%3e%3c/sodipodi:namedview%3e%3cdefs%20id='defs2'%20/%3e%3cg%20inkscape:label='Layer%201'%20inkscape:groupmode='layer'%20id='layer1'%3e%3cpath%20style='fill:none;stroke:%23000000;stroke-width:10;stroke-dasharray:none'%20d='M%207.9185622,40.195018%20C%2017.631127,10.282868%2027.506005,-14.748985%2041.621293,39.908944%2061.152028,102.40339%2066.055646,62.159434%2073.289058,40.202455'%20id='path113'%20sodipodi:nodetypes='ccc'%20/%3e%3cpath%20style='fill:none;stroke:%23000000;stroke-width:5;stroke-dasharray:20,5;stroke-dashoffset:0'%20d='M%201.2772021,39.941328%2079.018925,39.898992'%20id='path1020'%20/%3e%3cpath%20style='fill:none;stroke:%23000000;stroke-width:5;stroke-dasharray:20,5;stroke-dashoffset:0'%20d='M%203.8172185,1.6052225%203.8928693,78.585751'%20id='path1057'%20/%3e%3c/g%3e%3c/svg%3e";
60
+ const _ = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!--%20Created%20with%20Inkscape%20(http://www.inkscape.org/)%20--%3e%3csvg%20width='80mm'%20height='80mm'%20viewBox='0%200%2080%2080'%20version='1.1'%20id='svg5'%20sodipodi:docname='adc.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%3csodipodi:namedview%20id='namedview7'%20pagecolor='%23ffffff'%20bordercolor='%23000000'%20borderopacity='0.25'%20inkscape:showpageshadow='2'%20inkscape:pageopacity='0.0'%20inkscape:pagecheckerboard='0'%20inkscape:deskcolor='%23d1d1d1'%20inkscape:document-units='mm'%20showgrid='true'%20inkscape:zoom='2.8284272'%20inkscape:cx='118.97071'%20inkscape:cy='143.01234'%20inkscape:window-width='1918'%20inkscape:window-height='1150'%20inkscape:window-x='1440'%20inkscape:window-y='24'%20inkscape:window-maximized='1'%20inkscape:current-layer='layer1'%3e%3cinkscape:grid%20type='xygrid'%20id='grid483'%20/%3e%3c/sodipodi:namedview%3e%3cdefs%20id='defs2'%20/%3e%3cg%20inkscape:label='Layer%201'%20inkscape:groupmode='layer'%20id='layer1'%3e%3cpath%20style='fill:none;stroke:%23000000;stroke-width:10;stroke-dasharray:none'%20d='M%207.9185622,40.195018%20C%2017.631127,10.282868%2027.506005,-14.748985%2041.621293,39.908944%2061.152028,102.40339%2066.055646,62.159434%2073.289058,40.202455'%20id='path113'%20sodipodi:nodetypes='ccc'%20/%3e%3cpath%20style='fill:none;stroke:%23000000;stroke-width:5;stroke-dasharray:20,5;stroke-dashoffset:0'%20d='M%201.2772021,39.941328%2079.018925,39.898992'%20id='path1020'%20/%3e%3cpath%20style='fill:none;stroke:%23000000;stroke-width:5;stroke-dasharray:20,5;stroke-dashoffset:0'%20d='M%203.8172185,1.6052225%203.8928693,78.585751'%20id='path1057'%20/%3e%3c/g%3e%3c/svg%3e";
61
61
  function M(e, t) {
62
62
  e.Blocks.adc_minimal_class = {
63
63
  init: function() {
64
- this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(h, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Crear ADC, Pin:"), this.setOutput(!0, null), this.setColour(120), this.setTooltip("Crear canal del conversor ADC, se debe seleccionar un id pin con esta caracteristica del driver ADC. Los valores de entrada de voltaje están en el rango de 0 voltios a 3 voltios"), this.setHelpUrl("");
64
+ this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(_, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Crear ADC, Pin:"), this.setOutput(!0, null), this.setColour(120), this.setTooltip("Crear canal del conversor ADC, se debe seleccionar un id pin con esta caracteristica del driver ADC. Los valores de entrada de voltaje están en el rango de 0 voltios a 3 voltios"), this.setHelpUrl("");
65
65
  }
66
66
  }, t.adc_minimal_class = function(i) {
67
67
  var n = t.valueToCode(i, "id_pin", t.ORDER_ATOMIC);
@@ -70,7 +70,7 @@ function M(e, t) {
70
70
  return [a, t.ORDER_NONE];
71
71
  }, e.Blocks.adc_minimal_class_explicit = {
72
72
  init: function() {
73
- this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(h, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Crear ADC:").appendField(new e.FieldVariable("item"), "name").appendField(", Pin:"), this.setPreviousStatement(!0, null), this.setNextStatement(!0, null), this.setColour(120), this.setTooltip("Crear canal del conversor ADC, se debe seleccionar un id pin con esta caracteristica del driver ADC. Los valores de entrada de voltaje están en el rango de 0 voltios a 3 voltios"), this.setHelpUrl("");
73
+ this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(_, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Crear ADC:").appendField(new e.FieldVariable("item"), "name").appendField(", Pin:"), this.setPreviousStatement(!0, null), this.setNextStatement(!0, null), this.setColour(120), this.setTooltip("Crear canal del conversor ADC, se debe seleccionar un id pin con esta caracteristica del driver ADC. Los valores de entrada de voltaje están en el rango de 0 voltios a 3 voltios"), this.setHelpUrl("");
74
74
  }
75
75
  }, t.adc_minimal_class_explicit = function(i) {
76
76
  var n = t.nameDB_.getName(i.getFieldValue("name"), e.Variables.CATEGORY_NAME), a = t.valueToCode(i, "id_pin", t.ORDER_ATOMIC);
@@ -80,7 +80,7 @@ function M(e, t) {
80
80
  return o;
81
81
  }, e.Blocks.adc_minimal_read = {
82
82
  init: function() {
83
- this.appendDummyInput().appendField(new e.FieldImage(h, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Leer ADC, en:").appendField(new e.FieldVariable("item"), "adc_obj"), this.setInputsInline(!1), this.setOutput(!0, "Number"), this.setColour(120), this.setTooltip("Convierte un valor de voltaje entre [0, 3] a [0, 4095] unidades enteras (12bits), debe seleccionar la variable que representa el pin del canal ADC."), this.setHelpUrl("");
83
+ this.appendDummyInput().appendField(new e.FieldImage(_, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Leer ADC, en:").appendField(new e.FieldVariable("item"), "adc_obj"), this.setInputsInline(!1), this.setOutput(!0, "Number"), this.setColour(120), this.setTooltip("Convierte un valor de voltaje entre [0, 3] a [0, 4095] unidades enteras (12bits), debe seleccionar la variable que representa el pin del canal ADC."), this.setHelpUrl("");
84
84
  }
85
85
  }, t.adc_minimal_read = function(i) {
86
86
  var n = t.nameDB_.getName(i.getFieldValue("adc_obj"), e.Variables.CATEGORY_NAME);
@@ -89,7 +89,7 @@ function M(e, t) {
89
89
  return [a, t.ORDER_NONE];
90
90
  }, e.Blocks.adc_atten_class = {
91
91
  init: function() {
92
- this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(h, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Crear ADC, atenuación:").appendField(new e.FieldDropdown([["0dB", "ADC.ATTN_0DB"], ["2.5dB", "ADC.ATTN_2_5DB"], ["6dB", "ADC.ATTN_6DB"], ["11dB", "ADC.ATTN_11DB"]]), "atten").appendField(", Pin:"), this.setOutput(!0, "Number"), this.setColour(120), this.setTooltip("Crear canal del conversor ADC, se debe seleccionar un id pin con esta caracteristica del driver ADC, se puede seleccionar diferentes atenuaciones; 0dB -> (100mV - 950mV), 2.5dB -> (100mV - 1250 mV), 6dB -> (150mV - 1750 mV), 11dB -> (150mV - 2450mV)."), this.setHelpUrl("");
92
+ this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(_, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Crear ADC, atenuación:").appendField(new e.FieldDropdown([["0dB", "ADC.ATTN_0DB"], ["2.5dB", "ADC.ATTN_2_5DB"], ["6dB", "ADC.ATTN_6DB"], ["11dB", "ADC.ATTN_11DB"]]), "atten").appendField(", Pin:"), this.setOutput(!0, "Number"), this.setColour(120), this.setTooltip("Crear canal del conversor ADC, se debe seleccionar un id pin con esta caracteristica del driver ADC, se puede seleccionar diferentes atenuaciones; 0dB -> (100mV - 950mV), 2.5dB -> (100mV - 1250 mV), 6dB -> (150mV - 1750 mV), 11dB -> (150mV - 2450mV)."), this.setHelpUrl("");
93
93
  }
94
94
  }, t.adc_atten_class = function(i) {
95
95
  var n = i.getFieldValue("atten"), a = t.valueToCode(i, "id_pin", t.ORDER_ATOMIC);
@@ -98,7 +98,7 @@ function M(e, t) {
98
98
  return [o, t.ORDER_NONE];
99
99
  }, e.Blocks.adc_resolution_select_read = {
100
100
  init: function() {
101
- this.appendDummyInput().appendField(new e.FieldImage(h, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Leer ADC en").appendField(new e.FieldVariable("item"), "adc_obj").appendField(", resolución").appendField(new e.FieldDropdown([["12bits", "read()"], ["16bits", "read_u16()"], ["microvoltios", "read_uv()"]]), "resolution"), this.setInputsInline(!1), this.setOutput(!0, "Number"), this.setColour(120), this.setTooltip("Convierte un valor de voltaje a unidades (ADC). Se debe seleccionar la resolución: 12bits -> (0, 4095), 16 bits -> (0, 65535), microvoltios. debe seleccionar la variable que representa el pin del canal de ADC."), this.setHelpUrl("");
101
+ this.appendDummyInput().appendField(new e.FieldImage(_, 15, 15, { alt: "*", flipRtl: "FALSE" })).appendField("Leer ADC en").appendField(new e.FieldVariable("item"), "adc_obj").appendField(", resolución").appendField(new e.FieldDropdown([["12bits", "read()"], ["16bits", "read_u16()"], ["microvoltios", "read_uv()"]]), "resolution"), this.setInputsInline(!1), this.setOutput(!0, "Number"), this.setColour(120), this.setTooltip("Convierte un valor de voltaje a unidades (ADC). Se debe seleccionar la resolución: 12bits -> (0, 4095), 16 bits -> (0, 65535), microvoltios. debe seleccionar la variable que representa el pin del canal de ADC."), this.setHelpUrl("");
102
102
  }
103
103
  }, t.adc_resolution_select_read = function(i) {
104
104
  var n = t.nameDB_.getName(i.getFieldValue("adc_obj"), e.Variables.CATEGORY_NAME), a = i.getFieldValue("resolution");
@@ -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 S(e, t) {
145
+ function L(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 S(e, t) {
171
171
  return [o, t.ORDER_NONE];
172
172
  };
173
173
  }
174
- function L(e, t) {
175
- V(e, t), I(e, t), M(e, t), P(e, t), S(e, t);
174
+ function S(e, t) {
175
+ V(e, t), I(e, t), M(e, t), P(e, t), L(e, t);
176
176
  }
177
177
  const B = `
178
178
  <xml id="toolbox" style="display: none">
@@ -510,37 +510,31 @@ const B = `
510
510
  function H(e, t) {
511
511
  return e.INFINITE_LOOP_TRAP = null, e.workspaceToCode(t);
512
512
  }
513
- var s = /* @__PURE__ */ ((e) => (e[e.OK = 0] = "OK", e[e.FAILED = 1] = "FAILED", e[e.CHANGE = 2] = "CHANGE", e[e.WITHOUTCHANGE = 3] = "WITHOUTCHANGE", e[e.REQUEST = 4] = "REQUEST", e[e.REQUEST_SELECT_FILE_IN_TABVIEW = 5] = "REQUEST_SELECT_FILE_IN_TABVIEW", e[e.EXISTS = 6] = "EXISTS", e[e.NOEXIST = 7] = "NOEXIST", e[e.FOUND = 8] = "FOUND", e[e.NOTFOUND = 9] = "NOTFOUND", e[e.ADDED = 10] = "ADDED", e[e.SAVED = 11] = "SAVED", e[e.UNSAVED = 12] = "UNSAVED", e[e.SET_WS = 13] = "SET_WS", e[e.ENABLED = 14] = "ENABLED", e[e.DESABLED = 15] = "DESABLED", e))(s || {}), k = /* @__PURE__ */ ((e) => (e[e.EN = 0] = "EN", e[e.ES = 1] = "ES", e))(k || {}), r = /* @__PURE__ */ ((e) => (e[e.TOAST = 0] = "TOAST", e[e.TEXT_PRINT = 1] = "TEXT_PRINT", e[e.TEXT_AREA = 2] = "TEXT_AREA", e[e.URL_PRINT = 3] = "URL_PRINT", e[e.TERM = 4] = "TERM", e))(r || {}), D = /* @__PURE__ */ ((e) => (e[e.WEBSOCKET = 0] = "WEBSOCKET", e[e.TCP_IP = 1] = "TCP_IP", e[e.SERIAL = 2] = "SERIAL", e))(D || {});
513
+ var l = /* @__PURE__ */ ((e) => (e[e.OK = 0] = "OK", e[e.FAILED = 1] = "FAILED", e[e.CHANGE = 2] = "CHANGE", e[e.WITHOUTCHANGE = 3] = "WITHOUTCHANGE", e[e.REQUEST = 4] = "REQUEST", e[e.REQUEST_SELECT_FILE_IN_TABVIEW = 5] = "REQUEST_SELECT_FILE_IN_TABVIEW", e[e.EXISTS = 6] = "EXISTS", e[e.NOEXIST = 7] = "NOEXIST", e[e.FOUND = 8] = "FOUND", e[e.NOTFOUND = 9] = "NOTFOUND", e[e.ADDED = 10] = "ADDED", e[e.SAVED = 11] = "SAVED", e[e.UNSAVED = 12] = "UNSAVED", e[e.SET_WS = 13] = "SET_WS", e[e.ENABLED = 14] = "ENABLED", e[e.DESABLED = 15] = "DESABLED", e))(l || {}), k = /* @__PURE__ */ ((e) => (e[e.EN = 0] = "EN", e[e.ES = 1] = "ES", e))(k || {}), r = /* @__PURE__ */ ((e) => (e[e.TOAST = 0] = "TOAST", e[e.TEXT_PRINT = 1] = "TEXT_PRINT", e[e.TEXT_AREA = 2] = "TEXT_AREA", e[e.URL_PRINT = 3] = "URL_PRINT", e[e.TERM = 4] = "TERM", e))(r || {}), T = /* @__PURE__ */ ((e) => (e[e.WEBSOCKET = 0] = "WEBSOCKET", e[e.TCP_IP = 1] = "TCP_IP", e[e.SERIAL = 2] = "SERIAL", e))(T || {});
514
514
  const U = { name: "Python", extension: "py" }, C = "py", v = "json", E = "micropython-esp32", W = "main.py", K = '{"config":{"platform":"micropython-esp32","send":"wifi","ip_mpy":"192.168.4.1","serialport":""},"blocklycode":"<xml xmlns=\\"https://developers.google.com/blockly/xml\\"></xml>"}', X = `# platform: micropython-esp32
515
515
  # send: wifi
516
516
  # ip_mpy: 192.168.4.1
517
517
  # serialport:
518
518
  `;
519
- var _ = /* @__PURE__ */ ((e) => (e.WIFI = "wifi", e.SERIAL = "serial", e))(_ || {});
520
- const G = "http://" + location.hostname, z = "8080", q = "cors", Y = "nodemcu/";
521
- async function Z(e, t) {
519
+ var h = /* @__PURE__ */ ((e) => (e.WIFI = "wifi", e.SERIAL = "serial", e))(h || {});
520
+ async function G(e, t, i) {
521
+ const n = window.catalejo;
522
+ if (!n)
523
+ throw { message: "El editor no ofrece la conexión con el backend (window.catalejo)" };
524
+ return await n.call(e, t, i);
525
+ }
526
+ async function z() {
522
527
  try {
523
- const n = await (await fetch(e, t)).json();
524
- return n.status == s.OK, n;
525
- } catch (i) {
526
- return console.error(i), { status: s.FAILED };
528
+ const e = await G("serial.list", {});
529
+ return { status: l.OK, data: e.ports };
530
+ } catch (e) {
531
+ return console.error("serial.list", e), { status: l.FAILED, data: (e == null ? void 0 : e.message) || String(e) };
527
532
  }
528
533
  }
529
- async function Q() {
530
- const e = Y + "getserialportlist", t = G + ":" + z + "/" + e, n = {
531
- method: "PUT",
532
- mode: q,
533
- headers: {
534
- "Content-Type": "application/json"
535
- },
536
- body: JSON.stringify({})
537
- };
538
- return await Z(t, n);
539
- }
540
534
  function m(e) {
541
535
  return new Promise((t) => setTimeout(t, e));
542
536
  }
543
- async function J(e, t, i) {
537
+ async function q(e, t, i) {
544
538
  typeof t == "string" ? t = new TextEncoder().encode(t) : t instanceof Uint8Array || (t = new Uint8Array(t));
545
539
  const n = new WebSocket("ws://" + i.ipPy + ":" + i.portPy + "/");
546
540
  return n.binaryType = "arraybuffer", new Promise((a) => {
@@ -549,31 +543,31 @@ async function J(e, t, i) {
549
543
  }, n.onopen = async function() {
550
544
  console.log("WebSocket connection opened."), await m(100), console.log("This password: " + i.passwordPy), n.send(i.passwordPy + "\r"), await m(100);
551
545
  const o = t.length, d = e;
552
- let l = new Uint8Array(82);
553
- l[0] = 87, l[1] = 65, l[2] = 1, l[3] = 0, l[4] = 0, l[5] = 0, l[6] = 0, l[7] = 0, l[8] = 0, l[9] = 0, l[10] = 0, l[11] = 0, l[12] = o & 255, l[13] = o >> 8 & 255, l[14] = o >> 16 & 255, l[15] = o >> 24 & 255, l[16] = d.length & 255, l[17] = d.length >> 8 & 255;
546
+ let s = new Uint8Array(82);
547
+ 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] = d.length & 255, s[17] = d.length >> 8 & 255;
554
548
  for (var u = 0; u < 64; ++u)
555
- u < d.length ? l[18 + u] = d.charCodeAt(u) : l[18 + u] = 0;
556
- console.log("Send file to micropython: " + e), n.send(l), n.onmessage = async function() {
549
+ u < d.length ? s[18 + u] = d.charCodeAt(u) : s[18 + u] = 0;
550
+ console.log("Send file to micropython: " + e), n.send(s), n.onmessage = async function() {
557
551
  for (let f = 0; f < t.length; f += i.chuckSizePy) {
558
552
  const F = t.slice(f, f + i.chuckSizePy);
559
553
  console.log(F), n.send(F), await m(i.sleepTimePy);
560
554
  }
561
- n.send(""), m(100), n.close(), a({ status: s.OK, data: "File uploaded" });
555
+ n.send(""), m(100), n.close(), a({ status: l.OK, data: "File uploaded" });
562
556
  };
563
557
  }, n.onerror = function(o) {
564
- a({ status: s.FAILED, data: "WebSocket error" + o });
558
+ a({ status: l.FAILED, data: "WebSocket error" + o });
565
559
  }, n.onclose = function() {
566
560
  console.log("WebSocket connection closed.");
567
561
  };
568
562
  });
569
563
  }
570
- async function $(e, t) {
564
+ async function Y(e, t) {
571
565
  const i = new WebSocket("ws://" + t.ipPy + ":" + t.portPy + "/");
572
566
  return new Promise((n) => {
573
567
  i.onopen = async function() {
574
- await m(100), i.send(t.passwordPy + "\r"), await m(100), i.send(e), await m(100), i.close(), n({ status: s.OK, data: "File uploaded" });
568
+ 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" });
575
569
  }, i.onerror = function(a) {
576
- n({ status: s.FAILED, data: "WebSocket error" + a });
570
+ n({ status: l.FAILED, data: "WebSocket error" + a });
577
571
  }, i.onclose = function() {
578
572
  console.log("WebSocket connection closed.");
579
573
  }, i.onmessage = (a) => {
@@ -581,7 +575,7 @@ async function $(e, t) {
581
575
  };
582
576
  });
583
577
  }
584
- const c = {
578
+ const p = {
585
579
  micropythonSend: {
586
580
  en: "Send",
587
581
  es: "Enviar"
@@ -610,19 +604,15 @@ const c = {
610
604
  en: "Run terminal",
611
605
  es: "Conectersa a micropython"
612
606
  }
613
- }, j = {
607
+ }, Z = {
614
608
  docs: {
615
609
  title: {
616
610
  en: "Micropython documentation",
617
611
  es: "Documentación para Micropython"
618
- },
619
- description: {
620
- en: "Open the next link to get information about Micropython",
621
- es: " Abre el siguiente enlace para obtener información sobre Micropython"
622
612
  }
623
613
  }
624
614
  };
625
- function p(e, t) {
615
+ function c(e, t) {
626
616
  return t == k.EN ? e.en : t == k.ES ? e.es : "noname";
627
617
  }
628
618
  function O(e) {
@@ -634,27 +624,27 @@ function O(e) {
634
624
  chuckSizePy: e.chuckSize_mpy != null && e.chuckSize_mpy != "" ? parseInt(e.chuckSize_mpy) : 1024
635
625
  };
636
626
  }
637
- function ee(e, t) {
638
- return e.extension == C ? { status: s.OK, data: e.content } : e.extension == v && e.config.platform == E ? { status: s.OK, data: t() } : { status: s.FAILED };
627
+ function Q(e, t) {
628
+ return e.extension == C ? { status: l.OK, data: e.content } : e.extension == v && e.config.platform == E ? { status: l.OK, data: t() } : { status: l.FAILED };
639
629
  }
640
- function te(e) {
641
- return e.extension == C ? e.config.filename != "" && e.config.filename != null ? { status: s.OK, data: e.config.filename } : { status: s.OK, data: e.filename } : e.extension == v && e.config.platform == E ? e.config.filename != "" && e.config.filename != null ? { status: s.OK, data: e.config.filename } : { status: s.OK, data: W } : { status: s.FAILED };
630
+ function $(e) {
631
+ 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 == v && e.config.platform == E ? e.config.filename != "" && e.config.filename != null ? { status: l.OK, data: e.config.filename } : { status: l.OK, data: W } : { status: l.FAILED };
642
632
  }
643
- async function ie(e, t) {
633
+ async function J(e, t) {
644
634
  const i = O(e.config);
645
635
  if (i.ipPy == "")
646
- return { status: s.FAILED };
636
+ return { status: l.FAILED };
647
637
  let n;
648
- if (n = te(e), n.status == s.FAILED)
638
+ if (n = $(e), n.status == l.FAILED)
649
639
  return n;
650
640
  const a = n.data;
651
- if (n = ee(e, t), n.status == s.FAILED)
641
+ if (n = Q(e, t), n.status == l.FAILED)
652
642
  return n;
653
643
  const o = n.data;
654
- return n = await J(a, o, i), n;
644
+ return n = await q(a, o, i), n;
655
645
  }
656
- async function ne(e, t) {
657
- return e.config.send == _.WIFI && (await ie(e, t)).status == s.OK ? {
646
+ async function j(e, t) {
647
+ return e.config.send == h.WIFI && (await J(e, t)).status == l.OK ? {
658
648
  typeResult: r.TOAST,
659
649
  data: {
660
650
  severity: "success",
@@ -674,10 +664,10 @@ async function ne(e, t) {
674
664
  }
675
665
  async function R(e, t) {
676
666
  const i = O(e.config);
677
- return i.ipPy == "" ? { status: s.FAILED } : await $(t, i);
667
+ return i.ipPy == "" ? { status: l.FAILED } : await Y(t, i);
678
668
  }
679
- async function ae(e) {
680
- return e.config.send == _.WIFI && (await R(e, "from machine import reset\rreset()\r")).status == s.OK ? {
669
+ async function ee(e) {
670
+ return e.config.send == h.WIFI && (await R(e, "from machine import reset\rreset()\r")).status == l.OK ? {
681
671
  typeResult: r.TOAST,
682
672
  data: {
683
673
  severity: "success",
@@ -695,8 +685,8 @@ async function ae(e) {
695
685
  }
696
686
  };
697
687
  }
698
- async function oe(e) {
699
- return e.config.send == _.WIFI && (await R(e, "")).status == s.OK ? {
688
+ async function te(e) {
689
+ return e.config.send == h.WIFI && (await R(e, "")).status == l.OK ? {
700
690
  typeResult: r.TOAST,
701
691
  data: {
702
692
  severity: "success",
@@ -714,15 +704,15 @@ async function oe(e) {
714
704
  }
715
705
  };
716
706
  }
717
- async function se(e) {
707
+ async function ie(e) {
718
708
  const t = e.config.send, i = e.config;
719
- if (t == _.WIFI) {
709
+ if (t == h.WIFI) {
720
710
  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";
721
711
  if (n != "")
722
712
  return {
723
713
  typeResult: r.TERM,
724
714
  data: {
725
- typeConnection: D.WEBSOCKET,
715
+ typeConnection: T.WEBSOCKET,
726
716
  data: {
727
717
  ip: n,
728
718
  port: a,
@@ -743,7 +733,7 @@ async function se(e) {
743
733
  }
744
734
  };
745
735
  }
746
- async function le(e, t) {
736
+ async function ne(e, t) {
747
737
  return e.extension == v ? {
748
738
  typeResult: r.TEXT_PRINT,
749
739
  data: {
@@ -760,9 +750,9 @@ async function le(e, t) {
760
750
  }
761
751
  };
762
752
  }
763
- async function re() {
764
- const e = await Q();
765
- if (e.status == s.OK) {
753
+ async function ae() {
754
+ const e = await z();
755
+ if (e.status == l.OK) {
766
756
  let t = "";
767
757
  for (let i = 0; i < e.data.length; i++)
768
758
  t += e.data[i] + `
@@ -785,35 +775,35 @@ async function re() {
785
775
  }
786
776
  };
787
777
  }
788
- async function de(e) {
778
+ async function oe(e) {
789
779
  const a = "http://" + location.hostname + ":" + 8080 + "/plugins/nodemcu/docs/index.html";
790
780
  return {
791
781
  typeResult: r.URL_PRINT,
792
782
  data: {
793
- title: p(j.docs.title, e),
783
+ title: c(Z.docs.title, e),
794
784
  content: a,
795
785
  description: "Abre el siguiente enlace para obtener infomación sobre la documentación de nodemcu"
796
786
  }
797
787
  };
798
788
  }
799
789
  let g, x, A;
800
- const pe = E, ce = U, me = K, ue = X;
801
- function he(e, t, i) {
802
- A = e, g = t, x = i, L(A, g);
790
+ const le = E, se = U, re = K, de = X;
791
+ function ce(e, t, i) {
792
+ A = e, g = t, x = i, S(A, g);
803
793
  }
804
- function T() {
794
+ function D() {
805
795
  return H(g, x);
806
796
  }
807
- const _e = B;
808
- function fe(e) {
797
+ const pe = B;
798
+ function me(e) {
809
799
  return [
810
800
  {
811
- label: p(c.magic, e),
801
+ label: c(p.magic, e),
812
802
  icon: "pi pi-sparkles",
813
803
  command: "micropython-magic"
814
804
  },
815
805
  {
816
- label: p(c.micropythonSend, e),
806
+ label: c(p.micropythonSend, e),
817
807
  icon: "pi pi-send",
818
808
  command: "micropython-send"
819
809
  },
@@ -822,27 +812,27 @@ function fe(e) {
822
812
  icon: "pi pi-microchip",
823
813
  items: [
824
814
  {
825
- label: p(c.getSerialportList, e),
815
+ label: c(p.getSerialportList, e),
826
816
  icon: "pi pi-search",
827
817
  command: "nodemcu-getserialportlist"
828
818
  },
829
819
  {
830
- label: p(c.docs, e),
820
+ label: c(p.docs, e),
831
821
  icon: "pi pi-book",
832
822
  command: "micropython-docs"
833
823
  },
834
824
  {
835
- label: p(c.reset, e),
825
+ label: c(p.reset, e),
836
826
  icon: "pi pi-refresh",
837
827
  command: "micropython-reset"
838
828
  },
839
829
  {
840
- label: p(c.play, e),
830
+ label: c(p.play, e),
841
831
  icon: "pi pi-play",
842
832
  command: "micropython-play"
843
833
  },
844
834
  {
845
- label: p(c.term, e),
835
+ label: c(p.term, e),
846
836
  icon: "pi pi-sync",
847
837
  command: "micropython-term"
848
838
  }
@@ -850,8 +840,8 @@ function fe(e) {
850
840
  }
851
841
  ];
852
842
  }
853
- async function ye(e, t, i) {
854
- return t == "micropython-send" ? await ne(e, T) : t == "micropython-magic" ? await le(e, T) : t == "nodemcu-getserialportlist" ? await re() : t == "micropython-docs" ? await de(i) : t == "micropython-reset" ? await ae(e) : t == "micropython-play" ? await oe(e) : t == "micropython-term" ? await se(e) : {
843
+ async function ue(e, t, i) {
844
+ return t == "micropython-send" ? await j(e, D) : t == "micropython-magic" ? await ne(e, D) : t == "nodemcu-getserialportlist" ? await ae() : t == "micropython-docs" ? await oe(i) : t == "micropython-reset" ? await ee(e) : t == "micropython-play" ? await te(e) : t == "micropython-term" ? await ie(e) : {
855
845
  typeResult: r.TOAST,
856
846
  data: {
857
847
  severity: "error",
@@ -862,13 +852,13 @@ async function ye(e, t, i) {
862
852
  };
863
853
  }
864
854
  export {
865
- me as blockly_template,
866
- ye as commandEmit,
867
- T as generateCode,
868
- fe as getItemsToolBarOfPlugin,
869
- he as initBlockly,
870
- ue as lang_template,
871
- pe as platform,
872
- ce as platformLang,
873
- _e as toolbox
855
+ re as blockly_template,
856
+ ue as commandEmit,
857
+ D as generateCode,
858
+ me as getItemsToolBarOfPlugin,
859
+ ce as initBlockly,
860
+ de as lang_template,
861
+ le as platform,
862
+ se as platformLang,
863
+ pe as toolbox
874
864
  };
@@ -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:"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
- `;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"})});
350
+ `;var y=(e=>(e.WIFI="wifi",e.SERIAL="serial",e))(y||{});async function z(e,t,i){const n=window.catalejo;if(!n)throw{message:"El editor no ofrece la conexión con el backend (window.catalejo)"};return await n.call(e,t,i)}async function q(){try{const e=await z("serial.list",{});return{status:l.OK,data:e.ports}}catch(e){return console.error("serial.list",e),{status:l.FAILED,data:(e==null?void 0:e.message)||String(e)}}}function m(e){return new Promise(t=>setTimeout(t,e))}async function Y(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 Z(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"}},Q={docs:{title:{en:"Micropython documentation",es:"Documentación para 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 $(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 J(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 j(e,t){const i=O(e.config);if(i.ipPy=="")return{status:l.FAILED};let n;if(n=J(e),n.status==l.FAILED)return n;const a=n.data;if(n=$(e,t),n.status==l.FAILED)return n;const o=n.data;return n=await Y(a,o,i),n}async function ee(e,t){return e.config.send==y.WIFI&&(await j(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 Z(t,i)}async function te(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 ie(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 ne(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 ae(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 oe(){const e=await q();if(e.status==l.OK){let t="";for(let i=0;i<e.data.length;i++)t+=e.data[i]+`
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 le(e){const a="http://"+location.hostname+":"+8080+"/plugins/nodemcu/docs/index.html";return{typeResult:r.URL_PRINT,data:{title:p(Q.docs.title,e),content:a,description:"Abre el siguiente enlace para obtener infomación sobre la documentación de nodemcu"}}}let A,x,N;const se=F,re=W,de=X,ce=G;function pe(e,t,i){N=e,A=t,x=i,B(N,A)}function T(){return U(A,x)}const me=H;function ue(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 he(e,t,i){return t=="micropython-send"?await ee(e,T):t=="micropython-magic"?await ae(e,T):t=="nodemcu-getserialportlist"?await oe():t=="micropython-docs"?await le(i):t=="micropython-reset"?await te(e):t=="micropython-play"?await ie(e):t=="micropython-term"?await ne(e):{typeResult:r.TOAST,data:{severity:"error",summary:"Función no localizada en el plugin",detail:"",life:3e3}}}d.blockly_template=de,d.commandEmit=he,d.generateCode=T,d.getItemsToolBarOfPlugin=ue,d.initBlockly=pe,d.lang_template=ce,d.platform=se,d.platformLang=re,d.toolbox=me,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "micropython-esp32",
3
+ "js": "micropython.es.js",
4
+ "work": "esp32-libs",
5
+ "version": "0.1.1"
6
+ }
@@ -1,5 +1,4 @@
1
1
  import { STATUS, TYPE_PLUGIN_RESULT, TYPE_TERMINAL_CONNECTION } from './consts';
2
-
3
2
  export interface Config {
4
3
  send?: string;
5
4
  filename?: string;
@@ -1,5 +1,4 @@
1
1
  import { Result, UpyWebsocketOptions } from './types';
2
-
3
2
  export declare function sendFile(fileName: string, fileContent: string | Uint8Array, options: UpyWebsocketOptions): Promise<Result>;
4
3
  /** Ejecutar un comando */
5
4
  export declare function run(command: string, options: UpyWebsocketOptions): Promise<Result>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@johnnycubides/micropython-esp32-plugin-catalejo-editor",
3
3
  "private": false,
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",