@tricoteuses/tisseuse 0.13.2 → 0.13.3

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/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $t as e, A as t, En as n, Jn as r, Kn as i, L as a, Xn as o, Yn as s, a as c, an as l, c as u, dt as d, fn as f, ft as p, g as m, in as h, l as g, lt as _, nt as v, pt as y, qn as b, rt as x, st as ee, t as S, u as C, x as te } from "./textes-8dVwaLo9.js";
1
+ import { $t as e, A as t, Dn as n, Jn as r, L as i, Xn as a, Yn as o, Zn as s, a as c, an as l, c as u, dt as d, fn as f, ft as p, g as m, in as h, l as g, lt as _, nt as v, pt as y, qn as b, rt as x, st as ee, t as S, u as C, x as te } from "./textes-Enqe3lpa.js";
2
2
  import * as ne from "node:crypto";
3
3
  import w from "fs-extra";
4
4
  import T from "node:path";
@@ -19623,8 +19623,8 @@ async function* Ae({ context: e, date: t, flegiResolver: n, logIgnoredReferences
19623
19623
  function je(e) {
19624
19624
  return /^[a-z]$/i.test(e) ? 0 : 80;
19625
19625
  }
19626
- function k({ context: e, logPartialReferences: t, reference: n, state: r, text: a }) {
19627
- switch (a.nature) {
19626
+ function k({ context: e, logPartialReferences: t, reference: n, state: r, text: i }) {
19627
+ switch (i.nature) {
19628
19628
  case "ARRETE":
19629
19629
  case "CIRCULAIRE":
19630
19630
  case "CONVENTION":
@@ -19644,53 +19644,53 @@ function k({ context: e, logPartialReferences: t, reference: n, state: r, text:
19644
19644
  delete r.textId;
19645
19645
  break;
19646
19646
  case "CODE":
19647
- if (a.relative === 0 && r.codeId !== void 0) {
19647
+ if (i.relative === 0 && r.codeId !== void 0) {
19648
19648
  r.textId = r.codeId;
19649
19649
  break;
19650
19650
  }
19651
- if (a.cid === void 0) {
19652
- t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${a.nature} reference ${JSON.stringify(a, null, 2)}`), delete r.textId;
19651
+ if (i.cid === void 0) {
19652
+ t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${i.nature} reference ${JSON.stringify(i, null, 2)}`), delete r.textId;
19653
19653
  break;
19654
19654
  }
19655
- r.textId = r.codeId = a.cid;
19655
+ r.textId = r.codeId = i.cid;
19656
19656
  break;
19657
19657
  case "CONSTITUTION":
19658
- if (a.relative === 0 && r.constitutionId !== void 0) {
19658
+ if (i.relative === 0 && r.constitutionId !== void 0) {
19659
19659
  r.textId = r.constitutionId;
19660
19660
  break;
19661
19661
  }
19662
- if (a.cid === void 0) {
19663
- t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${a.nature} reference ${JSON.stringify(a, null, 2)}`), delete r.textId;
19662
+ if (i.cid === void 0) {
19663
+ t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${i.nature} reference ${JSON.stringify(i, null, 2)}`), delete r.textId;
19664
19664
  break;
19665
19665
  }
19666
- r.textId = r.constitutionId = a.cid;
19666
+ r.textId = r.constitutionId = i.cid;
19667
19667
  break;
19668
19668
  case "DECRET":
19669
- if (a.relative === 0 && r.decreeId !== void 0) {
19669
+ if (i.relative === 0 && r.decreeId !== void 0) {
19670
19670
  r.textId = r.decreeId;
19671
19671
  break;
19672
19672
  }
19673
- if (a.cid === void 0) {
19674
- t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${a.nature} reference ${JSON.stringify(a, null, 2)}`), delete r.textId;
19673
+ if (i.cid === void 0) {
19674
+ t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${i.nature} reference ${JSON.stringify(i, null, 2)}`), delete r.textId;
19675
19675
  break;
19676
19676
  }
19677
- r.textId = r.decreeId = a.cid;
19677
+ r.textId = r.decreeId = i.cid;
19678
19678
  break;
19679
19679
  case "LOI":
19680
19680
  case "LOI_CONSTIT":
19681
19681
  case "LOI_ORGANIQUE":
19682
19682
  case "ORDONNANCE":
19683
- if (a.relative === 0 && r.lawId !== void 0) {
19683
+ if (i.relative === 0 && r.lawId !== void 0) {
19684
19684
  r.textId = r.lawId;
19685
19685
  break;
19686
19686
  }
19687
- if (a.cid === void 0) {
19688
- t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${a.nature} reference ${JSON.stringify(a, null, 2)}`), delete r.textId;
19687
+ if (i.cid === void 0) {
19688
+ t && console.log(`In "${e.input.slice(n.position.start, n.position.stop)}": Missing CID of ${i.nature} reference ${JSON.stringify(i, null, 2)}`), delete r.textId;
19689
19689
  break;
19690
19690
  }
19691
- r.textId = r.lawId = a.cid;
19691
+ r.textId = r.lawId = i.cid;
19692
19692
  break;
19693
- default: a.nature === void 0 ? delete r.textId : i("nature", a.nature);
19693
+ default: i.nature === void 0 ? delete r.textId : b("nature", i.nature);
19694
19694
  }
19695
19695
  }
19696
19696
  function Me(e, t) {
@@ -19930,7 +19930,7 @@ function* P(e, t) {
19930
19930
  }
19931
19931
  break;
19932
19932
  }
19933
- default: i("iterDeepestDivisionsOrArticles reference.type", t);
19933
+ default: b("iterDeepestDivisionsOrArticles reference.type", t);
19934
19934
  }
19935
19935
  }
19936
19936
  function F(e) {
@@ -20051,11 +20051,11 @@ async function* I({ ancestors: t, flegiResolver: n, context: r, date: i, divisio
20051
20051
  function* Le(e, t) {
20052
20052
  let n = Math.floor(t), i = Math.floor((t - n) * 1e3);
20053
20053
  if (i === 0) {
20054
- for (let t of s(n)) yield `${t.toLowerCase()} ${e}`;
20055
- for (let t of b(n)) yield `${e} ${t.toLowerCase()}`;
20056
- } else for (let t of r(i)) {
20057
- for (let r of s(n)) yield `${r.toLowerCase()} ${t} ${e}`;
20058
- for (let r of b(n)) yield `${e} ${t} ${r.toLowerCase()}`;
20054
+ for (let t of a(n)) yield `${t.toLowerCase()} ${e}`;
20055
+ for (let t of r(n)) yield `${e} ${t.toLowerCase()}`;
20056
+ } else for (let t of o(i)) {
20057
+ for (let r of a(n)) yield `${r.toLowerCase()} ${t} ${e}`;
20058
+ for (let i of r(n)) yield `${e} ${t} ${i.toLowerCase()}`;
20059
20059
  }
20060
20060
  }
20061
20061
  async function* Re({ articleDefinitionByNumByTextId: e, flegiResolver: t, context: n, date: r, logIgnoredReferencesTypes: i, logPartialReferences: a, originalPositionsFromTransformedIterator: o, reference: s, state: c }) {
@@ -20204,34 +20204,34 @@ async function* Re({ articleDefinitionByNumByTextId: e, flegiResolver: t, contex
20204
20204
  }
20205
20205
  //#endregion
20206
20206
  //#region src/lib/f_legi/linkers/html.ts
20207
- async function ze({ legiResolver: e, date: t, html: r, linkBaseUrl: a, linkType: o, logIgnoredReferencesTypes: s, logPartialReferences: c, logReferences: l, onLink: d, previousContext: f, state: p }) {
20208
- let m = new O("f_legi.addLinksToHtml");
20209
- await m.time("preloadTextTitlesInfos", () => e.preloadTextTitlesInfos());
20210
- let h = m.timeSync("simplifyHtml", () => v({ removeAWithHref: !0 })(r), {
20207
+ async function ze({ legiResolver: e, date: t, html: r, linkBaseUrl: i, linkType: a, logIgnoredReferencesTypes: o, logPartialReferences: s, logReferences: c, onLink: l, previousContext: d, state: f }) {
20208
+ let p = new O("f_legi.addLinksToHtml");
20209
+ await p.time("preloadTextTitlesInfos", () => e.preloadTextTitlesInfos());
20210
+ let m = p.timeSync("simplifyHtml", () => v({ removeAWithHref: !0 })(r), {
20211
20211
  inputSize: r.length,
20212
20212
  outputSize: void 0
20213
- }), g = new n(h.output);
20214
- g.currentArticle = f?.currentArticle, g.currentText = f?.currentText;
20215
- let _ = [], y = { value: 0 }, b = -1;
20216
- await m.time("extractTextLinks", async () => {
20213
+ }), h = new n(m.output);
20214
+ h.currentArticle = d?.currentArticle, h.currentText = d?.currentText;
20215
+ let g = [], _ = { value: 0 }, y = -1;
20216
+ await p.time("extractTextLinks", async () => {
20217
20217
  for await (let n of Ae({
20218
20218
  flegiResolver: e,
20219
- context: g,
20219
+ context: h,
20220
20220
  date: t,
20221
- logIgnoredReferencesTypes: s,
20222
- logPartialReferences: c,
20223
- logReferences: l,
20224
- state: p,
20225
- transformation: h
20226
- })) if (b++, !(d !== void 0 && await d(n, b))) switch (n.type) {
20221
+ logIgnoredReferencesTypes: o,
20222
+ logPartialReferences: s,
20223
+ logReferences: c,
20224
+ state: f,
20225
+ transformation: m
20226
+ })) if (y++, !(l !== void 0 && await l(n, y))) switch (n.type) {
20227
20227
  case "article_definition": {
20228
20228
  let { article: e, originalTransformation: t, textId: i } = n;
20229
20229
  if (t === void 0) throw Error(`Missing originalTransformation attribute in article definition: ${JSON.stringify(n, null, 2)}`);
20230
20230
  L({
20231
20231
  inputHtml: r,
20232
20232
  originalTransformation: t,
20233
- output: { replacements: _ },
20234
- replacementCounter: y,
20233
+ output: { replacements: g },
20234
+ replacementCounter: _,
20235
20235
  tagHtmlFromOriginal: (t) => `<span class="definition_article" id="definition_article_${i}_${e.num.replaceAll(" ", "_")}">${t}</span>`
20236
20236
  });
20237
20237
  break;
@@ -20243,9 +20243,9 @@ async function ze({ legiResolver: e, date: t, html: r, linkBaseUrl: a, linkType:
20243
20243
  L({
20244
20244
  inputHtml: r,
20245
20245
  originalTransformation: t,
20246
- output: { replacements: _ },
20247
- replacementCounter: y,
20248
- tagHtmlFromOriginal: (t) => `<a class="lien_article_externe" href="${u(o, a, e)}">${t}</a>`
20246
+ output: { replacements: g },
20247
+ replacementCounter: _,
20248
+ tagHtmlFromOriginal: (t) => `<a class="lien_article_externe" href="${u(a, i, e)}">${t}</a>`
20249
20249
  });
20250
20250
  }
20251
20251
  break;
@@ -20257,9 +20257,9 @@ async function ze({ legiResolver: e, date: t, html: r, linkBaseUrl: a, linkType:
20257
20257
  L({
20258
20258
  inputHtml: r,
20259
20259
  originalTransformation: e,
20260
- output: { replacements: _ },
20261
- replacementCounter: y,
20262
- tagHtmlFromOriginal: (e) => `<a class="lien_division_externe" href="${u(o, a, t)}">${e}</a>`
20260
+ output: { replacements: g },
20261
+ replacementCounter: _,
20262
+ tagHtmlFromOriginal: (e) => `<a class="lien_division_externe" href="${u(a, i, t)}">${e}</a>`
20263
20263
  });
20264
20264
  }
20265
20265
  break;
@@ -20267,16 +20267,16 @@ async function ze({ legiResolver: e, date: t, html: r, linkBaseUrl: a, linkType:
20267
20267
  case "external_text": {
20268
20268
  let { originalTransformation: e, text: t } = n;
20269
20269
  if (t.cid === void 0) {
20270
- t.relative !== 0 && c && console.error(`Link to text "${g.text(t.position)}" without CID: ${JSON.stringify(t, null, 2)}`);
20270
+ t.relative !== 0 && s && console.error(`Link to text "${h.text(t.position)}" without CID: ${JSON.stringify(t, null, 2)}`);
20271
20271
  continue;
20272
20272
  }
20273
20273
  if (e === void 0) throw Error(`Missing originalTransformation attribute in external text link: ${JSON.stringify(n, null, 2)}`);
20274
20274
  L({
20275
20275
  inputHtml: r,
20276
20276
  originalTransformation: e,
20277
- output: { replacements: _ },
20278
- replacementCounter: y,
20279
- tagHtmlFromOriginal: (e) => `<a class="lien_texte_externe" href="${u(o, a, t.cid)}">${e}</a>`
20277
+ output: { replacements: g },
20278
+ replacementCounter: _,
20279
+ tagHtmlFromOriginal: (e) => `<a class="lien_texte_externe" href="${u(a, i, t.cid)}">${e}</a>`
20280
20280
  });
20281
20281
  break;
20282
20282
  }
@@ -20287,8 +20287,8 @@ async function ze({ legiResolver: e, date: t, html: r, linkBaseUrl: a, linkType:
20287
20287
  L({
20288
20288
  inputHtml: r,
20289
20289
  originalTransformation: t,
20290
- output: { replacements: _ },
20291
- replacementCounter: y,
20290
+ output: { replacements: g },
20291
+ replacementCounter: _,
20292
20292
  tagHtmlFromOriginal: (t) => `<a class="lien_texte_european" href="${e}" target="_blank">${t}</a>`
20293
20293
  });
20294
20294
  break;
@@ -20299,25 +20299,25 @@ async function ze({ legiResolver: e, date: t, html: r, linkBaseUrl: a, linkType:
20299
20299
  L({
20300
20300
  inputHtml: r,
20301
20301
  originalTransformation: t,
20302
- output: { replacements: _ },
20303
- replacementCounter: y,
20302
+ output: { replacements: g },
20303
+ replacementCounter: _,
20304
20304
  tagHtmlFromOriginal: (t) => `<a class="lien_article_interne" href="#definition_article_${e.textId}_${e.article.num.replaceAll(" ", "_")}" style="background-color: #eae462">${t}</a>`
20305
20305
  });
20306
20306
  break;
20307
20307
  }
20308
- default: i("Link", n);
20308
+ default: b("Link", n);
20309
20309
  }
20310
- }, { count: b + 1 });
20311
- let x = m.timeSync("applyHtmlReplacements", () => Be(r, _), {
20312
- count: _.length,
20310
+ }, { count: y + 1 });
20311
+ let x = p.timeSync("applyHtmlReplacements", () => Be(r, g), {
20312
+ count: g.length,
20313
20313
  inputSize: r.length
20314
20314
  });
20315
- return m.log({
20316
- linkCount: b + 1,
20317
- replacementCount: _.length
20315
+ return p.log({
20316
+ linkCount: y + 1,
20317
+ replacementCount: g.length
20318
20318
  }), {
20319
- context: g,
20320
- output: _.length === 0 ? null : x
20319
+ context: h,
20320
+ output: g.length === 0 ? null : x
20321
20321
  };
20322
20322
  }
20323
20323
  function Be(e, t) {
@@ -20460,11 +20460,11 @@ var Ke = class {
20460
20460
  t("resolveJsonPath:start");
20461
20461
  let n = await Ue(this.options.textTitlesInfosPath);
20462
20462
  t("resolveJsonPath:done", { detail: n }), t("readJson:start", { detail: n });
20463
- let r = await w.stat(n), i = await w.readJson(n);
20463
+ let r = await w.stat(n), a = await w.readJson(n);
20464
20464
  t("readJson:done", {
20465
20465
  count: r.size,
20466
20466
  detail: n
20467
- }), t("setTextTitlesInfos:start"), a(i), t("setTextTitlesInfos:done"), this.textTitlesInfosLoaded = !0;
20467
+ }), t("setTextTitlesInfos:start"), i(a), t("setTextTitlesInfos:done"), this.textTitlesInfosLoaded = !0;
20468
20468
  }
20469
20469
  async preloadUniqueActiveArticlesByNums({ date: e, nums: t }) {
20470
20470
  let n = [...new Set([...t].filter(Boolean))].filter((t) => !this.globalArticleRowsByNumAndDate.has(`${t}\0${e}`));
@@ -21548,7 +21548,7 @@ var $, Mn = class {
21548
21548
  throw $ = void 0, e;
21549
21549
  })) : t("waiting-for-shared-preload");
21550
21550
  let r = await $;
21551
- t("setTextTitlesInfos:start"), a(r), t("setTextTitlesInfos:done"), n.log(), this.textTitlesInfosLoaded = !0;
21551
+ t("setTextTitlesInfos:start"), i(r), t("setTextTitlesInfos:done"), n.log(), this.textTitlesInfosLoaded = !0;
21552
21552
  }
21553
21553
  async getUniqueActiveArticlesByNum({ date: e, num: t }) {
21554
21554
  if (t === void 0) return [];
@@ -21973,7 +21973,7 @@ function Nn(e, t, n, r) {
21973
21973
  n != null && ((e[t] ??= {})[n] ??= []).push(r);
21974
21974
  }
21975
21975
  function Pn(e, t, n) {
21976
- let r = Rn(S(t).replace(/[,()]/g, " ")).split(" ").map((e) => /^[IVX]+$/gi.test(e) ? o(e).toString() : e.toLowerCase().replace(/^no$/, "n°")), i = e;
21976
+ let r = Rn(S(t).replace(/[,()]/g, " ")).split(" ").map((e) => /^[IVX]+$/gi.test(e) ? s(e).toString() : e.toLowerCase().replace(/^no$/, "n°")), i = e;
21977
21977
  for (let e of r) i = i[e] ??= {};
21978
21978
  i.cid === void 0 ? i.cid = n : Array.isArray(i.cid) ? i.cid.push(n) : i.cid = [i.cid, n];
21979
21979
  }
@@ -29,7 +29,7 @@ export { date, duDate } from './text_parsers/dates.js';
29
29
  export { definitionDivision, designationDivision, division, divisions, natureDivisionSingulier, numeroDivision, } from './text_parsers/divisions.js';
30
30
  export type { FragmentPosition, FragmentReverseTransformation, } from './text_parsers/fragments.js';
31
31
  export { addChildLeftToLastChild, createEnumerationOrBoundedInterval, createParentChildTreeFromReferences, iterAtomicFirstParentReferences, iterAtomicReferences, iterIncludedReferences, } from './text_parsers/helpers.js';
32
- export { adjectifNumeralOrdinalCourt, adverbeMultiplicatifLatin, nombreAsTextAstNumber, nombreCardinal, nombreRomainCardinal, nombreRomainOrdinal, nombreRomainOu0iAsTextAstNumber, } from './text_parsers/numbers.js';
32
+ export { adjectifNumeralCardinal, adjectifNumeralOrdinalCourt, adverbeMultiplicatifLatin, nombreAsTextAstNumber, nombreCardinal, nombreRomainCardinal, nombreRomainOrdinal, nombreRomainOu0iAsTextAstNumber, } from './text_parsers/numbers.js';
33
33
  export { alternatives, chain, convert, optional, parseText, regExp, repeat, TextParserContext, variable, wordsTree, } from './text_parsers/parsers.js';
34
34
  export { auPortion, auxPortions, numeroPortion, portions, unePortion, } from './text_parsers/portions.js';
35
35
  export { adjectifTemporelSingulier, ditPluriel, ditSingulier, introPluriel, introSingulier, liaisonPluriel, liaisonSingulier, } from './text_parsers/prepositions.js';