glin-profanity 3.1.5 → 3.2.2

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.
Files changed (66) hide show
  1. package/README.md +84 -566
  2. package/dist/{types-CdDqSZY7.d.cts → Filter-BGcyIAvO.d.ts} +4 -162
  3. package/dist/{types-CdDqSZY7.d.ts → Filter-D34Wsmrj.d.cts} +4 -162
  4. package/dist/frameworks/index.cjs +5257 -0
  5. package/dist/frameworks/index.d.cts +2 -0
  6. package/dist/frameworks/index.d.ts +2 -0
  7. package/dist/frameworks/index.js +5252 -0
  8. package/dist/frameworks/nextjs.cjs +5257 -0
  9. package/dist/frameworks/nextjs.d.cts +173 -0
  10. package/dist/frameworks/nextjs.d.ts +173 -0
  11. package/dist/frameworks/nextjs.js +5252 -0
  12. package/dist/index.cjs +151 -85
  13. package/dist/index.d.cts +5 -29
  14. package/dist/index.d.ts +5 -29
  15. package/dist/index.js +152 -85
  16. package/dist/integrations/index.cjs +6110 -0
  17. package/dist/integrations/index.d.cts +5 -0
  18. package/dist/integrations/index.d.ts +5 -0
  19. package/dist/integrations/index.js +6082 -0
  20. package/dist/integrations/langchain.cjs +5252 -0
  21. package/dist/integrations/langchain.d.cts +231 -0
  22. package/dist/integrations/langchain.d.ts +231 -0
  23. package/dist/integrations/langchain.js +5239 -0
  24. package/dist/integrations/openai.cjs +5367 -0
  25. package/dist/integrations/openai.d.cts +167 -0
  26. package/dist/integrations/openai.d.ts +167 -0
  27. package/dist/integrations/openai.js +5362 -0
  28. package/dist/integrations/semantic.cjs +5314 -0
  29. package/dist/integrations/semantic.d.cts +268 -0
  30. package/dist/integrations/semantic.d.ts +268 -0
  31. package/dist/integrations/semantic.js +5309 -0
  32. package/dist/integrations/vercel-ai.cjs +5282 -0
  33. package/dist/integrations/vercel-ai.d.cts +224 -0
  34. package/dist/integrations/vercel-ai.d.ts +224 -0
  35. package/dist/integrations/vercel-ai.js +5273 -0
  36. package/dist/ml/index.cjs +358 -56
  37. package/dist/ml/index.d.cts +5 -2
  38. package/dist/ml/index.d.ts +5 -2
  39. package/dist/ml/index.js +354 -57
  40. package/dist/ml/transformers.cjs +5237 -0
  41. package/dist/ml/transformers.d.cts +232 -0
  42. package/dist/ml/transformers.d.ts +232 -0
  43. package/dist/ml/transformers.js +5231 -0
  44. package/dist/multimodal/audio.cjs +5269 -0
  45. package/dist/multimodal/audio.d.cts +255 -0
  46. package/dist/multimodal/audio.d.ts +255 -0
  47. package/dist/multimodal/audio.js +5264 -0
  48. package/dist/multimodal/index.cjs +5432 -0
  49. package/dist/multimodal/index.d.cts +4 -0
  50. package/dist/multimodal/index.d.ts +4 -0
  51. package/dist/multimodal/index.js +5422 -0
  52. package/dist/multimodal/ocr.cjs +5193 -0
  53. package/dist/multimodal/ocr.d.cts +157 -0
  54. package/dist/multimodal/ocr.d.ts +157 -0
  55. package/dist/multimodal/ocr.js +5187 -0
  56. package/dist/react.cjs +5133 -0
  57. package/dist/react.d.cts +13 -0
  58. package/dist/react.d.ts +13 -0
  59. package/dist/react.js +5131 -0
  60. package/dist/types-B9c_ik4k.d.cts +88 -0
  61. package/dist/types-B9c_ik4k.d.ts +88 -0
  62. package/dist/types-BuKh9tvV.d.ts +20 -0
  63. package/dist/types-Ct_ueYqw.d.cts +76 -0
  64. package/dist/types-Ct_ueYqw.d.ts +76 -0
  65. package/dist/types-DI8nzwWc.d.cts +20 -0
  66. package/package.json +170 -3
