react-native-nitro-markdown 0.4.2 → 0.5.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 (191) hide show
  1. package/README.md +605 -318
  2. package/android/src/main/java/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSession.kt +27 -8
  3. package/cpp/bindings/HybridMarkdownParser.cpp +216 -66
  4. package/cpp/bindings/HybridMarkdownParser.hpp +2 -0
  5. package/ios/HybridMarkdownSession.swift +33 -7
  6. package/lib/commonjs/MarkdownContext.js +2 -1
  7. package/lib/commonjs/MarkdownContext.js.map +1 -1
  8. package/lib/commonjs/headless.js +41 -5
  9. package/lib/commonjs/headless.js.map +1 -1
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/markdown-stream.js +109 -13
  12. package/lib/commonjs/markdown-stream.js.map +1 -1
  13. package/lib/commonjs/markdown.js +215 -44
  14. package/lib/commonjs/markdown.js.map +1 -1
  15. package/lib/commonjs/renderers/code.js +4 -3
  16. package/lib/commonjs/renderers/code.js.map +1 -1
  17. package/lib/commonjs/renderers/heading.js +1 -1
  18. package/lib/commonjs/renderers/heading.js.map +1 -1
  19. package/lib/commonjs/renderers/image.js +7 -5
  20. package/lib/commonjs/renderers/image.js.map +1 -1
  21. package/lib/commonjs/renderers/link.js +15 -3
  22. package/lib/commonjs/renderers/link.js.map +1 -1
  23. package/lib/commonjs/renderers/list.js +2 -2
  24. package/lib/commonjs/renderers/list.js.map +1 -1
  25. package/lib/commonjs/renderers/table.js +126 -21
  26. package/lib/commonjs/renderers/table.js.map +1 -1
  27. package/lib/commonjs/use-markdown-stream.js +16 -14
  28. package/lib/commonjs/use-markdown-stream.js.map +1 -1
  29. package/lib/commonjs/utils/incremental-ast.js +153 -0
  30. package/lib/commonjs/utils/incremental-ast.js.map +1 -0
  31. package/lib/commonjs/utils/link-security.js +21 -0
  32. package/lib/commonjs/utils/link-security.js.map +1 -0
  33. package/lib/commonjs/utils/stream-timeline.js +62 -0
  34. package/lib/commonjs/utils/stream-timeline.js.map +1 -0
  35. package/lib/module/MarkdownContext.js +2 -1
  36. package/lib/module/MarkdownContext.js.map +1 -1
  37. package/lib/module/headless.js +37 -4
  38. package/lib/module/headless.js.map +1 -1
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/markdown-stream.js +110 -14
  41. package/lib/module/markdown-stream.js.map +1 -1
  42. package/lib/module/markdown.js +217 -46
  43. package/lib/module/markdown.js.map +1 -1
  44. package/lib/module/renderers/blockquote.js.map +1 -1
  45. package/lib/module/renderers/code.js +4 -3
  46. package/lib/module/renderers/code.js.map +1 -1
  47. package/lib/module/renderers/heading.js +1 -1
  48. package/lib/module/renderers/heading.js.map +1 -1
  49. package/lib/module/renderers/image.js +7 -5
  50. package/lib/module/renderers/image.js.map +1 -1
  51. package/lib/module/renderers/link.js +15 -3
  52. package/lib/module/renderers/link.js.map +1 -1
  53. package/lib/module/renderers/list.js +2 -2
  54. package/lib/module/renderers/list.js.map +1 -1
  55. package/lib/module/renderers/paragraph.js.map +1 -1
  56. package/lib/module/renderers/table.js +127 -22
  57. package/lib/module/renderers/table.js.map +1 -1
  58. package/lib/module/use-markdown-stream.js +16 -14
  59. package/lib/module/use-markdown-stream.js.map +1 -1
  60. package/lib/module/utils/incremental-ast.js +147 -0
  61. package/lib/module/utils/incremental-ast.js.map +1 -0
  62. package/lib/module/utils/link-security.js +15 -0
  63. package/lib/module/utils/link-security.js.map +1 -0
  64. package/lib/module/utils/stream-timeline.js +56 -0
  65. package/lib/module/utils/stream-timeline.js.map +1 -0
  66. package/lib/typescript/commonjs/Markdown.nitro.d.ts +5 -3
  67. package/lib/typescript/commonjs/Markdown.nitro.d.ts.map +1 -1
  68. package/lib/typescript/commonjs/MarkdownContext.d.ts +26 -25
  69. package/lib/typescript/commonjs/MarkdownContext.d.ts.map +1 -1
  70. package/lib/typescript/commonjs/headless.d.ts +15 -2
  71. package/lib/typescript/commonjs/headless.d.ts.map +1 -1
  72. package/lib/typescript/commonjs/index.d.ts +3 -1
  73. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  74. package/lib/typescript/commonjs/markdown-stream.d.ts +7 -2
  75. package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -1
  76. package/lib/typescript/commonjs/markdown.d.ts +62 -5
  77. package/lib/typescript/commonjs/markdown.d.ts.map +1 -1
  78. package/lib/typescript/commonjs/renderers/blockquote.d.ts +3 -3
  79. package/lib/typescript/commonjs/renderers/blockquote.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/renderers/code.d.ts +5 -5
  81. package/lib/typescript/commonjs/renderers/code.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/renderers/heading.d.ts +3 -3
  83. package/lib/typescript/commonjs/renderers/heading.d.ts.map +1 -1
  84. package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts +2 -2
  85. package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/renderers/image.d.ts +2 -2
  87. package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/renderers/link.d.ts +3 -3
  89. package/lib/typescript/commonjs/renderers/link.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/renderers/list.d.ts +7 -7
  91. package/lib/typescript/commonjs/renderers/list.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/renderers/math.d.ts +4 -4
  93. package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/renderers/paragraph.d.ts +3 -3
  95. package/lib/typescript/commonjs/renderers/paragraph.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/renderers/table.d.ts +3 -3
  97. package/lib/typescript/commonjs/renderers/table.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts +5 -2
  99. package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/theme.d.ts +2 -2
  101. package/lib/typescript/commonjs/theme.d.ts.map +1 -1
  102. package/lib/typescript/commonjs/use-markdown-stream.d.ts.map +1 -1
  103. package/lib/typescript/commonjs/utils/incremental-ast.d.ts +12 -0
  104. package/lib/typescript/commonjs/utils/incremental-ast.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/utils/link-security.d.ts +3 -0
  106. package/lib/typescript/commonjs/utils/link-security.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/utils/stream-timeline.d.ts +11 -0
  108. package/lib/typescript/commonjs/utils/stream-timeline.d.ts.map +1 -0
  109. package/lib/typescript/module/Markdown.nitro.d.ts +5 -3
  110. package/lib/typescript/module/Markdown.nitro.d.ts.map +1 -1
  111. package/lib/typescript/module/MarkdownContext.d.ts +26 -25
  112. package/lib/typescript/module/MarkdownContext.d.ts.map +1 -1
  113. package/lib/typescript/module/headless.d.ts +15 -2
  114. package/lib/typescript/module/headless.d.ts.map +1 -1
  115. package/lib/typescript/module/index.d.ts +3 -1
  116. package/lib/typescript/module/index.d.ts.map +1 -1
  117. package/lib/typescript/module/markdown-stream.d.ts +7 -2
  118. package/lib/typescript/module/markdown-stream.d.ts.map +1 -1
  119. package/lib/typescript/module/markdown.d.ts +62 -5
  120. package/lib/typescript/module/markdown.d.ts.map +1 -1
  121. package/lib/typescript/module/renderers/blockquote.d.ts +3 -3
  122. package/lib/typescript/module/renderers/blockquote.d.ts.map +1 -1
  123. package/lib/typescript/module/renderers/code.d.ts +5 -5
  124. package/lib/typescript/module/renderers/code.d.ts.map +1 -1
  125. package/lib/typescript/module/renderers/heading.d.ts +3 -3
  126. package/lib/typescript/module/renderers/heading.d.ts.map +1 -1
  127. package/lib/typescript/module/renderers/horizontal-rule.d.ts +2 -2
  128. package/lib/typescript/module/renderers/horizontal-rule.d.ts.map +1 -1
  129. package/lib/typescript/module/renderers/image.d.ts +2 -2
  130. package/lib/typescript/module/renderers/image.d.ts.map +1 -1
  131. package/lib/typescript/module/renderers/link.d.ts +3 -3
  132. package/lib/typescript/module/renderers/link.d.ts.map +1 -1
  133. package/lib/typescript/module/renderers/list.d.ts +7 -7
  134. package/lib/typescript/module/renderers/list.d.ts.map +1 -1
  135. package/lib/typescript/module/renderers/math.d.ts +4 -4
  136. package/lib/typescript/module/renderers/math.d.ts.map +1 -1
  137. package/lib/typescript/module/renderers/paragraph.d.ts +3 -3
  138. package/lib/typescript/module/renderers/paragraph.d.ts.map +1 -1
  139. package/lib/typescript/module/renderers/table.d.ts +3 -3
  140. package/lib/typescript/module/renderers/table.d.ts.map +1 -1
  141. package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts +5 -2
  142. package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts.map +1 -1
  143. package/lib/typescript/module/theme.d.ts +2 -2
  144. package/lib/typescript/module/theme.d.ts.map +1 -1
  145. package/lib/typescript/module/use-markdown-stream.d.ts.map +1 -1
  146. package/lib/typescript/module/utils/incremental-ast.d.ts +12 -0
  147. package/lib/typescript/module/utils/incremental-ast.d.ts.map +1 -0
  148. package/lib/typescript/module/utils/link-security.d.ts +3 -0
  149. package/lib/typescript/module/utils/link-security.d.ts.map +1 -0
  150. package/lib/typescript/module/utils/stream-timeline.d.ts +11 -0
  151. package/lib/typescript/module/utils/stream-timeline.d.ts.map +1 -0
  152. package/nitrogen/generated/android/NitroMarkdownOnLoad.cpp +2 -0
  153. package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
  154. package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.cpp +18 -6
  155. package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.hpp +4 -2
  156. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/Func_void_double_double.kt +80 -0
  157. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSessionSpec.kt +11 -3
  158. package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.cpp +8 -0
  159. package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.hpp +31 -0
  160. package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.hpp +20 -2
  161. package/nitrogen/generated/ios/swift/Func_void.swift +0 -1
  162. package/nitrogen/generated/ios/swift/Func_void_double_double.swift +46 -0
  163. package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec.swift +4 -3
  164. package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec_cxx.swift +34 -10
  165. package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.cpp +2 -0
  166. package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.hpp +2 -0
  167. package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.cpp +2 -0
  168. package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.hpp +4 -2
  169. package/package.json +7 -5
  170. package/src/Markdown.nitro.ts +7 -3
  171. package/src/MarkdownContext.ts +31 -25
  172. package/src/headless.ts +44 -6
  173. package/src/index.ts +8 -0
  174. package/src/markdown-stream.tsx +159 -15
  175. package/src/markdown.tsx +406 -50
  176. package/src/renderers/blockquote.tsx +4 -4
  177. package/src/renderers/code.tsx +16 -10
  178. package/src/renderers/heading.tsx +4 -4
  179. package/src/renderers/horizontal-rule.tsx +3 -3
  180. package/src/renderers/image.tsx +11 -9
  181. package/src/renderers/link.tsx +25 -7
  182. package/src/renderers/list.tsx +9 -12
  183. package/src/renderers/math.tsx +4 -4
  184. package/src/renderers/paragraph.tsx +3 -3
  185. package/src/renderers/table.tsx +270 -98
  186. package/src/specs/MarkdownSession.nitro.ts +6 -2
  187. package/src/theme.ts +3 -3
  188. package/src/use-markdown-stream.ts +22 -16
  189. package/src/utils/incremental-ast.ts +224 -0
  190. package/src/utils/link-security.ts +22 -0
  191. package/src/utils/stream-timeline.ts +72 -0
