@finbheara/domain 0.40.0 → 0.42.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.
@@ -7422,6 +7422,7 @@ function genericKey2(folded) {
7422
7422
  var DEFAULT_PLACE_CAPACITY2 = 8192;
7423
7423
  var PLACE_CELL_SENTINELS = [...SHARED_ROW_SENTINELS2];
7424
7424
  var placeCellSentinelOf = sentinelIn2(PLACE_CELL_SENTINELS);
7425
+ var SHARED_INDEXES = new WeakMap;
7425
7426
  function createPlaceReader2(options = {}) {
7426
7427
  const nodes = options.tree ?? PLACE_NODES;
7427
7428
  const withinTable = options.within ?? PLACE_WITHIN;
@@ -7500,14 +7501,7 @@ function createPlaceReader2(options = {}) {
7500
7501
  const listedPhrases = new Set;
7501
7502
  const byHeading = new Map;
7502
7503
  const byRunPrint = new Map;
7503
- const byGeneric = new Map;
7504
7504
  for (const n of source) {
7505
- if (generic && n.kind === "city")
7506
- for (const p of [n.name, ...n.prints]) {
7507
- const k = genericKey2(fold(p));
7508
- if (k !== undefined)
7509
- push(byGeneric, k, n);
7510
- }
7511
7505
  for (const h of n.headings ?? [])
7512
7506
  push(byHeading, fold(h), n);
7513
7507
  for (const r of n.runPrints ?? [])
@@ -7515,11 +7509,12 @@ function createPlaceReader2(options = {}) {
7515
7509
  push(byPrint, fold(n.id), n);
7516
7510
  if (n.kind !== "body")
7517
7511
  push(byPrint, fold(n.name), n);
7518
- for (const p of n.prints)
7519
- push(byPrint, fold(p), n);
7520
- for (const p of n.prints)
7521
- if (fold(p).includes(" "))
7522
- listedPhrases.add(fold(p));
7512
+ for (const p of n.prints) {
7513
+ const f = fold(p);
7514
+ push(byPrint, f, n);
7515
+ if (f.includes(" "))
7516
+ listedPhrases.add(f);
7517
+ }
7523
7518
  for (const c of n.codes)
7524
7519
  push(byCode, c, n);
7525
7520
  for (const t of n.truncations ?? [])
@@ -7571,9 +7566,15 @@ function createPlaceReader2(options = {}) {
7571
7566
  }
7572
7567
  return out;
7573
7568
  };
7574
- const parents = new Map;
7575
- for (const n of source)
7576
- parents.set(n.id, upOf(n));
7569
+ let parents;
7570
+ const graph = () => {
7571
+ if (parents !== undefined)
7572
+ return parents;
7573
+ parents = new Map;
7574
+ for (const n of source)
7575
+ parents.set(n.id, upOf(n));
7576
+ return parents;
7577
+ };
7577
7578
  const countryOnMap = (n) => {
7578
7579
  const seen = new Set;
7579
7580
  for (let at = n;at !== undefined && !seen.has(at.id); ) {
@@ -7597,8 +7598,15 @@ function createPlaceReader2(options = {}) {
7597
7598
  }
7598
7599
  return;
7599
7600
  };
7600
- const ancestorsOf = new Map;
7601
- for (const n of source) {
7601
+ const ancestors = new Map;
7602
+ const ancestorsOf = (id) => {
7603
+ const held = ancestors.get(id);
7604
+ if (held !== undefined)
7605
+ return held;
7606
+ const n = byId.get(id);
7607
+ if (n === undefined)
7608
+ return;
7609
+ const parents = graph();
7602
7610
  const out = new Set;
7603
7611
  const todo = [n];
7604
7612
  const own = countryOnMap(n);
@@ -7616,35 +7624,67 @@ function createPlaceReader2(options = {}) {
7616
7624
  todo.push(parent);
7617
7625
  }
7618
7626
  }
7619
- ancestorsOf.set(n.id, out);
7620
- }
7621
- const phrases = [...byPrint.keys()].filter((k) => k.includes(" ")).sort((a, b) => b.length - a.length);
7622
- const printsSorted = [...byPrint.keys()].map((k, i) => [k, i]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
7627
+ ancestors.set(id, out);
7628
+ return out;
7629
+ };
7630
+ let byStem;
7631
+ let byGeneric;
7623
7632
  return {
7624
7633
  byId,
7625
7634
  byPrint,
7626
- printsSorted,
7635
+ get byStem() {
7636
+ if (byStem !== undefined)
7637
+ return byStem;
7638
+ byStem = new Map;
7639
+ for (const k of byPrint.keys()) {
7640
+ if (k.length < MIN_STEM)
7641
+ continue;
7642
+ const stem = k.slice(0, MIN_STEM);
7643
+ const run = byStem.get(stem);
7644
+ if (run === undefined)
7645
+ byStem.set(stem, [k]);
7646
+ else
7647
+ run.push(k);
7648
+ }
7649
+ return byStem;
7650
+ },
7627
7651
  byCode,
7628
7652
  byTruncation,
7629
7653
  byCountryCode,
7630
7654
  bySubdivisionPart,
7631
7655
  byOireachtas,
7632
7656
  ancestorsOf,
7633
- carries,
7634
- phrases,
7657
+ get carries() {
7658
+ graph();
7659
+ return carries;
7660
+ },
7635
7661
  listedPhrases,
7636
7662
  byHeading,
7637
7663
  byRunPrint,
7638
- byGeneric
7664
+ get byGeneric() {
7665
+ if (byGeneric !== undefined)
7666
+ return byGeneric;
7667
+ byGeneric = new Map;
7668
+ for (const n of source)
7669
+ if (n.kind === "city")
7670
+ for (const p of [n.name, ...n.prints]) {
7671
+ const k = genericKey2(fold(p));
7672
+ if (k !== undefined)
7673
+ push(byGeneric, k, n);
7674
+ }
7675
+ return byGeneric;
7676
+ }
7639
7677
  };
7640
7678
  }
7641
7679
  function idx() {
7642
- if (index === undefined)
7643
- index = buildIndex(nodes);
7680
+ if (index !== undefined)
7681
+ return index;
7682
+ index = SHARED_INDEXES.get(nodes) ?? buildIndex(nodes);
7683
+ SHARED_INDEXES.set(nodes, index);
7644
7684
  return index;
7645
7685
  }
7646
7686
  function ancestorIds(n) {
7647
- return idx().ancestorsOf.get(n.id) ?? new Set;
7687
+ return idx().ancestorsOf(n.id) ?? new Set;
7648
7688
  }
7649
7689
  function isAncestor(a, b) {
7650
7690
  return a.id === b.id || ancestorIds(b).has(a.id);
@@ -7889,27 +7929,9 @@ function createPlaceReader2(options = {}) {
7889
7929
  if (folded.length < MIN_STEM)
7890
7930
  return [];
7891
7931
  const i = idx();
7892
- const sorted = i.printsSorted;
7893
- let lo = 0;
7894
- let hi = sorted.length;
7895
- while (lo < hi) {
7896
- const mid = lo + hi >>> 1;
7897
- if (sorted[mid][0] < folded)
7898
- lo = mid + 1;
7899
- else
7900
- hi = mid;
7901
- }
7902
- const run = [];
7903
- for (let k = lo;k < sorted.length; k++) {
7904
- const at = sorted[k];
7905
- if (!at[0].startsWith(folded))
7906
- break;
7907
- run.push(at);
7908
- }
7909
- run.sort((a, b) => a[1] - b[1]);
7910
7932
  const out = [];
7911
- for (const [key] of run) {
7912
- if (key.length <= folded.length)
7933
+ for (const key of i.byStem.get(folded.slice(0, MIN_STEM)) ?? []) {
7934
+ if (key.length <= folded.length || !key.startsWith(folded))
7913
7935
  continue;
7914
7936
  if (key[folded.length] === " ")
7915
7937
  continue;
package/dist/geocode.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  place2,
6
6
  placeFromId2,
7
7
  placeParts2
8
- } from "./chunks/place-k6y6fe1y.js";
8
+ } from "./chunks/place-5kmn6jgj.js";
9
9
 
10
10
  var PLACE_TOWNS = {
11
11
  "AUS-ACT": "Acton~~r3dp~9973368|Ainslie~~r3dp~8348552|Amaroo~~r3dp~8349331|Aranda~~r3dp~8349333|Banks~~r3dn~8348388|Barton~~r3dp~8349163|Belconnen~~r3dp~2176373|Bonner~~r3dp~9973375|Bonython~~r3dn~8349164|Braddon~~r3dp~8349165|Bruce~~r3dp~8349301|Calwell~~r3dn~8347865|Campbell~~r3dp~2172618|Canberra City~~r3dp~8347868|Casey~~r3dp~8349161~AU.07.21610|Chapman~~r39y~8349166|Charnwood~~r39z~8349169|Chifley~~r3dn~8348372|Chisholm~~r3dn~8349303|Conder~~r3dn~8349167|Cook~~r3dp~8347746~AU.04.32500|Coombs~~r39z~9973426|Crace~~r3dp~8349353|Curtin~~r3dp~8349171|Deakin~~r3dp~8349172|Dickson~~r3dp~8348400|Downer~~r3dp~8348308|Duffy~~r39y~8349425|Dunlop~~r39z~8349173|Evatt~~r3dp~8349175|Fadden~~r3dn~8348126|Farrer~~r3dn~8347869|Fisher~~r39y~8349304~CA.03.5953379|Florey~~r39z~8349174|Flynn~~r39z~8349305|Forde~~r3dp~8347874|Forrest~~r3dp~8504554|Franklin~~r3dp~8349306|Fraser~~r39z~8348647|Garran~~r3dn~9973428|Gilmore~~r3dn~8349400|Giralang~~r3dp~8348680|Gordon~~r3dn~8348660|Gowrie~~r3dn~8348892|Greenway~~r3dn~8349176|Griffith~~r3dp~8349307~AU.02.13450|Gungahlin~~r3dp~8349178|Hackett~~r3dp~8349180|Harrison~~r3dp~8349179|Hawker~~r39z~8349385|Higgins~~r39z~8349181|Holder~~r39y~8349308|Holt~~r39z~8347705|Hughes~~r3dn~8349446|Isaacs~~r3dn~8349182|Isabella Plains~~r3dn~8349183|Jacka~~r3dp~9973376|Jervis Bay Village~~r3g0~2162322|Kaleen~~r3dp~6619483|Kambah~~r39y~8348370|Kingston~~r3dp~8349299~~3489854|Latham~~r39z~8349309|Lyneham~~r3dp~8347876|Lyons~~r3dn~8349159|Macarthur~~r3dn~7302189|Macgregor~~r39z~8348907|Macquarie~~r3dp~7281844|Mawson~~r3dn~8348684|McKellar~~r3dp~8349184|Melba~~r39z~8349186|Monash~~r3dn~8349310~AU.07.24970|Narrabundah~~r3dn~8349435|Ngunnawal~~r3dp~8349187|Nicholls~~r3dp~8349185|O'Connor~~r3dp~8348190|O'Malley~~r3dn~8349436|Oxley~~r3dn~8349413|Page~~r39z~8348129|Palmerston~~r3dp~8349170~AU.03.72800|Pearce~~r3dn~8349379|Phillip~~r3dn~2153335|Red Hill~~r3dp~9973374|Reid~~r3dp~8348371|Richardson~~r3dn~8349188|Rivett~~r39y~8349189|Scullin~~r39z~8349327|Spence~~r3dp~8349313|Stirling~~r39y~8349380~AU.08.57910,CA.01.4802009,GB.SCT.W6|Symonston~~r3dn~8349190|Theodore~~r3dn~8348420~CA.11.4709028|Torrens~~r3dn~8348973|Tuggeranong~~r3dn~2145936|Turner~~r3dp~8348040|Wanniassa~~r3dn~8349191|Waramanga~~r39y~8349192|Watson~~r3dp~8348373~CA.11.4710062|Weetangera~~r39z~2144224|Weston~~r39y~8349397|Wright~~r39z~9973427|Yarralumla~~r3dp~8348374",
@@ -149,7 +149,8 @@ var PLACE_TOWNS = {
149
149
  "USA-WY": "Afton~~9x95~5816861|Alpine~~9x9j~5817073~AU.07.20110|Antelope Valley-Crestview~~9xug~7260797|Arapahoe~~9xdu~5817340|Bar Nunn~~9xsk~5817809|Basin~~9xgh~5817923|Bear River~~9x35~5818158|Big Piney~~9x99~5818702|Buffalo~~9xuh~5819881|Byron~~9xfy~5820291~AU.02.11350|Casper~~9xs7~5820705|Cheyenne~~9xm6~5821086|Clearview Acres~~9x6k~5821415|Cody~~9xfm~5821593|Cokeville~~9x3p~5821618|Cowley~~9xfz~5822154~CA.01.4803016|Dayton~~9xgx~5822752|Diamondville~~9x3m~5823199|Douglas~~9xt5~5823516~AU.04.32810~3042237|Dubois~~9xdp~5823819|Ethete~~9xds~5824773|Evanston~~9x34~5824805|Evansville~~9xs7~5824810|Fort Washakie~~9xds~5825424|Fox Farm-College~~9xm3~7261302|Gillette~~9xug~5826027|Glenrock~~9xse~5826088|Green River~~9x6h~5826559|Greybull~~9xgj~5826603|Guernsey~~9xt8~5826723|Hanna~~9xkn~5826986~CA.01.4804011|Hartrandt~~9xs7~5827151|Hoback~~9x9n~5827703|Jackson~~9x9p~5828648|James Town~~9x6h~5828717|Kemmerer~~9x3m~5829425|La Barge~~9x98~5829816|Lander~~9xde~5830007|Laramie~~9xkg~5830062|Lovell~~9xfz~5831176|Lucerne~~9xg0~5831275|Lusk~~9xte~5831333|Lyman~~9x3e~5831346|Marbleton~~9x9d~5831530|Mills~~9xs7~5832481|Moorcroft~~9xv7~5832698|Moose Wilson Road~~9x9p~5832759|Mountain View~~9x3d~5832901|Newcastle~~9xvc~5833349~AU.02.15900|North Rock Springs~~9x6k~5833892|Pine Bluffs~~9xmf~5835069|Pine Haven~~9xvk~5835124|Pinedale~~9x9g~5835178|Powell~~9xfw~5835606|Purple Sage~~9x6k~5835760|Rafter J Ranch~~9x9p~5835865|Ranchester~~9xgz~5835955|Ranchettes~~9xm6~5835956|Rawlins~~9x7t~5836068|Reliance~~9x6m~5836399|Riverton~~9xdu~5836665|Rock Springs~~9x6k~5836898|Saratoga~~9xk5~5837593|Sheridan~~9xgy~5838198|Shoshoni~~9xej~5838312|Sleepy Hollow~~9xv5~5838617|South Greeley~~9xm3~5839233|South Park~~9x9p~5839264|Star Valley Ranch~~9x9h~8479282|Story~~9xgv~5840065|Sundance~~9xvu~5840284|Thermopolis~~9xg0~5840846|Torrington~~9xmz~5841207|Upton~~9xvd~5841818|Vista West~~9xs7~7176041|Washakie Ten~~9xg6~5842272|Wheatland~~9xmr~5842753|Wilson~~9x9p~5843239|Worland~~9xg4~5843495|Wright~~9xub~5843515"
150
150
  };
151
151
 
152
- var slug = (s) => s.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
152
+ var ASCII = /^[ -~]*$/;
153
+ var slug = (s) => (ASCII.test(s) ? s : s.normalize("NFD").replace(/\p{M}/gu, "")).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
153
154
  var towns;
154
155
  function geocodeTowns() {
155
156
  if (towns !== undefined)
@@ -182,6 +183,8 @@ function townNodes() {
182
183
  const ascii = new Map;
183
184
  for (const parent of Object.keys(PLACE_TOWNS))
184
185
  for (const row of PLACE_TOWNS[parent].split("|")) {
186
+ if (row[row.indexOf("~") + 1] === "~")
187
+ continue;
185
188
  const [, a, , id] = row.split("~");
186
189
  if (a !== "")
187
190
  ascii.set(id, a);
@@ -200,14 +203,19 @@ function townNodes() {
200
203
  }
201
204
  return out;
202
205
  }
206
+ var layerTree;
203
207
  var layer;
204
208
  var genericLayer;
209
+ function layerNodes() {
210
+ layerTree ??= [...PLACE_NODES, ...townNodes()];
211
+ return layerTree;
212
+ }
205
213
  function layerReader() {
206
- layer ??= createPlaceReader2({ tree: [...PLACE_NODES, ...townNodes()] });
214
+ layer ??= createPlaceReader2({ tree: layerNodes() });
207
215
  return layer;
208
216
  }
209
217
  function genericReader() {
210
- genericLayer ??= createPlaceReader2({ tree: [...PLACE_NODES, ...townNodes()], generic: true });
218
+ genericLayer ??= createPlaceReader2({ tree: layerNodes(), generic: true });
211
219
  return genericLayer;
212
220
  }
213
221
  function oneTown(t) {
package/dist/place.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  placesRelation2,
20
20
  probablySamePlace2,
21
21
  sameReading2
22
- } from "./chunks/place-k6y6fe1y.js";
22
+ } from "./chunks/place-5kmn6jgj.js";
23
23
  import"./chunks/place-tcgfvemw.js";
24
24
  export {
25
25
  DEFAULT_PLACE_CAPACITY2 as DEFAULT_PLACE_CAPACITY,
package/dist/school.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  areAllPlaceTokens2,
13
13
  placeRelation2,
14
14
  sameReading2
15
- } from "./chunks/place-k6y6fe1y.js";
15
+ } from "./chunks/place-5kmn6jgj.js";
16
16
  import {
17
17
  validity
18
18
  } from "./chunks/place-q9kwsmzd.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finbheara/domain",
3
- "version": "0.40.0",
3
+ "version": "0.42.0",
4
4
  "description": "Places, CLRG regions, school names, ages, dances, competition titles and schedules, and a person's print in its role, as they are printed: read, compared and told apart",
5
5
  "keywords": [
6
6
  "places",