@rr0/cms 0.1.14 → 0.1.16

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.
Files changed (223) hide show
  1. package/dist/BaseReplaceCommand.d.ts +2 -2
  2. package/dist/DefaultContentVisitor.d.ts +11 -11
  3. package/dist/DescriptionReplaceCommand.d.ts +3 -3
  4. package/dist/ImageCommand.d.ts +3 -3
  5. package/dist/MetaLinkReplaceCommand.d.ts +3 -3
  6. package/dist/OpenGraphCommand.d.ts +6 -6
  7. package/dist/OpenGraphCommand.js +1 -1
  8. package/dist/RR0ContentStep.d.ts +11 -11
  9. package/dist/RR0ContentStep.js +2 -2
  10. package/dist/{RR0SsgContext.d.ts → RR0Context.d.ts} +8 -8
  11. package/dist/{RR0SsgContext.js → RR0Context.js} +4 -4
  12. package/dist/anchor/AnchorHandler.d.ts +2 -2
  13. package/dist/anchor/AnchorReplaceCommand.d.ts +2 -2
  14. package/dist/anchor/AnchorReplacer.d.ts +3 -3
  15. package/dist/anchor/CaseAnchorHandler.d.ts +2 -2
  16. package/dist/anchor/CaseAnchorHandler.js +2 -2
  17. package/dist/anchor/DataAnchorHandler.d.ts +6 -6
  18. package/dist/book/BookContentVisitor.d.ts +2 -2
  19. package/dist/book/BookDirectoryStep.d.ts +5 -5
  20. package/dist/book/BookService.d.ts +3 -1
  21. package/dist/book/BookService.js +4 -4
  22. package/dist/book/Chapters.d.ts +3 -3
  23. package/dist/book/Chapters.js +2 -2
  24. package/dist/build.js +27 -8
  25. package/dist/data/AbstractDataFactory.d.ts +3 -2
  26. package/dist/data/AbstractDataFactory.js +1 -1
  27. package/dist/data/AbstractDataService.d.ts +2 -3
  28. package/dist/data/AbstractDataService.js +2 -8
  29. package/dist/data/RR0Data.d.ts +4 -3
  30. package/dist/data/TypedDataFactory.d.ts +3 -2
  31. package/dist/data/TypedDataFactory.js +4 -0
  32. package/dist/data/index.d.ts +1 -1
  33. package/dist/data/index.js +1 -1
  34. package/dist/index/IndexedReplacer.d.ts +4 -4
  35. package/dist/index/IndexedReplacerFactory.d.ts +2 -2
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.js +1 -1
  38. package/dist/lang/LanguageReplaceCommand.d.ts +3 -3
  39. package/dist/lang/RR0Messages.d.ts +1 -1
  40. package/dist/lang/RR0Messages_en.d.ts +1 -1
  41. package/dist/lang/RR0Messages_en.js +1 -1
  42. package/dist/lang/RR0Messages_fr.d.ts +1 -1
  43. package/dist/lang/RR0Messages_fr.js +1 -1
  44. package/dist/note/NoteFileCounter.d.ts +2 -2
  45. package/dist/note/NoteRenderer.d.ts +2 -2
  46. package/dist/note/NoteReplacer.d.ts +2 -2
  47. package/dist/note/NoteReplacerFactory.d.ts +2 -2
  48. package/dist/org/OrgMessages.d.ts +2 -2
  49. package/dist/org/Organization.d.ts +3 -3
  50. package/dist/org/Organization.js +3 -3
  51. package/dist/org/OrganizationMessages.d.ts +3 -3
  52. package/dist/org/OrganizationService.d.ts +4 -3
  53. package/dist/org/OrganizationService.js +10 -9
  54. package/dist/org/au/region/vic/index.d.ts +1 -1
  55. package/dist/org/au/region/vic/index.js +1 -1
  56. package/dist/org/br/region/cw/CentralWest.js +1 -1
  57. package/dist/org/br/region/se/SouthEast.js +1 -1
  58. package/dist/org/country/region/department/city/CityService.d.ts +2 -2
  59. package/dist/org/country/region/department/city/CityService.js +2 -1
  60. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseSummary.d.ts +1 -1
  61. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseSummaryRR0Mapper.d.ts +4 -4
  62. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseSummaryRR0Mapper.js +1 -1
  63. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseToSummaryMapper.d.ts +3 -3
  64. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseToSummaryMapper.js +1 -1
  65. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanDatasource.d.ts +3 -3
  66. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanFileDatasource.d.ts +3 -3
  67. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanHttpDatasource.d.ts +6 -5
  68. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanSummaryToCaseMapper.d.ts +3 -3
  69. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanTestCases.js +1 -1
  70. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanTestimonial.d.ts +1 -1
  71. package/dist/org/us/region/fl/Florida.js +1 -1
  72. package/dist/org/us/region/hi/Hawaii.js +1 -1
  73. package/dist/org/us/region/in/Indiana.js +1 -1
  74. package/dist/org/us/region/va/Virginia.js +1 -1
  75. package/dist/org/us/region/wa/Washington.js +1 -1
  76. package/dist/org/us/region/wv/WestVirginia.js +1 -1
  77. package/dist/people/PeopleDirectoryStep.d.ts +4 -4
  78. package/dist/people/PeopleReplacer.d.ts +3 -3
  79. package/dist/people/PeopleReplacerFactory.d.ts +2 -2
  80. package/dist/people/PeopleService.d.ts +3 -4
  81. package/dist/people/PeopleService.js +3 -14
  82. package/dist/people/author/AuthorReplaceCommand.d.ts +2 -2
  83. package/dist/people/witness/WitnessReplacer.d.ts +2 -2
  84. package/dist/people/witness/WitnessReplacerFactory.d.ts +2 -2
  85. package/dist/place/GooglePlaceService.d.ts +1 -1
  86. package/dist/place/GooglePlaceService.js +1 -1
  87. package/dist/place/Place.d.ts +1 -1
  88. package/dist/place/Place.js +1 -1
  89. package/dist/place/PlaceService.d.ts +1 -1
  90. package/dist/place/PlaceService.js +1 -1
  91. package/dist/place/index.d.ts +0 -4
  92. package/dist/place/index.js +0 -4
  93. package/dist/science/crypto/ufo/enquete/dossier/CaseDirectoryStep.d.ts +5 -5
  94. package/dist/science/crypto/ufo/enquete/dossier/CaseDirectoryStep.js +1 -1
  95. package/dist/science/crypto/ufo/enquete/dossier/CaseService.d.ts +3 -3
  96. package/dist/science/crypto/ufo/enquete/dossier/CaseService.js +2 -2
  97. package/dist/search/SearchVisitor.d.ts +5 -5
  98. package/dist/source/Source.d.ts +1 -1
  99. package/dist/source/SourceFactory.d.ts +4 -4
  100. package/dist/source/SourceFactory.js +3 -2
  101. package/dist/source/SourceFileCounter.d.ts +2 -2
  102. package/dist/source/SourceRegistry.d.ts +2 -2
  103. package/dist/source/SourceRenderer.d.ts +3 -3
  104. package/dist/source/SourceRenderer.js +2 -2
  105. package/dist/source/SourceReplacer.d.ts +3 -3
  106. package/dist/source/SourceReplacerFactory.d.ts +2 -2
  107. package/dist/tech/info/soft/proj/impl/lang/CodeReplacer.d.ts +3 -3
  108. package/dist/tech/info/soft/proj/impl/lang/CodeReplacerFactory.d.ts +2 -2
  109. package/dist/time/CaseSummaryRenderer.d.ts +1 -1
  110. package/dist/time/EventRenderer.d.ts +7 -7
  111. package/dist/time/EventReplacerFactory.d.ts +4 -4
  112. package/dist/time/SsiTitleReplaceCommand.d.ts +2 -2
  113. package/dist/time/Time.d.ts +5 -3
  114. package/dist/time/Time.js +31 -5
  115. package/dist/time/TimeLinkDefaultHandler.d.ts +10 -9
  116. package/dist/time/TimeLinkDefaultHandler.js +8 -12
  117. package/dist/time/TimeService.d.ts +16 -7
  118. package/dist/time/TimeService.js +16 -22
  119. package/dist/time/TimeTestUtil.d.ts +16 -0
  120. package/dist/time/TimeTestUtil.js +29 -0
  121. package/dist/time/TimeUrlBuilder.d.ts +7 -3
  122. package/dist/time/TimeUrlBuilder.js +7 -4
  123. package/dist/time/datasource/AbstractDatasource.d.ts +6 -6
  124. package/dist/time/datasource/ChronologyReplacer.d.ts +6 -6
  125. package/dist/time/datasource/ChronologyReplacerFactory.d.ts +2 -2
  126. package/dist/time/datasource/ChronologyReplacerFactory.js +1 -1
  127. package/dist/time/datasource/ContextFilter.d.ts +3 -3
  128. package/dist/time/datasource/CsvFileSource.d.ts +2 -2
  129. package/dist/time/datasource/CsvMapper.d.ts +5 -5
  130. package/dist/time/datasource/CsvMapper.js +1 -1
  131. package/dist/time/datasource/Datasource.d.ts +2 -2
  132. package/dist/time/datasource/DatasourceTestCase.d.ts +8 -8
  133. package/dist/time/datasource/DatasourceTestCase.js +18 -16
  134. package/dist/time/datasource/FileDatasource.d.ts +2 -2
  135. package/dist/time/datasource/JsonMapper.d.ts +4 -4
  136. package/dist/time/datasource/TimeContextFilter.d.ts +3 -3
  137. package/dist/time/datasource/acufo/AcufoCase.d.ts +1 -1
  138. package/dist/time/datasource/acufo/AcufoDatasource.d.ts +3 -3
  139. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummary.d.ts +1 -1
  140. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.d.ts +3 -3
  141. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.js +1 -1
  142. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.d.ts +3 -3
  143. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.js +1 -1
  144. package/dist/time/datasource/baseovnifrance/BaseOvniFranceDatasource.d.ts +2 -2
  145. package/dist/time/datasource/baseovnifrance/BaseOvniFranceHttpDatasource.d.ts +6 -6
  146. package/dist/time/datasource/baseovnifrance/BaseOvniFranceTestCases.js +1 -1
  147. package/dist/time/datasource/fufora/FuforaCaseSummary.d.ts +1 -1
  148. package/dist/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.d.ts +3 -3
  149. package/dist/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.js +1 -1
  150. package/dist/time/datasource/fufora/FuforaDatasource.d.ts +2 -2
  151. package/dist/time/datasource/fufora/FuforaHttpDatasource.d.ts +5 -5
  152. package/dist/time/datasource/fufora/FuforaTestCases.js +1 -1
  153. package/dist/time/datasource/nuforc/NuforcCaseSummary.d.ts +1 -1
  154. package/dist/time/datasource/nuforc/NuforcDatasource.d.ts +2 -2
  155. package/dist/time/datasource/nuforc/NuforcHttpDatasource.d.ts +6 -6
  156. package/dist/time/datasource/nuforc/NuforcRR0Mapper.d.ts +3 -3
  157. package/dist/time/datasource/nuforc/NuforcRR0Mapper.js +1 -1
  158. package/dist/time/datasource/nuforc/NuforcTestCases.js +1 -1
  159. package/dist/time/datasource/rr0/NamedPlace.d.ts +7 -0
  160. package/dist/time/datasource/rr0/RR0CaseMapping.d.ts +2 -2
  161. package/dist/time/datasource/rr0/RR0CaseSummary.d.ts +0 -7
  162. package/dist/time/datasource/rr0/RR0CaseSummaryMapper.d.ts +3 -3
  163. package/dist/time/datasource/rr0/RR0FileDatasource.d.ts +5 -5
  164. package/dist/time/datasource/rr0/RR0HttpDatasource.d.ts +10 -9
  165. package/dist/time/datasource/rr0/RR0HttpDatasource.js +3 -32
  166. package/dist/time/datasource/rr0/RR0TestCases.js +1 -1
  167. package/dist/time/datasource/rr0/index.d.ts +1 -0
  168. package/dist/time/datasource/rr0/index.js +1 -0
  169. package/dist/time/datasource/sceau/SceauCaseSummaryRR0Mapper.d.ts +3 -3
  170. package/dist/time/datasource/sceau/SceauCaseSummaryRR0Mapper.js +1 -1
  171. package/dist/time/datasource/sceau/SceauDatasource.d.ts +4 -4
  172. package/dist/time/datasource/sceau/SceauDatasource.js +1 -1
  173. package/dist/time/datasource/sceau/SceauHttpDatasource.d.ts +5 -5
  174. package/dist/time/datasource/ufo-search/UfoSearchCase.d.ts +1 -1
  175. package/dist/time/datasource/ufo-search/UfoSearchCaseRR0Mapper.d.ts +4 -4
  176. package/dist/time/datasource/ufo-search/UfoSearchCaseRR0Mapper.js +10 -10
  177. package/dist/time/datasource/ufo-search/UfoSearchDatasource.d.ts +2 -2
  178. package/dist/time/datasource/ufo-search/UfoSearchFileDatasource.d.ts +3 -3
  179. package/dist/time/datasource/ufo-search/UfoSearchFileDatasource.js +1 -1
  180. package/dist/time/datasource/ufo-search/UfoSearchHttpDatasource.d.ts +4 -4
  181. package/dist/time/datasource/ufo-search/UfoSearchTestCases.js +1 -1
  182. package/dist/time/datasource/urecat/UrecatCase.d.ts +1 -1
  183. package/dist/time/datasource/urecat/UrecatHttpDatasource.d.ts +5 -5
  184. package/dist/time/datasource/urecat/UrecatHttpDatasource.js +1 -1
  185. package/dist/time/datasource/urecat/UrecatRR0Mapper.d.ts +3 -3
  186. package/dist/time/datasource/urecat/UrecatRR0Mapper.js +1 -1
  187. package/dist/time/datasource/urecat/UrecatTestCases.js +1 -1
  188. package/dist/time/html/TimeElementFactory.d.ts +15 -0
  189. package/dist/time/{TimeElementFactory.js → html/TimeElementFactory.js} +16 -22
  190. package/dist/time/html/TimeRenderer.d.ts +18 -0
  191. package/dist/time/html/TimeRenderer.js +46 -0
  192. package/dist/time/html/TimeReplacer.d.ts +12 -0
  193. package/dist/time/{TimeReplacer.js → html/TimeReplacer.js} +0 -3
  194. package/dist/time/{TimeReplacerFactory.d.ts → html/TimeReplacerFactory.d.ts} +2 -2
  195. package/dist/time/{TimeReplacerFactory.js → html/TimeReplacerFactory.js} +1 -1
  196. package/dist/time/html/index.d.ts +4 -0
  197. package/dist/time/html/index.js +4 -0
  198. package/dist/time/index.d.ts +3 -8
  199. package/dist/time/index.js +3 -8
  200. package/dist/time/{RelativeTimeTextBuilder.d.ts → text/RelativeTimeTextBuilder.d.ts} +2 -2
  201. package/dist/time/text/RelativeTimeTextBuilder.js +165 -0
  202. package/dist/time/{TimeTextBuilder.d.ts → text/TimeTextBuilder.d.ts} +2 -2
  203. package/dist/time/{TimeTextBuilder.js → text/TimeTextBuilder.js} +1 -1
  204. package/dist/time/text/index.d.ts +2 -0
  205. package/dist/time/text/index.js +2 -0
  206. package/dist/value/UnitReplaceCommand.d.ts +2 -2
  207. package/package.json +12 -11
  208. package/tsconfig.json +2 -1
  209. package/dist/place/PlaceLocation.d.ts +0 -26
  210. package/dist/place/PlaceLocation.js +0 -48
  211. package/dist/place/PlaceMessages.d.ts +0 -5
  212. package/dist/place/PlaceMessages_en.d.ts +0 -2
  213. package/dist/place/PlaceMessages_en.js +0 -4
  214. package/dist/place/PlaceMessages_fr.d.ts +0 -2
  215. package/dist/place/PlaceMessages_fr.js +0 -4
  216. package/dist/time/RelativeTimeTextBuilder.js +0 -166
  217. package/dist/time/TimeContext.d.ts +0 -59
  218. package/dist/time/TimeContext.js +0 -267
  219. package/dist/time/TimeElementFactory.d.ts +0 -15
  220. package/dist/time/TimeRenderer.d.ts +0 -19
  221. package/dist/time/TimeRenderer.js +0 -63
  222. package/dist/time/TimeReplacer.d.ts +0 -24
  223. /package/dist/{place/PlaceMessages.js → time/datasource/rr0/NamedPlace.js} +0 -0
