@mailwoman/resolver-wof-wasm 8.0.0 → 8.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.
@@ -0,0 +1,341 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Tree resolution over a browser-side place lookup.
7
+ *
8
+ * This lived in the docs site (`docs/src/shared/`), which made it unreachable from the packages that
9
+ * need it: `hot-db.test.ts` here had to reach across a workspace boundary into a private Docusaurus
10
+ * app, dragging its React graph into a project that has no business type-checking it. Nothing in this
11
+ * file is docs-specific — it is the browser half of the same resolve cascade the node path runs.
12
+ *
13
+ * The lookup is structural (`MailwomanLookupLike`) rather than a concrete class, so the demo's HTTPVFS
14
+ * lookup, the WASM lookup here, and any future one all satisfy it.
15
+ */
16
+
17
+ import type { ResolvedPlace, ResolverBackend } from "@mailwoman/core/resolver"
18
+ import { createWOFResolver } from "@mailwoman/resolver/resolve"
19
+
20
+ /**
21
+ * One additional admin role a resolved place ALSO fulfils — the dual-role / city-state relation (#402). Berlin resolves
22
+ * as a locality but `role: "region"` here surfaces that it is also a federal state. `relationshipType` is the
23
+ * gazetteer-derived class (`city-state`, `capital-seat`, …).
24
+ */
25
+ export interface DualRole {
26
+ id: number
27
+ name: string
28
+ placetype: string
29
+ relationshipType: string
30
+ role: "region" | "locality"
31
+ }
32
+
33
+ export interface MailwomanLookupLike {
34
+ findPlace: (q: {
35
+ text: string
36
+ /**
37
+ * Requested placetype(s). Widened from the demo's original locality/postalcode/region union for the #861
38
+ * shared-resolver convergence: `resolveTree` + its coherence passes also query `country`, `county`, and pass arrays
39
+ * (the placetype-equivalence groups).
40
+ */
41
+ placetype?: string | string[] | undefined
42
+ country?: string
43
+ /**
44
+ * Point-in-bbox filter — constrains candidates to a parsed region/state's bounds.
45
+ */
46
+ bbox?: { minLat: number; maxLat: number; minLon: number; maxLon: number }
47
+ limit?: number
48
+ postcode?: string
49
+ /**
50
+ * Soft proximity hints (#938 — the demo's map viewport / user location). With bias present, exact-tier candidates
51
+ * near a hint sort ahead of distant ones; never a hard filter. Absent → population-first order.
52
+ */
53
+ bias?: Array<{ lat: number; lon: number; weight?: number }>
54
+ }) => Promise<
55
+ Array<{
56
+ id: number
57
+ name: string
58
+ placetype: string
59
+ /**
60
+ * ISO country code of the resolved place — lets the cascade country-gate an ambiguous postcode.
61
+ */
62
+ country?: string
63
+ lat: number
64
+ lon: number
65
+ score: number
66
+ /**
67
+ * True when the candidate's name, abbreviation, or an alias EXACTLY matched the query (vs a partial token match).
68
+ * The cascade accepts alias-exact hits ("New York City" → New York) the same way it accepts canonical-name
69
+ * matches.
70
+ */
71
+ exactMatch?: boolean
72
+ bbox?: { minLat: number; maxLat: number; minLon: number; maxLon: number }
73
+ }>
74
+ >
75
+ /**
76
+ * Dual-role partner roles for a resolved place id (#402). Optional — absent on lookups built from a slim DB that
77
+ * predates the `coincident_roles` relation.
78
+ */
79
+ coincidentRolesFor?: (placeID: number) => Promise<DualRole[]>
80
+ }
81
+
82
+ type CascadeHits = Awaited<ReturnType<MailwomanLookupLike["findPlace"]>>
83
+
84
+ /**
85
+ * Soft proximity hints (#938 `bias[]`): ordered, weighted, never a hard filter.
86
+ */
87
+ export type ResolveBias = Array<{ lat: number; lon: number; weight?: number }>
88
+
89
+ type LookupHit = Awaited<ReturnType<MailwomanLookupLike["findPlace"]>>[number]
90
+
91
+ type BBox = NonNullable<LookupHit["bbox"]>
92
+
93
+ /**
94
+ * What the adapter remembers about every candidate it has surfaced, keyed by place id.
95
+ */
96
+ interface CandidateMeta {
97
+ bbox?: BBox
98
+ country?: string
99
+ placetype: string
100
+ }
101
+
102
+ /**
103
+ * Minimal structural view of a decorated `AddressTree` node (decoupled from core's types).
104
+ */
105
+ interface ResolvedTreeNode {
106
+ source?: string
107
+ sourceID?: string
108
+ value?: unknown
109
+ lat?: number
110
+ lon?: number
111
+ placeID?: string
112
+ metadata?: Record<string, unknown>
113
+ alternatives?: unknown[]
114
+ children?: ResolvedTreeNode[]
115
+ }
116
+
117
+ /**
118
+ * WOF hierarchy rank of a locality.
119
+ */
120
+ const WOF_RANK_LOCALITY = 5
121
+
122
+ /**
123
+ * WOF hierarchy rank of a region, one step up from a locality.
124
+ */
125
+ const WOF_RANK_REGION = 4
126
+
127
+ /**
128
+ * How the demo picks THE pin from a resolved tree: prefer the most address-precise resolved node. Same ordering the
129
+ * eval harnesses use; `postalcode` outranks `locality` (the old cascade's "postcode first, most precise" tier), peers
130
+ * of locality sit just below it.
131
+ */
132
+ const PIN_RANK: Record<string, number> = {
133
+ postalcode: 6,
134
+ locality: 5,
135
+ borough: 4,
136
+ localadmin: 4,
137
+ neighbourhood: 4,
138
+ county: 3,
139
+ macrocounty: 3,
140
+ region: 2,
141
+ macroregion: 2,
142
+ country: 1,
143
+ }
144
+
145
+ export class CandidateResolverBackend implements ResolverBackend {
146
+ readonly #lookup: MailwomanLookupLike
147
+ readonly #meta = new Map<number, CandidateMeta>()
148
+
149
+ constructor(lookup: MailwomanLookupLike) {
150
+ this.#lookup = lookup
151
+ }
152
+
153
+ /**
154
+ * The memoized bbox/country/placetype of a previously returned candidate (for hit assembly).
155
+ */
156
+ metaFor(id: number): CandidateMeta | undefined {
157
+ return this.#meta.get(id)
158
+ }
159
+
160
+ async findPlace(query: Parameters<ResolverBackend["findPlace"]>[0]): Promise<ResolvedPlace[]> {
161
+ let bbox: BBox | undefined
162
+ let country = query.country
163
+
164
+ if (query.parentID !== undefined) {
165
+ const parent = this.#meta.get(Number(query.parentID))
166
+
167
+ // A parent the table can't scope by: answer "no descendants" and let the resolver's
168
+ // parentFallback retry unscoped. Silent unscoped results here would defeat the descent test.
169
+ if (!parent) return []
170
+
171
+ if (parent.placetype === "country" && parent.country) {
172
+ country = parent.country
173
+ } else if (parent.bbox) {
174
+ bbox = parent.bbox
175
+
176
+ // A region's country still constrains — "Springfield under Georgia (US state)" must not
177
+ // admit Georgian (GE) rows that happen to fall in the bbox overlap.
178
+ country ??= parent.country
179
+ } else if (parent.country) {
180
+ country = parent.country
181
+ } else {
182
+ return []
183
+ }
184
+ }
185
+
186
+ const hits = await this.#lookup.findPlace({
187
+ text: query.text,
188
+ placetype: query.placetype,
189
+ country,
190
+ bbox,
191
+ postcode: query.postcode,
192
+ limit: query.limit,
193
+ // #938: forward the proximity hints (map viewport / user location) so the candidate lookup
194
+ // re-ranks the exact tier by nearness — dropped here, the demo's viewport bias was inert.
195
+ bias: query.bias,
196
+ })
197
+
198
+ return hits.map((h) => {
199
+ this.#meta.set(h.id, { bbox: h.bbox, country: h.country, placetype: h.placetype })
200
+
201
+ return {
202
+ id: h.id,
203
+ name: h.name,
204
+ placetype: h.placetype,
205
+ lat: h.lat,
206
+ lon: h.lon,
207
+ score: h.score,
208
+ // ResolvedPlace requires a country; "" is the honest unknown (matches no ISO code, so
209
+ // the coherence passes treat it as un-scopable rather than accidentally matching).
210
+ country: h.country ?? "",
211
+ exactMatch: h.exactMatch,
212
+ }
213
+ })
214
+ }
215
+ }
216
+
217
+ export async function runCascade(
218
+ lookup: MailwomanLookupLike,
219
+ tree: { roots: unknown[] },
220
+ rawText: string,
221
+ bias?: ResolveBias
222
+ ): Promise<CascadeHits> {
223
+ const usable = (cs: CascadeHits): CascadeHits => cs.filter((c) => !(c.lat === 0 && c.lon === 0))
224
+
225
+ const backend = new CandidateResolverBackend(lookup)
226
+ const resolver = createWOFResolver(backend as never)
227
+
228
+ // adminCoherence is the point of the convergence (the passes the old cascade approximated);
229
+ // spanRescore + hierarchyCompletion ride their shared defaults. No defaultCountry — the demo is
230
+ // global by design (the placer/population ranking routes, never a hardcoded country).
231
+ // bias (#938): the map viewport (and optional geolocation) as SOFT proximity hints — an in-view
232
+ // namesake sorts ahead of a distant one at equal exact-tier, and no-bias stays byte-identical
233
+ // (48026 → Fraser MI vs Russi IT, the rule the library gate pins). Omitted when empty.
234
+ const resolved = (await resolver.resolveTree(tree as never, {
235
+ adminCoherence: true,
236
+ ...(bias && bias.length ? { bias } : {}),
237
+ })) as unknown as {
238
+ roots: ResolvedTreeNode[]
239
+ }
240
+
241
+ // Collect every resolver-decorated node, best-pin first.
242
+ const collected: Array<{ hit: CascadeHits[number]; rank: number }> = []
243
+ const alternativesOf = new Map<number, CascadeHits>()
244
+
245
+ const visit = (node: ResolvedTreeNode): void => {
246
+ if (node.source === "resolver" && node.sourceID && typeof node.lat === "number" && typeof node.lon === "number") {
247
+ const sep = node.sourceID.indexOf(":")
248
+ const placetype = sep === -1 ? node.sourceID : node.sourceID.slice(0, sep)
249
+ const id = Number(node.placeID?.replace(/^wof:/, "") ?? node.sourceID.slice(sep + 1))
250
+ const meta = backend.metaFor(id)
251
+
252
+ const hit: CascadeHits[number] = {
253
+ id,
254
+ name: String(node.metadata?.["resolver_name"] ?? node.value ?? ""),
255
+ placetype,
256
+ country: meta?.country,
257
+ lat: node.lat,
258
+ lon: node.lon,
259
+ score: typeof node.metadata?.["resolver_score"] === "number" ? (node.metadata["resolver_score"] as number) : 0,
260
+ exactMatch: true,
261
+ bbox: meta?.bbox,
262
+ }
263
+
264
+ if (!(hit.lat === 0 && hit.lon === 0)) {
265
+ collected.push({ hit, rank: PIN_RANK[placetype] ?? 0 })
266
+
267
+ const alts = (node.alternatives as Array<Record<string, unknown>> | undefined) ?? []
268
+
269
+ alternativesOf.set(
270
+ id,
271
+ usable(
272
+ alts.map((a) => ({
273
+ id: Number(a.id),
274
+ name: String(a.name ?? ""),
275
+ placetype: String(a.placetype ?? placetype),
276
+ country: typeof a.country === "string" && a.country ? a.country : undefined,
277
+ lat: Number(a.lat),
278
+ lon: Number(a.lon),
279
+ score: typeof a.score === "number" ? a.score : 0,
280
+ exactMatch: a.exactMatch === true,
281
+ bbox: backend.metaFor(Number(a.id))?.bbox,
282
+ }))
283
+ )
284
+ )
285
+ }
286
+ }
287
+
288
+ for (const child of node.children ?? []) {
289
+ visit(child)
290
+ }
291
+ }
292
+
293
+ for (const root of resolved.roots) {
294
+ visit(root)
295
+ }
296
+
297
+ if (!collected.length) {
298
+ // Nothing in the tree resolved (span-rescore included) — the old cascade's last resort.
299
+ return usable(await lookup.findPlace({ text: rawText, limit: 5 }))
300
+ }
301
+
302
+ collected.sort((a, b) => b.rank - a.rank || b.hit.score - a.hit.score)
303
+
304
+ // Cross-country postcode gate, carried over from the old cascade: an ambiguous INTERNATIONAL
305
+ // postcode (10115 = Berlin DE and a New York US ZIP shape) must not out-pin the parsed city
306
+ // across countries. When the top pin is a postcode whose country differs from the resolved
307
+ // locality's, the locality wins the pin; the postcode stays in the list.
308
+ const top = collected[0]!
309
+ const localityEntry = collected.find((c) => c.rank === WOF_RANK_LOCALITY || c.rank === WOF_RANK_REGION)
310
+
311
+ let pinOrder = collected
312
+
313
+ if (
314
+ top.hit.placetype === "postalcode" &&
315
+ localityEntry &&
316
+ top.hit.country &&
317
+ localityEntry.hit.country &&
318
+ top.hit.country !== localityEntry.hit.country
319
+ ) {
320
+ pinOrder = [localityEntry, ...collected.filter((c) => c !== localityEntry)]
321
+ }
322
+
323
+ const seen = new Set<number>()
324
+ const hits: CascadeHits = []
325
+
326
+ for (const { hit } of pinOrder) {
327
+ if (!seen.has(hit.id)) {
328
+ seen.add(hit.id)
329
+ hits.push(hit)
330
+ }
331
+
332
+ for (const alt of alternativesOf.get(hit.id) ?? []) {
333
+ if (!seen.has(alt.id)) {
334
+ seen.add(alt.id)
335
+ hits.push(alt)
336
+ }
337
+ }
338
+ }
339
+
340
+ return hits
341
+ }
package/loader.ts CHANGED
@@ -73,6 +73,7 @@ export async function loadSlimWOFDatabase(opts: LoadSlimOpts): Promise<{ db: Dat
73
73
  const p = sqlite3.wasm.alloc(bytes.byteLength)
74
74
  const heap = sqlite3.wasm.heap8u()
75
75
  heap.set(bytes, p)
76
+
76
77
  const rc = sqlite3.capi.sqlite3_deserialize(
77
78
  db.pointer!,
78
79
  "main",
package/lookup.ts CHANGED
@@ -26,7 +26,9 @@ import { aliasBagExactMatch } from "@mailwoman/resolver-wof-sqlite/fts"
26
26
  import type { Database } from "@sqlite.org/sqlite-wasm"
27
27
 
28
28
  export interface WOFWasmPlaceLookupOpts {
29
- /** Open `@sqlite.org/sqlite-wasm` Database (from `loadSlimWOFDatabase`). */
29
+ /**
30
+ * Open `@sqlite.org/sqlite-wasm` Database (from `loadSlimWOFDatabase`).
31
+ */
30
32
  db: Database
31
33
  }
32
34
 
@@ -37,12 +39,14 @@ export interface WOFWasmPlaceLookupOpts {
37
39
  * over "West New York") without steamrolling a clearly-better text match, because exact-name tiering is consulted
38
40
  * FIRST.
39
41
  */
40
- const POPULATION_BOOST = 4.0
41
- const POPULATION_SCALE_LOG10 = 6.0
42
+ const POPULATION_BOOST = 4
43
+ const POPULATION_SCALE_LOG10 = 6
42
44
 
43
- /** Normalize a name/query for exact-match tiering: lowercase, trim, collapse internal whitespace. */
45
+ /**
46
+ * Normalize a name/query for exact-match tiering: lowercase, trim, collapse internal whitespace.
47
+ */
44
48
  function normalizeName(s: string): string {
45
- return s.toLowerCase().trim().replace(/\s+/g, " ")
49
+ return s.toLowerCase().trim().replaceAll(/\s+/g, " ")
46
50
  }
47
51
 
48
52
  export class WOFWasmPlaceLookup implements PlaceLookup {
@@ -58,19 +62,24 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
58
62
  this.#db = opts.db
59
63
  }
60
64
 
61
- /** Lazily probe (once) whether the slim DB carries the `place_population` aux table. */
65
+ /**
66
+ * Lazily probe (once) whether the slim DB carries the `place_population` aux table.
67
+ */
62
68
  #hasPopulation(): boolean {
63
69
  if (this.#hasPopulationCache === undefined) {
64
70
  const r = this.#db.selectObjects(
65
71
  `SELECT 1 FROM sqlite_master WHERE type='table' AND name='place_population' LIMIT 1`
66
72
  )
73
+
67
74
  this.#hasPopulationCache = r.length > 0
68
75
  }
69
76
 
70
77
  return this.#hasPopulationCache
71
78
  }
