erudit 2.0.0-dev.7 → 2.0.0-dev.9

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 (212) hide show
  1. package/.nuxtrc +1 -1
  2. package/app/app.vue +172 -172
  3. package/app/components/Loading.vue +23 -23
  4. package/app/components/SiteAside.vue +382 -382
  5. package/app/components/SiteMain.vue +35 -35
  6. package/app/components/ads/BannerTemplate.vue +51 -51
  7. package/app/components/ads/BottomBanner.vue +45 -45
  8. package/app/components/ads/LeftBanner.vue +50 -50
  9. package/app/components/aside/AsideListItem.vue +74 -74
  10. package/app/components/aside/AsideMajor.vue +56 -56
  11. package/app/components/aside/AsideMinor.vue +71 -71
  12. package/app/components/aside/major/PaneContentScroll.vue +23 -23
  13. package/app/components/aside/major/PaneSwitch.vue +54 -54
  14. package/app/components/aside/major/PaneSwitchButton.vue +63 -63
  15. package/app/components/aside/major/SiteInfo.vue +85 -85
  16. package/app/components/aside/major/panes/Language.vue +79 -79
  17. package/app/components/aside/major/panes/Pages.vue +34 -34
  18. package/app/components/aside/major/panes/Search.vue +2 -2
  19. package/app/components/aside/major/panes/nav/Nav.vue +91 -91
  20. package/app/components/aside/major/panes/nav/NavBook.vue +86 -86
  21. package/app/components/aside/major/panes/nav/NavBookLoading.vue +24 -24
  22. package/app/components/aside/major/panes/nav/NavGlobal.vue +16 -16
  23. package/app/components/aside/major/panes/nav/fnav/FNav.vue +105 -105
  24. package/app/components/aside/major/panes/nav/fnav/FNavBook.vue +32 -32
  25. package/app/components/aside/major/panes/nav/fnav/FNavFlags.vue +40 -40
  26. package/app/components/aside/major/panes/nav/fnav/FNavFolder.vue +60 -60
  27. package/app/components/aside/major/panes/nav/fnav/FNavItem.vue +34 -34
  28. package/app/components/aside/major/panes/nav/fnav/FNavSeparator.vue +80 -80
  29. package/app/components/aside/major/panes/nav/fnav/FNavTopic.vue +24 -24
  30. package/app/components/aside/major/panes/other/ItemContent.vue +29 -29
  31. package/app/components/aside/major/panes/other/ItemGenerator.vue +15 -15
  32. package/app/components/aside/major/panes/other/ItemTheme.vue +54 -54
  33. package/app/components/aside/major/panes/other/Other.vue +16 -16
  34. package/app/components/aside/minor/AsideMinorContributor.vue +4 -4
  35. package/app/components/aside/minor/AsideMinorNews.vue +11 -11
  36. package/app/components/aside/minor/AsideMinorPane.vue +15 -15
  37. package/app/components/aside/minor/AsideMinorTopLink.vue +67 -67
  38. package/app/components/aside/minor/Contribute.vue +145 -145
  39. package/app/components/aside/minor/content/AsideMinorContent.vue +92 -92
  40. package/app/components/aside/minor/topic/AsideMinorTopic.vue +32 -32
  41. package/app/components/aside/minor/topic/TopicContributors.vue +177 -177
  42. package/app/components/aside/minor/topic/TopicNav.vue +49 -49
  43. package/app/components/aside/minor/topic/TopicToc.vue +203 -202
  44. package/app/components/aside/minor/topic/TopicTocItem.vue +31 -31
  45. package/app/components/aside/utils/AsideOverlayPane.vue +40 -40
  46. package/app/components/bitran/BitranContent.vue +63 -64
  47. package/app/components/bitran/RenderWrapper.vue +10 -12
  48. package/app/components/contributor/ContributorAvatar.vue +43 -43
  49. package/app/components/contributor/ContributorListItem.vue +35 -35
  50. package/app/components/main/topic/MainTopic.vue +79 -79
  51. package/app/components/main/topic/TopicPartSwitch.vue +118 -118
  52. package/app/components/main/utils/Breadcrumb.vue +75 -75
  53. package/app/components/main/utils/ContentDecoration.vue +29 -29
  54. package/app/components/main/utils/ContentDescription.vue +19 -19
  55. package/app/components/main/utils/ContentFlag.vue +15 -15
  56. package/app/components/main/utils/ContentPopover.vue +176 -176
  57. package/app/components/main/utils/ContentPopovers.vue +105 -105
  58. package/app/components/main/utils/ContentReferences.vue +75 -75
  59. package/app/components/main/utils/ContentSection.vue +41 -41
  60. package/app/components/main/utils/ContentTitle.vue +36 -36
  61. package/app/components/main/utils/reference/ReferenceGroup.vue +40 -40
  62. package/app/components/main/utils/reference/ReferenceItem.vue +63 -63
  63. package/app/components/main/utils/reference/ReferenceSource.vue +109 -109
  64. package/app/components/preview/Preview.vue +177 -177
  65. package/app/components/preview/PreviewDisplay.vue +139 -139
  66. package/app/components/preview/PreviewFooterAction.vue +73 -73
  67. package/app/components/preview/PreviewLoading.vue +14 -14
  68. package/app/components/preview/PreviewScreen.vue +99 -99
  69. package/app/components/preview/display/Alert.vue +50 -50
  70. package/app/components/preview/display/Custom.vue +18 -18
  71. package/app/components/preview/display/GenericLink.vue +48 -48
  72. package/app/components/preview/display/PageLink.vue +20 -20
  73. package/app/components/preview/display/Unique.vue +49 -49
  74. package/app/components/transition/Fade.vue +21 -21
  75. package/app/components/tree/TreeContainer.vue +11 -11
  76. package/app/components/tree/TreeItem.vue +89 -89
  77. package/app/composables/bitran.ts +98 -103
  78. package/app/composables/bitranContent.ts +2 -1
  79. package/app/composables/contentPage.ts +1 -1
  80. package/app/composables/phrases.ts +80 -80
  81. package/app/pages/_test/preview.vue +110 -110
  82. package/app/pages/article/[...articleId].vue +2 -2
  83. package/app/pages/book/[...bookId].vue +47 -47
  84. package/app/pages/group/[...groupId].vue +65 -64
  85. package/app/pages/index.vue +32 -32
  86. package/app/pages/members.vue +6 -6
  87. package/app/pages/practice/[...practice].vue +2 -2
  88. package/app/pages/summary/[...summaryId].vue +2 -2
  89. package/app/public/favicon/article.svg +9 -9
  90. package/app/public/favicon/default.svg +9 -9
  91. package/app/public/favicon/practice.svg +9 -9
  92. package/app/public/favicon/summary.svg +9 -9
  93. package/app/public/logotype.svg +16 -16
  94. package/app/public/user.svg +9 -9
  95. package/app/scripts/_immediate.js +3 -3
  96. package/app/scripts/flag.ts +28 -28
  97. package/app/scripts/og.ts +27 -27
  98. package/app/scripts/preview/data/unique.ts +3 -3
  99. package/app/scripts/preview/display.ts +5 -7
  100. package/app/scripts/preview/request.ts +2 -2
  101. package/app/styles/_immediate.css +2 -2
  102. package/app/styles/_util.scss +49 -49
  103. package/app/styles/_utils.scss +44 -44
  104. package/app/styles/default.scss +84 -84
  105. package/app/styles/partials/_darkMagic.scss +6 -6
  106. package/app/styles/partials/_fnav.scss +17 -17
  107. package/app/styles/partials/_preview.scss +6 -6
  108. package/globalPath.ts +21 -24
  109. package/globals/bitran.ts +21 -13
  110. package/globals/erudit.ts +5 -5
  111. package/globals/register.ts +18 -18
  112. package/languages/en.ts +95 -95
  113. package/languages/ru.ts +99 -99
  114. package/module/config.ts +34 -34
  115. package/module/imports.ts +46 -46
  116. package/module/index.ts +47 -35
  117. package/module/logger.ts +10 -10
  118. package/module/restart.ts +61 -61
  119. package/nuxt.config.ts +107 -96
  120. package/package.json +9 -6
  121. package/server/api/aside/major/nav/bookIds.ts +5 -5
  122. package/server/api/aside/major/nav/bookNav/[...bookId].ts +20 -20
  123. package/server/api/aside/major/nav/global.ts +7 -7
  124. package/server/api/aside/minor/news.ts +7 -7
  125. package/server/api/aside/minor/path.ts +78 -78
  126. package/server/api/bitran/content/[location].ts +7 -7
  127. package/server/api/bitran/toc/[location].ts +7 -7
  128. package/server/api/content/data.ts +72 -72
  129. package/server/api/fake/content.ts +10 -10
  130. package/server/api/fake/shared/languages.ts +12 -12
  131. package/server/api/language/functions.ts +12 -12
  132. package/server/api/language/phrase/[phraseId].ts +19 -19
  133. package/server/api/language/phraseIds.ts +8 -8
  134. package/server/api/preview/page/[...parts].ts +51 -51
  135. package/server/api/preview/unique/[location].ts +55 -55
  136. package/server/plugin/bitran/content.ts +55 -44
  137. package/server/plugin/bitran/products/include.ts +28 -27
  138. package/server/plugin/bitran/products/link.ts +11 -9
  139. package/server/plugin/bitran/setup.ts +0 -1
  140. package/server/plugin/bitran/toc.ts +25 -24
  141. package/server/plugin/bitran/transpiler.ts +46 -0
  142. package/server/plugin/build/close.ts +10 -10
  143. package/server/plugin/build/jobs/content/parse.ts +37 -27
  144. package/server/plugin/build/jobs/language.ts +36 -36
  145. package/server/plugin/build/process.ts +25 -25
  146. package/server/plugin/build/rebuild.ts +55 -55
  147. package/server/plugin/build/setup.ts +21 -21
  148. package/server/plugin/global.ts +18 -18
  149. package/server/plugin/importer.ts +12 -12
  150. package/server/plugin/index.ts +9 -9
  151. package/server/plugin/logger.ts +23 -23
  152. package/server/tsconfig.json +7 -7
  153. package/shared/bitran/context.ts +3 -2
  154. package/shared/bitran/default.ts +46 -0
  155. package/shared/bitran/{products/link/render → link}/Link.vue +7 -14
  156. package/shared/bitran/link/factory.ts +24 -0
  157. package/shared/bitran/link/languages/en.ts +7 -0
  158. package/shared/bitran/link/languages/ru.ts +7 -0
  159. package/shared/bitran/link/renderer.ts +21 -0
  160. package/shared/bitran/link/shared.ts +17 -0
  161. package/shared/bitran/{products/link → link}/target.ts +1 -1
  162. package/shared/bitran/link/transpiler.ts +10 -0
  163. package/shared/content/context.ts +9 -9
  164. package/shared/content/data/base.ts +32 -32
  165. package/shared/content/data/index.ts +5 -5
  166. package/shared/content/data/type/book.ts +5 -5
  167. package/shared/content/data/type/group.ts +6 -6
  168. package/shared/content/data/type/topic.ts +11 -11
  169. package/shared/content/previousNext.ts +9 -9
  170. package/shared/link.ts +25 -25
  171. package/shared/types/language.ts +75 -75
  172. package/test/bitran/{products/link → link}/target.test.ts +5 -2
  173. package/tsconfig.json +8 -8
  174. package/utils/stress.ts +9 -9
  175. package/server/plugin/bitran/core.ts +0 -51
  176. package/shared/bitran/alias.ts +0 -17
  177. package/shared/bitran/products/alias/core/factory.ts +0 -46
  178. package/shared/bitran/products/alias/core/index.ts +0 -13
  179. package/shared/bitran/products/alias/render/Alias.vue +0 -10
  180. package/shared/bitran/products/alias/render/icon.svg +0 -3
  181. package/shared/bitran/products/alias/render/index.ts +0 -17
  182. package/shared/bitran/products/alias/render/languages/en.ts +0 -5
  183. package/shared/bitran/products/alias/render/languages/ru.ts +0 -5
  184. package/shared/bitran/products/alias/shared.ts +0 -11
  185. package/shared/bitran/products/heading/core/factory.ts +0 -53
  186. package/shared/bitran/products/heading/core/index.ts +0 -19
  187. package/shared/bitran/products/heading/render/Heading.vue +0 -47
  188. package/shared/bitran/products/heading/render/icon.svg +0 -3
  189. package/shared/bitran/products/heading/render/index.ts +0 -17
  190. package/shared/bitran/products/heading/render/languages/en.ts +0 -5
  191. package/shared/bitran/products/heading/render/languages/ru.ts +0 -5
  192. package/shared/bitran/products/heading/shared.ts +0 -13
  193. package/shared/bitran/products/include/core/factory.ts +0 -61
  194. package/shared/bitran/products/include/core/index.ts +0 -13
  195. package/shared/bitran/products/include/render/Include.vue +0 -13
  196. package/shared/bitran/products/include/render/icon.svg +0 -3
  197. package/shared/bitran/products/include/render/index.ts +0 -18
  198. package/shared/bitran/products/include/render/languages/en.ts +0 -5
  199. package/shared/bitran/products/include/render/languages/ru.ts +0 -5
  200. package/shared/bitran/products/include/shared.ts +0 -15
  201. package/shared/bitran/products/link/core/factory.ts +0 -20
  202. package/shared/bitran/products/link/core/index.ts +0 -17
  203. package/shared/bitran/products/link/render/index.ts +0 -17
  204. package/shared/bitran/products/link/render/languages/en.ts +0 -5
  205. package/shared/bitran/products/link/render/languages/ru.ts +0 -5
  206. package/shared/bitran/products/link/shared.ts +0 -15
  207. package/test/bitran/alias.test.ts +0 -44
  208. package/test/bitran/products/alias.test.ts +0 -83
  209. package/test/bitran/products/heading.test.ts +0 -119
  210. package/test/bitran/products/include.test.ts +0 -77
  211. package/test/bitran/products/link/factory.test.ts +0 -30
  212. /package/shared/bitran/{products/link/render → link}/icon.svg +0 -0
