@mailwoman/locale-gate 4.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.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `detectLocale` — Stage 2 entry point. Composes the per-rule scorers and emits a `LocaleHint`.
7
+ *
8
+ * Caller-hint precedence: when `opts.hint` is provided, it wins at confidence 1.0 with
9
+ * `source="caller"`. The detector still runs the rules to populate `alternatives` so downstream
10
+ * consumers see what the input shape would have predicted (useful for diagnostics + future
11
+ * disagreement-detection metrics).
12
+ */
13
+ import type { DetectLocaleOpts, LocaleHint, NormalizedInputLite, QueryShapeLike } from "./types.js";
14
+ /** Synchronous, pure rule-based implementation. The async wrapper matches the pipeline contract. */
15
+ export declare function detectLocaleSync(_input: NormalizedInputLite, shape: QueryShapeLike, opts?: DetectLocaleOpts): LocaleHint;
16
+ /**
17
+ * Async variant matching `RuntimePipelineStages.detectLocale`. Wraps the sync impl so the pipeline
18
+ * coordinator can use it as-is.
19
+ */
20
+ export declare function detectLocale(input: NormalizedInputLite, shape: QueryShapeLike, opts?: DetectLocaleOpts): Promise<LocaleHint>;
21
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEnG,oGAAoG;AACpG,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,cAAc,EACrB,IAAI,GAAE,gBAAqB,GACzB,UAAU,CAqCZ;AAED;;;GAGG;AACH,wBAAsB,YAAY,CACjC,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,cAAc,EACrB,IAAI,CAAC,EAAE,gBAAgB,GACrB,OAAO,CAAC,UAAU,CAAC,CAErB"}
package/out/detect.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `detectLocale` — Stage 2 entry point. Composes the per-rule scorers and emits a `LocaleHint`.
7
+ *
8
+ * Caller-hint precedence: when `opts.hint` is provided, it wins at confidence 1.0 with
9
+ * `source="caller"`. The detector still runs the rules to populate `alternatives` so downstream
10
+ * consumers see what the input shape would have predicted (useful for diagnostics + future
11
+ * disagreement-detection metrics).
12
+ */
13
+ import { scoreByPostcode, scoreByScript, scoreFallback } from "./rules.js";
14
+ /** Synchronous, pure rule-based implementation. The async wrapper matches the pipeline contract. */
15
+ export function detectLocaleSync(_input, shape, opts = {}) {
16
+ const scored = [];
17
+ const script = scoreByScript(shape);
18
+ if (script)
19
+ scored.push(script);
20
+ const postcode = scoreByPostcode(shape);
21
+ if (postcode)
22
+ scored.push(postcode);
23
+ scored.push(scoreFallback(shape));
24
+ // Sort descending by confidence; preserve scorer order on ties (stable sort).
25
+ scored.sort((a, b) => b.confidence - a.confidence);
26
+ // Deduplicate by locale — if two scorers picked en-US, the higher-confidence wins; the other
27
+ // contributes nothing useful as an alternative.
28
+ const seen = new Set();
29
+ const deduped = scored.filter((c) => {
30
+ if (seen.has(c.locale))
31
+ return false;
32
+ seen.add(c.locale);
33
+ return true;
34
+ });
35
+ if (opts.hint) {
36
+ // Caller's hint wins. Detector results surface as alternatives.
37
+ return {
38
+ locale: opts.hint,
39
+ confidence: 1.0,
40
+ alternatives: deduped.map((c) => ({ locale: c.locale, confidence: c.confidence })),
41
+ source: "caller",
42
+ };
43
+ }
44
+ const top = deduped[0];
45
+ return {
46
+ locale: top.locale,
47
+ confidence: top.confidence,
48
+ alternatives: deduped.slice(1).map((c) => ({ locale: c.locale, confidence: c.confidence })),
49
+ source: "detected",
50
+ };
51
+ }
52
+ /**
53
+ * Async variant matching `RuntimePipelineStages.detectLocale`. Wraps the sync impl so the pipeline
54
+ * coordinator can use it as-is.
55
+ */
56
+ export async function detectLocale(input, shape, opts) {
57
+ return detectLocaleSync(input, shape, opts);
58
+ }
59
+ //# sourceMappingURL=detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.js","sourceRoot":"","sources":["../detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAwB,MAAM,YAAY,CAAA;AAGhG,oGAAoG;AACpG,MAAM,UAAU,gBAAgB,CAC/B,MAA2B,EAC3B,KAAqB,EACrB,OAAyB,EAAE;IAE3B,MAAM,MAAM,GAAsB,EAAE,CAAA;IACpC,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IACnC,IAAI,MAAM;QAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC/B,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IACvC,IAAI,QAAQ;QAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACnC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;IAEjC,8EAA8E;IAC9E,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAA;IAElD,6FAA6F;IAC7F,gDAAgD;IAChD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QACnC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAA;QACpC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QAClB,OAAO,IAAI,CAAA;IACZ,CAAC,CAAC,CAAA;IAEF,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACf,gEAAgE;QAChE,OAAO;YACN,MAAM,EAAE,IAAI,CAAC,IAAI;YACjB,UAAU,EAAE,GAAG;YACf,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;YAClF,MAAM,EAAE,QAAQ;SAChB,CAAA;IACF,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAE,CAAA;IACvB,OAAO;QACN,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,YAAY,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;QAC3F,MAAM,EAAE,UAAU;KAClB,CAAA;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,KAA0B,EAC1B,KAAqB,EACrB,IAAuB;IAEvB,OAAO,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;AAC5C,CAAC"}
package/out/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `@mailwoman/locale-gate` — Stage 2 of the runtime pipeline.
7
+ *
8
+ * Rule-based locale detection from `QueryShape`'s script + known-format hits. Returns a
9
+ * `LocaleHint` with the top candidate + alternatives, surfacing detector disagreement when the
10
+ * caller's `--locale` hint differs from what the input shape implies.
11
+ *
12
+ * Bitter-lesson-safe: only universal structural cues (script, postcode patterns), no place-name
13
+ * dictionaries. Trained character-level model is a v0.6.0 follow-on.
14
+ *
15
+ * See `docs/articles/plan/reference/STAGES.md` § Stage 2 for the contract.
16
+ */
17
+ export { detectLocale, detectLocaleSync } from "./detect.js";
18
+ export { scoreByPostcode, scoreByScript, scoreFallback } from "./rules.js";
19
+ export type { LocaleCandidate } from "./rules.js";
20
+ export type { DetectLocaleOpts, LocaleHint, LocaleTag, NormalizedInputLite, QueryShapeLike } from "./types.js";
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1E,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA"}
package/out/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `@mailwoman/locale-gate` — Stage 2 of the runtime pipeline.
7
+ *
8
+ * Rule-based locale detection from `QueryShape`'s script + known-format hits. Returns a
9
+ * `LocaleHint` with the top candidate + alternatives, surfacing detector disagreement when the
10
+ * caller's `--locale` hint differs from what the input shape implies.
11
+ *
12
+ * Bitter-lesson-safe: only universal structural cues (script, postcode patterns), no place-name
13
+ * dictionaries. Trained character-level model is a v0.6.0 follow-on.
14
+ *
15
+ * See `docs/articles/plan/reference/STAGES.md` § Stage 2 for the contract.
16
+ */
17
+ export { detectLocale, detectLocaleSync } from "./detect.js";
18
+ export { scoreByPostcode, scoreByScript, scoreFallback } from "./rules.js";
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
package/out/rules.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Rule-based locale detection from `QueryShape`. Bitter-lesson-safe: only universal structural cues
7
+ * (script class + known postcode formats), never place-name dictionaries.
8
+ *
9
+ * Scoring shape: each scorer returns `{ locale, confidence }` or null. The composer picks the
10
+ * highest-confidence non-null result; ties broken by scorer order (most-specific first).
11
+ */
12
+ import type { QueryShapeLike } from "./types.js";
13
+ export interface LocaleCandidate {
14
+ locale: string;
15
+ confidence: number;
16
+ reason: string;
17
+ }
18
+ /**
19
+ * Script-class scorer: maps the dominant character class to a default locale per script.
20
+ *
21
+ * - Cjk → ja-JP (only CJK locale we ship today; ko/zh would need their own weights)
22
+ * - Cyrillic → ru-RU (not currently shipped; signal is still useful)
23
+ * - Arabic → ar (similar)
24
+ * - Alpha / alphanumeric / numeric → no script-based commit (other scorers decide)
25
+ */
26
+ export declare function scoreByScript(shape: QueryShapeLike): LocaleCandidate | null;
27
+ /**
28
+ * Postcode-format scorer: maps a high-confidence postcode format hit to the country it implies.
29
+ *
30
+ * Ambiguous 5-digit hits (`us_zip`/`fr_postcode`/`de_postcode` all matching at confidence 0.6) are
31
+ * treated as low-confidence US (the most common 5-digit reading globally) — the caller can override
32
+ * with `--locale fr-FR`/`--locale de-DE` when the disambiguating context isn't in the string.
33
+ */
34
+ export declare function scoreByPostcode(shape: QueryShapeLike): LocaleCandidate | null;
35
+ /**
36
+ * Whole-input fallback: when nothing else fires, return en-US at low confidence. Keeps the gate
37
+ * always-decisive (no `null` to the caller, ever).
38
+ */
39
+ export declare function scoreFallback(_shape: QueryShapeLike): LocaleCandidate;
40
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,GAAG,IAAI,CAW3E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,GAAG,IAAI,CA2B7E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,eAAe,CAErE"}
package/out/rules.js ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Rule-based locale detection from `QueryShape`. Bitter-lesson-safe: only universal structural cues
7
+ * (script class + known postcode formats), never place-name dictionaries.
8
+ *
9
+ * Scoring shape: each scorer returns `{ locale, confidence }` or null. The composer picks the
10
+ * highest-confidence non-null result; ties broken by scorer order (most-specific first).
11
+ */
12
+ /**
13
+ * Script-class scorer: maps the dominant character class to a default locale per script.
14
+ *
15
+ * - Cjk → ja-JP (only CJK locale we ship today; ko/zh would need their own weights)
16
+ * - Cyrillic → ru-RU (not currently shipped; signal is still useful)
17
+ * - Arabic → ar (similar)
18
+ * - Alpha / alphanumeric / numeric → no script-based commit (other scorers decide)
19
+ */
20
+ export function scoreByScript(shape) {
21
+ switch (shape.characterClass) {
22
+ case "cjk":
23
+ return { locale: "ja-JP", confidence: 0.8, reason: "characterClass=cjk" };
24
+ case "cyrillic":
25
+ return { locale: "ru-RU", confidence: 0.85, reason: "characterClass=cyrillic" };
26
+ case "arabic":
27
+ return { locale: "ar", confidence: 0.85, reason: "characterClass=arabic" };
28
+ default:
29
+ return null;
30
+ }
31
+ }
32
+ /**
33
+ * Postcode-format scorer: maps a high-confidence postcode format hit to the country it implies.
34
+ *
35
+ * Ambiguous 5-digit hits (`us_zip`/`fr_postcode`/`de_postcode` all matching at confidence 0.6) are
36
+ * treated as low-confidence US (the most common 5-digit reading globally) — the caller can override
37
+ * with `--locale fr-FR`/`--locale de-DE` when the disambiguating context isn't in the string.
38
+ */
39
+ export function scoreByPostcode(shape) {
40
+ // Prefer unambiguous (confidence ≥ 0.9) hits over ambiguous (0.6) — among them, pick the one
41
+ // with the highest confidence + most-specific country mapping.
42
+ const unambiguous = shape.knownFormats.filter((f) => f.confidence >= 0.9);
43
+ if (unambiguous.length > 0) {
44
+ // Pick the first unambiguous hit (callers typically have one postcode per address).
45
+ const hit = unambiguous[0];
46
+ switch (hit.format) {
47
+ case "us_zip4":
48
+ return { locale: "en-US", confidence: 0.95, reason: `format=${hit.format}` };
49
+ case "uk_postcode":
50
+ return { locale: "en-GB", confidence: 0.95, reason: `format=${hit.format}` };
51
+ case "ca_postcode":
52
+ // Canadian — both en-CA and fr-CA possible. Default en-CA; FR caller can override.
53
+ return { locale: "en-CA", confidence: 0.9, reason: `format=${hit.format}` };
54
+ case "jp_postcode":
55
+ return { locale: "ja-JP", confidence: 0.95, reason: `format=${hit.format}` };
56
+ }
57
+ }
58
+ // Ambiguous 5-digit fallback.
59
+ const fivedigit = shape.knownFormats.find((f) => f.format === "us_zip" || f.format === "fr_postcode");
60
+ if (fivedigit) {
61
+ // Low confidence — US is the global plurality interpretation. Returns en-US so a downstream
62
+ // consumer without a stronger signal still gets a sensible default; alternatives surface FR/DE.
63
+ return { locale: "en-US", confidence: 0.5, reason: "ambiguous-5digit-postcode" };
64
+ }
65
+ return null;
66
+ }
67
+ /**
68
+ * Whole-input fallback: when nothing else fires, return en-US at low confidence. Keeps the gate
69
+ * always-decisive (no `null` to the caller, ever).
70
+ */
71
+ export function scoreFallback(_shape) {
72
+ return { locale: "en-US", confidence: 0.3, reason: "fallback" };
73
+ }
74
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAqB;IAClD,QAAQ,KAAK,CAAC,cAAc,EAAE,CAAC;QAC9B,KAAK,KAAK;YACT,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAA;QAC1E,KAAK,UAAU;YACd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAA;QAChF,KAAK,QAAQ;YACZ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAA;QAC3E;YACC,OAAO,IAAI,CAAA;IACb,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAqB;IACpD,6FAA6F;IAC7F,+DAA+D;IAC/D,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,GAAG,CAAC,CAAA;IACzE,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,oFAAoF;QACpF,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,CAAE,CAAA;QAC3B,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC;YACpB,KAAK,SAAS;gBACb,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,EAAE,EAAE,CAAA;YAC7E,KAAK,aAAa;gBACjB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,EAAE,EAAE,CAAA;YAC7E,KAAK,aAAa;gBACjB,mFAAmF;gBACnF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,EAAE,EAAE,CAAA;YAC5E,KAAK,aAAa;gBACjB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,EAAE,EAAE,CAAA;QAC9E,CAAC;IACF,CAAC;IACD,8BAA8B;IAC9B,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,CAAA;IACrG,IAAI,SAAS,EAAE,CAAC;QACf,4FAA4F;QAC5F,gGAAgG;QAChG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,2BAA2B,EAAE,CAAA;IACjF,CAAC;IACD,OAAO,IAAI,CAAA;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAsB;IACnD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA;AAChE,CAAC"}
package/out/types.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ /** Re-exports of the canonical types from `@mailwoman/core/pipeline`. */
7
+ export type { LocaleHint, LocaleTag } from "@mailwoman/core/pipeline";
8
+ /**
9
+ * Minimal `NormalizedInput` shape consumed by `detectLocale`. Compatible with
10
+ * `@mailwoman/normalize`'s output.
11
+ */
12
+ export interface NormalizedInputLite {
13
+ raw: string;
14
+ normalized: string;
15
+ appliedLocale?: string;
16
+ }
17
+ /**
18
+ * Minimal `QueryShape` shape consumed by `detectLocale`. Compatible with `@mailwoman/query-shape`'s
19
+ * output.
20
+ */
21
+ export interface QueryShapeLike {
22
+ knownFormats: ReadonlyArray<{
23
+ format: string;
24
+ span: {
25
+ start: number;
26
+ end: number;
27
+ };
28
+ confidence: number;
29
+ }>;
30
+ characterClass?: string;
31
+ totalLength?: number;
32
+ }
33
+ export interface DetectLocaleOpts {
34
+ /** Caller's locale hint. When set, returned at confidence 1.0 with source="caller". */
35
+ hint?: string;
36
+ /**
37
+ * Below this confidence, the detector returns the top candidate but also surfaces alternatives.
38
+ * Default 0.7.
39
+ */
40
+ confidenceFloor?: number;
41
+ }
42
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yEAAyE;AACzE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAErE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,YAAY,EAAE,aAAa,CAAC;QAC3B,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;QACpC,UAAU,EAAE,MAAM,CAAA;KAClB,CAAC,CAAA;IACF,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB;IAChC,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;CACxB"}
package/out/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@mailwoman/locale-gate",
3
+ "version": "4.0.0",
4
+ "description": "Stage 2 of the runtime pipeline — derive a LocaleHint from QueryShape (script + known-format hits). Rule-based v1; trained classifier deferred to v0.6.0.",
5
+ "license": "AGPL-3.0-only",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/sister-software/mailwoman.git",
9
+ "directory": "locale-gate"
10
+ },
11
+ "type": "module",
12
+ "exports": {
13
+ "./package.json": "./package.json",
14
+ ".": "./out/index.js"
15
+ },
16
+ "dependencies": {
17
+ "@mailwoman/core": "4.0.0"
18
+ },
19
+ "files": [
20
+ "out/**/*.js",
21
+ "out/**/*.js.map",
22
+ "out/**/*.d.ts",
23
+ "out/**/*.d.ts.map"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ }
28
+ }