@@ -1,7 +1,7 @@
1
- import { RR0SsgContext } from "../../../RR0SsgContext.js";
1
+ import { RR0Context } from "../../../RR0Context.js";
2
2
  import { AbstractDatasource } from "../AbstractDatasource.js";
3
3
  import { UfoSearchCase } from "./UfoSearchCase.js";
4
4
  export declare abstract class UfoSearchDatasource extends AbstractDatasource<UfoSearchCase> {
5
5
  protected constructor();
6
- protected abstract readCases(context: RR0SsgContext): Promise<UfoSearchCase[]>;
6
+ protected abstract readCases(context: RR0Context): Promise<UfoSearchCase[]>;
7
7
  }
@@ -1,4 +1,4 @@
1
- import { RR0SsgContext } from "../../../RR0SsgContext.js";
1
+ import { HtmlRR0Context } from "../../../RR0Context.js";
2
2
  import { Datasource } from "../Datasource.js";
3
3
  import { UfoSearchDatasource } from "./UfoSearchDatasource.js";
4
4
  import { JsonMapper } from "../JsonMapper.js";
@@ -7,12 +7,12 @@ import { UfoSearchCaseRR0Mapper } from "./UfoSearchCaseRR0Mapper.js";
7
7
  declare class FileMapper extends JsonMapper<UfoSearchCase> {
8
8
  protected mapper: UfoSearchCaseRR0Mapper;
9
9
  constructor(mapper: UfoSearchCaseRR0Mapper);
10
- parse(context: RR0SsgContext, data: string): UfoSearchCase[];
10
+ parse(context: HtmlRR0Context, data: string): UfoSearchCase[];
11
11
  }
