etiquetas.js 1.0.0-alpha.15 → 1.0.0-alpha.16

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.
@@ -599,8 +599,8 @@ CODE39$1.CODE39 = CODE39;
599
599
  var CODE128$2 = {};
600
600
  var CODE128_AUTO = {};
601
601
  var CODE128$1 = {};
602
- var constants$4 = {};
603
- Object.defineProperty(constants$4, "__esModule", {
602
+ var constants$5 = {};
603
+ Object.defineProperty(constants$5, "__esModule", {
604
604
  value: true
605
605
  });
606
606
  var _SET_BY_CODE;
@@ -612,29 +612,29 @@ function _defineProperty(obj, key, value) {
612
612
  }
613
613
  return obj;
614
614
  }
615
- var SET_A = constants$4.SET_A = 0;
616
- var SET_B = constants$4.SET_B = 1;
617
- var SET_C = constants$4.SET_C = 2;
618
- constants$4.SHIFT = 98;
619
- var START_A = constants$4.START_A = 103;
620
- var START_B = constants$4.START_B = 104;
621
- var START_C = constants$4.START_C = 105;
622
- constants$4.MODULO = 103;
623
- constants$4.STOP = 106;
624
- constants$4.FNC1 = 207;
625
- constants$4.SET_BY_CODE = (_SET_BY_CODE = {}, _defineProperty(_SET_BY_CODE, START_A, SET_A), _defineProperty(_SET_BY_CODE, START_B, SET_B), _defineProperty(_SET_BY_CODE, START_C, SET_C), _SET_BY_CODE);
626
- constants$4.SWAP = {
615
+ var SET_A = constants$5.SET_A = 0;
616
+ var SET_B = constants$5.SET_B = 1;
617
+ var SET_C = constants$5.SET_C = 2;
618
+ constants$5.SHIFT = 98;
619
+ var START_A = constants$5.START_A = 103;
620
+ var START_B = constants$5.START_B = 104;
621
+ var START_C = constants$5.START_C = 105;
622
+ constants$5.MODULO = 103;
623
+ constants$5.STOP = 106;
624
+ constants$5.FNC1 = 207;
625
+ constants$5.SET_BY_CODE = (_SET_BY_CODE = {}, _defineProperty(_SET_BY_CODE, START_A, SET_A), _defineProperty(_SET_BY_CODE, START_B, SET_B), _defineProperty(_SET_BY_CODE, START_C, SET_C), _SET_BY_CODE);
626
+ constants$5.SWAP = {
627
627
  101: SET_A,
628
628
  100: SET_B,
629
629
  99: SET_C
630
630
  };
631
- constants$4.A_START_CHAR = String.fromCharCode(208);
632
- constants$4.B_START_CHAR = String.fromCharCode(209);
633
- constants$4.C_START_CHAR = String.fromCharCode(210);
634
- constants$4.A_CHARS = "[\0-_È-Ï]";
635
- constants$4.B_CHARS = "[ -È-Ï]";
636
- constants$4.C_CHARS = "(Ï*[0-9]{2}Ï*)";
637
- constants$4.BARS = [11011001100, 11001101100, 11001100110, 10010011e3, 10010001100, 10001001100, 10011001e3, 10011000100, 10001100100, 11001001e3, 11001000100, 11000100100, 10110011100, 10011011100, 10011001110, 10111001100, 10011101100, 10011100110, 11001110010, 11001011100, 11001001110, 11011100100, 11001110100, 11101101110, 11101001100, 11100101100, 11100100110, 11101100100, 11100110100, 11100110010, 11011011e3, 11011000110, 11000110110, 10100011e3, 10001011e3, 10001000110, 10110001e3, 10001101e3, 10001100010, 11010001e3, 11000101e3, 11000100010, 10110111e3, 10110001110, 10001101110, 10111011e3, 10111000110, 10001110110, 11101110110, 11010001110, 11000101110, 11011101e3, 11011100010, 11011101110, 11101011e3, 11101000110, 11100010110, 11101101e3, 11101100010, 11100011010, 11101111010, 11001000010, 11110001010, 1010011e4, 10100001100, 1001011e4, 10010000110, 10000101100, 10000100110, 1011001e4, 10110000100, 1001101e4, 10011000010, 10000110100, 10000110010, 11000010010, 1100101e4, 11110111010, 11000010100, 10001111010, 10100111100, 10010111100, 10010011110, 10111100100, 10011110100, 10011110010, 11110100100, 11110010100, 11110010010, 11011011110, 11011110110, 11110110110, 10101111e3, 10100011110, 10001011110, 10111101e3, 10111100010, 11110101e3, 11110100010, 10111011110, 10111101110, 11101011110, 11110101110, 11010000100, 1101001e4, 11010011100, 1100011101011];
631
+ constants$5.A_START_CHAR = String.fromCharCode(208);
632
+ constants$5.B_START_CHAR = String.fromCharCode(209);
633
+ constants$5.C_START_CHAR = String.fromCharCode(210);
634
+ constants$5.A_CHARS = "[\0-_È-Ï]";
635
+ constants$5.B_CHARS = "[ -È-Ï]";
636
+ constants$5.C_CHARS = "(Ï*[0-9]{2}Ï*)";
637
+ constants$5.BARS = [11011001100, 11001101100, 11001100110, 10010011e3, 10010001100, 10001001100, 10011001e3, 10011000100, 10001100100, 11001001e3, 11001000100, 11000100100, 10110011100, 10011011100, 10011001110, 10111001100, 10011101100, 10011100110, 11001110010, 11001011100, 11001001110, 11011100100, 11001110100, 11101101110, 11101001100, 11100101100, 11100100110, 11101100100, 11100110100, 11100110010, 11011011e3, 11011000110, 11000110110, 10100011e3, 10001011e3, 10001000110, 10110001e3, 10001101e3, 10001100010, 11010001e3, 11000101e3, 11000100010, 10110111e3, 10110001110, 10001101110, 10111011e3, 10111000110, 10001110110, 11101110110, 11010001110, 11000101110, 11011101e3, 11011100010, 11011101110, 11101011e3, 11101000110, 11100010110, 11101101e3, 11101100010, 11100011010, 11101111010, 11001000010, 11110001010, 1010011e4, 10100001100, 1001011e4, 10010000110, 10000101100, 10000100110, 1011001e4, 10110000100, 1001101e4, 10011000010, 10000110100, 10000110010, 11000010010, 1100101e4, 11110111010, 11000010100, 10001111010, 10100111100, 10010111100, 10010011110, 10111100100, 10011110100, 10011110010, 11110100100, 11110010100, 11110010010, 11011011110, 11011110110, 11110110110, 10101111e3, 10100011110, 10001011110, 10111101e3, 10111100010, 11110101e3, 11110100010, 10111011110, 10111101110, 11101011110, 11110101110, 11010000100, 1101001e4, 11010011100, 1100011101011];
638
638
  Object.defineProperty(CODE128$1, "__esModule", {
639
639
  value: true
640
640
  });
@@ -656,7 +656,7 @@ var _createClass$m = /* @__PURE__ */ function() {
656
656
  }();
657
657
  var _Barcode2$b = Barcode$1;
658
658
  var _Barcode3$b = _interopRequireDefault$z(_Barcode2$b);
659
- var _constants$b = constants$4;
659
+ var _constants$b = constants$5;
660
660
  function _interopRequireDefault$z(obj) {
661
661
  return obj && obj.__esModule ? obj : { default: obj };
662
662
  }
@@ -784,7 +784,7 @@ var auto = {};
784
784
  Object.defineProperty(auto, "__esModule", {
785
785
  value: true
786
786
  });
787
- var _constants$a = constants$4;
787
+ var _constants$a = constants$5;
788
788
  var matchSetALength = function matchSetALength2(string) {
789
789
  return string.match(new RegExp("^" + _constants$a.A_CHARS + "*"))[0].length;
790
790
  };
@@ -897,7 +897,7 @@ var _createClass$l = /* @__PURE__ */ function() {
897
897
  }();
898
898
  var _CODE2$5 = CODE128$1;
899
899
  var _CODE3$4 = _interopRequireDefault$x(_CODE2$5);
900
- var _constants$9 = constants$4;
900
+ var _constants$9 = constants$5;
901
901
  function _interopRequireDefault$x(obj) {
902
902
  return obj && obj.__esModule ? obj : { default: obj };
903
903
  }
@@ -956,7 +956,7 @@ var _createClass$k = /* @__PURE__ */ function() {
956
956
  }();
957
957
  var _CODE2$4 = CODE128$1;
958
958
  var _CODE3$3 = _interopRequireDefault$w(_CODE2$4);
959
- var _constants$8 = constants$4;
959
+ var _constants$8 = constants$5;
960
960
  function _interopRequireDefault$w(obj) {
961
961
  return obj && obj.__esModule ? obj : { default: obj };
962
962
  }
@@ -1015,7 +1015,7 @@ var _createClass$j = /* @__PURE__ */ function() {
1015
1015
  }();
1016
1016
  var _CODE2$3 = CODE128$1;
1017
1017
  var _CODE3$2 = _interopRequireDefault$v(_CODE2$3);
1018
- var _constants$7 = constants$4;
1018
+ var _constants$7 = constants$5;
1019
1019
  function _interopRequireDefault$v(obj) {
1020
1020
  return obj && obj.__esModule ? obj : { default: obj };
1021
1021
  }
@@ -1073,13 +1073,13 @@ CODE128$2.CODE128B = _CODE128B2.default;
1073
1073
  CODE128$2.CODE128C = _CODE128C2.default;
1074
1074
  var EAN_UPC = {};
1075
1075
  var EAN13$1 = {};
1076
- var constants$3 = {};
1077
- Object.defineProperty(constants$3, "__esModule", {
1076
+ var constants$4 = {};
1077
+ Object.defineProperty(constants$4, "__esModule", {
1078
1078
  value: true
1079
1079
  });
1080
- constants$3.SIDE_BIN = "101";
1081
- constants$3.MIDDLE_BIN = "01010";
1082
- constants$3.BINARIES = {
1080
+ constants$4.SIDE_BIN = "101";
1081
+ constants$4.MIDDLE_BIN = "01010";
1082
+ constants$4.BINARIES = {
1083
1083
  "L": [
1084
1084
  // The L (left) type of encoding
1085
1085
  "0001101",
@@ -1146,15 +1146,15 @@ constants$3.BINARIES = {
1146
1146
  "0010111"
1147
1147
  ]
1148
1148
  };
1149
- constants$3.EAN2_STRUCTURE = ["LL", "LG", "GL", "GG"];
1150
- constants$3.EAN5_STRUCTURE = ["GGLLL", "GLGLL", "GLLGL", "GLLLG", "LGGLL", "LLGGL", "LLLGG", "LGLGL", "LGLLG", "LLGLG"];
1151
- constants$3.EAN13_STRUCTURE = ["LLLLLL", "LLGLGG", "LLGGLG", "LLGGGL", "LGLLGG", "LGGLLG", "LGGGLL", "LGLGLG", "LGLGGL", "LGGLGL"];
1149
+ constants$4.EAN2_STRUCTURE = ["LL", "LG", "GL", "GG"];
1150
+ constants$4.EAN5_STRUCTURE = ["GGLLL", "GLGLL", "GLLGL", "GLLLG", "LGGLL", "LLGGL", "LLLGG", "LGLGL", "LGLLG", "LLGLG"];
1151
+ constants$4.EAN13_STRUCTURE = ["LLLLLL", "LLGLGG", "LLGGLG", "LLGGGL", "LGLLGG", "LGGLLG", "LGGGLL", "LGLGLG", "LGLGGL", "LGGLGL"];
1152
1152
  var EAN$1 = {};
1153
1153
  var encoder = {};
1154
1154
  Object.defineProperty(encoder, "__esModule", {
1155
1155
  value: true
1156
1156
  });
1157
- var _constants$6 = constants$3;
1157
+ var _constants$6 = constants$4;
1158
1158
  var encode$1 = function encode(data, structure, separator) {
1159
1159
  var encoded = data.split("").map(function(val, idx) {
1160
1160
  return _constants$6.BINARIES[structure[idx]];
@@ -1189,7 +1189,7 @@ var _createClass$i = /* @__PURE__ */ function() {
1189
1189
  return Constructor;
1190
1190
  };
1191
1191
  }();
1192
- var _constants$5 = constants$3;
1192
+ var _constants$5 = constants$4;
1193
1193
  var _encoder$4 = encoder;
1194
1194
  var _encoder2$4 = _interopRequireDefault$t(_encoder$4);
1195
1195
  var _Barcode2$a = Barcode$1;
@@ -1308,7 +1308,7 @@ var _get$1 = function get(object2, property, receiver) {
1308
1308
  return getter.call(receiver);
1309
1309
  }
1310
1310
  };
1311
- var _constants$4 = constants$3;
1311
+ var _constants$4 = constants$4;
1312
1312
  var _EAN2$2 = EAN$1;
1313
1313
  var _EAN3$2 = _interopRequireDefault$s(_EAN2$2);
1314
1314
  function _interopRequireDefault$s(obj) {
@@ -1538,7 +1538,7 @@ var _createClass$f = /* @__PURE__ */ function() {
1538
1538
  return Constructor;
1539
1539
  };
1540
1540
  }();
1541
- var _constants$3 = constants$3;
1541
+ var _constants$3 = constants$4;
1542
1542
  var _encoder$3 = encoder;
1543
1543
  var _encoder2$3 = _interopRequireDefault$q(_encoder$3);
1544
1544
  var _Barcode2$9 = Barcode$1;
@@ -1616,7 +1616,7 @@ var _createClass$e = /* @__PURE__ */ function() {
1616
1616
  return Constructor;
1617
1617
  };
1618
1618
  }();
1619
- var _constants$2 = constants$3;
1619
+ var _constants$2 = constants$4;
1620
1620
  var _encoder$2 = encoder;
1621
1621
  var _encoder2$2 = _interopRequireDefault$p(_encoder$2);
1622
1622
  var _Barcode2$8 = Barcode$1;
@@ -2008,13 +2008,13 @@ EAN_UPC.UPC = _UPC2.default;
2008
2008
  EAN_UPC.UPCE = _UPCE2.default;
2009
2009
  var ITF$2 = {};
2010
2010
  var ITF$1 = {};
2011
- var constants$1 = {};
2012
- Object.defineProperty(constants$1, "__esModule", {
2011
+ var constants$3 = {};
2012
+ Object.defineProperty(constants$3, "__esModule", {
2013
2013
  value: true
2014
2014
  });
2015
- constants$1.START_BIN = "1010";
2016
- constants$1.END_BIN = "11101";
2017
- constants$1.BINARIES = ["00110", "10001", "01001", "11000", "00101", "10100", "01100", "00011", "10010", "01010"];
2015
+ constants$3.START_BIN = "1010";
2016
+ constants$3.END_BIN = "11101";
2017
+ constants$3.BINARIES = ["00110", "10001", "01001", "11000", "00101", "10100", "01100", "00011", "10010", "01010"];
2018
2018
  Object.defineProperty(ITF$1, "__esModule", {
2019
2019
  value: true
2020
2020
  });
@@ -2034,7 +2034,7 @@ var _createClass$b = /* @__PURE__ */ function() {
2034
2034
  return Constructor;
2035
2035
  };
2036
2036
  }();
2037
- var _constants$1 = constants$1;
2037
+ var _constants$1 = constants$3;
2038
2038
  var _Barcode2$5 = Barcode$1;
2039
2039
  var _Barcode3$5 = _interopRequireDefault$l(_Barcode2$5);
2040
2040
  function _interopRequireDefault$l(obj) {
@@ -2649,11 +2649,11 @@ var codabar = function(_Barcode) {
2649
2649
  codabar$1.codabar = codabar;
2650
2650
  var CODE93$2 = {};
2651
2651
  var CODE93$1 = {};
2652
- var constants = {};
2653
- Object.defineProperty(constants, "__esModule", {
2652
+ var constants$1 = {};
2653
+ Object.defineProperty(constants$1, "__esModule", {
2654
2654
  value: true
2655
2655
  });
2656
- constants.SYMBOLS = [
2656
+ constants$1.SYMBOLS = [
2657
2657
  "0",
2658
2658
  "1",
2659
2659
  "2",
@@ -2705,8 +2705,8 @@ constants.SYMBOLS = [
2705
2705
  // Start/Stop
2706
2706
  "ÿ"
2707
2707
  ];
2708
- constants.BINARIES = ["100010100", "101001000", "101000100", "101000010", "100101000", "100100100", "100100010", "101010000", "100010010", "100001010", "110101000", "110100100", "110100010", "110010100", "110010010", "110001010", "101101000", "101100100", "101100010", "100110100", "100011010", "101011000", "101001100", "101000110", "100101100", "100010110", "110110100", "110110010", "110101100", "110100110", "110010110", "110011010", "101101100", "101100110", "100110110", "100111010", "100101110", "111010100", "111010010", "111001010", "101101110", "101110110", "110101110", "100100110", "111011010", "111010110", "100110010", "101011110"];
2709
- constants.MULTI_SYMBOLS = {
2708
+ constants$1.BINARIES = ["100010100", "101001000", "101000100", "101000010", "100101000", "100100100", "100100010", "101010000", "100010010", "100001010", "110101000", "110100100", "110100010", "110010100", "110010010", "110001010", "101101000", "101100100", "101100010", "100110100", "100011010", "101011000", "101001100", "101000110", "100101100", "100010110", "110110100", "110110010", "110101100", "110100110", "110010110", "110011010", "101101100", "101100110", "100110110", "100111010", "100101110", "111010100", "111010010", "111001010", "101101110", "101110110", "110101110", "100100110", "111011010", "111010110", "100110010", "101011110"];
2709
+ constants$1.MULTI_SYMBOLS = {
2710
2710
  "\0": ["(%)", "U"],
2711
2711
  "": ["($)", "A"],
2712
2712
  "": ["($)", "B"],
@@ -2812,7 +2812,7 @@ var _createClass$6 = /* @__PURE__ */ function() {
2812
2812
  return Constructor;
2813
2813
  };
2814
2814
  }();
2815
- var _constants = constants;
2815
+ var _constants = constants$1;
2816
2816
  var _Barcode2$1 = Barcode$1;
2817
2817
  var _Barcode3$1 = _interopRequireDefault$a(_Barcode2$1);
2818
2818
  function _interopRequireDefault$a(obj) {
@@ -11529,7 +11529,7 @@ function(t2) {
11529
11529
  */
11530
11530
  function(t2) {
11531
11531
  function e2() {
11532
- return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-DhuHIaTr.js")).catch(function(t3) {
11532
+ return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-cX3jF13I.js")).catch(function(t3) {
11533
11533
  return Promise.reject(new Error("Could not load canvg: " + t3));
11534
11534
  }).then(function(t3) {
11535
11535
  return t3.default ? t3.default : t3;
@@ -28406,44 +28406,41 @@ const makeBarCode = (mainObject) => {
28406
28406
  const variableManager = new VariableManager();
28407
28407
  let bar = v2.originBarcode === "PERSONALIZADO" ? variableManager.processTemplate(v2.customBarcode, extendedData.variableProps) || "null" : variableManager.processTemplate(v2.originBarcode, extendedData.variableProps);
28408
28408
  if (!bar.includes("null") && bar.length > 0) {
28409
- const aspectRatio = vWidth / vHeight;
28410
28409
  let canvas2 = document$2.createElement("canvas");
28411
- let canvasWidth, canvasHeight;
28412
- if (aspectRatio > 5) {
28413
- canvasWidth = 5e3;
28414
- canvasHeight = Math.round(5e3 / aspectRatio);
28415
- canvasHeight = Math.max(canvasHeight, 300);
28416
- } else if (aspectRatio < 0.2) {
28417
- canvasHeight = 5e3;
28418
- canvasWidth = Math.round(5e3 * aspectRatio);
28419
- canvasWidth = Math.max(canvasWidth, 300);
28420
- } else {
28421
- canvasHeight = 1e3;
28422
- canvasWidth = Math.round(1e3 * aspectRatio);
28423
- }
28410
+ const scaleFactor = 10;
28411
+ let canvasWidth = vWidth * scaleFactor;
28412
+ let canvasHeight = vHeight * scaleFactor;
28413
+ const maxDimension = 5e3;
28414
+ if (canvasWidth > maxDimension || canvasHeight > maxDimension) {
28415
+ const reductionFactor = Math.min(maxDimension / canvasWidth, maxDimension / canvasHeight);
28416
+ canvasWidth = Math.round(canvasWidth * reductionFactor);
28417
+ canvasHeight = Math.round(canvasHeight * reductionFactor);
28418
+ }
28419
+ canvasWidth = Math.max(canvasWidth, 300);
28420
+ canvasHeight = Math.max(canvasHeight, 100);
28424
28421
  canvas2.width = canvasWidth;
28425
28422
  canvas2.height = canvasHeight;
28426
28423
  let px = width * y2 + (verticalSpace * y2 + marginLeft2) + vLeft;
28427
28424
  let py = height * x2 + (horizontalSpace * x2 + marginTop2) + vTop;
28428
28425
  try {
28429
- const barWidth = Math.max(1, Math.min(3, canvasWidth / 100));
28426
+ const barWidth = Math.max(1, Math.min(5, canvasWidth / 150));
28430
28427
  JsBarcode$1(canvas2, bar, {
28431
28428
  format: v2.barcodeFormat || "CODE128",
28432
28429
  width: barWidth,
28433
28430
  // Largura adaptativa das barras
28434
- height: canvasHeight * 0.8,
28435
- // Altura proporcional ao canvas
28431
+ height: canvasHeight,
28432
+ // Usar 90% da altura do canvas para o código
28436
28433
  displayValue: false,
28437
28434
  // Não mostrar valor do código (texto escondido)
28438
- margin: Math.max(canvasHeight * 0.1, 10),
28439
- // Margem proporcional com mínimo
28435
+ margin: 0,
28436
+ // Sem margem para maximizar o uso do espaço
28440
28437
  background: "#ffffff"
28441
28438
  });
28442
28439
  } catch (error) {
28443
28440
  console.error("Erro ao gerar código de barras:", error);
28444
28441
  canvas2 = document$2.createElement("canvas");
28445
- canvas2.width = 400;
28446
- canvas2.height = 200;
28442
+ canvas2.width = Math.max(300, vWidth * 2);
28443
+ canvas2.height = Math.max(100, vHeight * 2);
28447
28444
  }
28448
28445
  if (v2.angle === 90) {
28449
28446
  px = width * y2 + (verticalSpace * y2 + marginLeft2) + vLeft - vHeight;
@@ -29251,11 +29248,11 @@ class LabelWorker {
29251
29248
  return this.isGenerating;
29252
29249
  }
29253
29250
  }
29254
- const createLabelWorker = () => {
29251
+ const createLabelWorker$1 = () => {
29255
29252
  return new LabelWorker();
29256
29253
  };
29257
29254
  const generateLabelsFromHookData = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (labelData, additionalParams = {}, progressCallback = null) {
29258
- const worker = createLabelWorker();
29255
+ const worker = createLabelWorker$1();
29259
29256
  console.log("labelData =>>>>>", labelData);
29260
29257
  const params = __spreadValues({
29261
29258
  dataSource: labelData.data || [],
@@ -29265,6 +29262,12 @@ const generateLabelsFromHookData = (_0, ..._1) => __async(void 0, [_0, ..._1], f
29265
29262
  }, additionalParams);
29266
29263
  return yield worker.generateLabels(params, progressCallback);
29267
29264
  });
29265
+ const labelWorker = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
29266
+ __proto__: null,
29267
+ LabelWorker,
29268
+ createLabelWorker: createLabelWorker$1,
29269
+ generateLabelsFromHookData
29270
+ }, Symbol.toStringTag, { value: "Module" }));
29268
29271
  const labelTypeNames = {
29269
29272
  parts: "Peças",
29270
29273
  woodwork: "Tamponamentos",
@@ -29350,6 +29353,11 @@ const templateVariables = {
29350
29353
  ]
29351
29354
  };
29352
29355
  Object.values(templateVariables).flat();
29356
+ const constants = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
29357
+ __proto__: null,
29358
+ labelTypeNames,
29359
+ templateVariables
29360
+ }, Symbol.toStringTag, { value: "Module" }));
29353
29361
  const useLabelData = (config = {}) => {
29354
29362
  const defaultConfig = {
29355
29363
  type: "parts",
@@ -29361,7 +29369,7 @@ const useLabelData = (config = {}) => {
29361
29369
  };
29362
29370
  const finalConfig = __spreadValues(__spreadValues({}, defaultConfig), config);
29363
29371
  const generateLabels = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (data, labels, userPrefs = {}, additionalParams = {}) {
29364
- const worker = createLabelWorker();
29372
+ const worker = createLabelWorker$1();
29365
29373
  const params = __spreadValues({
29366
29374
  dataSource: data || [],
29367
29375
  labels: labels || [],
@@ -59167,6 +59175,17 @@ const processLabelForParts = (..._0) => __async(void 0, [..._0], function* (part
59167
59175
  };
59168
59176
  }
59169
59177
  });
59178
+ const printerWorker = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
59179
+ __proto__: null,
59180
+ checkPrinterAvailability,
59181
+ convertPdfFileToArrayBuffer,
59182
+ convertPdfToImages,
59183
+ downloadPdfFallback,
59184
+ processLabelForParts,
59185
+ sendImagesToPrinter,
59186
+ sendPdfFileToPrinter,
59187
+ sendToPrinter: sendToPrinter$1
59188
+ }, Symbol.toStringTag, { value: "Module" }));
59170
59189
  let window$1, document$1, btoa$1;
59171
59190
  const initializeBrowserEnvironment = () => {
59172
59191
  if (!isBrowser) {
@@ -59375,114 +59394,6 @@ const makeLamination = (mainObject) => {
59375
59394
  }
59376
59395
  return pdf.output("datauristring");
59377
59396
  };
59378
- function getTemplateById(templateId) {
59379
- return __async(this, null, function* () {
59380
- try {
59381
- const labelData = yield LabelsAPI.getLabel(templateId);
59382
- if (!labelData) {
59383
- throw new Error(`Template/etiqueta não encontrado com ID: ${templateId}`);
59384
- }
59385
- console.log("templateContent:", labelData);
59386
- return JSON.parse(labelData.label_content);
59387
- } catch (error) {
59388
- console.error(`Erro ao buscar template: ${error.message}`);
59389
- throw error;
59390
- }
59391
- });
59392
- }
59393
- const createPrinterSlice = (set, get3) => ({
59394
- printerStatus: {
59395
- name: "Aguardando...",
59396
- connected: false,
59397
- status: "disconnected",
59398
- hasDefaultPrinter: false,
59399
- message: "Conectando ao servidor...",
59400
- printer: null
59401
- },
59402
- setPrinterStatus: (status) => set(() => ({ printerStatus: status })),
59403
- updatePrinterStatus: (updates) => set((state) => ({
59404
- printerStatus: __spreadValues(__spreadValues({}, state.printerStatus), updates)
59405
- }))
59406
- });
59407
- const createSSESlice = (set, get3) => ({
59408
- sseConnected: false,
59409
- eventSource: null,
59410
- setSseConnected: (connected) => set(() => ({ sseConnected: connected })),
59411
- setEventSource: (eventSource) => set(() => ({ eventSource })),
59412
- connectToSSE: () => {
59413
- const { eventSource, setSseConnected, updatePrinterStatus, setEventSource } = get3();
59414
- if (typeof EventSource === "undefined") {
59415
- console.log("EventSource não disponível em ambiente Node.js");
59416
- setSseConnected(false);
59417
- updatePrinterStatus({ connected: false, status: "disconnected" });
59418
- return;
59419
- }
59420
- if (eventSource) {
59421
- eventSource.close();
59422
- }
59423
- try {
59424
- const newEventSource = new EventSource("http://localhost:9999/printer/status/stream");
59425
- setEventSource(newEventSource);
59426
- newEventSource.onopen = () => {
59427
- console.log("Conexão SSE estabelecida com a impressora");
59428
- setSseConnected(true);
59429
- updatePrinterStatus({ status: "connecting" });
59430
- };
59431
- newEventSource.addEventListener("printer-status", (event) => {
59432
- var _a2;
59433
- try {
59434
- const data = JSON.parse(event.data);
59435
- console.log("message =>>>>>>>>>", data);
59436
- let status = "disconnected";
59437
- let name = "Nenhuma impressora";
59438
- if (!data.hasDefaultPrinter) {
59439
- status = "no-printer";
59440
- name = "Sem impressora configurada";
59441
- } else if (data.isConnected && data.printer) {
59442
- status = "connected";
59443
- name = data.printer.name || "Impressora";
59444
- } else {
59445
- status = "disconnected";
59446
- name = ((_a2 = data.printer) == null ? void 0 : _a2.name) || "Impressora";
59447
- }
59448
- updatePrinterStatus({
59449
- name,
59450
- connected: data.isConnected || false,
59451
- status,
59452
- hasDefaultPrinter: data.hasDefaultPrinter || false,
59453
- message: data.message || "",
59454
- printer: data.printer || null
59455
- });
59456
- } catch (error) {
59457
- console.warn("Erro ao processar dados da impressora:", error);
59458
- }
59459
- });
59460
- newEventSource.onerror = (error) => {
59461
- console.error("Erro na conexão SSE:", error);
59462
- setSseConnected(false);
59463
- updatePrinterStatus({ connected: false, status: "disconnected" });
59464
- newEventSource.close();
59465
- setEventSource(null);
59466
- setTimeout(() => {
59467
- get3().connectToSSE();
59468
- }, 5e3);
59469
- };
59470
- } catch (error) {
59471
- console.error("Erro ao conectar SSE:", error);
59472
- setSseConnected(false);
59473
- updatePrinterStatus({ connected: false, status: "disconnected" });
59474
- }
59475
- },
59476
- disconnectSSE: () => {
59477
- const { eventSource, setSseConnected, setEventSource } = get3();
59478
- if (eventSource) {
59479
- eventSource.close();
59480
- setEventSource(null);
59481
- }
59482
- setSseConnected(false);
59483
- }
59484
- });
59485
- const usePrinterStore = create((set, get3) => __spreadValues(__spreadValues({}, createPrinterSlice(set)), createSSESlice(set, get3)));
59486
59397
  const transformField = (data, fieldName, fieldMap) => {
59487
59398
  const transformation = fieldMap[fieldName];
59488
59399
  if (!transformation) {
@@ -59668,6 +59579,29 @@ const legacyFieldMap = {
59668
59579
  const legacyTransformer = (data) => {
59669
59580
  return applyTransformations(data, legacyFieldMap);
59670
59581
  };
59582
+ const isModuleContext = typeof import.meta !== "undefined";
59583
+ let createLabelWorker, getTemplateById;
59584
+ let printerWorkerSendToPrinter, usePrinterStore;
59585
+ if (isModuleContext) {
59586
+ Promise.resolve().then(() => labelWorker).then((module) => {
59587
+ module.LabelWorker;
59588
+ createLabelWorker = module.createLabelWorker;
59589
+ });
59590
+ Promise.resolve().then(() => constants).then((module) => {
59591
+ module.labelTypeNames;
59592
+ });
59593
+ import("./templates-DB-LZbhi.js").then((module) => {
59594
+ getTemplateById = module.getTemplateById;
59595
+ });
59596
+ Promise.resolve().then(() => printerWorker).then((module) => {
59597
+ printerWorkerSendToPrinter = module.sendToPrinter;
59598
+ });
59599
+ import("./usePrinterStore-DjE7a9VN.js").then((module) => {
59600
+ usePrinterStore = module.default;
59601
+ });
59602
+ } else {
59603
+ console.warn("Etiquetas.js carregado via tag script - modo de compatibilidade ativado");
59604
+ }
59671
59605
  new VariableManager();
59672
59606
  let globalConfig = {
59673
59607
  printerName: null,
@@ -60115,7 +60049,7 @@ const sendToPrinter = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (pdf
60115
60049
  status: printerStatus.status,
60116
60050
  hasDefaultPrinter: printerStatus.hasDefaultPrinter
60117
60051
  });
60118
- const result = yield sendToPrinter$1(pdfBuffer, options);
60052
+ const result = yield printerWorkerSendToPrinter(pdfBuffer, options);
60119
60053
  if (result.success && result.printed) {
60120
60054
  result.printerName = printerStatus.name;
60121
60055
  result.printerConnected = printerStatus.connected;
@@ -60383,71 +60317,72 @@ const EtiquetasJS = __spreadProps(__spreadValues({}, etiquetasAPI), {
60383
60317
  }
60384
60318
  });
60385
60319
  export {
60386
- makeLamination as $,
60387
- etiquetasAPI as A,
60388
- isBrowser as B,
60389
- isNodeJS$1 as C,
60390
- createBrowserCanvas as D,
60320
+ getBorderColor as $,
60321
+ validateLabelData as A,
60322
+ etiquetasAPI as B,
60323
+ isBrowser as C,
60324
+ isNodeJS$1 as D,
60391
60325
  EtiquetasJS as E,
60392
- loadImageBrowser as F,
60393
- createBrowserDOM as G,
60394
- downloadFile as H,
60395
- serializeXML as I,
60396
- createBuffer as J,
60397
- base64Encode as K,
60398
- LABEL_TYPES as L,
60399
- base64Decode as M,
60400
- sendPdfFileToPrinter as N,
60401
- processLabelForParts as O,
60402
- convertPdfToImages as P,
60403
- checkPrinterAvailability as Q,
60404
- sendImagesToPrinter as R,
60405
- downloadPdfFallback as S,
60406
- convertPdfFileToArrayBuffer as T,
60407
- createMiniSheet as U,
60408
- createImage as V,
60409
- createImageFromPart as W,
60410
- drawRect as X,
60411
- setBorder as Y,
60412
- getBorderColor as Z,
60326
+ createBrowserCanvas as F,
60327
+ loadImageBrowser as G,
60328
+ createBrowserDOM as H,
60329
+ downloadFile as I,
60330
+ serializeXML as J,
60331
+ createBuffer as K,
60332
+ LabelsAPI as L,
60333
+ base64Encode as M,
60334
+ base64Decode as N,
60335
+ sendPdfFileToPrinter as O,
60336
+ processLabelForParts as P,
60337
+ convertPdfToImages as Q,
60338
+ checkPrinterAvailability as R,
60339
+ sendImagesToPrinter as S,
60340
+ downloadPdfFallback as T,
60341
+ convertPdfFileToArrayBuffer as U,
60342
+ createMiniSheet as V,
60343
+ createImage as W,
60344
+ createImageFromPart as X,
60345
+ drawRect as Y,
60346
+ setBorder as Z,
60413
60347
  _typeof as _,
60414
- getPartLabels as a,
60415
- getNode as a0,
60416
- getAspectRatio as a1,
60417
- DEFAULT_LAMINATION_COLORS as a2,
60418
- stopCreatingLabels as a3,
60419
- initializeBrowserEnvironment as a4,
60420
- getImagesFromUrl as a5,
60421
- getImagesFromUrlToBase64 as a6,
60422
- mmToPx as a7,
60423
- convertSVGTableToAutoTableData as a8,
60424
- generateTableSVG as a9,
60425
- dataTypeList as aa,
60426
- getInputsByCategory as ab,
60427
- getScrapLabels as b,
60428
- commonjsGlobal as c,
60429
- getThickenedLabels as d,
60430
- getInputLabels as e,
60431
- getVolumeLabels as f,
60348
+ commonjsGlobal as a,
60349
+ makeLamination as a0,
60350
+ getNode as a1,
60351
+ getAspectRatio as a2,
60352
+ DEFAULT_LAMINATION_COLORS as a3,
60353
+ stopCreatingLabels as a4,
60354
+ initializeBrowserEnvironment as a5,
60355
+ getImagesFromUrl as a6,
60356
+ getImagesFromUrlToBase64 as a7,
60357
+ mmToPx as a8,
60358
+ convertSVGTableToAutoTableData as a9,
60359
+ generateTableSVG as aa,
60360
+ dataTypeList as ab,
60361
+ getInputsByCategory as ac,
60362
+ LABEL_TYPES as b,
60363
+ create as c,
60364
+ getPartLabels as d,
60365
+ getScrapLabels as e,
60366
+ getThickenedLabels as f,
60432
60367
  getDefaultExportFromCjs as g,
60433
- LabelWorker as h,
60434
- createLabelWorker as i,
60435
- generateLabelsFromHookData as j,
60436
- useLabelStore as k,
60437
- getPartsForLabels as l,
60438
- getInputForLabels as m,
60439
- getPartsFromProjectToLabels as n,
60440
- labelTypeNames as o,
60441
- initialState as p,
60442
- LabelsAPI as q,
60443
- reducer as r,
60444
- init as s,
60445
- getPrinterStatus as t,
60368
+ getInputLabels as h,
60369
+ getVolumeLabels as i,
60370
+ LabelWorker as j,
60371
+ createLabelWorker$1 as k,
60372
+ generateLabelsFromHookData as l,
60373
+ useLabelStore as m,
60374
+ getPartsForLabels as n,
60375
+ getInputForLabels as o,
60376
+ getPartsFromProjectToLabels as p,
60377
+ labelTypeNames as q,
60378
+ initialState as r,
60379
+ reducer as s,
60380
+ init as t,
60446
60381
  useLabelData as u,
60447
- makeLabel as v,
60448
- sendLabel as w,
60449
- downloadPDF as x,
60450
- sendToPrinter as y,
60451
- validateLabelData as z
60382
+ getPrinterStatus as v,
60383
+ makeLabel as w,
60384
+ sendLabel as x,
60385
+ downloadPDF as y,
60386
+ sendToPrinter as z
60452
60387
  };
60453
- //# sourceMappingURL=index-DS6c6wBJ.js.map
60388
+ //# sourceMappingURL=index-CrFIiiLi.js.map