@react-lgpd-consent/core 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +141 -2
- package/README.md +46 -0
- package/dist/index.cjs +233 -60
- package/dist/index.d.cts +118 -5
- package/dist/index.d.ts +118 -5
- package/dist/index.js +231 -61
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,130 @@
|
|
|
1
1
|
# Changelog - @react-lgpd-consent/core
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#124](https://github.com/lucianoedipo/react-lgpd-consent/pull/124) [`7669c4f`](https://github.com/lucianoedipo/react-lgpd-consent/commit/7669c4fba84b5cfea8f7da8ab65468110d3e77f7) Thanks [@lucianoedipo](https://github.com/lucianoedipo)! - # v0.7.0 - Código Limpo, Testes Aprimorados e Qualidade de Código
|
|
8
|
+
|
|
9
|
+
Esta release é parte do trabalho nas issues: [#60](https://github.com/lucianoedipo/react-lgpd-consent/issues/60), [#63](https://github.com/lucianoedipo/react-lgpd-consent/issues/63), [#64](https://github.com/lucianoedipo/react-lgpd-consent/issues/64), [#65](https://github.com/lucianoedipo/react-lgpd-consent/issues/65), [#68](https://github.com/lucianoedipo/react-lgpd-consent/issues/68), [#70](https://github.com/lucianoedipo/react-lgpd-consent/issues/70), [#71](https://github.com/lucianoedipo/react-lgpd-consent/issues/71), [#72](https://github.com/lucianoedipo/react-lgpd-consent/issues/72)
|
|
10
|
+
|
|
11
|
+
## 🧹 Correções de Lint e Code Quality
|
|
12
|
+
|
|
13
|
+
### Migração para APIs Modernas
|
|
14
|
+
- **globalThis**: Convertidos ~50+ usos de `window` e `global` para `globalThis.window` e `globalThis` (compatibilidade SSR/universal)
|
|
15
|
+
- **String.replaceAll()**: Migrado de `replace()` com regex global para `replaceAll()` (ES2021)
|
|
16
|
+
- **Object.hasOwn()**: Migrado de `Object.prototype.hasOwnProperty.call()` para `Object.hasOwn()` (ES2022)
|
|
17
|
+
- **Number.parseInt()**: Padronizado uso de `Number.parseInt()` em vez de `parseInt()` global
|
|
18
|
+
|
|
19
|
+
### TypeScript Configuration
|
|
20
|
+
- Adicionado `ES2021.String` ao lib do tsconfig para suportar `String.replaceAll()`
|
|
21
|
+
- Adicionado `ES2022.Object` ao lib do tsconfig para suportar `Object.hasOwn()`
|
|
22
|
+
- Mantida compatibilidade com target `ES2020`
|
|
23
|
+
|
|
24
|
+
> **ℹ️ Atenção à Compatibilidade com Browsers**
|
|
25
|
+
>
|
|
26
|
+
> Esta versão faz uso de recursos ES2021/ES2022 (`String.replaceAll()`, `Object.hasOwn()`, etc.), que não estão disponíveis em todos os navegadores (especialmente versões antigas do Safari, Edge ou Firefox). Se você utiliza este pacote em aplicações web que precisam suportar navegadores legados, é recomendado configurar um transpiler (como Babel) e/ou polyfills apropriados para garantir compatibilidade.
|
|
27
|
+
|
|
28
|
+
### Melhorias de Código
|
|
29
|
+
- **cookieDiscovery.ts**: Função `matchPattern` movida para outer scope (evita recriação)
|
|
30
|
+
- **validation.ts**: Adicionado warning quando prop `categories` não é fornecida
|
|
31
|
+
- **Condições**: Invertidas condições negadas para melhor legibilidade
|
|
32
|
+
- **Type Safety**: Correções de type assertions em testes
|
|
33
|
+
|
|
34
|
+
## 🧪 Aumento Significativo de Cobertura de Testes
|
|
35
|
+
|
|
36
|
+
### Cobertura Geral: 94.82% → 95.46% (+0.64%)
|
|
37
|
+
|
|
38
|
+
| Arquivo | Antes | Depois | Melhoria |
|
|
39
|
+
| ---------------------- | ------ | ----------- | -------- |
|
|
40
|
+
| **theme.ts** | 83.33% | **100%** ✅ | +16.67% |
|
|
41
|
+
| **cookieDiscovery.ts** | 88.13% | **96.61%** | +8.48% |
|
|
42
|
+
| **peerDepsCheck.ts** | 74.19% | **80.64%** | +6.45% |
|
|
43
|
+
| **validation.ts** | 96.87% | **98.24%** | +1.37% |
|
|
44
|
+
|
|
45
|
+
### Novos Testes Adicionados (+33 testes: 318 → 351)
|
|
46
|
+
|
|
47
|
+
#### peerDepsCheck.ts
|
|
48
|
+
- Testes para detecção de múltiplas instâncias React via DevTools hook
|
|
49
|
+
- Testes para verificação de versões React no limite inferior/superior do range
|
|
50
|
+
- Testes para logging de erros e warnings quando `logWarnings=true`
|
|
51
|
+
- Cobertura de edge cases de versão semver complexa
|
|
52
|
+
|
|
53
|
+
#### dataLayerEvents.ts
|
|
54
|
+
- Testes para `ensureDataLayer` criar dataLayer quando undefined
|
|
55
|
+
- Testes para preservação de eventos existentes no dataLayer
|
|
56
|
+
- Testes para origins programmatic/reset
|
|
57
|
+
- Testes para previousCategories vazias/undefined
|
|
58
|
+
- Testes de SSR safety (window parcialmente definido)
|
|
59
|
+
- Testes para falha silenciosa de dataLayer.push
|
|
60
|
+
|
|
61
|
+
#### cookieDiscovery.ts
|
|
62
|
+
- Testes para uso de cookies descobertos globalmente (`__LGPD_DISCOVERED_COOKIES__`)
|
|
63
|
+
- Testes para `registerOverrides=true` chamando `setCookieCatalogOverrides`
|
|
64
|
+
- Testes para cookies sem nome ou duplicados
|
|
65
|
+
- Testes para match de padrões wildcard
|
|
66
|
+
|
|
67
|
+
#### cookieUtils.ts
|
|
68
|
+
- Testes para JSON malformado e objetos vazios
|
|
69
|
+
- Testes para `buildConsentStorageKey` com caracteres especiais
|
|
70
|
+
- Testes para `createConsentAuditEntry` com estado mínimo
|
|
71
|
+
- Testes para uso de nomes customizados em `removeConsentCookie`
|
|
72
|
+
|
|
73
|
+
#### theme.ts (100% coverage)
|
|
74
|
+
- Testes completos para palette, typography e component overrides
|
|
75
|
+
- Testes para button contained hover shadows
|
|
76
|
+
- Testes para Paper e Dialog border radius
|
|
77
|
+
- Testes para função deprecada `defaultConsentTheme()`
|
|
78
|
+
- Verificação de novas instâncias a cada chamada
|
|
79
|
+
|
|
80
|
+
## 📚 Documentação
|
|
81
|
+
|
|
82
|
+
### DEVELOPMENT.md
|
|
83
|
+
- Adicionada seção **"Cobertura de Testes"** com tabela de métricas por módulo
|
|
84
|
+
- Comando para rodar testes com cobertura: `pnpm test:coverage`
|
|
85
|
+
- Tabela detalhada mostrando Statements/Branches/Functions/Lines por pacote
|
|
86
|
+
|
|
87
|
+
### TypeDoc
|
|
88
|
+
- Documentação regenerada com todas as APIs atualizadas
|
|
89
|
+
- 15 warnings aceitáveis sobre links relativos para pacotes do monorepo
|
|
90
|
+
|
|
91
|
+
## ✅ Validação
|
|
92
|
+
- ✅ **type-check**: Todos os tipos válidos (ES2021/ES2022 APIs suportadas)
|
|
93
|
+
- ✅ **lint**: Código limpo sem erros
|
|
94
|
+
- ✅ **test**: 351/351 testes passando (100%)
|
|
95
|
+
- ✅ **build**: Build limpo de todos os pacotes
|
|
96
|
+
- ✅ **docs**: TypeDoc gerado com sucesso
|
|
97
|
+
|
|
98
|
+
## 🔧 Arquivos Modificados
|
|
99
|
+
|
|
100
|
+
### Core Package
|
|
101
|
+
- `src/utils/scriptIntegrations.ts`: globalThis, Date.now()
|
|
102
|
+
- `src/utils/peerDepsCheck.ts`: globalThis, Number.parseInt()
|
|
103
|
+
- `src/utils/dataLayerEvents.ts`: globalThis, ??= operator
|
|
104
|
+
- `src/utils/cookieUtils.ts`: replaceAll(), globalThis, condição invertida
|
|
105
|
+
- `src/utils/cookieDiscovery.ts`: matchPattern outer scope
|
|
106
|
+
- `src/utils/validation.ts`: warning categories undefined
|
|
107
|
+
- `src/context/ConsentContext.tsx`: Object.hasOwn(), state deps
|
|
108
|
+
- `src/context/__tests__/CategoriesContext.test.tsx`: globalThis
|
|
109
|
+
- `__tests__/*`: +25 novos testes
|
|
110
|
+
|
|
111
|
+
### MUI Package
|
|
112
|
+
- `src/utils/theme.ts`: 100% coverage
|
|
113
|
+
- `src/utils/__tests__/theme.test.ts`: +8 novos testes
|
|
114
|
+
|
|
115
|
+
### Configuration
|
|
116
|
+
- `tsconfig.base.json`: ES2021.String, ES2022.Object no lib
|
|
117
|
+
|
|
118
|
+
### Documentation
|
|
119
|
+
- `DEVELOPMENT.md`: seção de cobertura de testes
|
|
120
|
+
|
|
121
|
+
***
|
|
122
|
+
|
|
123
|
+
**Breaking Changes:** Nenhuma
|
|
124
|
+
**Migration Required:** Não
|
|
125
|
+
|
|
126
|
+
Esta release foca em qualidade de código, testes robustos e aderência a padrões modernos do JavaScript/TypeScript.
|
|
127
|
+
|
|
3
128
|
## 0.6.3
|
|
4
129
|
|
|
5
130
|
### Patch Changes
|
|
@@ -42,5 +167,19 @@
|
|
|
42
167
|
- 🚀 Configuração de Turborepo para builds otimizados
|
|
43
168
|
- 📦 Configuração de Changesets para versionamento automatizado
|
|
44
169
|
|
|
45
|
-
|
|
46
|
-
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Versões Anteriores (< 0.6.0)
|
|
173
|
+
|
|
174
|
+
Para histórico completo de versões 0.5.x e anteriores, consulte:
|
|
175
|
+
|
|
176
|
+
- [CHANGELOG.md do pacote principal](../react-lgpd-consent/CHANGELOG.md)
|
|
177
|
+
- [Releases no GitHub](https://github.com/lucianoedipo/react-lgpd-consent/releases)
|
|
178
|
+
|
|
179
|
+
**Resumo de marcos importantes:**
|
|
180
|
+
|
|
181
|
+
- **v0.5.0** (25/10/2025): Arquitetura modular - criação dos pacotes `@react-lgpd-consent/core` e `@react-lgpd-consent/mui`
|
|
182
|
+
- **v0.4.5** (25/10/2025): DataLayer events para Google Tag Manager
|
|
183
|
+
- **v0.4.1** (21/09/2025): Expansão de integrações nativas (Hotjar, Mixpanel, Clarity, Intercom, Zendesk)
|
|
184
|
+
- **v0.3.0-v0.4.0**: Sistema de design tokens, categorias customizadas, testes de acessibilidade
|
|
185
|
+
- **v0.1.0-v0.2.x**: Implementação inicial com ConsentProvider, CookieBanner, PreferencesModal
|
package/README.md
CHANGED
|
@@ -62,6 +62,52 @@ function MyCustomBanner() {
|
|
|
62
62
|
- **Integrações:** Google Analytics, GTM, UserWay, Facebook Pixel, Hotjar, etc.
|
|
63
63
|
- **Tipos TypeScript:** Tipagem completa para toda a API
|
|
64
64
|
|
|
65
|
+
## 🆕 Novidades v0.7.0
|
|
66
|
+
|
|
67
|
+
### Callbacks de Lifecycle
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { ConsentProvider } from '@react-lgpd-consent/core'
|
|
71
|
+
|
|
72
|
+
<ConsentProvider
|
|
73
|
+
onConsentInit={(state) => console.log('Init:', state)}
|
|
74
|
+
onConsentChange={(current, previous) => {
|
|
75
|
+
console.log('Mudou:', { current, previous })
|
|
76
|
+
}}
|
|
77
|
+
onAuditLog={(entry) => {
|
|
78
|
+
// Enviar para backend
|
|
79
|
+
fetch('/api/audit', { method: 'POST', body: JSON.stringify(entry) })
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Presets ANPD
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { createAnpdCategories, ANPD_CATEGORY_PRESETS } from '@react-lgpd-consent/core'
|
|
88
|
+
|
|
89
|
+
// Preset BÁSICO
|
|
90
|
+
const basic = createAnpdCategories({ include: ['analytics'] })
|
|
91
|
+
|
|
92
|
+
// Preset COMPLETO
|
|
93
|
+
const full = createAnpdCategories({
|
|
94
|
+
include: ['analytics', 'marketing', 'functional', 'social', 'personalization']
|
|
95
|
+
})
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Auditoria de Consentimento
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { createConsentAuditEntry } from '@react-lgpd-consent/core'
|
|
102
|
+
|
|
103
|
+
const audit = createConsentAuditEntry(
|
|
104
|
+
{ consented: true, preferences: { analytics: true } },
|
|
105
|
+
{ action: 'update', storageKey: 'lgpd-consent__v1' }
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
📖 **Saiba mais:** [TROUBLESHOOTING.md](../../TROUBLESHOOTING.md)
|
|
110
|
+
|
|
65
111
|
## 📚 Documentação
|
|
66
112
|
|
|
67
113
|
Para documentação completa, exemplos e API reference:
|