@saiansh2525/react-native-nitro-markdown 0.3.2

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 (243) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +468 -0
  3. package/android/CMakeLists.txt +40 -0
  4. package/android/build.gradle +92 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +4 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +7 -0
  8. package/android/src/main/java/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSession.kt +61 -0
  9. package/android/src/main/java/com/nitromarkdown/NitroMarkdownPackage.kt +27 -0
  10. package/cpp/CMakeLists.txt +46 -0
  11. package/cpp/bindings/HybridMarkdownParser.cpp +114 -0
  12. package/cpp/bindings/HybridMarkdownParser.hpp +28 -0
  13. package/cpp/bindings/HybridMarkdownSession.cpp +0 -0
  14. package/cpp/core/MD4CParser.cpp +440 -0
  15. package/cpp/core/MD4CParser.hpp +21 -0
  16. package/cpp/core/MarkdownSessionCore.cpp +0 -0
  17. package/cpp/core/MarkdownTypes.hpp +124 -0
  18. package/cpp/md4c/md4c.c +6610 -0
  19. package/cpp/md4c/md4c.h +410 -0
  20. package/ios/HybridMarkdownSession.swift +64 -0
  21. package/lib/commonjs/Markdown.nitro.js +6 -0
  22. package/lib/commonjs/Markdown.nitro.js.map +1 -0
  23. package/lib/commonjs/MarkdownContext.js +17 -0
  24. package/lib/commonjs/MarkdownContext.js.map +1 -0
  25. package/lib/commonjs/MarkdownSession.js +11 -0
  26. package/lib/commonjs/MarkdownSession.js.map +1 -0
  27. package/lib/commonjs/default-markdown-renderer.js +217 -0
  28. package/lib/commonjs/default-markdown-renderer.js.map +1 -0
  29. package/lib/commonjs/headless.js +98 -0
  30. package/lib/commonjs/headless.js.map +1 -0
  31. package/lib/commonjs/index.js +226 -0
  32. package/lib/commonjs/index.js.map +1 -0
  33. package/lib/commonjs/markdown-stream.js +32 -0
  34. package/lib/commonjs/markdown-stream.js.map +1 -0
  35. package/lib/commonjs/markdown.js +385 -0
  36. package/lib/commonjs/markdown.js.map +1 -0
  37. package/lib/commonjs/package.json +1 -0
  38. package/lib/commonjs/renderers/blockquote.js +36 -0
  39. package/lib/commonjs/renderers/blockquote.js.map +1 -0
  40. package/lib/commonjs/renderers/code.js +99 -0
  41. package/lib/commonjs/renderers/code.js.map +1 -0
  42. package/lib/commonjs/renderers/heading.js +63 -0
  43. package/lib/commonjs/renderers/heading.js.map +1 -0
  44. package/lib/commonjs/renderers/horizontal-rule.js +29 -0
  45. package/lib/commonjs/renderers/horizontal-rule.js.map +1 -0
  46. package/lib/commonjs/renderers/image.js +184 -0
  47. package/lib/commonjs/renderers/image.js.map +1 -0
  48. package/lib/commonjs/renderers/link.js +35 -0
  49. package/lib/commonjs/renderers/link.js.map +1 -0
  50. package/lib/commonjs/renderers/list.js +114 -0
  51. package/lib/commonjs/renderers/list.js.map +1 -0
  52. package/lib/commonjs/renderers/math.js +137 -0
  53. package/lib/commonjs/renderers/math.js.map +1 -0
  54. package/lib/commonjs/renderers/paragraph.js +37 -0
  55. package/lib/commonjs/renderers/paragraph.js.map +1 -0
  56. package/lib/commonjs/renderers/table.js +290 -0
  57. package/lib/commonjs/renderers/table.js.map +1 -0
  58. package/lib/commonjs/specs/MarkdownSession.nitro.js +6 -0
  59. package/lib/commonjs/specs/MarkdownSession.nitro.js.map +1 -0
  60. package/lib/commonjs/theme.js +191 -0
  61. package/lib/commonjs/theme.js.map +1 -0
  62. package/lib/commonjs/use-markdown-stream.js +71 -0
  63. package/lib/commonjs/use-markdown-stream.js.map +1 -0
  64. package/lib/module/Markdown.nitro.js +4 -0
  65. package/lib/module/Markdown.nitro.js.map +1 -0
  66. package/lib/module/MarkdownContext.js +12 -0
  67. package/lib/module/MarkdownContext.js.map +1 -0
  68. package/lib/module/MarkdownSession.js +7 -0
  69. package/lib/module/MarkdownSession.js.map +1 -0
  70. package/lib/module/default-markdown-renderer.js +212 -0
  71. package/lib/module/default-markdown-renderer.js.map +1 -0
  72. package/lib/module/headless.js +90 -0
  73. package/lib/module/headless.js.map +1 -0
  74. package/lib/module/index.js +21 -0
  75. package/lib/module/index.js.map +1 -0
  76. package/lib/module/markdown-stream.js +27 -0
  77. package/lib/module/markdown-stream.js.map +1 -0
  78. package/lib/module/markdown.js +380 -0
  79. package/lib/module/markdown.js.map +1 -0
  80. package/lib/module/package.json +1 -0
  81. package/lib/module/renderers/blockquote.js +31 -0
  82. package/lib/module/renderers/blockquote.js.map +1 -0
  83. package/lib/module/renderers/code.js +93 -0
  84. package/lib/module/renderers/code.js.map +1 -0
  85. package/lib/module/renderers/heading.js +58 -0
  86. package/lib/module/renderers/heading.js.map +1 -0
  87. package/lib/module/renderers/horizontal-rule.js +24 -0
  88. package/lib/module/renderers/horizontal-rule.js.map +1 -0
  89. package/lib/module/renderers/image.js +179 -0
  90. package/lib/module/renderers/image.js.map +1 -0
  91. package/lib/module/renderers/link.js +30 -0
  92. package/lib/module/renderers/link.js.map +1 -0
  93. package/lib/module/renderers/list.js +107 -0
  94. package/lib/module/renderers/list.js.map +1 -0
  95. package/lib/module/renderers/math.js +131 -0
  96. package/lib/module/renderers/math.js.map +1 -0
  97. package/lib/module/renderers/paragraph.js +32 -0
  98. package/lib/module/renderers/paragraph.js.map +1 -0
  99. package/lib/module/renderers/table.js +285 -0
  100. package/lib/module/renderers/table.js.map +1 -0
  101. package/lib/module/specs/MarkdownSession.nitro.js +4 -0
  102. package/lib/module/specs/MarkdownSession.nitro.js.map +1 -0
  103. package/lib/module/theme.js +186 -0
  104. package/lib/module/theme.js.map +1 -0
  105. package/lib/module/use-markdown-stream.js +66 -0
  106. package/lib/module/use-markdown-stream.js.map +1 -0
  107. package/lib/typescript/commonjs/Markdown.nitro.d.ts +13 -0
  108. package/lib/typescript/commonjs/Markdown.nitro.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/MarkdownContext.d.ts +65 -0
  110. package/lib/typescript/commonjs/MarkdownContext.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/MarkdownSession.d.ts +4 -0
  112. package/lib/typescript/commonjs/MarkdownSession.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/default-markdown-renderer.d.ts +10 -0
  114. package/lib/typescript/commonjs/default-markdown-renderer.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/headless.d.ts +61 -0
  116. package/lib/typescript/commonjs/headless.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/index.d.ts +22 -0
  118. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/markdown-stream.d.ts +15 -0
  120. package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/markdown.d.ts +60 -0
  122. package/lib/typescript/commonjs/markdown.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/package.json +1 -0
  124. package/lib/typescript/commonjs/renderers/blockquote.d.ts +9 -0
  125. package/lib/typescript/commonjs/renderers/blockquote.d.ts.map +1 -0
  126. package/lib/typescript/commonjs/renderers/code.d.ts +19 -0
  127. package/lib/typescript/commonjs/renderers/code.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/renderers/heading.d.ts +10 -0
  129. package/lib/typescript/commonjs/renderers/heading.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts +8 -0
  131. package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/renderers/image.d.ts +13 -0
  133. package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/renderers/link.d.ts +10 -0
  135. package/lib/typescript/commonjs/renderers/link.d.ts.map +1 -0
  136. package/lib/typescript/commonjs/renderers/list.d.ts +26 -0
  137. package/lib/typescript/commonjs/renderers/list.d.ts.map +1 -0
  138. package/lib/typescript/commonjs/renderers/math.d.ts +14 -0
  139. package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/renderers/paragraph.d.ts +10 -0
  141. package/lib/typescript/commonjs/renderers/paragraph.d.ts.map +1 -0
  142. package/lib/typescript/commonjs/renderers/table.d.ts +12 -0
  143. package/lib/typescript/commonjs/renderers/table.d.ts.map +1 -0
  144. package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts +12 -0
  145. package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/theme.d.ts +65 -0
  147. package/lib/typescript/commonjs/theme.d.ts.map +1 -0
  148. package/lib/typescript/commonjs/use-markdown-stream.d.ts +22 -0
  149. package/lib/typescript/commonjs/use-markdown-stream.d.ts.map +1 -0
  150. package/lib/typescript/module/Markdown.nitro.d.ts +13 -0
  151. package/lib/typescript/module/Markdown.nitro.d.ts.map +1 -0
  152. package/lib/typescript/module/MarkdownContext.d.ts +65 -0
  153. package/lib/typescript/module/MarkdownContext.d.ts.map +1 -0
  154. package/lib/typescript/module/MarkdownSession.d.ts +4 -0
  155. package/lib/typescript/module/MarkdownSession.d.ts.map +1 -0
  156. package/lib/typescript/module/default-markdown-renderer.d.ts +10 -0
  157. package/lib/typescript/module/default-markdown-renderer.d.ts.map +1 -0
  158. package/lib/typescript/module/headless.d.ts +61 -0
  159. package/lib/typescript/module/headless.d.ts.map +1 -0
  160. package/lib/typescript/module/index.d.ts +22 -0
  161. package/lib/typescript/module/index.d.ts.map +1 -0
  162. package/lib/typescript/module/markdown-stream.d.ts +15 -0
  163. package/lib/typescript/module/markdown-stream.d.ts.map +1 -0
  164. package/lib/typescript/module/markdown.d.ts +60 -0
  165. package/lib/typescript/module/markdown.d.ts.map +1 -0
  166. package/lib/typescript/module/package.json +1 -0
  167. package/lib/typescript/module/renderers/blockquote.d.ts +9 -0
  168. package/lib/typescript/module/renderers/blockquote.d.ts.map +1 -0
  169. package/lib/typescript/module/renderers/code.d.ts +19 -0
  170. package/lib/typescript/module/renderers/code.d.ts.map +1 -0
  171. package/lib/typescript/module/renderers/heading.d.ts +10 -0
  172. package/lib/typescript/module/renderers/heading.d.ts.map +1 -0
  173. package/lib/typescript/module/renderers/horizontal-rule.d.ts +8 -0
  174. package/lib/typescript/module/renderers/horizontal-rule.d.ts.map +1 -0
  175. package/lib/typescript/module/renderers/image.d.ts +13 -0
  176. package/lib/typescript/module/renderers/image.d.ts.map +1 -0
  177. package/lib/typescript/module/renderers/link.d.ts +10 -0
  178. package/lib/typescript/module/renderers/link.d.ts.map +1 -0
  179. package/lib/typescript/module/renderers/list.d.ts +26 -0
  180. package/lib/typescript/module/renderers/list.d.ts.map +1 -0
  181. package/lib/typescript/module/renderers/math.d.ts +14 -0
  182. package/lib/typescript/module/renderers/math.d.ts.map +1 -0
  183. package/lib/typescript/module/renderers/paragraph.d.ts +10 -0
  184. package/lib/typescript/module/renderers/paragraph.d.ts.map +1 -0
  185. package/lib/typescript/module/renderers/table.d.ts +12 -0
  186. package/lib/typescript/module/renderers/table.d.ts.map +1 -0
  187. package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts +12 -0
  188. package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts.map +1 -0
  189. package/lib/typescript/module/theme.d.ts +65 -0
  190. package/lib/typescript/module/theme.d.ts.map +1 -0
  191. package/lib/typescript/module/use-markdown-stream.d.ts +22 -0
  192. package/lib/typescript/module/use-markdown-stream.d.ts.map +1 -0
  193. package/nitro.json +19 -0
  194. package/nitrogen/generated/.gitattributes +1 -0
  195. package/nitrogen/generated/android/NitroMarkdown+autolinking.cmake +82 -0
  196. package/nitrogen/generated/android/NitroMarkdown+autolinking.gradle +27 -0
  197. package/nitrogen/generated/android/NitroMarkdownOnLoad.cpp +56 -0
  198. package/nitrogen/generated/android/NitroMarkdownOnLoad.hpp +25 -0
  199. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  200. package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.cpp +91 -0
  201. package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.hpp +70 -0
  202. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/Func_void.kt +80 -0
  203. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSessionSpec.kt +78 -0
  204. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/NitroMarkdownOnLoad.kt +35 -0
  205. package/nitrogen/generated/ios/NitroMarkdown+autolinking.rb +60 -0
  206. package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.cpp +41 -0
  207. package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.hpp +93 -0
  208. package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Umbrella.hpp +45 -0
  209. package/nitrogen/generated/ios/NitroMarkdownAutolinking.mm +43 -0
  210. package/nitrogen/generated/ios/NitroMarkdownAutolinking.swift +26 -0
  211. package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.cpp +11 -0
  212. package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.hpp +108 -0
  213. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  214. package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec.swift +59 -0
  215. package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec_cxx.swift +190 -0
  216. package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.cpp +22 -0
  217. package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.hpp +65 -0
  218. package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.cpp +26 -0
  219. package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.hpp +67 -0
  220. package/nitrogen/generated/shared/c++/ParserOptions.hpp +87 -0
  221. package/package.json +134 -0
  222. package/react-native-nitro-markdown.podspec +42 -0
  223. package/src/Markdown.nitro.ts +12 -0
  224. package/src/MarkdownContext.ts +98 -0
  225. package/src/MarkdownSession.ts +8 -0
  226. package/src/default-markdown-renderer.tsx +261 -0
  227. package/src/headless.ts +171 -0
  228. package/src/index.ts +52 -0
  229. package/src/markdown-stream.tsx +32 -0
  230. package/src/markdown.tsx +521 -0
  231. package/src/renderers/blockquote.tsx +30 -0
  232. package/src/renderers/code.tsx +112 -0
  233. package/src/renderers/heading.tsx +66 -0
  234. package/src/renderers/horizontal-rule.tsx +23 -0
  235. package/src/renderers/image.tsx +204 -0
  236. package/src/renderers/link.tsx +33 -0
  237. package/src/renderers/list.tsx +123 -0
  238. package/src/renderers/math.tsx +147 -0
  239. package/src/renderers/paragraph.tsx +45 -0
  240. package/src/renderers/table.tsx +370 -0
  241. package/src/specs/MarkdownSession.nitro.ts +14 -0
  242. package/src/theme.ts +243 -0
  243. package/src/use-markdown-stream.ts +83 -0
