@stream-mdx/react 0.1.1 → 0.3.0

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 (45) hide show
  1. package/dist/components/index.cjs +497 -163
  2. package/dist/components/index.d.cts +1 -1
  3. package/dist/components/index.d.ts +1 -1
  4. package/dist/components/index.mjs +496 -163
  5. package/dist/{index-Bt1opGCs.d.cts → index-D7px9jug.d.cts} +27 -2
  6. package/dist/{index-Bt1opGCs.d.ts → index-D7px9jug.d.ts} +27 -2
  7. package/dist/index.cjs +3767 -2043
  8. package/dist/index.d.cts +43 -5
  9. package/dist/index.d.ts +43 -5
  10. package/dist/index.mjs +3991 -2265
  11. package/dist/mdx-client.cjs +60 -18
  12. package/dist/mdx-client.d.cts +11 -0
  13. package/dist/mdx-client.d.ts +11 -0
  14. package/dist/mdx-client.mjs +60 -18
  15. package/dist/mdx-coordinator.cjs +60 -18
  16. package/dist/mdx-coordinator.mjs +60 -18
  17. package/dist/renderer/node-views.cjs +466 -133
  18. package/dist/renderer/node-views.d.cts +1 -1
  19. package/dist/renderer/node-views.d.ts +1 -1
  20. package/dist/renderer/node-views.mjs +409 -68
  21. package/dist/renderer/patch-commit-scheduler.cjs +68 -7
  22. package/dist/renderer/patch-commit-scheduler.d.cts +6 -5
  23. package/dist/renderer/patch-commit-scheduler.d.ts +6 -5
  24. package/dist/renderer/patch-commit-scheduler.mjs +68 -7
  25. package/dist/renderer/store.cjs +481 -56
  26. package/dist/renderer/store.d.cts +2 -1
  27. package/dist/renderer/store.d.ts +2 -1
  28. package/dist/renderer/store.mjs +479 -47
  29. package/dist/renderer/virtualized-code.cjs +8 -2
  30. package/dist/renderer/virtualized-code.d.cts +4 -0
  31. package/dist/renderer/virtualized-code.d.ts +4 -0
  32. package/dist/renderer/virtualized-code.mjs +8 -2
  33. package/dist/renderer.cjs +3199 -2208
  34. package/dist/renderer.d.cts +4 -2
  35. package/dist/renderer.d.ts +4 -2
  36. package/dist/renderer.mjs +2956 -1957
  37. package/dist/streaming-markdown-DSC4L0xR.d.cts +157 -0
  38. package/dist/streaming-markdown-Dp1IDgMT.d.ts +157 -0
  39. package/dist/streaming-markdown.cjs +3950 -2248
  40. package/dist/streaming-markdown.d.cts +6 -95
  41. package/dist/streaming-markdown.d.ts +6 -95
  42. package/dist/streaming-markdown.mjs +3962 -2252
  43. package/dist/utils/inline-html.d.cts +1 -1
  44. package/dist/utils/inline-html.d.ts +1 -1
  45. package/package.json +3 -3
@@ -42,6 +42,8 @@ function calculateCodeWindow(lines, scrollTop, containerHeight, lineHeight, conf
42
42
  return {
43
43
  startIndex: 0,
44
44
  endIndex: totalLines,
45
+ visibleStart: 0,
46
+ visibleEnd: totalLines,
45
47
  visibleLines: lines,
46
48
  totalLines,
47
49
  mountedLines: totalLines
@@ -49,11 +51,15 @@ function calculateCodeWindow(lines, scrollTop, containerHeight, lineHeight, conf
49
51
  }
50
52
  const firstVisibleLine = Math.floor(scrollTop / lineHeight);
51
53
  const lastVisibleLine = Math.ceil((scrollTop + containerHeight) / lineHeight);
52
- const startIndex = Math.max(0, firstVisibleLine - config.bufferSize);
53
- const endIndex = Math.min(totalLines, lastVisibleLine + config.bufferSize);
54
+ const visibleStart = Math.max(0, firstVisibleLine);
55
+ const visibleEnd = Math.min(totalLines, Math.max(visibleStart, lastVisibleLine));
56
+ const startIndex = Math.max(0, visibleStart - config.bufferSize);
57
+ const endIndex = Math.min(totalLines, visibleEnd + config.bufferSize);
54
58
  return {
55
59
  startIndex,
56
60
  endIndex,
61
+ visibleStart,
62
+ visibleEnd,
57
63
  visibleLines: lines.slice(startIndex, endIndex),
58
64
  totalLines,
59
65
  mountedLines: endIndex - startIndex
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { TokenLineV1 } from '@stream-mdx/core';
2
3
 
3
4
  interface VirtualizedCodeConfig {
4
5
  enabled: boolean;
@@ -12,10 +13,13 @@ interface VirtualizedLine {
12
13
  index: number;
13
14
  text: string;
14
15
  html?: string | null;
16
+ tokens?: TokenLineV1 | null;
15
17
  }
16
18
  interface VirtualizedCodeWindow {
17
19
  startIndex: number;
18
20
  endIndex: number;
21
+ visibleStart: number;
22
+ visibleEnd: number;
19
23
  visibleLines: VirtualizedLine[];
20
24
  totalLines: number;
21
25
  mountedLines: number;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { TokenLineV1 } from '@stream-mdx/core';
2
3
 
3
4
  interface VirtualizedCodeConfig {
4
5
  enabled: boolean;
@@ -12,10 +13,13 @@ interface VirtualizedLine {
12
13
  index: number;
13
14
  text: string;
14
15
  html?: string | null;
16
+ tokens?: TokenLineV1 | null;
15
17
  }
16
18
  interface VirtualizedCodeWindow {
17
19
  startIndex: number;
18
20
  endIndex: number;
21
+ visibleStart: number;
22
+ visibleEnd: number;
19
23
  visibleLines: VirtualizedLine[];
20
24
  totalLines: number;
21
25
  mountedLines: number;
@@ -17,6 +17,8 @@ function calculateCodeWindow(lines, scrollTop, containerHeight, lineHeight, conf
17
17
  return {
18
18
  startIndex: 0,
19
19
  endIndex: totalLines,
20
+ visibleStart: 0,
21
+ visibleEnd: totalLines,
20
22
  visibleLines: lines,
21
23
  totalLines,
22
24
  mountedLines: totalLines
@@ -24,11 +26,15 @@ function calculateCodeWindow(lines, scrollTop, containerHeight, lineHeight, conf
24
26
  }
25
27
  const firstVisibleLine = Math.floor(scrollTop / lineHeight);
26
28
  const lastVisibleLine = Math.ceil((scrollTop + containerHeight) / lineHeight);
27
- const startIndex = Math.max(0, firstVisibleLine - config.bufferSize);
28
- const endIndex = Math.min(totalLines, lastVisibleLine + config.bufferSize);
29
+ const visibleStart = Math.max(0, firstVisibleLine);
30
+ const visibleEnd = Math.min(totalLines, Math.max(visibleStart, lastVisibleLine));
31
+ const startIndex = Math.max(0, visibleStart - config.bufferSize);
32
+ const endIndex = Math.min(totalLines, visibleEnd + config.bufferSize);
29
33
  return {
30
34
  startIndex,
31
35
  endIndex,
36
+ visibleStart,
37
+ visibleEnd,
32
38
  visibleLines: lines.slice(startIndex, endIndex),
33
39
  totalLines,
34
40
  mountedLines: endIndex - startIndex