text-sanctifier 1.1.1 → 1.3.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.
@@ -14,7 +14,12 @@ export function inspectText(text: string): UnicodeTrashReport;
14
14
  * - `nul`: U+0000
15
15
  * - `c0_control`: U+0001–U+001F except tab, LF and CR; and U+007F
16
16
  * - `c1_control`: U+0080–U+009F
17
+ * - `invisible_format`: soft hyphen U+00AD, U+034F, U+180E, invisible operators U+2061–U+2064
18
+ * - `hangul_filler`: U+115F, U+1160, U+3164, U+FFA0 (letters that render blank)
19
+ * - `variation_selector`: U+FE00–U+FE0F, U+E0100–U+E01EF (including VS16 in emoji)
20
+ * - `tag`: U+E0000–U+E007F (tag characters, used for "ASCII smuggling")
17
21
  *
22
+ * `codePoint` is the full code point; `offset` and `column` count UTF-16 units.
18
23
  * Every occurrence is counted; only the first `maxFindings` are listed.
19
24
  * One pass over the string, no regex, no copy.
20
25
  *
@@ -57,10 +62,11 @@ export type UnicodeTrashReport = {
57
62
  hasNonKeyboardChars: boolean;
58
63
  summary: string[];
59
64
  };
60
- export type TrashCategory = "bidi_control" | "zero_width" | "nonbreaking_space" | "bom" | "nul" | "c0_control" | "c1_control";
65
+ export type TrashCategory = "bidi_control" | "zero_width" | "nonbreaking_space" | "bom" | "nul" | "c0_control" | "c1_control" | "invisible_format" | "hangul_filler" | "variation_selector" | "tag";
61
66
  /**
62
67
  * One located character.
63
- * - `offset`: 0-based UTF-16 index into the input (a JS string index).
68
+ * - `offset`: 0-based UTF-16 index into the input (a JS string index); for a code point
69
+ * above U+FFFF, the index of its high surrogate.
64
70
  * - `line`: 1-based; lines end at LF, CR, or CRLF (counted once).
65
71
  * - `column`: 1-based, in UTF-16 code units from the start of the line.
66
72
  * - `atStart`: present on `bom` findings only; true at offset 0, where a BOM is legitimate.
@@ -81,6 +87,10 @@ export type TrashCounts = {
81
87
  nul: number;
82
88
  c0_control: number;
83
89
  c1_control: number;
90
+ invisible_format: number;
91
+ hangul_filler: number;
92
+ variation_selector: number;
93
+ tag: number;
84
94
  };
85
95
  export type DetailedTrashReport = {
86
96
  /**
@@ -91,7 +91,7 @@ export namespace summonSanctifier {
91
91
  * ⚠️ Note: This is plain-text normalization/filtering — not an HTML/XSS sanitizer.
92
92
  *
93
93
  * @param {string} text
94
- * @param {boolean} [purgeInvisibleChars=false] - Remove ZWSP, NBSP, bidi, etc.
94
+ * @param {boolean} [purgeInvisibleChars=false] - Remove ZWSP, NBSP, bidi, tags, variation selectors, etc.
95
95
  * @param {boolean} [purgeEmojis=false] - Remove emoji characters entirely.
96
96
  * @param {boolean} [nukeControls=false] - Remove non-whitespace control characters.
97
97
  * @param {boolean} [keyboardOnlyFilter=false] - Keep printable ASCII + full emoji sequences only (drops other Unicode).
@@ -121,9 +121,13 @@ export function normalizeTypographicJank(text: string): string;
121
121
  * Purges invisible Unicode "trash" characters and removes them.
122
122
  *
123
123
  * Targets:
124
- * - Non-breaking spaces (\u00A0)
125
- * - Zero-width spaces and miscellaneous Unicode spaces (\u2000–\u200D, \u202F, \u2060, \u3000, \uFEFF)
126
- * - Bidi controls: marks, embeddings/overrides and isolates (\u061C, \u200E, \u200F, \u202A–\u202E, \u2066–\u2069)
124
+ * - Non-breaking spaces ( )
125
+ * - Zero-width spaces and miscellaneous Unicode spaces ( –‍,  , ⁠,  , )
126
+ * - Bidi controls: marks, embeddings/overrides and isolates (؜, ‎, ‏, ‪–‮, ⁦–⁩)
127
+ * - Invisible format characters: soft hyphen, CGJ, Mongolian vowel separator, invisible operators (­, ͏, ᠎, ⁡–⁤)
128
+ * - Hangul fillers (ᅟ, ᅠ, ㅤ, ᅠ)
129
+ * - Variation selectors (︀–️, \u{E0100}–\u{E01EF}), including VS16 in emoji
130
+ * - Tag characters (\u{E0000}–\u{E007F}), used for "ASCII smuggling"
127
131
  *
128
132
  * @param {string} text
129
133
  * @returns {string}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "text-sanctifier",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "A brutal text normalizer and invisible trash scrubber for modern web projects.",
6
6
  "engines": {
@@ -9,8 +9,12 @@
9
9
  "main": "./src/index.js",
10
10
  "module": "./src/index.js",
11
11
  "browser": "./dist/text-sanctifier.min.js",
12
+ "bin": {
13
+ "text-sanctifier": "bin/text-sanctifier.js"
14
+ },
12
15
  "files": [
13
16
  "src",
17
+ "bin",
14
18
  "dist/text-sanctifier.min.js",
15
19
  "dist/types",
16
20
  "LICENSE",
@@ -34,7 +38,7 @@
34
38
  "build": "node scripts/buildc.js",
35
39
  "build:types": "tsc -p tsconfig.types.json",
36
40
  "test:types": "tsc -p tests/types/tsconfig.json",
37
- "test": "node tests/sanctifyText.test.js && node tests/inspectTextDetailed.test.js",
41
+ "test": "node tests/sanctifyText.test.js && node tests/inspectTextDetailed.test.js && node tests/cli.test.js",
38
42
  "test-min": "node tests/sanctifyText.test.min.js",
39
43
  "ci": "npm run test && npm run build && npm run build:types && npm run test:types && npm run test-min"
40
44
  },