@stream-mdx/react 0.1.0 → 0.2.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 (47) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +4 -0
  3. package/dist/components/index.cjs +497 -163
  4. package/dist/components/index.d.cts +1 -1
  5. package/dist/components/index.d.ts +1 -1
  6. package/dist/components/index.mjs +496 -163
  7. package/dist/{index-Bt1opGCs.d.cts → index-D0akq48G.d.cts} +24 -2
  8. package/dist/{index-Bt1opGCs.d.ts → index-D0akq48G.d.ts} +24 -2
  9. package/dist/index.cjs +3797 -2048
  10. package/dist/index.d.cts +43 -5
  11. package/dist/index.d.ts +43 -5
  12. package/dist/index.mjs +3741 -1990
  13. package/dist/mdx-client.cjs +60 -18
  14. package/dist/mdx-client.d.cts +11 -0
  15. package/dist/mdx-client.d.ts +11 -0
  16. package/dist/mdx-client.mjs +60 -18
  17. package/dist/mdx-coordinator.cjs +60 -18
  18. package/dist/mdx-coordinator.mjs +60 -18
  19. package/dist/renderer/node-views.cjs +481 -130
  20. package/dist/renderer/node-views.d.cts +1 -1
  21. package/dist/renderer/node-views.d.ts +1 -1
  22. package/dist/renderer/node-views.mjs +424 -65
  23. package/dist/renderer/patch-commit-scheduler.cjs +68 -7
  24. package/dist/renderer/patch-commit-scheduler.d.cts +6 -5
  25. package/dist/renderer/patch-commit-scheduler.d.ts +6 -5
  26. package/dist/renderer/patch-commit-scheduler.mjs +68 -7
  27. package/dist/renderer/store.cjs +481 -56
  28. package/dist/renderer/store.d.cts +2 -1
  29. package/dist/renderer/store.d.ts +2 -1
  30. package/dist/renderer/store.mjs +479 -47
  31. package/dist/renderer/virtualized-code.cjs +8 -2
  32. package/dist/renderer/virtualized-code.d.cts +4 -0
  33. package/dist/renderer/virtualized-code.d.ts +4 -0
  34. package/dist/renderer/virtualized-code.mjs +8 -2
  35. package/dist/renderer.cjs +3188 -2172
  36. package/dist/renderer.d.cts +4 -2
  37. package/dist/renderer.d.ts +4 -2
  38. package/dist/renderer.mjs +3009 -1985
  39. package/dist/streaming-markdown-Ch6PwjAa.d.cts +154 -0
  40. package/dist/streaming-markdown-tca-Mf8D.d.ts +154 -0
  41. package/dist/streaming-markdown.cjs +3929 -2202
  42. package/dist/streaming-markdown.d.cts +6 -95
  43. package/dist/streaming-markdown.d.ts +6 -95
  44. package/dist/streaming-markdown.mjs +3943 -2208
  45. package/dist/utils/inline-html.d.cts +1 -1
  46. package/dist/utils/inline-html.d.ts +1 -1
  47. 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