@mailwoman/variant-aliases 8.6.0 → 9.0.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/lookup.ts +22 -14
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +21 -14
- package/out/lookup.js.map +1 -1
- package/package.json +1 -1
package/lookup.ts
CHANGED
|
@@ -10,29 +10,37 @@
|
|
|
10
10
|
* The runtime integration into the kind classifier is v0.6.0+ work.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { readFileSync } from "node:fs"
|
|
13
|
+
import { existsSync, readFileSync } from "node:fs"
|
|
14
14
|
import { resolve } from "node:path"
|
|
15
15
|
|
|
16
16
|
import type { AliasLookupResult, VariantAlias, VariantAliasTable } from "./types.ts"
|
|
17
17
|
|
|
18
18
|
const moduleDir = import.meta.dirname
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Read the shipped alias table.
|
|
22
|
+
*
|
|
23
|
+
* `data/` sits at the package root (it is a `files` entry), and this module sits either at that root — running from
|
|
24
|
+
* source — or under `out/` when compiled, so there are exactly two places to look. The probe tests for the FILE:
|
|
25
|
+
* probing by attempting a parse folds a corrupt table into "not this candidate", and the package then reports a missing
|
|
26
|
+
* table it is looking straight at.
|
|
27
|
+
*
|
|
28
|
+
* `@mailwoman/poi-taxonomy` carries the same loader against its own tables. The duplication is deliberate — both
|
|
29
|
+
* packages declare ZERO dependencies and publish independently, so sharing one would mean one taking a dependency on
|
|
30
|
+
* the other for eight lines.
|
|
31
|
+
*/
|
|
20
32
|
function loadTable(): VariantAliasTable {
|
|
21
|
-
const candidates = [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for (const path of candidates) {
|
|
28
|
-
try {
|
|
29
|
-
return JSON.parse(readFileSync(path, "utf8")) as VariantAliasTable
|
|
30
|
-
} catch {
|
|
31
|
-
// try next
|
|
32
|
-
}
|
|
33
|
+
const candidates = [resolve(moduleDir, "data", "aliases.json"), resolve(moduleDir, "..", "data", "aliases.json")]
|
|
34
|
+
const found = candidates.find((candidate) => existsSync(candidate))
|
|
35
|
+
|
|
36
|
+
if (!found) {
|
|
37
|
+
throw new Error(`variant-aliases: could not find data/aliases.json — looked in ${candidates.join(", ")}`)
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
// A corrupt shipped table is a broken build, and the SyntaxError names the offset. Zero dependencies here, so
|
|
41
|
+
// `@mailwoman/core`'s parse wrappers are deliberately out of reach.
|
|
42
|
+
// oxlint-disable-next-line no-restricted-properties
|
|
43
|
+
return JSON.parse(readFileSync(found, "utf8")) as VariantAliasTable
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
const TABLE = loadTable()
|
package/out/lookup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAA;AAkDpF;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CA8BtF;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,aAAa,CAAC,YAAY,CAAC,CAE3D;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAAgB,CAAA"}
|
package/out/lookup.js
CHANGED
|
@@ -9,24 +9,31 @@
|
|
|
9
9
|
* This is the data-side foundation for #166 (variant alias table + locale-gated category matching).
|
|
10
10
|
* The runtime integration into the kind classifier is v0.6.0+ work.
|
|
11
11
|
*/
|
|
12
|
-
import { readFileSync } from "node:fs";
|
|
12
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
13
13
|
import { resolve } from "node:path";
|
|
14
14
|
const moduleDir = import.meta.dirname;
|
|
15
|
+
/**
|
|
16
|
+
* Read the shipped alias table.
|
|
17
|
+
*
|
|
18
|
+
* `data/` sits at the package root (it is a `files` entry), and this module sits either at that root — running from
|
|
19
|
+
* source — or under `out/` when compiled, so there are exactly two places to look. The probe tests for the FILE:
|
|
20
|
+
* probing by attempting a parse folds a corrupt table into "not this candidate", and the package then reports a missing
|
|
21
|
+
* table it is looking straight at.
|
|
22
|
+
*
|
|
23
|
+
* `@mailwoman/poi-taxonomy` carries the same loader against its own tables. The duplication is deliberate — both
|
|
24
|
+
* packages declare ZERO dependencies and publish independently, so sharing one would mean one taking a dependency on
|
|
25
|
+
* the other for eight lines.
|
|
26
|
+
*/
|
|
15
27
|
function loadTable() {
|
|
16
|
-
const candidates = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
];
|
|
21
|
-
for (const path of candidates) {
|
|
22
|
-
try {
|
|
23
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
// try next
|
|
27
|
-
}
|
|
28
|
+
const candidates = [resolve(moduleDir, "data", "aliases.json"), resolve(moduleDir, "..", "data", "aliases.json")];
|
|
29
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
30
|
+
if (!found) {
|
|
31
|
+
throw new Error(`variant-aliases: could not find data/aliases.json — looked in ${candidates.join(", ")}`);
|
|
28
32
|
}
|
|
29
|
-
|
|
33
|
+
// A corrupt shipped table is a broken build, and the SyntaxError names the offset. Zero dependencies here, so
|
|
34
|
+
// `@mailwoman/core`'s parse wrappers are deliberately out of reach.
|
|
35
|
+
// oxlint-disable-next-line no-restricted-properties
|
|
36
|
+
return JSON.parse(readFileSync(found, "utf8"));
|
|
30
37
|
}
|
|
31
38
|
const TABLE = loadTable();
|
|
32
39
|
/**
|
package/out/lookup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAA;AAErC;;;;;;;;;;;GAWG;AACH,SAAS,SAAS;IACjB,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;IACjH,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAA;IAEnE,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,iEAAiE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC1G,CAAC;IAED,8GAA8G;IAC9G,oEAAoE;IACpE,oDAAoD;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAsB,CAAA;AACpE,CAAC;AAED,MAAM,KAAK,GAAG,SAAS,EAAE,CAAA;AAEzB;;;;GAIG;AACH,MAAM,KAAK,GAAqD,CAAC,GAAG,EAAE;IACrE,MAAM,GAAG,GAAG,IAA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MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAA;QAE5E,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAA;QACzC,CAAC;IACF,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAA;IAEnD,OAAO,OAAO,CAAA;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC5B,OAAO,KAAK,CAAC,OAAO,CAAA;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/variant-aliases",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Regional variant alias table — local terms for amenities/brands gated by locale. 'servo' → fuel (en-AU), 'マクド' → McDonald's (ja-JP), 'PFK' → KFC (fr-CA).",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|