react-native-nitro-markdown 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +142 -84
- package/android/src/main/cpp/cpp-adapter.cpp +1 -1
- package/android/src/main/java/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSession.kt +61 -0
- package/android/src/main/java/com/nitromarkdown/NitroMarkdownPackage.kt +5 -1
- package/cpp/bindings/HybridMarkdownParser.cpp +2 -2
- package/cpp/bindings/HybridMarkdownParser.hpp +2 -2
- package/cpp/bindings/HybridMarkdownSession.cpp +0 -0
- package/cpp/core/MarkdownSessionCore.cpp +0 -0
- package/ios/HybridMarkdownSession.swift +64 -0
- package/lib/commonjs/MarkdownContext.js +21 -0
- package/lib/commonjs/MarkdownContext.js.map +1 -0
- package/lib/commonjs/MarkdownSession.js +11 -0
- package/lib/commonjs/MarkdownSession.js.map +1 -0
- package/lib/commonjs/default-markdown-renderer.js +220 -0
- package/lib/commonjs/default-markdown-renderer.js.map +1 -0
- package/lib/commonjs/headless.js +50 -0
- package/lib/commonjs/headless.js.map +1 -0
- package/lib/commonjs/index.js +185 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/markdown-stream.js +32 -0
- package/lib/commonjs/markdown-stream.js.map +1 -0
- package/lib/commonjs/markdown.js +326 -0
- package/lib/commonjs/markdown.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/renderers/blockquote.js +36 -0
- package/lib/commonjs/renderers/blockquote.js.map +1 -0
- package/lib/commonjs/renderers/code.js +92 -0
- package/lib/commonjs/renderers/code.js.map +1 -0
- package/lib/commonjs/renderers/heading.js +62 -0
- package/lib/commonjs/renderers/heading.js.map +1 -0
- package/lib/commonjs/renderers/horizontal-rule.js +27 -0
- package/lib/commonjs/renderers/horizontal-rule.js.map +1 -0
- package/lib/commonjs/renderers/image.js +159 -0
- package/lib/commonjs/renderers/image.js.map +1 -0
- package/lib/commonjs/renderers/link.js +37 -0
- package/lib/commonjs/renderers/link.js.map +1 -0
- package/lib/commonjs/renderers/list.js +114 -0
- package/lib/commonjs/renderers/list.js.map +1 -0
- package/lib/commonjs/renderers/math.js +151 -0
- package/lib/commonjs/renderers/math.js.map +1 -0
- package/lib/commonjs/renderers/paragraph.js +44 -0
- package/lib/commonjs/renderers/paragraph.js.map +1 -0
- package/lib/commonjs/renderers/table.js +283 -0
- package/lib/commonjs/renderers/table.js.map +1 -0
- package/lib/commonjs/specs/MarkdownSession.nitro.js +6 -0
- package/lib/commonjs/specs/MarkdownSession.nitro.js.map +1 -0
- package/lib/commonjs/theme.js +58 -0
- package/lib/commonjs/theme.js.map +1 -0
- package/lib/commonjs/use-markdown-stream.js +71 -0
- package/lib/commonjs/use-markdown-stream.js.map +1 -0
- package/lib/module/MarkdownContext.js +17 -0
- package/lib/module/MarkdownContext.js.map +1 -0
- package/lib/module/MarkdownSession.js +7 -0
- package/lib/module/MarkdownSession.js.map +1 -0
- package/lib/module/default-markdown-renderer.js +215 -0
- package/lib/module/default-markdown-renderer.js.map +1 -0
- package/lib/module/headless.js +44 -0
- package/lib/module/headless.js.map +1 -0
- package/lib/module/index.js +36 -10
- package/lib/module/index.js.map +1 -1
- package/lib/module/markdown-stream.js +27 -0
- package/lib/module/markdown-stream.js.map +1 -0
- package/lib/module/markdown.js +321 -0
- package/lib/module/markdown.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/renderers/blockquote.js +31 -0
- package/lib/module/renderers/blockquote.js.map +1 -0
- package/lib/module/renderers/code.js +86 -0
- package/lib/module/renderers/code.js.map +1 -0
- package/lib/module/renderers/heading.js +57 -0
- package/lib/module/renderers/heading.js.map +1 -0
- package/lib/module/renderers/horizontal-rule.js +22 -0
- package/lib/module/renderers/horizontal-rule.js.map +1 -0
- package/lib/module/renderers/image.js +154 -0
- package/lib/module/renderers/image.js.map +1 -0
- package/lib/module/renderers/link.js +32 -0
- package/lib/module/renderers/link.js.map +1 -0
- package/lib/module/renderers/list.js +107 -0
- package/lib/module/renderers/list.js.map +1 -0
- package/lib/module/renderers/math.js +145 -0
- package/lib/module/renderers/math.js.map +1 -0
- package/lib/module/renderers/paragraph.js +39 -0
- package/lib/module/renderers/paragraph.js.map +1 -0
- package/lib/module/renderers/table.js +278 -0
- package/lib/module/renderers/table.js.map +1 -0
- package/lib/module/specs/MarkdownSession.nitro.js +4 -0
- package/lib/module/specs/MarkdownSession.nitro.js.map +1 -0
- package/lib/module/theme.js +54 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/use-markdown-stream.js +66 -0
- package/lib/module/use-markdown-stream.js.map +1 -0
- package/lib/typescript/commonjs/Markdown.nitro.d.ts.map +1 -0
- package/lib/typescript/commonjs/MarkdownContext.d.ts +26 -0
- package/lib/typescript/commonjs/MarkdownContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/MarkdownSession.d.ts +4 -0
- package/lib/typescript/commonjs/MarkdownSession.d.ts.map +1 -0
- package/lib/typescript/commonjs/default-markdown-renderer.d.ts +10 -0
- package/lib/typescript/commonjs/default-markdown-renderer.d.ts.map +1 -0
- package/lib/typescript/commonjs/headless.d.ts +50 -0
- package/lib/typescript/commonjs/headless.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +34 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/markdown-stream.d.ts +15 -0
- package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -0
- package/lib/typescript/commonjs/markdown.d.ts +29 -0
- package/lib/typescript/commonjs/markdown.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/renderers/blockquote.d.ts +9 -0
- package/lib/typescript/commonjs/renderers/blockquote.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/code.d.ts +15 -0
- package/lib/typescript/commonjs/renderers/code.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/heading.d.ts +10 -0
- package/lib/typescript/commonjs/renderers/heading.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts +3 -0
- package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/image.d.ts +11 -0
- package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/link.d.ts +10 -0
- package/lib/typescript/commonjs/renderers/link.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/list.d.ts +22 -0
- package/lib/typescript/commonjs/renderers/list.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/math.d.ts +15 -0
- package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/paragraph.d.ts +15 -0
- package/lib/typescript/commonjs/renderers/paragraph.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/table.d.ts +10 -0
- package/lib/typescript/commonjs/renderers/table.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts +12 -0
- package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme.d.ts +52 -0
- package/lib/typescript/commonjs/theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/use-markdown-stream.d.ts +22 -0
- package/lib/typescript/commonjs/use-markdown-stream.d.ts.map +1 -0
- package/lib/typescript/module/Markdown.nitro.d.ts +13 -0
- package/lib/typescript/module/Markdown.nitro.d.ts.map +1 -0
- package/lib/typescript/module/MarkdownContext.d.ts +26 -0
- package/lib/typescript/module/MarkdownContext.d.ts.map +1 -0
- package/lib/typescript/module/MarkdownSession.d.ts +4 -0
- package/lib/typescript/module/MarkdownSession.d.ts.map +1 -0
- package/lib/typescript/module/default-markdown-renderer.d.ts +10 -0
- package/lib/typescript/module/default-markdown-renderer.d.ts.map +1 -0
- package/lib/typescript/module/headless.d.ts +50 -0
- package/lib/typescript/module/headless.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +34 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/markdown-stream.d.ts +15 -0
- package/lib/typescript/module/markdown-stream.d.ts.map +1 -0
- package/lib/typescript/module/markdown.d.ts +29 -0
- package/lib/typescript/module/markdown.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/renderers/blockquote.d.ts +9 -0
- package/lib/typescript/module/renderers/blockquote.d.ts.map +1 -0
- package/lib/typescript/module/renderers/code.d.ts +15 -0
- package/lib/typescript/module/renderers/code.d.ts.map +1 -0
- package/lib/typescript/module/renderers/heading.d.ts +10 -0
- package/lib/typescript/module/renderers/heading.d.ts.map +1 -0
- package/lib/typescript/module/renderers/horizontal-rule.d.ts +3 -0
- package/lib/typescript/module/renderers/horizontal-rule.d.ts.map +1 -0
- package/lib/typescript/module/renderers/image.d.ts +11 -0
- package/lib/typescript/module/renderers/image.d.ts.map +1 -0
- package/lib/typescript/module/renderers/link.d.ts +10 -0
- package/lib/typescript/module/renderers/link.d.ts.map +1 -0
- package/lib/typescript/module/renderers/list.d.ts +22 -0
- package/lib/typescript/module/renderers/list.d.ts.map +1 -0
- package/lib/typescript/module/renderers/math.d.ts +15 -0
- package/lib/typescript/module/renderers/math.d.ts.map +1 -0
- package/lib/typescript/module/renderers/paragraph.d.ts +15 -0
- package/lib/typescript/module/renderers/paragraph.d.ts.map +1 -0
- package/lib/typescript/module/renderers/table.d.ts +10 -0
- package/lib/typescript/module/renderers/table.d.ts.map +1 -0
- package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts +12 -0
- package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts.map +1 -0
- package/lib/typescript/module/theme.d.ts +52 -0
- package/lib/typescript/module/theme.d.ts.map +1 -0
- package/lib/typescript/module/use-markdown-stream.d.ts +22 -0
- package/lib/typescript/module/use-markdown-stream.d.ts.map +1 -0
- package/nitro.json +5 -2
- package/nitrogen/generated/android/NitroMarkdown+autolinking.cmake +3 -2
- package/nitrogen/generated/android/NitroMarkdown+autolinking.gradle +1 -1
- package/nitrogen/generated/android/NitroMarkdownOnLoad.cpp +17 -5
- package/nitrogen/generated/android/NitroMarkdownOnLoad.hpp +4 -4
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.cpp +91 -0
- package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.hpp +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSessionSpec.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/NitroMarkdownOnLoad.kt +1 -1
- package/nitrogen/generated/ios/NitroMarkdown+autolinking.rb +2 -2
- package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.cpp +28 -4
- package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.hpp +72 -6
- package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Umbrella.hpp +11 -4
- package/nitrogen/generated/ios/NitroMarkdownAutolinking.mm +11 -3
- package/nitrogen/generated/ios/NitroMarkdownAutolinking.swift +16 -3
- package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.hpp +108 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec.swift +59 -0
- package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec_cxx.swift +190 -0
- package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.cpp +3 -3
- package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.hpp +4 -4
- package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/ParserOptions.hpp +22 -14
- package/package.json +45 -7
- package/react-native-nitro-markdown.podspec +5 -5
- package/src/MarkdownContext.ts +41 -0
- package/src/MarkdownSession.ts +8 -0
- package/src/default-markdown-renderer.tsx +266 -0
- package/src/headless.ts +106 -0
- package/src/index.ts +41 -59
- package/src/markdown-stream.tsx +32 -0
- package/src/markdown.tsx +415 -0
- package/src/renderers/blockquote.tsx +31 -0
- package/src/renderers/code.tsx +88 -0
- package/src/renderers/heading.tsx +66 -0
- package/src/renderers/horizontal-rule.tsx +20 -0
- package/src/renderers/image.tsx +160 -0
- package/src/renderers/link.tsx +38 -0
- package/src/renderers/list.tsx +125 -0
- package/src/renderers/math.tsx +164 -0
- package/src/renderers/paragraph.tsx +53 -0
- package/src/renderers/table.tsx +345 -0
- package/src/specs/MarkdownSession.nitro.ts +16 -0
- package/src/theme.ts +52 -0
- package/src/use-markdown-stream.ts +83 -0
- package/ios/NitroMarkdown-Bridging-Header.h +0 -14
- package/lib/commonjs/MarkdownJS.reference.js +0 -114
- package/lib/commonjs/MarkdownJS.reference.js.map +0 -1
- package/lib/module/MarkdownJS.reference.js +0 -107
- package/lib/module/MarkdownJS.reference.js.map +0 -1
- package/lib/typescript/Markdown.nitro.d.ts.map +0 -1
- package/lib/typescript/MarkdownJS.reference.d.ts +0 -33
- package/lib/typescript/MarkdownJS.reference.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -22
- package/lib/typescript/index.d.ts.map +0 -1
- package/src/MarkdownJS.reference.ts +0 -122
- /package/lib/typescript/{Markdown.nitro.d.ts → commonjs/Markdown.nitro.d.ts} +0 -0
|
@@ -0,0 +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;AAIpD,UAAU,SAAS;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAyB9B,CAAC;AAEF,UAAU,aAAa;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAsCtC,CAAC;AAEF,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAiC9C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
interface MathInlineProps {
|
|
3
|
+
content?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const MathInline: FC<MathInlineProps>;
|
|
6
|
+
interface MathBlockProps {
|
|
7
|
+
content?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Block math renderer.
|
|
11
|
+
* Uses react-native-mathjax-svg if installed, otherwise shows raw LaTeX.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MathBlock: FC<MathBlockProps>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +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;AA2B7D,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAuED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2B1C,CAAC;AAEF,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAyBxC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode, type FC } from "react";
|
|
2
|
+
import { type StyleProp, type ViewStyle } from "react-native";
|
|
3
|
+
interface ParagraphProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
inListItem?: boolean;
|
|
6
|
+
style?: StyleProp<ViewStyle>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Paragraph component that supports mixed content (Text and View elements).
|
|
10
|
+
* Uses View with flexDirection: 'row' and flexWrap: 'wrap' to allow inline flow
|
|
11
|
+
* of both text and non-text elements (like inline math).
|
|
12
|
+
*/
|
|
13
|
+
export declare const Paragraph: FC<ParagraphProps>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=paragraph.d.ts.map
|
|
@@ -0,0 +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;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAoCxC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type FC, type ComponentType } from "react";
|
|
2
|
+
import type { MarkdownNode } from "../headless";
|
|
3
|
+
import { type NodeRendererProps } from "../MarkdownContext";
|
|
4
|
+
interface TableRendererProps {
|
|
5
|
+
node: MarkdownNode;
|
|
6
|
+
Renderer: ComponentType<NodeRendererProps>;
|
|
7
|
+
}
|
|
8
|
+
export declare const TableRenderer: FC<TableRendererProps>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAUf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AA6ChF,UAAU,kBAAkB;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC5C;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAwKhD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HybridObject } from "react-native-nitro-modules";
|
|
2
|
+
export interface MarkdownSession extends HybridObject<{
|
|
3
|
+
ios: "swift";
|
|
4
|
+
android: "kotlin";
|
|
5
|
+
}> {
|
|
6
|
+
append(chunk: string): void;
|
|
7
|
+
clear(): void;
|
|
8
|
+
getAllText(): string;
|
|
9
|
+
highlightPosition: number;
|
|
10
|
+
addListener(listener: () => void): () => void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=MarkdownSession.nitro.d.ts.map
|
|
@@ -0,0 +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,eACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IAEzD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,IAAI,IAAI,CAAC;IACd,UAAU,IAAI,MAAM,CAAC;IAIrB,iBAAiB,EAAE,MAAM,CAAC;IAG1B,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC/C"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default theme configuration for the Markdown components.
|
|
3
|
+
* Optimized for a modern dark mode aesthetic.
|
|
4
|
+
*/
|
|
5
|
+
export declare const defaultMarkdownTheme: {
|
|
6
|
+
/** Colors used throughout the markdown renderer */
|
|
7
|
+
colors: {
|
|
8
|
+
text: string;
|
|
9
|
+
textMuted: string;
|
|
10
|
+
heading: string;
|
|
11
|
+
link: string;
|
|
12
|
+
code: string;
|
|
13
|
+
codeBackground: string;
|
|
14
|
+
blockquote: string;
|
|
15
|
+
border: string;
|
|
16
|
+
surface: string;
|
|
17
|
+
surfaceLight: string;
|
|
18
|
+
accent: string;
|
|
19
|
+
tableBorder: string;
|
|
20
|
+
tableHeader: string;
|
|
21
|
+
tableHeaderText: string;
|
|
22
|
+
tableRowEven: string;
|
|
23
|
+
tableRowOdd: string;
|
|
24
|
+
};
|
|
25
|
+
/** Standard spacing increments */
|
|
26
|
+
spacing: {
|
|
27
|
+
xs: number;
|
|
28
|
+
s: number;
|
|
29
|
+
m: number;
|
|
30
|
+
l: number;
|
|
31
|
+
xl: number;
|
|
32
|
+
};
|
|
33
|
+
/** Font sizes for different text elements */
|
|
34
|
+
fontSizes: {
|
|
35
|
+
xs: number;
|
|
36
|
+
s: number;
|
|
37
|
+
m: number;
|
|
38
|
+
l: number;
|
|
39
|
+
xl: number;
|
|
40
|
+
h1: number;
|
|
41
|
+
h2: number;
|
|
42
|
+
h3: number;
|
|
43
|
+
h4: number;
|
|
44
|
+
h5: number;
|
|
45
|
+
h6: number;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Type definition for the Markdown theme.
|
|
50
|
+
*/
|
|
51
|
+
export type MarkdownTheme = typeof defaultMarkdownTheme;
|
|
52
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB;IAC/B,mDAAmD;;;;;;;;;;;;;;;;;;;IAmBnD,kCAAkC;;;;;;;;IAQlC,6CAA6C;;;;;;;;;;;;;;CAc9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createMarkdownSession } from "./MarkdownSession";
|
|
2
|
+
export type MarkdownSession = ReturnType<typeof createMarkdownSession>;
|
|
3
|
+
export declare function useMarkdownSession(): {
|
|
4
|
+
getSession: () => import("./specs/MarkdownSession.nitro").MarkdownSession;
|
|
5
|
+
isStreaming: boolean;
|
|
6
|
+
setIsStreaming: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
7
|
+
stop: () => void;
|
|
8
|
+
clear: () => void;
|
|
9
|
+
setHighlight: (position: number) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function useStream(timestamps?: Record<number, number>): {
|
|
12
|
+
isPlaying: boolean;
|
|
13
|
+
setIsPlaying: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
14
|
+
sync: (currentTimeMs: number) => void;
|
|
15
|
+
getSession: () => import("./specs/MarkdownSession.nitro").MarkdownSession;
|
|
16
|
+
isStreaming: boolean;
|
|
17
|
+
setIsStreaming: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
18
|
+
stop: () => void;
|
|
19
|
+
clear: () => void;
|
|
20
|
+
setHighlight: (position: number) => void;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=use-markdown-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAE1D,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;;;0BAczC,MAAM;;;;;;6BA9BoB,MAAM;EAoDnD"}
|
package/nitro.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"cxxNamespace": ["
|
|
2
|
+
"cxxNamespace": ["Markdown"],
|
|
3
3
|
"ios": {
|
|
4
4
|
"iosModuleName": "NitroMarkdown"
|
|
5
5
|
},
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"autolinking": {
|
|
11
11
|
"MarkdownParser": {
|
|
12
12
|
"cpp": "HybridMarkdownParser"
|
|
13
|
+
},
|
|
14
|
+
"MarkdownSession": {
|
|
15
|
+
"swift": "HybridMarkdownSession",
|
|
16
|
+
"kotlin": "HybridMarkdownSession"
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
|
-
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# NitroMarkdown+autolinking.cmake
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright ©
|
|
5
|
+
# Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
# This is a CMake file that adds all files generated by Nitrogen
|
|
@@ -34,8 +34,9 @@ target_sources(
|
|
|
34
34
|
../nitrogen/generated/android/NitroMarkdownOnLoad.cpp
|
|
35
35
|
# Shared Nitrogen C++ sources
|
|
36
36
|
../nitrogen/generated/shared/c++/HybridMarkdownParserSpec.cpp
|
|
37
|
+
../nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.cpp
|
|
37
38
|
# Android-specific Nitrogen C++ sources
|
|
38
|
-
|
|
39
|
+
../nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.cpp
|
|
39
40
|
)
|
|
40
41
|
|
|
41
42
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroMarkdown+autolinking.gradle
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroMarkdownOnLoad.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#ifndef BUILDING_NITROMARKDOWN_WITH_GENERATED_CMAKE_PROJECT
|
|
@@ -15,18 +15,22 @@
|
|
|
15
15
|
#include <fbjni/fbjni.h>
|
|
16
16
|
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
17
|
|
|
18
|
+
#include "JHybridMarkdownSessionSpec.hpp"
|
|
19
|
+
#include "JFunc_void.hpp"
|
|
18
20
|
#include "HybridMarkdownParser.hpp"
|
|
21
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
19
22
|
|
|
20
|
-
namespace margelo::nitro::
|
|
23
|
+
namespace margelo::nitro::Markdown {
|
|
21
24
|
|
|
22
25
|
int initialize(JavaVM* vm) {
|
|
23
26
|
using namespace margelo::nitro;
|
|
24
|
-
using namespace margelo::nitro::
|
|
27
|
+
using namespace margelo::nitro::Markdown;
|
|
25
28
|
using namespace facebook;
|
|
26
29
|
|
|
27
30
|
return facebook::jni::initialize(vm, [] {
|
|
28
31
|
// Register native JNI methods
|
|
29
|
-
|
|
32
|
+
margelo::nitro::Markdown::JHybridMarkdownSessionSpec::registerNatives();
|
|
33
|
+
margelo::nitro::Markdown::JFunc_void_cxx::registerNatives();
|
|
30
34
|
|
|
31
35
|
// Register Nitro Hybrid Objects
|
|
32
36
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
@@ -38,7 +42,15 @@ int initialize(JavaVM* vm) {
|
|
|
38
42
|
return std::make_shared<HybridMarkdownParser>();
|
|
39
43
|
}
|
|
40
44
|
);
|
|
45
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
46
|
+
"MarkdownSession",
|
|
47
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
48
|
+
static DefaultConstructableObject<JHybridMarkdownSessionSpec::javaobject> object("com/margelo/nitro/com/nitromarkdown/HybridMarkdownSession");
|
|
49
|
+
auto instance = object.create();
|
|
50
|
+
return instance->cthis()->shared();
|
|
51
|
+
}
|
|
52
|
+
);
|
|
41
53
|
});
|
|
42
54
|
}
|
|
43
55
|
|
|
44
|
-
} // namespace margelo::nitro::
|
|
56
|
+
} // namespace margelo::nitro::Markdown
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
/// NitroMarkdownOnLoad.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include <jni.h>
|
|
9
9
|
#include <NitroModules/NitroDefines.hpp>
|
|
10
10
|
|
|
11
|
-
namespace margelo::nitro::
|
|
11
|
+
namespace margelo::nitro::Markdown {
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Initializes the native (C++) part of NitroMarkdown, and autolinks all Hybrid Objects.
|
|
@@ -16,10 +16,10 @@ namespace margelo::nitro::NitroMarkdown {
|
|
|
16
16
|
* Example:
|
|
17
17
|
* ```cpp (cpp-adapter.cpp)
|
|
18
18
|
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
-
* return margelo::nitro::
|
|
19
|
+
* return margelo::nitro::Markdown::initialize(vm);
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
int initialize(JavaVM* vm);
|
|
24
24
|
|
|
25
|
-
} // namespace margelo::nitro::
|
|
25
|
+
} // namespace margelo::nitro::Markdown
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void.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 `() -> Unit`.
|
|
22
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
23
|
+
*/
|
|
24
|
+
struct JFunc_void: public jni::JavaClass<JFunc_void> {
|
|
25
|
+
public:
|
|
26
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/Func_void;";
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* Invokes the function this `JFunc_void` instance holds through JNI.
|
|
31
|
+
*/
|
|
32
|
+
void invoke() const {
|
|
33
|
+
static const auto method = javaClassStatic()->getMethod<void()>("invoke");
|
|
34
|
+
method(self());
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`)
|
|
40
|
+
*/
|
|
41
|
+
class JFunc_void_cxx final: public jni::HybridClass<JFunc_void_cxx, JFunc_void> {
|
|
42
|
+
public:
|
|
43
|
+
static jni::local_ref<JFunc_void::javaobject> fromCpp(const std::function<void()>& func) {
|
|
44
|
+
return JFunc_void_cxx::newObjectCxxArgs(func);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
/**
|
|
49
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds.
|
|
50
|
+
*/
|
|
51
|
+
void invoke_cxx() {
|
|
52
|
+
_func();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
[[nodiscard]]
|
|
57
|
+
inline const std::function<void()>& getFunction() const {
|
|
58
|
+
return _func;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/Func_void_cxx;";
|
|
63
|
+
static void registerNatives() {
|
|
64
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private:
|
|
68
|
+
explicit JFunc_void_cxx(const std::function<void()>& func): _func(func) { }
|
|
69
|
+
|
|
70
|
+
private:
|
|
71
|
+
friend HybridBase;
|
|
72
|
+
std::function<void()> _func;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro::Markdown
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridMarkdownSessionSpec.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 "JHybridMarkdownSessionSpec.hpp"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <functional>
|
|
14
|
+
#include "JFunc_void.hpp"
|
|
15
|
+
#include <NitroModules/JNICallable.hpp>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::Markdown {
|
|
18
|
+
|
|
19
|
+
jni::local_ref<JHybridMarkdownSessionSpec::jhybriddata> JHybridMarkdownSessionSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
20
|
+
return makeCxxInstance(jThis);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void JHybridMarkdownSessionSpec::registerNatives() {
|
|
24
|
+
registerHybrid({
|
|
25
|
+
makeNativeMethod("initHybrid", JHybridMarkdownSessionSpec::initHybrid),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
size_t JHybridMarkdownSessionSpec::getExternalMemorySize() noexcept {
|
|
30
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
31
|
+
return method(_javaPart);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
bool JHybridMarkdownSessionSpec::equals(const std::shared_ptr<HybridObject>& other) {
|
|
35
|
+
if (auto otherCast = std::dynamic_pointer_cast<JHybridMarkdownSessionSpec>(other)) {
|
|
36
|
+
return _javaPart == otherCast->_javaPart;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
void JHybridMarkdownSessionSpec::dispose() noexcept {
|
|
42
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
43
|
+
method(_javaPart);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
std::string JHybridMarkdownSessionSpec::toString() {
|
|
47
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
48
|
+
auto javaString = method(_javaPart);
|
|
49
|
+
return javaString->toStdString();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Properties
|
|
53
|
+
double JHybridMarkdownSessionSpec::getHighlightPosition() {
|
|
54
|
+
static const auto method = javaClassStatic()->getMethod<double()>("getHighlightPosition");
|
|
55
|
+
auto __result = method(_javaPart);
|
|
56
|
+
return __result;
|
|
57
|
+
}
|
|
58
|
+
void JHybridMarkdownSessionSpec::setHighlightPosition(double highlightPosition) {
|
|
59
|
+
static const auto method = javaClassStatic()->getMethod<void(double /* highlightPosition */)>("setHighlightPosition");
|
|
60
|
+
method(_javaPart, highlightPosition);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 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));
|
|
67
|
+
}
|
|
68
|
+
void JHybridMarkdownSessionSpec::clear() {
|
|
69
|
+
static const auto method = javaClassStatic()->getMethod<void()>("clear");
|
|
70
|
+
method(_javaPart);
|
|
71
|
+
}
|
|
72
|
+
std::string JHybridMarkdownSessionSpec::getAllText() {
|
|
73
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getAllText");
|
|
74
|
+
auto __result = method(_javaPart);
|
|
75
|
+
return __result->toStdString();
|
|
76
|
+
}
|
|
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));
|
|
80
|
+
return [&]() -> std::function<void()> {
|
|
81
|
+
if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
|
|
82
|
+
auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
|
|
83
|
+
return downcast->cthis()->getFunction();
|
|
84
|
+
} else {
|
|
85
|
+
auto __resultRef = jni::make_global(__result);
|
|
86
|
+
return JNICallable<JFunc_void, void()>(std::move(__resultRef));
|
|
87
|
+
}
|
|
88
|
+
}();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
} // namespace margelo::nitro::Markdown
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMarkdownSessionSpec.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 <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridMarkdownSessionSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::Markdown {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridMarkdownSessionSpec: public jni::HybridClass<JHybridMarkdownSessionSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridMarkdownSessionSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/com/nitromarkdown/HybridMarkdownSessionSpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridMarkdownSessionSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridMarkdownSessionSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridMarkdownSessionSpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override;
|
|
44
|
+
void dispose() noexcept override;
|
|
45
|
+
std::string toString() override;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline const jni::global_ref<JHybridMarkdownSessionSpec::javaobject>& getJavaPart() const noexcept {
|
|
49
|
+
return _javaPart;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Properties
|
|
54
|
+
double getHighlightPosition() override;
|
|
55
|
+
void setHighlightPosition(double highlightPosition) override;
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
// Methods
|
|
59
|
+
void append(const std::string& chunk) override;
|
|
60
|
+
void clear() override;
|
|
61
|
+
std::string getAllText() override;
|
|
62
|
+
std::function<void()> addListener(const std::function<void()>& listener) override;
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
friend HybridBase;
|
|
66
|
+
using HybridBase::HybridBase;
|
|
67
|
+
jni::global_ref<JHybridMarkdownSessionSpec::javaobject> _javaPart;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
} // namespace margelo::nitro::Markdown
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void.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 `() => 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: () -> 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(): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `() => 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_cxx: Func_void {
|
|
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(): Unit
|
|
60
|
+
= invoke_cxx()
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `() => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `() -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_java(private val function: () -> Unit): Func_void {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(): Unit {
|
|
78
|
+
return this.function()
|
|
79
|
+
}
|
|
80
|
+
}
|