@brillout/docpress 0.5.40 → 0.6.1

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 (146) hide show
  1. package/+config.ts +17 -0
  2. package/MobileHeader.tsx +68 -0
  3. package/PageLayout.css +42 -0
  4. package/PageLayout.tsx +39 -0
  5. package/algolia/DocSearch.css +34 -0
  6. package/algolia/DocSearch.ts +62 -0
  7. package/autoScrollNav.ts +36 -0
  8. package/components/CodeBlockTransformer.css +9 -0
  9. package/components/CodeBlockTransformer.tsx +18 -0
  10. package/components/Comment.tsx +7 -0
  11. package/components/Consulting.tsx +47 -0
  12. package/components/Contributors.tsx +113 -0
  13. package/components/EditPageNote.tsx +18 -0
  14. package/components/FeatureList/FeatureList.client.ts +66 -0
  15. package/{dist/components/features → components/FeatureList}/FeatureList.css +10 -2
  16. package/components/FeatureList/FeatureList.tsx +114 -0
  17. package/components/HorizontalLine.tsx +20 -0
  18. package/components/ImportMeta.tsx +11 -0
  19. package/components/Link.tsx +144 -0
  20. package/components/Note.css +54 -0
  21. package/components/Note.tsx +78 -0
  22. package/components/P.css +8 -0
  23. package/components/P.tsx +8 -0
  24. package/components/ReadingRecommendation.tsx +56 -0
  25. package/components/RepoLink.tsx +24 -0
  26. package/components/Sponsors/label.draft.svg +108 -0
  27. package/components/Sponsors.tsx +218 -0
  28. package/components/Supporters.tsx +136 -0
  29. package/components/index.ts +14 -0
  30. package/config/getConfig.ts +18 -0
  31. package/config/resolveConfig/resolveHeading.ts +0 -0
  32. package/config/resolvePageContext.ts +186 -0
  33. package/css/button.css +7 -0
  34. package/css/code/block.css +36 -0
  35. package/css/code/inline.css +27 -0
  36. package/css/code.css +20 -0
  37. package/css/colorize-on-hover.css +29 -0
  38. package/css/font.css +25 -0
  39. package/css/heading.css +45 -0
  40. package/css/index.css +12 -0
  41. package/css/link.css +17 -0
  42. package/css/reset.css +12 -0
  43. package/css/table.css +14 -0
  44. package/css/tooltip.css +11 -0
  45. package/data/maintainersList.tsx +92 -0
  46. package/data/sponsorsList.ts +147 -0
  47. package/dist/+config.d.ts +19 -0
  48. package/dist/+config.js +15 -0
  49. package/dist/markdownHeadingsVitePlugin.d.ts +13 -0
  50. package/dist/markdownHeadingsVitePlugin.js +170 -0
  51. package/dist/utils/assert.d.ts +6 -0
  52. package/dist/utils/assert.js +48 -0
  53. package/dist/utils/determineSectionUrlHash.d.ts +4 -0
  54. package/dist/utils/determineSectionUrlHash.js +38 -0
  55. package/dist/vite.config.d.ts +3 -0
  56. package/dist/vite.config.js +32 -0
  57. package/index.ts +4 -0
  58. package/installSectionUrlHashs.ts +60 -0
  59. package/markdownHeadingsVitePlugin.ts +150 -0
  60. package/navigation/Navigation-highlight.css +41 -0
  61. package/navigation/Navigation-items.css +119 -0
  62. package/navigation/Navigation-layout.css +127 -0
  63. package/navigation/Navigation.client.ts +43 -0
  64. package/navigation/Navigation.css +3 -0
  65. package/navigation/Navigation.tsx +211 -0
  66. package/navigation/NavigationHeader.tsx +111 -0
  67. package/navigation/navigation-fullscreen/NavigationFullscreenButton.css +32 -0
  68. package/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +44 -0
  69. package/navigation/navigation-fullscreen/initNavigationFullscreen.ts +116 -0
  70. package/package.json +38 -53
  71. package/parseEmojis.ts +35 -0
  72. package/parseTitle.ts +139 -0
  73. package/renderer/client.ts +4 -0
  74. package/renderer/onRenderHtml.tsx +69 -0
  75. package/renderer/usePageContext.tsx +25 -0
  76. package/tsconfig.config.json +7 -0
  77. package/tsconfig.json +15 -0
  78. package/types/Config.ts +46 -0
  79. package/types/Heading.ts +49 -0
  80. package/utils/Emoji/Emoji.ts +224 -0
  81. package/utils/Emoji/assets.ts +9 -0
  82. package/utils/Emoji/index.ts +1 -0
  83. package/utils/Emoji/mountain.svg +1 -0
  84. package/utils/assert.ts +51 -0
  85. package/utils/client.ts +2 -0
  86. package/utils/determineSectionUrlHash.ts +44 -0
  87. package/utils/filesystemPathHandling.ts +42 -0
  88. package/utils/filter.ts +12 -0
  89. package/utils/isBrowser.ts +5 -0
  90. package/utils/jsxToTextContent.ts +11 -0
  91. package/utils/objectAssign.ts +9 -0
  92. package/utils/server.ts +7 -0
  93. package/vite.config.ts +36 -0
  94. package/bin.js +0 -3
  95. package/dist/chunk-2ZTPUQGS.js +0 -58
  96. package/dist/chunk-3QC7HYIF.js +0 -7
  97. package/dist/chunk-MGOI4AFO.js +0 -165
  98. package/dist/chunk-NVJING6T.js +0 -91
  99. package/dist/chunk-QWL3MA4E.js +0 -171
  100. package/dist/chunk-UN23G34B.js +0 -157
  101. package/dist/cli/index.d.ts +0 -1
  102. package/dist/cli/index.js +0 -34
  103. package/dist/components/features/FeatureList.d.ts +0 -13
  104. package/dist/components/features/FeatureList.js +0 -7
  105. package/dist/components/features/initFeatureList.d.ts +0 -3
  106. package/dist/components/features/initFeatureList.js +0 -59
  107. package/dist/devServer-JKH6U5PF.js +0 -36
  108. package/dist/index.css +0 -120
  109. package/dist/index.d.ts +0 -221
  110. package/dist/index.js +0 -947
  111. package/dist/renderer/_default.page.client.css +0 -318
  112. package/dist/renderer/_default.page.client.d.ts +0 -1
  113. package/dist/renderer/_default.page.client.js +0 -218
  114. package/dist/renderer/_default.page.server.css +0 -310
  115. package/dist/renderer/_default.page.server.d.ts +0 -22
  116. package/dist/renderer/_default.page.server.js +0 -665
  117. package/readme.md +0 -5
  118. /package/{dist/chevron-R2IYJD62.svg → components/FeatureList/chevron.svg} +0 -0
  119. /package/{dist/label-MP75CTIA.svg → components/Sponsors/label.svg} +0 -0
  120. /package/{dist/medalBronze-CO4CTUR4.svg → components/Sponsors/medalBronze.svg} +0 -0
  121. /package/{dist/medalGold-UP6A73FL.svg → components/Sponsors/medalGold.svg} +0 -0
  122. /package/{dist/medalSilver-FAPGGOBN.svg → components/Sponsors/medalSilver.svg} +0 -0
  123. /package/{dist/Inter-Var-IOAEQULN.ttf → css/Inter-Var.ttf} +0 -0
  124. /package/{dist/alignable-B4QZV4X7.svg → data/sponsorsList/companyLogos/alignable.svg} +0 -0
  125. /package/{dist/bluefin-JQABZFGV.svg → data/sponsorsList/companyLogos/bluefin.svg} +0 -0
  126. /package/{dist/burdaforward-EUGURYZY.png → data/sponsorsList/companyLogos/burdaforward.png} +0 -0
  127. /package/{dist/contra-WLZBOPBV.svg → data/sponsorsList/companyLogos/contra.svg} +0 -0
  128. /package/{dist/ecosia-OYRLTR5T.svg → data/sponsorsList/companyLogos/ecosia.svg} +0 -0
  129. /package/{dist/inlang-GFRWND6X.png → data/sponsorsList/companyLogos/inlang.png} +0 -0
  130. /package/{dist/optimizers-SFEZF3NW.svg → data/sponsorsList/companyLogos/optimizers.svg} +0 -0
  131. /package/{dist/sourcegraph-YR2HADLS.svg → data/sponsorsList/companyLogos/sourcegraph.svg} +0 -0
  132. /package/{dist/changelog-IPI5F42D.svg → icons/changelog.svg} +0 -0
  133. /package/{dist/discord-JD33TUSF.svg → icons/discord.svg} +0 -0
  134. /package/{dist/github-P5ZSKN2N.svg → icons/github.svg} +0 -0
  135. /package/{dist/heart-OINVKOXO.svg → icons/heart.svg} +0 -0
  136. /package/{dist/languages-KXPKJFQL.svg → icons/languages.svg} +0 -0
  137. /package/{dist/people-72KKQHU4.svg → icons/people.svg} +0 -0
  138. /package/{dist/twitter-I7DXDN3J.svg → icons/twitter.svg} +0 -0
  139. /package/{dist/chevron-K3WPYLOP.svg → navigation/navigation-fullscreen/chevron.svg} +0 -0
  140. /package/{dist/close-IQXTDOHV.svg → navigation/navigation-fullscreen/close.svg} +0 -0
  141. /package/{dist/compass-2RWQU3E4.svg → utils/Emoji/compass.svg} +0 -0
  142. /package/{dist/engine-6Q6VSCVA.png → utils/Emoji/engine.png} +0 -0
  143. /package/{dist/mechanical-arm-TR7IQQMG.svg → utils/Emoji/mechanical-arm.svg} +0 -0
  144. /package/{dist/road-fork-3WZLW3HB.svg → utils/Emoji/road-fork.svg} +0 -0
  145. /package/{dist/shield-CU45RG5C.svg → utils/Emoji/shield.svg} +0 -0
  146. /package/{dist/typescript-ALIPKLRM.svg → utils/Emoji/typescript.svg} +0 -0