72
79
 
73
- /** Lazily probe (once) whether the slim DB carries the `place_abbr` aux table (build-slim ≥ #189). */
80
+ /**
81
+ * Lazily probe (once) whether the slim DB carries the `place_abbr` aux table (build-slim ≥ #189).
82
+ */
74
83
  #hasPlaceAbbr(): boolean {
75
84
  if (this.#hasPlaceAbbrCache === undefined) {
76
85
  const r = this.#db.selectObjects(`SELECT 1 FROM sqlite_master WHERE type='table' AND name='place_abbr' LIMIT 1`)
@@ -88,6 +97,7 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
88
97
  const t = text.trim()
89
98
 
90
99
  if (!t || !this.#hasPlaceAbbr()) return new Set()
100
+
91
101
  const rows = this.#db.selectObjects(`SELECT id FROM place_abbr WHERE abbr = ? COLLATE NOCASE`, [t]) as Array<{
92
102
  id: number
93
103
  }>
@@ -122,7 +132,7 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
122
132
  // uses — the two backends can't drift.
123
133
  const placetypes = expandPlacetypeFilter(normalizePlacetypes(query.placetype)) as WOFPlacetype[] | null
124
134
 
125
- if (placetypes && placetypes.length > 0) {
135
+ if (placetypes && placetypes.length) {
126
136
  conditions.push(`spr.placetype IN (${placetypes.map(() => "?").join(",")})`)
127
137
  params.push(...placetypes)
128
138
  }
@@ -148,6 +158,7 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
148
158
  // bm25, which is why the demo targeted West New York for "New York, NY".)
149
159
  const hasPop = this.#hasPopulation()
150
160
  const pool = Math.max(limit, 50)
161
+
151
162
  const sql =
152
163
  `SELECT spr.id, spr.name, spr.placetype, spr.country, spr.latitude, spr.longitude, spr.parent_id, ` +
153
164
  `spr.min_latitude, spr.max_latitude, spr.min_longitude, spr.max_longitude, ` +
@@ -158,6 +169,7 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
158
169
  `WHERE ${conditions.join(" AND ")} ` +
159
170
  `ORDER BY bm25(place_search) ASC ` +
160
171
  `LIMIT ?`
172
+
161
173
  params.push(pool)
162
174
 
163
175
  const rows = this.#db.selectObjects(sql, params) as Array<{
@@ -185,10 +197,12 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
185
197
  // DBs built before place_abbr (the table is absent → empty set). This is the data-driven
186
198
  // replacement for the demo's hardcoded `expandUSRegion` map; it also generalizes beyond US.
187
199
  const abbrIds = this.#abbrExactIds(text)
200
+
188
201
  // Strict exact = canonical name or region abbreviation equals the query. Computed for the whole
189
202
  // pool FIRST because the ALIAS tier below only engages when no strict exact exists.
190
203
  const strictExact = (row: { name: string; id: number }): boolean =>
191
204
  normalizeName(row.name) === normQuery || abbrIds.has(row.id)
205
+
192
206
  const anyStrictExact = rows.some(strictExact)
193
207
 
194
208
  return rows
@@ -202,16 +216,18 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
202
216
  // (`WOFSqlitePlaceLookup.#exactMatchIds`).
203
217
  const aliasExact = aliasBagExactMatch(row.alt_names, normQuery, anyStrictExact)
204
218
  const exactTier = strictExact(row) || aliasExact ? 0 : 1
219
+
205
220
  const popBoost =
206
221
  row.population && row.population > 0
207
222
  ? POPULATION_BOOST * Math.min(1, Math.log10(1 + row.population) / POPULATION_SCALE_LOG10)
208
223
  : 0
224
+
209
225
  // Lower adjScore = better, matching SQLite's bm25 convention (more negative = better).
210
226
  const adjScore = row.bm25 - popBoost
211
227
 
212
228
  return { row, exactTier, adjScore }
213
229
  })
