@brett_lamy/docstream 1.18.1 → 1.19.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 (41) hide show
  1. package/README.md +65 -19
  2. package/dist/docs/DocsRenderer.d.ts.map +1 -1
  3. package/dist/docs/DocsRenderer.js +14 -3
  4. package/dist/docs/DocsRenderer.js.map +1 -1
  5. package/dist/gitbook/parse.js +10 -2
  6. package/dist/gitbook/parse.js.map +1 -1
  7. package/dist/openapi/OpenApiOperation.d.ts.map +1 -1
  8. package/dist/openapi/OpenApiOperation.js +13 -5
  9. package/dist/openapi/OpenApiOperation.js.map +1 -1
  10. package/dist/replay/ReplayStageImpl.d.ts.map +1 -1
  11. package/dist/replay/ReplayStageImpl.js +4 -1
  12. package/dist/replay/ReplayStageImpl.js.map +1 -1
  13. package/dist/site/DocsSite.d.ts +74 -0
  14. package/dist/site/DocsSite.d.ts.map +1 -0
  15. package/dist/site/DocsSite.js +479 -0
  16. package/dist/site/DocsSite.js.map +1 -0
  17. package/dist/site/index.d.ts +7 -0
  18. package/dist/site/index.d.ts.map +1 -0
  19. package/dist/site/index.js +5 -0
  20. package/dist/site/index.js.map +1 -0
  21. package/dist/site/search.d.ts +28 -0
  22. package/dist/site/search.d.ts.map +1 -0
  23. package/dist/site/search.js +125 -0
  24. package/dist/site/search.js.map +1 -0
  25. package/dist/site/site.css +816 -0
  26. package/dist/site/tree.d.ts +105 -0
  27. package/dist/site/tree.d.ts.map +1 -0
  28. package/dist/site/tree.js +411 -0
  29. package/dist/site/tree.js.map +1 -0
  30. package/dist/styles.css +1 -0
  31. package/package.json +8 -1
  32. package/src/docs/DocsRenderer.tsx +14 -3
  33. package/src/gitbook/parse.ts +10 -2
  34. package/src/openapi/OpenApiOperation.tsx +13 -5
  35. package/src/replay/ReplayStageImpl.tsx +4 -1
  36. package/src/site/DocsSite.tsx +958 -0
  37. package/src/site/index.ts +18 -0
  38. package/src/site/search.ts +138 -0
  39. package/src/site/site.css +816 -0
  40. package/src/site/tree.ts +482 -0
  41. package/src/styles.css +1 -0
@@ -1099,6 +1099,14 @@ interface ParsedList {
1099
1099
 
1100
1100
  const LIST_ITEM_RE = /^(\s*)([-*+]|\d+[.)])(\s+)(.*)$/
1101
1101
 
1102
+ /** Whether `marker` continues a list opened by `first`: CommonMark starts a new list when the
1103
+ bullet character (`-`, `*`, `+`) or the ordered delimiter (`.`, `)`) changes. */
1104
+ function sameListKind(first: string, marker: string): boolean {
1105
+ const ordered = /^\d/.test(first)
1106
+ if (ordered !== /^\d/.test(marker)) return false
1107
+ return ordered ? first.slice(-1) === marker.slice(-1) : first === marker
1108
+ }
1109
+
1102
1110
  // Indent-aware list parser: deeper-indented marker lines become nested lists
1103
1111
  // inside the item (handled recursively via parseBlocks on dedented lines).
1104
1112
  // The markers, numbering, padding, continuation indent and blank lines between items are recorded
@@ -1123,7 +1131,7 @@ function parseList(lines: string[], start: number): ParsedList {
1123
1131
 
1124
1132
  while (i < lines.length) {
1125
1133
  const m = lines[i].match(LIST_ITEM_RE)
1126
- if (!m || m[1].length !== baseIndent || /^\d/.test(m[2]) !== ordered) break
1134
+ if (!m || m[1].length !== baseIndent || !sameListKind(first[2], m[2])) break
1127
1135
 
1128
1136
  let content = m[4]
1129
1137
  let checked: boolean | undefined
@@ -1184,7 +1192,7 @@ function parseList(lines: string[], start: number): ParsedList {
1184
1192
  // skip a single blank line between sibling items
1185
1193
  if (i < lines.length && !lines[i].trim()) {
1186
1194
  const after = lines[i + 1]?.match(/^(\s*)([-*+]|\d+[.)])\s+/)
1187
- if (after && after[1].length === baseIndent && /^\d/.test(after[2]) === ordered) {
1195
+ if (after && after[1].length === baseIndent && sameListKind(first[2], after[2])) {
1188
1196
  gap = 1
1189
1197
  blankLine = lines[i]
1190
1198
  i++
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useState } from "react"
2
2
  import { parse as parseYaml } from "yaml"
3
3
 
4
+ import { useAsset } from "../asset-resolver"
4
5
  import { MarkdownContent } from "../docs/DocsRenderer"
5
6
  import { HighlightedCode } from "../docs/HighlightedCode"
6
7
 
@@ -98,15 +99,22 @@ export function OpenApiOperation({
98
99
  }) {
99
100
  const [spec, setSpec] = useState<any>(null)
100
101
  const [error, setError] = useState<string | null>(null)
102
+ // The spec link goes through the host's asset resolver like any other file the page points
103
+ // at, so `[api](openapi.json)` can name a file in the host's VFS. Undefined while it resolves.
104
+ const url = useAsset(specUrl)
101
105
 
102
106
  useEffect(() => {
103
- if (!specUrl) return
107
+ if (!url) return
108
+ let live = true
104
109
  setSpec(null)
105
110
  setError(null)
106
- loadSpec(specUrl)
107
- .then(setSpec)
108
- .catch((e) => setError(String(e.message ?? e)))
109
- }, [specUrl])
111
+ loadSpec(url)
112
+ .then((s) => live && setSpec(s))
113
+ .catch((e) => live && setError(String(e.message ?? e)))
114
+ return () => {
115
+ live = false
116
+ }
117
+ }, [url])
110
118
 
111
119
  if (!specUrl) return <div className="oas oas-empty">Set an OpenAPI spec URL…</div>
112
120
  if (error) return <div className="oas oas-empty">⚠︎ {error}</div>
@@ -178,7 +178,10 @@ const ReplayStageImpl = forwardRef<ReplayStageHandle, ReplayStageProps>(function
178
178
  callbacks.current.onFinish?.()
179
179
  }
180
180
  })
181
- replayer.pause(initialTime)
181
+ // rrweb applies only events stamped before the pause point, so pausing at 0 would leave out the
182
+ // mutations recorded with the first snapshot (a trimmed recording stamps everything before its
183
+ // window there): 1ms in, the first frame is the page as recorded at the start.
184
+ replayer.pause(Math.max(initialTime, 1))
182
185
  replayerRef.current = replayer
183
186
  fedCountRef.current = prepared.length
184
187
  let duration = meta.duration