namespace-guard 0.20.0 → 0.21.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/dist/cli.js +4 -2
- package/dist/cli.mjs +4 -2
- package/dist/confusable-weights.d.mts +5 -3
- package/dist/confusable-weights.d.ts +5 -3
- package/dist/confusable-weights.js +807 -5035
- package/dist/confusable-weights.mjs +807 -5035
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +5 -3
- package/dist/index.mjs +5 -3
- package/dist/profanity-en.js +4 -2
- package/dist/profanity-en.mjs +4 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8931,6 +8931,7 @@ var COMPOSABILITY_VECTORS = NFKC_TR39_DIVERGENCE_VECTORS;
|
|
|
8931
8931
|
var COMPOSABILITY_VECTORS_COUNT = COMPOSABILITY_VECTORS.length;
|
|
8932
8932
|
var DEFAULT_IGNORABLE_RE = /[\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5\u180B-\u180F\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8\u{1BCA0}-\u{1BCA3}\u{1D173}-\u{1D17A}\u{E0000}-\u{E0FFF}]/gu;
|
|
8933
8933
|
var DEFAULT_IGNORABLE_SINGLE_RE = new RegExp(DEFAULT_IGNORABLE_RE.source, "u");
|
|
8934
|
+
var DIACRITIC_RE = /[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/gu;
|
|
8934
8935
|
var LETTER_RE = /\p{L}/u;
|
|
8935
8936
|
var LATIN_SCRIPT_RE = /\p{Script=Latin}/u;
|
|
8936
8937
|
var SCRIPT_DETECTORS = [
|
|
@@ -9115,13 +9116,14 @@ function buildInsertionStep(ch, fromIndex, toIndex) {
|
|
|
9115
9116
|
}
|
|
9116
9117
|
function skeleton(input, options) {
|
|
9117
9118
|
const map = options?.map ?? CONFUSABLE_MAP_FULL;
|
|
9118
|
-
|
|
9119
|
+
const dropMarks = (v) => options?.ignoreDiacritics ? v.replace(DIACRITIC_RE, "") : v;
|
|
9120
|
+
let s = dropMarks(input.normalize("NFD"));
|
|
9119
9121
|
s = s.replace(DEFAULT_IGNORABLE_RE, "");
|
|
9120
9122
|
let result = "";
|
|
9121
9123
|
for (const ch of s) {
|
|
9122
9124
|
result += map[ch] ?? ch;
|
|
9123
9125
|
}
|
|
9124
|
-
result = result.normalize("NFD");
|
|
9126
|
+
result = dropMarks(result.normalize("NFD"));
|
|
9125
9127
|
return result.toLowerCase();
|
|
9126
9128
|
}
|
|
9127
9129
|
function confusableDistance(a, b, options) {
|
package/dist/cli.mjs
CHANGED
|
@@ -8908,6 +8908,7 @@ var COMPOSABILITY_VECTORS = NFKC_TR39_DIVERGENCE_VECTORS;
|
|
|
8908
8908
|
var COMPOSABILITY_VECTORS_COUNT = COMPOSABILITY_VECTORS.length;
|
|
8909
8909
|
var DEFAULT_IGNORABLE_RE = /[\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5\u180B-\u180F\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8\u{1BCA0}-\u{1BCA3}\u{1D173}-\u{1D17A}\u{E0000}-\u{E0FFF}]/gu;
|
|
8910
8910
|
var DEFAULT_IGNORABLE_SINGLE_RE = new RegExp(DEFAULT_IGNORABLE_RE.source, "u");
|
|
8911
|
+
var DIACRITIC_RE = /[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/gu;
|
|
8911
8912
|
var LETTER_RE = /\p{L}/u;
|
|
8912
8913
|
var LATIN_SCRIPT_RE = /\p{Script=Latin}/u;
|
|
8913
8914
|
var SCRIPT_DETECTORS = [
|
|
@@ -9092,13 +9093,14 @@ function buildInsertionStep(ch, fromIndex, toIndex) {
|
|
|
9092
9093
|
}
|
|
9093
9094
|
function skeleton(input, options) {
|
|
9094
9095
|
const map = options?.map ?? CONFUSABLE_MAP_FULL;
|
|
9095
|
-
|
|
9096
|
+
const dropMarks = (v) => options?.ignoreDiacritics ? v.replace(DIACRITIC_RE, "") : v;
|
|
9097
|
+
let s = dropMarks(input.normalize("NFD"));
|
|
9096
9098
|
s = s.replace(DEFAULT_IGNORABLE_RE, "");
|
|
9097
9099
|
let result = "";
|
|
9098
9100
|
for (const ch of s) {
|
|
9099
9101
|
result += map[ch] ?? ch;
|
|
9100
9102
|
}
|
|
9101
|
-
result = result.normalize("NFD");
|
|
9103
|
+
result = dropMarks(result.normalize("NFD"));
|
|
9102
9104
|
return result.toLowerCase();
|
|
9103
9105
|
}
|
|
9104
9106
|
function confusableDistance(a, b, options) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ConfusableWeights } from './index.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Measured visual similarity weights for
|
|
5
|
-
* scored across 245 fonts using vector-outline raycasting (RaySpace).
|
|
4
|
+
* Measured visual similarity weights for 372 confusable pairs, from confusable-vision release 2026.09.24.
|
|
6
5
|
*
|
|
7
|
-
* Each
|
|
6
|
+
* Each pair was found alike by RaySpace at the size and baseline position the two glyphs have in running text,
|
|
7
|
+
* within one font or across fonts (a rare-script character in its fallback font against Latin in a common text
|
|
8
|
+
* font). danger and stableDanger are the share of text fonts (or font combinations) where the pair is alike, and
|
|
9
|
+
* cost is 1 minus that share. Identifier property flags describe the source character.
|
|
8
10
|
*
|
|
9
11
|
* Import from "namespace-guard/confusable-weights" to use with confusableDistance().
|
|
10
12
|
*
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ConfusableWeights } from './index.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Measured visual similarity weights for
|
|
5
|
-
* scored across 245 fonts using vector-outline raycasting (RaySpace).
|
|
4
|
+
* Measured visual similarity weights for 372 confusable pairs, from confusable-vision release 2026.09.24.
|
|
6
5
|
*
|
|
7
|
-
* Each
|
|
6
|
+
* Each pair was found alike by RaySpace at the size and baseline position the two glyphs have in running text,
|
|
7
|
+
* within one font or across fonts (a rare-script character in its fallback font against Latin in a common text
|
|
8
|
+
* font). danger and stableDanger are the share of text fonts (or font combinations) where the pair is alike, and
|
|
9
|
+
* cost is 1 minus that share. Identifier property flags describe the source character.
|
|
8
10
|
*
|
|
9
11
|
* Import from "namespace-guard/confusable-weights" to use with confusableDistance().
|
|
10
12
|
*
|