@mailwoman/registry 11.0.0 → 11.2.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/README.md +21 -6
- package/data/manifests/artifacts.json +35 -0
- package/data/manifests/coverage.json +63 -0
- package/data/manifests/sources.lock.json +12 -0
- package/data/normalized/language-subtags.json +18518 -0
- package/docs/data-policy.md +5 -5
- package/docs/performance.md +1 -1
- package/docs/rgy1.md +5 -5
- package/lib/artifacts/bcp47/extlang.fixture.json +260 -0
- package/lib/artifacts/bcp47/extlang.ts +32 -0
- package/lib/artifacts/bcp47/grandfathered.fixture.json +28 -0
- package/lib/artifacts/bcp47/grandfathered.ts +32 -0
- package/lib/artifacts/bcp47/language.fixture.json +8278 -0
- package/lib/artifacts/bcp47/language.ts +32 -0
- package/lib/artifacts/bcp47/redundant.fixture.json +69 -0
- package/lib/artifacts/bcp47/redundant.ts +32 -0
- package/lib/artifacts/bcp47/region.fixture.json +307 -0
- package/lib/artifacts/bcp47/region.ts +32 -0
- package/lib/artifacts/bcp47/script.fixture.json +227 -0
- package/lib/artifacts/bcp47/script.ts +32 -0
- package/lib/artifacts/bcp47/variant.fixture.json +141 -0
- package/lib/artifacts/bcp47/variant.ts +32 -0
- package/lib/artifacts/country-airport-collision.ts +7 -5
- package/lib/artifacts/iata-airport/membership.ts +7 -5
- package/lib/artifacts/iata-airport/records.ts +7 -5
- package/lib/artifacts/iso3166-1/alpha2-membership.ts +7 -5
- package/lib/artifacts/iso3166-1/alpha3-membership.ts +7 -5
- package/lib/artifacts/iso3166-1/records.ts +7 -5
- package/lib/bcp47/subtag-index.ts +65 -0
- package/lib/bcp47/tag.ts +301 -0
- package/lib/errors.ts +22 -9
- package/lib/iata/airports/records.ts +3 -4
- package/lib/iata/airports/validate.ts +6 -5
- package/lib/index.ts +18 -8
- package/lib/inspect.ts +5 -5
- package/lib/iso15924/codes.ts +169 -0
- package/lib/iso15924/unicode-script.ts +124 -0
- package/lib/iso3166/alpha2.ts +5 -5
- package/lib/iso3166/alpha3.ts +6 -6
- package/lib/iso3166/records.ts +9 -8
- package/lib/iso3166/relations.ts +5 -5
- package/lib/iso639/languages.ts +88 -0
- package/lib/key.ts +9 -7
- package/lib/normalize.ts +12 -8
- package/lib/overlap/country-airport.ts +14 -12
- package/lib/rgy1/base64.ts +3 -4
- package/lib/rgy1/reader.ts +8 -7
- package/lib/rgy1/sections.generated.ts +6 -5
- package/lib/rgy1/views.ts +5 -6
- package/lib/types.ts +66 -7
- package/lib/wasm.ts +11 -9
- package/out/artifacts/bcp47/extlang.d.ts +21 -0
- package/out/artifacts/bcp47/extlang.d.ts.map +1 -0
- package/out/artifacts/bcp47/extlang.fixture.json +260 -0
- package/out/artifacts/bcp47/extlang.js +17 -0
- package/out/artifacts/bcp47/extlang.js.map +1 -0
- package/out/artifacts/bcp47/grandfathered.d.ts +21 -0
- package/out/artifacts/bcp47/grandfathered.d.ts.map +1 -0
- package/out/artifacts/bcp47/grandfathered.fixture.json +28 -0
- package/out/artifacts/bcp47/grandfathered.js +17 -0
- package/out/artifacts/bcp47/grandfathered.js.map +1 -0
- package/out/artifacts/bcp47/language.d.ts +21 -0
- package/out/artifacts/bcp47/language.d.ts.map +1 -0
- package/out/artifacts/bcp47/language.fixture.json +8278 -0
- package/out/artifacts/bcp47/language.js +17 -0
- package/out/artifacts/bcp47/language.js.map +1 -0
- package/out/artifacts/bcp47/redundant.d.ts +21 -0
- package/out/artifacts/bcp47/redundant.d.ts.map +1 -0
- package/out/artifacts/bcp47/redundant.fixture.json +69 -0
- package/out/artifacts/bcp47/redundant.js +17 -0
- package/out/artifacts/bcp47/redundant.js.map +1 -0
- package/out/artifacts/bcp47/region.d.ts +21 -0
- package/out/artifacts/bcp47/region.d.ts.map +1 -0
- package/out/artifacts/bcp47/region.fixture.json +307 -0
- package/out/artifacts/bcp47/region.js +17 -0
- package/out/artifacts/bcp47/region.js.map +1 -0
- package/out/artifacts/bcp47/script.d.ts +21 -0
- package/out/artifacts/bcp47/script.d.ts.map +1 -0
- package/out/artifacts/bcp47/script.fixture.json +227 -0
- package/out/artifacts/bcp47/script.js +17 -0
- package/out/artifacts/bcp47/script.js.map +1 -0
- package/out/artifacts/bcp47/variant.d.ts +21 -0
- package/out/artifacts/bcp47/variant.d.ts.map +1 -0
- package/out/artifacts/bcp47/variant.fixture.json +141 -0
- package/out/artifacts/bcp47/variant.js +17 -0
- package/out/artifacts/bcp47/variant.js.map +1 -0
- package/out/artifacts/country-airport-collision.d.ts +0 -8
- package/out/artifacts/country-airport-collision.d.ts.map +1 -1
- package/out/artifacts/country-airport-collision.js +6 -5
- package/out/artifacts/country-airport-collision.js.map +1 -1
- package/out/artifacts/iata-airport/membership.d.ts +0 -8
- package/out/artifacts/iata-airport/membership.d.ts.map +1 -1
- package/out/artifacts/iata-airport/membership.js +6 -5
- package/out/artifacts/iata-airport/membership.js.map +1 -1
- package/out/artifacts/iata-airport/records.d.ts +0 -8
- package/out/artifacts/iata-airport/records.d.ts.map +1 -1
- package/out/artifacts/iata-airport/records.js +6 -5
- package/out/artifacts/iata-airport/records.js.map +1 -1
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts +0 -8
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts.map +1 -1
- package/out/artifacts/iso3166-1/alpha2-membership.js +6 -5
- package/out/artifacts/iso3166-1/alpha2-membership.js.map +1 -1
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts +0 -8
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts.map +1 -1
- package/out/artifacts/iso3166-1/alpha3-membership.js +6 -5
- package/out/artifacts/iso3166-1/alpha3-membership.js.map +1 -1
- package/out/artifacts/iso3166-1/records.d.ts +0 -8
- package/out/artifacts/iso3166-1/records.d.ts.map +1 -1
- package/out/artifacts/iso3166-1/records.js +6 -5
- package/out/artifacts/iso3166-1/records.js.map +1 -1
- package/out/bcp47/subtag-index.d.ts +22 -0
- package/out/bcp47/subtag-index.d.ts.map +1 -0
- package/out/bcp47/subtag-index.js +43 -0
- package/out/bcp47/subtag-index.js.map +1 -0
- package/out/bcp47/tag.d.ts +47 -0
- package/out/bcp47/tag.d.ts.map +1 -0
- package/out/bcp47/tag.js +218 -0
- package/out/bcp47/tag.js.map +1 -0
- package/out/errors.d.ts +12 -8
- package/out/errors.d.ts.map +1 -1
- package/out/errors.js +10 -8
- package/out/errors.js.map +1 -1
- package/out/iata/airports/records.d.ts +0 -7
- package/out/iata/airports/records.d.ts.map +1 -1
- package/out/iata/airports/records.js +2 -4
- package/out/iata/airports/records.js.map +1 -1
- package/out/iata/airports/validate.d.ts +0 -8
- package/out/iata/airports/validate.d.ts.map +1 -1
- package/out/iata/airports/validate.js +5 -5
- package/out/iata/airports/validate.js.map +1 -1
- package/out/index.d.ts +13 -8
- package/out/index.d.ts.map +1 -1
- package/out/index.js +6 -12
- package/out/index.js.map +1 -1
- package/out/inspect.d.ts +2 -5
- package/out/inspect.d.ts.map +1 -1
- package/out/inspect.js +4 -5
- package/out/inspect.js.map +1 -1
- package/out/iso15924/codes.d.ts +57 -0
- package/out/iso15924/codes.d.ts.map +1 -0
- package/out/iso15924/codes.js +133 -0
- package/out/iso15924/codes.js.map +1 -0
- package/out/iso15924/unicode-script.d.ts +10 -0
- package/out/iso15924/unicode-script.d.ts.map +1 -0
- package/out/iso15924/unicode-script.js +103 -0
- package/out/iso15924/unicode-script.js.map +1 -0
- package/out/iso3166/alpha2.d.ts +0 -8
- package/out/iso3166/alpha2.d.ts.map +1 -1
- package/out/iso3166/alpha2.js +4 -5
- package/out/iso3166/alpha2.js.map +1 -1
- package/out/iso3166/alpha3.d.ts +1 -9
- package/out/iso3166/alpha3.d.ts.map +1 -1
- package/out/iso3166/alpha3.js +5 -6
- package/out/iso3166/alpha3.js.map +1 -1
- package/out/iso3166/records.d.ts +0 -11
- package/out/iso3166/records.d.ts.map +1 -1
- package/out/iso3166/records.js +8 -8
- package/out/iso3166/records.js.map +1 -1
- package/out/iso3166/relations.d.ts +0 -7
- package/out/iso3166/relations.d.ts.map +1 -1
- package/out/iso3166/relations.js +4 -5
- package/out/iso3166/relations.js.map +1 -1
- package/out/iso639/languages.d.ts +40 -0
- package/out/iso639/languages.d.ts.map +1 -0
- package/out/iso639/languages.js +54 -0
- package/out/iso639/languages.js.map +1 -0
- package/out/key.d.ts +6 -7
- package/out/key.d.ts.map +1 -1
- package/out/key.js +8 -7
- package/out/key.js.map +1 -1
- package/out/normalize.d.ts +9 -8
- package/out/normalize.d.ts.map +1 -1
- package/out/normalize.js +2 -12
- package/out/normalize.js.map +1 -1
- package/out/overlap/country-airport.d.ts +2 -16
- package/out/overlap/country-airport.d.ts.map +1 -1
- package/out/overlap/country-airport.js +13 -12
- package/out/overlap/country-airport.js.map +1 -1
- package/out/rgy1/base64.d.ts +0 -4
- package/out/rgy1/base64.d.ts.map +1 -1
- package/out/rgy1/base64.js +2 -4
- package/out/rgy1/base64.js.map +1 -1
- package/out/rgy1/reader.d.ts +0 -11
- package/out/rgy1/reader.d.ts.map +1 -1
- package/out/rgy1/reader.js +7 -7
- package/out/rgy1/reader.js.map +1 -1
- package/out/rgy1/sections.generated.d.ts +3 -5
- package/out/rgy1/sections.generated.d.ts.map +1 -1
- package/out/rgy1/sections.generated.js +5 -5
- package/out/rgy1/sections.generated.js.map +1 -1
- package/out/rgy1/views.d.ts +2 -9
- package/out/rgy1/views.d.ts.map +1 -1
- package/out/rgy1/views.js +4 -6
- package/out/rgy1/views.js.map +1 -1
- package/out/sdk/fetch.d.ts +6 -6
- package/out/sdk/fetch.d.ts.map +1 -1
- package/out/sdk/fetch.js +23 -11
- package/out/sdk/fetch.js.map +1 -1
- package/out/sdk/fetch.run.d.ts +0 -12
- package/out/sdk/fetch.run.d.ts.map +1 -1
- package/out/sdk/fetch.run.js +22 -9
- package/out/sdk/fetch.run.js.map +1 -1
- package/out/sdk/sources.d.ts +7 -16
- package/out/sdk/sources.d.ts.map +1 -1
- package/out/sdk/sources.js +34 -14
- package/out/sdk/sources.js.map +1 -1
- package/out/tools/artifact-path.d.ts +0 -5
- package/out/tools/artifact-path.d.ts.map +1 -1
- package/out/tools/artifact-path.js +2 -5
- package/out/tools/artifact-path.js.map +1 -1
- package/out/tools/bench.run.d.ts +0 -17
- package/out/tools/bench.run.d.ts.map +1 -1
- package/out/tools/bench.run.js +13 -10
- package/out/tools/bench.run.js.map +1 -1
- package/out/tools/build-wasm.run.d.ts +0 -16
- package/out/tools/build-wasm.run.d.ts.map +1 -1
- package/out/tools/build-wasm.run.js +8 -10
- package/out/tools/build-wasm.run.js.map +1 -1
- package/out/tools/generate-sections.run.d.ts +0 -11
- package/out/tools/generate-sections.run.d.ts.map +1 -1
- package/out/tools/generate-sections.run.js +5 -14
- package/out/tools/generate-sections.run.js.map +1 -1
- package/out/tools/generate.run.d.ts +0 -16
- package/out/tools/generate.run.d.ts.map +1 -1
- package/out/tools/generate.run.js +61 -17
- package/out/tools/generate.run.js.map +1 -1
- package/out/tools/language-subtags.d.ts +59 -0
- package/out/tools/language-subtags.d.ts.map +1 -0
- package/out/tools/language-subtags.js +145 -0
- package/out/tools/language-subtags.js.map +1 -0
- package/out/tools/normalize.d.ts +4 -14
- package/out/tools/normalize.d.ts.map +1 -1
- package/out/tools/normalize.js +14 -14
- package/out/tools/normalize.js.map +1 -1
- package/out/tools/normalize.run.d.ts +0 -12
- package/out/tools/normalize.run.d.ts.map +1 -1
- package/out/tools/normalize.run.js +24 -7
- package/out/tools/normalize.run.js.map +1 -1
- package/out/types.d.ts +62 -7
- package/out/types.d.ts.map +1 -1
- package/out/types.js +12 -9
- package/out/types.js.map +1 -1
- package/out/wasm.d.ts +0 -13
- package/out/wasm.d.ts.map +1 -1
- package/out/wasm.js +10 -9
- package/out/wasm.js.map +1 -1
- package/package.json +12 -4
- package/sdk/fetch.run.ts +25 -9
- package/sdk/fetch.ts +32 -12
- package/sdk/sources.ts +36 -14
- package/tools/artifact-path.ts +2 -5
- package/tools/bench.run.ts +19 -10
- package/tools/build-wasm.run.ts +9 -10
- package/tools/generate-sections.run.ts +6 -14
- package/tools/generate.run.ts +68 -17
- package/tools/language-subtags.ts +195 -0
- package/tools/normalize.run.ts +28 -7
- package/tools/normalize.ts +16 -15
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
/**
|
|
4
|
+
* ISO 15924 script codes, read from the script subtags of the IANA Language Subtag Registry.
|
|
5
|
+
*
|
|
6
|
+
* An import of this module retains the 225-row script table and no language or region row.
|
|
7
|
+
*/
|
|
8
|
+
import { scriptSubtagRows } from "#artifacts/bcp47/script";
|
|
9
|
+
import { lazySubtagIndex } from "#bcp47/subtag-index";
|
|
10
|
+
import { ParseFailure } from "#errors";
|
|
11
|
+
const index = lazySubtagIndex(scriptSubtagRows);
|
|
12
|
+
const CANONICAL = /^[A-Z][a-z]{3}$/;
|
|
13
|
+
const LETTERS = /^[A-Za-z]{4}$/;
|
|
14
|
+
/**
|
|
15
|
+
* Whether `input` is a script code the registry holds, in its canonical title case.
|
|
16
|
+
*
|
|
17
|
+
* `Latn` and `Jpan` are.
|
|
18
|
+
* `latn`, `LATN` and `Latin` are not.
|
|
19
|
+
*/
|
|
20
|
+
export function isScriptCode(input) {
|
|
21
|
+
return CANONICAL.test(input) && index().get(input) !== null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The branded script code, or the reason the input was refused.
|
|
25
|
+
*/
|
|
26
|
+
export function parseScriptCode(input) {
|
|
27
|
+
if (!LETTERS.test(input))
|
|
28
|
+
return { ok: false, reason: ParseFailure.Shape, input };
|
|
29
|
+
if (!CANONICAL.test(input))
|
|
30
|
+
return { ok: false, reason: ParseFailure.Case, input };
|
|
31
|
+
if (!isScriptCode(input))
|
|
32
|
+
return { ok: false, reason: ParseFailure.NotFound, input };
|
|
33
|
+
return { ok: true, value: input };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The record of a canonical script code, or `null`.
|
|
37
|
+
*/
|
|
38
|
+
export function getScript(code) {
|
|
39
|
+
if (!CANONICAL.test(code))
|
|
40
|
+
return null;
|
|
41
|
+
const row = index().get(code);
|
|
42
|
+
if (!row)
|
|
43
|
+
return null;
|
|
44
|
+
return {
|
|
45
|
+
code: code,
|
|
46
|
+
name: row.descriptions[0] ?? code,
|
|
47
|
+
descriptions: row.descriptions,
|
|
48
|
+
deprecated: row.deprecated ?? null,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* ISO 15924 codes that name a combination or a variant of Unicode scripts, mapped to the
|
|
53
|
+
* Unicode Script property values (short aliases) whose characters they cover.
|
|
54
|
+
*
|
|
55
|
+
* Unicode encodes the characters of a variant code, such as Fraktur `Latf`, under the base script.
|
|
56
|
+
* A combined code, such as Japanese `Jpan`, covers several scripts at once.
|
|
57
|
+
*/
|
|
58
|
+
const UNICODE_SCRIPT_EXPANSIONS = {
|
|
59
|
+
Jpan: ["Hani", "Hira", "Kana"],
|
|
60
|
+
Kore: ["Hang", "Hani"],
|
|
61
|
+
Hans: ["Hani"],
|
|
62
|
+
Hant: ["Hani"],
|
|
63
|
+
Hanb: ["Hani", "Bopo"],
|
|
64
|
+
Hrkt: ["Hira", "Kana"],
|
|
65
|
+
Latf: ["Latn"],
|
|
66
|
+
Latg: ["Latn"],
|
|
67
|
+
Aran: ["Arab"],
|
|
68
|
+
Cyrs: ["Cyrl"],
|
|
69
|
+
Syre: ["Syrc"],
|
|
70
|
+
Syrj: ["Syrc"],
|
|
71
|
+
Syrn: ["Syrc"],
|
|
72
|
+
Geok: ["Geor"],
|
|
73
|
+
};
|
|
74
|
+
function isUnicodeScriptValue(code) {
|
|
75
|
+
try {
|
|
76
|
+
new RegExp(`\\p{Script=${code}}`, "u");
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The Unicode Script property values whose characters a script code covers.
|
|
85
|
+
*
|
|
86
|
+
* `Jpan` gives `Hani`, `Hira` and `Kana`, and `Latn` gives `Latn`.
|
|
87
|
+
* A code with no Unicode script of its own, such as `Zmth` (mathematical notation)
|
|
88
|
+
* or a private-use code, gives an empty list.
|
|
89
|
+
*
|
|
90
|
+
* The runtime's regular-expression engine decides which values it knows.
|
|
91
|
+
*/
|
|
92
|
+
export function unicodeScriptsOf(code) {
|
|
93
|
+
const expanded = UNICODE_SCRIPT_EXPANSIONS[code];
|
|
94
|
+
if (expanded)
|
|
95
|
+
return expanded;
|
|
96
|
+
return isUnicodeScriptValue(code) ? [code] : [];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Whether every letter in `text` belongs to one of the scripts the code covers.
|
|
100
|
+
*
|
|
101
|
+
* Digits, punctuation, spaces and other non-letters are ignored, so `ニューヨーク州 10001` is written in `Jpan`.
|
|
102
|
+
* A text without letters returns `false`, because it shows no script at all.
|
|
103
|
+
*
|
|
104
|
+
* Common and Inherited letters, such as the prolonged sound mark `ー` in `ニューヨーク`,
|
|
105
|
+
* are accepted beside any script and don't count as evidence of one.
|
|
106
|
+
*
|
|
107
|
+
* Letters of an `alsoAccepted` script pass without counting, so `金龍酒家, 12 Gerrard Street`
|
|
108
|
+
* is written in `Latn` when `Hani` is also accepted: the Latin letters make up
|
|
109
|
+
* the address, and the Han name sits inside it.
|
|
110
|
+
*/
|
|
111
|
+
export function isWrittenInScript(text, code, alsoAccepted = []) {
|
|
112
|
+
const scripts = unicodeScriptsOf(code);
|
|
113
|
+
if (!scripts.length)
|
|
114
|
+
return false;
|
|
115
|
+
const own = scriptClass(scripts);
|
|
116
|
+
const accepted = scriptClass([...alsoAccepted.flatMap(unicodeScriptsOf), "Zyyy", "Zinh"]);
|
|
117
|
+
let letters = 0;
|
|
118
|
+
for (const character of text) {
|
|
119
|
+
if (!/\p{L}|\p{M}/u.test(character))
|
|
120
|
+
continue;
|
|
121
|
+
if (own.test(character)) {
|
|
122
|
+
letters++;
|
|
123
|
+
}
|
|
124
|
+
else if (!accepted.test(character)) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return letters > 0;
|
|
129
|
+
}
|
|
130
|
+
function scriptClass(scripts) {
|
|
131
|
+
return new RegExp(`^[${scripts.map((script) => `\\p{Script=${script}}`).join("")}]$`, "u");
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.js","sourceRoot":"","sources":["../../lib/iso15924/codes.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAe,YAAY,EAAE,MAAM,SAAS,CAAA;AAGnD,MAAM,KAAK,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAA;AAE/C,MAAM,SAAS,GAAG,iBAAiB,CAAA;AACnC,MAAM,OAAO,GAAG,eAAe,CAAA;AAkB/B;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACzC,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,CAAA;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,CAAA;IAEjF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE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SAAS,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,CAAA;QACV,CAAC;aAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACtC,OAAO,KAAK,CAAA;QACb,CAAC;IACF,CAAC;IAED,OAAO,OAAO,GAAG,CAAC,CAAA;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,OAA0B;IAC9C,OAAO,IAAI,MAAM,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC3F,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BCP47 } from "#types";
|
|
2
|
+
/**
|
|
3
|
+
* The ISO 15924 script of a code point.
|
|
4
|
+
*
|
|
5
|
+
* @param codePoint A Unicode scalar value, from 0 to 0x10FFFF.
|
|
6
|
+
* @returns `Zyyy` for Common, `Zinh` for Inherited, and `Zzzz` when the runtime
|
|
7
|
+
* assigns the code point no registry script.
|
|
8
|
+
*/
|
|
9
|
+
export declare function codePointScript(codePoint: number): BCP47.ScriptCode;
|
|
10
|
+
//# sourceMappingURL=unicode-script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unicode-script.d.ts","sourceRoot":"","sources":["../../lib/iso15924/unicode-script.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAwDnC;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC,UAAU,CAiCnE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
/**
|
|
4
|
+
* The ISO 15924 script of a code point, from the Unicode Script property of the runtime.
|
|
5
|
+
*
|
|
6
|
+
* The answer is the registry's own code: `Latn`, `Grek`, `Hani`, `Deva`.
|
|
7
|
+
* `Zyyy` marks a Common code point (digits and punctuation), `Zinh` an Inherited one
|
|
8
|
+
* (a combining mark), and `Zzzz` a code point that has no script in the runtime's Unicode version.
|
|
9
|
+
*
|
|
10
|
+
* # The Unicode version is the runtime's
|
|
11
|
+
*
|
|
12
|
+
* The tables are the regular-expression engine's `\p{Script=…}` classes, so they add no byte to a bundle.
|
|
13
|
+
* The answer for a code point that a later Unicode version assigned depends on
|
|
14
|
+
* the runtime that runs the call: a Worker, a browser and Node can report `Zzzz`
|
|
15
|
+
* for a script that a newer one reports by name.
|
|
16
|
+
*
|
|
17
|
+
* The test of this module pins the answers for a fixed list of code points.
|
|
18
|
+
*
|
|
19
|
+
* The candidates are the registry's script codes that the runtime's regular-expression
|
|
20
|
+
* engine also names as a Script value, so the set follows both tables.
|
|
21
|
+
* A code point of a Unicode script that the registry omits reports `Zzzz`.
|
|
22
|
+
*
|
|
23
|
+
* The lookup costs one array read for ASCII, and one cached read for a code point seen before.
|
|
24
|
+
*/
|
|
25
|
+
import { scriptSubtagRows } from "#artifacts/bcp47/script";
|
|
26
|
+
/**
|
|
27
|
+
* The scripts tried first, because most addresses are written in them.
|
|
28
|
+
* The rest follow in the registry's order.
|
|
29
|
+
*/
|
|
30
|
+
const COMMON_FIRST = [
|
|
31
|
+
"Zyyy",
|
|
32
|
+
"Zinh",
|
|
33
|
+
"Latn",
|
|
34
|
+
"Hani",
|
|
35
|
+
"Cyrl",
|
|
36
|
+
"Arab",
|
|
37
|
+
"Hang",
|
|
38
|
+
"Hira",
|
|
39
|
+
"Kana",
|
|
40
|
+
"Grek",
|
|
41
|
+
"Deva",
|
|
42
|
+
"Thai",
|
|
43
|
+
"Hebr",
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* The most code points the cache holds before it starts again.
|
|
47
|
+
*/
|
|
48
|
+
const CACHE_LIMIT = 65_536;
|
|
49
|
+
let matcher = null;
|
|
50
|
+
const cache = new Map();
|
|
51
|
+
function isScriptValue(code) {
|
|
52
|
+
try {
|
|
53
|
+
new RegExp(`\\p{Script=${code}}`, "u");
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function build() {
|
|
61
|
+
const known = scriptSubtagRows()
|
|
62
|
+
.map((row) => row.subtag)
|
|
63
|
+
.filter((code) => /^[A-Z][a-z]{3}$/.test(code) && isScriptValue(code));
|
|
64
|
+
const present = new Set(known);
|
|
65
|
+
const first = COMMON_FIRST.filter((code) => present.has(code));
|
|
66
|
+
const codes = [...first, ...known.filter((code) => !first.includes(code))];
|
|
67
|
+
// Each script is one capture group, so one `exec` reports which group matched.
|
|
68
|
+
const pattern = new RegExp(codes.map((code) => `(\\p{Script=${code}})`).join("|"), "u");
|
|
69
|
+
return { pattern, codes };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The ISO 15924 script of a code point.
|
|
73
|
+
*
|
|
74
|
+
* @param codePoint A Unicode scalar value, from 0 to 0x10FFFF.
|
|
75
|
+
* @returns `Zyyy` for Common, `Zinh` for Inherited, and `Zzzz` when the runtime
|
|
76
|
+
* assigns the code point no registry script.
|
|
77
|
+
*/
|
|
78
|
+
export function codePointScript(codePoint) {
|
|
79
|
+
if (codePoint < 0x80) {
|
|
80
|
+
const lower = codePoint | 0x20;
|
|
81
|
+
return (lower >= 0x61 && lower <= 0x7a ? "Latn" : "Zyyy");
|
|
82
|
+
}
|
|
83
|
+
const cached = cache.get(codePoint);
|
|
84
|
+
if (cached)
|
|
85
|
+
return cached;
|
|
86
|
+
matcher ??= build();
|
|
87
|
+
const found = matcher.pattern.exec(String.fromCodePoint(codePoint));
|
|
88
|
+
let script = "Zzzz";
|
|
89
|
+
if (found) {
|
|
90
|
+
for (let group = 1; group < found.length; group++) {
|
|
91
|
+
if (found[group] !== undefined) {
|
|
92
|
+
script = matcher.codes[group - 1];
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (cache.size >= CACHE_LIMIT) {
|
|
98
|
+
cache.clear();
|
|
99
|
+
}
|
|
100
|
+
cache.set(codePoint, script);
|
|
101
|
+
return script;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=unicode-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unicode-script.js","sourceRoot":"","sources":["../../lib/iso15924/unicode-script.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAG1D;;;GAGG;AACH,MAAM,YAAY,GAAG;IACpB,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;CACN,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,GAAG,MAAM,CAAA;AAE1B,IAAI,OAAO,GAAqF,IAAI,CAAA;AAEpG,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4B,CAAA;AAEjD,SAAS,aAAa,CAAC,IAAY;IAClC,IAAI,CAAC;QACJ,IAAI,MAAM,CAAC,cAAc,IAAI,GAAG,EAAE,GAAG,CAAC,CAAA;QAEtC,OAAO,IAAI,CAAA;IACZ,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC;AAED,SAAS,KAAK;IACb,MAAM,KAAK,GAAG,gBAAgB,EAAE;SAC9B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;SACxB,MAAM,CAAC,CAAC,IAAI,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AC,CAAC,CAAA;IACnE,IAAI,MAAM,GAAqB,MAA0B,CAAA;IAEzD,IAAI,KAAK,EAAE,CAAC;QACX,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACnD,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAE,CAAA;gBAElC,MAAK;YACN,CAAC;QACF,CAAC;IACF,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,KAAK,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IAE5B,OAAO,MAAM,CAAA;AACd,CAAC"}
|
package/out/iso3166/alpha2.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The strict alpha-2 country-code predicate over the `iso3166-1-alpha2-membership` bitset. An import of it retains
|
|
7
|
-
* that 85-byte bitset and the reader, and no name, airport or record.
|
|
8
|
-
*/
|
|
9
1
|
import { type Parsed } from "#errors";
|
|
10
2
|
import type { ISO } from "#types";
|
|
11
3
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha2.d.ts","sourceRoot":"","sources":["../../lib/iso3166/alpha2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alpha2.d.ts","sourceRoot":"","sources":["../../lib/iso3166/alpha2.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,MAAM,EAA8B,MAAM,SAAS,CAAA;AAIjE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAUjC;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG,CAAC,yBAAyB,CAEzF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAQ3F"}
|
package/out/iso3166/alpha2.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
4
|
+
* The strict alpha-2 country-code predicate over the `iso3166-1-alpha2-membership` bitset.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* that 85-byte bitset and the reader, and no name, airport or record.
|
|
6
|
+
* An import of it retains that 85-byte bitset and the reader, and no name, airport or record.
|
|
8
7
|
*/
|
|
9
8
|
import { iso31661Alpha2MembershipArtifact } from "#artifacts/iso3166-1/alpha2-membership";
|
|
10
9
|
import { ParseFailure, shapeFailure } from "#errors";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha2.js","sourceRoot":"","sources":["../../lib/iso3166/alpha2.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"alpha2.js","sourceRoot":"","sources":["../../lib/iso3166/alpha2.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;GAIG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAA;AACzF,OAAO,EAAe,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,IAAI,MAAM,GAAsB,IAAI,CAAA;AAEpC,SAAS,UAAU;IAClB,MAAM,KAAK,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAA;IAE5E,OAAO,MAAM,CAAA;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAChD,OAAO,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa;IACnD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;IAE1C,IAAI,KAAK;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IAErD,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;IAE3F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAClC,CAAC"}
|
package/out/iso3166/alpha3.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The strict alpha-3 country-code predicate over the `iso3166-1-alpha3-membership` bitset. An import of it retains
|
|
7
|
-
* that 2,197-byte bitset and the reader, and no name, airport or record.
|
|
8
|
-
*/
|
|
9
1
|
import { type Parsed } from "#errors";
|
|
10
2
|
import { BitsetView } from "#rgy1/views";
|
|
11
3
|
import type { ISO } from "#types";
|
|
@@ -19,7 +11,7 @@ export declare function alpha3Membership(): BitsetView;
|
|
|
19
11
|
* `AUS` is one.
|
|
20
12
|
* `aus` and `AU` are not.
|
|
21
13
|
*
|
|
22
|
-
* A former code such as `DDR`
|
|
14
|
+
* A former code such as `DDR` isn't: the records artifact still describes it.
|
|
23
15
|
*/
|
|
24
16
|
export declare function isCountryCodeAlpha3(input: string): input is ISO.CountryCode_3166_1_Alpha3;
|
|
25
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha3.d.ts","sourceRoot":"","sources":["../../lib/iso3166/alpha3.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alpha3.d.ts","sourceRoot":"","sources":["../../lib/iso3166/alpha3.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,MAAM,EAA8B,MAAM,SAAS,CAAA;AAGjE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAIjC;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAI7C;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG,CAAC,yBAAyB,CAEzF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAQ3F"}
|
package/out/iso3166/alpha3.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
4
|
+
* The strict alpha-3 country-code predicate over the `iso3166-1-alpha3-membership` bitset.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* that 2,197-byte bitset and the reader, and no name, airport or record.
|
|
6
|
+
* An import of it retains that 2,197-byte bitset and the reader, and no name, airport or record.
|
|
8
7
|
*/
|
|
9
8
|
import { iso31661Alpha3MembershipArtifact } from "#artifacts/iso3166-1/alpha3-membership";
|
|
10
9
|
import { ParseFailure, shapeFailure } from "#errors";
|
|
@@ -25,7 +24,7 @@ export function alpha3Membership() {
|
|
|
25
24
|
* `AUS` is one.
|
|
26
25
|
* `aus` and `AU` are not.
|
|
27
26
|
*
|
|
28
|
-
* A former code such as `DDR`
|
|
27
|
+
* A former code such as `DDR` isn't: the records artifact still describes it.
|
|
29
28
|
*/
|
|
30
29
|
export function isCountryCodeAlpha3(input) {
|
|
31
30
|
return alpha3Membership().test(encode3(input));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha3.js","sourceRoot":"","sources":["../../lib/iso3166/alpha3.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"alpha3.js","sourceRoot":"","sources":["../../lib/iso3166/alpha3.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;GAIG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAA;AACzF,OAAO,EAAe,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,IAAI,MAAM,GAAsB,IAAI,CAAA;AAEpC;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC/B,MAAM,KAAK,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAA;IAE5E,OAAO,MAAM,CAAA;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAChD,OAAO,gBAAgB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa;IACnD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;IAE1C,IAAI,KAAK;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IAErD,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;IAE3F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAClC,CAAC"}
|
package/out/iso3166/records.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Country record retrieval over the `iso3166-1-records` artifact: three id tables, six columns and a string pool.
|
|
7
|
-
*
|
|
8
|
-
* A record is materialized on request and cached by row, so a repeated read of one country returns one object. The
|
|
9
|
-
* artifact holds every status; `getCountry*` answers a record of any status and reports it, while the brands and the
|
|
10
|
-
* membership predicates cover officially assigned codes only.
|
|
11
|
-
*/
|
|
12
1
|
import { Artifact } from "#rgy1/reader";
|
|
13
2
|
import { type CountryRecord } from "#types";
|
|
14
3
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../lib/iso3166/records.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../lib/iso3166/records.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,QAAQ,CAAA;AA6D1D;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAuBjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAEtE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAEzD"}
|
package/out/iso3166/records.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
4
|
+
* Country record retrieval over the `iso3166-1-records` artifact: three id tables,
|
|
5
|
+
* six columns and a string pool.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* membership predicates cover officially assigned codes only.
|
|
7
|
+
* A record is materialized on request and cached by row, so a repeated read
|
|
8
|
+
* of one country returns one object.
|
|
9
|
+
* The artifact holds every status; `getCountry*` answers a record of any status and reports it,
|
|
10
|
+
* while the brands and the membership predicates cover officially assigned codes only.
|
|
11
11
|
*/
|
|
12
12
|
import { iso31661RecordsArtifact } from "#artifacts/iso3166-1/records";
|
|
13
13
|
import { ARITY_NUMERIC, CODE_LENGTH_2, CODE_LENGTH_3, decode2, decode3, decodeNumeric, encode2, encode3, encodeNumeric, } from "#key";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../lib/iso3166/records.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../lib/iso3166/records.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;GAQG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EACN,aAAa,EACb,aAAa,EACb,aAAa,EACb,OAAO,EACP,OAAO,EACP,aAAa,EACb,OAAO,EACP,OAAO,EACP,aAAa,GACb,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,EAAsB,aAAa,EAAE,MAAM,QAAQ,CAAA;AAmB1D,IAAI,MAAM,GAAkB,IAAI,CAAA;AAEhC;;;GAGG;AACH,MAAM,MAAM,GAAG;IACd,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;IACZ,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;CACF,CAAA;AAEV,SAAS,iBAAiB;IACzB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAA;IAEzB,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,uBAAuB,EAAE,CAAC,CAAA;IAE1D,MAAM,GAAG;QACR,QAAQ;QACR,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;QAC/C,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC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AC,IAAI,CAAC,CAAC,CAAC,CAAA;AAC7E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IACjC,OAAO,iBAAiB,EAAE,CAAC,OAAO,CAAC,MAAM,CAAA;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IACnC,OAAO,iBAAiB,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAA;AAC3C,CAAC"}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The code-equivalence relations of one country entity: alpha-2, alpha-3 and numeric codes of the same record.
|
|
7
|
-
*/
|
|
8
1
|
/**
|
|
9
2
|
* The alpha-3 code of the entity an alpha-2 code identifies, or `null`.
|
|
10
3
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../lib/iso3166/relations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../lib/iso3166/relations.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE/D"}
|
package/out/iso3166/relations.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The code-equivalence relations of one country entity: alpha-2, alpha-3 and numeric codes of the same record.
|
|
4
|
+
* The code-equivalence relations of one country entity: alpha-2, alpha-3
|
|
5
|
+
* and numeric codes of the same record.
|
|
7
6
|
*/
|
|
8
7
|
import { getCountryByAlpha2, getCountryByAlpha3, getCountryByNumeric } from "#iso3166/records";
|
|
9
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../../lib/iso3166/relations.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../../lib/iso3166/relations.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAE9F;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC7C,OAAO,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,IAAI,CAAA;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC7C,OAAO,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,IAAI,CAAA;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC/C,OAAO,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,IAAI,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Parsed } from "#errors";
|
|
2
|
+
import type { BCP47 } from "#types";
|
|
3
|
+
/**
|
|
4
|
+
* One language as the registry describes it.
|
|
5
|
+
*/
|
|
6
|
+
export interface LanguageRecord {
|
|
7
|
+
subtag: BCP47.LanguageSubtag;
|
|
8
|
+
/**
|
|
9
|
+
* The registry's first description, such as `Japanese`.
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
descriptions: readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* The script a tag for this language leaves implied, such as `Jpan` for `ja`, or `null`.
|
|
15
|
+
*/
|
|
16
|
+
suppressScript: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* The macrolanguage this language is a member of, such as `zh` for `yue`, or `null`.
|
|
19
|
+
*/
|
|
20
|
+
macrolanguage: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* `macrolanguage`, `collection`, `special` or `private-use`, or `null` for an individual language.
|
|
23
|
+
*/
|
|
24
|
+
scope: string | null;
|
|
25
|
+
deprecated: string | null;
|
|
26
|
+
preferredValue: string | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether `input` is a language subtag the registry holds, in lowercase.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isLanguageSubtag(input: string): input is BCP47.LanguageSubtag;
|
|
32
|
+
/**
|
|
33
|
+
* The branded language subtag, or the reason the input was refused.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseLanguageSubtag(input: string): Parsed<BCP47.LanguageSubtag>;
|
|
36
|
+
/**
|
|
37
|
+
* The record of a lowercase language subtag, or `null`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getLanguage(subtag: string): LanguageRecord | null;
|
|
40
|
+
//# sourceMappingURL=languages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../lib/iso639/languages.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,SAAS,CAAA;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAOnC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,KAAK,CAAC,cAAc,CAAA;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IAC/B;;OAEG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B;;OAEG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,KAAK,CAAC,cAAc,CAE7E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAQ/E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAiBjE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
/**
|
|
4
|
+
* ISO 639 language subtags, read from the language subtags of the IANA Language Subtag Registry.
|
|
5
|
+
*
|
|
6
|
+
* The registry holds one subtag per language: the ISO 639-1 two-letter code
|
|
7
|
+
* where one exists, and otherwise the ISO 639-2, 639-3 or 639-5 three-letter code.
|
|
8
|
+
* Japanese is `ja` and never `jpn`; Cantonese is `yue`.
|
|
9
|
+
*/
|
|
10
|
+
import { languageSubtagRows } from "#artifacts/bcp47/language";
|
|
11
|
+
import { lazySubtagIndex } from "#bcp47/subtag-index";
|
|
12
|
+
import { ParseFailure } from "#errors";
|
|
13
|
+
const index = lazySubtagIndex(languageSubtagRows);
|
|
14
|
+
const CANONICAL = /^[a-z]{2,3}$/;
|
|
15
|
+
const LETTERS = /^[A-Za-z]{2,3}$/;
|
|
16
|
+
/**
|
|
17
|
+
* Whether `input` is a language subtag the registry holds, in lowercase.
|
|
18
|
+
*/
|
|
19
|
+
export function isLanguageSubtag(input) {
|
|
20
|
+
return CANONICAL.test(input) && index().get(input) !== null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The branded language subtag, or the reason the input was refused.
|
|
24
|
+
*/
|
|
25
|
+
export function parseLanguageSubtag(input) {
|
|
26
|
+
if (!LETTERS.test(input))
|
|
27
|
+
return { ok: false, reason: ParseFailure.Shape, input };
|
|
28
|
+
if (!CANONICAL.test(input))
|
|
29
|
+
return { ok: false, reason: ParseFailure.Case, input };
|
|
30
|
+
if (!isLanguageSubtag(input))
|
|
31
|
+
return { ok: false, reason: ParseFailure.NotFound, input };
|
|
32
|
+
return { ok: true, value: input };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The record of a lowercase language subtag, or `null`.
|
|
36
|
+
*/
|
|
37
|
+
export function getLanguage(subtag) {
|
|
38
|
+
if (!CANONICAL.test(subtag))
|
|
39
|
+
return null;
|
|
40
|
+
const row = index().get(subtag);
|
|
41
|
+
if (!row)
|
|
42
|
+
return null;
|
|
43
|
+
return {
|
|
44
|
+
subtag: subtag,
|
|
45
|
+
name: row.descriptions[0] ?? subtag,
|
|
46
|
+
descriptions: row.descriptions,
|
|
47
|
+
suppressScript: row.suppressScript ?? null,
|
|
48
|
+
macrolanguage: row.macrolanguage ?? null,
|
|
49
|
+
scope: row.scope ?? null,
|
|
50
|
+
deprecated: row.deprecated ?? null,
|
|
51
|
+
preferredValue: row.preferredValue ?? null,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=languages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../../lib/iso639/languages.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE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;QACN,MAAM,EAAE,MAA8B;QACtC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,MAAM;QACnC,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,cAAc,EAAE,GAAG,CAAC,cAAc,IAAI,IAAI;QAC1C,aAAa,EAAE,GAAG,CAAC,aAAa,IAAI,IAAI;QACxC,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI;QACxB,UAAU,EAAE,GAAG,CAAC,UAAU,IAAI,IAAI;QAClC,cAAc,EAAE,GAAG,CAAC,cAAc,IAAI,IAAI;KAC1C,CAAA;AACF,CAAC"}
|
package/out/key.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
2
|
+
* Key encodings: the position of a code in its direct-address key space,
|
|
3
|
+
* mirroring `crates/registry-core/src/key.rs`.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
5
|
+
* Two or three upper-case ASCII letters encode base-26 with the first letter in the highest place.
|
|
6
|
+
* A three-digit numeric code encodes as its decimal value.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* anything else. A caller normalizes case or whitespace before calling, never here.
|
|
8
|
+
* Every encoder checks length and alphabet first and answers `-1` for anything else.
|
|
9
|
+
* A caller normalizes case or whitespace before calling, never here.
|
|
11
10
|
*/
|
|
12
11
|
/**
|
|
13
12
|
* The number of two-letter keys, 26².
|
package/out/key.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../lib/key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../lib/key.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW,MAAM,CAAA;AAE9B;;GAEG;AACH,eAAO,MAAM,WAAW,QAAS,CAAA;AAEjC;;GAEG;AACH,eAAO,MAAM,iBAAiB,OAAO,CAAA;AAErC;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAA;AAE9B;;GAEG;AACH,eAAO,MAAM,MAAM,KAAK,CAAA;AAExB;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAA;AAE9B;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAA;AAa9B;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU5C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAclD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAWlE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM3C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD"}
|
package/out/key.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
4
|
+
* Key encodings: the position of a code in its direct-address key space,
|
|
5
|
+
* mirroring `crates/registry-core/src/key.rs`.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
+
* Two or three upper-case ASCII letters encode base-26 with the first letter in the highest place.
|
|
8
|
+
* A three-digit numeric code encodes as its decimal value.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* anything else. A caller normalizes case or whitespace before calling, never here.
|
|
10
|
+
* Every encoder checks length and alphabet first and answers `-1` for anything else.
|
|
11
|
+
* A caller normalizes case or whitespace before calling, never here.
|
|
11
12
|
*/
|
|
12
13
|
/**
|
|
13
14
|
* The number of two-letter keys, 26².
|