@@ -1,38 +1,39 @@
1
- import type { BitranCore } from 'bitran/core';
2
- import { BlockNode, type ProductNode } from 'bitran/dom';
1
+ import { BlockNode, type ElementNode } from '@bitran-js/core';
2
+ import type { BitranTranspiler } from '@bitran-js/transpiler';
3
+ import { IncludeNode } from '@erudit-js/bitran-elements/include/shared';
4
+ import {
5
+ AliasesNode,
6
+ tryReplaceAlias,
7
+ type Aliases,
8
+ } from '@erudit-js/bitran-elements/aliases/shared';
9
+
10
+ import { createBitranTranspiler } from '@server/bitran/transpiler';
11
+ import { ERUDIT_SERVER } from '@server/global';
12
+ import { DbUnique } from '@server/db/entities/Unique';
13
+ import {
14
+ toAbsoluteContentId,
15
+ toAbsoluteContentLocation,
16
+ } from '@server/content/absoluteId';
3
17
 
4
18
  import type { BitranContext } from '@erudit/shared/bitran/context';
5
- import { IncludeNode } from '@erudit/shared/bitran/products/include/core';
6
19
  import {
7
20
  parseBitranLocation,
8
21
  parsePartialBitranLocation,
9
22
  stringifyBitranLocation,
10
23
  } from '@erudit/shared/bitran/location';