12
12
  export declare class UfoSearchFileDatasource extends UfoSearchDatasource implements Datasource<UfoSearchCase> {
13
13
  readonly fileName: string;
14
14
  readonly fileMapper: FileMapper;
15
15
  constructor(fileName: string, mapper: UfoSearchCaseRR0Mapper);
16
- protected readCases(context: RR0SsgContext): Promise<UfoSearchCase[]>;
16
+ protected readCases(context: HtmlRR0Context): Promise<UfoSearchCase[]>;
17
17
  }
18
18
  export {};
@@ -8,7 +8,7 @@ class FileMapper extends JsonMapper {
8
8
  }
9
9
  parse(context, data) {
10
10
  const allData = super.parse(context, data);
11
- return allData["Majestic Timeline"].map(this.mapper.map);
11
+ return allData["Majestic Timeline"].map(line => this.mapper.map(context, line, context.file.lastModified));
12
12
  }
13
13
  }
14
14
  export class UfoSearchFileDatasource extends UfoSearchDatasource {
@@ -1,6 +1,6 @@
1
- import { RR0SsgContext } from "../../../RR0SsgContext.js";
1
+ import { RR0Context } from "../../../RR0Context.js";
2
2
  import { UfoSearchDatasource } from "./UfoSearchDatasource.js";
3
- import { TimeContext } from "../../TimeContext.js";
3
+ import { TimeContext } from "@rr0/time";
4
4
  import { HttpSource } from "../HttpSource.js";
5
5
  import { UfoSearchCase } from "./UfoSearchCase.js";
6
6
  export declare class UfoSearchHttpDatasource extends UfoSearchDatasource {
@@ -9,8 +9,8 @@ export declare class UfoSearchHttpDatasource extends UfoSearchDatasource {
9
9
  protected readonly http: HttpSource;
10
10
  constructor(baseUrl: string, searchPath: string);
11
11
  queryUrl(year: number | undefined, month: number | undefined, day: number | undefined): string;
12
- protected readCases(context: RR0SsgContext): Promise<UfoSearchCase[]>;
12
+ protected readCases(context: RR0Context): Promise<UfoSearchCase[]>;
13
13
  protected setDate(time: TimeContext, dateStr: string): void;
14
- protected getFromRow(context: RR0SsgContext, row: Element): Promise<UfoSearchCase>;
14
+ protected getFromRow(context: RR0Context, row: Element): Promise<UfoSearchCase>;
15
15
  protected setTime(dateTime: TimeContext, timeLabel: HTMLElement): void;
16
16
  }
@@ -1,5 +1,5 @@
1
1
  import { UfoSearchCaseType } from "./UfoSearchCase.js";
2
- import { TimeContext } from "../../TimeContext.js";
2
+ import { TimeContext } from "@rr0/time";
3
3
  export const ufoSearchTestCases = [
4
4
  {
5
5
  id: "979AEFAA",
@@ -1,4 +1,4 @@
1
- import { TimeContext } from "../../TimeContext.js";
1
+ import { TimeContext } from "@rr0/time";
2
2
  export type UrecatCaseHistoryRedaction = {
3
3
  mainAuthor: string;
4
4
  contributors: string;
@@ -1,4 +1,4 @@
1
- import { HtmlRR0SsgContext, RR0SsgContext } from "../../../RR0SsgContext.js";
1
+ import { HtmlRR0Context, RR0Context } from "../../../RR0Context.js";
2
2
  import { HttpSource } from "../HttpSource.js";
3
3
  import { UrecatCase, UrecatWitness } from "./UrecatCase.js";
4
4
  import { UrecatDatasource } from "./UrecatDatasource.js";
@@ -12,15 +12,15 @@ export declare class UrecatHttpDatasource extends UrecatDatasource {
12
12
  protected readonly http: HttpSource;
13
13
  protected readonly intlOptions: Intl.DateTimeFormatOptions;
14
14
  constructor(baseUrl: URL, searchPath?: string);
15
- queryUrl(context: RR0SsgContext): URL;
15
+ queryUrl(context: RR0Context): URL;
16
16
  getWitnesses(witnessesStr: string): UrecatWitness[];
17
- protected readCases(context: HtmlRR0SsgContext): Promise<UrecatCase[]>;
17
+ protected readCases(context: HtmlRR0Context): Promise<UrecatCase[]>;
18
18
  protected getLocation(column: HTMLTableCellElement): {
19
19
  placeName: string;
20
20
  country: string;
21
21
  departmentOrState: string;
22
22
  };
23
- protected getDate(context: RR0SsgContext, caseLink: URL, row: Element): RR0SsgContext;
23
+ protected getDate(context: RR0Context, caseLink: URL, row: Element): RR0Context;
24
24
  protected getLink(linkCol: HTMLTableCellElement): URL;
25
- protected getFromRow(context: RR0SsgContext, row: Element): UrecatCase;
25
+ protected getFromRow(context: RR0Context, row: Element): UrecatCase;
26
26
  }
@@ -1,7 +1,7 @@
1
1
  import { JSDOM } from "jsdom";
2
2
  import { HttpSource } from "../HttpSource.js";
3
3
  import { ObjectUtil, UrlUtil } from "../../../util/index.js";
4
- import { TimeTextBuilder } from "../../TimeTextBuilder.js";
4
+ import { TimeTextBuilder } from "../../text/TimeTextBuilder.js";
5
5
  import { MessageUtils } from "../../../lang/index.js";
6
6
  import { UrecatDatasource } from "./UrecatDatasource.js";
7
7
  export class UrecatHttpDatasource extends UrecatDatasource {
@@ -1,10 +1,10 @@
1
1
  import { CaseMapper } from "../CaseMapper.js";
2
2
  import { UrecatCase } from "./UrecatCase.js";
3
- import { HtmlRR0SsgContext } from "../../../RR0SsgContext.js";
3
+ import { HtmlRR0Context } from "../../../RR0Context.js";
4
4
  import { RR0CaseSummary } from "../rr0/RR0CaseSummary.js";
5
5
  import { CityService } from "../../../org/country/index.js";
6
6
  import { CountryService } from "../../../org/country/CountryService.js";
7
- export declare class UrecatRR0Mapper implements CaseMapper<HtmlRR0SsgContext, UrecatCase, RR0CaseSummary> {
7
+ export declare class UrecatRR0Mapper implements CaseMapper<HtmlRR0Context, UrecatCase, RR0CaseSummary> {
8
8
  protected cityService: CityService;
9
9
  protected countryService: CountryService;
10
10
  readonly baseUrl: URL;
@@ -12,5 +12,5 @@ export declare class UrecatRR0Mapper implements CaseMapper<HtmlRR0SsgContext, Ur
12
12
  readonly authors: string[];
13
13
  constructor(cityService: CityService, countryService: CountryService, baseUrl: URL, copyright: string, authors: string[]);
14
14
  getDescription(c: UrecatCase): string;
15
- map(context: HtmlRR0SsgContext, sourceCase: UrecatCase, sourceTime: Date): RR0CaseSummary;
15
+ map(context: HtmlRR0Context, sourceCase: UrecatCase, sourceTime: Date): RR0CaseSummary;
16
16
  }
@@ -1,5 +1,5 @@
1
1
  import assert from "assert";
2
- import { TimeContext } from "../../TimeContext.js";
2
+ import { TimeContext } from "@rr0/time";
3
3
  export class UrecatRR0Mapper {
4
4
  constructor(cityService, countryService, baseUrl, copyright, authors) {
5
5
  this.cityService = cityService;
@@ -1,4 +1,4 @@
1
- import { TimeContext } from "../../TimeContext.js";
1
+ import { TimeContext } from "@rr0/time";
2
2
  import { rr0TestUtil } from "../../../test/index.js";
3
3
  const noWeekdayOptions = { ...rr0TestUtil.intlOptions };
4
4
  noWeekdayOptions.weekday = undefined;
@@ -0,0 +1,15 @@
1
+ import { HtmlRR0Context, RR0Context } from "../../RR0Context.js";
2
+ import { TimeRenderer, TimeRenderOptions } from "./TimeRenderer.js";
3
+ /**
4
+ * Creates <time> elements from time strings.
5
+ */
6
+ export declare class TimeElementFactory {
7
+ readonly renderer: TimeRenderer;
8
+ constructor(renderer: TimeRenderer);
9
+ create(context: HtmlRR0Context, previousContext: HtmlRR0Context | undefined, options?: TimeRenderOptions): HTMLElement | undefined;
10
+ protected createInterval(fromContext: HtmlRR0Context, toContext: HtmlRR0Context, previousContext: HtmlRR0Context, options: TimeRenderOptions): HTMLElement | undefined;
11
+ protected createStarting(fromContext: HtmlRR0Context, previousContext: HtmlRR0Context, options: TimeRenderOptions): HTMLElement | undefined;
12
+ protected valueReplacement(context: HtmlRR0Context, previousContext: RR0Context | undefined, options?: TimeRenderOptions): HTMLElement | undefined;
13
+ protected durationReplacement(context: HtmlRR0Context): HTMLTimeElement | undefined;
14
+ protected dateTimeReplacement(context: HtmlRR0Context, previousContext: RR0Context | null, options?: TimeRenderOptions): HTMLElement | undefined;
15
+ }
@@ -1,5 +1,4 @@
1
1
  import { TimeReplacer } from "./TimeReplacer.js";
2
- import { TimeContext } from "./TimeContext.js";
3
2
  /**
4
3
  * Creates <time> elements from time strings.
5
4
  */
@@ -10,7 +9,7 @@ export class TimeElementFactory {
10
9
  create(context, previousContext, options = { url: true }) {
11
10
  let replacement;
12
11
  const time = context.time;
13
- let interval = time.interval;
12
+ const interval = time.interval;
14
13
  if (interval) {
15
14
  const fromContext = context.clone();
16
15
  fromContext.time.date = interval.start;
@@ -64,31 +63,26 @@ export class TimeElementFactory {
64
63
  return replacement;
65
64
  }
66
65
  durationReplacement(context) {
66
+ const duration = context.time.duration;
67
67
  const items = [];
68
- let duration = context.time.duration;
69
68
  const messages = context.messages.context.time.duration;
70
- let datetime = "P";
71
- const days = Math.floor(duration / TimeContext.DAY);
72
- if (days > 0) {
73
- items.push(messages.days(days));
74
- datetime += days + "D";
69
+ const datetime = duration.toString();
70
+ const spec = duration.toSpec();
71
+ const days = spec.days;
72
+ if (days) {
73
+ items.push(messages.days(days.value));
75
74
  }
76
- duration %= TimeContext.DAY;
77
- const hours = Math.floor(duration / TimeContext.HOUR);
78
- if (hours > 0) {
79
- items.push(messages.hours(hours));
80
- datetime += hours + "H";
75
+ const hours = spec.hours;
76
+ if (hours) {
77
+ items.push(messages.hours(hours.value));
81
78
  }
82
- duration %= TimeContext.HOUR;
83
- const minutes = Math.floor(duration / TimeContext.MINUTE);
84
- if (minutes > 0) {
85
- items.push(messages.minutes(minutes));
86
- datetime += minutes + "M";
79
+ const minutes = spec.minutes;
80
+ if (minutes) {
81
+ items.push(messages.minutes(minutes.value));
87
82
  }
88
- duration %= TimeContext.MINUTE;
89
- if (duration > 0) {
90
- items.push(messages.seconds(duration));
91
- datetime += duration + "S";
83
+ const seconds = spec.seconds;
84
+ if (seconds) {
85
+ items.push(messages.seconds(seconds.value));
92
86
  }
93
87
  let replacement;
94
88
  if (items.length > 0) {
@@ -0,0 +1,18 @@
1
+ import { HtmlRR0Context, RR0Context } from "../../RR0Context.js";
2
+ import { TimeTextBuilder } from "../text/TimeTextBuilder.js";
3
+ import { RelativeTimeTextBuilder } from "../text/RelativeTimeTextBuilder.js";
4
+ import { TimeService } from "../TimeService";
5
+ export interface TimeRenderOptions {
6
+ url: boolean;
7
+ }
8
+ export declare class TimeRenderer {
9
+ readonly service: TimeService;
10
+ protected textBuilder: TimeTextBuilder;
11
+ protected readonly relativeTextBuilder: RelativeTimeTextBuilder;
12
+ constructor(service: TimeService, textBuilder: TimeTextBuilder);
13
+ render(context: HtmlRR0Context, previousContext?: RR0Context, options?: TimeRenderOptions): HTMLElement;
14
+ renderContent(context: HtmlRR0Context, previousContext: RR0Context, options: TimeRenderOptions, renderOptions?: Intl.DateTimeFormatOptions): {
15
+ result: HTMLElement;
16
+ replacement: HTMLElement;
17
+ };
18
+ }
@@ -0,0 +1,46 @@
1
+ import { RelativeTimeTextBuilder } from "../text/RelativeTimeTextBuilder.js";
2
+ import { UrlUtil } from "../../util/url/UrlUtil.js";
3
+ import { TimeReplacer } from "./TimeReplacer.js";
4
+ export class TimeRenderer {
5
+ constructor(service, textBuilder) {
6
+ this.service = service;
7
+ this.textBuilder = textBuilder;
8
+ this.relativeTextBuilder = new RelativeTimeTextBuilder(textBuilder);
9
+ }
10
+ render(context, previousContext, options = { url: true }) {
11
+ const { result, replacement } = this.renderContent(context, previousContext, options);
12
+ const timeMessages = context.messages.context.time;
13
+ const time = context.time;
14
+ const message = time.getDayOfMonth() ? timeMessages.on : timeMessages.in;
15
+ result.append(message(time.approximate), replacement);
16
+ return result;
17
+ }
18
+ renderContent(context, previousContext, options, renderOptions = this.textBuilder.options) {
19
+ const time = context.time;
20
+ const absoluteTimeUrl = this.service.urlBuilder.fromContext(time);
21
+ const title = this.textBuilder.build(context, true, renderOptions);
22
+ const text = (previousContext ? this.relativeTextBuilder.build(previousContext, context) : undefined) || title;
23
+ const file = context.file;
24
+ const currentFileName = file.name;
25
+ const doc = file.document;
26
+ let replacement;
27
+ const timeEl = TimeReplacer.resolvedTime(context, time.toString());
28
+ if (title !== text) {
29
+ timeEl.title = title;
30
+ }
31
+ timeEl.textContent = text;
32
+ const dirName = currentFileName.substring(0, currentFileName.indexOf("/index"));
33
+ const existingUrl = options.url && this.service.matchExistingTimeFile(absoluteTimeUrl);
34
+ if (existingUrl && existingUrl !== dirName) {
35
+ const a = replacement = doc.createElement("a");
36
+ a.href = UrlUtil.absolute(existingUrl);
37
+ a.append(timeEl);
38
+ }
39
+ else {
40
+ replacement = timeEl;
41
+ }
42
+ const result = file.document.createElement("span");
43
+ result.className = "time-resolved";
44
+ return { result, replacement };
45
+ }
46
+ }
@@ -0,0 +1,12 @@
1
+ import { HtmlRR0Context } from "../../RR0Context.js";
2
+ import { DomReplacement } from "../DomReplacement.js";
3
+ import { TimeElementFactory } from "./TimeElementFactory.js";
4
+ /**
5
+ * Replaces a <time> tag.
6
+ */
7
+ export declare class TimeReplacer implements DomReplacement<HtmlRR0Context, HTMLTimeElement> {
8
+ readonly factory: TimeElementFactory;
9
+ constructor(factory: TimeElementFactory);
10
+ static resolvedTime(context: HtmlRR0Context, dateTime: string): HTMLTimeElement;
11
+ replacement(context: HtmlRR0Context, origEl: HTMLTimeElement): Promise<HTMLElement>;
12
+ }
@@ -3,9 +3,6 @@ import { ObjectUtils } from "@rr0/common";
3
3
  * Replaces a <time> tag.
4
4
  */
5
5
  export class TimeReplacer {
6
- /**
7
- * @param factory
8
- */
9
6
  constructor(factory) {
10
7
  this.factory = factory;
11
8
  }
@@ -1,5 +1,5 @@
1
1
  import { TimeReplacer } from "./TimeReplacer.js";
2
- import { HtmlRR0SsgContext } from "../RR0SsgContext.js";
2
+ import { HtmlRR0Context } from "../../RR0Context.js";
3
3
  import { DomReplacer, ReplacerFactory } from "ssg-api";
4
4
  export declare class TimeReplacerFactory implements ReplacerFactory<DomReplacer> {
5
5
  protected readonly replacer: TimeReplacer;
@@ -9,5 +9,5 @@ export declare class TimeReplacerFactory implements ReplacerFactory<DomReplacer>
9
9
  *
10
10
  * @param context
11
11
  */
12
- create(context: HtmlRR0SsgContext): Promise<DomReplacer>;
12
+ create(context: HtmlRR0Context): Promise<DomReplacer>;
13
13
  }
@@ -10,7 +10,7 @@ export class TimeReplacerFactory {
10
10
  async create(context) {
11
11
  return {
12
12
  replace: (original) => {
13
- return this.replacer.replacement(this.replacer.factory.renderer.timeFiles.includes(context.file.name) ? context.clone() : context, original);
13
+ return this.replacer.replacement(this.replacer.factory.renderer.service.isTimeFile(context.file.name) ? context.clone() : context, original);
14
14
  }
15
15
  };
16
16
  }
@@ -0,0 +1,4 @@
1
+ export * from "./TimeRenderer.js";
2
+ export * from "./TimeElementFactory.js";
3
+ export * from "./TimeReplacer.js";
4
+ export * from "./TimeReplacerFactory.js";
@@ -0,0 +1,4 @@
1
+ export * from "./TimeRenderer.js";
2
+ export * from "./TimeElementFactory.js";
3
+ export * from "./TimeReplacer.js";
4
+ export * from "./TimeReplacerFactory.js";
@@ -1,17 +1,12 @@
1
- export * from "./datasource";
1
+ export * from "./text/index.js";
2
+ export * from "./html/index.js";
2
3
  export * from "./CaseSummaryRenderer.js";
3
4
  export * from "./DomReplacement.js";
4
5
  export * from "./EventRenderer.js";
5
6
  export * from "./EventReplacerFactory.js";
6
- export * from "./RelativeTimeTextBuilder.js";
7
7
  export * from "./SsiTitleReplaceCommand.js";
8
8
  export * from "./Time.js";
9
- export * from "./TimeContext.js";
10
- export * from "./TimeElementFactory.js";
11
9
  export * from "./TimeLinkDefaultHandler.js";
12
- export * from "./TimeRenderer.js";
13
- export * from "./TimeReplacer.js";
14
- export * from "./TimeReplacerFactory.js";
15
10
  export * from "./TimeService.js";
16
- export * from "./TimeTextBuilder.js";
17
11
  export * from "./TimeUrlBuilder.js";
12
+ export * from "./datasource/index.js";
@@ -1,17 +1,12 @@
1
- export * from "./datasource";
1
+ export * from "./text/index.js";
2
+ export * from "./html/index.js";
2
3
  export * from "./CaseSummaryRenderer.js";
3
4
  export * from "./DomReplacement.js";
4
5
  export * from "./EventRenderer.js";
5
6
  export * from "./EventReplacerFactory.js";
6
- export * from "./RelativeTimeTextBuilder.js";
7
7
  export * from "./SsiTitleReplaceCommand.js";
8
8
  export * from "./Time.js";
9
- export * from "./TimeContext.js";
10
- export * from "./TimeElementFactory.js";
11
9
  export * from "./TimeLinkDefaultHandler.js";
12
- export * from "./TimeRenderer.js";
13
- export * from "./TimeReplacer.js";
14
- export * from "./TimeReplacerFactory.js";
15
10
  export * from "./TimeService.js";
16
- export * from "./TimeTextBuilder.js";
17
11
  export * from "./TimeUrlBuilder.js";
12
+ export * from "./datasource/index.js";
@@ -1,7 +1,7 @@
1
1
  import { TimeTextBuilder } from "./TimeTextBuilder.js";
2
- import { RR0SsgContext } from "../RR0SsgContext.js";
2
+ import { RR0Context } from "../../RR0Context.js";
3
3
  export declare class RelativeTimeTextBuilder {
4
4
  protected timeTextBuilder: TimeTextBuilder;
5
5
  constructor(timeTextBuilder: TimeTextBuilder);
6
- build(oldContext: RR0SsgContext, newContext: RR0SsgContext): string;
6
+ build(oldContext: RR0Context, newContext: RR0Context): string;
7
7
  }
@@ -0,0 +1,165 @@
1
+ export class RelativeTimeTextBuilder {
2
+ constructor(timeTextBuilder) {
3
+ this.timeTextBuilder = timeTextBuilder;
4
+ }
5
+ build(oldContext, newContext) {
6
+ let text;
7
+ let print = true;
8
+ const previousTime = oldContext === null || oldContext === void 0 ? void 0 : oldContext.time;
9
+ if (previousTime === null || previousTime === void 0 ? void 0 : previousTime.isDefined()) {
10
+ const deltaContext = oldContext.clone();
11
+ const deltaTime = deltaContext.time;
12
+ let dayOfMonthDelta;
13
+ let yearDelta;
14
+ let monthDelta;
15
+ let hourDelta;
16
+ let minutesDelta;
17
+ function shouldSetDay() {
18
+ return !previousTime.getMonth() || monthDelta === 0;
19
+ }
20
+ function shouldSetHour() {
21
+ return !previousTime.getDayOfMonth() || dayOfMonthDelta === 0;
22
+ }
23
+ function shouldSetMinutes() {
24
+ return !previousTime.getMinutes() || hourDelta === 0;
25
+ }
26
+ function setYear(year) {
27
+ const previousYear = previousTime.getYear();
28
+ if (previousYear) {
29
+ yearDelta = year - previousYear;
30
+ if (yearDelta != 0) {
31
+ deltaTime.setYear(year);
32
+ }
33
+ }
34
+ }
35
+ function setMonth(month) {
36
+ const previousMonth = previousTime.getMonth();
37
+ if (yearDelta === 0) {
38
+ monthDelta = month - (previousMonth || 0);
39
+ if (monthDelta != 0) {
40
+ deltaTime.setMonth(month);
41
+ }
42
+ }
43
+ else if (yearDelta != 0) {
44
+ deltaTime.setMonth(month);
45
+ }
46
+ }
47
+ function setDayOfMonth(dayOfMonth) {
48
+ const sameMonth = yearDelta === 0 && shouldSetDay();
49
+ if (sameMonth) {
50
+ dayOfMonthDelta = dayOfMonth - (previousTime.getDayOfMonth() || 0);
51
+ if (dayOfMonthDelta != 0) {
52
+ deltaTime.setDayOfMonth(dayOfMonth);
53
+ }
54
+ }
55
+ else if (monthDelta != 0) {
56
+ deltaTime.setDayOfMonth(dayOfMonth);
57
+ }
58
+ }
59
+ function setHour(hour) {
60
+ const sameDay = yearDelta === 0 && shouldSetDay() && shouldSetHour();
61
+ if (sameDay) {
62
+ hourDelta = hour - (previousTime.getHour() || 0);
63
+ if (hourDelta != 0) {
64
+ deltaTime.setHour(hour);
65
+ }
66
+ }
67
+ else if (dayOfMonthDelta != 0) {
68
+ deltaTime.setHour(hour);
69
+ }
70
+ }
71
+ function setMinutes(minutes) {
72
+ const sameHour = yearDelta === 0 && shouldSetDay() && shouldSetHour() && shouldSetMinutes();
73
+ if (sameHour) {
74
+ minutesDelta = minutes - (previousTime.getMinutes() || 0);
75
+ if (minutesDelta != 0) {
76
+ deltaTime.setMinutes(minutes);
77
+ }
78
+ }
79
+ deltaTime.setMinutes(minutes);
80
+ }
81
+ const time = newContext.time;
82
+ const year = time.getYear();
83
+ if (year) {
84
+ setYear(year);
85
+ }
86
+ const month = time.getMonth();
87
+ if (month) {
88
+ setMonth(month);
89
+ }
90
+ const dayOfMonth = time.getDayOfMonth();
91
+ if (dayOfMonth) {
92
+ setDayOfMonth(dayOfMonth);
93
+ }
94
+ const hour = time.getHour();
95
+ if (hour) {
96
+ setHour(hour);
97
+ }
98
+ const minutes = time.getMinutes();
99
+ if (minutes) {
100
+ setMinutes(minutes);
101
+ }
102
+ let messages = newContext.messages.context.time.relative;
103
+ if (dayOfMonthDelta) {
104
+ switch (dayOfMonthDelta) {
105
+ case -1:
106
+ text = messages.day.before;
107
+ break;
108
+ case +1:
109
+ text = messages.day.after;
110
+ break;
111
+ }
112
+ }
113
+ else {
114
+ if (!dayOfMonth) {
115
+ switch (monthDelta) {
116
+ case -1:
117
+ text = messages.month.before;
118
+ break;
119
+ case +1:
120
+ text = messages.month.after;
121
+ break;
122
+ }
123
+ }
124
+ if (!month) {
125
+ switch (yearDelta) {
126
+ case -1:
127
+ text = messages.year.before;
128
+ break;
129
+ case +1:
130
+ text = messages.year.after;
131
+ break;
132
+ }
133
+ }
134
+ if (!minutes) {
135
+ switch (hourDelta) {
136
+ case -1:
137
+ text = messages.hour.before;
138
+ break;
139
+ case +1:
140
+ text = messages.hour.after;
141
+ break;
142
+ }
143
+ }
144
+ }
145
+ if (!text) {
146
+ let defaultContext;
147
+ if (deltaContext.time.isDefined()) {
148
+ defaultContext = deltaContext;
149
+ const dayOfMonth = defaultContext.time.getDayOfMonth();
150
+ if (dayOfMonth && shouldSetDay()) {
151
+ defaultContext.time.setMonth(newContext.time.getMonth() || previousTime.getMonth(), false); // give month
152
+ defaultContext.time.setYear(newContext.time.getYear() || previousTime.getYear(), false); // give year
153
+ // context for the day but won't
154
+ print = false;
155
+ }
156
+ newContext = defaultContext;
157
+ }
158
+ }
159
+ }
160
+ if (!text) {
161
+ text = this.timeTextBuilder.build(newContext, print);
162
+ }
163
+ return text;
164
+ }
165
+ }
@@ -1,4 +1,4 @@
1
- import { RR0SsgContext } from "../RR0SsgContext.js";
1
+ import { RR0Context } from "../../RR0Context.js";
2
2
  export declare class TimeTextBuilder {
3
3
  readonly options: Intl.DateTimeFormatOptions;
4
4
  constructor(options: Intl.DateTimeFormatOptions);
@@ -9,5 +9,5 @@ export declare class TimeTextBuilder {
9
9
  * @param print
10
10
  * @param options
11
11
  */
12
- build(context: RR0SsgContext, print?: boolean, options?: Intl.DateTimeFormatOptions): string;
12
+ build(context: RR0Context, print: boolean, options?: Intl.DateTimeFormatOptions): string;
13
13
  }
@@ -9,7 +9,7 @@ export class TimeTextBuilder {
9
9
  * @param print
10
10
  * @param options
11
11
  */
12
- build(context, print = true, options = this.options) {
12
+ build(context, print, options = this.options) {
13
13
  const time = context.time;
14
14
  const printOptions = {};
15
15
  const date = new Date(undefined, undefined, undefined);
@@ -0,0 +1,2 @@
1
+ export * from "./TimeTextBuilder.js";
2
+ export * from "./RelativeTimeTextBuilder.js";
@@ -0,0 +1,2 @@
1
+ export * from "./TimeTextBuilder.js";
2
+ export * from "./RelativeTimeTextBuilder.js";
@@ -1,9 +1,9 @@
1
1
  import { DomReplaceCommand, DomReplacer } from "ssg-api";
2
- import { HtmlRR0SsgContext } from "../RR0SsgContext.js";
2
+ import { HtmlRR0Context } from "../RR0Context.js";
3
3
  /**
4
4
  * Register images (`<img>` tags) required in an HTML file.
5
5
  */
6
6
  export declare class UnitReplaceCommand extends DomReplaceCommand {
7
7
  constructor();
8
- protected createReplacer(context: HtmlRR0SsgContext): Promise<DomReplacer>;
8
+ protected createReplacer(context: HtmlRR0Context): Promise<DomReplacer>;
9
9
  }