@brillout/docpress 0.16.11 → 0.16.13

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 (89) hide show
  1. package/+config.ts +2 -2
  2. package/EditLink.tsx +3 -3
  3. package/ExternalLinks.tsx +1 -1
  4. package/Layout.tsx +15 -14
  5. package/MenuModal/Collapsible.tsx +1 -1
  6. package/MenuModal/NavigationWithColumnLayout.tsx +11 -11
  7. package/MenuModal/toggleMenuModal.ts +4 -4
  8. package/MenuModal.tsx +12 -8
  9. package/NavItemComponent.tsx +4 -3
  10. package/code-blocks/components/ChoiceGroup.css +9 -12
  11. package/code-blocks/components/ChoiceGroup.tsx +18 -19
  12. package/code-blocks/components/Pre.tsx +1 -1
  13. package/code-blocks/hooks/useSelectedChoice.ts +1 -1
  14. package/code-blocks/remarkChoiceGroup.ts +3 -5
  15. package/code-blocks/remarkDetype.ts +2 -3
  16. package/code-blocks/remarkPkgManager.ts +3 -1
  17. package/code-blocks/shikiTransformerAutoLinks.ts +2 -2
  18. package/code-blocks/utils/generateChoiceGroupCode.ts +40 -21
  19. package/components/Algolia/Hit.tsx +3 -3
  20. package/components/CodeBlockTransformer.tsx +1 -1
  21. package/components/Comment.tsx +1 -1
  22. package/components/HorizontalLine.tsx +1 -1
  23. package/components/ImportMeta.tsx +1 -1
  24. package/components/Link.tsx +5 -5
  25. package/components/Note.tsx +1 -1
  26. package/components/RepoLink.tsx +1 -1
  27. package/components/index.ts +10 -10
  28. package/css/index.css +1 -1
  29. package/determineNavItemsColumnLayout.spec.ts +2 -2
  30. package/determineNavItemsColumnLayout.ts +6 -6
  31. package/dist/+config.d.ts +2 -2
  32. package/dist/NavItemComponent.js +2 -2
  33. package/dist/code-blocks/rehypeMetaToProps.js +1 -1
  34. package/dist/code-blocks/remarkChoiceGroup.js +4 -6
  35. package/dist/code-blocks/remarkDetype.js +3 -3
  36. package/dist/code-blocks/remarkPkgManager.js +4 -2
  37. package/dist/code-blocks/utils/generateChoiceGroupCode.d.ts +2 -2
  38. package/dist/code-blocks/utils/generateChoiceGroupCode.js +35 -18
  39. package/dist/components/CodeBlockTransformer.js +1 -1
  40. package/dist/components/Comment.d.ts +1 -3
  41. package/dist/components/Comment.js +1 -1
  42. package/dist/components/HorizontalLine.js +1 -1
  43. package/dist/components/ImportMeta.js +1 -1
  44. package/dist/components/Link.d.ts +1 -1
  45. package/dist/components/Link.js +3 -3
  46. package/dist/components/Note.js +2 -2
  47. package/dist/components/RepoLink.js +1 -1
  48. package/dist/components/index.d.ts +10 -10
  49. package/dist/components/index.js +10 -10
  50. package/dist/determineNavItemsColumnLayout.d.ts +1 -1
  51. package/dist/determineNavItemsColumnLayout.js +3 -2
  52. package/dist/renderer/usePageContext.d.ts +3 -3
  53. package/dist/renderer/usePageContext.js +1 -1
  54. package/dist/resolvePageContext.d.ts +2 -2
  55. package/dist/resolvePageContext.js +5 -5
  56. package/dist/types/Config.d.ts +1 -1
  57. package/dist/utils/Emoji/Emoji.js +2 -2
  58. package/dist/utils/Emoji/index.d.ts +1 -1
  59. package/dist/utils/Emoji/index.js +1 -1
  60. package/dist/utils/client.d.ts +3 -3
  61. package/dist/utils/client.js +3 -3
  62. package/dist/utils/jsxToTextContent.js +1 -1
  63. package/dist/utils/server.d.ts +7 -7
  64. package/dist/utils/server.js +7 -7
  65. package/docsearch/DocSearchInstall.tsx +3 -3
  66. package/docsearch/SearchLink.tsx +2 -2
  67. package/docsearch/toggleDocsearchModal.ts +1 -1
  68. package/index.ts +10 -10
  69. package/initKeyBindings.ts +2 -2
  70. package/installSectionUrlHashs.ts +1 -1
  71. package/package.json +1 -1
  72. package/parsePageSections.ts +2 -2
  73. package/renderer/getHydrationPromise.ts +2 -2
  74. package/renderer/getPageElement.tsx +3 -3
  75. package/renderer/initOnNavigation.ts +3 -3
  76. package/renderer/onCreatePageContext.ts +1 -1
  77. package/renderer/onRenderClient.tsx +9 -9
  78. package/renderer/onRenderHtml.tsx +14 -8
  79. package/renderer/usePageContext.tsx +1 -1
  80. package/resolvePageContext.ts +10 -10
  81. package/tsconfig.json +20 -12
  82. package/types/Config.ts +1 -1
  83. package/utils/Emoji/Emoji.ts +2 -2
  84. package/utils/Emoji/index.ts +1 -1
  85. package/utils/addScript.ts +1 -1
  86. package/utils/client.ts +3 -3
  87. package/utils/determineSectionUrlHash.ts +2 -2
  88. package/utils/jsxToTextContent.ts +1 -1
  89. package/utils/server.ts +7 -7