@@ -0,0 +1,157 @@
1
+ import { F as Filter } from '../Filter-D34Wsmrj.cjs';
2
+ import { L as Language, F as FilterConfig, C as CheckProfanityResult } from '../types-B9c_ik4k.cjs';
3
+
4
+ /**
5
+ * OCR (Optical Character Recognition) Integration for glin-profanity
6
+ *
7
+ * Extracts text from images and checks for profanity.
8
+ * Uses Tesseract.js as an optional peer dependency.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { createOCRChecker, checkImageForProfanity } from 'glin-profanity/ocr';
13
+ *
14
+ * // Quick check
15
+ * const result = await checkImageForProfanity(imageBuffer);
16
+ * console.log(result.containsProfanity);
17
+ *
18
+ * // With custom config
19
+ * const checker = createOCRChecker({
20
+ * languages: ['english', 'spanish'],
21
+ * tesseractLangs: ['eng', 'spa'],
22
+ * detectLeetspeak: true,
23
+ * });
24
+ * const result = await checker.checkImage(imageBuffer);
25
+ * ```
26
+ *
27
+ * @packageDocumentation
28
+ * @module glin-profanity/ocr
29
+ */
30
+
31
+ type ImageLike = string | Buffer | Uint8Array | Blob | File | HTMLImageElement | HTMLCanvasElement;
32
+ /**
33
+ * OCR checker configuration
34
+ */
35
+ interface OCRCheckerConfig {
36
+ /** Languages for profanity detection */
37
+ languages?: Language[];
38
+ /** Tesseract language codes (e.g., 'eng', 'spa', 'fra') */
39
+ tesseractLangs?: string[];
40
+ /** Enable leetspeak detection */
41
+ detectLeetspeak?: boolean;
42
+ /** Enable Unicode normalization */
43
+ normalizeUnicode?: boolean;
44
+ /** Minimum OCR confidence to process text (0-100) */
45
+ minConfidence?: number;
46
+ /** Custom filter configuration */
47
+ filterConfig?: Partial<FilterConfig>;
48
+ }
49
+ /**
50
+ * OCR check result
51
+ */
52
+ interface OCRCheckResult {
53
+ /** Whether profanity was found in the extracted text */
54
+ containsProfanity: boolean;
55
+ /** Extracted text from the image */
56
+ extractedText: string;
57
+ /** OCR confidence score (0-100) */
58
+ ocrConfidence: number;
59
+ /** Profane words found */
60
+ profaneWords: string[];
61
+ /** Full profanity check result */
62
+ profanityResult: CheckProfanityResult;
63
+ /** Processing time in milliseconds */
64
+ processingTimeMs: number;
65
+ }
66
+ /**
67
+ * Creates an OCR profanity checker
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const checker = createOCRChecker({
72
+ * languages: ['english'],
73
+ * tesseractLangs: ['eng'],
74
+ * detectLeetspeak: true,
75
+ * });
76
+ *
77
+ * // Check an image
78
+ * const result = await checker.checkImage('./screenshot.png');
79
+ *
80
+ * // Check multiple images
81
+ * const results = await checker.checkImages([image1, image2, image3]);
82
+ *
83
+ * // Clean up when done
84
+ * await checker.terminate();
85
+ * ```
86
+ */
87
+ declare function createOCRChecker(config?: OCRCheckerConfig): {
88
+ /**
89
+ * Check a single image for profanity
90
+ */
91
+ checkImage(image: ImageLike): Promise<OCRCheckResult>;
92
+ /**
93
+ * Check multiple images for profanity
94
+ */
95
+ checkImages(images: ImageLike[]): Promise<OCRCheckResult[]>;
96
+ /**
97
+ * Extract text from image without profanity check
98
+ */
99
+ extractText(image: ImageLike): Promise<{
100
+ text: string;
101
+ confidence: number;
102
+ }>;
103
+ /**
104
+ * Check extracted text (if you already have text from another OCR)
105
+ */
106
+ checkText(text: string): CheckProfanityResult;
107
+ /**
108
+ * Terminate the Tesseract worker (clean up resources)
109
+ */
110
+ terminate(): Promise<void>;
111
+ /**
112
+ * Get the underlying filter instance
113
+ */
114
+ getFilter(): Filter;
115
+ };
116
+ /**
117
+ * Quick function to check an image for profanity
118
+ * Creates a temporary worker, checks the image, and terminates
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * import { checkImageForProfanity } from 'glin-profanity/ocr';
123
+ *
124
+ * const result = await checkImageForProfanity('./meme.png');
125
+ * if (result.containsProfanity) {
126
+ * console.log('Found profanity:', result.profaneWords);
127
+ * }
128
+ * ```
129
+ */
130
+ declare function checkImageForProfanity(image: ImageLike, config?: OCRCheckerConfig): Promise<OCRCheckResult>;
131
+ /**
132
+ * Batch check multiple images for profanity
133
+ * More efficient than calling checkImageForProfanity multiple times
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * import { batchCheckImages } from 'glin-profanity/ocr';
138
+ *
139
+ * const images = ['./img1.png', './img2.png', './img3.png'];
140
+ * const results = await batchCheckImages(images);
141
+ *
142
+ * const flagged = results.filter(r => r.containsProfanity);
143
+ * console.log(`${flagged.length} images contain profanity`);
144
+ * ```
145
+ */
146
+ declare function batchCheckImages(images: ImageLike[], config?: OCRCheckerConfig): Promise<OCRCheckResult[]>;
147
+ /**
148
+ * Supported Tesseract language codes
149
+ * Map from glin-profanity language to Tesseract code
150
+ */
151
+ declare const LANGUAGE_TO_TESSERACT: Record<Language, string>;
152
+ /**
153
+ * Helper to convert glin-profanity languages to Tesseract codes
154
+ */
155
+ declare function languagesToTesseract(languages: Language[]): string[];
156
+
157
+ export { CheckProfanityResult, FilterConfig, LANGUAGE_TO_TESSERACT, Language, type OCRCheckResult, type OCRCheckerConfig, batchCheckImages, checkImageForProfanity, createOCRChecker, languagesToTesseract };
@@ -0,0 +1,157 @@
1
+ import { F as Filter } from '../Filter-BGcyIAvO.js';
2
+ import { L as Language, F as FilterConfig, C as CheckProfanityResult } from '../types-B9c_ik4k.js';
3
+
4
+ /**
5
+ * OCR (Optical Character Recognition) Integration for glin-profanity
6
+ *
7
+ * Extracts text from images and checks for profanity.
8
+ * Uses Tesseract.js as an optional peer dependency.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { createOCRChecker, checkImageForProfanity } from 'glin-profanity/ocr';
13
+ *
14
+ * // Quick check
15
+ * const result = await checkImageForProfanity(imageBuffer);
16
+ * console.log(result.containsProfanity);
17
+ *
18
+ * // With custom config
19
+ * const checker = createOCRChecker({
20
+ * languages: ['english', 'spanish'],
21
+ * tesseractLangs: ['eng', 'spa'],
22
+ * detectLeetspeak: true,
23
+ * });
24
+ * const result = await checker.checkImage(imageBuffer);
25
+ * ```
26
+ *
27
+ * @packageDocumentation
28
+ * @module glin-profanity/ocr
29
+ */
30
+
31
+ type ImageLike = string | Buffer | Uint8Array | Blob | File | HTMLImageElement | HTMLCanvasElement;
32
+ /**
33
+ * OCR checker configuration
34
+ */
35
+ interface OCRCheckerConfig {
36
+ /** Languages for profanity detection */
37
+ languages?: Language[];
38
+ /** Tesseract language codes (e.g., 'eng', 'spa', 'fra') */
39
+ tesseractLangs?: string[];
40
+ /** Enable leetspeak detection */
41
+ detectLeetspeak?: boolean;
42
+ /** Enable Unicode normalization */
43
+ normalizeUnicode?: boolean;
44
+ /** Minimum OCR confidence to process text (0-100) */
45
+ minConfidence?: number;
46
+ /** Custom filter configuration */
47
+ filterConfig?: Partial<FilterConfig>;
48
+ }
49
+ /**
50
+ * OCR check result
51
+ */
52
+ interface OCRCheckResult {
53
+ /** Whether profanity was found in the extracted text */
54
+ containsProfanity: boolean;
55
+ /** Extracted text from the image */
56
+ extractedText: string;
57
+ /** OCR confidence score (0-100) */
58
+ ocrConfidence: number;
59
+ /** Profane words found */
60
+ profaneWords: string[];
61
+ /** Full profanity check result */
62
+ profanityResult: CheckProfanityResult;
63
+ /** Processing time in milliseconds */
64
+ processingTimeMs: number;
65
+ }
66
+ /**
67
+ * Creates an OCR profanity checker
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const checker = createOCRChecker({
72
+ * languages: ['english'],
73
+ * tesseractLangs: ['eng'],
74
+ * detectLeetspeak: true,
75
+ * });
76
+ *
77
+ * // Check an image
78
+ * const result = await checker.checkImage('./screenshot.png');
79
+ *
80
+ * // Check multiple images
81
+ * const results = await checker.checkImages([image1, image2, image3]);
82
+ *
83
+ * // Clean up when done
84
+ * await checker.terminate();
85
+ * ```
86
+ */
87
+ declare function createOCRChecker(config?: OCRCheckerConfig): {
88
+ /**
89
+ * Check a single image for profanity
90
+ */
91
+ checkImage(image: ImageLike): Promise<OCRCheckResult>;
92
+ /**
93
+ * Check multiple images for profanity
94
+ */
95
+ checkImages(images: ImageLike[]): Promise<OCRCheckResult[]>;
96
+ /**
97
+ * Extract text from image without profanity check
98
+ */
99
+ extractText(image: ImageLike): Promise<{
100
+ text: string;
101
+ confidence: number;
102
+ }>;
103
+ /**
104
+ * Check extracted text (if you already have text from another OCR)
105
+ */
106
+ checkText(text: string): CheckProfanityResult;
107
+ /**
108
+ * Terminate the Tesseract worker (clean up resources)
109
+ */
110
+ terminate(): Promise<void>;
111
+ /**
112
+ * Get the underlying filter instance
113
+ */
114
+ getFilter(): Filter;
115
+ };
116
+ /**
117
+ * Quick function to check an image for profanity
118
+ * Creates a temporary worker, checks the image, and terminates
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * import { checkImageForProfanity } from 'glin-profanity/ocr';
123
+ *
124
+ * const result = await checkImageForProfanity('./meme.png');
125
+ * if (result.containsProfanity) {
126
+ * console.log('Found profanity:', result.profaneWords);
127
+ * }
128
+ * ```
129
+ */
130
+ declare function checkImageForProfanity(image: ImageLike, config?: OCRCheckerConfig): Promise<OCRCheckResult>;
131
+ /**
132
+ * Batch check multiple images for profanity
133
+ * More efficient than calling checkImageForProfanity multiple times
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * import { batchCheckImages } from 'glin-profanity/ocr';
138
+ *
139
+ * const images = ['./img1.png', './img2.png', './img3.png'];
140
+ * const results = await batchCheckImages(images);
141
+ *
142
+ * const flagged = results.filter(r => r.containsProfanity);
143
+ * console.log(`${flagged.length} images contain profanity`);
144
+ * ```
145
+ */
146
+ declare function batchCheckImages(images: ImageLike[], config?: OCRCheckerConfig): Promise<OCRCheckResult[]>;
147
+ /**
148
+ * Supported Tesseract language codes
149
+ * Map from glin-profanity language to Tesseract code
150
+ */
151
+ declare const LANGUAGE_TO_TESSERACT: Record<Language, string>;
152
+ /**
153
+ * Helper to convert glin-profanity languages to Tesseract codes
154
+ */
155
+ declare function languagesToTesseract(languages: Language[]): string[];
156
+
157
+ export { CheckProfanityResult, FilterConfig, LANGUAGE_TO_TESSERACT, Language, type OCRCheckResult, type OCRCheckerConfig, batchCheckImages, checkImageForProfanity, createOCRChecker, languagesToTesseract };