214
- .sort((a, b) => a.exactTier - b.exactTier || a.adjScore - b.adjScore)
230
+ .toSorted((a, b) => a.exactTier - b.exactTier || a.adjScore - b.adjScore)
215
231
  .slice(0, limit)
216
232
  .map(({ row, adjScore, exactTier }) => ({
217
233
  id: row.id,
@@ -252,11 +268,12 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
252
268
 
253
269
  if (!this.#coincidentRolesCache) {
254
270
  const map = new Map<number, CoincidentLocality[]>()
271
+
255
272
  const exists = this.#db.selectObjects(
256
273
  `SELECT 1 FROM sqlite_master WHERE type='table' AND name='coincident_roles' LIMIT 1`
257
274
  )
258
275
 
259
- if (exists.length > 0) {
276
+ if (exists.length) {
260
277
  const rows = this.#db.selectObjects(
261
278
  `SELECT cr.admin_id AS adminID, s.id AS id, s.name AS name, s.country AS country,
262
279
  s.latitude AS lat, s.longitude AS lon, cr.relationship_type AS relationshipType,
@@ -287,6 +304,7 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
287
304
  population: r.population,
288
305
  distanceKm: r.distanceKm,
289
306
  }
307
+
290
308
  const list = map.get(r.adminID)
291
309
 
292
310
  if (list) {
@@ -296,6 +314,7 @@ export class WOFWasmPlaceLookup implements PlaceLookup {
296
314
  }
297
315
  }
298
316
  }
317
+
299
318
  this.#coincidentRolesCache = map
300
319
  }
301
320
 
@@ -323,10 +342,11 @@ function sanitizeFTSQuery(text: string, opts?: { fuseTokens?: boolean }): string
323
342
 
324
343
  // #920 name law (postcode-typed queries): delete intra-token punctuation and fuse.
325
344
  if (opts?.fuseTokens) {
326
- const body = trimmed.replace(/[^\p{L}\p{N}]/gu, "")
345
+ const body = trimmed.replaceAll(/[^\p{L}\p{N}]/gu, "")
327
346
 
328
347
  if (!body) continue
329
- out.push(hasPrefixStar ? `${body}*` : `"${body.replace(/"/g, '""')}"`)
348
+ out.push(hasPrefixStar ? `${body}*` : `"${body.replaceAll('"', '""')}"`)
349
+
330
350
  continue
331
351
  }
332
352
 
@@ -335,10 +355,10 @@ function sanitizeFTSQuery(text: string, opts?: { fuseTokens?: boolean }): string
335
355
  const parts = trimmed.split(/[^\p{L}\p{N}]+/u).filter(Boolean)
336
356
 
337
357
  for (let i = 0; i < parts.length; i++) {
338
- const body = parts[i]!.replace(/\*/g, "")
358
+ const body = parts[i]!.replaceAll("*", "")
339
359
 
340
360
  if (!body) continue
341
- out.push(hasPrefixStar && i === parts.length - 1 ? `${body}*` : `"${body.replace(/"/g, '""')}"`)
361
+ out.push(hasPrefixStar && i === parts.length - 1 ? `${body}*` : `"${body.replaceAll('"', '""')}"`)
342
362
  }
343
363
  }
344
364
 
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Tree resolution over a browser-side place lookup.
7
+ *
8
+ * This lived in the docs site (`docs/src/shared/`), which made it unreachable from the packages that
9
+ * need it: `hot-db.test.ts` here had to reach across a workspace boundary into a private Docusaurus
10
+ * app, dragging its React graph into a project that has no business type-checking it. Nothing in this
11
+ * file is docs-specific — it is the browser half of the same resolve cascade the node path runs.
12
+ *
13
+ * The lookup is structural (`MailwomanLookupLike`) rather than a concrete class, so the demo's HTTPVFS
14
+ * lookup, the WASM lookup here, and any future one all satisfy it.
15
+ */
16
+ import type { ResolvedPlace, ResolverBackend } from "@mailwoman/core/resolver";
17
+ /**
18
+ * One additional admin role a resolved place ALSO fulfils — the dual-role / city-state relation (#402). Berlin resolves
19
+ * as a locality but `role: "region"` here surfaces that it is also a federal state. `relationshipType` is the
20
+ * gazetteer-derived class (`city-state`, `capital-seat`, …).
21
+ */
22
+ export interface DualRole {
23
+ id: number;
24
+ name: string;
25
+ placetype: string;
26
+ relationshipType: string;
27
+ role: "region" | "locality";
28
+ }
29
+ export interface MailwomanLookupLike {
30
+ findPlace: (q: {
31
+ text: string;
32
+ /**
33
+ * Requested placetype(s). Widened from the demo's original locality/postalcode/region union for the #861
34
+ * shared-resolver convergence: `resolveTree` + its coherence passes also query `country`, `county`, and pass arrays
35
+ * (the placetype-equivalence groups).
36
+ */
37
+ placetype?: string | string[] | undefined;
38
+ country?: string;
39
+ /**
40
+ * Point-in-bbox filter — constrains candidates to a parsed region/state's bounds.
41
+ */
42
+ bbox?: {
43
+ minLat: number;
44
+ maxLat: number;
45
+ minLon: number;
46
+ maxLon: number;
47
+ };
48
+ limit?: number;
49
+ postcode?: string;
50
+ /**
51
+ * Soft proximity hints (#938 — the demo's map viewport / user location). With bias present, exact-tier candidates
52
+ * near a hint sort ahead of distant ones; never a hard filter. Absent → population-first order.
53
+ */
54
+ bias?: Array<{
55
+ lat: number;
56
+ lon: number;
57
+ weight?: number;
58
+ }>;
59
+ }) => Promise<Array<{
60
+ id: number;
61
+ name: string;
62
+ placetype: string;
63
+ /**
64
+ * ISO country code of the resolved place — lets the cascade country-gate an ambiguous postcode.
65
+ */
66
+ country?: string;
67
+ lat: number;
68
+ lon: number;
69
+ score: number;
70
+ /**
71
+ * True when the candidate's name, abbreviation, or an alias EXACTLY matched the query (vs a partial token match).
72
+ * The cascade accepts alias-exact hits ("New York City" → New York) the same way it accepts canonical-name
73
+ * matches.
74
+ */
75
+ exactMatch?: boolean;
76
+ bbox?: {
77
+ minLat: number;
78
+ maxLat: number;
79
+ minLon: number;
80
+ maxLon: number;
81
+ };
82
+ }>>;
83
+ /**
84
+ * Dual-role partner roles for a resolved place id (#402). Optional — absent on lookups built from a slim DB that
85
+ * predates the `coincident_roles` relation.
86
+ */
87
+ coincidentRolesFor?: (placeID: number) => Promise<DualRole[]>;
88
+ }
89
+ type CascadeHits = Awaited<ReturnType<MailwomanLookupLike["findPlace"]>>;
90
+ /**
91
+ * Soft proximity hints (#938 `bias[]`): ordered, weighted, never a hard filter.
92
+ */
93
+ export type ResolveBias = Array<{
94
+ lat: number;
95
+ lon: number;
96
+ weight?: number;
97
+ }>;
98
+ type LookupHit = Awaited<ReturnType<MailwomanLookupLike["findPlace"]>>[number];
99
+ type BBox = NonNullable<LookupHit["bbox"]>;
100
+ /**
101
+ * What the adapter remembers about every candidate it has surfaced, keyed by place id.
102
+ */
103
+ interface CandidateMeta {
104
+ bbox?: BBox;
105
+ country?: string;
106
+ placetype: string;
107
+ }
108
+ export declare class CandidateResolverBackend implements ResolverBackend {
109
+ #private;
110
+ constructor(lookup: MailwomanLookupLike);
111
+ /**
112
+ * The memoized bbox/country/placetype of a previously returned candidate (for hit assembly).
113
+ */
114
+ metaFor(id: number): CandidateMeta | undefined;
115
+ findPlace(query: Parameters<ResolverBackend["findPlace"]>[0]): Promise<ResolvedPlace[]>;
116
+ }
117
+ export declare function runCascade(lookup: MailwomanLookupLike, tree: {
118
+ roots: unknown[];
119
+ }, rawText: string, bias?: ResolveBias): Promise<CascadeHits>;
120
+ export {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GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAuD7F;AAED,wBAAsB,UAAU,CAC/B,MAAM,EAAE,mBAAmB,EAC3B,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,EAAE,CAAA;CAAE,EAC1B,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,WAAW,GAChB,OAAO,CAAC,WAAW,CAAC,CAuHtB"}
@@ -0,0 +1,199 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Tree resolution over a browser-side place lookup.
7
+ *
8
+ * This lived in the docs site (`docs/src/shared/`), which made it unreachable from the packages that
9
+ * need it: `hot-db.test.ts` here had to reach across a workspace boundary into a private Docusaurus
10
+ * app, dragging its React graph into a project that has no business type-checking it. Nothing in this
11
+ * file is docs-specific — it is the browser half of the same resolve cascade the node path runs.
12
+ *
13
+ * The lookup is structural (`MailwomanLookupLike`) rather than a concrete class, so the demo's HTTPVFS
14
+ * lookup, the WASM lookup here, and any future one all satisfy it.
15
+ */
16
+ import { createWOFResolver } from "@mailwoman/resolver/resolve";
17
+ /**
18
+ * WOF hierarchy rank of a locality.
19
+ */
20
+ const WOF_RANK_LOCALITY = 5;
21
+ /**
22
+ * WOF hierarchy rank of a region, one step up from a locality.
23
+ */
24
+ const WOF_RANK_REGION = 4;
25
+ /**
26
+ * How the demo picks THE pin from a resolved tree: prefer the most address-precise resolved node. Same ordering the
27
+ * eval harnesses use; `postalcode` outranks `locality` (the old cascade's "postcode first, most precise" tier), peers
28
+ * of locality sit just below it.
29
+ */
30
+ const PIN_RANK = {
31
+ postalcode: 6,
32
+ locality: 5,
33
+ borough: 4,
34
+ localadmin: 4,
35
+ neighbourhood: 4,
36
+ county: 3,
37
+ macrocounty: 3,
38
+ region: 2,
39
+ macroregion: 2,
40
+ country: 1,
41
+ };
42
+ export class CandidateResolverBackend {
43
+ #lookup;
44
+ #meta = new Map();
45
+ constructor(lookup) {
46
+ this.#lookup = lookup;
47
+ }
48
+ /**
49
+ * The memoized bbox/country/placetype of a previously returned candidate (for hit assembly).
50
+ */
51
+ metaFor(id) {
52
+ return this.#meta.get(id);
53
+ }
54
+ async findPlace(query) {
55
+ let bbox;
56
+ let country = query.country;
57
+ if (query.parentID !== undefined) {
58
+ const parent = this.#meta.get(Number(query.parentID));
59
+ // A parent the table can't scope by: answer "no descendants" and let the resolver's
60
+ // parentFallback retry unscoped. Silent unscoped results here would defeat the descent test.
61
+ if (!parent)
62
+ return [];
63
+ if (parent.placetype === "country" && parent.country) {
64
+ country = parent.country;
65
+ }
66
+ else if (parent.bbox) {
67
+ bbox = parent.bbox;
68
+ // A region's country still constrains — "Springfield under Georgia (US state)" must not
69
+ // admit Georgian (GE) rows that happen to fall in the bbox overlap.
70
+ country ??= parent.country;
71
+ }
72
+ else if (parent.country) {
73
+ country = parent.country;
74
+ }
75
+ else {
76
+ return [];
77
+ }
78
+ }
79
+ const hits = await this.#lookup.findPlace({
80
+ text: query.text,
81
+ placetype: query.placetype,
82
+ country,
83
+ bbox,
84
+ postcode: query.postcode,
85
+ limit: query.limit,
86
+ // #938: forward the proximity hints (map viewport / user location) so the candidate lookup
87
+ // re-ranks the exact tier by nearness — dropped here, the demo's viewport bias was inert.
88
+ bias: query.bias,
89
+ });
90
+ return hits.map((h) => {
91
+ this.#meta.set(h.id, { bbox: h.bbox, country: h.country, placetype: h.placetype });
92
+ return {
93
+ id: h.id,
94
+ name: h.name,
95
+ placetype: h.placetype,
96
+ lat: h.lat,
97
+ lon: h.lon,
98
+ score: h.score,
99
+ // ResolvedPlace requires a country; "" is the honest unknown (matches no ISO code, so
100
+ // the coherence passes treat it as un-scopable rather than accidentally matching).
101
+ country: h.country ?? "",
102
+ exactMatch: h.exactMatch,
103
+ };
104
+ });
105
+ }
106
+ }
107
+ export async function runCascade(lookup, tree, rawText, bias) {
108
+ const usable = (cs) => cs.filter((c) => !(c.lat === 0 && c.lon === 0));
109
+ const backend = new CandidateResolverBackend(lookup);
110
+ const resolver = createWOFResolver(backend);
111
+ // adminCoherence is the point of the convergence (the passes the old cascade approximated);
112
+ // spanRescore + hierarchyCompletion ride their shared defaults. No defaultCountry — the demo is
113
+ // global by design (the placer/population ranking routes, never a hardcoded country).
114
+ // bias (#938): the map viewport (and optional geolocation) as SOFT proximity hints — an in-view
115
+ // namesake sorts ahead of a distant one at equal exact-tier, and no-bias stays byte-identical
116
+ // (48026 → Fraser MI vs Russi IT, the rule the library gate pins). Omitted when empty.
117
+ const resolved = (await resolver.resolveTree(tree, {
118
+ adminCoherence: true,
119
+ ...(bias && bias.length ? { bias } : {}),
120
+ }));
121
+ // Collect every resolver-decorated node, best-pin first.
122
+ const collected = [];
123
+ const alternativesOf = new Map();
124
+ const visit = (node) => {
125
+ if (node.source === "resolver" && node.sourceID && typeof node.lat === "number" && typeof node.lon === "number") {
126
+ const sep = node.sourceID.indexOf(":");
127
+ const placetype = sep === -1 ? node.sourceID : node.sourceID.slice(0, sep);
128
+ const id = Number(node.placeID?.replace(/^wof:/, "") ?? node.sourceID.slice(sep + 1));
129
+ const meta = backend.metaFor(id);
130
+ const hit = {
131
+ id,
132
+ name: String(node.metadata?.["resolver_name"] ?? node.value ?? ""),
133
+ placetype,
134
+ country: meta?.country,
135
+ lat: node.lat,
136
+ lon: node.lon,
137
+ score: typeof node.metadata?.["resolver_score"] === "number" ? node.metadata["resolver_score"] : 0,
138
+ exactMatch: true,
139
+ bbox: meta?.bbox,
140
+ };
141
+ if (!(hit.lat === 0 && hit.lon === 0)) {
142
+ collected.push({ hit, rank: PIN_RANK[placetype] ?? 0 });
143
+ const alts = node.alternatives ?? [];
144
+ alternativesOf.set(id, usable(alts.map((a) => ({
145
+ id: Number(a.id),
146
+ name: String(a.name ?? ""),
147
+ placetype: String(a.placetype ?? placetype),
148
+ country: typeof a.country === "string" && a.country ? a.country : undefined,
149
+ lat: Number(a.lat),
150
+ lon: Number(a.lon),
151
+ score: typeof a.score === "number" ? a.score : 0,
152
+ exactMatch: a.exactMatch === true,
153
+ bbox: backend.metaFor(Number(a.id))?.bbox,
154
+ }))));
155
+ }
156
+ }
157
+ for (const child of node.children ?? []) {
158
+ visit(child);
159
+ }
160
+ };
161
+ for (const root of resolved.roots) {
162
+ visit(root);
163
+ }
164
+ if (!collected.length) {
165
+ // Nothing in the tree resolved (span-rescore included) — the old cascade's last resort.
166
+ return usable(await lookup.findPlace({ text: rawText, limit: 5 }));
167
+ }
168
+ collected.sort((a, b) => b.rank - a.rank || b.hit.score - a.hit.score);
169
+ // Cross-country postcode gate, carried over from the old cascade: an ambiguous INTERNATIONAL
170
+ // postcode (10115 = Berlin DE and a New York US ZIP shape) must not out-pin the parsed city
171
+ // across countries. When the top pin is a postcode whose country differs from the resolved
172
+ // locality's, the locality wins the pin; the postcode stays in the list.
173
+ const top = collected[0];
174
+ const localityEntry = collected.find((c) => c.rank === WOF_RANK_LOCALITY || c.rank === WOF_RANK_REGION);
175
+ let pinOrder = collected;
176
+ if (top.hit.placetype === "postalcode" &&
177
+ localityEntry &&
178
+ top.hit.country &&
179
+ localityEntry.hit.country &&
180
+ top.hit.country !== localityEntry.hit.country) {
181
+ pinOrder = [localityEntry, ...collected.filter((c) => c !== localityEntry)];
182
+ }
183
+ const seen = new Set();
184
+ const hits = [];
185
+ for (const { hit } of pinOrder) {
186
+ if (!seen.has(hit.id)) {
187
+ seen.add(hit.id);
188
+ hits.push(hit);
189
+ }
190
+ for (const alt of alternativesOf.get(hit.id) ?? []) {
191
+ if (!seen.has(alt.id)) {
192
+ seen.add(alt.id);
193
+ hits.push(alt);
194
+ }
195
+ }
196
+ }
197
+ return hits;
198
+ }
199
+ //# sourceMappingURL=browser-cascade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-cascade.js","sourceRoot":"","sources":["../browser-cascade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAmG/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cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;gBAChB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACf,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAA;AACZ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAA0B,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAE9F,MAAM,WAAW,YAAY;IAC5B;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;IAC3B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACxB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAAC,CAwC/G"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAA0B,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAE9F,MAAM,WAAW,YAAY;IAC5B;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;IAC3B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,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/lookup.d.ts CHANGED
@@ -21,7 +21,9 @@ import { type CoincidentLocality } from "@mailwoman/resolver";
21
21
  import type { FindPlaceQuery, PlaceCandidate, PlaceLookup } from "@mailwoman/resolver-wof-sqlite";
