@rr0/cms 0.1.13 → 0.1.15

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 (244) hide show
  1. package/README.md +2 -0
  2. package/dist/BaseReplaceCommand.d.ts +2 -2
  3. package/dist/DefaultContentVisitor.d.ts +11 -11
  4. package/dist/DescriptionReplaceCommand.d.ts +3 -3
  5. package/dist/ImageCommand.d.ts +3 -3
  6. package/dist/MetaLinkReplaceCommand.d.ts +3 -3
  7. package/dist/OpenGraphCommand.d.ts +6 -6
  8. package/dist/OpenGraphCommand.js +1 -1
  9. package/dist/RR0ContentStep.d.ts +11 -11
  10. package/dist/RR0ContentStep.js +2 -2
  11. package/dist/{RR0SsgContext.d.ts → RR0Context.d.ts} +8 -8
  12. package/dist/{RR0SsgContext.js → RR0Context.js} +4 -4
  13. package/dist/anchor/AnchorHandler.d.ts +2 -2
  14. package/dist/anchor/AnchorReplaceCommand.d.ts +2 -2
  15. package/dist/anchor/AnchorReplacer.d.ts +3 -3
  16. package/dist/anchor/CaseAnchorHandler.d.ts +2 -2
  17. package/dist/anchor/CaseAnchorHandler.js +2 -2
  18. package/dist/anchor/DataAnchorHandler.d.ts +6 -6
  19. package/dist/book/BookContentVisitor.d.ts +2 -2
  20. package/dist/book/BookDirectoryStep.d.ts +5 -5
  21. package/dist/book/BookService.d.ts +3 -1
  22. package/dist/book/BookService.js +4 -4
  23. package/dist/book/Chapters.d.ts +3 -3
  24. package/dist/book/Chapters.js +2 -2
  25. package/dist/build.js +27 -8
  26. package/dist/data/AbstractDataFactory.d.ts +3 -2
  27. package/dist/data/AbstractDataFactory.js +1 -1
  28. package/dist/data/AbstractDataService.d.ts +2 -3
  29. package/dist/data/AbstractDataService.js +2 -8
  30. package/dist/data/RR0Data.d.ts +4 -3
  31. package/dist/data/TypedDataFactory.d.ts +3 -2
  32. package/dist/data/TypedDataFactory.js +4 -0
  33. package/dist/data/index.d.ts +1 -1
  34. package/dist/data/index.js +1 -1
  35. package/dist/index/IndexedReplacer.d.ts +4 -4
  36. package/dist/index/IndexedReplacerFactory.d.ts +2 -2
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/lang/LanguageReplaceCommand.d.ts +3 -3
  40. package/dist/lang/RR0Messages.d.ts +1 -1
  41. package/dist/lang/RR0Messages_en.d.ts +1 -1
  42. package/dist/lang/RR0Messages_en.js +1 -1
  43. package/dist/lang/RR0Messages_fr.d.ts +1 -1
  44. package/dist/lang/RR0Messages_fr.js +1 -1
  45. package/dist/lang/form.js +1 -1
  46. package/dist/note/NoteFileCounter.d.ts +2 -2
  47. package/dist/note/NoteRenderer.d.ts +2 -2
  48. package/dist/note/NoteReplacer.d.ts +2 -2
  49. package/dist/note/NoteReplacerFactory.d.ts +2 -2
  50. package/dist/org/OrgMessages.d.ts +2 -2
  51. package/dist/org/Organization.d.ts +3 -3
  52. package/dist/org/Organization.js +3 -3
  53. package/dist/org/OrganizationMessages.d.ts +3 -3
  54. package/dist/org/OrganizationService.d.ts +4 -3
  55. package/dist/org/OrganizationService.js +10 -9
  56. package/dist/org/au/Australia_en.d.ts +1 -1
  57. package/dist/org/au/Australia_fr.d.ts +1 -1
  58. package/dist/org/au/region/index.d.ts +4 -4
  59. package/dist/org/au/region/index.js +4 -4
  60. package/dist/org/au/region/nsw/NewSouthWalesMessages_en.d.ts +2 -2
  61. package/dist/org/au/region/nsw/NewSouthWalesMessages_en.js +2 -2
  62. package/dist/org/au/region/nsw/NewSouthWalesMessages_fr.d.ts +2 -2
  63. package/dist/org/au/region/nsw/NewSouthWalesMessages_fr.js +2 -2
  64. package/dist/org/au/region/nsw/index.d.ts +1 -1
  65. package/dist/org/au/region/nsw/index.js +1 -1
  66. package/dist/org/au/region/vic/index.d.ts +1 -1
  67. package/dist/org/au/region/vic/index.js +1 -1
  68. package/dist/org/br/region/cw/CentralWest.js +1 -1
  69. package/dist/org/br/region/se/SouthEast.js +1 -1
  70. package/dist/org/country/region/department/city/CityService.d.ts +2 -2
  71. package/dist/org/country/region/department/city/CityService.js +2 -1
  72. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseSummary.d.ts +1 -1
  73. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseSummaryRR0Mapper.d.ts +4 -4
  74. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseSummaryRR0Mapper.js +1 -1
  75. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseToSummaryMapper.d.ts +3 -3
  76. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseToSummaryMapper.js +1 -1
  77. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanDatasource.d.ts +3 -3
  78. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanFileDatasource.d.ts +3 -3
  79. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanHttpDatasource.d.ts +6 -5
  80. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanSummaryToCaseMapper.d.ts +3 -3
  81. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanTestCases.js +1 -1
  82. package/dist/org/eu/fr/cnes/geipan/geipan/GeipanTestimonial.d.ts +1 -1
  83. package/dist/org/eu/fr/region/idf/77/SeineEtMarneCities.js +1 -1
  84. package/dist/org/eu/fr/region/idf/77/SeineEtMarneMessages.js +1 -1
  85. package/dist/org/eu/fr/region/idf/77/SivryCourtry/index.d.ts +2 -0
  86. package/dist/org/eu/fr/region/idf/77/SivryCourtry/index.js +2 -0
  87. package/dist/org/eu/fr/region/idf/77/index.d.ts +5 -0
  88. package/dist/org/eu/fr/region/idf/77/index.js +5 -0
  89. package/dist/org/us/region/fl/Florida.js +1 -1
  90. package/dist/org/us/region/hi/Hawaii.js +1 -1
  91. package/dist/org/us/region/in/Indiana.js +1 -1
  92. package/dist/org/us/region/va/Virginia.js +1 -1
  93. package/dist/org/us/region/wa/Washington.js +1 -1
  94. package/dist/org/us/region/wv/WestVirginia.js +1 -1
  95. package/dist/people/PeopleDirectoryStep.d.ts +4 -4
  96. package/dist/people/PeopleReplacer.d.ts +3 -3
  97. package/dist/people/PeopleReplacerFactory.d.ts +2 -2
  98. package/dist/people/PeopleService.d.ts +3 -4
  99. package/dist/people/PeopleService.js +3 -14
  100. package/dist/people/author/AuthorReplaceCommand.d.ts +2 -2
  101. package/dist/people/witness/WitnessReplacer.d.ts +2 -2
  102. package/dist/people/witness/WitnessReplacerFactory.d.ts +2 -2
  103. package/dist/place/GooglePlaceService.d.ts +1 -1
  104. package/dist/place/GooglePlaceService.js +1 -1
  105. package/dist/place/Place.d.ts +1 -1
  106. package/dist/place/Place.js +1 -1
  107. package/dist/place/PlaceService.d.ts +1 -1
  108. package/dist/place/PlaceService.js +1 -1
  109. package/dist/place/index.d.ts +0 -4
  110. package/dist/place/index.js +0 -4
  111. package/dist/science/crypto/ufo/enquete/dossier/CaseDirectoryStep.d.ts +5 -5
  112. package/dist/science/crypto/ufo/enquete/dossier/CaseDirectoryStep.js +1 -1
  113. package/dist/science/crypto/ufo/enquete/dossier/CaseService.d.ts +3 -3
  114. package/dist/science/crypto/ufo/enquete/dossier/CaseService.js +2 -2
  115. package/dist/search/SearchVisitor.d.ts +5 -5
  116. package/dist/source/Source.d.ts +1 -1
  117. package/dist/source/SourceFactory.d.ts +4 -4
  118. package/dist/source/SourceFactory.js +3 -2
  119. package/dist/source/SourceFileCounter.d.ts +2 -2
  120. package/dist/source/SourceRegistry.d.ts +2 -2
  121. package/dist/source/SourceRenderer.d.ts +3 -3
  122. package/dist/source/SourceRenderer.js +2 -2
  123. package/dist/source/SourceReplacer.d.ts +3 -3
  124. package/dist/source/SourceReplacerFactory.d.ts +2 -2
  125. package/dist/tech/info/soft/proj/impl/lang/CodeReplacer.d.ts +3 -3
  126. package/dist/tech/info/soft/proj/impl/lang/CodeReplacerFactory.d.ts +2 -2
  127. package/dist/time/CaseSummaryRenderer.d.ts +1 -1
  128. package/dist/time/EventRenderer.d.ts +7 -7
  129. package/dist/time/EventReplacerFactory.d.ts +4 -4
  130. package/dist/time/SsiTitleReplaceCommand.d.ts +2 -2
  131. package/dist/time/Time.d.ts +5 -3
  132. package/dist/time/Time.js +31 -5
  133. package/dist/time/TimeLinkDefaultHandler.d.ts +10 -9
  134. package/dist/time/TimeLinkDefaultHandler.js +8 -12
  135. package/dist/time/TimeService.d.ts +16 -7
  136. package/dist/time/TimeService.js +16 -22
  137. package/dist/time/TimeTestUtil.d.ts +16 -0
  138. package/dist/time/TimeTestUtil.js +29 -0
  139. package/dist/time/TimeUrlBuilder.d.ts +7 -3
  140. package/dist/time/TimeUrlBuilder.js +7 -4
  141. package/dist/time/datasource/AbstractDatasource.d.ts +6 -6
  142. package/dist/time/datasource/ChronologyReplacer.d.ts +6 -6
  143. package/dist/time/datasource/ChronologyReplacerFactory.d.ts +2 -2
  144. package/dist/time/datasource/ChronologyReplacerFactory.js +1 -1
  145. package/dist/time/datasource/ContextFilter.d.ts +3 -3
  146. package/dist/time/datasource/CsvFileSource.d.ts +2 -2
  147. package/dist/time/datasource/CsvMapper.d.ts +5 -5
  148. package/dist/time/datasource/CsvMapper.js +1 -1
  149. package/dist/time/datasource/Datasource.d.ts +2 -2
  150. package/dist/time/datasource/DatasourceTestCase.d.ts +8 -8
  151. package/dist/time/datasource/DatasourceTestCase.js +18 -16
  152. package/dist/time/datasource/FileDatasource.d.ts +2 -2
  153. package/dist/time/datasource/JsonMapper.d.ts +4 -4
  154. package/dist/time/datasource/TimeContextFilter.d.ts +3 -3
  155. package/dist/time/datasource/acufo/AcufoCase.d.ts +1 -1
  156. package/dist/time/datasource/acufo/AcufoDatasource.d.ts +3 -3
  157. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummary.d.ts +1 -1
  158. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.d.ts +3 -3
  159. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.js +1 -1
  160. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.d.ts +3 -3
  161. package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.js +1 -1
  162. package/dist/time/datasource/baseovnifrance/BaseOvniFranceDatasource.d.ts +2 -2
  163. package/dist/time/datasource/baseovnifrance/BaseOvniFranceHttpDatasource.d.ts +6 -6
  164. package/dist/time/datasource/baseovnifrance/BaseOvniFranceTestCases.js +1 -1
  165. package/dist/time/datasource/fufora/FuforaCaseSummary.d.ts +1 -1
  166. package/dist/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.d.ts +3 -3
  167. package/dist/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.js +1 -1
  168. package/dist/time/datasource/fufora/FuforaDatasource.d.ts +2 -2
  169. package/dist/time/datasource/fufora/FuforaHttpDatasource.d.ts +5 -5
  170. package/dist/time/datasource/fufora/FuforaTestCases.js +1 -1
  171. package/dist/time/datasource/nuforc/NuforcCaseSummary.d.ts +1 -1
  172. package/dist/time/datasource/nuforc/NuforcDatasource.d.ts +2 -2
  173. package/dist/time/datasource/nuforc/NuforcHttpDatasource.d.ts +6 -6
  174. package/dist/time/datasource/nuforc/NuforcRR0Mapper.d.ts +3 -3
  175. package/dist/time/datasource/nuforc/NuforcRR0Mapper.js +1 -1
  176. package/dist/time/datasource/nuforc/NuforcTestCases.js +1 -1
  177. package/dist/time/datasource/rr0/NamedPlace.d.ts +7 -0
  178. package/dist/time/datasource/rr0/RR0CaseMapping.d.ts +2 -2
  179. package/dist/time/datasource/rr0/RR0CaseSummary.d.ts +0 -7
  180. package/dist/time/datasource/rr0/RR0CaseSummaryMapper.d.ts +3 -3
  181. package/dist/time/datasource/rr0/RR0FileDatasource.d.ts +5 -5
  182. package/dist/time/datasource/rr0/RR0HttpDatasource.d.ts +10 -9
  183. package/dist/time/datasource/rr0/RR0HttpDatasource.js +3 -32
  184. package/dist/time/datasource/rr0/RR0TestCases.js +1 -1
  185. package/dist/time/datasource/rr0/index.d.ts +1 -0
  186. package/dist/time/datasource/sceau/SceauCaseSummaryRR0Mapper.d.ts +3 -3
  187. package/dist/time/datasource/sceau/SceauCaseSummaryRR0Mapper.js +1 -1
  188. package/dist/time/datasource/sceau/SceauDatasource.d.ts +4 -4
  189. package/dist/time/datasource/sceau/SceauDatasource.js +1 -1
  190. package/dist/time/datasource/sceau/SceauHttpDatasource.d.ts +5 -5
  191. package/dist/time/datasource/ufo-search/UfoSearchCase.d.ts +1 -1
  192. package/dist/time/datasource/ufo-search/UfoSearchCaseRR0Mapper.d.ts +4 -4
  193. package/dist/time/datasource/ufo-search/UfoSearchCaseRR0Mapper.js +10 -10
  194. package/dist/time/datasource/ufo-search/UfoSearchDatasource.d.ts +2 -2
  195. package/dist/time/datasource/ufo-search/UfoSearchFileDatasource.d.ts +3 -3
  196. package/dist/time/datasource/ufo-search/UfoSearchFileDatasource.js +1 -1
  197. package/dist/time/datasource/ufo-search/UfoSearchHttpDatasource.d.ts +4 -4
  198. package/dist/time/datasource/ufo-search/UfoSearchTestCases.js +1 -1
  199. package/dist/time/datasource/urecat/UrecatCase.d.ts +1 -1
  200. package/dist/time/datasource/urecat/UrecatHttpDatasource.d.ts +5 -5
  201. package/dist/time/datasource/urecat/UrecatHttpDatasource.js +1 -1
  202. package/dist/time/datasource/urecat/UrecatRR0Mapper.d.ts +3 -3
  203. package/dist/time/datasource/urecat/UrecatRR0Mapper.js +1 -1
  204. package/dist/time/datasource/urecat/UrecatTestCases.js +1 -1
  205. package/dist/time/html/TimeElementFactory.d.ts +15 -0
  206. package/dist/time/{TimeElementFactory.js → html/TimeElementFactory.js} +16 -22
  207. package/dist/time/html/TimeRenderer.d.ts +18 -0
  208. package/dist/time/html/TimeRenderer.js +46 -0
  209. package/dist/time/html/TimeReplacer.d.ts +12 -0
  210. package/dist/time/{TimeReplacer.js → html/TimeReplacer.js} +0 -3
  211. package/dist/time/{TimeReplacerFactory.d.ts → html/TimeReplacerFactory.d.ts} +2 -2
  212. package/dist/time/{TimeReplacerFactory.js → html/TimeReplacerFactory.js} +1 -1
  213. package/dist/time/html/index.d.ts +4 -0
  214. package/dist/time/html/index.js +4 -0
  215. package/dist/time/index.d.ts +3 -8
  216. package/dist/time/index.js +3 -8
  217. package/dist/time/{RelativeTimeTextBuilder.d.ts → text/RelativeTimeTextBuilder.d.ts} +2 -2
  218. package/dist/time/text/RelativeTimeTextBuilder.js +165 -0
  219. package/dist/time/{TimeTextBuilder.d.ts → text/TimeTextBuilder.d.ts} +2 -2
  220. package/dist/time/{TimeTextBuilder.js → text/TimeTextBuilder.js} +1 -1
  221. package/dist/time/text/index.d.ts +2 -0
  222. package/dist/time/text/index.js +2 -0
  223. package/dist/value/UnitReplaceCommand.d.ts +2 -2
  224. package/package.json +15 -12
  225. package/tsconfig.json +2 -1
  226. package/dist/place/PlaceLocation.d.ts +0 -26
  227. package/dist/place/PlaceLocation.js +0 -48
  228. package/dist/place/PlaceMessages.d.ts +0 -5
  229. package/dist/place/PlaceMessages_en.d.ts +0 -2
  230. package/dist/place/PlaceMessages_en.js +0 -4
  231. package/dist/place/PlaceMessages_fr.d.ts +0 -2
  232. package/dist/place/PlaceMessages_fr.js +0 -4
  233. package/dist/time/RelativeTimeTextBuilder.js +0 -166
  234. package/dist/time/TimeContext.d.ts +0 -59
  235. package/dist/time/TimeContext.js +0 -267
  236. package/dist/time/TimeElementFactory.d.ts +0 -15
  237. package/dist/time/TimeRenderer.d.ts +0 -19
  238. package/dist/time/TimeRenderer.js +0 -63
  239. package/dist/time/TimeReplacer.d.ts +0 -24
  240. /package/dist/org/eu/fr/region/idf/77/{paris → SivryCourtry}/SivryCourtry.d.ts +0 -0
  241. /package/dist/org/eu/fr/region/idf/77/{paris → SivryCourtry}/SivryCourtry.js +0 -0
  242. /package/dist/org/eu/fr/region/idf/77/{paris → SivryCourtry}/SivryCourtryMessages.d.ts +0 -0
  243. /package/dist/org/eu/fr/region/idf/77/{paris → SivryCourtry}/SivryCourtryMessages.js +0 -0
  244. /package/dist/{place/PlaceMessages.js → time/datasource/rr0/NamedPlace.js} +0 -0
