etiquetas.js 1.0.0-alpha.1 → 1.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -38
- package/README.npm.md +0 -0
- package/dist/etiquetas.es.js +65 -0
- package/dist/etiquetas.es.js.map +1 -0
- package/dist/etiquetas.umd.js +358 -0
- package/dist/etiquetas.umd.js.map +1 -0
- package/dist/index-Bl0CvwuC.js +59982 -0
- package/dist/index-Bl0CvwuC.js.map +1 -0
- package/dist/index.es-eEPQXFRd.js +9229 -0
- package/dist/index.es-eEPQXFRd.js.map +1 -0
- package/dist/purify.es-DzZgBtzL.js +965 -0
- package/dist/purify.es-DzZgBtzL.js.map +1 -0
- package/package.json +38 -14
- package/README.git.md +0 -486
- package/api/api-labels.json +0 -114
- package/api/api.js +0 -316
- package/api/mock/data-volume-id_680.json +0 -64
- package/api/mock/labels-input.json +0 -96
- package/api/mock/labels-part.json +0 -216
- package/api/mock/labels-scrap.json +0 -76
- package/api/mock/labels-thickened.json +0 -96
- package/api/mock/labels-volume.json +0 -56
- package/api/token.txt +0 -1
- package/services/index.js +0 -28
- package/src/constants.js +0 -247
- package/src/createLabel.js +0 -342
- package/src/etiquetas.js +0 -654
- package/src/formatData.js +0 -96
- package/src/formatDataIntegrated.js +0 -498
- package/src/index.js +0 -86
- package/src/label/services/index.js +0 -1201
- package/src/label/services/sortFunctions.js +0 -158
- package/src/label/services/utils.js +0 -280
- package/src/labelWorker.js +0 -123
- package/src/reducer.js +0 -40
- package/src/store.js +0 -55
- package/src/templates.js +0 -139
- package/src/useLabelData.js +0 -99
- package/src/usePrinterStore.js +0 -115
- package/src/variableManager.js +0 -224
package/README.git.md
DELETED
|
@@ -1,486 +0,0 @@
|
|
|
1
|
-
# 🏷️ Sistema de Etiquetas - Etiquetas.js
|
|
2
|
-
|
|
3
|
-
Sistema completo para geração de etiquetas de peças, tamponamentos, insumos, retalhos e volumes com suporte a impressão e download de PDFs.
|
|
4
|
-
|
|
5
|
-
## 📋 Índice
|
|
6
|
-
|
|
7
|
-
- [Instalação](#instalação)
|
|
8
|
-
- [Configuração Inicial](#configuração-inicial)
|
|
9
|
-
- [API Principal](#api-principal)
|
|
10
|
-
- [Tipos de Etiquetas](#tipos-de-etiquetas)
|
|
11
|
-
- [Exemplos de Uso](#exemplos-de-uso)
|
|
12
|
-
- [Templates](#templates)
|
|
13
|
-
- [Testes](#testes)
|
|
14
|
-
- [Estrutura do Projeto](#estrutura-do-projeto)
|
|
15
|
-
- [Sistema Legacy](#sistema-legacy)
|
|
16
|
-
|
|
17
|
-
## 🚀 Instalação
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install etiquetas-js
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## ⚙️ Configuração Inicial
|
|
24
|
-
|
|
25
|
-
```javascript
|
|
26
|
-
import etiquetas from 'etiquetas-js';
|
|
27
|
-
|
|
28
|
-
// Inicializar o sistema
|
|
29
|
-
etiquetas.init({
|
|
30
|
-
printerName: 'Zebra ZT230',
|
|
31
|
-
paperSize: 'A4',
|
|
32
|
-
orientation: 'portrait',
|
|
33
|
-
defaultTemplate: 'template-padrao'
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## 📚 API Principal
|
|
38
|
-
|
|
39
|
-
### Inicialização e Configuração
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
// Inicializar sistema
|
|
43
|
-
etiquetas.init(config);
|
|
44
|
-
|
|
45
|
-
// Configurar impressora
|
|
46
|
-
etiquetas.configurePrinter({
|
|
47
|
-
printerName: 'HP LaserJet Pro',
|
|
48
|
-
paperSize: 'A4',
|
|
49
|
-
orientation: 'landscape'
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Verificar status da impressora
|
|
53
|
-
const status = await etiquetas.getPrinterStatus();
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Geração de Etiquetas
|
|
57
|
-
|
|
58
|
-
```javascript
|
|
59
|
-
// Gerar etiqueta de peça
|
|
60
|
-
const pdfPeca = await etiquetas.makePartLabel(dadosPeca, 'template-peca-padrao');
|
|
61
|
-
|
|
62
|
-
// Gerar etiqueta de tamponamento
|
|
63
|
-
const pdfTamp = await etiquetas.makeTamponamentoLabel(dadosTamp, 'template-tamponamento-padrao');
|
|
64
|
-
|
|
65
|
-
// Gerar etiqueta de insumo
|
|
66
|
-
const pdfInsumo = await etiquetas.makeInsumoLabel(dadosInsumo, 'template-insumo-padrao');
|
|
67
|
-
|
|
68
|
-
// Gerar etiqueta de retalho
|
|
69
|
-
const pdfRetalho = await etiquetas.makeRetalhoLabel(dadosRetalho, 'template-retalho-padrao');
|
|
70
|
-
|
|
71
|
-
// Gerar etiqueta de volume
|
|
72
|
-
const pdfVolume = await etiquetas.makeVolumeLabel(dadosVolume, 'template-volume-padrao');
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Saída e Impressão
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
// Download de PDF
|
|
79
|
-
await etiquetas.downloadPDF(pdfBuffer, 'etiqueta.pdf');
|
|
80
|
-
|
|
81
|
-
// Enviar para impressora
|
|
82
|
-
await etiquetas.sendToPrinter(pdfBuffer);
|
|
83
|
-
|
|
84
|
-
// Envio inteligente (imprime se conectado, senão faz download)
|
|
85
|
-
await etiquetas.sendPartLabel(dadosPeca, 'template-peca-padrao');
|
|
86
|
-
await etiquetas.sendTamponamentoLabel(dadosTamp, 'template-tamponamento-padrao');
|
|
87
|
-
await etiquetas.sendInsumoLabel(dadosInsumo, 'template-insumo-padrao');
|
|
88
|
-
await etiquetas.sendRetalhoLabel(dadosRetalho, 'template-retalho-padrao');
|
|
89
|
-
await etiquetas.sendVolumeLabel(dadosVolume, 'template-volume-padrao');
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Geração em Lote
|
|
93
|
-
|
|
94
|
-
```javascript
|
|
95
|
-
// Gerar múltiplas etiquetas
|
|
96
|
-
const pdfs = await etiquetas.makeBatchLabels(
|
|
97
|
-
[peca1, peca2, peca3],
|
|
98
|
-
'template-peca-padrao',
|
|
99
|
-
'parts'
|
|
100
|
-
);
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## 🏷️ Tipos de Etiquetas
|
|
104
|
-
|
|
105
|
-
### 1. Etiquetas de Peças (`parts`)
|
|
106
|
-
|
|
107
|
-
```javascript
|
|
108
|
-
const dadosPeca = {
|
|
109
|
-
id: "P001",
|
|
110
|
-
codigo: "PID123",
|
|
111
|
-
nome: "Lateral Esquerda",
|
|
112
|
-
tipo: "cabinet",
|
|
113
|
-
largura: 600,
|
|
114
|
-
altura: 800,
|
|
115
|
-
espessura: 15,
|
|
116
|
-
material: {
|
|
117
|
-
nome: "MDF Branco",
|
|
118
|
-
altura: 2750,
|
|
119
|
-
largura: 1830
|
|
120
|
-
},
|
|
121
|
-
bordas: {
|
|
122
|
-
esquerda: "Branco 0.4",
|
|
123
|
-
direita: "Branco 0.4",
|
|
124
|
-
superior: "Branco 0.4",
|
|
125
|
-
inferior: "Sem borda"
|
|
126
|
-
},
|
|
127
|
-
furacao: {
|
|
128
|
-
codigoA: "A001",
|
|
129
|
-
codigoB: "B002",
|
|
130
|
-
ladoUsinagem: "face"
|
|
131
|
-
},
|
|
132
|
-
projeto: {
|
|
133
|
-
id: "PROJ001",
|
|
134
|
-
nome: "Cozinha Moderna",
|
|
135
|
-
cliente: "João Silva"
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### 2. Etiquetas de Tamponamentos (`woodwork`)
|
|
141
|
-
|
|
142
|
-
```javascript
|
|
143
|
-
const dadosTamponamento = {
|
|
144
|
-
id: "TAMP-001",
|
|
145
|
-
name: "Tamponamento Lateral",
|
|
146
|
-
ref: "T001",
|
|
147
|
-
qt: 2,
|
|
148
|
-
weight: 1.5,
|
|
149
|
-
material: "MDF 15mm",
|
|
150
|
-
project_id: "PROJ001",
|
|
151
|
-
project_description: "Cozinha Moderna",
|
|
152
|
-
project_customer_name: "João Silva"
|
|
153
|
-
};
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### 3. Etiquetas de Insumos (`inputs`)
|
|
157
|
-
|
|
158
|
-
```javascript
|
|
159
|
-
const dadosInsumo = {
|
|
160
|
-
id: "INS-001",
|
|
161
|
-
name: "Parafuso Phillips 4x30",
|
|
162
|
-
dimensions: "4x30mm",
|
|
163
|
-
qt: 50,
|
|
164
|
-
weight: 0.1,
|
|
165
|
-
ref: "PAR-001",
|
|
166
|
-
manufacturer: "Fixadores SA",
|
|
167
|
-
project_id: "PROJ001",
|
|
168
|
-
project_description: "Cozinha Moderna",
|
|
169
|
-
project_customer_name: "João Silva"
|
|
170
|
-
};
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### 4. Etiquetas de Retalhos (`scraps`)
|
|
174
|
-
|
|
175
|
-
```javascript
|
|
176
|
-
const dadosRetalho = {
|
|
177
|
-
scrapId: "RET-001",
|
|
178
|
-
id: "RET-001",
|
|
179
|
-
name: "Retalho MDF Branco",
|
|
180
|
-
ref: "R001",
|
|
181
|
-
qt: 1,
|
|
182
|
-
weight: 2.3,
|
|
183
|
-
date: "2024-01-15T10:30:00Z",
|
|
184
|
-
material: "MDF Branco 15mm",
|
|
185
|
-
project_id: "PROJ001",
|
|
186
|
-
project_description: "Cozinha Moderna",
|
|
187
|
-
project_customer_name: "João Silva"
|
|
188
|
-
};
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### 5. Etiquetas de Volumes (`volumes`)
|
|
192
|
-
|
|
193
|
-
```javascript
|
|
194
|
-
const dadosVolume = {
|
|
195
|
-
volume_id: "VOL-001",
|
|
196
|
-
volume_name: "Volume Cozinha - Módulo 1",
|
|
197
|
-
volume_weight: 45.8,
|
|
198
|
-
volume_date: "2024-01-15T10:30:00Z",
|
|
199
|
-
project_id: "PROJ001",
|
|
200
|
-
project_description: "Cozinha Moderna",
|
|
201
|
-
project_customer_name: "João Silva"
|
|
202
|
-
};
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## 🎨 Templates
|
|
206
|
-
|
|
207
|
-
### Templates Disponíveis
|
|
208
|
-
|
|
209
|
-
- **Peças**: `template-peca-padrao`, `template-peca-compacto`
|
|
210
|
-
- **Tamponamentos**: `template-tamponamento-padrao`
|
|
211
|
-
- **Insumos**: `template-insumo-padrao`
|
|
212
|
-
- **Retalhos**: `template-retalho-padrao`
|
|
213
|
-
- **Volumes**: `template-volume-padrao`
|
|
214
|
-
|
|
215
|
-
### Variáveis de Template
|
|
216
|
-
|
|
217
|
-
O sistema suporta 44+ variáveis organizadas por categoria:
|
|
218
|
-
|
|
219
|
-
#### Projeto (5 variáveis)
|
|
220
|
-
- `{{PROJETO_ID}}`, `{{PROJETO_NOME}}`, `{{PROJETO_OBS}}`
|
|
221
|
-
- `{{CLIENTE_ID}}`, `{{CLIENTE_NOME}}`
|
|
222
|
-
|
|
223
|
-
#### Peça (7 variáveis)
|
|
224
|
-
- `{{PECA_ID}}`, `{{PECA_CODIGO}}`, `{{PECA_NOME}}`, `{{PECA_TIPO}}`
|
|
225
|
-
- `{{LARGURA}}`, `{{ALTURA}}`, `{{ESPESSURA}}`
|
|
226
|
-
|
|
227
|
-
#### Material (3 variáveis)
|
|
228
|
-
- `{{MN}}` (Nome), `{{MA}}` (Altura), `{{ML}}` (Largura)
|
|
229
|
-
|
|
230
|
-
#### Bordas (4 variáveis)
|
|
231
|
-
- `{{FE}}` (Esquerda), `{{FD}}` (Direita), `{{FS}}` (Superior), `{{FI}}` (Inferior)
|
|
232
|
-
|
|
233
|
-
#### Furação (3 variáveis)
|
|
234
|
-
- `{{FURO_A}}`, `{{FURO_B}}`, `{{LADO_USINAGEM}}`
|
|
235
|
-
|
|
236
|
-
#### Volume (4 variáveis)
|
|
237
|
-
- `{{VOLUME_ID}}`, `{{VOLUME_NOME}}`, `{{VOLUME_PESO}}`, `{{VOLUME_DATA}}`
|
|
238
|
-
|
|
239
|
-
#### Insumo (7 variáveis)
|
|
240
|
-
- `{{INSUMO_NOME}}`, `{{INSUMO_ID}}`, `{{INSUMO_DIMENSOES}}`
|
|
241
|
-
- `{{INSUMO_QTD}}`, `{{INSUMO_PESO}}`, `{{INSUMO_REF}}`, `{{INSUMO_MARCA}}`
|
|
242
|
-
|
|
243
|
-
#### Tamponamento (5 variáveis)
|
|
244
|
-
- `{{TAMPONAMENTO_ID}}`, `{{TAMPONAMENTO_REF}}`, `{{TAMPONAMENTO_QT}}`
|
|
245
|
-
- `{{TAMPONAMENTO_PESO}}`, `{{TAMPONAMENTO_NOME}}`
|
|
246
|
-
|
|
247
|
-
#### Retalho (3 variáveis)
|
|
248
|
-
- `{{RETALHO_ID}}`, `{{DATA_CRIACAO}}`, `{{RETALHO_INDICE}}`
|
|
249
|
-
|
|
250
|
-
## 🧪 Testes
|
|
251
|
-
|
|
252
|
-
Execute os testes do sistema:
|
|
253
|
-
|
|
254
|
-
```bash
|
|
255
|
-
# Executar testes completos
|
|
256
|
-
node mock/testes.js
|
|
257
|
-
|
|
258
|
-
# Teste rápido - apenas geração de todos os tipos
|
|
259
|
-
node mock/executar-teste-completo.js
|
|
260
|
-
|
|
261
|
-
# Teste específico de todos os tipos
|
|
262
|
-
node mock/teste-todos-tipos.js
|
|
263
|
-
|
|
264
|
-
# Teste otimizado (recomendado para evitar problemas de memória)
|
|
265
|
-
node mock/executar-teste-otimizado.js
|
|
266
|
-
|
|
267
|
-
# Ou importar funções específicas
|
|
268
|
-
import { executarTodosTestes, gerarEtiquetasDeTodosOsTipos } from './mock/testes.js';
|
|
269
|
-
import { gerarEtiquetasOtimizado } from './mock/teste-todos-tipos-otimizado.js';
|
|
270
|
-
|
|
271
|
-
await executarTodosTestes();
|
|
272
|
-
await gerarEtiquetasDeTodosOsTipos();
|
|
273
|
-
await gerarEtiquetasOtimizado(); // Versão otimizada
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### Testes Incluídos
|
|
277
|
-
|
|
278
|
-
- ✅ Status da Impressora
|
|
279
|
-
- ✅ Configuração de Impressora
|
|
280
|
-
- ✅ Geração de Etiquetas (todos os 5 tipos)
|
|
281
|
-
- ✅ Download de PDF
|
|
282
|
-
- ✅ Envio Inteligente
|
|
283
|
-
- ✅ Geração em Lote
|
|
284
|
-
- 🆕 **Teste Completo - Todos os Tipos** (novo!)
|
|
285
|
-
|
|
286
|
-
### Novo Teste: Todos os Tipos de Etiquetas
|
|
287
|
-
|
|
288
|
-
O novo teste `gerarEtiquetasDeTodosOsTipos()` gera uma etiqueta de cada tipo disponível:
|
|
289
|
-
|
|
290
|
-
```javascript
|
|
291
|
-
import { gerarEtiquetasDeTodosOsTipos } from './mock/teste-todos-tipos.js';
|
|
292
|
-
|
|
293
|
-
const resultados = await gerarEtiquetasDeTodosOsTipos();
|
|
294
|
-
console.log(`Sucessos: ${resultados.sucessos}/5`);
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### 🚀 Teste Otimizado (Recomendado)
|
|
298
|
-
|
|
299
|
-
Para evitar problemas de memória e heap overflow, use a versão otimizada:
|
|
300
|
-
|
|
301
|
-
```bash
|
|
302
|
-
# Execução rápida
|
|
303
|
-
node mock/executar-teste-otimizado.js
|
|
304
|
-
|
|
305
|
-
# Com mais memória (se necessário)
|
|
306
|
-
node --max-old-space-size=4096 mock/executar-teste-otimizado.js
|
|
307
|
-
|
|
308
|
-
# Com garbage collection
|
|
309
|
-
node --expose-gc mock/executar-teste-otimizado.js
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
**Melhorias da versão otimizada:**
|
|
313
|
-
- ⚡ Timeouts para evitar travamentos
|
|
314
|
-
- 🧹 Limpeza automática de memória
|
|
315
|
-
- 🔄 Processamento sequencial com pausas
|
|
316
|
-
- 📊 Dados simplificados para melhor performance
|
|
317
|
-
- ❌ Tratamento robusto de erros
|
|
318
|
-
|
|
319
|
-
**Tipos testados:**
|
|
320
|
-
- 📋 Etiqueta de Peça
|
|
321
|
-
- 🔧 Etiqueta de Tamponamento
|
|
322
|
-
- 🔩 Etiqueta de Insumo
|
|
323
|
-
- ♻️ Etiqueta de Retalho
|
|
324
|
-
- 📦 Etiqueta de Volume
|
|
325
|
-
|
|
326
|
-
**Recursos do teste:**
|
|
327
|
-
- ⏱️ Medição de tempo de geração
|
|
328
|
-
- 📊 Relatório detalhado de resultados
|
|
329
|
-
- 💾 Salvamento automático dos PDFs em `mock/output/`
|
|
330
|
-
- 📈 Estatísticas de performance
|
|
331
|
-
|
|
332
|
-
## 📁 Estrutura do Projeto
|
|
333
|
-
|
|
334
|
-
```
|
|
335
|
-
etiquetas.js/
|
|
336
|
-
├── src/
|
|
337
|
-
│ ├── etiquetas.js # API principal reorganizada
|
|
338
|
-
│ ├── index.js # Exportações principais
|
|
339
|
-
│ ├── constants.js # Constantes e configurações
|
|
340
|
-
│ ├── templates.js # Templates de etiquetas
|
|
341
|
-
│ ├── types.ts # Definições TypeScript
|
|
342
|
-
│ ├── formatData.js # Formatação de dados
|
|
343
|
-
│ ├── labelWorker.js # Worker para geração
|
|
344
|
-
│ └── createLabel.jsx # Geração de PDFs
|
|
345
|
-
├── mock/
|
|
346
|
-
│ ├── testes.js # Testes completos
|
|
347
|
-
│ └── exemplo de dados... # Dados de exemplo
|
|
348
|
-
└── GITHUB_ISSUE.md # Documentação técnica
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
## 🔧 Configurações Avançadas
|
|
352
|
-
|
|
353
|
-
### Configuração Personalizada
|
|
354
|
-
|
|
355
|
-
```javascript
|
|
356
|
-
etiquetas.init({
|
|
357
|
-
printerName: 'Zebra ZT230',
|
|
358
|
-
paperSize: 'A4',
|
|
359
|
-
orientation: 'portrait',
|
|
360
|
-
defaultTemplate: 'template-personalizado',
|
|
361
|
-
autoDownloadOnPrinterError: true,
|
|
362
|
-
maxBatchSize: 100,
|
|
363
|
-
cacheEnabled: true,
|
|
364
|
-
debugMode: false
|
|
365
|
-
});
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
### Tratamento de Erros
|
|
369
|
-
|
|
370
|
-
```javascript
|
|
371
|
-
try {
|
|
372
|
-
const pdf = await etiquetas.makePartLabel(dados, template);
|
|
373
|
-
await etiquetas.sendToPrinter(pdf);
|
|
374
|
-
} catch (error) {
|
|
375
|
-
console.error('Erro:', error.message);
|
|
376
|
-
// Fallback para download
|
|
377
|
-
await etiquetas.downloadPDF(pdf, 'etiqueta-backup.pdf');
|
|
378
|
-
}
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
## 📊 Status e Monitoramento
|
|
382
|
-
|
|
383
|
-
```javascript
|
|
384
|
-
// Verificar status completo
|
|
385
|
-
const status = await etiquetas.getPrinterStatus();
|
|
386
|
-
console.log('Impressora:', status.connected ? 'Conectada' : 'Desconectada');
|
|
387
|
-
console.log('Nome:', status.printerName);
|
|
388
|
-
console.log('Papel:', status.paperSize);
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
---
|
|
392
|
-
|
|
393
|
-
## 🔄 Sistema Legacy
|
|
394
|
-
|
|
395
|
-
### Label Viewer Without UI (Sistema Anterior)
|
|
396
|
-
|
|
397
|
-
Este projeto evoluiu de um fork do `labelViewer` que removia componentes de UI. O sistema legacy ainda está disponível para compatibilidade:
|
|
398
|
-
|
|
399
|
-
#### Exemplo básico com hook e worker (Legacy)
|
|
400
|
-
|
|
401
|
-
```javascript
|
|
402
|
-
import { useLabelData, createLabelWorker } from './src';
|
|
403
|
-
|
|
404
|
-
function MyComponent() {
|
|
405
|
-
const { getLabelData, config, userPrefs } = useLabelData();
|
|
406
|
-
|
|
407
|
-
const generateLabels = async () => {
|
|
408
|
-
const labelData = getLabelData('parts');
|
|
409
|
-
const worker = createLabelWorker();
|
|
410
|
-
|
|
411
|
-
const params = {
|
|
412
|
-
dataSource: labelData.data,
|
|
413
|
-
labels: labelData.label,
|
|
414
|
-
userPrefs: labelData.userPrefs,
|
|
415
|
-
cacheKey: labelData.cacheKey,
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
try {
|
|
419
|
-
const result = await worker.generateLabels(params, (progress) => {
|
|
420
|
-
console.log(`Progresso: ${progress.percentage}%`);
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
console.log('Labels gerados:', result);
|
|
424
|
-
} catch (error) {
|
|
425
|
-
console.error('Erro ao gerar labels:', error);
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
return (
|
|
430
|
-
<button onClick={generateLabels}>
|
|
431
|
-
Gerar Labels
|
|
432
|
-
</button>
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
#### Usando o store (Legacy)
|
|
438
|
-
|
|
439
|
-
```javascript
|
|
440
|
-
import { useLabelStore } from './src';
|
|
441
|
-
|
|
442
|
-
function MyComponent() {
|
|
443
|
-
const {
|
|
444
|
-
pdfInstance,
|
|
445
|
-
isGenerating,
|
|
446
|
-
progress,
|
|
447
|
-
setPDFInstance,
|
|
448
|
-
setGenerating
|
|
449
|
-
} = useLabelStore();
|
|
450
|
-
|
|
451
|
-
// Use o store para gerenciar estado...
|
|
452
|
-
}
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
### Migração do Sistema Legacy
|
|
456
|
-
|
|
457
|
-
Para migrar do sistema legacy para a nova API:
|
|
458
|
-
|
|
459
|
-
```javascript
|
|
460
|
-
// Antes (Legacy)
|
|
461
|
-
import { useLabelData, createLabelWorker } from './src';
|
|
462
|
-
const labelData = getLabelData('parts');
|
|
463
|
-
const worker = createLabelWorker();
|
|
464
|
-
const result = await worker.generateLabels(params);
|
|
465
|
-
|
|
466
|
-
// Depois (Nova API)
|
|
467
|
-
import etiquetas from './src/etiquetas.js';
|
|
468
|
-
etiquetas.init(config);
|
|
469
|
-
const pdf = await etiquetas.makePartLabel(dadosPeca, template);
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
## 🤝 Contribuição
|
|
473
|
-
|
|
474
|
-
1. Fork o projeto
|
|
475
|
-
2. Crie uma branch para sua feature (`git checkout -b feature/nova-feature`)
|
|
476
|
-
3. Commit suas mudanças (`git commit -am 'Adiciona nova feature'`)
|
|
477
|
-
4. Push para a branch (`git push origin feature/nova-feature`)
|
|
478
|
-
5. Abra um Pull Request
|
|
479
|
-
|
|
480
|
-
## 📄 Licença
|
|
481
|
-
|
|
482
|
-
Este projeto está sob a licença MIT. Veja o arquivo [LICENSE](LICENSE) para mais detalhes.
|
|
483
|
-
|
|
484
|
-
---
|
|
485
|
-
|
|
486
|
-
**Desenvolvido com ❤️ para facilitar a geração de etiquetas industriais**
|
package/api/api-labels.json
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"namespace":"v1",
|
|
3
|
-
"routes":{
|
|
4
|
-
"\/v1\/labels":{
|
|
5
|
-
"namespace":"v1",
|
|
6
|
-
"methods":[
|
|
7
|
-
"GET"
|
|
8
|
-
],
|
|
9
|
-
"endpoints":[
|
|
10
|
-
{
|
|
11
|
-
"methods":[
|
|
12
|
-
"GET"
|
|
13
|
-
],
|
|
14
|
-
"args":{
|
|
15
|
-
"p":{
|
|
16
|
-
"description":"Page",
|
|
17
|
-
"type":"integer",
|
|
18
|
-
"required":false
|
|
19
|
-
},
|
|
20
|
-
"s":{
|
|
21
|
-
"description":"Search",
|
|
22
|
-
"type":"string",
|
|
23
|
-
"required":false
|
|
24
|
-
},
|
|
25
|
-
"label_id":{
|
|
26
|
-
"description":"ID",
|
|
27
|
-
"type":"integer",
|
|
28
|
-
"required":false
|
|
29
|
-
},
|
|
30
|
-
"label_type":{
|
|
31
|
-
"description":"Tipo",
|
|
32
|
-
"type":"string",
|
|
33
|
-
"enum":[
|
|
34
|
-
"part",
|
|
35
|
-
"scrap",
|
|
36
|
-
"thickened",
|
|
37
|
-
"input",
|
|
38
|
-
"volume"
|
|
39
|
-
],
|
|
40
|
-
"required":false
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
"_links":{
|
|
46
|
-
"self":[
|
|
47
|
-
{
|
|
48
|
-
"href":"https:\/\/www.dinabox.app\/api\/v1\/labels"
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"\/v1\/label":{
|
|
54
|
-
"namespace":"v1",
|
|
55
|
-
"methods":[
|
|
56
|
-
"GET",
|
|
57
|
-
"POST",
|
|
58
|
-
"DELETE"
|
|
59
|
-
],
|
|
60
|
-
"endpoints":[
|
|
61
|
-
{
|
|
62
|
-
"methods":[
|
|
63
|
-
"GET",
|
|
64
|
-
"POST",
|
|
65
|
-
"DELETE"
|
|
66
|
-
],
|
|
67
|
-
"args":{
|
|
68
|
-
"label_id":{
|
|
69
|
-
"description":"ID",
|
|
70
|
-
"type":"integer",
|
|
71
|
-
"required":false
|
|
72
|
-
},
|
|
73
|
-
"label_type":{
|
|
74
|
-
"description":"Tipo",
|
|
75
|
-
"type":"string",
|
|
76
|
-
"enum":[
|
|
77
|
-
"part",
|
|
78
|
-
"scrap",
|
|
79
|
-
"thickened",
|
|
80
|
-
"input",
|
|
81
|
-
"volume"
|
|
82
|
-
],
|
|
83
|
-
"required":false
|
|
84
|
-
},
|
|
85
|
-
"label_name":{
|
|
86
|
-
"description":"Nome",
|
|
87
|
-
"type":"string",
|
|
88
|
-
"required":false
|
|
89
|
-
},
|
|
90
|
-
"label_content":{
|
|
91
|
-
"description":"Conte\u00fado",
|
|
92
|
-
"type":"textarea",
|
|
93
|
-
"required":false
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
"_links":{
|
|
99
|
-
"self":[
|
|
100
|
-
{
|
|
101
|
-
"href":"https:\/\/www.dinabox.app\/api\/v1\/label"
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"_links":{
|
|
108
|
-
"up":[
|
|
109
|
-
{
|
|
110
|
-
"href":"https:\/\/www.dinabox.app\/api\/"
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
}
|