22
22
  import type { Database } from "@sqlite.org/sqlite-wasm";
23
23
  export interface WOFWasmPlaceLookupOpts {
24
- /** Open `@sqlite.org/sqlite-wasm` Database (from `loadSlimWOFDatabase`). */
24
+ /**
25
+ * Open `@sqlite.org/sqlite-wasm` Database (from `loadSlimWOFDatabase`).
26
+ */
25
27
  db: Database;
26
28
  }
27
29
  export declare class WOFWasmPlaceLookup implements PlaceLookup {
@@ -1 +1 @@
1
- {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAgB,MAAM,gCAAgC,CAAA;AAI/G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD,MAAM,WAAW,sBAAsB;IACtC,4EAA4E;IAC5E,EAAE,EAAE,QAAQ,CAAA;CACZ;AAiBD,qBAAa,kBAAmB,YAAW,WAAW;;gBASzC,IAAI,EAAE,sBAAsB;IAyClC,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAgJjE;;;;;OAKG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,kBAAkB,EAAE;IAyDvE,KAAK,IAAI,IAAI;CAGb"}
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAgB,MAAM,gCAAgC,CAAA;AAI/G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,EAAE,EAAE,QAAQ,CAAA;CACZ;AAmBD,qBAAa,kBAAmB,YAAW,WAAW;;gBASzC,IAAI,EAAE,sBAAsB;IA+ClC,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAsJjE;;;;;OAKG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,kBAAkB,EAAE;IA4DvE,KAAK,IAAI,IAAI;CAGb"}
package/out/lookup.js CHANGED
@@ -28,11 +28,13 @@ import { aliasBagExactMatch } from "@mailwoman/resolver-wof-sqlite/fts";
28
28
  * over "West New York") without steamrolling a clearly-better text match, because exact-name tiering is consulted
29
29
  * FIRST.
30
30
  */
31
- const POPULATION_BOOST = 4.0;
32
- const POPULATION_SCALE_LOG10 = 6.0;
33
- /** Normalize a name/query for exact-match tiering: lowercase, trim, collapse internal whitespace. */
31
+ const POPULATION_BOOST = 4;
32
+ const POPULATION_SCALE_LOG10 = 6;
33
+ /**
34
+ * Normalize a name/query for exact-match tiering: lowercase, trim, collapse internal whitespace.
35
+ */
34
36
  function normalizeName(s) {
35
- return s.toLowerCase().trim().replace(/\s+/g, " ");
37
+ return s.toLowerCase().trim().replaceAll(/\s+/g, " ");
36
38
  }
37
39
  export class WOFWasmPlaceLookup {
38
40
  #db;
@@ -45,7 +47,9 @@ export class WOFWasmPlaceLookup {
45
47
  constructor(opts) {
46
48
  this.#db = opts.db;
47
49
  }
48
- /** Lazily probe (once) whether the slim DB carries the `place_population` aux table. */
50
+ /**
51
+ * Lazily probe (once) whether the slim DB carries the `place_population` aux table.
52
+ */
49
53
  #hasPopulation() {
50
54
  if (this.#hasPopulationCache === undefined) {
51
55
  const r = this.#db.selectObjects(`SELECT 1 FROM sqlite_master WHERE type='table' AND name='place_population' LIMIT 1`);
@@ -53,7 +57,9 @@ export class WOFWasmPlaceLookup {
53
57
  }
54
58
  return this.#hasPopulationCache;
55
59
  }
56
- /** Lazily probe (once) whether the slim DB carries the `place_abbr` aux table (build-slim ≥ #189). */
60
+ /**
61
+ * Lazily probe (once) whether the slim DB carries the `place_abbr` aux table (build-slim ≥ #189).
62
+ */
57
63
  #hasPlaceAbbr() {
58
64
  if (this.#hasPlaceAbbrCache === undefined) {
59
65
  const r = this.#db.selectObjects(`SELECT 1 FROM sqlite_master WHERE type='table' AND name='place_abbr' LIMIT 1`);
@@ -94,7 +100,7 @@ export class WOFWasmPlaceLookup {
94
100
  // match) was unreachable and the fuzzy "Brooklyn Park, MN" won. Same table the Node resolver
95
101
  // uses — the two backends can't drift.
96
102
  const placetypes = expandPlacetypeFilter(normalizePlacetypes(query.placetype));
97
- if (placetypes && placetypes.length > 0) {
103
+ if (placetypes && placetypes.length) {
98
104
  conditions.push(`spr.placetype IN (${placetypes.map(() => "?").join(",")})`);
99
105
  params.push(...placetypes);
100
106
  }
@@ -158,7 +164,7 @@ export class WOFWasmPlaceLookup {
158
164
  const adjScore = row.bm25 - popBoost;
159
165
  return { row, exactTier, adjScore };
160
166
  })
161
- .sort((a, b) => a.exactTier - b.exactTier || a.adjScore - b.adjScore)
167
+ .toSorted((a, b) => a.exactTier - b.exactTier || a.adjScore - b.adjScore)
162
168
  .slice(0, limit)
163
169
  .map(({ row, adjScore, exactTier }) => ({
164
170
  id: row.id,
@@ -197,7 +203,7 @@ export class WOFWasmPlaceLookup {
197
203
  if (!this.#coincidentRolesCache) {
198
204
  const map = new Map();
199
205
  const exists = this.#db.selectObjects(`SELECT 1 FROM sqlite_master WHERE type='table' AND name='coincident_roles' LIMIT 1`);
200
- if (exists.length > 0) {
206
+ if (exists.length) {
201
207
  const rows = this.#db.selectObjects(`SELECT cr.admin_id AS adminID, s.id AS id, s.name AS name, s.country AS country,
202
208
  s.latitude AS lat, s.longitude AS lon, cr.relationship_type AS relationshipType,
203
209
  cr.locality_population AS population, cr.distance_km AS distanceKm
@@ -246,20 +252,20 @@ function sanitizeFTSQuery(text, opts) {
246
252
  const hasPrefixStar = trimmed.endsWith("*");
247
253
  // #920 name law (postcode-typed queries): delete intra-token punctuation and fuse.
248
254
  if (opts?.fuseTokens) {
249
- const body = trimmed.replace(/[^\p{L}\p{N}]/gu, "");
255
+ const body = trimmed.replaceAll(/[^\p{L}\p{N}]/gu, "");
250
256
  if (!body)
251
257
  continue;
252
- out.push(hasPrefixStar ? `${body}*` : `"${body.replace(/"/g, '""')}"`);
258
+ out.push(hasPrefixStar ? `${body}*` : `"${body.replaceAll('"', '""')}"`);
253
259
  continue;
254
260
  }
255
261
  // Non-postcode queries SPLIT on intra-token punctuation — fusing made "Thiron-Gardais" an
256
262
  // unmatchable single term while the FTS doc holds two (#945).
257
263
  const parts = trimmed.split(/[^\p{L}\p{N}]+/u).filter(Boolean);
258
264
  for (let i = 0; i < parts.length; i++) {
259
- const body = parts[i].replace(/\*/g, "");
265
+ const body = parts[i].replaceAll("*", "");
260
266
  if (!body)
261
267
  continue;
262
- out.push(hasPrefixStar && i === parts.length - 1 ? `${body}*` : `"${body.replace(/"/g, '""')}"`);
268
+ out.push(hasPrefixStar && i === parts.length - 1 ? `${body}*` : `"${body.replaceAll('"', '""')}"`);
263
269
  }
264
270
  }
265
271
  return out.join(" ");
package/out/lookup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lookup.js","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,qBAAqB,EAA2B,MAAM,qBAAqB,CAAA;AAEpF,2FAA2F;AAC3F,0FAA0F;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAQvE;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAC5B,MAA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GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACrB,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAkC;IAC9D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAC9C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailwoman/resolver-wof-wasm",
3
- "version": "8.0.0",
3
+ "version": "8.2.0",
4
4
  "description": "Who's On First WASM resolver — browser-side PlaceLookup backed by @sqlite.org/sqlite-wasm. Drop-in replacement for @mailwoman/resolver-wof-sqlite when you need a static-asset deploy (Phase B of the demo plan).",
5
5
  "license": "AGPL-3.0-only OR LicenseRef-Commercial",
6
6
  "repository": {
@@ -29,6 +29,10 @@
29
29
  ".": {
30
30
  "types": "./out/index.d.ts",
31
31
  "default": "./out/index.js"
32
+ },
33
+ "./browser-cascade": {
34
+ "types": "./out/browser-cascade.d.ts",
35
+ "default": "./out/browser-cascade.js"
32
36
  }
33
37
  },
34
38
  "publishConfig": {
@@ -38,13 +42,17 @@
38
42
  ".": {
39
43
  "types": "./out/index.d.ts",
40
44
  "default": "./out/index.js"
45
+ },
46
+ "./browser-cascade": {
47
+ "types": "./out/browser-cascade.d.ts",
48
+ "default": "./out/browser-cascade.js"
41
49
  }
42
50
  }
43
51
  },
44
52
  "dependencies": {
45
- "@mailwoman/core": "8.0.0",
46
- "@mailwoman/resolver": "8.0.0",
47
- "@mailwoman/resolver-wof-sqlite": "8.0.0",
53
+ "@mailwoman/core": "8.2.0",
54
+ "@mailwoman/resolver": "8.2.0",
55
+ "@mailwoman/resolver-wof-sqlite": "8.2.0",
48
56
  "@sqlite.org/sqlite-wasm": "^3.53.0-build1"
49
57
  }
50
58
  }