@@ -1,26 +1,26 @@
1
- import { ReactNode, type FC } from "react";
1
+ import { type FC, type ReactNode } from "react";
2
2
  import { type ViewStyle } from "react-native";
3
- interface ListProps {
3
+ type ListProps = {
4
4
  ordered: boolean;
5
5
  start?: number;
6
6
  depth: number;
7
7
  children: ReactNode;
8
8
  style?: ViewStyle;
9
- }
9
+ };
10
10
  export declare const List: FC<ListProps>;
11
- interface ListItemProps {
11
+ type ListItemProps = {
12
12
  children: ReactNode;
13
13
  index: number;
14
14
  ordered: boolean;
15
15
  start: number;
16
16
  style?: ViewStyle;
17
- }
17
+ };
18
18
  export declare const ListItem: FC<ListItemProps>;
19
- interface TaskListItemProps {
19
+ type TaskListItemProps = {
20
20
  children: ReactNode;
21
21
  checked: boolean;
22
22
  style?: ViewStyle;
23
- }
23
+ };
24
24
  export declare const TaskListItem: FC<TaskListItemProps>;
25
25
  export {};
26
26
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/renderers/list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGhF,UAAU,SAAS;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAoB9B,CAAC;AAEF,UAAU,aAAa;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAwCtC,CAAC;AAEF,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAwD9C,CAAC"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/renderers/list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGhF,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAoB9B,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAwCtC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAqD9C,CAAC"}
@@ -1,14 +1,14 @@
1
1
  import { type FC } from "react";