package/css/font.css ADDED
@@ -0,0 +1,25 @@
1
+ body {
2
+ font-family: 'Inter';
3
+ }
4
+ button {
5
+ font-family: inherit;
6
+ }
7
+ body {
8
+ --color-text: #323d48;
9
+ color: var(--color-text);
10
+ line-height: 1.5;
11
+ }
12
+
13
+ @font-face {
14
+ font-family: 'Inter';
15
+ font-weight: 100 900;
16
+ font-stretch: 75% 125%;
17
+ font-style: oblique 0deg 12deg;
18
+ src: url('./Inter-Var.ttf') format('truetype-variations');
19
+ }
20
+
21
+ em,
22
+ i {
23
+ font-variation-settings: 'slnt' -10;
24
+ font-style: normal;
25
+ }
@@ -0,0 +1,45 @@
1
+ .doc-page h2,
2
+ .doc-page h3 {
3
+ margin-bottom: 16px;
4
+ }
5
+ .doc-page h2 {
6
+ margin-top: 50px;
7
+ }
8
+ .doc-page h3 {
9
+ margin-top: 40px;
10
+ }
11
+
12
+ .doc-page h1 + h2,
13
+ .doc-page h1 + h3,
14
+ .doc-page h2 + h3 {
15
+ margin-top: 0;
16
+ }
17
+
18
+ .doc-page h4 {
19
+ margin-top: 32px;
20
+ margin-bottom: 16px;
21
+ }
22
+
23
+ .doc-page h5 {
24
+ font-size: 0.94em;
25
+ color: #777;
26
+ margin-bottom: 10px;
27
+ }
28
+
29
+ /***************/
30
+ /** Clickable **/
31
+ /***************/
32
+ .doc-page h2[id],
33
+ .doc-page h3[id] {
34
+ cursor: pointer;
35
+ position: relative;
36
+ padding-left: 26px;
37
+ margin-left: -26px;
38
+ }
39
+ .doc-page h2[id]:hover::before,
40
+ .doc-page h3[id]:hover::before {
41
+ content: '#';
42
+ position: absolute;
43
+ left: calc(-1 * (0.75em - 26px));
44
+ color: #aaa;
45
+ }
package/css/index.css ADDED
@@ -0,0 +1,12 @@
1
+ @import './reset.css';
2
+ @import './colorize-on-hover.css';
3
+ @import './heading.css';
4
+ @import './button.css';
5
+ @import './link.css';
6
+ @import './font.css';
7
+ @import './code.css';
8
+ @import './table.css';
9
+ @import './tooltip.css';
10
+ @import '../algolia/DocSearch.css';
11
+ @import '../components/Note.css';
12
+ @import '../components/CodeBlockTransformer.css';
package/css/link.css ADDED
@@ -0,0 +1,17 @@
1
+ /*
2
+ :root {
3
+ --link-color: #4747ff;
4
+ }
5
+ */
6
+
7
+ a {
8
+ /*
9
+ color: inherit;
10
+ color: var(--link-color);
11
+ */
12
+ color: #4747ff;
13
+ text-decoration: none;
14
+ }
15
+ a > button {
16
+ color: var(--color-text);
17
+ }
package/css/reset.css ADDED
@@ -0,0 +1,12 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ }
4
+ body {
5
+ margin: 0;
6
+ }
7
+
8
+ /* Avoid tweet embeds to overflow the body width.
9
+ * Settings `overflow: hidden` to a container doesn't work (This is a CSS bug?) */
10
+ iframe {
11
+ max-width: 100%;
12
+ }
package/css/table.css ADDED
@@ -0,0 +1,14 @@
1
+ table th {
2
+ background-color: #f7f7f7;
3
+ }
4
+ table {
5
+ border-collapse: collapse;
6
+ }
7
+ table td,
8
+ table th {
9
+ padding: 8px;
10
+ border: 1px solid #ccc;
11
+ }
12
+ table th {
13
+ text-align: left;
14
+ }
@@ -0,0 +1,11 @@
1
+ @import 'balloon-css';
2
+
3
+ :root {
4
+ --balloon-color: #444;
5
+ --balloon-move: 2px;
6
+ --balloon-font-size: 14px;
7
+ --balloon-border-radius: 5px;
8
+ }
9
+ [aria-label][data-balloon-pos]:after {
10
+ font-family: 'Inter';
11
+ }
@@ -0,0 +1,92 @@
1
+ export { maintainers }
2
+
3
+ import React from 'react'
4
+
5
+ type Maintainer = {
6
+ username: string
7
+ firstName: string
8
+ roles: React.ReactNode[]
9
+ consultingUrl?: string
10
+ }
11
+
12
+ const maintainers: Maintainer[] = [
13
+ {
14
+ username: 'brillout',
15
+ firstName: 'Rom',
16
+ roles: [
17
+ <>Vike Core (Lead Maintainer, Creator)</>,
18
+ <>
19
+ <code>vike-react</code> (Lead Maintainer, Creator)
20
+ </>,
21
+ <>
22
+ <code>vike-vue</code> (Contributor)
23
+ </>
24
+ ]
25
+ },
26
+ {
27
+ username: 'magne4000',
28
+ firstName: 'Joël',
29
+ roles: [
30
+ <>Bati (Lead Maintainer, Creator)</>,
31
+ <>
32
+ <code>vike-solid</code> (Lead Maintainer, Creator)
33
+ </>,
34
+ <>Vike Core (Contributor)</>
35
+ ]
36
+ },
37
+ {
38
+ username: 'AurelienLourot',
39
+ firstName: 'Aurélien',
40
+ roles: [
41
+ <>
42
+ <code>vike-vue</code> (Lead Maintainer, Creator)
43
+ </>,
44
+ <>
45
+ <code>vike-react</code> (Contributor)
46
+ </>,
47
+ <>Vike Core (Contributor)</>
48
+ ]
49
+ // consultingUrl: 'https://lourot.dev/'
50
+ },
51
+ {
52
+ username: 'nitedani',
53
+ firstName: 'Dániel',
54
+ roles: [
55
+ <>
56
+ <code>vike-react-query</code> (Lead Maintainer, Creator)
57
+ </>,
58
+ <>
59
+ <code>vike-angular</code> (Lead Maintainer, Creator)
60
+ </>,
61
+ <>Vike Core (Contributor)</>
62
+ ]
63
+ },
64
+ {
65
+ username: 'phonzammi',
66
+ firstName: 'Muhammad',
67
+ roles: [
68
+ <>
69
+ <code>vike-vue</code> (Contributor)
70
+ </>,
71
+ <>
72
+ <code>vike-solid</code> (Contributor)
73
+ </>,
74
+ <>
75
+ <code>vike-react</code> (Contributor)
76
+ </>
77
+ ]
78
+ },
79
+ {
80
+ username: '4350pChris',
81
+ firstName: 'Chris',
82
+ roles: [
83
+ <>
84
+ <code>vike-pinia</code> (Lead Maintainer, Creator)
85
+ </>,
86
+ <>
87
+ <code>vike-vue</code> (Contributor)
88
+ </>,
89
+ <>Vike Core (Contributor)</>
90
+ ]
91
+ }
92
+ ]
@@ -0,0 +1,147 @@
1
+ export { sponsorsList }
2
+
3
+ import type { Sponsor } from '../components/Sponsors'
4
+ import contraLogo from './sponsorsList/companyLogos/contra.svg'
5
+ import optimizersLogo from './sponsorsList/companyLogos/optimizers.svg'
6
+ import sourcegraphLogo from './sponsorsList/companyLogos/sourcegraph.svg'
7
+ import burdaforwardLogo from './sponsorsList/companyLogos/burdaforward.png'
8
+ import ecosiaLogo from './sponsorsList/companyLogos/ecosia.svg'
9
+ import inlangLogo from './sponsorsList/companyLogos/inlang.png'
10
+ import bluefinLogo from './sponsorsList/companyLogos/bluefin.svg'
11
+ import alignableLogo from './sponsorsList/companyLogos/alignable.svg'
12
+
13
+ const individuals: Sponsor[] = [
14
+ { username: 'arp' },
15
+ { username: 'tlancina' },
16
+ { username: 'shishkin17' },
17
+ { username: 'royalswe' },
18
+ { username: 'lebretont' },
19
+ { username: 'xar' },
20
+ { username: 'NicoZweifel' },
21
+ { username: 'mariuslian' },
22
+ { username: 'shortpoet' },
23
+ { username: 'sqs' },
24
+ { username: 'dylmye' },
25
+ { username: 'isakura313' },
26
+ { username: 'rivatove' },
27
+ { username: 'SMKJALLAD' },
28
+ { username: 'routinghub' },
29
+ { username: 'LostCrew' }, // Ecosia
30
+ { username: 'jakubfiala' }, // Ecosia
31
+ { username: 'HarshwardhanSingh' },
32
+ { username: 'd3x7r0' },
33
+ { username: 'ChristophP' }, // BurdaForward
34
+ { username: 'msiegenthaler' },
35
+ { username: 'linkyard' },
36
+ { username: 'AnukarOP' },
37
+ { username: 'RoyMcCrain' },
38
+ { username: 'chrisvander' }, // Bluefin
39
+ { username: 'EralChen' },
40
+ { username: '3dyuval' },
41
+ { username: 'talzion12' },
42
+ { username: 'felixhaeberle' },
43
+ { username: 'apappas1129' },
44
+ /* 404
45
+ { username: 'agalbenus' },
46
+ */
47
+ { username: 'phiberber' },
48
+ { username: 'cookieplace' },
49
+ { username: 'JiangWeixian' },
50
+ { username: 'harrytran998' },
51
+ { username: 'alexturpin' },
52
+ { username: 'gu-stav' },
53
+ { username: 'YannBirba' },
54
+ { username: 'fi3ework' },
55
+ { username: 'EJM-Company' },
56
+ { username: 'Nelie-Taylor' },
57
+ { username: 'fortezhuo' },
58
+ { username: 'nshelia' },
59
+ { username: 'marcusway' },
60
+ { username: 'edikdeisling' },
61
+ { username: 'AurelienLourot' },
62
+ { username: 'jahredhope' },
63
+ { username: 'charlieforward9' },
64
+ { username: 'leonmondria' },
65
+ { username: 'jscottsf' },
66
+ { username: 'micah-redwood' },
67
+ { username: 'nicka-redwood' },
68
+ { username: 'ser1us' },
69
+ { username: 'nikitavoloboev' },
70
+ { username: 'samuelstroschein' },
71
+ { username: 'npacucci' },
72
+ { username: 'szarapka' },
73
+ { username: 'techniath' },
74
+ { username: 'DannyZB' },
75
+ { username: 'pieperz' },
76
+ { username: 'hemengke1997' },
77
+ { username: 'spacedawwwg' },
78
+ { username: 'arthurgailes' },
79
+ { username: 'stackblitz' },
80
+ { username: 'codthing' },
81
+ { username: 'Junaidhkn' },
82
+ { username: 'zgfdev' }
83
+ ]
84
+
85
+ const companies: Sponsor[] = [
86
+ {
87
+ companyName: 'Contra',
88
+ companyLogo: contraLogo,
89
+ plan: 'silver',
90
+ website: 'https://contra.com',
91
+ github: 'contra'
92
+ },
93
+ {
94
+ companyName: 'Inlang',
95
+ companyLogo: inlangLogo,
96
+ plan: 'silver',
97
+ website: 'https://inlang.com/',
98
+ github: 'opral'
99
+ },
100
+ {
101
+ companyName: 'Alignable',
102
+ companyLogo: alignableLogo,
103
+ plan: 'silver',
104
+ website: 'https://www.alignable.com/',
105
+ github: 'AlignableUser'
106
+ },
107
+ {
108
+ companyName: 'Sourcegraph',
109
+ companyLogo: sourcegraphLogo,
110
+ plan: 'bronze',
111
+ website: 'https://sourcegraph.com',
112
+ github: 'sourcegraph'
113
+ },
114
+ {
115
+ companyName: 'Optimizers',
116
+ companyLogo: optimizersLogo,
117
+ plan: 'bronze',
118
+ website: 'https://www.optimizers.nl/',
119
+ divSize: {
120
+ padding: 20
121
+ },
122
+ github: 'OptimizersGroup'
123
+ },
124
+ {
125
+ companyName: 'BurdaFoward',
126
+ companyLogo: burdaforwardLogo,
127
+ plan: 'bronze',
128
+ website: 'https://www.burda-forward.de',
129
+ github: 'BurdaForward'
130
+ },
131
+ {
132
+ companyName: 'Ecosia',
133
+ companyLogo: ecosiaLogo,
134
+ plan: 'bronze',
135
+ website: 'https://ecosia.org',
136
+ github: 'ecosia'
137
+ },
138
+ {
139
+ companyName: 'Bluefin',
140
+ companyLogo: bluefinLogo,
141
+ plan: 'indie',
142
+ website: 'https://www.bluefin.one',
143
+ github: 'bluefin-clinical'
144
+ }
145
+ ]
146
+
147
+ const sponsorsList: Sponsor[] = [...companies, ...individuals]
@@ -0,0 +1,19 @@
1
+ declare const _default: {
2
+ name: string;
3
+ onRenderHtml: "import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml";
4
+ client: string;
5
+ meta: {
6
+ Page: {
7
+ env: {
8
+ client: false;
9
+ server: true;
10
+ };
11
+ };
12
+ name: {
13
+ env: {
14
+ config: true;
15
+ };
16
+ };
17
+ };
18
+ };
19
+ export default _default;
@@ -0,0 +1,15 @@
1
+ export default {
2
+ // @ts-expect-error remove this @ts-expect-error once Vike's new version is released
3
+ name: '@brillout/docpress',
4
+ onRenderHtml: 'import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml',
5
+ client: 'import:@brillout/docpress/renderer/client:doesNotExist',
6
+ meta: {
7
+ Page: {
8
+ env: { client: false, server: true }
9
+ },
10
+ // Vike already defines the setting 'name', but we redundantly define it here for older Vike versions (otherwise older Vike versions will complain that 'name` is an unknown config).
11
+ name: {
12
+ env: { config: true }
13
+ }
14
+ }
15
+ };
@@ -0,0 +1,13 @@
1
+ export { markdownHeadingsVitePlugin };
2
+ export type { MarkdownHeading };
3
+ type MarkdownHeading = {
4
+ title: string;
5
+ headingId: string | null;
6
+ headingLevel: number;
7
+ titleAddendum?: string;
8
+ };
9
+ declare function markdownHeadingsVitePlugin(): {
10
+ name: string;
11
+ enforce: string;
12
+ transform: (code: string, id: string) => Promise<string | undefined>;
13
+ };
@@ -0,0 +1,170 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ export { markdownHeadingsVitePlugin };
38
+ import { assert } from './utils/assert.js';
39
+ import { determineSectionUrlHash } from './utils/determineSectionUrlHash.js';
40
+ import os from 'os';
41
+ function markdownHeadingsVitePlugin() {
42
+ var _this = this;
43
+ return {
44
+ name: 'mdx-headings',
45
+ enforce: 'pre',
46
+ transform: function (code, id) { return __awaiter(_this, void 0, void 0, function () {
47
+ var codeNew;
48
+ return __generator(this, function (_a) {
49
+ if (!id.endsWith('+Page.mdx')) {
50
+ return [2 /*return*/];
51
+ }
52
+ codeNew = transform(code);
53
+ return [2 /*return*/, codeNew];
54
+ });
55
+ }); }
56
+ };
57
+ }
58
+ function transform(code) {
59
+ var headings = [];
60
+ var isCodeBlock = false;
61
+ var codeNew = code
62
+ .split('\n')
63
+ .map(function (line) {
64
+ // Skip code blocks, e.g.
65
+ // ~~~md
66
+ // # Markdown Example
67
+ // Bla
68
+ // ~~~
69
+ if (line.startsWith('~~~') || line.startsWith('```')) {
70
+ isCodeBlock = !isCodeBlock;
71
+ return line;
72
+ }
73
+ if (isCodeBlock) {
74
+ return line;
75
+ }
76
+ if (line.startsWith('#')) {
77
+ var _a = parseMarkdownHeading(line), headingId = _a.headingId, headingLevel = _a.headingLevel, title = _a.title, headingHtml = _a.headingHtml;
78
+ headings.push({ headingId: headingId, headingLevel: headingLevel, title: title });
79
+ return headingHtml;
80
+ }
81
+ return line;
82
+ })
83
+ .join('\n');
84
+ var headingsExportCode = "export const headings = [".concat(headings
85
+ .map(function (heading) { return JSON.stringify(heading); })
86
+ .join(', '), "];");
87
+ codeNew += "\n\n".concat(headingsExportCode, "\n");
88
+ return codeNew;
89
+ }
90
+ function parseMarkdownHeading(line) {
91
+ var _a;
92
+ var _b = line.split(' '), lineBegin = _b[0], lineWords = _b.slice(1);
93
+ assert(lineBegin.split('#').join('') === '', { line: line, lineWords: lineWords });
94
+ var headingLevel = lineBegin.length;
95
+ var titleMdx = lineWords.join(' ');
96
+ assert(!titleMdx.startsWith(' '), { line: line, lineWords: lineWords });
97
+ assert(titleMdx, { line: line, lineWords: lineWords });
98
+ var headingMdx = {
99
+ title: titleMdx,
100
+ anchor: titleMdx
101
+ };
102
+ {
103
+ // Support custom anchor like: `## title{#custom-anchor}`
104
+ var customAnchor = (_a = /(?<={#).*(?=})/g.exec(titleMdx)) === null || _a === void 0 ? void 0 : _a[0];
105
+ if (customAnchor) {
106
+ headingMdx.anchor = customAnchor;
107
+ headingMdx.title = titleMdx.replace(/{#.*}/g, '');
108
+ }
109
+ }
110
+ var headingId = determineSectionUrlHash(headingMdx.anchor);
111
+ var title = headingMdx.title;
112
+ var titleParsed = parseTitle(title);
113
+ assert(headingId === null || headingId.length > 0);
114
+ var headingAttrId = headingId === null ? '' : " id=\"".concat(headingId, "\"");
115
+ var headingHtml = "<h".concat(headingLevel).concat(headingAttrId, ">").concat(titleParsed, "</h").concat(headingLevel, ">");
116
+ var heading = { headingLevel: headingLevel, title: title, headingId: headingId, headingHtml: headingHtml };
117
+ return heading;
118
+ }
119
+ function parseTitle(titleMarkdown) {
120
+ var parts = [];
121
+ var current;
122
+ titleMarkdown.split('').forEach(function (letter) {
123
+ if (letter === '`') {
124
+ if ((current === null || current === void 0 ? void 0 : current.nodeType) === 'code') {
125
+ // </code>
126
+ parts.push(current);
127
+ current = undefined;
128
+ }
129
+ else {
130
+ // <code>
131
+ if (current) {
132
+ parts.push(current);
133
+ }
134
+ current = { nodeType: 'code', content: '' };
135
+ }
136
+ }
137
+ else {
138
+ if (!current) {
139
+ current = { nodeType: 'text', content: '' };
140
+ }
141
+ current.content += letter;
142
+ }
143
+ });
144
+ if (current) {
145
+ parts.push(current);
146
+ }
147
+ var titleHtml = parts
148
+ .map(function (part) {
149
+ if (part.nodeType === 'code') {
150
+ return "<code>".concat(serializeText(part.content), "</code>");
151
+ }
152
+ else {
153
+ assert(part.nodeType === 'text', { parts: parts });
154
+ return serializeText(part.content);
155
+ }
156
+ })
157
+ .join('');
158
+ return titleHtml;
159
+ function serializeText(text) {
160
+ var textEscaped = text.split("'").join("\\'");
161
+ // https://github.com/brillout/docpress/pull/2
162
+ if (isWindows()) {
163
+ textEscaped = textEscaped.replace(/\r/, '');
164
+ }
165
+ return "{'".concat(textEscaped, "'}");
166
+ }
167
+ }
168
+ function isWindows() {
169
+ return os.platform() === 'win32';
170
+ }
@@ -0,0 +1,6 @@
1
+ export { assert };
2
+ export { assertUsage };
3
+ export { assertWarning };
4
+ declare function assert(condition: unknown, debugInfo?: unknown): asserts condition;
5
+ declare function assertUsage(condition: unknown, msg: string): asserts condition;
6
+ declare function assertWarning(condition: unknown, msg: string): asserts condition;
@@ -0,0 +1,48 @@
1
+ export { assert };
2
+ export { assertUsage };
3
+ export { assertWarning };
4
+ function assert(condition, debugInfo) {
5
+ if (condition) {
6
+ return;
7
+ }
8
+ var hasDebugInfo = debugInfo !== undefined;
9
+ if (hasDebugInfo) {
10
+ console.log(debugInfo);
11
+ if (typeof debugInfo === 'object') {
12
+ debugInfo = JSON.stringify(debugInfo);
13
+ }
14
+ }
15
+ var errMsg = '[DocPress] Bug. Contact DocPress maintainer.';
16
+ if (hasDebugInfo) {
17
+ errMsg += ' Debug info: ' + String(debugInfo);
18
+ }
19
+ var err = new Error(errMsg);
20
+ if (isBrowserAndDev()) {
21
+ alert(err.stack);
22
+ }
23
+ throw err;
24
+ }
25
+ function assertUsage(condition, msg) {
26
+ if (condition) {
27
+ return;
28
+ }
29
+ var err = new Error('[DocPress][Wrong Usage] ' + msg);
30
+ if (isBrowserAndDev()) {
31
+ alert(err.stack);
32
+ }
33
+ throw err;
34
+ }
35
+ function isBrowserAndDev() {
36
+ var _a;
37
+ return typeof window !== 'undefined' && ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.port) !== '';
38
+ }
39
+ function assertWarning(condition, msg) {
40
+ if (condition) {
41
+ return;
42
+ }
43
+ msg = '[DocPress][Warning] ' + msg;
44
+ console.warn(msg);
45
+ if (isBrowserAndDev()) {
46
+ alert(msg);
47
+ }
48
+ }
@@ -0,0 +1,4 @@
1
+ export { determineSectionUrlHash };
2
+ export { determineSectionTitle };
3
+ declare function determineSectionUrlHash(title: string): string | null;
4
+ declare function determineSectionTitle(urlWithHash: string): string;