@@ -0,0 +1,93 @@
1
+ ///
2
+ /// NitroMarkdown-Swift-Cxx-Bridge.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
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridMarkdownSessionSpec` to properly resolve imports.
12
+ namespace margelo::nitro::Markdown { class HybridMarkdownSessionSpec; }
13
+
14
+ // Forward declarations of Swift defined types
15
+ // Forward declaration of `HybridMarkdownSessionSpec_cxx` to properly resolve imports.
16
+ namespace NitroMarkdown { class HybridMarkdownSessionSpec_cxx; }
17
+
18
+ // Include C++ defined types
19
+ #include "HybridMarkdownSessionSpec.hpp"
20
+ #include <NitroModules/Result.hpp>
21
+ #include <exception>
22
+ #include <functional>
23
+ #include <memory>
24
+ #include <string>
25
+
26
+ /**
27
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
28
+ * as well as helper functions to interact with those C++ types from Swift.
29
+ */
30
+ namespace margelo::nitro::Markdown::bridge::swift {
31
+
32
+ // pragma MARK: std::function<void()>
33
+ /**
34
+ * Specialized version of `std::function<void()>`.
35
+ */
36
+ using Func_void = std::function<void()>;
37
+ /**
38
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
39
+ */
40
+ class Func_void_Wrapper final {
41
+ public:
42
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
43
+ inline void call() const noexcept {
44
+ _function->operator()();
45
+ }
46
+ private:
47
+ std::unique_ptr<std::function<void()>> _function;
48
+ } SWIFT_NONCOPYABLE;
49
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
50
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
51
+ return Func_void_Wrapper(std::move(value));
52
+ }
53
+
54
+ // pragma MARK: std::shared_ptr<HybridMarkdownSessionSpec>
55
+ /**
56
+ * Specialized version of `std::shared_ptr<HybridMarkdownSessionSpec>`.
57
+ */
58
+ using std__shared_ptr_HybridMarkdownSessionSpec_ = std::shared_ptr<HybridMarkdownSessionSpec>;
59
+ std::shared_ptr<HybridMarkdownSessionSpec> create_std__shared_ptr_HybridMarkdownSessionSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
60
+ void* NON_NULL get_std__shared_ptr_HybridMarkdownSessionSpec_(std__shared_ptr_HybridMarkdownSessionSpec_ cppType);
61
+
62
+ // pragma MARK: std::weak_ptr<HybridMarkdownSessionSpec>
63
+ using std__weak_ptr_HybridMarkdownSessionSpec_ = std::weak_ptr<HybridMarkdownSessionSpec>;
64
+ inline std__weak_ptr_HybridMarkdownSessionSpec_ weakify_std__shared_ptr_HybridMarkdownSessionSpec_(const std::shared_ptr<HybridMarkdownSessionSpec>& strong) noexcept { return strong; }
65
+
66
+ // pragma MARK: Result<void>
67
+ using Result_void_ = Result<void>;
68
+ inline Result_void_ create_Result_void_() noexcept {
69
+ return Result<void>::withValue();
70
+ }
71
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
72
+ return Result<void>::withError(error);
73
+ }
74
+
75
+ // pragma MARK: Result<std::string>
76
+ using Result_std__string_ = Result<std::string>;
77
+ inline Result_std__string_ create_Result_std__string_(const std::string& value) noexcept {
78
+ return Result<std::string>::withValue(value);
79
+ }
80
+ inline Result_std__string_ create_Result_std__string_(const std::exception_ptr& error) noexcept {
81
+ return Result<std::string>::withError(error);
82
+ }
83
+
84
+ // pragma MARK: Result<std::function<void()>>
85
+ using Result_std__function_void____ = Result<std::function<void()>>;
86
+ inline Result_std__function_void____ create_Result_std__function_void____(const std::function<void()>& value) noexcept {
87
+ return Result<std::function<void()>>::withValue(value);
88
+ }
89
+ inline Result_std__function_void____ create_Result_std__function_void____(const std::exception_ptr& error) noexcept {
90
+ return Result<std::function<void()>>::withError(error);
91
+ }
92
+
93
+ } // namespace margelo::nitro::Markdown::bridge::swift
@@ -0,0 +1,45 @@
1
+ ///
2
+ /// NitroMarkdown-Swift-Cxx-Umbrella.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
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridMarkdownSessionSpec` to properly resolve imports.
12
+ namespace margelo::nitro::Markdown { class HybridMarkdownSessionSpec; }
13
+
14
+ // Include C++ defined types
15
+ #include "HybridMarkdownSessionSpec.hpp"
16
+ #include <NitroModules/Result.hpp>
17
+ #include <exception>
18
+ #include <functional>
19
+ #include <memory>
20
+ #include <string>
21
+
22
+ // C++ helpers for Swift
23
+ #include "NitroMarkdown-Swift-Cxx-Bridge.hpp"
24
+
25
+ // Common C++ types used in Swift
26
+ #include <NitroModules/ArrayBufferHolder.hpp>
27
+ #include <NitroModules/AnyMapUtils.hpp>
28
+ #include <NitroModules/RuntimeError.hpp>
29
+ #include <NitroModules/DateToChronoDate.hpp>
30
+
31
+ // Forward declarations of Swift defined types
32
+ // Forward declaration of `HybridMarkdownSessionSpec_cxx` to properly resolve imports.
33
+ namespace NitroMarkdown { class HybridMarkdownSessionSpec_cxx; }
34
+
35
+ // Include Swift defined types
36
+ #if __has_include("NitroMarkdown-Swift.h")
37
+ // This header is generated by Xcode/Swift on every app build.
38
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroMarkdown".
39
+ #include "NitroMarkdown-Swift.h"
40
+ // Same as above, but used when building with frameworks (`use_frameworks`)
41
+ #elif __has_include(<NitroMarkdown/NitroMarkdown-Swift.h>)
42
+ #include <NitroMarkdown/NitroMarkdown-Swift.h>
43
+ #else
44
+ #error NitroMarkdown's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroMarkdown", and try building the app first.
45
+ #endif
@@ -0,0 +1,43 @@
1
+ ///
2
+ /// NitroMarkdownAutolinking.mm
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 <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "NitroMarkdown-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridMarkdownParser.hpp"
14
+ #include "HybridMarkdownSessionSpecSwift.hpp"
15
+
16
+ @interface NitroMarkdownAutolinking : NSObject
17
+ @end
18
+
19
+ @implementation NitroMarkdownAutolinking
20
+
21
+ + (void) load {
22
+ using namespace margelo::nitro;
23
+ using namespace margelo::nitro::Markdown;
24
+
25
+ HybridObjectRegistry::registerHybridObjectConstructor(
26
+ "MarkdownParser",
27
+ []() -> std::shared_ptr<HybridObject> {
28
+ static_assert(std::is_default_constructible_v<HybridMarkdownParser>,
29
+ "The HybridObject \"HybridMarkdownParser\" is not default-constructible! "
30
+ "Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
31
+ return std::make_shared<HybridMarkdownParser>();
32
+ }
33
+ );
34
+ HybridObjectRegistry::registerHybridObjectConstructor(
35
+ "MarkdownSession",
36
+ []() -> std::shared_ptr<HybridObject> {
37
+ std::shared_ptr<HybridMarkdownSessionSpec> hybridObject = NitroMarkdown::NitroMarkdownAutolinking::createMarkdownSession();
38
+ return hybridObject;
39
+ }
40
+ );
41
+ }
42
+
43
+ @end
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// NitroMarkdownAutolinking.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
+ // TODO: Use empty enums once Swift supports exporting them as namespaces
11
+ // See: https://github.com/swiftlang/swift/pull/83616
12
+ public final class NitroMarkdownAutolinking {
13
+ public typealias bridge = margelo.nitro.Markdown.bridge.swift
14
+
15
+ public static func createMarkdownSession() -> bridge.std__shared_ptr_HybridMarkdownSessionSpec_ {
16
+ let hybridObject = HybridMarkdownSession()
17
+ return { () -> bridge.std__shared_ptr_HybridMarkdownSessionSpec_ in
18
+ let __cxxWrapped = hybridObject.getCxxWrapper()
19
+ return __cxxWrapped.getCxxPart()
20
+ }()
21
+ }
22
+
23
+ public static func isMarkdownSessionRecyclable() -> Bool {
24
+ return HybridMarkdownSession.self is any RecyclableView.Type
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridMarkdownSessionSpecSwift.cpp
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
+ #include "HybridMarkdownSessionSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::Markdown {
11
+ } // namespace margelo::nitro::Markdown
@@ -0,0 +1,108 @@
1
+ ///
2
+ /// HybridMarkdownSessionSpecSwift.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 "HybridMarkdownSessionSpec.hpp"
11
+
12
+ // Forward declaration of `HybridMarkdownSessionSpec_cxx` to properly resolve imports.
13
+ namespace NitroMarkdown { class HybridMarkdownSessionSpec_cxx; }
14
+
15
+
16
+
17
+ #include <string>
18
+ #include <functional>
19
+
20
+ #include "NitroMarkdown-Swift-Cxx-Umbrella.hpp"
21
+
22
+ namespace margelo::nitro::Markdown {
23
+
24
+ /**
25
+ * The C++ part of HybridMarkdownSessionSpec_cxx.swift.
26
+ *
27
+ * HybridMarkdownSessionSpecSwift (C++) accesses HybridMarkdownSessionSpec_cxx (Swift), and might
28
+ * contain some additional bridging code for C++ <> Swift interop.
29
+ *
30
+ * Since this obviously introduces an overhead, I hope at some point in
31
+ * the future, HybridMarkdownSessionSpec_cxx can directly inherit from the C++ class HybridMarkdownSessionSpec
32
+ * to simplify the whole structure and memory management.
33
+ */
34
+ class HybridMarkdownSessionSpecSwift: public virtual HybridMarkdownSessionSpec {
35
+ public:
36
+ // Constructor from a Swift instance
37
+ explicit HybridMarkdownSessionSpecSwift(const NitroMarkdown::HybridMarkdownSessionSpec_cxx& swiftPart):
38
+ HybridObject(HybridMarkdownSessionSpec::TAG),
39
+ _swiftPart(swiftPart) { }
40
+
41
+ public:
42
+ // Get the Swift part
43
+ inline NitroMarkdown::HybridMarkdownSessionSpec_cxx& getSwiftPart() noexcept {
44
+ return _swiftPart;
45
+ }
46
+
47
+ public:
48
+ inline size_t getExternalMemorySize() noexcept override {
49
+ return _swiftPart.getMemorySize();
50
+ }
51
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
52
+ if (auto otherCast = std::dynamic_pointer_cast<HybridMarkdownSessionSpecSwift>(other)) {
53
+ return _swiftPart.equals(otherCast->_swiftPart);
54
+ }
55
+ return false;
56
+ }
57
+ void dispose() noexcept override {
58
+ _swiftPart.dispose();
59
+ }
60
+ std::string toString() override {
61
+ return _swiftPart.toString();
62
+ }
63
+
64
+ public:
65
+ // Properties
66
+ inline double getHighlightPosition() noexcept override {
67
+ return _swiftPart.getHighlightPosition();
68
+ }
69
+ inline void setHighlightPosition(double highlightPosition) noexcept override {
70
+ _swiftPart.setHighlightPosition(std::forward<decltype(highlightPosition)>(highlightPosition));
71
+ }
72
+
73
+ public:
74
+ // Methods
75
+ inline void append(const std::string& chunk) override {
76
+ auto __result = _swiftPart.append(chunk);
77
+ if (__result.hasError()) [[unlikely]] {
78
+ std::rethrow_exception(__result.error());
79
+ }
80
+ }
81
+ inline void clear() override {
82
+ auto __result = _swiftPart.clear();
83
+ if (__result.hasError()) [[unlikely]] {
84
+ std::rethrow_exception(__result.error());
85
+ }
86
+ }
87
+ inline std::string getAllText() override {
88
+ auto __result = _swiftPart.getAllText();
89
+ if (__result.hasError()) [[unlikely]] {
90
+ std::rethrow_exception(__result.error());
91
+ }
92
+ auto __value = std::move(__result.value());
93
+ return __value;
94
+ }
95
+ inline std::function<void()> addListener(const std::function<void()>& listener) override {
96
+ auto __result = _swiftPart.addListener(listener);
97
+ if (__result.hasError()) [[unlikely]] {
98
+ std::rethrow_exception(__result.error());
99
+ }
100
+ auto __value = std::move(__result.value());
101
+ return __value;
102
+ }
103
+
104
+ private:
105
+ NitroMarkdown::HybridMarkdownSessionSpec_cxx _swiftPart;
106
+ };
107
+
108
+ } // namespace margelo::nitro::Markdown
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void.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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `() -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void {
16
+ public typealias bridge = margelo.nitro.Markdown.bridge.swift
17
+
18
+ private let closure: () -> Void
19
+
20
+ public init(_ closure: @escaping () -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call() -> Void {
26
+ self.closure()
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
45
+ return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,59 @@
1
+ ///
2
+ /// HybridMarkdownSessionSpec.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 Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridMarkdownSessionSpec``
12
+ public protocol HybridMarkdownSessionSpec_protocol: HybridObject {
13
+ // Properties
14
+ var highlightPosition: Double { get set }
15
+
16
+ // Methods
17
+ func append(chunk: String) throws -> Void
18
+ func clear() throws -> Void
19
+ func getAllText() throws -> String
20
+ func addListener(listener: @escaping () -> Void) throws -> () -> Void
21
+ }
22
+
23
+ public extension HybridMarkdownSessionSpec_protocol {
24
+ /// Default implementation of ``HybridObject.toString``
25
+ func toString() -> String {
26
+ return "[HybridObject MarkdownSession]"
27
+ }
28
+ }
29
+
30
+ /// See ``HybridMarkdownSessionSpec``
31
+ open class HybridMarkdownSessionSpec_base {
32
+ private weak var cxxWrapper: HybridMarkdownSessionSpec_cxx? = nil
33
+ public init() { }
34
+ public func getCxxWrapper() -> HybridMarkdownSessionSpec_cxx {
35
+ #if DEBUG
36
+ guard self is any HybridMarkdownSessionSpec else {
37
+ fatalError("`self` is not a `HybridMarkdownSessionSpec`! Did you accidentally inherit from `HybridMarkdownSessionSpec_base` instead of `HybridMarkdownSessionSpec`?")
38
+ }
39
+ #endif
40
+ if let cxxWrapper = self.cxxWrapper {
41
+ return cxxWrapper
42
+ } else {
43
+ let cxxWrapper = HybridMarkdownSessionSpec_cxx(self as! any HybridMarkdownSessionSpec)
44
+ self.cxxWrapper = cxxWrapper
45
+ return cxxWrapper
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * A Swift base-protocol representing the MarkdownSession HybridObject.
52
+ * Implement this protocol to create Swift-based instances of MarkdownSession.
53
+ * ```swift
54
+ * class HybridMarkdownSession : HybridMarkdownSessionSpec {
55
+ * // ...
56
+ * }
57
+ * ```
58
+ */
59
+ public typealias HybridMarkdownSessionSpec = HybridMarkdownSessionSpec_protocol & HybridMarkdownSessionSpec_base
@@ -0,0 +1,190 @@
1
+ ///
2
+ /// HybridMarkdownSessionSpec_cxx.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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridMarkdownSessionSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridMarkdownSessionSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::Markdown::bridge::swift`)
23
+ * from `NitroMarkdown-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.Markdown.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridMarkdownSessionSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridMarkdownSessionSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridMarkdownSessionSpec_
37
+
38
+ /**
39
+ * Create a new `HybridMarkdownSessionSpec_cxx` that wraps the given `HybridMarkdownSessionSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridMarkdownSessionSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridMarkdownSessionSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridMarkdownSessionSpec() -> any HybridMarkdownSessionSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridMarkdownSessionSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridMarkdownSessionSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridMarkdownSessionSpec_cxx {
70
+ return Unmanaged<HybridMarkdownSessionSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridMarkdownSessionSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridMarkdownSessionSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridMarkdownSessionSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridMarkdownSessionSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Compares this object with the given [other] object for reference equality.
101
+ */
102
+ @inline(__always)
103
+ public func equals(other: HybridMarkdownSessionSpec_cxx) -> Bool {
104
+ return self.__implementation === other.__implementation
105
+ }
106
+
107
+ /**
108
+ * Call dispose() on the Swift class.
109
+ * This _may_ be called manually from JS.
110
+ */
111
+ @inline(__always)
112
+ public func dispose() {
113
+ self.__implementation.dispose()
114
+ }
115
+
116
+ /**
117
+ * Call toString() on the Swift class.
118
+ */
119
+ @inline(__always)
120
+ public func toString() -> String {
121
+ return self.__implementation.toString()
122
+ }
123
+
124
+ // Properties
125
+ public final var highlightPosition: Double {
126
+ @inline(__always)
127
+ get {
128
+ return self.__implementation.highlightPosition
129
+ }
130
+ @inline(__always)
131
+ set {
132
+ self.__implementation.highlightPosition = newValue
133
+ }
134
+ }
135
+
136
+ // Methods
137
+ @inline(__always)
138
+ public final func append(chunk: std.string) -> bridge.Result_void_ {
139
+ do {
140
+ try self.__implementation.append(chunk: String(chunk))
141
+ return bridge.create_Result_void_()
142
+ } catch (let __error) {
143
+ let __exceptionPtr = __error.toCpp()
144
+ return bridge.create_Result_void_(__exceptionPtr)
145
+ }
146
+ }
147
+
148
+ @inline(__always)
149
+ public final func clear() -> bridge.Result_void_ {
150
+ do {
151
+ try self.__implementation.clear()
152
+ return bridge.create_Result_void_()
153
+ } catch (let __error) {
154
+ let __exceptionPtr = __error.toCpp()
155
+ return bridge.create_Result_void_(__exceptionPtr)
156
+ }
157
+ }
158
+
159
+ @inline(__always)
160
+ public final func getAllText() -> bridge.Result_std__string_ {
161
+ do {
162
+ let __result = try self.__implementation.getAllText()
163
+ let __resultCpp = std.string(__result)
164
+ return bridge.create_Result_std__string_(__resultCpp)
165
+ } catch (let __error) {
166
+ let __exceptionPtr = __error.toCpp()
167
+ return bridge.create_Result_std__string_(__exceptionPtr)
168
+ }
169
+ }
170
+
171
+ @inline(__always)
172
+ public final func addListener(listener: bridge.Func_void) -> bridge.Result_std__function_void____ {
173
+ do {
174
+ let __result = try self.__implementation.addListener(listener: { () -> () -> Void in
175
+ let __wrappedFunction = bridge.wrap_Func_void(listener)
176
+ return { () -> Void in
177
+ __wrappedFunction.call()
178
+ }
179
+ }())
180
+ let __resultCpp = { () -> bridge.Func_void in
181
+ let __closureWrapper = Func_void(__result)
182
+ return bridge.create_Func_void(__closureWrapper.toUnsafe())
183
+ }()
184
+ return bridge.create_Result_std__function_void____(__resultCpp)
185
+ } catch (let __error) {
186
+ let __exceptionPtr = __error.toCpp()
187
+ return bridge.create_Result_std__function_void____(__exceptionPtr)
188
+ }
189
+ }
190
+ }
@@ -0,0 +1,22 @@
1
+ ///
2
+ /// HybridMarkdownParserSpec.cpp
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
+ #include "HybridMarkdownParserSpec.hpp"
9
+
10
+ namespace margelo::nitro::Markdown {
11
+
12
+ void HybridMarkdownParserSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("parse", &HybridMarkdownParserSpec::parse);
18
+ prototype.registerHybridMethod("parseWithOptions", &HybridMarkdownParserSpec::parseWithOptions);
19
+ });
20
+ }
21
+
22
+ } // namespace margelo::nitro::Markdown