11
- import {
12
- tryReplaceAlias,
13
- type BitranAliases,
14
- } from '@erudit/shared/bitran/alias';
15
- import {
16
- toAbsoluteContentId,
17
- toAbsoluteContentLocation,
18
- } from '../../content/absoluteId';
19
- import { ERUDIT_SERVER } from '../../global';
20
- import { DbUnique } from '../../db/entities/Unique';
21
- import { createBitranCore } from '../core';
22
- import { AliasNode } from '@erudit/shared/bitran/products/alias/core';
23
- import { LinkNode } from '@erudit/shared/bitran/products/link/core';
24
- import { createLinkTarget } from '@erudit/shared/bitran/products/link/target';
24
+ import { createLinkTarget } from '@erudit/shared/bitran/link/target';
25
+ import { LinkNode } from '@erudit/shared/bitran/link/shared';
25
26
 
26
27
  export type TraverseEnterFn = (payload: {
27
28
  _location: string;
28
- _bitranCore: BitranCore;
29
+ _bitranTranspiler: BitranTranspiler;
29
30
  _biCode: string;
30
31
  }) => Promise<any>;
31
32
 
32
33
  export type TraverseStepFn = (payload: {
33
34
  _location: string;
34
- _bitranCore: BitranCore;
35
- _node: ProductNode;
35
+ _bitranTranspiler: BitranTranspiler;
36
+ _node: ElementNode;
36
37
  }) => Promise<any>;