@@ -1,8 +1,8 @@
1
1
  export { SearchLink }
2
2
 
3
3
  import React from 'react'
4
- import { openDocsearchModal } from './toggleDocsearchModal'
5
- import { iconMagnifyingGlass } from '../icons'
4
+ import { openDocsearchModal } from './toggleDocsearchModal.js'
5
+ import { iconMagnifyingGlass } from '../icons/index.js'
6
6
 
7
7
  type PropsAnchor = React.HTMLProps<HTMLAnchorElement>
8
8
  function SearchLink(props: PropsAnchor) {
@@ -1,7 +1,7 @@
1
1
  export { closeDocsearchModal }
2
2
  export { openDocsearchModal }
3
3
 
4
- import { assert } from '../utils/client'
4
+ import { assert } from '../utils/client.js'
5
5
 
6
6
  function closeDocsearchModal() {
7
7
  if (isClosed()) return
package/index.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  /**********/
2
2
  /* PUBLIC */
3
3
  /**********/
4
- export { CodeBlockTransformer, Link, RepoLink, FileAdded, FileRemoved, ImportMeta, Emoji } from './components'
5
- export { MenuToggle } from './Layout'
6
- export * from './components/Note'
7
- export * from './icons/index'
8
- export { assert } from './utils/assert'
9
- export { parseMarkdownMini } from './parseMarkdownMini'
10
- export type { Config } from './types/Config'
11
- export type { HeadingDefinition, HeadingDetachedDefinition } from './types/Heading'
4
+ export { CodeBlockTransformer, Link, RepoLink, FileAdded, FileRemoved, ImportMeta, Emoji } from './components/index.js'
5
+ export { MenuToggle } from './Layout.js'
6
+ export * from './components/Note.js'
7
+ export * from './icons/index.js'
8
+ export { assert } from './utils/assert.js'
9
+ export { parseMarkdownMini } from './parseMarkdownMini.js'
10
+ export type { Config } from './types/Config.js'
11
+ export type { HeadingDefinition, HeadingDetachedDefinition } from './types/Heading.js'
12
12
  // The only place usePageContext() is used at:
13
13
  // https://github.com/vikejs/vike/blob/0b1b109f64aafbed23a1c2ac2630e6146a270ec0/packages/vike.dev/components/CommunityNote.tsx#L4
14
- export { usePageContext } from './renderer/usePageContext'
14
+ export { usePageContext } from './renderer/usePageContext.js'
15
15
 
16
16
  // The following are used internally by DocPress — users (should) never use these exports
17
17
  /************/
@@ -19,4 +19,4 @@ export { usePageContext } from './renderer/usePageContext'
19
19
  /************/
20
20
  // We provide our own `useMDXComponents()` to enable MDX component injection by setting `providerImportSource` to '@brillout/docpress'.
21
21
  // https://mdxjs.com/guides/injecting-components/
22
- export { useMDXComponents } from './code-blocks/hooks/useMDXComponents'
22
+ export { useMDXComponents } from './code-blocks/hooks/useMDXComponents.js'
@@ -1,7 +1,7 @@
1
1
  export { initKeyBindings }
2
2
 
3
- import { closeDocsearchModal } from './docsearch/toggleDocsearchModal'
4
- import { closeMenuModal } from './MenuModal/toggleMenuModal'
3
+ import { closeDocsearchModal } from './docsearch/toggleDocsearchModal.js'
4
+ import { closeMenuModal } from './MenuModal/toggleMenuModal.js'
5
5
 
6
6
  function initKeyBindings() {
7
7
  window.addEventListener(
@@ -1,6 +1,6 @@
1
1
  export { installSectionUrlHashs }
2
2
 
3
- import { assert } from './utils/client'
3
+ import { assert } from './utils/client.js'
4
4
 
5
5
  // TO-DO/eventually: use React instead of manually installing click handlers?
6
6
  function installSectionUrlHashs() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.16.11",
3
+ "version": "0.16.13",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
@@ -68,8 +68,8 @@ function transform(code: string) {
68
68
 
69
69
  function parsePageSection(line: string): PageSection & { headingHtml: string } {
70
70
  const [lineBegin, ...lineWords] = line.split(' ')
71
- assert(lineBegin.split('#').join('') === '', { line, lineWords })
72
- const pageSectionLevel = lineBegin.length
71
+ assert(lineBegin!.split('#').join('') === '', { line, lineWords })
72
+ const pageSectionLevel = lineBegin!.length
73
73
 
74
74
  const titleMdx = lineWords.join(' ')
75
75
  assert(!titleMdx.startsWith(' '), { line, lineWords })
@@ -1,8 +1,8 @@
1
1
  export { getHydrationPromise }
2
2
  export { setHydrationIsFinished }
3
3
 
4
- import { getGlobalObject } from '../utils/client'
5
- import { genPromise } from '../utils/genPromise'
4
+ import { getGlobalObject } from '../utils/client.js'
5
+ import { genPromise } from '../utils/genPromise.js'
6
6
 
7
7
  const globalObject = getGlobalObject<{
8
8
  hydrationPromise: Promise<void>
@@ -1,10 +1,10 @@
1
1
  export { getPageElement }
2
2
 
3
3
  import type { PageContext } from 'vike/types'
4
- import { PageContextProvider } from './usePageContext'
4
+ import { PageContextProvider } from './usePageContext.js'
5
5
  import React from 'react'
6
- import { DocSearchInstall } from '../docsearch/DocSearchInstall'
7
- import { Layout } from '../Layout'
6
+ import { DocSearchInstall } from '../docsearch/DocSearchInstall.js'
7
+ import { Layout } from '../Layout.js'
8
8
 
9
9
  function getPageElement(pageContext: PageContext) {
10
10
  const { Page } = pageContext
@@ -1,8 +1,8 @@
1
1
  export { initOnNavigation }
2
2
 
3
- import { isBrowser } from '../utils/isBrowser'
4
- import { closeMenuModal } from '../MenuModal/toggleMenuModal'
5
- import { unexpandNav } from '../Layout'
3
+ import { isBrowser } from '../utils/isBrowser.js'
4
+ import { closeMenuModal } from '../MenuModal/toggleMenuModal.js'
5
+ import { unexpandNav } from '../Layout.js'
6
6
 
7
7
  function onNavigation() {
8
8
  closeMenuModal()
@@ -1,7 +1,7 @@
1
1
  export { onCreatePageContext }
2
2
 
3
3
  import type { PageContextServer } from 'vike/types'
4
- import { resolvePageContext } from '../resolvePageContext'
4
+ import { resolvePageContext } from '../resolvePageContext.js'
5
5
 
6
6
  function onCreatePageContext(pageContext: PageContextServer) {
7
7
  pageContext.resolved = resolvePageContext(pageContext)
@@ -3,16 +3,16 @@ export { onRenderClient }
3
3
  import React, { useEffect } from 'react'
4
4
  import type { PageContextClient } from 'vike/types'
5
5
  import ReactDOM from 'react-dom/client'
6
- import { getPageElement } from './getPageElement'
7
- import { closeMenuModal } from '../MenuModal/toggleMenuModal'
6
+ import { getPageElement } from './getPageElement.js'
7
+ import { closeMenuModal } from '../MenuModal/toggleMenuModal.js'
8
8
  import '../css/index.css'
9
- import { autoScrollNav } from '../autoScrollNav'
10
- import { installSectionUrlHashs } from '../installSectionUrlHashs'
11
- import { getGlobalObject } from '../utils/client'
12
- import { initKeyBindings } from '../initKeyBindings'
13
- import { initOnNavigation } from './initOnNavigation'
14
- import { setHydrationIsFinished } from './getHydrationPromise'
15
- import { addScript } from '../utils/addScript'
9
+ import { autoScrollNav } from '../autoScrollNav.js'
10
+ import { installSectionUrlHashs } from '../installSectionUrlHashs.js'
11
+ import { getGlobalObject } from '../utils/client.js'
12
+ import { initKeyBindings } from '../initKeyBindings.js'
13
+ import { initOnNavigation } from './initOnNavigation.js'
14
+ import { setHydrationIsFinished } from './getHydrationPromise.js'
15
+ import { addScript } from '../utils/addScript.js'
16
16
 
17
17
  const globalObject = getGlobalObject<{
18
18
  root?: ReactDOM.Root
@@ -2,10 +2,10 @@ export { onRenderHtml }
2
2
 
3
3
  import ReactDOMServer from 'react-dom/server'
4
4
  import { escapeInject, dangerouslySkipEscape } from 'vike/server'
5
- import { assert, assertUsage } from '../utils/server'
6
- import { getPageElement } from './getPageElement'
5
+ import { assert, assertUsage } from '../utils/server.js'
6
+ import { getPageElement } from './getPageElement.js'
7
7
  import type { PageContextServer } from 'vike/types'
8
- import type { Config } from '../types/Config'
8
+ import type { Config } from '../types/Config.js'
9
9
 
10
10
  async function onRenderHtml(pageContext: PageContextServer): Promise<any> {
11
11
  const page = getPageElement(pageContext)
@@ -108,11 +108,17 @@ function getOpenGraphTags(url: string, documentTitle: string, config: Config) {
108
108
  // - Single PNG:
109
109
  // https://rubyonrails.org
110
110
  // - Favicon shown in browser is different than favicon shown in Google:
111
- // https://evilmartians.com
112
- // Shown in Google: <link rel="apple-touch-icon" href="/apple-touch-icon.png" /> or <link rel="manifest" href="/manifest.webmanifest" />
113
- // Shown in Browser: <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
114
- // https://gemini.google.com/share/8bcf76a26783
115
- // https://chatgpt.com/share/696930b6-4414-800d-9c55-598ac7fa1ccb
111
+ // - Resources:
112
+ // https://gemini.google.com/share/8bcf76a26783
113
+ // https://chatgpt.com/share/696930b6-4414-800d-9c55-598ac7fa1ccb
114
+ // - https://evilmartians.com
115
+ // Shown in Google: <link rel="apple-touch-icon" href="/apple-touch-icon.png" /> or <link rel="manifest" href="/manifest.webmanifest" />
116
+ // Shown in Browser: <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
117
+ // Google preview is fake (it picks the browser one, not the Google one): https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://evilmartians.com&size=48
118
+ // - https://vike.dev
119
+ // Shown in Google: <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
120
+ // Shown in Browser: <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
121
+ // Google preview is fake (it picks the browser one, not the Google one): https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://vike.dev&size=48
116
122
  function getFaviconTags(config: Config) {
117
123
  const { faviconBrowser, faviconGoogle } = getFavicons(config)
118
124
  assert(faviconBrowser)
@@ -4,7 +4,7 @@ export { usePageContextLegacy }
4
4
 
5
5
  import React, { useContext } from 'react'
6
6
  import type { PageContext } from 'vike/types'
7
- import { getGlobalObject } from '../utils/getGlobalObject'
7
+ import { getGlobalObject } from '../utils/getGlobalObject.js'
8
8
 
9
9
  const globalObject = getGlobalObject('usePageContext.ts', {
10
10
  Ctx: React.createContext<PageContext>(undefined as any),
@@ -1,23 +1,23 @@
1
1
  export { resolvePageContext }
2
2
  export type Resolved = ReturnType<typeof resolvePageContext>
3
3
 
4
- import type { Config } from './types/Config'
5
- import type { NavItem } from './NavItemComponent'
6
- import type { LinkData } from './components'
4
+ import type { Config } from './types/Config.js'
5
+ import type { NavItem } from './NavItemComponent.js'
6
+ import type { LinkData } from './components/index.js'
7
7
  import type { PageContextServer } from 'vike/types'
8
- import type { PageSection } from './parsePageSections'
8
+ import type { PageSection } from './parsePageSections.js'
9
9
  import type {
10
10
  HeadingDefinition,
11
11
  HeadingDetachedDefinition,
12
12
  HeadingResolved,
13
13
  HeadingDetachedResolved,
14
14
  StringArray,
15
- } from './types/Heading'
16
- import { assert, assertUsage } from './utils/assert'
17
- import { jsxToTextContent } from './utils/jsxToTextContent'
15
+ } from './types/Heading.js'
16
+ import { assert, assertUsage } from './utils/assert.js'
17
+ import { jsxToTextContent } from './utils/jsxToTextContent.js'
18
18
  import pc from '@brillout/picocolors'
19
- import { parseMarkdownMini } from './parseMarkdownMini'
20
- import { determineNavItemsColumnLayout } from './determineNavItemsColumnLayout'
19
+ import { parseMarkdownMini } from './parseMarkdownMini.js'
20
+ import { determineNavItemsColumnLayout } from './determineNavItemsColumnLayout.js'
21
21
 
22
22
  type PageSectionResolved = {
23
23
  url: string | null
@@ -152,8 +152,8 @@ function getActiveHeading(
152
152
  const URLs =
153
153
  '\n' +
154
154
  [...headingsResolved, ...headingsDetachedResolved]
155
- .filter(Boolean)
156
155
  .map((h) => h.url)
156
+ .filter(Boolean)
157
157
  .sort()
158
158
  .map((url) => ` ${url}`)
159
159
  .join('\n')
package/tsconfig.json CHANGED
@@ -1,17 +1,25 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "outDir": "./dist/",
4
- "jsx": "react",
5
- "module": "ES2022",
6
- "target": "ES2022",
7
- "moduleResolution": "Bundler",
8
- "lib": ["DOM", "DOM.Iterable", "ESNext"],
9
- "types": ["vite/client"],
10
- "esModuleInterop": true,
3
+ // Misc
11
4
  "skipLibCheck": true,
12
- "allowSyntheticDefaultImports": true,
13
- "declaration": true,
14
- // "noUncheckedIndexedAccess": true,
15
- "strict": true
5
+ "noErrorTruncation": true,
6
+ // Strictness
7
+ "strict": true,
8
+ "noUncheckedIndexedAccess": true,
9
+ "noUnusedLocals": true,
10
+ "noUnusedParameters": true,
11
+ // Resolution
12
+ "esModuleInterop": true,
13
+ "moduleResolution": "Node16",
14
+ "jsx": "react",
15
+ // Libs
16
+ "lib": ["DOM", "DOM.Iterable", "ES2022"],
17
+ "types": ["node", "vite/client"],
18
+ // Output
19
+ "target": "ES2020",
20
+ "module": "Node16",
21
+ "outDir": "./dist/",
22
+ "rootDir": "./",
23
+ "declaration": true
16
24
  }
17
25
  }
package/types/Config.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { Config }
2
2
 
3
- import type { HeadingDefinition, HeadingDetachedDefinition } from './Heading'
3
+ import type { HeadingDefinition, HeadingDetachedDefinition } from './Heading.js'
4
4
 
5
5
  type Config = {
6
6
  name: string
@@ -1,9 +1,9 @@
1
1
  // Let's eventually remove this. Telefunc is still using this as of 2024-12.
2
2
 
3
3
  import React from 'react'
4
- import { assert } from '../assert'
4
+ import { assert } from '../assert.js'
5
5
 
6
- import { iconMechanicalArm, iconShield, iconTypescript, iconEngine } from './assets'
6
+ import { iconMechanicalArm, iconShield, iconTypescript, iconEngine } from './assets.js'
7
7
 
8
8
  export { Emoji }
9
9
  export type { EmojiName }
@@ -1 +1 @@
1
- export * from './Emoji'
1
+ export * from './Emoji.js'
@@ -1,6 +1,6 @@
1
1
  export { addScript }
2
2
 
3
- import { genPromise } from './genPromise'
3
+ import { genPromise } from './genPromise.js'
4
4
 
5
5
  async function addScript(src: string) {
6
6
  const { promise, resolve, reject } = genPromise()
package/utils/client.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './assert'
2
- export * from './isBrowser'
3
- export * from './getGlobalObject'
1
+ export * from './assert.js'
2
+ export * from './isBrowser.js'
3
+ export * from './getGlobalObject.js'
@@ -26,7 +26,7 @@ function removeAccentsAndDiacritics(str: string): string {
26
26
 
27
27
  function determineSectionTitle(urlWithHash: string): string {
28
28
  assert(urlWithHash.includes('#'), { urlWithHash })
29
- const urlHash = urlWithHash.split('#')[1]
29
+ const urlHash = urlWithHash.split('#')[1]!
30
30
  const title = urlHash
31
31
  .split('-')
32
32
  .map((word, i) => {
@@ -40,5 +40,5 @@ function determineSectionTitle(urlWithHash: string): string {
40
40
  }
41
41
 
42
42
  function capitalizeFirstLetter(word: string): string {
43
- return word[0].toUpperCase() + word.slice(1)
43
+ return word[0]!.toUpperCase() + word.slice(1)
44
44
  }
@@ -1,4 +1,4 @@
1
- import { assert } from './assert'
1
+ import { assert } from './assert.js'
2
2
 
3
3
  export { jsxToTextContent }
4
4
 
package/utils/server.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from './client'
2
- export * from './isBrowser'
3
- export * from './filter'
4
- export * from './determineSectionUrlHash'
5
- export * from './jsxToTextContent'
6
- export * from './objectAssign'
7
- export * from './Emoji'
1
+ export * from './client.js'
2
+ export * from './isBrowser.js'
3
+ export * from './filter.js'
4
+ export * from './determineSectionUrlHash.js'
5
+ export * from './jsxToTextContent.js'
6
+ export * from './objectAssign.js'
7
+ export * from './Emoji/index.js'