text-sanctifier 1.0.17 → 1.0.19
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/ADDITIONAL_TERMS.md +122 -0
- package/LICENSE +694 -0
- package/README.md +163 -163
- package/dist/text-sanctifier.min.js +9 -7
- package/dist/types/index.d.ts +4 -0
- package/dist/types/inspectText.d.ts +38 -0
- package/dist/types/sanctifyText.d.ts +167 -0
- package/package.json +65 -55
- package/robots.txt +79 -0
- package/src/index.d.ts +4 -116
- package/src/index.js +12 -12
- package/src/inspectText.js +175 -171
- package/src/sanctifyText.js +507 -451
- package/LICENSE.md +0 -285
package/package.json
CHANGED
|
@@ -1,55 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "text-sanctifier",
|
|
3
|
+
"version": "1.0.19",
|
|
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",
|
|
14
|
+
"README.md",
|
|
15
|
+
"ADDITIONAL_TERMS.md",
|
|
16
|
+
"robots.txt"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/types/index.d.ts",
|
|
21
|
+
"default": "./src/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./browser": {
|
|
24
|
+
"default": "./dist/text-sanctifier.min.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"types": "./dist/types/index.d.ts",
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "node scripts/buildc.js",
|
|
31
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
32
|
+
"test": "node tests/sanctifyText.test.js",
|
|
33
|
+
"test-min": "node tests/sanctifyText.test.min.js",
|
|
34
|
+
"ci": "npm run test && npm run build && npm run build:types && npm run test-min"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"text",
|
|
38
|
+
"sanitize",
|
|
39
|
+
"normalize",
|
|
40
|
+
"invisible",
|
|
41
|
+
"scrubber",
|
|
42
|
+
"unicode",
|
|
43
|
+
"clean",
|
|
44
|
+
"sanctify"
|
|
45
|
+
],
|
|
46
|
+
"author": "WATT3D <WATT3D@protonmail.com>",
|
|
47
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/iWhatty/text-sanctifier.git"
|
|
51
|
+
},
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/iWhatty/text-sanctifier/issues"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://github.com/iWhatty/text-sanctifier#readme",
|
|
56
|
+
"directories": {
|
|
57
|
+
"test": "tests"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"esbuild": "^0.25.3",
|
|
61
|
+
"google-closure-compiler": "^20240317.0.0",
|
|
62
|
+
"terser": "^5.39.0",
|
|
63
|
+
"typescript": "^5.9.3"
|
|
64
|
+
}
|
|
65
|
+
}
|
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.d.ts
CHANGED
|
@@ -1,116 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
purgeInvisibleChars?: boolean;
|
|
6
|
-
|
|
7
|
-
/** Remove emoji characters */
|
|
8
|
-
purgeEmojis?: boolean;
|
|
9
|
-
|
|
10
|
-
/** Nuke hidden control characters (excluding whitespace like \n and \t) */
|
|
11
|
-
nukeControls?: boolean;
|
|
12
|
-
|
|
13
|
-
/** Restrict to printable ASCII (+ emoji if `purgeEmojis` is false) */
|
|
14
|
-
keyboardOnlyFilter?: boolean;
|
|
15
|
-
|
|
16
|
-
/** Normalize all newline sequences to LF (`\n`) */
|
|
17
|
-
normalizeNewlines?: boolean;
|
|
18
|
-
|
|
19
|
-
/** Remove tabs and spaces before/after newline characters */
|
|
20
|
-
trimSpacesAroundNewlines?: boolean;
|
|
21
|
-
|
|
22
|
-
/** Collapse multiple consecutive newlines */
|
|
23
|
-
collapseNewLines?: boolean;
|
|
24
|
-
|
|
25
|
-
/** When collapsing newlines, preserve paragraph breaks as double `\n\n` */
|
|
26
|
-
preserveParagraphs?: boolean;
|
|
27
|
-
|
|
28
|
-
/** Collapse multiple spaces into a single space */
|
|
29
|
-
collapseSpaces?: boolean;
|
|
30
|
-
|
|
31
|
-
/** Trim leading and trailing whitespace from final result */
|
|
32
|
-
finalTrim?: boolean;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Preconfigured sanitizer function */
|
|
36
|
-
export type Sanctifier = (text: string) => string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Summon a reusable text sanitizer.
|
|
40
|
-
*/
|
|
41
|
-
export function summonSanctifier(
|
|
42
|
-
defaultOptions?: SanctifyOptions,
|
|
43
|
-
): Sanctifier;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Strict sanitizer preset:
|
|
47
|
-
* - Collapse spaces
|
|
48
|
-
* - Collapse all newlines
|
|
49
|
-
* - Nuke control characters
|
|
50
|
-
* - Purge emojis
|
|
51
|
-
*/
|
|
52
|
-
export namespace summonSanctifier {
|
|
53
|
-
const strict: Sanctifier;
|
|
54
|
-
const loose: Sanctifier;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Keeps printable ASCII and emoji.
|
|
58
|
-
* Leaves spacing soft and preserves emoji.
|
|
59
|
-
*/
|
|
60
|
-
const keyboardOnlyEmoji: Sanctifier;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Keeps printable ASCII only.
|
|
64
|
-
* Collapses whitespace and purges emoji.
|
|
65
|
-
*/
|
|
66
|
-
const keyboardOnly: Sanctifier;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Brutally normalizes and cleans a string of text.
|
|
71
|
-
*/
|
|
72
|
-
export function sanctifyText(
|
|
73
|
-
text: string,
|
|
74
|
-
purgeInvisibleChars?: boolean,
|
|
75
|
-
purgeEmojis?: boolean,
|
|
76
|
-
nukeControls?: boolean,
|
|
77
|
-
keyboardOnlyFilter?: boolean,
|
|
78
|
-
normalizeNewlines?: boolean,
|
|
79
|
-
trimSpacesAroundNewlines?: boolean,
|
|
80
|
-
collapseNewLines?: boolean,
|
|
81
|
-
preserveParagraphs?: boolean,
|
|
82
|
-
collapseSpaces?: boolean,
|
|
83
|
-
finalTrim?: boolean,
|
|
84
|
-
): string;
|
|
85
|
-
|
|
86
|
-
/** Style of newline characters detected in a string */
|
|
87
|
-
export type NewlineStyle = 'LF' | 'CRLF' | 'CR' | 'Mixed' | null;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* A structural report of anomalies found in text.
|
|
91
|
-
*/
|
|
92
|
-
export interface UnicodeTrashReport {
|
|
93
|
-
hasControlChars: boolean;
|
|
94
|
-
hasInvisibleChars: boolean;
|
|
95
|
-
hasMixedNewlines: boolean;
|
|
96
|
-
newlineStyle: NewlineStyle;
|
|
97
|
-
hasEmojis: boolean;
|
|
98
|
-
hasNonKeyboardChars: boolean;
|
|
99
|
-
summary: string[];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Analyze a string and return a report of Unicode/control character issues,
|
|
104
|
-
* invisible characters, newline styles, emojis, and more.
|
|
105
|
-
*/
|
|
106
|
-
export function inspectText(text: string): UnicodeTrashReport;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Creates a recommended set of `summonSanctifier` options based on the findings
|
|
111
|
-
* of `inspectText()`. This maps only what can be inferred automatically —
|
|
112
|
-
* user-preference settings like whitespace collapsing are left unset.
|
|
113
|
-
*/
|
|
114
|
-
export function getRecommendedSanctifierOptions(
|
|
115
|
-
report: UnicodeTrashReport
|
|
116
|
-
): SanctifyOptions;
|
|
1
|
+
import { inspectText } from './inspectText.js';
|
|
2
|
+
import { getRecommendedSanctifierOptions } from './inspectText.js';
|
|
3
|
+
import { summonSanctifier } from './sanctifyText.js';
|
|
4
|
+
export { inspectText, getRecommendedSanctifierOptions, summonSanctifier };
|
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';
|