37
38
 
38
39
  export type TraverseLeaveFn = (payload: { _location: string }) => Promise<any>;
@@ -52,7 +53,7 @@ export async function traverseInclude(
52
53
  },
53
54
  ) {
54
55
  const entryLocation = stringifyBitranLocation(
55
- parsePartialBitranLocation(includeNode.getId(), context.location),
56
+ parsePartialBitranLocation(includeNode.id, context.location),
56
57
  );
57
58
 
58
59
  const travelMap: Record<string, string | null> = {
@@ -86,7 +87,7 @@ export async function traverseInclude(
86
87
  async function _traverseStep(
87
88
  includeNode: IncludeNode,
88
89
  location: string,
89
- aliases: BitranAliases,
90
+ aliases: Aliases,
90
91
  listeners: {
91
92
  enter?: TraverseEnterFn;
92
93
  step?: TraverseStepFn;
@@ -140,13 +141,13 @@ async function _traverseStep(
140
141
  aliases: dbUnique.context.aliases,
141
142
  };
142
143
 
143
- const bitranCore = await createBitranCore(context);
144
+ const bitranTranspiler = await createBitranTranspiler();
144
145
 
145
146
  listeners.enter &&
146
147
  (await listeners.enter({
147
148
  _biCode: dbUnique.content,
148
149
  _location: includeTargetLocation,
149
- _bitranCore: bitranCore,
150
+ _bitranTranspiler: bitranTranspiler,
150
151
  }));
151
152
 
152
153
  //
@@ -155,12 +156,12 @@ async function _traverseStep(
155
156
 
156
157
  let stepErrorMessage: string | undefined;
157
158
 
158
- await bitranCore.parser.parse(dbUnique.content, {
159
+ await bitranTranspiler.parser.parse(dbUnique.content, {
159
160
  step: async (node) => {
160
161
  if (stepErrorMessage) return;
161
162
 
162
163
  // Skip Alias nodes to prevent them being injected into calling document context and possibly conflicting with other aliases, includes and links...
163
- if (node instanceof AliasNode) return;
164
+ if (node instanceof AliasesNode) return;
164
165
 
165
166
  // Replacing block ids with absolute ones to make possible to link to them
166
167
  if (node instanceof BlockNode)
@@ -192,7 +193,7 @@ async function _traverseStep(
192
193
  (await listeners.step({
193
194
  _location: includeTargetLocation,
194
195
  _node: node,
195
- _bitranCore: bitranCore,
196
+ _bitranTranspiler: bitranTranspiler,
196
197
  }));
197
198
 
198
199
  return;
@@ -1,15 +1,19 @@
1
+ import { isTopicPart } from 'erudit-cog/schema';
2
+
3
+ import { DbUnique } from '@server/db/entities/Unique';
4
+ import { ERUDIT_SERVER } from '@server/global';
5
+ import { DbContent } from '@server/db/entities/Content';
6
+ import { DbContributor } from '@server/db/entities/Contributor';
7
+
1
8
  import {
2
9
  createLinkTarget,
3
10
  type LinkTarget,
4
- } from '@erudit/shared/bitran/products/link/target';
11
+ } from '@erudit/shared/bitran/link/target';
5
12
  import {
6
13
  toAbsoluteContentId,
7
14
  toAbsoluteContentLocation,
8
- } from '../../content/absoluteId';
15
+ } from '@server/content/absoluteId';
9
16
  import type { BitranContext } from '@erudit/shared/bitran/context';
10
- import type { LinkData } from '@erudit/shared/bitran/products/link/shared';
11
- import { DbUnique } from '../../db/entities/Unique';
12
- import { ERUDIT_SERVER } from '../../global';
13
17
  import {
14
18
  parseBitranLocation,
15
19
  stringifyBitranLocation,
@@ -20,12 +24,10 @@ import {
20
24
  createContributorLink,
21
25
  createTopicPartLink,
22
26
  } from '@erudit/shared/link';
23
- import { DbContent } from '../../db/entities/Content';
24
- import { isTopicPart } from 'erudit-cog/schema';
25
- import { DbContributor } from '../../db/entities/Contributor';
27
+ import type { LinkParseData } from '@erudit/shared/bitran/link/shared';
26
28
 
27
29
  export async function resolveLinkTarget(
28
- linkData: LinkData,
30
+ linkData: LinkParseData,
29
31
  context: BitranContext,
30
32
  ): Promise<LinkTarget> {
31
33
  const linkTarget = createLinkTarget(linkData.target, context);
@@ -5,6 +5,5 @@ import { ERUDIT_SERVER } from '@server/global';
5
5
  export async function setupBitranConfig() {
6
6
  try {
7
7
  ERUDIT_SERVER.BITRAN_CONFIG = await IMPORT(PROJECT_DIR + '/bitran.ts');
8
- console.log(ERUDIT_SERVER.BITRAN_CONFIG);
9
8
  } catch {}
10
9
  }
@@ -1,48 +1,49 @@
1
- import type { ProductNode } from 'bitran/dom';
1
+ import { BlockErrorNode, type ElementNode } from '@bitran-js/core';
2
+ import { IncludeNode } from '@erudit-js/bitran-elements/include/shared';
3
+ import {
4
+ headingName,
5
+ HeadingNode,
6
+ } from '@erudit-js/bitran-elements/heading/shared';
2
7
 
3
- import { getRawBitranContent } from './content';
4
- import { createBitranCore } from './core';
5
8
  import type { BitranLocation } from '@erudit/shared/bitran/location';
6
9
  import type { Toc } from '@erudit/shared/bitran/toc';
7
- import { IncludeNode } from '@erudit/shared/bitran/products/include/core';
10
+ import { ERUDIT_SERVER } from '@server/global';
11
+ import { getRawBitranContent } from './content';
12
+ import { createBitranTranspiler } from './transpiler';
8
13
  import { traverseInclude } from './products/include';
9
- import { HeadingNode } from '@erudit/shared/bitran/products/heading/core';
10
- import { headingName } from '@erudit/shared/bitran/products/heading/shared';
11
- import { ERUDIT_SERVER } from '../global';
12
14
 
13
15
  export async function getBitranToc(location: BitranLocation) {
14
16
  const rawContent = await getRawBitranContent(location);
15
- const bitranCore = await createBitranCore(rawContent.context);
17
+ const bitranCore = await createBitranTranspiler();
16
18
 
17
19
  const toc: Toc = [];
18
20
 
19
21
  await bitranCore.parser.parse(rawContent.biCode, {
20
- step: async (productNode) => {
21
- if (productNode instanceof IncludeNode) {
22
- await traverseInclude(productNode, rawContent.context, {
22
+ async step(node) {
23
+ if (node instanceof IncludeNode) {
24
+ await traverseInclude(node, rawContent.context, {
23
25
  step: async ({ _node }) => tryAddToToc(_node),
24
26
  });
25
- } else tryAddToToc(productNode);
27
+ } else tryAddToToc(node);
26
28
  },
27
29
  });
28
30
 
29
31
  return toc;
30
32
 
31
- function tryAddToToc(product: ProductNode) {
33
+ function tryAddToToc(node: ElementNode) {
32
34
  const tocItemBase = {
33
- id: product.getId(),
34
- productName: product.name,
35
+ id: node.id,
36
+ productName: node.name,
35
37
  };
36
38
 
37
39
  // Check if node is manually excluded from TOC
38
- if (typeof product.meta?.toc === 'boolean' && !product.meta?.toc)
39
- return;
40
+ if (typeof node.meta?.toc === 'boolean' && !node.meta?.toc) return;
40
41
 
41
- if (product instanceof HeadingNode) {
42
+ if (node instanceof HeadingNode) {
42
43
  toc.push({
43
44
  ...tocItemBase,
44
- level: product.parseData.level,
45
- title: product.parseData.title,
45
+ level: node.parseData.level,
46
+ title: node.parseData.title,
46
47
  });
47
48
  return;
48
49
  }
@@ -59,22 +60,22 @@ export async function getBitranToc(location: BitranLocation) {
59
60
  : lastTocItem.level;
60
61
  };
61
62
 
62
- if (ERUDIT_SERVER.BITRAN_CONFIG?.toc?.includes(product.name)) {
63
+ if (ERUDIT_SERVER.BITRAN_CONFIG?.toc?.includes(node.name)) {
63
64
  // Erudit Config says to add these products to TOC
64
65
  toc.push({
65
66
  ...tocItemBase,
66
67
  level: notHeadingLevel(),
67
- title: product.meta?.title || product.parseData?.title,
68
+ title: node.meta?.title || node.parseData?.title,
68
69
  });
69
70
  return;
70
71
  }
71
72
 
72
- if (product.meta?.toc) {
73
+ if (node.meta?.toc) {
73
74
  // Show in Toc any product with truthy `toc` meta property
74
75
  toc.push({
75
76
  ...tocItemBase,
76
77
  level: notHeadingLevel(),
77
- title: product.meta?.title || product.parseData?.title,
78
+ title: node.meta?.title || node.parseData?.title,
78
79
  });
79
80
  return;
80
81
  }
@@ -0,0 +1,46 @@
1
+ import {
2
+ defineBitranTranspiler,
3
+ type ElementTranspilers,
4
+ } from '@bitran-js/transpiler';
5
+
6
+ import { ERUDIT_SERVER } from '@server/global';
7
+
8
+ // Default Elements
9
+ import { aliasesName } from '@erudit-js/bitran-elements/aliases/shared';
10
+ import { aliasesTranspiler } from '@erudit-js/bitran-elements/aliases/transpiler';
11
+ import { headingName } from '@erudit-js/bitran-elements/heading/shared';
12
+ import { headingTranspiler } from '@erudit-js/bitran-elements/heading/transpiler';
13
+ import { includeName } from '@erudit-js/bitran-elements/include/shared';
14
+ import { includeTranspiler } from '@erudit-js/bitran-elements/include/transpiler';
15
+ import { linkName } from '@erudit/shared/bitran/link/shared';
16
+ import { linkTranspiler } from '@erudit/shared/bitran/link/transpiler';
17
+
18
+ export async function createBitranTranspiler() {
19
+ const projectTranspilers = await getProjectTranspilers();
20
+
21
+ const defaultTranspilers = {
22
+ [aliasesName]: aliasesTranspiler,
23
+ [includeName]: includeTranspiler,
24
+ [headingName]: headingTranspiler,
25
+ [linkName]: linkTranspiler,
26
+ };
27
+
28
+ const bitranTranspiler = defineBitranTranspiler({
29
+ ...projectTranspilers,
30
+ ...defaultTranspilers,
31
+ });
32
+
33
+ return bitranTranspiler;
34
+ }
35
+
36
+ async function getProjectTranspilers(): Promise<ElementTranspilers> {
37
+ const bitranElements = ERUDIT_SERVER?.BITRAN_CONFIG?.elements;
38
+
39
+ if (!bitranElements) return {};
40
+
41
+ const projectTranspilers: ElementTranspilers = {};
42
+ for (const [name, bitranElement] of Object.entries(bitranElements))
43
+ projectTranspilers[name] = await bitranElement.transpiler();
44
+
45
+ return projectTranspilers;
46
+ }
@@ -1,10 +1,10 @@
1
- import { debug, logger } from '@server/logger';
2
- import { ERUDIT_SERVER } from '@server/global';
3
-
4
- export async function close() {
5
- debug.start('Shutting down server...');
6
-
7
- await ERUDIT_SERVER.DB?.destroy();
8
-
9
- logger.success('Server shut down gracefully!');
10
- }
1
+ import { debug, logger } from '@server/logger';
2
+ import { ERUDIT_SERVER } from '@server/global';
3
+
4
+ export async function close() {
5
+ debug.start('Shutting down server...');
6
+
7
+ await ERUDIT_SERVER.DB?.destroy();
8
+
9
+ logger.success('Server shut down gracefully!');
10
+ }
@@ -1,21 +1,24 @@
1
- import type { BitranCore } from 'bitran/core';
2
- import { assumeGroupItem, type ProductNode } from 'bitran/dom';
1
+ import { ElementNode, walkForward } from '@bitran-js/core';
2
+ import { type BitranTranspiler } from '@bitran-js/transpiler';
3
+ import {
4
+ AliasesNode,
5
+ mergeAliases,
6
+ NO_ALIASES,
7
+ } from '@erudit-js/bitran-elements/aliases/shared';
8
+ import { HeadingNode } from '@erudit-js/bitran-elements/heading/shared';
3
9
 
4
- import { createBitranCore } from '@server/bitran/core';
5
- import { DbUnique } from '@server/db/entities/Unique';
10
+ import { createBitranTranspiler } from '@server/bitran/transpiler';
6
11
  import { ERUDIT_SERVER } from '@server/global';
12
+ import { DbUnique } from '@server/db/entities/Unique';
7
13
 
8
- import { NO_ALIASES } from '@shared/bitran/alias';
9
14
  import type { BitranContext } from '@shared/bitran/context';
10
15
  import {
11
16
  stringifyBitranLocation,
12
17
  type BitranLocation,
13
18
  } from '@shared/bitran/location';
14
- import { AliasNode } from '@shared/bitran/products/alias/core';
15
- import { HeadingNode } from '@shared/bitran/products/heading/core';
16
19
 
17
20
  let context: BitranContext = {} as any;
18
- let bitranCore: BitranCore;
21
+ let bitranTranspiler: BitranTranspiler;
19
22
 
20
23
  const blocksAfterHeading = 2;
21
24
 
@@ -27,39 +30,45 @@ export async function parseBitranContent(
27
30
  context.location = location;
28
31
  context.aliases = NO_ALIASES();
29
32
 
30
- bitranCore ||= await createBitranCore(context);
33
+ bitranTranspiler ||= await createBitranTranspiler();
31
34
 
32
35
  // Tracking heading nodes to deal with them later
33
- let headings: HeadingNode[] = [];
36
+ const headings: HeadingNode[] = [];
34
37
 
35
- await bitranCore.parser.parse(biCode, {
36
- async step(product) {
37
- const meta = product.meta;
38
+ await bitranTranspiler.parser.parse(biCode, {
39
+ async step(node) {
40
+ const meta = node.meta;
38
41
  const uniqueId = meta?.id;
39
42
 
43
+ if (node instanceof AliasesNode) {
44
+ mergeAliases(context.aliases, node.parseData);
45
+ }
46
+
40
47
  if (uniqueId) {
41
- if (product instanceof HeadingNode) {
42
- headings.push(product);
48
+ if (node instanceof HeadingNode) {
49
+ headings.push(node);
43
50
  return;
44
51
  }
45
52
 
46
- await addUnique(product);
53
+ await addUnique(node);
47
54
  }
48
55
  },
49
56
  });
50
57
 
51
58
  for (const heading of headings) {
52
59
  let blocksAfter = 0;
53
- let content = bitranCore.stringifier.stringify(heading);
60
+ let content = await bitranTranspiler.stringifier.stringify(heading);
54
61
 
55
- assumeGroupItem(heading).walkForward((product) => {
62
+ await walkForward(heading, async (node) => {
56
63
  if (blocksAfter >= blocksAfterHeading) return false;
57
64
 
58
- if (product instanceof AliasNode) return;
65
+ if (node instanceof AliasesNode) return;
59
66
  // Spoiler
60
67
  // Todo
61
68
 
62
- content += '\n\n' + bitranCore.stringifier.stringify(product);
69
+ content +=
70
+ '\n\n' + (await bitranTranspiler.stringifier.stringify(node));
71
+
63
72
  blocksAfter++;
64
73
  });
65
74
 
@@ -70,19 +79,20 @@ export async function parseBitranContent(
70
79
  //
71
80
  //
72
81
 
73
- function createUniqueLocation(product: ProductNode) {
82
+ function createUniqueLocation(node: ElementNode) {
74
83
  return stringifyBitranLocation({
75
84
  ...location,
76
- ...{ unique: product.meta.id! },
85
+ ...{ unique: node.meta.id! },
77
86
  });
78
87
  }
79
88
 
80
- async function addUnique(product: ProductNode, content?: string) {
89
+ async function addUnique(node: ElementNode, content?: string) {
81
90
  const dbUnique = new DbUnique();
82
- dbUnique.location = createUniqueLocation(product);
83
- dbUnique.content = content || bitranCore.stringifier.stringify(product);
84
- dbUnique.title = product.parseData?.title || product.meta?.title;
85
- dbUnique.productName = product.name;
91
+ dbUnique.location = createUniqueLocation(node);
92
+ dbUnique.content =
93
+ content || (await bitranTranspiler.stringifier.stringify(node));
94
+ dbUnique.title = node.parseData?.title || node.meta?.title;
95
+ dbUnique.productName = node.name;
86
96
  dbUnique.context = context;
87
97
 
88
98
  await ERUDIT_SERVER.DB.manager.save(dbUnique);
@@ -1,36 +1,36 @@
1
- import { existsSync } from 'node:fs';
2
-
3
- import { ERUDIT_DIR } from '#erudit/globalPaths';
4
- import { stress } from '@erudit/utils/stress';
5
- import { ERUDIT_SERVER } from '@server/global';
6
- import { IMPORT } from '@server/importer';
7
-
8
- export async function setupLanguage() {
9
- const languageCode = ERUDIT_SERVER.CONFIG?.language || 'en';
10
- const languageFilePath = ERUDIT_DIR + `/languages/${languageCode}.ts`;
11
-
12
- if (!existsSync(languageFilePath))
13
- throw new Error(`Language file for ${stress(languageCode)} not found!`);
14
-
15
- try {
16
- const languageModule = await IMPORT(languageFilePath);
17
-
18
- if (!languageModule.default)
19
- throw new Error(
20
- `Language file for ${stress(languageCode)} is missing default export with phrases!`,
21
- );
22
-
23
- const { default: phrases, ...context } = { ...languageModule };
24
-
25
- ERUDIT_SERVER.LANGUAGE = {
26
- phrases,
27
- functions: Object.entries(context)
28
- .filter(([, value]) => typeof value === 'function')
29
- .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
30
- };
31
- } catch (error) {
32
- throw new Error(
33
- `Error while loading language ${stress(languageCode)}!\n\n${error}`,
34
- );
35
- }
36
- }
1
+ import { existsSync } from 'node:fs';
2
+
3
+ import { ERUDIT_DIR } from '#erudit/globalPaths';
4
+ import { stress } from '@erudit/utils/stress';
5
+ import { ERUDIT_SERVER } from '@server/global';
6
+ import { IMPORT } from '@server/importer';
7
+
8
+ export async function setupLanguage() {
9
+ const languageCode = ERUDIT_SERVER.CONFIG?.language || 'en';
10
+ const languageFilePath = ERUDIT_DIR + `/languages/${languageCode}.ts`;
11
+
12
+ if (!existsSync(languageFilePath))
13
+ throw new Error(`Language file for ${stress(languageCode)} not found!`);
14
+
15
+ try {
16
+ const languageModule = await IMPORT(languageFilePath);
17
+
18
+ if (!languageModule.default)
19
+ throw new Error(
20
+ `Language file for ${stress(languageCode)} is missing default export with phrases!`,
21
+ );
22
+
23
+ const { default: phrases, ...context } = { ...languageModule };
24
+
25
+ ERUDIT_SERVER.LANGUAGE = {
26
+ phrases,
27
+ functions: Object.entries(context)
28
+ .filter(([, value]) => typeof value === 'function')
29
+ .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
30
+ };
31
+ } catch (error) {
32
+ throw new Error(
33
+ `Error while loading language ${stress(languageCode)}!\n\n${error}`,
34
+ );
35
+ }
36
+ }
@@ -1,25 +1,25 @@
1
- import { debug, logger } from '@server/logger';
2
-
3
- import { setup } from './setup';
4
- import { setupLanguage } from './jobs/language';
5
- import { buildContributors } from './jobs/contributors';
6
- import { buildNav } from './jobs/nav';
7
- import { buildContent } from './jobs/content/generic';
8
-
9
- let initial = true;
10
-
11
- export async function build() {
12
- debug.start('Building data...');
13
-
14
- if (initial) {
15
- await setup();
16
- initial = false;
17
- }
18
-
19
- await setupLanguage();
20
- await buildContributors();
21
- await buildNav();
22
- await buildContent();
23
-
24
- logger.success('Build successful!');
25
- }
1
+ import { debug, logger } from '@server/logger';
2
+
3
+ import { setup } from './setup';
4
+ import { setupLanguage } from './jobs/language';
5
+ import { buildContributors } from './jobs/contributors';
6
+ import { buildNav } from './jobs/nav';
7
+ import { buildContent } from './jobs/content/generic';
8
+
9
+ let initial = true;
10
+
11
+ export async function build() {
12
+ debug.start('Building data...');
13
+
14
+ if (initial) {
15
+ await setup();
16
+ initial = false;
17
+ }
18
+
19
+ await setupLanguage();
20
+ await buildContributors();
21
+ await buildNav();
22
+ await buildContent();
23
+
24
+ logger.success('Build successful!');
25
+ }