text-sanctifier 1.0.18 โ†’ 1.0.20

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 CHANGED
@@ -1,167 +1,163 @@
1
- # text-sanctifier
2
-
3
- [![npm](https://img.shields.io/npm/v/text-sanctifier)](https://www.npmjs.com/package/text-sanctifier)
4
- [![gzip size](https://img.shields.io/bundlephobia/minzip/text-sanctifier)](https://bundlephobia.com/package/text-sanctifier)
5
- [![downloads](https://img.shields.io/npm/dw/text-sanctifier)](https://www.npmjs.com/package/text-sanctifier)
6
- [![GitHub stars](https://img.shields.io/github/stars/iWhatty/text-sanctifier?style=social)](https://github.com/iWhatty/text-sanctifier)
7
-
8
- Brutal text normalizer and invisible Unicode scrubber for modern web projects.
9
-
10
- * Minified: (3.70 KB)
11
- * Gzipped (GCC): (1.66 KB)
12
-
13
- ## Features
14
-
15
- * Purges zero-width Unicode garbage
16
- * Normalizes line endings (CRLF, CR, LF) โ†’ LF
17
- * Collapses unwanted spaces and paragraphs
18
- * Nukes control characters (if enabled)
19
- * Smart normalization of typographic junk (quotes, dashes, bullets, full-width punctuation)
20
- * Keyboard-only filtering (retain printable ASCII + full emoji sequences)
21
-
22
- * Preserves ZWJ emoji clusters (๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ)
23
- * Preserves VS16 emoji presentation variants (โœŒ๏ธ, โ€ผ๏ธ)
24
- * Configurable via fine-grained flags or ready-made presets
25
- * Includes strict, loose, and keyboard-only modes
26
- * Deterministic RegExp usage (no global `lastIndex` state leaks)
27
-
28
- ## Security notes
29
-
30
- - **Not an HTML/XSS sanitizer.** This library normalizes and filters plain text.
31
- - If you need to render **untrusted content**, render it as text (e.g. `textContent`), not HTML (`innerHTML`).
32
- - If you need to sanitize **HTML**, use a dedicated HTML sanitizer (e.g. DOMPurify / sanitize-html).
33
- - Like any text-processing library, extremely large untrusted inputs can be used for CPU/DoS pressure; consider input size limits in high-risk environments.
34
-
35
- ## Install
36
-
37
- ```bash
38
- npm install text-sanctifier
39
- ```
40
-
41
- ## Runtime Requirements
42
-
43
- Requires modern JavaScript runtime with ES2020+ support.
44
-
45
- * Node.js 14+
46
- * Modern evergreen browsers
47
-
48
- ---
49
-
50
- ## ๐Ÿ“ฆ Package & Build Info
51
-
52
- * **Source (`src/`)**: ES2020+ ESM modules with JSDoc
53
- * **Browser Build (`dist/`)**: Minified ESM bundle for `<script type="module">`
54
- * **Tree-shaking Friendly**: Fully optimized with `sideEffects: false`
55
- * **Zero Transpilation**: No built-in polyfills or runtime overhead
56
- * **Bundler Ready**: Works great with Vite, Rollup, Webpack, Parcel, etc.
57
-
58
- ---
59
-
60
- ## ๐Ÿ”ง Quick Usage
61
-
62
- ### Custom Config
63
-
64
- ```js
65
- import { summonSanctifier } from 'text-sanctifier';
66
-
67
- const clean = summonSanctifier({
68
- purgeInvisibleChars: true,
69
- purgeEmojis: true,
70
- collapseSpaces: true,
71
- collapseNewLines: true,
72
- preserveParagraphs: true,
73
- finalTrim: true,
74
- });
75
-
76
- const output = clean(rawText);
77
- ```
78
-
79
- ### Strict Preset
80
-
81
- ```js
82
- const output = summonSanctifier.strict(rawText);
83
- ```
84
-
85
- ### Loose Preset
86
-
87
- ```js
88
- const output = summonSanctifier.loose(rawText);
89
- ```
90
-
91
- ### Keyboard-Only (No Emojis)
92
-
93
- ```js
94
- const output = summonSanctifier.keyboardOnly(userInput);
95
- ```
96
-
97
- ### Keyboard-Only (With Emojis)
98
-
99
- ```js
100
- const output = summonSanctifier.keyboardOnlyEmoji(commentText);
101
- ```
102
-
103
- ---
104
-
105
- ## ๐Ÿ” Unicode Trash Detection
106
-
107
- ```js
108
- import { inspectText } from 'text-sanctifier';
109
-
110
- const report = inspectText(input);
111
-
112
- /*
113
- {
114
- hasControlChars: true,
115
- hasInvisibleChars: true,
116
- hasMixedNewlines: false,
117
- newlineStyle: 'LF',
118
- hasEmojis: true,
119
- hasNonKeyboardChars: false,
120
- summary: [
121
- 'Control characters detected.',
122
- 'Invisible Unicode characters detected.',
123
- 'Emojis detected.',
124
- 'Consistent newline style: LF'
125
- ]
126
- }
127
- */
128
- ```
129
-
130
- Use `inspectText` to preflight text content before rendering, storing, or linting. It's a diagnostic tool to help inform sanitization needs.
131
-
132
- Pass the report to `getRecommendedSanctifierOptions(report)` to auto-generate config flags for `summonSanctifier()`.
133
-
134
- ---
135
-
136
- ## API
137
-
138
- ### `summonSanctifier(options?: SanctifyOptions): (text: string) => string`
139
-
140
- Creates a reusable sanitizer from an option object.
141
-
142
- ### `summonSanctifier.strict`
143
-
144
- Aggressively purges: emojis, control characters, extra spacing, and newlines.
145
-
146
- ### `summonSanctifier.loose`
147
-
148
- Gently normalizes spacing and newlines while preserving emojis and paragraphs.
149
-
150
- ### `summonSanctifier.keyboardOnly`
151
-
152
- Restricts to printable ASCII only (removes emojis).
153
-
154
- ### `summonSanctifier.keyboardOnlyEmoji`
155
-
156
- Restricts to printable ASCII + full emoji sequences.
157
- Preserves ZWJ emoji clusters and emoji presentation variants.
158
-
159
- ### `inspectText(text: string): UnicodeTrashReport`
160
-
161
- Returns a structural report of control codes, invisible chars, newline styles, and more.
162
-
163
- ---
164
-
165
- ## License
166
-
167
- --{DR.WATT v3.0}--
1
+ # text-sanctifier
2
+
3
+ [![npm](https://img.shields.io/npm/v/text-sanctifier)](https://www.npmjs.com/package/text-sanctifier)
4
+ [![downloads](https://img.shields.io/npm/dm/text-sanctifier)](https://www.npmjs.com/package/text-sanctifier)
5
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/text-sanctifier)](https://bundlephobia.com/package/text-sanctifier)
6
+ [![license](https://img.shields.io/npm/l/text-sanctifier)](https://github.com/iWhatty/text-sanctifier/blob/main/LICENSE)
7
+ [![stars](https://img.shields.io/github/stars/iWhatty/text-sanctifier?style=social)](https://github.com/iWhatty/text-sanctifier)
8
+
9
+ Brutal text normalizer and invisible Unicode scrubber for modern web projects. ~1.66 KB gzipped.
10
+
11
+ ## Features
12
+
13
+ - Purges zero-width Unicode garbage
14
+ - Normalizes line endings (CRLF, CR, LF) to LF
15
+ - Collapses unwanted spaces and paragraphs
16
+ - Nukes control characters (if enabled)
17
+ - Smart normalization of typographic junk (quotes, dashes, bullets, full-width punctuation)
18
+ - Keyboard-only filtering (retain printable ASCII + full emoji sequences)
19
+ - Preserves ZWJ emoji clusters (๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ)
20
+ - Preserves VS16 emoji presentation variants (โœŒ๏ธ, โ€ผ๏ธ)
21
+ - Configurable via fine-grained flags or ready-made presets
22
+ - Includes strict, loose, and keyboard-only modes
23
+ - Deterministic RegExp usage (no global `lastIndex` state leaks)
24
+
25
+ ---
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ pnpm add text-sanctifier
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Quick start
36
+
37
+ **Custom config:**
38
+
39
+ ```js
40
+ import { summonSanctifier } from 'text-sanctifier';
41
+
42
+ const clean = summonSanctifier({
43
+ purgeInvisibleChars: true,
44
+ purgeEmojis: true,
45
+ collapseSpaces: true,
46
+ collapseNewLines: true,
47
+ preserveParagraphs: true,
48
+ finalTrim: true,
49
+ });
50
+
51
+ const output = clean(rawText);
52
+ ```
53
+
54
+ **Strict preset:**
55
+
56
+ ```js
57
+ const output = summonSanctifier.strict(rawText);
58
+ ```
59
+
60
+ **Loose preset:**
61
+
62
+ ```js
63
+ const output = summonSanctifier.loose(rawText);
64
+ ```
65
+
66
+ **Keyboard-only (no emojis):**
67
+
68
+ ```js
69
+ const output = summonSanctifier.keyboardOnly(userInput);
70
+ ```
71
+
72
+ **Keyboard-only (with emojis):**
73
+
74
+ ```js
75
+ const output = summonSanctifier.keyboardOnlyEmoji(commentText);
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Security notes
81
+
82
+ - **Not an HTML/XSS sanitizer.** This library normalizes and filters plain text.
83
+ - If you need to render **untrusted content**, render it as text (e.g. `textContent`), not HTML (`innerHTML`).
84
+ - If you need to sanitize **HTML**, use a dedicated HTML sanitizer (e.g. DOMPurify / sanitize-html).
85
+ - Like any text-processing library, extremely large untrusted inputs can be used for CPU/DoS pressure; consider input size limits in high-risk environments.
86
+
87
+ ---
88
+
89
+ ## API
90
+
91
+ ### `summonSanctifier(options?: SanctifyOptions): (text: string) => string`
92
+
93
+ Creates a reusable sanitizer from an option object.
94
+
95
+ ### `summonSanctifier.strict`
96
+
97
+ Aggressively purges: emojis, control characters, extra spacing, and newlines.
98
+
99
+ ### `summonSanctifier.loose`
100
+
101
+ Gently normalizes spacing and newlines while preserving emojis and paragraphs.
102
+
103
+ ### `summonSanctifier.keyboardOnly`
104
+
105
+ Restricts to printable ASCII only (removes emojis).
106
+
107
+ ### `summonSanctifier.keyboardOnlyEmoji`
108
+
109
+ Restricts to printable ASCII + full emoji sequences. Preserves ZWJ emoji clusters and emoji presentation variants.
110
+
111
+ ### `inspectText(text: string): UnicodeTrashReport`
112
+
113
+ Returns a structural report of control codes, invisible chars, newline styles, and more.
114
+
115
+ ```js
116
+ import { inspectText } from 'text-sanctifier';
117
+
118
+ const report = inspectText(input);
119
+
120
+ /*
121
+ {
122
+ hasControlChars: true,
123
+ hasInvisibleChars: true,
124
+ hasMixedNewlines: false,
125
+ newlineStyle: 'LF',
126
+ hasEmojis: true,
127
+ hasNonKeyboardChars: false,
128
+ summary: [
129
+ 'Control characters detected.',
130
+ 'Invisible Unicode characters detected.',
131
+ 'Emojis detected.',
132
+ 'Consistent newline style: LF'
133
+ ]
134
+ }
135
+ */
136
+ ```
137
+
138
+ Use `inspectText` to preflight text content before rendering, storing, or linting. It's a diagnostic tool to help inform sanitization needs. Pass the report to `getRecommendedSanctifierOptions(report)` to auto-generate config flags for `summonSanctifier()`.
139
+
140
+ ---
141
+
142
+ ## Notes
143
+
144
+ ### Runtime requirements
145
+
146
+ Requires a modern JavaScript runtime with ES2020+ support:
147
+
148
+ - Node.js 14+
149
+ - Modern evergreen browsers
150
+
151
+ ### Package and build info
152
+
153
+ - **Source (`src/`):** ES2020+ ESM modules with JSDoc
154
+ - **Browser build (`dist/`):** Minified ESM bundle for `<script type="module">`
155
+ - **Tree-shake friendly:** ships `sideEffects: false`
156
+ - **Zero transpilation:** no built-in polyfills or runtime overhead
157
+ - **Bundler ready:** works with Vite, Rollup, Webpack, Parcel, esbuild
158
+
159
+ ---
160
+
161
+ ## License
162
+
163
+ Licensed under AGPL-3.0 with WATT3D Additional Terms. See [LICENSE](./LICENSE) and [ADDITIONAL_TERMS.md](./ADDITIONAL_TERMS.md). Commercial AI/model-training use requires compliance with those terms or a separate WATT3D license. ยฉ WATT3D.
package/package.json CHANGED
@@ -1,63 +1,69 @@
1
- {
2
- "name": "text-sanctifier",
3
- "version": "1.0.18",
4
- "type": "module",
5
- "description": "A brutal text normalizer and invisible trash scrubber for modern web projects.",
6
- "main": "./src/index.js",
7
- "module": "./src/index.js",
8
- "browser": "./dist/text-sanctifier.min.js",
9
- "files": [
10
- "src",
11
- "dist/text-sanctifier.min.js",
12
- "dist/types",
13
- "LICENSE.md",
14
- "README.md"
15
- ],
16
- "exports": {
17
- ".": {
18
- "types": "./dist/types/index.d.ts",
19
- "default": "./src/index.js"
20
- },
21
- "./browser": {
22
- "default": "./dist/text-sanctifier.min.js"
23
- }
24
- },
25
- "types": "./dist/types/index.d.ts",
26
- "sideEffects": false,
27
- "scripts": {
28
- "build": "node scripts/buildc.js",
29
- "build:types": "tsc -p tsconfig.types.json",
30
- "test": "node tests/sanctifyText.test.js",
31
- "test-min": "node tests/sanctifyText.test.min.js",
32
- "ci": "npm run test && npm run build && npm run build:types && npm run test-min"
33
- },
34
- "keywords": [
35
- "text",
36
- "sanitize",
37
- "normalize",
38
- "invisible",
39
- "scrubber",
40
- "unicode",
41
- "clean",
42
- "sanctify"
43
- ],
44
- "author": "๐Ÿ‘พDr.Watt๐Ÿ‘พ <WATT3D@protonmail.com>",
45
- "license": "๐Ÿ‘พDr.Watt๐Ÿ‘พ License v3.0",
46
- "repository": {
47
- "type": "git",
48
- "url": "git+https://github.com/iWhatty/text-sanctifier.git"
49
- },
50
- "bugs": {
51
- "url": "https://github.com/iWhatty/text-sanctifier/issues"
52
- },
53
- "homepage": "https://github.com/iWhatty/text-sanctifier#readme",
54
- "directories": {
55
- "test": "tests"
56
- },
57
- "devDependencies": {
58
- "esbuild": "^0.25.3",
59
- "google-closure-compiler": "^20240317.0.0",
60
- "terser": "^5.39.0",
61
- "typescript": "^5.9.3"
62
- }
63
- }
1
+ {
2
+ "name": "text-sanctifier",
3
+ "version": "1.0.20",
4
+ "type": "module",
5
+ "description": "A brutal text normalizer and invisible trash scrubber for modern web projects.",
6
+ "engines": {
7
+ "node": ">=18"
8
+ },
9
+ "main": "./src/index.js",
10
+ "module": "./src/index.js",
11
+ "browser": "./dist/text-sanctifier.min.js",
12
+ "files": [
13
+ "src",
14
+ "dist/text-sanctifier.min.js",
15
+ "dist/types",
16
+ "LICENSE",
17
+ "README.md",
18
+ "ADDITIONAL_TERMS.md",
19
+ "robots.txt"
20
+ ],
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/types/index.d.ts",
24
+ "default": "./src/index.js"
25
+ },
26
+ "./browser": {
27
+ "types": "./dist/types/index.d.ts",
28
+ "default": "./dist/text-sanctifier.min.js"
29
+ }
30
+ },
31
+ "types": "./dist/types/index.d.ts",
32
+ "sideEffects": false,
33
+ "scripts": {
34
+ "build": "node scripts/buildc.js",
35
+ "build:types": "tsc -p tsconfig.types.json",
36
+ "test": "node tests/sanctifyText.test.js",
37
+ "test-min": "node tests/sanctifyText.test.min.js",
38
+ "ci": "npm run test && npm run build && npm run build:types && npm run test-min"
39
+ },
40
+ "keywords": [
41
+ "text",
42
+ "sanitize",
43
+ "normalize",
44
+ "invisible",
45
+ "scrubber",
46
+ "unicode",
47
+ "clean",
48
+ "sanctify"
49
+ ],
50
+ "author": "WATT3D <WATT3D@protonmail.com>",
51
+ "license": "SEE LICENSE IN LICENSE",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/iWhatty/text-sanctifier.git"
55
+ },
56
+ "bugs": {
57
+ "url": "https://github.com/iWhatty/text-sanctifier/issues"
58
+ },
59
+ "homepage": "https://github.com/iWhatty/text-sanctifier#readme",
60
+ "directories": {
61
+ "test": "tests"
62
+ },
63
+ "devDependencies": {
64
+ "esbuild": "^0.25.3",
65
+ "google-closure-compiler": "^20240317.0.0",
66
+ "terser": "^5.39.0",
67
+ "typescript": "^5.9.3"
68
+ }
69
+ }
package/robots.txt ADDED
@@ -0,0 +1,79 @@
1
+ # WATT3D โ€” AI scraping policy
2
+ #
3
+ # This file enumerates known AI / LLM training and inference crawlers
4
+ # that the WATT3D AI Training Rider does not consent to. See
5
+ # ./ADDITIONAL_TERMS.md for the legal scope and definitions.
6
+ #
7
+ # Honoring robots.txt is voluntary. The rider applies whether or not
8
+ # a bot respects this file. The enumeration is non-exhaustive โ€” bots
9
+ # not listed here are still bound by the rider if they perform
10
+ # Training Use as defined in ADDITIONAL_TERMS.md ยง1.
11
+
12
+ User-agent: GPTBot
13
+ Disallow: /
14
+
15
+ User-agent: ChatGPT-User
16
+ Disallow: /
17
+
18
+ User-agent: OAI-SearchBot
19
+ Disallow: /
20
+
21
+ User-agent: anthropic-ai
22
+ Disallow: /
23
+
24
+ User-agent: ClaudeBot
25
+ Disallow: /
26
+
27
+ User-agent: Claude-Web
28
+ Disallow: /
29
+
30
+ User-agent: Claude-SearchBot
31
+ Disallow: /
32
+
33
+ User-agent: Google-Extended
34
+ Disallow: /
35
+
36
+ User-agent: Applebot-Extended
37
+ Disallow: /
38
+
39
+ User-agent: Meta-ExternalAgent
40
+ Disallow: /
41
+
42
+ User-agent: Meta-ExternalFetcher
43
+ Disallow: /
44
+
45
+ User-agent: FacebookBot
46
+ Disallow: /
47
+
48
+ User-agent: CCBot
49
+ Disallow: /
50
+
51
+ User-agent: PerplexityBot
52
+ Disallow: /
53
+
54
+ User-agent: Perplexity-User
55
+ Disallow: /
56
+
57
+ User-agent: cohere-ai
58
+ Disallow: /
59
+
60
+ User-agent: Bytespider
61
+ Disallow: /
62
+
63
+ User-agent: Amazonbot
64
+ Disallow: /
65
+
66
+ User-agent: Omgilibot
67
+ Disallow: /
68
+
69
+ User-agent: AI2Bot
70
+ Disallow: /
71
+
72
+ User-agent: Diffbot
73
+ Disallow: /
74
+
75
+ # Everyone else: full access. Search engines and human-driven crawlers
76
+ # remain welcome.
77
+
78
+ User-agent: *
79
+ Allow: /
package/src/index.js CHANGED
@@ -1,12 +1,12 @@
1
- // src/index.js
2
-
3
-
4
- import { inspectText, getRecommendedSanctifierOptions } from './inspectText.js';
5
- export { inspectText, getRecommendedSanctifierOptions };
6
-
7
- import { summonSanctifier } from './sanctifyText.js';
8
- export { summonSanctifier };
9
-
10
-
11
- // In Future: export helpers for power users
12
- // export { purgeInvisibleTrash, purgeEmojisCharacters, normalizeNewlines, trimSpacesAroundNewlines, collapseParagraphs, collapseExtraSpaces, purgeControlCharacters } from './sanctifyText.js';
1
+ // src/index.js
2
+
3
+
4
+ import { inspectText, getRecommendedSanctifierOptions } from './inspectText.js';
5
+ export { inspectText, getRecommendedSanctifierOptions };
6
+
7
+ import { summonSanctifier } from './sanctifyText.js';
8
+ export { summonSanctifier };
9
+
10
+
11
+ // In Future: export helpers for power users
12
+ // export { purgeInvisibleTrash, purgeEmojisCharacters, normalizeNewlines, trimSpacesAroundNewlines, collapseParagraphs, collapseExtraSpaces, purgeControlCharacters } from './sanctifyText.js';