2
2
  import { type ViewStyle } from "react-native";
3
- interface MathInlineProps {
3
+ type MathInlineProps = {
4
4
  content?: string;
5
5
  style?: ViewStyle;
6
- }
6
+ };
7
7
  export declare const MathInline: FC<MathInlineProps>;
8
- interface MathBlockProps {
8
+ type MathBlockProps = {
9
9
  content?: string;
10
10
  style?: ViewStyle;
11
- }
11
+ };
12
12
  export declare const MathBlock: FC<MathBlockProps>;
13
13
  export {};
14
14
  //# sourceMappingURL=math.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/renderers/math.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAoBtB,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAyDD,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2B1C,CAAC;AAEF,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CA0BxC,CAAC"}
1
+ {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/renderers/math.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAoBtB,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAyDF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2B1C,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CA0BxC,CAAC"}
@@ -1,10 +1,10 @@
1
- import { ReactNode, type FC } from "react";
1
+ import { type FC, type ReactNode } from "react";
2
2
  import { type StyleProp, type ViewStyle } from "react-native";
3
- interface ParagraphProps {
3
+ type ParagraphProps = {
4
4
  children: ReactNode;
5
5
  inListItem?: boolean;
6
6
  style?: StyleProp<ViewStyle>;
7
- }
7
+ };
8
8
  export declare const Paragraph: FC<ParagraphProps>;
9
9
  export {};
10
10
  //# sourceMappingURL=paragraph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../../src/renderers/paragraph.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGhF,UAAU,cAAc;IACtB,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAkCxC,CAAC"}
1
+ {"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../../src/renderers/paragraph.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGhF,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAkCxC,CAAC"}
@@ -1,12 +1,12 @@
1
1
  import { type FC, type ComponentType } from "react";
2
2
  import { type ViewStyle } from "react-native";
3
- import type { MarkdownNode } from "../headless";
3
+ import { type MarkdownNode } from "../headless";
4
4
  import { type NodeRendererProps } from "../MarkdownContext";
5
- interface TableRendererProps {
5
+ type TableRendererProps = {
6
6
  node: MarkdownNode;
7
7
  Renderer: ComponentType<NodeRendererProps>;
8
8
  style?: ViewStyle;
9
- }
9
+ };
10
10
  export declare const TableRenderer: FC<TableRendererProps>;
11
11
  export {};
12
12
  //# sourceMappingURL=table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/renderers/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,EAQL,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAwChF,UAAU,kBAAkB;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAYD,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAmLhD,CAAC"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/renderers/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,EAAE,EACP,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,EAQL,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAwChF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAmFF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAyRhD,CAAC"}
@@ -1,12 +1,15 @@
1
1
  import type { HybridObject } from "react-native-nitro-modules";
2
+ export type MarkdownSessionListener = (from: number, to: number) => void;
2
3
  export interface MarkdownSession extends HybridObject<{
3
4
  ios: "swift";
4
5
  android: "kotlin";
5
6
  }> {
6
- append(chunk: string): void;
7
+ append(chunk: string): number;
7
8
  clear(): void;
8
9
  getAllText(): string;
10
+ getLength(): number;
11
+ getTextRange(from: number, to: number): string;
9
12
  highlightPosition: number;
10
- addListener(listener: () => void): () => void;
13
+ addListener(listener: MarkdownSessionListener): () => void;
11
14
  }
12
15
  //# sourceMappingURL=MarkdownSession.nitro.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownSession.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/MarkdownSession.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,eAAgB,SAAQ,YAAY,CAAC;IACpD,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;IACA,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,IAAI,IAAI,CAAC;IACd,UAAU,IAAI,MAAM,CAAC;IAErB,iBAAiB,EAAE,MAAM,CAAC;IAE1B,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC/C"}
1
+ {"version":3,"file":"MarkdownSession.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/MarkdownSession.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,MAAM,uBAAuB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;AAEzE,MAAM,WAAW,eAAgB,SAAQ,YAAY,CAAC;IACpD,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;IACA,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,KAAK,IAAI,IAAI,CAAC;IACd,UAAU,IAAI,MAAM,CAAC;IACrB,SAAS,IAAI,MAAM,CAAC;IACpB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAE/C,iBAAiB,EAAE,MAAM,CAAC;IAE1B,WAAW,CAAC,QAAQ,EAAE,uBAAuB,GAAG,MAAM,IAAI,CAAC;CAC5D"}
@@ -1,6 +1,6 @@
1
1
  import { type TextStyle, type ViewStyle } from "react-native";
2
2
  import type { MarkdownNode } from "./headless";
3
- export interface MarkdownTheme {
3
+ export type MarkdownTheme = {
4
4
  colors: {
5
5
  text: string | undefined;
6
6
  textMuted: string | undefined;
@@ -52,7 +52,7 @@ export interface MarkdownTheme {
52
52
  l: number;
53
53
  };
54
54
  showCodeLanguage: boolean;
55
- }
55
+ };
56
56
  export declare const defaultMarkdownTheme: MarkdownTheme;
57
57
  export type PartialMarkdownTheme = {
58
58
  [K in keyof MarkdownTheme]?: K extends "showCodeLanguage" | "headingWeight" ? MarkdownTheme[K] : MarkdownTheme[K] extends object ? Partial<MarkdownTheme[K]> : MarkdownTheme[K];
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,SAAS,EAAE,MAAM,GA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;;;;;;6BAyBY,MAAM;EAcnD;AAED,wBAAgB,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;0BAczC,MAAM;;;;;;6BA9BoB,MAAM;EAoDnD"}
1
+ {"version":3,"file":"use-markdown-stream.d.ts","sourceRoot":"","sources":["../../../src/use-markdown-stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAO1D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEvE,wBAAgB,kBAAkB;;;;;;6BAyBY,MAAM;EAcnD;AAED,wBAAgB,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;0BAgBzC,MAAM;;;;;;6BAhCoB,MAAM;EAqDnD"}
@@ -0,0 +1,12 @@
1
+ import { type MarkdownNode } from "../headless";
2
+ import type { ParserOptions } from "../Markdown.nitro";
3
+ export type IncrementalAstInput = {
4
+ allowIncremental?: boolean;
5
+ nextText: string;
6
+ options?: ParserOptions;
7
+ previousAst: MarkdownNode;
8
+ previousText: string;
9
+ };
10
+ export declare const getNextStreamAst: ({ allowIncremental, nextText, options, previousAst, previousText, }: IncrementalAstInput) => MarkdownNode;
11
+ export declare const parseMarkdownAst: (text: string, options?: ParserOptions) => MarkdownNode;
12
+ //# sourceMappingURL=incremental-ast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incremental-ast.d.ts","sourceRoot":"","sources":["../../../../src/utils/incremental-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAqJvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,WAAW,EAAE,YAAY,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,qEAM9B,mBAAmB,KAAG,YAgDxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,EACZ,UAAU,aAAa,KACtB,YAEF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const normalizeLinkHref: (href: string) => string | null;
2
+ export declare const getAllowedExternalHref: (href: string) => string | null;
3
+ //# sourceMappingURL=link-security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-security.d.ts","sourceRoot":"","sources":["../../../../src/utils/link-security.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAGzD,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAQ9D,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type TimestampEntry = {
2
+ index: number;
3
+ time: number;
4
+ };
5
+ export type TimestampTimeline = {
6
+ entries: TimestampEntry[];
7
+ monotonic: boolean;
8
+ };
9
+ export declare const createTimestampTimeline: (timestamps?: Record<number, number>) => TimestampTimeline;
10
+ export declare const resolveHighlightPosition: (timeline: TimestampTimeline, currentTimeMs: number) => number;
11
+ //# sourceMappingURL=stream-timeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-timeline.d.ts","sourceRoot":"","sources":["../../../../src/utils/stream-timeline.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,aAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAClC,iBAwBF,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,EAC3B,eAAe,MAAM,KACpB,MA8BF,CAAC"}
@@ -17,6 +17,7 @@
17
17
 
18
18
  #include "JHybridMarkdownSessionSpec.hpp"
19
19
  #include "JFunc_void.hpp"
20
+ #include "JFunc_void_double_double.hpp"
20
21
  #include "HybridMarkdownParser.hpp"
21
22
  #include <NitroModules/DefaultConstructableObject.hpp>
22
23
 
@@ -31,6 +32,7 @@ int initialize(JavaVM* vm) {
31
32
  // Register native JNI methods
32
33
  margelo::nitro::Markdown::JHybridMarkdownSessionSpec::registerNatives();
33
34
  margelo::nitro::Markdown::JFunc_void_cxx::registerNatives();
35
+ margelo::nitro::Markdown::JFunc_void_double_double_cxx::registerNatives();
34
36
 
35
37
  // Register Nitro Hybrid Objects
36
38
  HybridObjectRegistry::registerHybridObjectConstructor(
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JFunc_void_double_double.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include <functional>
14
+ #include <NitroModules/JNICallable.hpp>
15
+
16
+ namespace margelo::nitro::Markdown {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * Represents the Java/Kotlin callback `(from: Double, to: Double) -> Unit`.
22
+ * This can be passed around between C++ and Java/Kotlin.
23
+ */
24
+ struct JFunc_void_double_double: public jni::JavaClass<JFunc_void_double_double> {
25
+ public:
26
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/Func_void_double_double;";
27
+
28
+ public:
29
+ /**
30
+ * Invokes the function this `JFunc_void_double_double` instance holds through JNI.
31
+ */
32
+ void invoke(double from, double to) const {
33
+ static const auto method = javaClassStatic()->getMethod<void(double /* from */, double /* to */)>("invoke");
34
+ method(self(), from, to);
35
+ }
36
+ };
37
+
38
+ /**
39
+ * An implementation of Func_void_double_double that is backed by a C++ implementation (using `std::function<...>`)
40
+ */
41
+ class JFunc_void_double_double_cxx final: public jni::HybridClass<JFunc_void_double_double_cxx, JFunc_void_double_double> {
42
+ public:
43
+ static jni::local_ref<JFunc_void_double_double::javaobject> fromCpp(const std::function<void(double /* from */, double /* to */)>& func) {
44
+ return JFunc_void_double_double_cxx::newObjectCxxArgs(func);
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Invokes the C++ `std::function<...>` this `JFunc_void_double_double_cxx` instance holds.
50
+ */
51
+ void invoke_cxx(double from, double to) {
52
+ _func(from, to);
53
+ }
54
+
55
+ public:
56
+ [[nodiscard]]
57
+ inline const std::function<void(double /* from */, double /* to */)>& getFunction() const {
58
+ return _func;
59
+ }
60
+
61
+ public:
62
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/Func_void_double_double_cxx;";
63
+ static void registerNatives() {
64
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_double_cxx::invoke_cxx)});
65
+ }
66
+
67
+ private:
68
+ explicit JFunc_void_double_double_cxx(const std::function<void(double /* from */, double /* to */)>& func): _func(func) { }
69
+
70
+ private:
71
+ friend HybridBase;
72
+ std::function<void(double /* from */, double /* to */)> _func;
73
+ };
74
+
75
+ } // namespace margelo::nitro::Markdown
@@ -13,6 +13,7 @@
13
13
  #include <functional>
14
14
  #include "JFunc_void.hpp"
15
15
  #include <NitroModules/JNICallable.hpp>
16
+ #include "JFunc_void_double_double.hpp"
16
17
 
17
18
  namespace margelo::nitro::Markdown {
18
19
 
@@ -61,9 +62,10 @@ namespace margelo::nitro::Markdown {
61
62
  }
62
63
 
63
64
  // Methods
64
- void JHybridMarkdownSessionSpec::append(const std::string& chunk) {
65
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* chunk */)>("append");
66
- method(_javaPart, jni::make_jstring(chunk));
65
+ double JHybridMarkdownSessionSpec::append(const std::string& chunk) {
66
+ static const auto method = javaClassStatic()->getMethod<double(jni::alias_ref<jni::JString> /* chunk */)>("append");
67
+ auto __result = method(_javaPart, jni::make_jstring(chunk));
68
+ return __result;
67
69
  }
68
70
  void JHybridMarkdownSessionSpec::clear() {
69
71
  static const auto method = javaClassStatic()->getMethod<void()>("clear");
@@ -74,9 +76,19 @@ namespace margelo::nitro::Markdown {
74
76
  auto __result = method(_javaPart);
75
77
  return __result->toStdString();
76
78
  }
77
- std::function<void()> JHybridMarkdownSessionSpec::addListener(const std::function<void()>& listener) {
78
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>(jni::alias_ref<JFunc_void::javaobject> /* listener */)>("addListener_cxx");
79
- auto __result = method(_javaPart, JFunc_void_cxx::fromCpp(listener));
79
+ double JHybridMarkdownSessionSpec::getLength() {
80
+ static const auto method = javaClassStatic()->getMethod<double()>("getLength");
81
+ auto __result = method(_javaPart);
82
+ return __result;
83
+ }
84
+ std::string JHybridMarkdownSessionSpec::getTextRange(double from, double to) {
85
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>(double /* from */, double /* to */)>("getTextRange");
86
+ auto __result = method(_javaPart, from, to);
87
+ return __result->toStdString();
88
+ }
89
+ std::function<void()> JHybridMarkdownSessionSpec::addListener(const std::function<void(double /* from */, double /* to */)>& listener) {
90
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>(jni::alias_ref<JFunc_void_double_double::javaobject> /* listener */)>("addListener_cxx");
91
+ auto __result = method(_javaPart, JFunc_void_double_double_cxx::fromCpp(listener));
80
92
  return [&]() -> std::function<void()> {
81
93
  if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
82
94
  auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
@@ -56,10 +56,12 @@ namespace margelo::nitro::Markdown {
56
56
 
57
57
  public:
58
58
  // Methods
59
- void append(const std::string& chunk) override;
59
+ double append(const std::string& chunk) override;
60
60
  void clear() override;
61
61
  std::string getAllText() override;
62
- std::function<void()> addListener(const std::function<void()>& listener) override;
62
+ double getLength() override;
63
+ std::string getTextRange(double from, double to) override;
64
+ std::function<void()> addListener(const std::function<void(double /* from */, double /* to */)>& listener) override;
63
65
 
64
66
  private:
65
67
  friend HybridBase;
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// Func_void_double_double.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.com.nitromarkdown
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
14
+
15
+
16
+ /**
17
+ * Represents the JavaScript callback `(from: number, to: number) => void`.
18
+ * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
+ * or in Kotlin/Java (in which case it is a native callback).
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress("ClassName", "RedundantUnitReturnType")
24
+ fun interface Func_void_double_double: (Double, Double) -> Unit {
25
+ /**
26
+ * Call the given JS callback.
27
+ * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
+ */
29
+ @DoNotStrip
30
+ @Keep
31
+ override fun invoke(from: Double, to: Double): Unit
32
+ }
33
+
34
+ /**
35
+ * Represents the JavaScript callback `(from: number, to: number) => void`.
36
+ * This is implemented in C++, via a `std::function<...>`.
37
+ * The callback might be coming from JS.
38
+ */
39
+ @DoNotStrip
40
+ @Keep
41
+ @Suppress(
42
+ "KotlinJniMissingFunction", "unused",
43
+ "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
+ "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
+ )
46
+ class Func_void_double_double_cxx: Func_void_double_double {
47
+ @DoNotStrip
48
+ @Keep
49
+ private val mHybridData: HybridData
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ private constructor(hybridData: HybridData) {
54
+ mHybridData = hybridData
55
+ }
56
+
57
+ @DoNotStrip
58
+ @Keep
59
+ override fun invoke(from: Double, to: Double): Unit
60
+ = invoke_cxx(from,to)
61
+
62
+ @FastNative
63
+ private external fun invoke_cxx(from: Double, to: Double): Unit
64
+ }
65
+
66
+ /**
67
+ * Represents the JavaScript callback `(from: number, to: number) => void`.
68
+ * This is implemented in Java/Kotlin, via a `(Double, Double) -> Unit`.
69
+ * The callback is always coming from native.
70
+ */
71
+ @DoNotStrip
72
+ @Keep
73
+ @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
+ class Func_void_double_double_java(private val function: (Double, Double) -> Unit): Func_void_double_double {
75
+ @DoNotStrip
76
+ @Keep
77
+ override fun invoke(from: Double, to: Double): Unit {
78
+ return this.function(from, to)
79
+ }
80
+ }
@@ -51,7 +51,7 @@ abstract class HybridMarkdownSessionSpec: HybridObject() {
51
51
  // Methods
52
52
  @DoNotStrip
53
53
  @Keep
54
- abstract fun append(chunk: String): Unit
54
+ abstract fun append(chunk: String): Double
55
55
 
56
56
  @DoNotStrip
57
57
  @Keep
@@ -61,11 +61,19 @@ abstract class HybridMarkdownSessionSpec: HybridObject() {
61
61
  @Keep
62
62
  abstract fun getAllText(): String
63
63
 
64
- abstract fun addListener(listener: () -> Unit): () -> Unit
64
+ @DoNotStrip
65
+ @Keep
66
+ abstract fun getLength(): Double
67
+
68
+ @DoNotStrip
69
+ @Keep
70
+ abstract fun getTextRange(from: Double, to: Double): String
71
+
72
+ abstract fun addListener(listener: (from: Double, to: Double) -> Unit): () -> Unit
65
73
 
66
74
  @DoNotStrip
67
75
  @Keep
68
- private fun addListener_cxx(listener: Func_void): Func_void {
76
+ private fun addListener_cxx(listener: Func_void_double_double): Func_void {
69
77
  val __result = addListener(listener)
70
78
  return Func_void_java(__result)
71
79
  }
@@ -22,6 +22,14 @@ namespace margelo::nitro::Markdown::bridge::swift {
22
22
  };
23
23
  }
24
24
 
25
+ // pragma MARK: std::function<void(double /* from */, double /* to */)>
26
+ Func_void_double_double create_Func_void_double_double(void* NON_NULL swiftClosureWrapper) noexcept {
27
+ auto swiftClosure = NitroMarkdown::Func_void_double_double::fromUnsafe(swiftClosureWrapper);
28
+ return [swiftClosure = std::move(swiftClosure)](double from, double to) mutable -> void {
29
+ swiftClosure.call(from, to);
30
+ };
31
+ }
32
+
25
33
  // pragma MARK: std::shared_ptr<HybridMarkdownSessionSpec>
26
34
  std::shared_ptr<HybridMarkdownSessionSpec> create_std__shared_ptr_HybridMarkdownSessionSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
27
35
  NitroMarkdown::HybridMarkdownSessionSpec_cxx swiftPart = NitroMarkdown::HybridMarkdownSessionSpec_cxx::fromUnsafe(swiftUnsafePointer);
@@ -51,6 +51,28 @@ namespace margelo::nitro::Markdown::bridge::swift {
51
51
  return Func_void_Wrapper(std::move(value));
52
52
  }
53
53
 
54
+ // pragma MARK: std::function<void(double /* from */, double /* to */)>
55
+ /**
56
+ * Specialized version of `std::function<void(double, double)>`.
57
+ */
58
+ using Func_void_double_double = std::function<void(double /* from */, double /* to */)>;
59
+ /**
60
+ * Wrapper class for a `std::function<void(double / * from * /, double / * to * /)>`, this can be used from Swift.
61
+ */
62
+ class Func_void_double_double_Wrapper final {
63
+ public:
64
+ explicit Func_void_double_double_Wrapper(std::function<void(double /* from */, double /* to */)>&& func): _function(std::make_unique<std::function<void(double /* from */, double /* to */)>>(std::move(func))) {}
65
+ inline void call(double from, double to) const noexcept {
66
+ _function->operator()(from, to);
67
+ }
68
+ private:
69
+ std::unique_ptr<std::function<void(double /* from */, double /* to */)>> _function;
70
+ } SWIFT_NONCOPYABLE;
71
+ Func_void_double_double create_Func_void_double_double(void* NON_NULL swiftClosureWrapper) noexcept;
72
+ inline Func_void_double_double_Wrapper wrap_Func_void_double_double(Func_void_double_double value) noexcept {
73
+ return Func_void_double_double_Wrapper(std::move(value));
74
+ }
75
+
54
76
  // pragma MARK: std::shared_ptr<HybridMarkdownSessionSpec>
55
77
  /**
56
78
  * Specialized version of `std::shared_ptr<HybridMarkdownSessionSpec>`.
@@ -63,6 +85,15 @@ namespace margelo::nitro::Markdown::bridge::swift {
63
85
  using std__weak_ptr_HybridMarkdownSessionSpec_ = std::weak_ptr<HybridMarkdownSessionSpec>;
64
86
  inline std__weak_ptr_HybridMarkdownSessionSpec_ weakify_std__shared_ptr_HybridMarkdownSessionSpec_(const std::shared_ptr<HybridMarkdownSessionSpec>& strong) noexcept { return strong; }
65
87
 
88
+ // pragma MARK: Result<double>
89
+ using Result_double_ = Result<double>;
90
+ inline Result_double_ create_Result_double_(double value) noexcept {
91
+ return Result<double>::withValue(std::move(value));
92
+ }
93
+ inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
94
+ return Result<double>::withError(error);
95
+ }
96
+
66
97
  // pragma MARK: Result<void>
67
98
  using Result_void_ = Result<void>;
68
99
  inline Result_void_ create_Result_void_() noexcept {
@@ -72,11 +72,13 @@ namespace margelo::nitro::Markdown {
72
72
 
73
73
  public:
74
74
  // Methods
75
- inline void append(const std::string& chunk) override {
75
+ inline double append(const std::string& chunk) override {
76
76
  auto __result = _swiftPart.append(chunk);
77
77
  if (__result.hasError()) [[unlikely]] {
78
78
  std::rethrow_exception(__result.error());
79
79
  }
80
+ auto __value = std::move(__result.value());
81
+ return __value;
80
82
  }
81
83
  inline void clear() override {
82
84
  auto __result = _swiftPart.clear();
@@ -92,7 +94,23 @@ namespace margelo::nitro::Markdown {
92
94
  auto __value = std::move(__result.value());
93
95
  return __value;
94
96
  }
95
- inline std::function<void()> addListener(const std::function<void()>& listener) override {
97
+ inline double getLength() override {
98
+ auto __result = _swiftPart.getLength();
99
+ if (__result.hasError()) [[unlikely]] {
100
+ std::rethrow_exception(__result.error());
101
+ }
102
+ auto __value = std::move(__result.value());
103
+ return __value;
104
+ }
105
+ inline std::string getTextRange(double from, double to) override {
106
+ auto __result = _swiftPart.getTextRange(std::forward<decltype(from)>(from), std::forward<decltype(to)>(to));
107
+ if (__result.hasError()) [[unlikely]] {
108
+ std::rethrow_exception(__result.error());
109
+ }
110
+ auto __value = std::move(__result.value());
111
+ return __value;
112
+ }
113
+ inline std::function<void()> addListener(const std::function<void(double /* from */, double /* to */)>& listener) override {
96
114
  auto __result = _swiftPart.addListener(listener);
97
115
  if (__result.hasError()) [[unlikely]] {
98
116
  std::rethrow_exception(__result.error());
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_double_double.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ from: Double, _ to: Double) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_double_double {
15
+ public typealias bridge = margelo.nitro.Markdown.bridge.swift
16
+
17
+ private let closure: (_ from: Double, _ to: Double) -> Void
18
+
19
+ public init(_ closure: @escaping (_ from: Double, _ to: Double) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(from: Double, to: Double) -> Void {
25
+ self.closure(from, to)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_double_double`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_double_double>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double_double {
44
+ return Unmanaged<Func_void_double_double>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }