forlogic-core 1.10.3 → 1.11.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/README.md +290 -0
- package/dist/README.md +290 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/tailwind/index.esm.js +141 -0
- package/dist/tailwind/index.js +144 -0
- package/dist/vite/index.esm.js +204 -0
- package/dist/vite/index.js +209 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -14,6 +14,11 @@ A biblioteca `forlogic-core` requer as seguintes **peer dependencies** instalada
|
|
|
14
14
|
# Dependências obrigatórias
|
|
15
15
|
npm install react@^18.0.0 react-dom@^18.0.0
|
|
16
16
|
npm install lucide-react@>=0.400.0
|
|
17
|
+
|
|
18
|
+
# Internacionalização (i18n)
|
|
19
|
+
npm install i18next@^25.0.0 react-i18next@^16.0.0
|
|
20
|
+
```
|
|
21
|
+
|
|
17
22
|
### Instalar a Biblioteca
|
|
18
23
|
|
|
19
24
|
```bash
|
|
@@ -22,6 +27,20 @@ npm install forlogic-core
|
|
|
22
27
|
|
|
23
28
|
**Nota**: O npm/yarn irá alertar automaticamente se alguma peer dependency estiver faltando ou com versão incompatível.
|
|
24
29
|
|
|
30
|
+
### ⚠️ IMPORTANTE: Imports de i18n
|
|
31
|
+
|
|
32
|
+
**Sempre** importe hooks de internacionalização do `forlogic-core`, nunca diretamente de `react-i18next`:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
// ❌ ERRADO - Causa conflito de instâncias (erro NO_I18NEXT_INSTANCE)
|
|
36
|
+
import { useTranslation } from 'react-i18next';
|
|
37
|
+
|
|
38
|
+
// ✅ CORRETO - Usa a mesma instância configurada pelo CoreProviders
|
|
39
|
+
import { useTranslation } from 'forlogic-core';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Isso garante que todos os componentes compartilhem a mesma instância do i18next configurada pelo `CoreProviders`.
|
|
43
|
+
|
|
25
44
|
---
|
|
26
45
|
|
|
27
46
|
## 🤖 REGRAS CRÍTICAS
|
|
@@ -187,6 +206,277 @@ CREATE INDEX idx_processes_title ON processes.processes(title);
|
|
|
187
206
|
|
|
188
207
|
---
|
|
189
208
|
|
|
209
|
+
## ⚙️ Configuração Vite e Tailwind (Projetos Consumidores)
|
|
210
|
+
|
|
211
|
+
A biblioteca `forlogic-core` exporta configurações padronizadas de Vite e Tailwind para garantir consistência de segurança e estilo em todos os projetos.
|
|
212
|
+
|
|
213
|
+
### 📦 Instalação
|
|
214
|
+
|
|
215
|
+
As configurações estão disponíveis via subpaths do pacote:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
// Configurações Vite
|
|
219
|
+
import { createSecurityHeadersPlugin, createForlogicViteConfig } from 'forlogic-core/vite';
|
|
220
|
+
|
|
221
|
+
// Preset Tailwind
|
|
222
|
+
import { forlogicTailwindPreset, forlogicContentPaths } from 'forlogic-core/tailwind';
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
### 🔒 Plugin de Headers de Segurança (Vite)
|
|
228
|
+
|
|
229
|
+
O plugin configura automaticamente:
|
|
230
|
+
- **Content Security Policy (CSP)** - Proteção contra XSS e injeção de scripts
|
|
231
|
+
- **CORS seguro** - Origens confiáveis sem usar `*`
|
|
232
|
+
- **Headers OWASP** - HSTS, X-Content-Type-Options, X-Frame-Options, etc.
|
|
233
|
+
- **Permissions Policy** - Controle de APIs do navegador
|
|
234
|
+
|
|
235
|
+
#### Uso Básico
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
// vite.config.ts
|
|
239
|
+
import { defineConfig } from 'vite';
|
|
240
|
+
import react from '@vitejs/plugin-react-swc';
|
|
241
|
+
import { createSecurityHeadersPlugin } from 'forlogic-core/vite';
|
|
242
|
+
|
|
243
|
+
export default defineConfig(({ mode }) => ({
|
|
244
|
+
plugins: [
|
|
245
|
+
react(),
|
|
246
|
+
createSecurityHeadersPlugin(mode === 'development', {
|
|
247
|
+
supabaseUrls: ['https://seu-projeto.supabase.co'],
|
|
248
|
+
}),
|
|
249
|
+
],
|
|
250
|
+
}));
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Configuração Completa
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
// vite.config.ts
|
|
257
|
+
import { defineConfig } from 'vite';
|
|
258
|
+
import react from '@vitejs/plugin-react-swc';
|
|
259
|
+
import { createSecurityHeadersPlugin } from 'forlogic-core/vite';
|
|
260
|
+
|
|
261
|
+
export default defineConfig(({ mode }) => {
|
|
262
|
+
const isDev = mode === 'development';
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
plugins: [
|
|
266
|
+
react(),
|
|
267
|
+
createSecurityHeadersPlugin(isDev, {
|
|
268
|
+
// URLs do Supabase para permitir conexões
|
|
269
|
+
supabaseUrls: [
|
|
270
|
+
'https://seu-projeto-dev.supabase.co',
|
|
271
|
+
'https://seu-projeto-prod.supabase.co',
|
|
272
|
+
],
|
|
273
|
+
|
|
274
|
+
// Origens confiáveis adicionais para CORS
|
|
275
|
+
trustedOrigins: [
|
|
276
|
+
'https://meu-app.com',
|
|
277
|
+
'https://admin.meu-app.com',
|
|
278
|
+
],
|
|
279
|
+
|
|
280
|
+
// APIs externas para connect-src
|
|
281
|
+
additionalConnectSrc: [
|
|
282
|
+
'https://api.exemplo.com',
|
|
283
|
+
'wss://websocket.exemplo.com',
|
|
284
|
+
],
|
|
285
|
+
|
|
286
|
+
// CDNs de scripts adicionais
|
|
287
|
+
additionalScriptSrc: [
|
|
288
|
+
'https://cdn.analytics.com',
|
|
289
|
+
],
|
|
290
|
+
|
|
291
|
+
// CDNs de estilos adicionais
|
|
292
|
+
additionalStyleSrc: [
|
|
293
|
+
'https://fonts.custom.com',
|
|
294
|
+
],
|
|
295
|
+
|
|
296
|
+
// URI para reportar violações CSP
|
|
297
|
+
cspReportUri: 'https://seu-projeto.supabase.co/functions/v1/csp-report',
|
|
298
|
+
|
|
299
|
+
// Habilitar Trusted Types em produção (default: true)
|
|
300
|
+
enableTrustedTypes: true,
|
|
301
|
+
|
|
302
|
+
// Upgrade HTTP para HTTPS em produção (default: true)
|
|
303
|
+
upgradeInsecureRequests: true,
|
|
304
|
+
}),
|
|
305
|
+
],
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
#### Opções do Plugin
|
|
311
|
+
|
|
312
|
+
| Opção | Tipo | Padrão | Descrição |
|
|
313
|
+
|-------|------|--------|-----------|
|
|
314
|
+
| `supabaseUrls` | `string[]` | `[]` | URLs do Supabase para permitir conexões |
|
|
315
|
+
| `trustedOrigins` | `string[]` | `[]` | Origens confiáveis adicionais para CORS |
|
|
316
|
+
| `additionalScriptSrc` | `string[]` | `[]` | Fontes de script adicionais para CSP |
|
|
317
|
+
| `additionalStyleSrc` | `string[]` | `[]` | Fontes de estilo adicionais para CSP |
|
|
318
|
+
| `additionalConnectSrc` | `string[]` | `[]` | APIs/WebSockets adicionais para CSP |
|
|
319
|
+
| `cspReportUri` | `string` | - | URI para relatório de violações CSP |
|
|
320
|
+
| `enableTrustedTypes` | `boolean` | `true` | Habilitar Trusted Types em produção |
|
|
321
|
+
| `upgradeInsecureRequests` | `boolean` | `true` | Upgrade HTTP→HTTPS em produção |
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
### 🏗️ Factory de Configuração Vite (Opcional)
|
|
326
|
+
|
|
327
|
+
Para projetos que desejam usar a configuração completa padronizada:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
// vite.config.ts
|
|
331
|
+
import { defineConfig } from 'vite';
|
|
332
|
+
import react from '@vitejs/plugin-react-swc';
|
|
333
|
+
import { createForlogicViteConfig } from 'forlogic-core/vite';
|
|
334
|
+
|
|
335
|
+
// Cria configuração com opções personalizadas
|
|
336
|
+
const forlogicConfig = createForlogicViteConfig({
|
|
337
|
+
srcAlias: '@', // Alias para ./src
|
|
338
|
+
libAlias: 'forlogic-core', // Alias para ./lib (desenvolvimento local)
|
|
339
|
+
security: {
|
|
340
|
+
supabaseUrls: ['https://seu-projeto.supabase.co'],
|
|
341
|
+
trustedOrigins: ['https://meu-app.com'],
|
|
342
|
+
},
|
|
343
|
+
server: {
|
|
344
|
+
host: '::',
|
|
345
|
+
port: 8080,
|
|
346
|
+
},
|
|
347
|
+
build: {
|
|
348
|
+
chunkSizeWarningLimit: 4000,
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
export default defineConfig(({ mode }) => {
|
|
353
|
+
const config = forlogicConfig(mode === 'development');
|
|
354
|
+
|
|
355
|
+
return {
|
|
356
|
+
...config,
|
|
357
|
+
plugins: [
|
|
358
|
+
react(),
|
|
359
|
+
...config.plugins,
|
|
360
|
+
],
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
### 🎨 Preset Tailwind CSS
|
|
368
|
+
|
|
369
|
+
O preset inclui:
|
|
370
|
+
- **Cores semânticas** - primary, secondary, destructive, success, warning, etc.
|
|
371
|
+
- **Border radius** - lg, md, sm padronizados
|
|
372
|
+
- **Animações** - accordion, fade, slide, scale
|
|
373
|
+
- **Gradientes** - primary, secondary, accent
|
|
374
|
+
- **Sombras** - xs até 2xl, inner, primary
|
|
375
|
+
|
|
376
|
+
#### Uso Básico
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
// tailwind.config.ts
|
|
380
|
+
import type { Config } from 'tailwindcss';
|
|
381
|
+
import { forlogicTailwindPreset, forlogicContentPaths } from 'forlogic-core/tailwind';
|
|
382
|
+
|
|
383
|
+
export default {
|
|
384
|
+
presets: [forlogicTailwindPreset],
|
|
385
|
+
content: [
|
|
386
|
+
...forlogicContentPaths,
|
|
387
|
+
// Paths adicionais específicos do seu projeto
|
|
388
|
+
],
|
|
389
|
+
} satisfies Config;
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
#### Uso com Extensões
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
// tailwind.config.ts
|
|
396
|
+
import type { Config } from 'tailwindcss';
|
|
397
|
+
import { forlogicTailwindPreset, forlogicContentPaths } from 'forlogic-core/tailwind';
|
|
398
|
+
|
|
399
|
+
export default {
|
|
400
|
+
presets: [forlogicTailwindPreset],
|
|
401
|
+
content: [
|
|
402
|
+
...forlogicContentPaths,
|
|
403
|
+
],
|
|
404
|
+
theme: {
|
|
405
|
+
extend: {
|
|
406
|
+
// Extensões específicas do seu projeto
|
|
407
|
+
colors: {
|
|
408
|
+
brand: {
|
|
409
|
+
50: 'hsl(var(--brand-50))',
|
|
410
|
+
// ...
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
plugins: [
|
|
416
|
+
require('tailwindcss-animate'),
|
|
417
|
+
// Plugins adicionais
|
|
418
|
+
],
|
|
419
|
+
} satisfies Config;
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### Content Paths Padrão
|
|
423
|
+
|
|
424
|
+
O `forlogicContentPaths` inclui:
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
[
|
|
428
|
+
'./pages/**/*.{ts,tsx}',
|
|
429
|
+
'./components/**/*.{ts,tsx}',
|
|
430
|
+
'./app/**/*.{ts,tsx}',
|
|
431
|
+
'./src/**/*.{ts,tsx}',
|
|
432
|
+
'./lib/**/*.{ts,tsx}',
|
|
433
|
+
'./node_modules/forlogic-core/dist/**/*.{js,ts,jsx,tsx}',
|
|
434
|
+
]
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
### 📋 Checklist de Configuração
|
|
440
|
+
|
|
441
|
+
```markdown
|
|
442
|
+
- [ ] Instalou `forlogic-core` no projeto?
|
|
443
|
+
- [ ] Configurou `vite.config.ts` com `createSecurityHeadersPlugin`?
|
|
444
|
+
- [ ] Adicionou URLs do Supabase em `supabaseUrls`?
|
|
445
|
+
- [ ] Configurou `tailwind.config.ts` com `forlogicTailwindPreset`?
|
|
446
|
+
- [ ] Adicionou `forlogicContentPaths` ao content?
|
|
447
|
+
- [ ] Definiu variáveis CSS no `index.css` (--primary, --background, etc.)?
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
### 🔧 Configuração do package.json (Publicação da Lib)
|
|
453
|
+
|
|
454
|
+
Para projetos que estão **publicando** a `forlogic-core`, adicione os exports condicionais:
|
|
455
|
+
|
|
456
|
+
```json
|
|
457
|
+
{
|
|
458
|
+
"exports": {
|
|
459
|
+
".": {
|
|
460
|
+
"import": "./dist/index.esm.js",
|
|
461
|
+
"require": "./dist/index.js",
|
|
462
|
+
"types": "./dist/index.d.ts"
|
|
463
|
+
},
|
|
464
|
+
"./vite": {
|
|
465
|
+
"import": "./dist/vite/index.esm.js",
|
|
466
|
+
"require": "./dist/vite/index.js",
|
|
467
|
+
"types": "./dist/vite/index.d.ts"
|
|
468
|
+
},
|
|
469
|
+
"./tailwind": {
|
|
470
|
+
"import": "./dist/tailwind/index.esm.js",
|
|
471
|
+
"require": "./dist/tailwind/index.js",
|
|
472
|
+
"types": "./dist/tailwind/index.d.ts"
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
190
480
|
## 🚩 Feature Flags (Variáveis de Ambiente)
|
|
191
481
|
|
|
192
482
|
A biblioteca suporta feature flags para habilitar/desabilitar funcionalidades opcionais.
|
package/dist/README.md
CHANGED
|
@@ -14,6 +14,11 @@ A biblioteca `forlogic-core` requer as seguintes **peer dependencies** instalada
|
|
|
14
14
|
# Dependências obrigatórias
|
|
15
15
|
npm install react@^18.0.0 react-dom@^18.0.0
|
|
16
16
|
npm install lucide-react@>=0.400.0
|
|
17
|
+
|
|
18
|
+
# Internacionalização (i18n)
|
|
19
|
+
npm install i18next@^25.0.0 react-i18next@^16.0.0
|
|
20
|
+
```
|
|
21
|
+
|
|
17
22
|
### Instalar a Biblioteca
|
|
18
23
|
|
|
19
24
|
```bash
|
|
@@ -22,6 +27,20 @@ npm install forlogic-core
|
|
|
22
27
|
|
|
23
28
|
**Nota**: O npm/yarn irá alertar automaticamente se alguma peer dependency estiver faltando ou com versão incompatível.
|
|
24
29
|
|
|
30
|
+
### ⚠️ IMPORTANTE: Imports de i18n
|
|
31
|
+
|
|
32
|
+
**Sempre** importe hooks de internacionalização do `forlogic-core`, nunca diretamente de `react-i18next`:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
// ❌ ERRADO - Causa conflito de instâncias (erro NO_I18NEXT_INSTANCE)
|
|
36
|
+
import { useTranslation } from 'react-i18next';
|
|
37
|
+
|
|
38
|
+
// ✅ CORRETO - Usa a mesma instância configurada pelo CoreProviders
|
|
39
|
+
import { useTranslation } from 'forlogic-core';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Isso garante que todos os componentes compartilhem a mesma instância do i18next configurada pelo `CoreProviders`.
|
|
43
|
+
|
|
25
44
|
---
|
|
26
45
|
|
|
27
46
|
## 🤖 REGRAS CRÍTICAS
|
|
@@ -187,6 +206,277 @@ CREATE INDEX idx_processes_title ON processes.processes(title);
|
|
|
187
206
|
|
|
188
207
|
---
|
|
189
208
|
|
|
209
|
+
## ⚙️ Configuração Vite e Tailwind (Projetos Consumidores)
|
|
210
|
+
|
|
211
|
+
A biblioteca `forlogic-core` exporta configurações padronizadas de Vite e Tailwind para garantir consistência de segurança e estilo em todos os projetos.
|
|
212
|
+
|
|
213
|
+
### 📦 Instalação
|
|
214
|
+
|
|
215
|
+
As configurações estão disponíveis via subpaths do pacote:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
// Configurações Vite
|
|
219
|
+
import { createSecurityHeadersPlugin, createForlogicViteConfig } from 'forlogic-core/vite';
|
|
220
|
+
|
|
221
|
+
// Preset Tailwind
|
|
222
|
+
import { forlogicTailwindPreset, forlogicContentPaths } from 'forlogic-core/tailwind';
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
### 🔒 Plugin de Headers de Segurança (Vite)
|
|
228
|
+
|
|
229
|
+
O plugin configura automaticamente:
|
|
230
|
+
- **Content Security Policy (CSP)** - Proteção contra XSS e injeção de scripts
|
|
231
|
+
- **CORS seguro** - Origens confiáveis sem usar `*`
|
|
232
|
+
- **Headers OWASP** - HSTS, X-Content-Type-Options, X-Frame-Options, etc.
|
|
233
|
+
- **Permissions Policy** - Controle de APIs do navegador
|
|
234
|
+
|
|
235
|
+
#### Uso Básico
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
// vite.config.ts
|
|
239
|
+
import { defineConfig } from 'vite';
|
|
240
|
+
import react from '@vitejs/plugin-react-swc';
|
|
241
|
+
import { createSecurityHeadersPlugin } from 'forlogic-core/vite';
|
|
242
|
+
|
|
243
|
+
export default defineConfig(({ mode }) => ({
|
|
244
|
+
plugins: [
|
|
245
|
+
react(),
|
|
246
|
+
createSecurityHeadersPlugin(mode === 'development', {
|
|
247
|
+
supabaseUrls: ['https://seu-projeto.supabase.co'],
|
|
248
|
+
}),
|
|
249
|
+
],
|
|
250
|
+
}));
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Configuração Completa
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
// vite.config.ts
|
|
257
|
+
import { defineConfig } from 'vite';
|
|
258
|
+
import react from '@vitejs/plugin-react-swc';
|
|
259
|
+
import { createSecurityHeadersPlugin } from 'forlogic-core/vite';
|
|
260
|
+
|
|
261
|
+
export default defineConfig(({ mode }) => {
|
|
262
|
+
const isDev = mode === 'development';
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
plugins: [
|
|
266
|
+
react(),
|
|
267
|
+
createSecurityHeadersPlugin(isDev, {
|
|
268
|
+
// URLs do Supabase para permitir conexões
|
|
269
|
+
supabaseUrls: [
|
|
270
|
+
'https://seu-projeto-dev.supabase.co',
|
|
271
|
+
'https://seu-projeto-prod.supabase.co',
|
|
272
|
+
],
|
|
273
|
+
|
|
274
|
+
// Origens confiáveis adicionais para CORS
|
|
275
|
+
trustedOrigins: [
|
|
276
|
+
'https://meu-app.com',
|
|
277
|
+
'https://admin.meu-app.com',
|
|
278
|
+
],
|
|
279
|
+
|
|
280
|
+
// APIs externas para connect-src
|
|
281
|
+
additionalConnectSrc: [
|
|
282
|
+
'https://api.exemplo.com',
|
|
283
|
+
'wss://websocket.exemplo.com',
|
|
284
|
+
],
|
|
285
|
+
|
|
286
|
+
// CDNs de scripts adicionais
|
|
287
|
+
additionalScriptSrc: [
|
|
288
|
+
'https://cdn.analytics.com',
|
|
289
|
+
],
|
|
290
|
+
|
|
291
|
+
// CDNs de estilos adicionais
|
|
292
|
+
additionalStyleSrc: [
|
|
293
|
+
'https://fonts.custom.com',
|
|
294
|
+
],
|
|
295
|
+
|
|
296
|
+
// URI para reportar violações CSP
|
|
297
|
+
cspReportUri: 'https://seu-projeto.supabase.co/functions/v1/csp-report',
|
|
298
|
+
|
|
299
|
+
// Habilitar Trusted Types em produção (default: true)
|
|
300
|
+
enableTrustedTypes: true,
|
|
301
|
+
|
|
302
|
+
// Upgrade HTTP para HTTPS em produção (default: true)
|
|
303
|
+
upgradeInsecureRequests: true,
|
|
304
|
+
}),
|
|
305
|
+
],
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
#### Opções do Plugin
|
|
311
|
+
|
|
312
|
+
| Opção | Tipo | Padrão | Descrição |
|
|
313
|
+
|-------|------|--------|-----------|
|
|
314
|
+
| `supabaseUrls` | `string[]` | `[]` | URLs do Supabase para permitir conexões |
|
|
315
|
+
| `trustedOrigins` | `string[]` | `[]` | Origens confiáveis adicionais para CORS |
|
|
316
|
+
| `additionalScriptSrc` | `string[]` | `[]` | Fontes de script adicionais para CSP |
|
|
317
|
+
| `additionalStyleSrc` | `string[]` | `[]` | Fontes de estilo adicionais para CSP |
|
|
318
|
+
| `additionalConnectSrc` | `string[]` | `[]` | APIs/WebSockets adicionais para CSP |
|
|
319
|
+
| `cspReportUri` | `string` | - | URI para relatório de violações CSP |
|
|
320
|
+
| `enableTrustedTypes` | `boolean` | `true` | Habilitar Trusted Types em produção |
|
|
321
|
+
| `upgradeInsecureRequests` | `boolean` | `true` | Upgrade HTTP→HTTPS em produção |
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
### 🏗️ Factory de Configuração Vite (Opcional)
|
|
326
|
+
|
|
327
|
+
Para projetos que desejam usar a configuração completa padronizada:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
// vite.config.ts
|
|
331
|
+
import { defineConfig } from 'vite';
|
|
332
|
+
import react from '@vitejs/plugin-react-swc';
|
|
333
|
+
import { createForlogicViteConfig } from 'forlogic-core/vite';
|
|
334
|
+
|
|
335
|
+
// Cria configuração com opções personalizadas
|
|
336
|
+
const forlogicConfig = createForlogicViteConfig({
|
|
337
|
+
srcAlias: '@', // Alias para ./src
|
|
338
|
+
libAlias: 'forlogic-core', // Alias para ./lib (desenvolvimento local)
|
|
339
|
+
security: {
|
|
340
|
+
supabaseUrls: ['https://seu-projeto.supabase.co'],
|
|
341
|
+
trustedOrigins: ['https://meu-app.com'],
|
|
342
|
+
},
|
|
343
|
+
server: {
|
|
344
|
+
host: '::',
|
|
345
|
+
port: 8080,
|
|
346
|
+
},
|
|
347
|
+
build: {
|
|
348
|
+
chunkSizeWarningLimit: 4000,
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
export default defineConfig(({ mode }) => {
|
|
353
|
+
const config = forlogicConfig(mode === 'development');
|
|
354
|
+
|
|
355
|
+
return {
|
|
356
|
+
...config,
|
|
357
|
+
plugins: [
|
|
358
|
+
react(),
|
|
359
|
+
...config.plugins,
|
|
360
|
+
],
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
### 🎨 Preset Tailwind CSS
|
|
368
|
+
|
|
369
|
+
O preset inclui:
|
|
370
|
+
- **Cores semânticas** - primary, secondary, destructive, success, warning, etc.
|
|
371
|
+
- **Border radius** - lg, md, sm padronizados
|
|
372
|
+
- **Animações** - accordion, fade, slide, scale
|
|
373
|
+
- **Gradientes** - primary, secondary, accent
|
|
374
|
+
- **Sombras** - xs até 2xl, inner, primary
|
|
375
|
+
|
|
376
|
+
#### Uso Básico
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
// tailwind.config.ts
|
|
380
|
+
import type { Config } from 'tailwindcss';
|
|
381
|
+
import { forlogicTailwindPreset, forlogicContentPaths } from 'forlogic-core/tailwind';
|
|
382
|
+
|
|
383
|
+
export default {
|
|
384
|
+
presets: [forlogicTailwindPreset],
|
|
385
|
+
content: [
|
|
386
|
+
...forlogicContentPaths,
|
|
387
|
+
// Paths adicionais específicos do seu projeto
|
|
388
|
+
],
|
|
389
|
+
} satisfies Config;
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
#### Uso com Extensões
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
// tailwind.config.ts
|
|
396
|
+
import type { Config } from 'tailwindcss';
|
|
397
|
+
import { forlogicTailwindPreset, forlogicContentPaths } from 'forlogic-core/tailwind';
|
|
398
|
+
|
|
399
|
+
export default {
|
|
400
|
+
presets: [forlogicTailwindPreset],
|
|
401
|
+
content: [
|
|
402
|
+
...forlogicContentPaths,
|
|
403
|
+
],
|
|
404
|
+
theme: {
|
|
405
|
+
extend: {
|
|
406
|
+
// Extensões específicas do seu projeto
|
|
407
|
+
colors: {
|
|
408
|
+
brand: {
|
|
409
|
+
50: 'hsl(var(--brand-50))',
|
|
410
|
+
// ...
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
plugins: [
|
|
416
|
+
require('tailwindcss-animate'),
|
|
417
|
+
// Plugins adicionais
|
|
418
|
+
],
|
|
419
|
+
} satisfies Config;
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### Content Paths Padrão
|
|
423
|
+
|
|
424
|
+
O `forlogicContentPaths` inclui:
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
[
|
|
428
|
+
'./pages/**/*.{ts,tsx}',
|
|
429
|
+
'./components/**/*.{ts,tsx}',
|
|
430
|
+
'./app/**/*.{ts,tsx}',
|
|
431
|
+
'./src/**/*.{ts,tsx}',
|
|
432
|
+
'./lib/**/*.{ts,tsx}',
|
|
433
|
+
'./node_modules/forlogic-core/dist/**/*.{js,ts,jsx,tsx}',
|
|
434
|
+
]
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
### 📋 Checklist de Configuração
|
|
440
|
+
|
|
441
|
+
```markdown
|
|
442
|
+
- [ ] Instalou `forlogic-core` no projeto?
|
|
443
|
+
- [ ] Configurou `vite.config.ts` com `createSecurityHeadersPlugin`?
|
|
444
|
+
- [ ] Adicionou URLs do Supabase em `supabaseUrls`?
|
|
445
|
+
- [ ] Configurou `tailwind.config.ts` com `forlogicTailwindPreset`?
|
|
446
|
+
- [ ] Adicionou `forlogicContentPaths` ao content?
|
|
447
|
+
- [ ] Definiu variáveis CSS no `index.css` (--primary, --background, etc.)?
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
### 🔧 Configuração do package.json (Publicação da Lib)
|
|
453
|
+
|
|
454
|
+
Para projetos que estão **publicando** a `forlogic-core`, adicione os exports condicionais:
|
|
455
|
+
|
|
456
|
+
```json
|
|
457
|
+
{
|
|
458
|
+
"exports": {
|
|
459
|
+
".": {
|
|
460
|
+
"import": "./dist/index.esm.js",
|
|
461
|
+
"require": "./dist/index.js",
|
|
462
|
+
"types": "./dist/index.d.ts"
|
|
463
|
+
},
|
|
464
|
+
"./vite": {
|
|
465
|
+
"import": "./dist/vite/index.esm.js",
|
|
466
|
+
"require": "./dist/vite/index.js",
|
|
467
|
+
"types": "./dist/vite/index.d.ts"
|
|
468
|
+
},
|
|
469
|
+
"./tailwind": {
|
|
470
|
+
"import": "./dist/tailwind/index.esm.js",
|
|
471
|
+
"require": "./dist/tailwind/index.js",
|
|
472
|
+
"types": "./dist/tailwind/index.d.ts"
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
190
480
|
## 🚩 Feature Flags (Variáveis de Ambiente)
|
|
191
481
|
|
|
192
482
|
A biblioteca suporta feature flags para habilitar/desabilitar funcionalidades opcionais.
|