@@ -1,267 +0,0 @@
1
- import { Time } from "./Time.js";
2
- import { Level2Date as EdtfDate, Level2Duration as EdtfDuration, Level2Interval as EdtfInterval, Level2Timeshift } from "@rr0/time";
3
- /**
4
- * Time context for a RR0 page.
5
- */
6
- export class TimeContext {
7
- constructor(_year, _month, _dayOfMonth, _hour, _minutes, _timeZone, approximate = false, approximateTime = false,
8
- /** @deprecated */
9
- from = undefined,
10
- /** @deprecated */
11
- to = undefined, duration = undefined) {
12
- if (from) {
13
- this.interval = new EdtfInterval(from === null || from === void 0 ? void 0 : from.date, to === null || to === void 0 ? void 0 : to.date);
14
- }
15
- else if (duration) {
16
- this.duration = new EdtfDuration(duration);
17
- }
18
- else {
19
- this.date = new EdtfDate({ year: _year, month: _month, day: _dayOfMonth, hour: _hour, minutes: _minutes, timeZone: _timeZone });
20
- if (approximate) {
21
- this.date.year.approximate = true;
22
- }
23
- if (approximateTime) {
24
- if (this.date.hour) {
25
- this.date.hour.approximateComponent = true;
26
- }
27
- if (this.date.minutes) {
28
- this.date.minutes.approximateComponent = true;
29
- }
30
- if (this.date.seconds) {
31
- this.date.seconds.approximateComponent = true;
32
- }
33
- }
34
- }
35
- }
36
- get from() {
37
- var _a;
38
- return (_a = this.interval) === null || _a === void 0 ? void 0 : _a.start;
39
- }
40
- get to() {
41
- var _a;
42
- return (_a = this.interval) === null || _a === void 0 ? void 0 : _a.end;
43
- }
44
- get approximate() {
45
- var _a, _b, _c;
46
- return ((_a = this.date) === null || _a === void 0 ? void 0 : _a.approximate) || ((_b = this.interval) === null || _b === void 0 ? void 0 : _b.approximate) || ((_c = this.duration) === null || _c === void 0 ? void 0 : _c.approximate);
47
- }
48
- set approximate(approx) {
49
- this.date.approximate = approx;
50
- }
51
- get approximateTime() {
52
- var _a, _b, _c, _d, _e, _f;
53
- return this.approximate || ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.hour) === null || _b === void 0 ? void 0 : _b.approximate) || ((_d = (_c = this.date) === null || _c === void 0 ? void 0 : _c.minute) === null || _d === void 0 ? void 0 : _d.approximate) || ((_f = (_e = this.date) === null || _e === void 0 ? void 0 : _e.second) === null || _f === void 0 ? void 0 : _f.approximate);
54
- }
55
- static parseDateTime(timeStr) {
56
- var _a, _b, _c, _d, _e, _f;
57
- try {
58
- const date = EdtfDate.fromString(timeStr);
59
- return {
60
- approximate: date === null || date === void 0 ? void 0 : date.approximate,
61
- yearStr: (_a = date.year) === null || _a === void 0 ? void 0 : _a.toString(),
62
- monthStr: (_b = date.month) === null || _b === void 0 ? void 0 : _b.toString(),
63
- dayOfMonthStr: (_c = date.day) === null || _c === void 0 ? void 0 : _c.toString(),
64
- hour: (_d = date.hour) === null || _d === void 0 ? void 0 : _d.toString(),
65
- minutes: (_e = date.minutes) === null || _e === void 0 ? void 0 : _e.toString(),
66
- timeZone: (_f = date.timeZone) === null || _f === void 0 ? void 0 : _f.toString()
67
- };
68
- }
69
- catch (e) {
70
- return undefined;
71
- }
72
- }
73
- static fromString(timeStr) {
74
- const timeContext = new TimeContext();
75
- timeContext.updateFromStr(timeStr);
76
- return timeContext;
77
- }
78
- static fromDate(date) {
79
- return new TimeContext(date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), "UTC" + (date.getTimezoneOffset() < 0 ? "-" : "+") + date.getTimezoneOffset());
80
- }
81
- static fromFileName(context, fileName = context.file.name) {
82
- let timeContext;
83
- let elems;
84
- if (fileName.endsWith("index.html")) {
85
- while ((elems = fileName.split("/")).length < 6) {
86
- fileName = elems.slice(0, elems.length - 1).join("/") + "/0/index.html";
87
- }
88
- }
89
- const timeExec = Time.parseFileName(fileName);
90
- if (timeExec && timeExec.length > 5) {
91
- const pageContext = context.clone();
92
- timeContext = pageContext.time;
93
- const m = parseInt(timeExec[2], 10);
94
- const c = parseInt(timeExec[3], 10);
95
- const d = parseInt(timeExec[4], 10);
96
- const u = parseInt(timeExec[5], 10);
97
- const year = (timeExec[1] ? -1 : 1) * (m * 1000 + c * 100 + d * 10 + u);
98
- timeContext.setYear(year);
99
- const monthStr = timeExec[6];
100
- timeContext.setMonth(monthStr ? parseInt(monthStr, 10) : undefined);
101
- const dayStr = timeExec[7];
102
- timeContext.setDayOfMonth(dayStr ? parseInt(dayStr, 10) : undefined);
103
- timeContext.setHour(undefined);
104
- timeContext.setMinutes(undefined);
105
- }
106
- return timeContext;
107
- }
108
- /**
109
- * @param {string} timeStr
110
- * @return If the string could be parsed
111
- */
112
- updateFromStr(timeStr) {
113
- let valid = Boolean(timeStr);
114
- if (valid) {
115
- try {
116
- this.interval = EdtfInterval.fromString(timeStr);
117
- this.date = undefined;
118
- this.duration = undefined;
119
- }
120
- catch (e) {
121
- try {
122
- this.duration = EdtfDuration.fromString(timeStr);
123
- this.interval = undefined;
124
- this.date = undefined;
125
- }
126
- catch (e) {
127
- try {
128
- this.date = EdtfDate.fromString(timeStr);
129
- this.duration = undefined;
130
- this.interval = undefined;
131
- }
132
- catch (e) {
133
- console.warn("Could not resolve time string", timeStr, e.message);
134
- valid = false;
135
- }
136
- }
137
- }
138
- }
139
- return valid;
140
- }
141
- getYear() {
142
- var _a, _b;
143
- return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.year) === null || _b === void 0 ? void 0 : _b.value;
144
- }
145
- setYear(year, print = true) {
146
- var _a, _b;
147
- if (year != ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.year) === null || _b === void 0 ? void 0 : _b.value) && print) {
148
- this.setMonth(undefined, print);
149
- }
150
- this.date = this.date || new EdtfDate();
151
- this.date.year = year;
152
- return this;
153
- }
154
- getMonth() {
155
- var _a, _b;
156
- return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.month) === null || _b === void 0 ? void 0 : _b.value;
157
- }
158
- setMonth(month, print = true) {
159
- var _a, _b;
160
- if (month != ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.month) === null || _b === void 0 ? void 0 : _b.value) && print) {
161
- this.setDayOfMonth(undefined, print);
162
- }
163
- this.date = this.date || new EdtfDate();
164
- this.date.month = month;
165
- return this;
166
- }
167
- getDayOfMonth() {
168
- var _a, _b;
169
- return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.day) === null || _b === void 0 ? void 0 : _b.value;
170
- }
171
- setDayOfMonth(dayOfMonth, print = true) {
172
- var _a, _b;
173
- if (dayOfMonth != ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.day) === null || _b === void 0 ? void 0 : _b.value) && print) {
174
- this.setHour(undefined, print);
175
- }
176
- this.date = this.date || new EdtfDate();
177
- this.date.day = dayOfMonth;
178
- return this;
179
- }
180
- getHour() {
181
- var _a, _b;
182
- return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.hour) === null || _b === void 0 ? void 0 : _b.value;
183
- }
184
- setHour(hour, print = true) {
185
- var _a, _b;
186
- if (hour != ((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.hour) === null || _b === void 0 ? void 0 : _b.value) && print) {
187
- this.setMinutes(undefined);
188
- }
189
- this.date = this.date || new EdtfDate();
190
- this.date.hour = hour;
191
- return this;
192
- }
193
- getMinutes() {
194
- var _a, _b;
195
- return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.minute) === null || _b === void 0 ? void 0 : _b.value;
196
- }
197
- setMinutes(minutes) {
198
- this.date = this.date || new EdtfDate();
199
- this.date.minute = minutes;
200
- return this;
201
- }
202
- /**
203
- * @deprecated
204
- */
205
- getTimeZone() {
206
- var _a, _b;
207
- return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.timeshift) === null || _b === void 0 ? void 0 : _b.toString();
208
- }
209
- getTimeshift() {
210
- var _a, _b;
211
- return (_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.timeshift) === null || _b === void 0 ? void 0 : _b.toString();
212
- }
213
- setTimeZone(timeZone) {
214
- this.date = this.date || new Level2Timeshift();
215
- try {
216
- this.date.timeshift = Level2Timeshift.fromString(timeZone);
217
- }
218
- catch (e) {
219
- console.warn("Could not resolve time zone", timeZone, e.message);
220
- }
221
- return this;
222
- }
223
- isDefined() {
224
- var _a, _b, _c, _d, _e;
225
- const date = this.date;
226
- if (!date) {
227
- return false;
228
- }
229
- return ((_a = date.year) === null || _a === void 0 ? void 0 : _a.value) != undefined
230
- || ((_b = date.month) === null || _b === void 0 ? void 0 : _b.value) != undefined
231
- || ((_c = date.day) === null || _c === void 0 ? void 0 : _c.value) != undefined
232
- || ((_d = date.hour) === null || _d === void 0 ? void 0 : _d.value) != undefined
233
- || ((_e = date.minute) === null || _e === void 0 ? void 0 : _e.value) != undefined;
234
- }
235
- clone() {
236
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
237
- return new TimeContext((_b = (_a = this.date) === null || _a === void 0 ? void 0 : _a.year) === null || _b === void 0 ? void 0 : _b.value, (_d = (_c = this.date) === null || _c === void 0 ? void 0 : _c.month) === null || _d === void 0 ? void 0 : _d.value, (_f = (_e = this.date) === null || _e === void 0 ? void 0 : _e.day) === null || _f === void 0 ? void 0 : _f.value, (_h = (_g = this.date) === null || _g === void 0 ? void 0 : _g.hour) === null || _h === void 0 ? void 0 : _h.value, (_k = (_j = this.date) === null || _j === void 0 ? void 0 : _j.minutes) === null || _k === void 0 ? void 0 : _k.value, (_m = (_l = this.date) === null || _l === void 0 ? void 0 : _l.timeshift) === null || _m === void 0 ? void 0 : _m.value, this.approximate, this.approximateTime, (_o = this.interval) === null || _o === void 0 ? void 0 : _o.from, (_p = this.interval) === null || _p === void 0 ? void 0 : _p.to, this.duration);
238
- }
239
- reset() {
240
- this.date = undefined;
241
- this.interval = undefined;
242
- this.duration = undefined;
243
- return this;
244
- }
245
- isBefore(other) {
246
- return this.toString().localeCompare(other.toString()) < 0;
247
- }
248
- isAfter(other) {
249
- return this.toString().localeCompare(other.toString()) > 0;
250
- }
251
- equals(other) {
252
- return this.toString() === other.toString();
253
- }
254
- toString() {
255
- return this.date ? this.date.toString() : "";
256
- }
257
- toJSON() {
258
- return this.toString();
259
- }
260
- isSet(value) {
261
- return value != void 0 && value != null;
262
- }
263
- }
264
- TimeContext.dateTimeRegexp = new RegExp("^(~)?(-?\\d{3,})?(?:-?([0-1]\\d)(?!\:))?(?:-?([0-3]\\d{1,2}(?!\:)))?(?:[T ]?(?:([0-2]\\d):([0-5]\\d))?)?(?: ?([A-Z]{3}))?");
265
- TimeContext.MINUTE = 60;
266
- TimeContext.HOUR = 60 * TimeContext.MINUTE;
267
- TimeContext.DAY = 24 * TimeContext.HOUR;
@@ -1,15 +0,0 @@
1
- import { HtmlRR0SsgContext, RR0SsgContext } from "../RR0SsgContext.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: HtmlRR0SsgContext, previousContext: HtmlRR0SsgContext | undefined, options?: TimeRenderOptions): HTMLElement | undefined;
10
- createInterval(fromContext: HtmlRR0SsgContext, toContext: HtmlRR0SsgContext, previousContext: HtmlRR0SsgContext, options: TimeRenderOptions): HTMLElement | undefined;
11
- createStarting(fromContext: HtmlRR0SsgContext, previousContext: HtmlRR0SsgContext, options: TimeRenderOptions): HTMLElement | undefined;
12
- valueReplacement(context: HtmlRR0SsgContext, previousContext: RR0SsgContext | undefined, options?: TimeRenderOptions): HTMLElement | undefined;
13
- protected durationReplacement(context: HtmlRR0SsgContext): HTMLTimeElement | undefined;
14
- protected dateTimeReplacement(context: HtmlRR0SsgContext, previousContext: RR0SsgContext | null, options?: TimeRenderOptions): HTMLElement | undefined;
15
- }
@@ -1,19 +0,0 @@
1
- import { HtmlRR0SsgContext, RR0SsgContext } from "../RR0SsgContext.js";
2
- import { TimeTextBuilder } from "./TimeTextBuilder.js";
3
- export interface TimeRenderOptions {
4
- url: boolean;
5
- }
6
- export declare class TimeRenderer {
7
- readonly timeFiles: string[];
8
- protected textBuilder: TimeTextBuilder;
9
- constructor(timeFiles: string[], textBuilder: TimeTextBuilder);
10
- render(context: HtmlRR0SsgContext, previousContext?: RR0SsgContext, options?: TimeRenderOptions): HTMLElement;
11
- renderContent(context: HtmlRR0SsgContext, previousContext: RR0SsgContext, options: TimeRenderOptions, renderOptions?: Intl.DateTimeFormatOptions): {
12
- result: HTMLElement;
13
- replacement: HTMLElement;
14
- };
15
- /**
16
- * Creates <time> elements from time contexts.
17
- */
18
- protected matchExistingTimeFile(url: string): string | undefined;
19
- }
@@ -1,63 +0,0 @@
1
- import { TimeUrlBuilder } from "./TimeUrlBuilder.js";
2
- import { RelativeTimeTextBuilder } from "./RelativeTimeTextBuilder.js";
3
- import { UrlUtil } from "../util/url/UrlUtil.js";
4
- import { TimeReplacer } from "./TimeReplacer.js";
5
- export class TimeRenderer {
6
- constructor(timeFiles, textBuilder) {
7
- this.timeFiles = timeFiles;
8
- this.textBuilder = 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
- if (time.getDayOfMonth()) {
15
- result.append(timeMessages.on(time.approximate), replacement);
16
- }
17
- else {
18
- result.append(timeMessages.in(time.approximate), replacement);
19
- }
20
- return result;
21
- }
22
- renderContent(context, previousContext, options, renderOptions = this.textBuilder.options) {
23
- const time = context.time;
24
- const absoluteTimeUrl = TimeUrlBuilder.fromContext(time);
25
- const title = this.textBuilder.build(context, true, renderOptions);
26
- let text = previousContext ? new RelativeTimeTextBuilder(this.textBuilder).build(previousContext, context) : undefined;
27
- if (!text) {
28
- text = title;
29
- }
30
- const file = context.file;
31
- const currentFileName = file.name;
32
- const doc = file.document;
33
- let replacement;
34
- const timeEl = TimeReplacer.resolvedTime(context, time.toString());
35
- if (title !== text) {
36
- timeEl.title = title;
37
- }
38
- timeEl.textContent = text;
39
- const dirName = currentFileName.substring(0, currentFileName.indexOf("/index"));
40
- const url = options.url && this.matchExistingTimeFile(absoluteTimeUrl);
41
- if (url && url !== dirName) {
42
- const a = replacement = doc.createElement("a");
43
- a.href = UrlUtil.absolute(url);
44
- a.append(timeEl);
45
- }
46
- else {
47
- replacement = timeEl;
48
- }
49
- let result = context.file.document.createElement("span");
50
- result.className = "time-resolved";
51
- return { result, replacement };
52
- }
53
- /**
54
- * Creates <time> elements from time contexts.
55
- */
56
- matchExistingTimeFile(url) {
57
- while (url !== "time" && this.timeFiles.indexOf(`${url}/index.html`) < 0) {
58
- const slash = url.lastIndexOf("/");
59
- url = url.substring(0, slash);
60
- }
61
- return url === "time" ? undefined : url;
62
- }
63
- }
@@ -1,24 +0,0 @@
1
- import { HtmlRR0SsgContext } from "../RR0SsgContext.js";
2
- import { DomReplacement } from "./DomReplacement.js";
3
- import { TimeElementFactory } from "./TimeElementFactory.js";
4
- export type TimeParseResult = {
5
- approximate: string;
6
- yearStr: string;
7
- monthStr: string;
8
- dayOfMonthStr: string;
9
- hour: string;
10
- minutes: string;
11
- timeZone: string;
12
- };
13
- /**
14
- * Replaces a <time> tag.
15
- */
16
- export declare class TimeReplacer implements DomReplacement<HtmlRR0SsgContext, HTMLTimeElement> {
17
- readonly factory: TimeElementFactory;
18
- /**
19
- * @param factory
20
- */
21
- constructor(factory: TimeElementFactory);
22
- static resolvedTime(context: HtmlRR0SsgContext, dateTime: string): HTMLTimeElement;
23
- replacement(context: HtmlRR0SsgContext, origEl: HTMLTimeElement): Promise<HTMLElement>;
24
- }