@apollohg/react-native-rich-text-editor 2.0.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 (494) hide show
  1. package/LICENSE +160 -0
  2. package/README.md +259 -0
  3. package/RUST-STANDARD-LIBRARY-NOTICES.html +8266 -0
  4. package/ReactNativeProseEditor.podspec +59 -0
  5. package/THIRD_PARTY_NOTICES.md +31155 -0
  6. package/android/build.gradle +188 -0
  7. package/android/consumer-rules.pro +18 -0
  8. package/android/expo/build.gradle +17 -0
  9. package/android/src/debug/java/com/apollohg/editor/viewer/PreparedProseDrawInstrumentation.kt +7 -0
  10. package/android/src/main/assets/editor-icons/MaterialIcons.json +2236 -0
  11. package/android/src/main/assets/editor-icons/MaterialIcons.ttf +0 -0
  12. package/android/src/main/java/com/apollohg/editor/AndroidApiCompat.kt +19 -0
  13. package/android/src/main/java/com/apollohg/editor/AndroidCollaborationTransport.kt +860 -0
  14. package/android/src/main/java/com/apollohg/editor/CaretGeometry.kt +91 -0
  15. package/android/src/main/java/com/apollohg/editor/CodeHighlighting.kt +141 -0
  16. package/android/src/main/java/com/apollohg/editor/DecodedBitmapBudget.kt +250 -0
  17. package/android/src/main/java/com/apollohg/editor/EditorAddons.kt +133 -0
  18. package/android/src/main/java/com/apollohg/editor/EditorBlockSpacing.kt +51 -0
  19. package/android/src/main/java/com/apollohg/editor/EditorBoxDrawable.kt +16 -0
  20. package/android/src/main/java/com/apollohg/editor/EditorBoxDrawing.kt +234 -0
  21. package/android/src/main/java/com/apollohg/editor/EditorCheckboxSpan.kt +87 -0
  22. package/android/src/main/java/com/apollohg/editor/EditorCodeHighlighting.kt +120 -0
  23. package/android/src/main/java/com/apollohg/editor/EditorDecorationLayer.java +18 -0
  24. package/android/src/main/java/com/apollohg/editor/EditorDocumentLayout.kt +626 -0
  25. package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +1042 -0
  26. package/android/src/main/java/com/apollohg/editor/EditorEditTextAnnotations.kt +191 -0
  27. package/android/src/main/java/com/apollohg/editor/EditorEditTextCaret.kt +100 -0
  28. package/android/src/main/java/com/apollohg/editor/EditorEditTextClipboard.kt +101 -0
  29. package/android/src/main/java/com/apollohg/editor/EditorEditTextComposition.kt +220 -0
  30. package/android/src/main/java/com/apollohg/editor/EditorEditTextConfiguration.kt +316 -0
  31. package/android/src/main/java/com/apollohg/editor/EditorEditTextCorrection.kt +303 -0
  32. package/android/src/main/java/com/apollohg/editor/EditorEditTextDeferredUpdates.kt +327 -0
  33. package/android/src/main/java/com/apollohg/editor/EditorEditTextDeletion.kt +258 -0
  34. package/android/src/main/java/com/apollohg/editor/EditorEditTextDiagnostics.kt +83 -0
  35. package/android/src/main/java/com/apollohg/editor/EditorEditTextDragDrop.kt +67 -0
  36. package/android/src/main/java/com/apollohg/editor/EditorEditTextExternalComposition.kt +357 -0
  37. package/android/src/main/java/com/apollohg/editor/EditorEditTextHardwareInput.kt +277 -0
  38. package/android/src/main/java/com/apollohg/editor/EditorEditTextImages.kt +280 -0
  39. package/android/src/main/java/com/apollohg/editor/EditorEditTextInputLifecycle.kt +183 -0
  40. package/android/src/main/java/com/apollohg/editor/EditorEditTextInputPreparation.kt +79 -0
  41. package/android/src/main/java/com/apollohg/editor/EditorEditTextInputTraits.kt +384 -0
  42. package/android/src/main/java/com/apollohg/editor/EditorEditTextLayout.kt +100 -0
  43. package/android/src/main/java/com/apollohg/editor/EditorEditTextNativeMutation.kt +243 -0
  44. package/android/src/main/java/com/apollohg/editor/EditorEditTextPlaceholder.kt +154 -0
  45. package/android/src/main/java/com/apollohg/editor/EditorEditTextRenderPatch.kt +347 -0
  46. package/android/src/main/java/com/apollohg/editor/EditorEditTextRendering.kt +313 -0
  47. package/android/src/main/java/com/apollohg/editor/EditorEditTextRustCommands.kt +281 -0
  48. package/android/src/main/java/com/apollohg/editor/EditorEditTextSelection.kt +352 -0
  49. package/android/src/main/java/com/apollohg/editor/EditorEditTextState.kt +113 -0
  50. package/android/src/main/java/com/apollohg/editor/EditorEditTextTaskMarkers.kt +92 -0
  51. package/android/src/main/java/com/apollohg/editor/EditorEditTextTextCommit.kt +327 -0
  52. package/android/src/main/java/com/apollohg/editor/EditorEditTextToolbar.kt +84 -0
  53. package/android/src/main/java/com/apollohg/editor/EditorEditTextUpdates.kt +245 -0
  54. package/android/src/main/java/com/apollohg/editor/EditorGlyphHeightCursorDrawable.kt +42 -0
  55. package/android/src/main/java/com/apollohg/editor/EditorHeightBehavior.kt +13 -0
  56. package/android/src/main/java/com/apollohg/editor/EditorInputConnection.kt +923 -0
  57. package/android/src/main/java/com/apollohg/editor/EditorInputCoordinates.kt +191 -0
  58. package/android/src/main/java/com/apollohg/editor/EditorInputCorrection.kt +107 -0
  59. package/android/src/main/java/com/apollohg/editor/EditorInputCursorGeometry.kt +128 -0
  60. package/android/src/main/java/com/apollohg/editor/EditorInputSnapshots.kt +134 -0
  61. package/android/src/main/java/com/apollohg/editor/EditorInputSurroundingDeletion.kt +321 -0
  62. package/android/src/main/java/com/apollohg/editor/EditorKeyboardToolbarView.kt +851 -0
  63. package/android/src/main/java/com/apollohg/editor/EditorMentionStyle.kt +192 -0
  64. package/android/src/main/java/com/apollohg/editor/EditorReconciliationWatcher.kt +46 -0
  65. package/android/src/main/java/com/apollohg/editor/EditorStyleSheet.kt +303 -0
  66. package/android/src/main/java/com/apollohg/editor/EditorStyleSheetSpans.kt +253 -0
  67. package/android/src/main/java/com/apollohg/editor/EditorSurfaceInputConnection.kt +67 -0
  68. package/android/src/main/java/com/apollohg/editor/EditorTextDecorationDrawing.kt +143 -0
  69. package/android/src/main/java/com/apollohg/editor/EditorTextSurface.kt +712 -0
  70. package/android/src/main/java/com/apollohg/editor/EditorTextSurfaceDragDrop.kt +94 -0
  71. package/android/src/main/java/com/apollohg/editor/EditorTextSurfaceInteraction.kt +708 -0
  72. package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +650 -0
  73. package/android/src/main/java/com/apollohg/editor/EditorV2Adapter.kt +912 -0
  74. package/android/src/main/java/com/apollohg/editor/EditorV2AdapterMutations.kt +402 -0
  75. package/android/src/main/java/com/apollohg/editor/EditorV2AdapterRendering.kt +123 -0
  76. package/android/src/main/java/com/apollohg/editor/EditorV2AdapterSelection.kt +203 -0
  77. package/android/src/main/java/com/apollohg/editor/EditorV2Backend.kt +120 -0
  78. package/android/src/main/java/com/apollohg/editor/EditorV2Driver.kt +87 -0
  79. package/android/src/main/java/com/apollohg/editor/EditorV2Registry.kt +97 -0
  80. package/android/src/main/java/com/apollohg/editor/EditorV2RenderValidation.kt +409 -0
  81. package/android/src/main/java/com/apollohg/editor/ExpoAutoGrowStyleSizePublisher.kt +34 -0
  82. package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +266 -0
  83. package/android/src/main/java/com/apollohg/editor/ImeTextCoordinateMapper.kt +102 -0
  84. package/android/src/main/java/com/apollohg/editor/KeyboardToolbarImeAnimationController.kt +101 -0
  85. package/android/src/main/java/com/apollohg/editor/MentionSuggestionChipView.kt +234 -0
  86. package/android/src/main/java/com/apollohg/editor/NativeCollaborationTransportRegistry.kt +493 -0
  87. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +813 -0
  88. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewAtoms.kt +68 -0
  89. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewBinding.kt +126 -0
  90. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewDiagnostics.kt +208 -0
  91. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewErrors.kt +146 -0
  92. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewEvents.kt +150 -0
  93. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewExternalComposition.kt +39 -0
  94. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewFocus.kt +176 -0
  95. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewLifecycle.kt +302 -0
  96. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewMentions.kt +259 -0
  97. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewNativeActions.kt +179 -0
  98. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewOutsideTap.kt +214 -0
  99. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewPendingUpdates.kt +376 -0
  100. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewProperties.kt +234 -0
  101. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewPropertyRetries.kt +197 -0
  102. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewToolbar.kt +285 -0
  103. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewTypes.kt +28 -0
  104. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewUpdates.kt +271 -0
  105. package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +687 -0
  106. package/android/src/main/java/com/apollohg/editor/NativeEditorOutsideTapDispatcher.kt +380 -0
  107. package/android/src/main/java/com/apollohg/editor/NativeEditorV2Numbers.kt +45 -0
  108. package/android/src/main/java/com/apollohg/editor/NativeEditorViewRegistry.kt +372 -0
  109. package/android/src/main/java/com/apollohg/editor/NativeImagePipeline.kt +22 -0
  110. package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +193 -0
  111. package/android/src/main/java/com/apollohg/editor/NativeToolbarIcons.kt +177 -0
  112. package/android/src/main/java/com/apollohg/editor/NativeToolbarItem.kt +274 -0
  113. package/android/src/main/java/com/apollohg/editor/OkHttpCollaborationSocket.kt +102 -0
  114. package/android/src/main/java/com/apollohg/editor/OrderedListMarkerFormatter.kt +130 -0
  115. package/android/src/main/java/com/apollohg/editor/PointerTransparentView.java +18 -0
  116. package/android/src/main/java/com/apollohg/editor/PositionBridge.kt +128 -0
  117. package/android/src/main/java/com/apollohg/editor/ProseViewerView.kt +854 -0
  118. package/android/src/main/java/com/apollohg/editor/RemoteSelectionOverlayView.kt +314 -0
  119. package/android/src/main/java/com/apollohg/editor/RenderBlockSpans.kt +314 -0
  120. package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +224 -0
  121. package/android/src/main/java/com/apollohg/editor/RenderBridgeBlockStyles.kt +407 -0
  122. package/android/src/main/java/com/apollohg/editor/RenderBridgeElements.kt +544 -0
  123. package/android/src/main/java/com/apollohg/editor/RenderBridgeInlineAndAtoms.kt +631 -0
  124. package/android/src/main/java/com/apollohg/editor/RenderBridgeParagraphs.kt +215 -0
  125. package/android/src/main/java/com/apollohg/editor/RenderImageDecoder.kt +748 -0
  126. package/android/src/main/java/com/apollohg/editor/RenderImageLoader.kt +900 -0
  127. package/android/src/main/java/com/apollohg/editor/RenderLayoutConstants.kt +117 -0
  128. package/android/src/main/java/com/apollohg/editor/RenderMediaSpans.kt +337 -0
  129. package/android/src/main/java/com/apollohg/editor/RenderParagraphSpans.kt +182 -0
  130. package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +951 -0
  131. package/android/src/main/java/com/apollohg/editor/SharedNativeImagePipeline.kt +78 -0
  132. package/android/src/main/java/com/apollohg/editor/UniffiEditorV2Backend.kt +261 -0
  133. package/android/src/main/java/com/apollohg/editor/viewer/AndroidProseLayoutEngine.kt +1656 -0
  134. package/android/src/main/java/com/apollohg/editor/viewer/FabricAttachmentSidecars.kt +80 -0
  135. package/android/src/main/java/com/apollohg/editor/viewer/FabricLeaseHandleBridge.kt +59 -0
  136. package/android/src/main/java/com/apollohg/editor/viewer/FallbackSelectionGeometry.kt +450 -0
  137. package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseDrawingView.kt +678 -0
  138. package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseInstrumentation.kt +608 -0
  139. package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseLayout.kt +186 -0
  140. package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseLayoutCache.kt +393 -0
  141. package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseLayoutRegistry.kt +828 -0
  142. package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseTheme.kt +316 -0
  143. package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseViewerManager.kt +900 -0
  144. package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseViewerPackage.kt +16 -0
  145. package/android/src/main/java/com/apollohg/editor/viewer/PreparedViewerAtoms.kt +89 -0
  146. package/android/src/main/java/com/apollohg/editor/viewer/ViewerCodeHighlighting.kt +91 -0
  147. package/android/src/main/java/com/apollohg/editor/viewer/ViewerDocument.kt +453 -0
  148. package/android/src/main/java/com/apollohg/editor/viewer/ViewerFontEnvironment.kt +282 -0
  149. package/android/src/main/java/com/apollohg/editor/viewer/ViewerImagePipeline.kt +460 -0
  150. package/android/src/main/jni/CMakeLists.txt +85 -0
  151. package/android/src/main/jni/PreparedProseViewerMeasurementsManager.cpp +334 -0
  152. package/android/src/main/jni/ReactNativeProseEditorSpec.h +17 -0
  153. package/android/src/main/jni/reactnativeproseeditor.h +6 -0
  154. package/android/src/main/res/values/attrs.xml +6 -0
  155. package/android/src/release/java/com/apollohg/editor/viewer/PreparedProseDrawInstrumentation.kt +9 -0
  156. package/app.plugin.js +62 -0
  157. package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseMeasurementsManager.h +62 -0
  158. package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerComponentDescriptor.h +30 -0
  159. package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerShadowNode.cpp +192 -0
  160. package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerShadowNode.h +46 -0
  161. package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerState.h +145 -0
  162. package/dist/AtomHost.d.ts +17 -0
  163. package/dist/AtomHost.js +135 -0
  164. package/dist/DefaultAtomChip.d.ts +2 -0
  165. package/dist/DefaultAtomChip.js +22 -0
  166. package/dist/EditorAddon.d.ts +32 -0
  167. package/dist/EditorAddon.js +29 -0
  168. package/dist/EditorAddonNormalization.d.ts +6 -0
  169. package/dist/EditorAddonNormalization.js +48 -0
  170. package/dist/EditorMentionThemeNormalization.d.ts +8 -0
  171. package/dist/EditorMentionThemeNormalization.js +22 -0
  172. package/dist/EditorMentionThemeValidation.d.ts +12 -0
  173. package/dist/EditorMentionThemeValidation.js +95 -0
  174. package/dist/EditorStyleSheet.d.ts +4 -0
  175. package/dist/EditorStyleSheet.js +10 -0
  176. package/dist/EditorStyleSheetNormalization.d.ts +3 -0
  177. package/dist/EditorStyleSheetNormalization.js +226 -0
  178. package/dist/EditorStyleSheetTypes.d.ts +151 -0
  179. package/dist/EditorStyleSheetTypes.js +2 -0
  180. package/dist/EditorTheme.d.ts +117 -0
  181. package/dist/EditorTheme.js +41 -0
  182. package/dist/EditorToolbar.d.ts +4 -0
  183. package/dist/EditorToolbar.js +17 -0
  184. package/dist/EditorToolbarComponent.d.ts +13 -0
  185. package/dist/EditorToolbarComponent.js +24 -0
  186. package/dist/EditorToolbarItems.d.ts +9 -0
  187. package/dist/EditorToolbarItems.js +58 -0
  188. package/dist/EditorToolbarRegistry.d.ts +59 -0
  189. package/dist/EditorToolbarRegistry.js +175 -0
  190. package/dist/EditorToolbarTypes.d.ts +273 -0
  191. package/dist/EditorToolbarTypes.js +2 -0
  192. package/dist/EditorToolbarVisuals.d.ts +154 -0
  193. package/dist/EditorToolbarVisuals.js +228 -0
  194. package/dist/EditorUpdateRevision.d.ts +8 -0
  195. package/dist/EditorUpdateRevision.js +22 -0
  196. package/dist/ExternalTextComposition.d.ts +45 -0
  197. package/dist/ExternalTextComposition.js +537 -0
  198. package/dist/ImageLoadingPolicy.d.ts +54 -0
  199. package/dist/ImageLoadingPolicy.js +60 -0
  200. package/dist/NativeEditorBoundaryError.d.ts +111 -0
  201. package/dist/NativeEditorBoundaryError.js +268 -0
  202. package/dist/NativeEditorBridge.d.ts +9 -0
  203. package/dist/NativeEditorBridge.js +37 -0
  204. package/dist/NativeEditorCollaborationTransport.d.ts +154 -0
  205. package/dist/NativeEditorCollaborationTransport.js +275 -0
  206. package/dist/NativeEditorCreateConfig.d.ts +16 -0
  207. package/dist/NativeEditorCreateConfig.js +249 -0
  208. package/dist/NativeEditorCreateJson.d.ts +76 -0
  209. package/dist/NativeEditorCreateJson.js +474 -0
  210. package/dist/NativeEditorCreateValidation.d.ts +32 -0
  211. package/dist/NativeEditorCreateValidation.js +150 -0
  212. package/dist/NativeEditorDocumentBridge.d.ts +72 -0
  213. package/dist/NativeEditorDocumentBridge.js +305 -0
  214. package/dist/NativeEditorDocumentHandle.d.ts +70 -0
  215. package/dist/NativeEditorDocumentHandle.js +89 -0
  216. package/dist/NativeEditorLocalAwareness.d.ts +34 -0
  217. package/dist/NativeEditorLocalAwareness.js +153 -0
  218. package/dist/NativeEditorNativeModule.d.ts +48 -0
  219. package/dist/NativeEditorNativeModule.js +34 -0
  220. package/dist/NativeEditorRenderNormalization.d.ts +22 -0
  221. package/dist/NativeEditorRenderNormalization.js +274 -0
  222. package/dist/NativeEditorResultNormalization.d.ts +108 -0
  223. package/dist/NativeEditorResultNormalization.js +400 -0
  224. package/dist/NativeEditorTypes.d.ts +318 -0
  225. package/dist/NativeEditorTypes.js +15 -0
  226. package/dist/NativeEditorV2Decimal.d.ts +5 -0
  227. package/dist/NativeEditorV2Decimal.js +18 -0
  228. package/dist/NativeProseViewer.d.ts +122 -0
  229. package/dist/NativeProseViewer.js +130 -0
  230. package/dist/NativeRichTextEditor.d.ts +3 -0
  231. package/dist/NativeRichTextEditor.js +6 -0
  232. package/dist/ResourceLimits.d.ts +100 -0
  233. package/dist/ResourceLimits.js +80 -0
  234. package/dist/RichTextEditor.d.ts +4 -0
  235. package/dist/RichTextEditor.js +25 -0
  236. package/dist/RichTextEditorNativeTypes.d.ts +122 -0
  237. package/dist/RichTextEditorNativeTypes.js +2 -0
  238. package/dist/RichTextEditorNativeView.d.ts +12 -0
  239. package/dist/RichTextEditorNativeView.js +15 -0
  240. package/dist/RichTextEditorSerialization.d.ts +53 -0
  241. package/dist/RichTextEditorSerialization.js +283 -0
  242. package/dist/RichTextEditorTypes.d.ts +281 -0
  243. package/dist/RichTextEditorTypes.js +2 -0
  244. package/dist/ViewerConfiguration.d.ts +22 -0
  245. package/dist/ViewerConfiguration.js +6 -0
  246. package/dist/YjsCollaboration.d.ts +146 -0
  247. package/dist/YjsCollaboration.js +496 -0
  248. package/dist/addons.d.ts +193 -0
  249. package/dist/addons.js +122 -0
  250. package/dist/atomConstants.d.ts +3 -0
  251. package/dist/atomConstants.js +6 -0
  252. package/dist/atomInstances.d.ts +35 -0
  253. package/dist/atomInstances.js +79 -0
  254. package/dist/atomPolicy.d.ts +4 -0
  255. package/dist/atomPolicy.js +47 -0
  256. package/dist/atomUpdates.d.ts +2 -0
  257. package/dist/atomUpdates.js +38 -0
  258. package/dist/atoms.d.ts +92 -0
  259. package/dist/atoms.js +222 -0
  260. package/dist/attributeValidation.d.ts +4 -0
  261. package/dist/attributeValidation.js +97 -0
  262. package/dist/contentExpression.d.ts +6 -0
  263. package/dist/contentExpression.js +335 -0
  264. package/dist/index.d.ts +21 -0
  265. package/dist/index.js +78 -0
  266. package/dist/listMarkers.d.ts +15 -0
  267. package/dist/listMarkers.js +21 -0
  268. package/dist/schemaDefinition.d.ts +143 -0
  269. package/dist/schemaDefinition.js +206 -0
  270. package/dist/schemaDocument.d.ts +17 -0
  271. package/dist/schemaDocument.js +69 -0
  272. package/dist/schemaDocumentConstruction.d.ts +5 -0
  273. package/dist/schemaDocumentConstruction.js +125 -0
  274. package/dist/schemaNormalization.d.ts +29 -0
  275. package/dist/schemaNormalization.js +313 -0
  276. package/dist/schemaPresets.d.ts +68 -0
  277. package/dist/schemaPresets.js +198 -0
  278. package/dist/schemaResolution.d.ts +9 -0
  279. package/dist/schemaResolution.js +211 -0
  280. package/dist/schemas.d.ts +5 -0
  281. package/dist/schemas.js +28 -0
  282. package/dist/specs/PreparedProseViewerNativeComponent.d.ts +37 -0
  283. package/dist/specs/PreparedProseViewerNativeComponent.js +6 -0
  284. package/dist/useEditorToolbarInteractions.d.ts +12 -0
  285. package/dist/useEditorToolbarInteractions.js +218 -0
  286. package/dist/useEditorToolbarItems.d.ts +8 -0
  287. package/dist/useEditorToolbarItems.js +280 -0
  288. package/dist/useEditorToolbarPresentation.d.ts +4 -0
  289. package/dist/useEditorToolbarPresentation.js +203 -0
  290. package/dist/useEditorToolbarState.d.ts +63 -0
  291. package/dist/useEditorToolbarState.js +108 -0
  292. package/dist/useFocusPreservingFrames.d.ts +17 -0
  293. package/dist/useFocusPreservingFrames.js +108 -0
  294. package/dist/useNativeEditor.d.ts +66 -0
  295. package/dist/useNativeEditor.js +370 -0
  296. package/dist/useRichTextEditorCommands.d.ts +21 -0
  297. package/dist/useRichTextEditorCommands.js +299 -0
  298. package/dist/useRichTextEditorEvents.d.ts +18 -0
  299. package/dist/useRichTextEditorEvents.js +216 -0
  300. package/dist/useRichTextEditorMentions.d.ts +11 -0
  301. package/dist/useRichTextEditorMentions.js +316 -0
  302. package/dist/useRichTextEditorPresentation.d.ts +5 -0
  303. package/dist/useRichTextEditorPresentation.js +178 -0
  304. package/dist/useRichTextEditorState.d.ts +180 -0
  305. package/dist/useRichTextEditorState.js +405 -0
  306. package/dist/useRichTextEditorUpdates.d.ts +10 -0
  307. package/dist/useRichTextEditorUpdates.js +308 -0
  308. package/dist/useViewerAtoms.d.ts +38 -0
  309. package/dist/useViewerAtoms.js +288 -0
  310. package/expo-module.config.json +13 -0
  311. package/ios/EditorAddons.swift +354 -0
  312. package/ios/EditorCodeHighlighting.swift +184 -0
  313. package/ios/EditorCore.xcframework/Info.plist +44 -0
  314. package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
  315. package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
  316. package/ios/EditorInteractionOverlays.swift +697 -0
  317. package/ios/EditorLayoutManager.swift +971 -0
  318. package/ios/EditorNodeTypes.swift +37 -0
  319. package/ios/EditorStyleSheet.swift +461 -0
  320. package/ios/EditorTextView+AttributedPatch.swift +305 -0
  321. package/ios/EditorTextView+Binding.swift +61 -0
  322. package/ios/EditorTextView+Caret.swift +333 -0
  323. package/ios/EditorTextView+Commands.swift +203 -0
  324. package/ios/EditorTextView+Delegate.swift +65 -0
  325. package/ios/EditorTextView+Diagnostics.swift +225 -0
  326. package/ios/EditorTextView+DragDrop.swift +290 -0
  327. package/ios/EditorTextView+ExternalComposition.swift +364 -0
  328. package/ios/EditorTextView+Images.swift +354 -0
  329. package/ios/EditorTextView+InputTraits.swift +200 -0
  330. package/ios/EditorTextView+KeyboardInput.swift +318 -0
  331. package/ios/EditorTextView+Layout.swift +245 -0
  332. package/ios/EditorTextView+MarkedText.swift +267 -0
  333. package/ios/EditorTextView+NativeInputLifecycle.swift +372 -0
  334. package/ios/EditorTextView+NativeMutation.swift +471 -0
  335. package/ios/EditorTextView+Reconciliation.swift +97 -0
  336. package/ios/EditorTextView+RenderPatch.swift +573 -0
  337. package/ios/EditorTextView+Rendering.swift +539 -0
  338. package/ios/EditorTextView+Selection.swift +542 -0
  339. package/ios/EditorTextView.swift +953 -0
  340. package/ios/EditorTheme.swift +626 -0
  341. package/ios/EditorV2Adapter+Commands.swift +204 -0
  342. package/ios/EditorV2Adapter+Envelope.swift +238 -0
  343. package/ios/EditorV2Adapter+Mutation.swift +392 -0
  344. package/ios/EditorV2Adapter+Registry.swift +185 -0
  345. package/ios/EditorV2Adapter+RenderState.swift +360 -0
  346. package/ios/EditorV2Adapter+RenderValidation.swift +420 -0
  347. package/ios/EditorV2Adapter+Selection.swift +329 -0
  348. package/ios/EditorV2Adapter+TextCommands.swift +430 -0
  349. package/ios/EditorV2Adapter.swift +376 -0
  350. package/ios/EditorV2Shadow.swift +353 -0
  351. package/ios/Generated_editor_core.swift +2378 -0
  352. package/ios/NativeCodeHighlighting.swift +159 -0
  353. package/ios/NativeCollaborationSocket.swift +144 -0
  354. package/ios/NativeCollaborationTransport+Protocol.swift +258 -0
  355. package/ios/NativeCollaborationTransport+Socket.swift +379 -0
  356. package/ios/NativeCollaborationTransport+Validation.swift +103 -0
  357. package/ios/NativeCollaborationTransport.swift +322 -0
  358. package/ios/NativeCollaborationTransportRegistry.swift +521 -0
  359. package/ios/NativeEditorExpoView+AccessoryRetry.swift +219 -0
  360. package/ios/NativeEditorExpoView+Binding.swift +268 -0
  361. package/ios/NativeEditorExpoView+Diagnostics.swift +66 -0
  362. package/ios/NativeEditorExpoView+Events.swift +131 -0
  363. package/ios/NativeEditorExpoView+Focus.swift +169 -0
  364. package/ios/NativeEditorExpoView+MentionRetry.swift +288 -0
  365. package/ios/NativeEditorExpoView+Mentions.swift +288 -0
  366. package/ios/NativeEditorExpoView+Properties.swift +300 -0
  367. package/ios/NativeEditorExpoView+Toolbar.swift +86 -0
  368. package/ios/NativeEditorExpoView+Updates.swift +312 -0
  369. package/ios/NativeEditorExpoView.swift +349 -0
  370. package/ios/NativeEditorModule.swift +856 -0
  371. package/ios/NativeEditorViewRegistry.swift +226 -0
  372. package/ios/NativeToolbar+ButtonStyle.swift +214 -0
  373. package/ios/NativeToolbar+Buttons.swift +228 -0
  374. package/ios/NativeToolbar+Diagnostics.swift +114 -0
  375. package/ios/NativeToolbar+Menu.swift +101 -0
  376. package/ios/NativeToolbar+Models.swift +519 -0
  377. package/ios/NativeToolbar+Placeholder.swift +39 -0
  378. package/ios/NativeToolbar.swift +612 -0
  379. package/ios/OrderedListMarkerFormatter.swift +103 -0
  380. package/ios/PositionBridge.swift +596 -0
  381. package/ios/ProseViewerView.swift +462 -0
  382. package/ios/RenderBridge+Atoms.swift +288 -0
  383. package/ios/RenderBridge+Attachments.swift +246 -0
  384. package/ios/RenderBridge+BlockBoundaries.swift +313 -0
  385. package/ios/RenderBridge+Style.swift +343 -0
  386. package/ios/RenderBridge.swift +704 -0
  387. package/ios/RichTextEditorView.swift +930 -0
  388. package/ios/SharedNativeImagePipeline+Cache.swift +189 -0
  389. package/ios/SharedNativeImagePipeline+Transport.swift +328 -0
  390. package/ios/SharedNativeImagePipeline.swift +533 -0
  391. package/ios/Viewer/CoreTextProseLayoutEngine+AttributedText.swift +436 -0
  392. package/ios/Viewer/CoreTextProseLayoutEngine+Models.swift +322 -0
  393. package/ios/Viewer/CoreTextProseLayoutEngine.swift +635 -0
  394. package/ios/Viewer/Fabric/PREPPreparedProseViewerComponentView.h +4 -0
  395. package/ios/Viewer/Fabric/PREPPreparedProseViewerComponentView.mm +767 -0
  396. package/ios/Viewer/Fabric/PreparedProseMeasurementsManager.mm +118 -0
  397. package/ios/Viewer/NativeSVGImageDecoder.h +9 -0
  398. package/ios/Viewer/NativeSVGImageDecoder.mm +106 -0
  399. package/ios/Viewer/NativeSVGPreflight.h +11 -0
  400. package/ios/Viewer/NativeSVGPreflight.mm +219 -0
  401. package/ios/Viewer/PreparedProseDrawingView.swift +639 -0
  402. package/ios/Viewer/PreparedProseInstrumentation.swift +387 -0
  403. package/ios/Viewer/PreparedProseLayout.swift +326 -0
  404. package/ios/Viewer/PreparedProseLayoutCache.swift +766 -0
  405. package/ios/Viewer/PreparedProseLayoutRegistry+Artifacts.swift +377 -0
  406. package/ios/Viewer/PreparedProseLayoutRegistry+Fabric.swift +582 -0
  407. package/ios/Viewer/PreparedProseLayoutRegistry+FabricOwnership.swift +128 -0
  408. package/ios/Viewer/PreparedProseLayoutRegistry.swift +381 -0
  409. package/ios/Viewer/ViewerDocument.swift +575 -0
  410. package/ios/Viewer/ViewerFontEnvironment.swift +283 -0
  411. package/ios/Viewer/ViewerImagePipeline.swift +478 -0
  412. package/ios/editor_coreFFI/editor_coreFFI.h +1023 -0
  413. package/ios/editor_coreFFI/module.modulemap +7 -0
  414. package/package.json +151 -0
  415. package/react-native.config.js +17 -0
  416. package/rust/android/arm64-v8a/libeditor_core.so +0 -0
  417. package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
  418. package/rust/android/x86/libeditor_core.so +0 -0
  419. package/rust/android/x86_64/libeditor_core.so +0 -0
  420. package/rust/bindings/kotlin/uniffi/editor_core/editor_core.kt +3146 -0
  421. package/src/AtomHost.tsx +180 -0
  422. package/src/DefaultAtomChip.tsx +27 -0
  423. package/src/EditorAddon.ts +65 -0
  424. package/src/EditorAddonNormalization.ts +49 -0
  425. package/src/EditorMentionThemeNormalization.ts +25 -0
  426. package/src/EditorMentionThemeValidation.ts +133 -0
  427. package/src/EditorStyleSheet.ts +9 -0
  428. package/src/EditorStyleSheetNormalization.ts +219 -0
  429. package/src/EditorStyleSheetTypes.ts +189 -0
  430. package/src/EditorTheme.ts +196 -0
  431. package/src/EditorToolbar.tsx +31 -0
  432. package/src/EditorToolbarComponent.tsx +23 -0
  433. package/src/EditorToolbarItems.tsx +64 -0
  434. package/src/EditorToolbarRegistry.tsx +254 -0
  435. package/src/EditorToolbarTypes.tsx +322 -0
  436. package/src/EditorToolbarVisuals.tsx +270 -0
  437. package/src/EditorUpdateRevision.ts +26 -0
  438. package/src/ExternalTextComposition.ts +658 -0
  439. package/src/ImageLoadingPolicy.ts +125 -0
  440. package/src/NativeEditorBoundaryError.ts +345 -0
  441. package/src/NativeEditorBridge.ts +93 -0
  442. package/src/NativeEditorCollaborationTransport.ts +493 -0
  443. package/src/NativeEditorCreateConfig.ts +326 -0
  444. package/src/NativeEditorCreateJson.ts +579 -0
  445. package/src/NativeEditorCreateValidation.ts +178 -0
  446. package/src/NativeEditorDocumentBridge.ts +485 -0
  447. package/src/NativeEditorDocumentHandle.ts +168 -0
  448. package/src/NativeEditorLocalAwareness.ts +168 -0
  449. package/src/NativeEditorNativeModule.ts +97 -0
  450. package/src/NativeEditorRenderNormalization.ts +320 -0
  451. package/src/NativeEditorResultNormalization.ts +469 -0
  452. package/src/NativeEditorTypes.ts +366 -0
  453. package/src/NativeEditorV2Decimal.ts +13 -0
  454. package/src/NativeProseViewer.tsx +356 -0
  455. package/src/NativeRichTextEditor.tsx +33 -0
  456. package/src/ResourceLimits.ts +187 -0
  457. package/src/RichTextEditor.tsx +27 -0
  458. package/src/RichTextEditorNativeTypes.tsx +144 -0
  459. package/src/RichTextEditorNativeView.tsx +21 -0
  460. package/src/RichTextEditorSerialization.tsx +381 -0
  461. package/src/RichTextEditorTypes.tsx +327 -0
  462. package/src/ViewerConfiguration.ts +23 -0
  463. package/src/YjsCollaboration.ts +692 -0
  464. package/src/addons.ts +311 -0
  465. package/src/atomConstants.ts +3 -0
  466. package/src/atomInstances.ts +123 -0
  467. package/src/atomPolicy.ts +47 -0
  468. package/src/atomUpdates.ts +52 -0
  469. package/src/atoms.ts +379 -0
  470. package/src/attributeValidation.ts +116 -0
  471. package/src/contentExpression.ts +338 -0
  472. package/src/index.ts +295 -0
  473. package/src/listMarkers.ts +18 -0
  474. package/src/schemaDefinition.ts +395 -0
  475. package/src/schemaDocument.ts +92 -0
  476. package/src/schemaDocumentConstruction.ts +148 -0
  477. package/src/schemaNormalization.ts +367 -0
  478. package/src/schemaPresets.ts +250 -0
  479. package/src/schemaResolution.ts +242 -0
  480. package/src/schemas.ts +43 -0
  481. package/src/specs/PreparedProseViewerNativeComponent.ts +40 -0
  482. package/src/useEditorToolbarInteractions.tsx +329 -0
  483. package/src/useEditorToolbarItems.tsx +390 -0
  484. package/src/useEditorToolbarPresentation.tsx +483 -0
  485. package/src/useEditorToolbarState.tsx +172 -0
  486. package/src/useFocusPreservingFrames.ts +171 -0
  487. package/src/useNativeEditor.ts +534 -0
  488. package/src/useRichTextEditorCommands.tsx +478 -0
  489. package/src/useRichTextEditorEvents.tsx +342 -0
  490. package/src/useRichTextEditorMentions.tsx +441 -0
  491. package/src/useRichTextEditorPresentation.tsx +563 -0
  492. package/src/useRichTextEditorState.tsx +620 -0
  493. package/src/useRichTextEditorUpdates.tsx +403 -0
  494. package/src/useViewerAtoms.tsx +427 -0
@@ -0,0 +1,3146 @@
1
+ // This file was autogenerated by some hot garbage in the `uniffi` crate.
2
+ // Trust me, you don't want to mess with it!
3
+
4
+ @file:Suppress("NAME_SHADOWING")
5
+
6
+ package uniffi.editor_core
7
+
8
+ // Common helper code.
9
+ //
10
+ // Ideally this would live in a separate .kt file where it can be unittested etc
11
+ // in isolation, and perhaps even published as a re-useable package.
12
+ //
13
+ // However, it's important that the details of how this helper code works (e.g. the
14
+ // way that different builtin types are passed across the FFI) exactly match what's
15
+ // expected by the Rust code on the other side of the interface. In practice right
16
+ // now that means coming from the exact some version of `uniffi` that was used to
17
+ // compile the Rust component. The easiest way to ensure this is to bundle the Kotlin
18
+ // helpers directly inline like we're doing here.
19
+
20
+ import com.sun.jna.Library
21
+ import com.sun.jna.IntegerType
22
+ import com.sun.jna.Native
23
+ import com.sun.jna.Pointer
24
+ import com.sun.jna.Structure
25
+ import com.sun.jna.Callback
26
+ import com.sun.jna.ptr.*
27
+ import java.nio.ByteBuffer
28
+ import java.nio.ByteOrder
29
+ import java.nio.CharBuffer
30
+ import java.nio.charset.CodingErrorAction
31
+ import java.util.concurrent.atomic.AtomicLong
32
+ import java.util.concurrent.ConcurrentHashMap
33
+ import java.util.concurrent.atomic.AtomicBoolean
34
+
35
+ // This is a helper for safely working with byte buffers returned from the Rust code.
36
+ // A rust-owned buffer is represented by its capacity, its current length, and a
37
+ // pointer to the underlying data.
38
+
39
+ /**
40
+ * @suppress
41
+ */
42
+ @Structure.FieldOrder("capacity", "len", "data")
43
+ open class RustBuffer : Structure() {
44
+ // Note: `capacity` and `len` are actually `ULong` values, but JVM only supports signed values.
45
+ // When dealing with these fields, make sure to call `toULong()`.
46
+ @JvmField var capacity: Long = 0
47
+ @JvmField var len: Long = 0
48
+ @JvmField var data: Pointer? = null
49
+
50
+ class ByValue: RustBuffer(), Structure.ByValue
51
+ class ByReference: RustBuffer(), Structure.ByReference
52
+
53
+ internal fun setValue(other: RustBuffer) {
54
+ capacity = other.capacity
55
+ len = other.len
56
+ data = other.data
57
+ }
58
+
59
+ companion object {
60
+ internal fun alloc(size: ULong = 0UL) = uniffiRustCall() { status ->
61
+ // Note: need to convert the size to a `Long` value to make this work with JVM.
62
+ UniffiLib.INSTANCE.ffi_editor_core_rustbuffer_alloc(size.toLong(), status)
63
+ }.also {
64
+ if(it.data == null) {
65
+ throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})")
66
+ }
67
+ }
68
+
69
+ internal fun create(capacity: ULong, len: ULong, data: Pointer?): RustBuffer.ByValue {
70
+ var buf = RustBuffer.ByValue()
71
+ buf.capacity = capacity.toLong()
72
+ buf.len = len.toLong()
73
+ buf.data = data
74
+ return buf
75
+ }
76
+
77
+ internal fun free(buf: RustBuffer.ByValue) = uniffiRustCall() { status ->
78
+ UniffiLib.INSTANCE.ffi_editor_core_rustbuffer_free(buf, status)
79
+ }
80
+ }
81
+
82
+ @Suppress("TooGenericExceptionThrown")
83
+ fun asByteBuffer() =
84
+ this.data?.getByteBuffer(0, this.len.toLong())?.also {
85
+ it.order(ByteOrder.BIG_ENDIAN)
86
+ }
87
+ }
88
+
89
+ /**
90
+ * The equivalent of the `*mut RustBuffer` type.
91
+ * Required for callbacks taking in an out pointer.
92
+ *
93
+ * Size is the sum of all values in the struct.
94
+ *
95
+ * @suppress
96
+ */
97
+ class RustBufferByReference : ByReference(16) {
98
+ /**
99
+ * Set the pointed-to `RustBuffer` to the given value.
100
+ */
101
+ fun setValue(value: RustBuffer.ByValue) {
102
+ // NOTE: The offsets are as they are in the C-like struct.
103
+ val pointer = getPointer()
104
+ pointer.setLong(0, value.capacity)
105
+ pointer.setLong(8, value.len)
106
+ pointer.setPointer(16, value.data)
107
+ }
108
+
109
+ /**
110
+ * Get a `RustBuffer.ByValue` from this reference.
111
+ */
112
+ fun getValue(): RustBuffer.ByValue {
113
+ val pointer = getPointer()
114
+ val value = RustBuffer.ByValue()
115
+ value.writeField("capacity", pointer.getLong(0))
116
+ value.writeField("len", pointer.getLong(8))
117
+ value.writeField("data", pointer.getLong(16))
118
+
119
+ return value
120
+ }
121
+ }
122
+
123
+ // This is a helper for safely passing byte references into the rust code.
124
+ // It's not actually used at the moment, because there aren't many things that you
125
+ // can take a direct pointer to in the JVM, and if we're going to copy something
126
+ // then we might as well copy it into a `RustBuffer`. But it's here for API
127
+ // completeness.
128
+
129
+ @Structure.FieldOrder("len", "data")
130
+ internal open class ForeignBytes : Structure() {
131
+ @JvmField var len: Int = 0
132
+ @JvmField var data: Pointer? = null
133
+
134
+ class ByValue : ForeignBytes(), Structure.ByValue
135
+ }
136
+ /**
137
+ * The FfiConverter interface handles converter types to and from the FFI
138
+ *
139
+ * All implementing objects should be public to support external types. When a
140
+ * type is external we need to import it's FfiConverter.
141
+ *
142
+ * @suppress
143
+ */
144
+ public interface FfiConverter<KotlinType, FfiType> {
145
+ // Convert an FFI type to a Kotlin type
146
+ fun lift(value: FfiType): KotlinType
147
+
148
+ // Convert an Kotlin type to an FFI type
149
+ fun lower(value: KotlinType): FfiType
150
+
151
+ // Read a Kotlin type from a `ByteBuffer`
152
+ fun read(buf: ByteBuffer): KotlinType
153
+
154
+ // Calculate bytes to allocate when creating a `RustBuffer`
155
+ //
156
+ // This must return at least as many bytes as the write() function will
157
+ // write. It can return more bytes than needed, for example when writing
158
+ // Strings we can't know the exact bytes needed until we the UTF-8
159
+ // encoding, so we pessimistically allocate the largest size possible (3
160
+ // bytes per codepoint). Allocating extra bytes is not really a big deal
161
+ // because the `RustBuffer` is short-lived.
162
+ fun allocationSize(value: KotlinType): ULong
163
+
164
+ // Write a Kotlin type to a `ByteBuffer`
165
+ fun write(value: KotlinType, buf: ByteBuffer)
166
+
167
+ // Lower a value into a `RustBuffer`
168
+ //
169
+ // This method lowers a value into a `RustBuffer` rather than the normal
170
+ // FfiType. It's used by the callback interface code. Callback interface
171
+ // returns are always serialized into a `RustBuffer` regardless of their
172
+ // normal FFI type.
173
+ fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue {
174
+ val rbuf = RustBuffer.alloc(allocationSize(value))
175
+ try {
176
+ val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity).also {
177
+ it.order(ByteOrder.BIG_ENDIAN)
178
+ }
179
+ write(value, bbuf)
180
+ rbuf.writeField("len", bbuf.position().toLong())
181
+ return rbuf
182
+ } catch (e: Throwable) {
183
+ RustBuffer.free(rbuf)
184
+ throw e
185
+ }
186
+ }
187
+
188
+ // Lift a value from a `RustBuffer`.
189
+ //
190
+ // This here mostly because of the symmetry with `lowerIntoRustBuffer()`.
191
+ // It's currently only used by the `FfiConverterRustBuffer` class below.
192
+ fun liftFromRustBuffer(rbuf: RustBuffer.ByValue): KotlinType {
193
+ val byteBuf = rbuf.asByteBuffer()!!
194
+ try {
195
+ val item = read(byteBuf)
196
+ if (byteBuf.hasRemaining()) {
197
+ throw RuntimeException("junk remaining in buffer after lifting, something is very wrong!!")
198
+ }
199
+ return item
200
+ } finally {
201
+ RustBuffer.free(rbuf)
202
+ }
203
+ }
204
+ }
205
+
206
+ /**
207
+ * FfiConverter that uses `RustBuffer` as the FfiType
208
+ *
209
+ * @suppress
210
+ */
211
+ public interface FfiConverterRustBuffer<KotlinType>: FfiConverter<KotlinType, RustBuffer.ByValue> {
212
+ override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value)
213
+ override fun lower(value: KotlinType) = lowerIntoRustBuffer(value)
214
+ }
215
+ // A handful of classes and functions to support the generated data structures.
216
+ // This would be a good candidate for isolating in its own ffi-support lib.
217
+
218
+ internal const val UNIFFI_CALL_SUCCESS = 0.toByte()
219
+ internal const val UNIFFI_CALL_ERROR = 1.toByte()
220
+ internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte()
221
+
222
+ @Structure.FieldOrder("code", "error_buf")
223
+ internal open class UniffiRustCallStatus : Structure() {
224
+ @JvmField var code: Byte = 0
225
+ @JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue()
226
+
227
+ class ByValue: UniffiRustCallStatus(), Structure.ByValue
228
+
229
+ fun isSuccess(): Boolean {
230
+ return code == UNIFFI_CALL_SUCCESS
231
+ }
232
+
233
+ fun isError(): Boolean {
234
+ return code == UNIFFI_CALL_ERROR
235
+ }
236
+
237
+ fun isPanic(): Boolean {
238
+ return code == UNIFFI_CALL_UNEXPECTED_ERROR
239
+ }
240
+
241
+ companion object {
242
+ fun create(code: Byte, errorBuf: RustBuffer.ByValue): UniffiRustCallStatus.ByValue {
243
+ val callStatus = UniffiRustCallStatus.ByValue()
244
+ callStatus.code = code
245
+ callStatus.error_buf = errorBuf
246
+ return callStatus
247
+ }
248
+ }
249
+ }
250
+
251
+ class InternalException(message: String) : kotlin.Exception(message)
252
+
253
+ /**
254
+ * Each top-level error class has a companion object that can lift the error from the call status's rust buffer
255
+ *
256
+ * @suppress
257
+ */
258
+ interface UniffiRustCallStatusErrorHandler<E> {
259
+ fun lift(error_buf: RustBuffer.ByValue): E;
260
+ }
261
+
262
+ // Helpers for calling Rust
263
+ // In practice we usually need to be synchronized to call this safely, so it doesn't
264
+ // synchronize itself
265
+
266
+ // Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err
267
+ private inline fun <U, E: kotlin.Exception> uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler<E>, callback: (UniffiRustCallStatus) -> U): U {
268
+ var status = UniffiRustCallStatus()
269
+ val return_value = callback(status)
270
+ uniffiCheckCallStatus(errorHandler, status)
271
+ return return_value
272
+ }
273
+
274
+ // Check UniffiRustCallStatus and throw an error if the call wasn't successful
275
+ private fun<E: kotlin.Exception> uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler<E>, status: UniffiRustCallStatus) {
276
+ if (status.isSuccess()) {
277
+ return
278
+ } else if (status.isError()) {
279
+ throw errorHandler.lift(status.error_buf)
280
+ } else if (status.isPanic()) {
281
+ // when the rust code sees a panic, it tries to construct a rustbuffer
282
+ // with the message. but if that code panics, then it just sends back
283
+ // an empty buffer.
284
+ if (status.error_buf.len > 0) {
285
+ throw InternalException(FfiConverterString.lift(status.error_buf))
286
+ } else {
287
+ throw InternalException("Rust panic")
288
+ }
289
+ } else {
290
+ throw InternalException("Unknown rust call status: $status.code")
291
+ }
292
+ }
293
+
294
+ /**
295
+ * UniffiRustCallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR
296
+ *
297
+ * @suppress
298
+ */
299
+ object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler<InternalException> {
300
+ override fun lift(error_buf: RustBuffer.ByValue): InternalException {
301
+ RustBuffer.free(error_buf)
302
+ return InternalException("Unexpected CALL_ERROR")
303
+ }
304
+ }
305
+
306
+ // Call a rust function that returns a plain value
307
+ private inline fun <U> uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U {
308
+ return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback)
309
+ }
310
+
311
+ internal inline fun<T> uniffiTraitInterfaceCall(
312
+ callStatus: UniffiRustCallStatus,
313
+ makeCall: () -> T,
314
+ writeReturn: (T) -> Unit,
315
+ ) {
316
+ try {
317
+ writeReturn(makeCall())
318
+ } catch(e: kotlin.Exception) {
319
+ callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
320
+ callStatus.error_buf = FfiConverterString.lower(e.toString())
321
+ }
322
+ }
323
+
324
+ internal inline fun<T, reified E: Throwable> uniffiTraitInterfaceCallWithError(
325
+ callStatus: UniffiRustCallStatus,
326
+ makeCall: () -> T,
327
+ writeReturn: (T) -> Unit,
328
+ lowerError: (E) -> RustBuffer.ByValue
329
+ ) {
330
+ try {
331
+ writeReturn(makeCall())
332
+ } catch(e: kotlin.Exception) {
333
+ if (e is E) {
334
+ callStatus.code = UNIFFI_CALL_ERROR
335
+ callStatus.error_buf = lowerError(e)
336
+ } else {
337
+ callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
338
+ callStatus.error_buf = FfiConverterString.lower(e.toString())
339
+ }
340
+ }
341
+ }
342
+ // Map handles to objects
343
+ //
344
+ // This is used pass an opaque 64-bit handle representing a foreign object to the Rust code.
345
+ internal class UniffiHandleMap<T: Any> {
346
+ private val map = ConcurrentHashMap<Long, T>()
347
+ private val counter = java.util.concurrent.atomic.AtomicLong(0)
348
+
349
+ val size: Int
350
+ get() = map.size
351
+
352
+ // Insert a new object into the handle map and get a handle for it
353
+ fun insert(obj: T): Long {
354
+ val handle = counter.getAndAdd(1)
355
+ map.put(handle, obj)
356
+ return handle
357
+ }
358
+
359
+ // Get an object from the handle map
360
+ fun get(handle: Long): T {
361
+ return map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle")
362
+ }
363
+
364
+ // Remove an entry from the handlemap and get the Kotlin object back
365
+ fun remove(handle: Long): T {
366
+ return map.remove(handle) ?: throw InternalException("UniffiHandleMap: Invalid handle")
367
+ }
368
+ }
369
+
370
+ // Contains loading, initialization code,
371
+ // and the FFI Function declarations in a com.sun.jna.Library.
372
+ @Synchronized
373
+ private fun findLibraryName(componentName: String): String {
374
+ val libOverride = System.getProperty("uniffi.component.$componentName.libraryOverride")
375
+ if (libOverride != null) {
376
+ return libOverride
377
+ }
378
+ return "editor_core"
379
+ }
380
+
381
+ private inline fun <reified Lib : Library> loadIndirect(
382
+ componentName: String
383
+ ): Lib {
384
+ return Native.load<Lib>(findLibraryName(componentName), Lib::class.java)
385
+ }
386
+
387
+ // Define FFI callback types
388
+ internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback {
389
+ fun callback(`data`: Long,`pollResult`: Byte,)
390
+ }
391
+ internal interface UniffiForeignFutureFree : com.sun.jna.Callback {
392
+ fun callback(`handle`: Long,)
393
+ }
394
+ internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback {
395
+ fun callback(`handle`: Long,)
396
+ }
397
+ @Structure.FieldOrder("handle", "free")
398
+ internal open class UniffiForeignFuture(
399
+ @JvmField internal var `handle`: Long = 0.toLong(),
400
+ @JvmField internal var `free`: UniffiForeignFutureFree? = null,
401
+ ) : Structure() {
402
+ class UniffiByValue(
403
+ `handle`: Long = 0.toLong(),
404
+ `free`: UniffiForeignFutureFree? = null,
405
+ ): UniffiForeignFuture(`handle`,`free`,), Structure.ByValue
406
+
407
+ internal fun uniffiSetValue(other: UniffiForeignFuture) {
408
+ `handle` = other.`handle`
409
+ `free` = other.`free`
410
+ }
411
+
412
+ }
413
+ @Structure.FieldOrder("returnValue", "callStatus")
414
+ internal open class UniffiForeignFutureStructU8(
415
+ @JvmField internal var `returnValue`: Byte = 0.toByte(),
416
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
417
+ ) : Structure() {
418
+ class UniffiByValue(
419
+ `returnValue`: Byte = 0.toByte(),
420
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
421
+ ): UniffiForeignFutureStructU8(`returnValue`,`callStatus`,), Structure.ByValue
422
+
423
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructU8) {
424
+ `returnValue` = other.`returnValue`
425
+ `callStatus` = other.`callStatus`
426
+ }
427
+
428
+ }
429
+ internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback {
430
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU8.UniffiByValue,)
431
+ }
432
+ @Structure.FieldOrder("returnValue", "callStatus")
433
+ internal open class UniffiForeignFutureStructI8(
434
+ @JvmField internal var `returnValue`: Byte = 0.toByte(),
435
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
436
+ ) : Structure() {
437
+ class UniffiByValue(
438
+ `returnValue`: Byte = 0.toByte(),
439
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
440
+ ): UniffiForeignFutureStructI8(`returnValue`,`callStatus`,), Structure.ByValue
441
+
442
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructI8) {
443
+ `returnValue` = other.`returnValue`
444
+ `callStatus` = other.`callStatus`
445
+ }
446
+
447
+ }
448
+ internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback {
449
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI8.UniffiByValue,)
450
+ }
451
+ @Structure.FieldOrder("returnValue", "callStatus")
452
+ internal open class UniffiForeignFutureStructU16(
453
+ @JvmField internal var `returnValue`: Short = 0.toShort(),
454
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
455
+ ) : Structure() {
456
+ class UniffiByValue(
457
+ `returnValue`: Short = 0.toShort(),
458
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
459
+ ): UniffiForeignFutureStructU16(`returnValue`,`callStatus`,), Structure.ByValue
460
+
461
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructU16) {
462
+ `returnValue` = other.`returnValue`
463
+ `callStatus` = other.`callStatus`
464
+ }
465
+
466
+ }
467
+ internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback {
468
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU16.UniffiByValue,)
469
+ }
470
+ @Structure.FieldOrder("returnValue", "callStatus")
471
+ internal open class UniffiForeignFutureStructI16(
472
+ @JvmField internal var `returnValue`: Short = 0.toShort(),
473
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
474
+ ) : Structure() {
475
+ class UniffiByValue(
476
+ `returnValue`: Short = 0.toShort(),
477
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
478
+ ): UniffiForeignFutureStructI16(`returnValue`,`callStatus`,), Structure.ByValue
479
+
480
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructI16) {
481
+ `returnValue` = other.`returnValue`
482
+ `callStatus` = other.`callStatus`
483
+ }
484
+
485
+ }
486
+ internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback {
487
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI16.UniffiByValue,)
488
+ }
489
+ @Structure.FieldOrder("returnValue", "callStatus")
490
+ internal open class UniffiForeignFutureStructU32(
491
+ @JvmField internal var `returnValue`: Int = 0,
492
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
493
+ ) : Structure() {
494
+ class UniffiByValue(
495
+ `returnValue`: Int = 0,
496
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
497
+ ): UniffiForeignFutureStructU32(`returnValue`,`callStatus`,), Structure.ByValue
498
+
499
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructU32) {
500
+ `returnValue` = other.`returnValue`
501
+ `callStatus` = other.`callStatus`
502
+ }
503
+
504
+ }
505
+ internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback {
506
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU32.UniffiByValue,)
507
+ }
508
+ @Structure.FieldOrder("returnValue", "callStatus")
509
+ internal open class UniffiForeignFutureStructI32(
510
+ @JvmField internal var `returnValue`: Int = 0,
511
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
512
+ ) : Structure() {
513
+ class UniffiByValue(
514
+ `returnValue`: Int = 0,
515
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
516
+ ): UniffiForeignFutureStructI32(`returnValue`,`callStatus`,), Structure.ByValue
517
+
518
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructI32) {
519
+ `returnValue` = other.`returnValue`
520
+ `callStatus` = other.`callStatus`
521
+ }
522
+
523
+ }
524
+ internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback {
525
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI32.UniffiByValue,)
526
+ }
527
+ @Structure.FieldOrder("returnValue", "callStatus")
528
+ internal open class UniffiForeignFutureStructU64(
529
+ @JvmField internal var `returnValue`: Long = 0.toLong(),
530
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
531
+ ) : Structure() {
532
+ class UniffiByValue(
533
+ `returnValue`: Long = 0.toLong(),
534
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
535
+ ): UniffiForeignFutureStructU64(`returnValue`,`callStatus`,), Structure.ByValue
536
+
537
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructU64) {
538
+ `returnValue` = other.`returnValue`
539
+ `callStatus` = other.`callStatus`
540
+ }
541
+
542
+ }
543
+ internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback {
544
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU64.UniffiByValue,)
545
+ }
546
+ @Structure.FieldOrder("returnValue", "callStatus")
547
+ internal open class UniffiForeignFutureStructI64(
548
+ @JvmField internal var `returnValue`: Long = 0.toLong(),
549
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
550
+ ) : Structure() {
551
+ class UniffiByValue(
552
+ `returnValue`: Long = 0.toLong(),
553
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
554
+ ): UniffiForeignFutureStructI64(`returnValue`,`callStatus`,), Structure.ByValue
555
+
556
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructI64) {
557
+ `returnValue` = other.`returnValue`
558
+ `callStatus` = other.`callStatus`
559
+ }
560
+
561
+ }
562
+ internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback {
563
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI64.UniffiByValue,)
564
+ }
565
+ @Structure.FieldOrder("returnValue", "callStatus")
566
+ internal open class UniffiForeignFutureStructF32(
567
+ @JvmField internal var `returnValue`: Float = 0.0f,
568
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
569
+ ) : Structure() {
570
+ class UniffiByValue(
571
+ `returnValue`: Float = 0.0f,
572
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
573
+ ): UniffiForeignFutureStructF32(`returnValue`,`callStatus`,), Structure.ByValue
574
+
575
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructF32) {
576
+ `returnValue` = other.`returnValue`
577
+ `callStatus` = other.`callStatus`
578
+ }
579
+
580
+ }
581
+ internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback {
582
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructF32.UniffiByValue,)
583
+ }
584
+ @Structure.FieldOrder("returnValue", "callStatus")
585
+ internal open class UniffiForeignFutureStructF64(
586
+ @JvmField internal var `returnValue`: Double = 0.0,
587
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
588
+ ) : Structure() {
589
+ class UniffiByValue(
590
+ `returnValue`: Double = 0.0,
591
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
592
+ ): UniffiForeignFutureStructF64(`returnValue`,`callStatus`,), Structure.ByValue
593
+
594
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructF64) {
595
+ `returnValue` = other.`returnValue`
596
+ `callStatus` = other.`callStatus`
597
+ }
598
+
599
+ }
600
+ internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback {
601
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructF64.UniffiByValue,)
602
+ }
603
+ @Structure.FieldOrder("returnValue", "callStatus")
604
+ internal open class UniffiForeignFutureStructPointer(
605
+ @JvmField internal var `returnValue`: Pointer = Pointer.NULL,
606
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
607
+ ) : Structure() {
608
+ class UniffiByValue(
609
+ `returnValue`: Pointer = Pointer.NULL,
610
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
611
+ ): UniffiForeignFutureStructPointer(`returnValue`,`callStatus`,), Structure.ByValue
612
+
613
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructPointer) {
614
+ `returnValue` = other.`returnValue`
615
+ `callStatus` = other.`callStatus`
616
+ }
617
+
618
+ }
619
+ internal interface UniffiForeignFutureCompletePointer : com.sun.jna.Callback {
620
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructPointer.UniffiByValue,)
621
+ }
622
+ @Structure.FieldOrder("returnValue", "callStatus")
623
+ internal open class UniffiForeignFutureStructRustBuffer(
624
+ @JvmField internal var `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
625
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
626
+ ) : Structure() {
627
+ class UniffiByValue(
628
+ `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
629
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
630
+ ): UniffiForeignFutureStructRustBuffer(`returnValue`,`callStatus`,), Structure.ByValue
631
+
632
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructRustBuffer) {
633
+ `returnValue` = other.`returnValue`
634
+ `callStatus` = other.`callStatus`
635
+ }
636
+
637
+ }
638
+ internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback {
639
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructRustBuffer.UniffiByValue,)
640
+ }
641
+ @Structure.FieldOrder("callStatus")
642
+ internal open class UniffiForeignFutureStructVoid(
643
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
644
+ ) : Structure() {
645
+ class UniffiByValue(
646
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
647
+ ): UniffiForeignFutureStructVoid(`callStatus`,), Structure.ByValue
648
+
649
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructVoid) {
650
+ `callStatus` = other.`callStatus`
651
+ }
652
+
653
+ }
654
+ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback {
655
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructVoid.UniffiByValue,)
656
+ }
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+
672
+
673
+
674
+
675
+
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+ // For large crates we prevent `MethodTooLargeException` (see #2340)
804
+ // N.B. the name of the extension is very misleading, since it is
805
+ // rather `InterfaceTooLargeException`, caused by too many methods
806
+ // in the interface for large crates.
807
+ //
808
+ // By splitting the otherwise huge interface into two parts
809
+ // * UniffiLib
810
+ // * IntegrityCheckingUniffiLib (this)
811
+ // we allow for ~2x as many methods in the UniffiLib interface.
812
+ //
813
+ // The `ffi_uniffi_contract_version` method and all checksum methods are put
814
+ // into `IntegrityCheckingUniffiLib` and these methods are called only once,
815
+ // when the library is loaded.
816
+ internal interface IntegrityCheckingUniffiLib : Library {
817
+ // Integrity check functions only
818
+ fun uniffi_editor_core_checksum_func_editor_core_version(
819
+ ): Short
820
+ fun uniffi_editor_core_checksum_func_editor_v2_apply_command(
821
+ ): Short
822
+ fun uniffi_editor_core_checksum_func_editor_v2_apply_input(
823
+ ): Short
824
+ fun uniffi_editor_core_checksum_func_editor_v2_apply_local_api(
825
+ ): Short
826
+ fun uniffi_editor_core_checksum_func_editor_v2_apply_native_intent(
827
+ ): Short
828
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_ack_outbound(
829
+ ): Short
830
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_detach(
831
+ ): Short
832
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_drive(
833
+ ): Short
834
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_lease_outbound(
835
+ ): Short
836
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_nack_outbound(
837
+ ): Short
838
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_peers(
839
+ ): Short
840
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_reattach(
841
+ ): Short
842
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_receive(
843
+ ): Short
844
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_set_awareness(
845
+ ): Short
846
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_set_awareness_selection(
847
+ ): Short
848
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_socket_close(
849
+ ): Short
850
+ fun uniffi_editor_core_checksum_func_editor_v2_collaboration_socket_open(
851
+ ): Short
852
+ fun uniffi_editor_core_checksum_func_editor_v2_create(
853
+ ): Short
854
+ fun uniffi_editor_core_checksum_func_editor_v2_destroy(
855
+ ): Short
856
+ fun uniffi_editor_core_checksum_func_editor_v2_doc_to_scalar(
857
+ ): Short
858
+ fun uniffi_editor_core_checksum_func_editor_v2_get_content_snapshot(
859
+ ): Short
860
+ fun uniffi_editor_core_checksum_func_editor_v2_get_document_html(
861
+ ): Short
862
+ fun uniffi_editor_core_checksum_func_editor_v2_get_document_json(
863
+ ): Short
864
+ fun uniffi_editor_core_checksum_func_editor_v2_get_state(
865
+ ): Short
866
+ fun uniffi_editor_core_checksum_func_editor_v2_pin_position_epoch(
867
+ ): Short
868
+ fun uniffi_editor_core_checksum_func_editor_v2_redo(
869
+ ): Short
870
+ fun uniffi_editor_core_checksum_func_editor_v2_release_native_binding(
871
+ ): Short
872
+ fun uniffi_editor_core_checksum_func_editor_v2_render_native(
873
+ ): Short
874
+ fun uniffi_editor_core_checksum_func_editor_v2_render_update(
875
+ ): Short
876
+ fun uniffi_editor_core_checksum_func_editor_v2_replace_document(
877
+ ): Short
878
+ fun uniffi_editor_core_checksum_func_editor_v2_resolve_scalar_selection(
879
+ ): Short
880
+ fun uniffi_editor_core_checksum_func_editor_v2_scalar_to_doc(
881
+ ): Short
882
+ fun uniffi_editor_core_checksum_func_editor_v2_set_selection(
883
+ ): Short
884
+ fun uniffi_editor_core_checksum_func_editor_v2_snapshot_export(
885
+ ): Short
886
+ fun uniffi_editor_core_checksum_func_editor_v2_snapshot_restore(
887
+ ): Short
888
+ fun uniffi_editor_core_checksum_func_editor_v2_undo(
889
+ ): Short
890
+ fun uniffi_editor_core_checksum_func_viewer_compile(
891
+ ): Short
892
+ fun uniffi_editor_core_checksum_method_viewercompileddocument_elements(
893
+ ): Short
894
+ fun uniffi_editor_core_checksum_method_viewercompileddocument_is_empty(
895
+ ): Short
896
+ fun uniffi_editor_core_checksum_method_viewercompileddocument_preferred_text_block_name(
897
+ ): Short
898
+ fun uniffi_editor_core_checksum_method_viewercompileddocument_retained_bytes_decimal(
899
+ ): Short
900
+ fun uniffi_editor_core_checksum_method_viewercompileddocument_semantic_key(
901
+ ): Short
902
+ fun uniffi_editor_core_checksum_method_viewercompileddocument_trailing_empty_text_block_count(
903
+ ): Short
904
+ fun ffi_editor_core_uniffi_contract_version(
905
+ ): Int
906
+
907
+ }
908
+
909
+ // A JNA Library to expose the extern-C FFI definitions.
910
+ // This is an implementation detail which will be called internally by the public API.
911
+ internal interface UniffiLib : Library {
912
+ companion object {
913
+ internal val INSTANCE: UniffiLib by lazy {
914
+ val componentName = "editor_core"
915
+ // For large crates we prevent `MethodTooLargeException` (see #2340)
916
+ // N.B. the name of the extension is very misleading, since it is
917
+ // rather `InterfaceTooLargeException`, caused by too many methods
918
+ // in the interface for large crates.
919
+ //
920
+ // By splitting the otherwise huge interface into two parts
921
+ // * UniffiLib (this)
922
+ // * IntegrityCheckingUniffiLib
923
+ // And all checksum methods are put into `IntegrityCheckingUniffiLib`
924
+ // we allow for ~2x as many methods in the UniffiLib interface.
925
+ //
926
+ // Thus we first load the library with `loadIndirect` as `IntegrityCheckingUniffiLib`
927
+ // so that we can (optionally!) call `uniffiCheckApiChecksums`...
928
+ loadIndirect<IntegrityCheckingUniffiLib>(componentName)
929
+ .also { lib: IntegrityCheckingUniffiLib ->
930
+ uniffiCheckContractApiVersion(lib)
931
+ uniffiCheckApiChecksums(lib)
932
+ }
933
+ // ... and then we load the library as `UniffiLib`
934
+ // N.B. we cannot use `loadIndirect` once and then try to cast it to `UniffiLib`
935
+ // => results in `java.lang.ClassCastException: com.sun.proxy.$Proxy cannot be cast to ...`
936
+ // error. So we must call `loadIndirect` twice. For crates large enough
937
+ // to trigger this issue, the performance impact is negligible, running on
938
+ // a macOS M1 machine the `loadIndirect` call takes ~50ms.
939
+ val lib = loadIndirect<UniffiLib>(componentName)
940
+ // No need to check the contract version and checksums, since
941
+ // we already did that with `IntegrityCheckingUniffiLib` above.
942
+ // Loading of library with integrity check done.
943
+ lib
944
+ }
945
+
946
+ // The Cleaner for the whole library
947
+ internal val CLEANER: UniffiCleaner by lazy {
948
+ UniffiCleaner.create()
949
+ }
950
+ }
951
+
952
+ // FFI functions
953
+ fun uniffi_editor_core_fn_clone_viewercompileddocument(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
954
+ ): Pointer
955
+ fun uniffi_editor_core_fn_free_viewercompileddocument(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
956
+ ): Unit
957
+ fun uniffi_editor_core_fn_method_viewercompileddocument_elements(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
958
+ ): RustBuffer.ByValue
959
+ fun uniffi_editor_core_fn_method_viewercompileddocument_is_empty(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
960
+ ): Byte
961
+ fun uniffi_editor_core_fn_method_viewercompileddocument_preferred_text_block_name(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
962
+ ): RustBuffer.ByValue
963
+ fun uniffi_editor_core_fn_method_viewercompileddocument_retained_bytes_decimal(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
964
+ ): RustBuffer.ByValue
965
+ fun uniffi_editor_core_fn_method_viewercompileddocument_semantic_key(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
966
+ ): RustBuffer.ByValue
967
+ fun uniffi_editor_core_fn_method_viewercompileddocument_trailing_empty_text_block_count(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
968
+ ): Int
969
+ fun uniffi_editor_core_fn_func_editor_core_version(uniffi_out_err: UniffiRustCallStatus,
970
+ ): RustBuffer.ByValue
971
+ fun uniffi_editor_core_fn_func_editor_v2_apply_command(`editorId`: RustBuffer.ByValue,`requestJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
972
+ ): RustBuffer.ByValue
973
+ fun uniffi_editor_core_fn_func_editor_v2_apply_input(`editorId`: RustBuffer.ByValue,`requestJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
974
+ ): RustBuffer.ByValue
975
+ fun uniffi_editor_core_fn_func_editor_v2_apply_local_api(`editorId`: RustBuffer.ByValue,`requestJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
976
+ ): RustBuffer.ByValue
977
+ fun uniffi_editor_core_fn_func_editor_v2_apply_native_intent(`editorId`: RustBuffer.ByValue,`requestJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
978
+ ): RustBuffer.ByValue
979
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_ack_outbound(`editorId`: RustBuffer.ByValue,`generation`: RustBuffer.ByValue,`leaseId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
980
+ ): RustBuffer.ByValue
981
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_detach(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
982
+ ): RustBuffer.ByValue
983
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_drive(`editorId`: RustBuffer.ByValue,`nowMillis`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
984
+ ): RustBuffer.ByValue
985
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_lease_outbound(`editorId`: RustBuffer.ByValue,`generation`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
986
+ ): RustBuffer.ByValue
987
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_nack_outbound(`editorId`: RustBuffer.ByValue,`generation`: RustBuffer.ByValue,`leaseId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
988
+ ): RustBuffer.ByValue
989
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_peers(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
990
+ ): RustBuffer.ByValue
991
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_reattach(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
992
+ ): RustBuffer.ByValue
993
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_receive(`editorId`: RustBuffer.ByValue,`generation`: RustBuffer.ByValue,`message`: RustBuffer.ByValue,`nowMillis`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
994
+ ): RustBuffer.ByValue
995
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_set_awareness(`editorId`: RustBuffer.ByValue,`awarenessJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
996
+ ): RustBuffer.ByValue
997
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_set_awareness_selection(`editorId`: RustBuffer.ByValue,`selectionJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
998
+ ): RustBuffer.ByValue
999
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_socket_close(`editorId`: RustBuffer.ByValue,`generation`: RustBuffer.ByValue,`code`: RustBuffer.ByValue,`reason`: RustBuffer.ByValue,`nowMillis`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1000
+ ): RustBuffer.ByValue
1001
+ fun uniffi_editor_core_fn_func_editor_v2_collaboration_socket_open(`editorId`: RustBuffer.ByValue,`generation`: RustBuffer.ByValue,`nowMillis`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1002
+ ): RustBuffer.ByValue
1003
+ fun uniffi_editor_core_fn_func_editor_v2_create(`configJson`: RustBuffer.ByValue,`snapshotState`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1004
+ ): RustBuffer.ByValue
1005
+ fun uniffi_editor_core_fn_func_editor_v2_destroy(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1006
+ ): RustBuffer.ByValue
1007
+ fun uniffi_editor_core_fn_func_editor_v2_doc_to_scalar(`editorId`: RustBuffer.ByValue,`docPos`: Int,uniffi_out_err: UniffiRustCallStatus,
1008
+ ): RustBuffer.ByValue
1009
+ fun uniffi_editor_core_fn_func_editor_v2_get_content_snapshot(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1010
+ ): RustBuffer.ByValue
1011
+ fun uniffi_editor_core_fn_func_editor_v2_get_document_html(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1012
+ ): RustBuffer.ByValue
1013
+ fun uniffi_editor_core_fn_func_editor_v2_get_document_json(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1014
+ ): RustBuffer.ByValue
1015
+ fun uniffi_editor_core_fn_func_editor_v2_get_state(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1016
+ ): RustBuffer.ByValue
1017
+ fun uniffi_editor_core_fn_func_editor_v2_pin_position_epoch(`editorId`: RustBuffer.ByValue,`ownerId`: RustBuffer.ByValue,`documentRevision`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1018
+ ): RustBuffer.ByValue
1019
+ fun uniffi_editor_core_fn_func_editor_v2_redo(`editorId`: RustBuffer.ByValue,`requestJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1020
+ ): RustBuffer.ByValue
1021
+ fun uniffi_editor_core_fn_func_editor_v2_release_native_binding(`editorId`: RustBuffer.ByValue,`ownerId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1022
+ ): RustBuffer.ByValue
1023
+ fun uniffi_editor_core_fn_func_editor_v2_render_native(`editorId`: RustBuffer.ByValue,`ownerId`: RustBuffer.ByValue,`mirrorScalarAnchor`: RustBuffer.ByValue,`mirrorScalarHead`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1024
+ ): RustBuffer.ByValue
1025
+ fun uniffi_editor_core_fn_func_editor_v2_render_update(`editorId`: RustBuffer.ByValue,`mirrorScalarAnchor`: RustBuffer.ByValue,`mirrorScalarHead`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1026
+ ): RustBuffer.ByValue
1027
+ fun uniffi_editor_core_fn_func_editor_v2_replace_document(`editorId`: RustBuffer.ByValue,`requestJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1028
+ ): RustBuffer.ByValue
1029
+ fun uniffi_editor_core_fn_func_editor_v2_resolve_scalar_selection(`editorId`: RustBuffer.ByValue,`scalarAnchor`: Int,`scalarHead`: Int,uniffi_out_err: UniffiRustCallStatus,
1030
+ ): RustBuffer.ByValue
1031
+ fun uniffi_editor_core_fn_func_editor_v2_scalar_to_doc(`editorId`: RustBuffer.ByValue,`scalar`: Int,uniffi_out_err: UniffiRustCallStatus,
1032
+ ): RustBuffer.ByValue
1033
+ fun uniffi_editor_core_fn_func_editor_v2_set_selection(`editorId`: RustBuffer.ByValue,`requestJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1034
+ ): RustBuffer.ByValue
1035
+ fun uniffi_editor_core_fn_func_editor_v2_snapshot_export(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1036
+ ): RustBuffer.ByValue
1037
+ fun uniffi_editor_core_fn_func_editor_v2_snapshot_restore(`editorId`: RustBuffer.ByValue,`metadataJson`: RustBuffer.ByValue,`encodedState`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1038
+ ): RustBuffer.ByValue
1039
+ fun uniffi_editor_core_fn_func_editor_v2_undo(`editorId`: RustBuffer.ByValue,`requestJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1040
+ ): RustBuffer.ByValue
1041
+ fun uniffi_editor_core_fn_func_viewer_compile(`request`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1042
+ ): RustBuffer.ByValue
1043
+ fun ffi_editor_core_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus,
1044
+ ): RustBuffer.ByValue
1045
+ fun ffi_editor_core_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus,
1046
+ ): RustBuffer.ByValue
1047
+ fun ffi_editor_core_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
1048
+ ): Unit
1049
+ fun ffi_editor_core_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus,
1050
+ ): RustBuffer.ByValue
1051
+ fun ffi_editor_core_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1052
+ ): Unit
1053
+ fun ffi_editor_core_rust_future_cancel_u8(`handle`: Long,
1054
+ ): Unit
1055
+ fun ffi_editor_core_rust_future_free_u8(`handle`: Long,
1056
+ ): Unit
1057
+ fun ffi_editor_core_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1058
+ ): Byte
1059
+ fun ffi_editor_core_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1060
+ ): Unit
1061
+ fun ffi_editor_core_rust_future_cancel_i8(`handle`: Long,
1062
+ ): Unit
1063
+ fun ffi_editor_core_rust_future_free_i8(`handle`: Long,
1064
+ ): Unit
1065
+ fun ffi_editor_core_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1066
+ ): Byte
1067
+ fun ffi_editor_core_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1068
+ ): Unit
1069
+ fun ffi_editor_core_rust_future_cancel_u16(`handle`: Long,
1070
+ ): Unit
1071
+ fun ffi_editor_core_rust_future_free_u16(`handle`: Long,
1072
+ ): Unit
1073
+ fun ffi_editor_core_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1074
+ ): Short
1075
+ fun ffi_editor_core_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1076
+ ): Unit
1077
+ fun ffi_editor_core_rust_future_cancel_i16(`handle`: Long,
1078
+ ): Unit
1079
+ fun ffi_editor_core_rust_future_free_i16(`handle`: Long,
1080
+ ): Unit
1081
+ fun ffi_editor_core_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1082
+ ): Short
1083
+ fun ffi_editor_core_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1084
+ ): Unit
1085
+ fun ffi_editor_core_rust_future_cancel_u32(`handle`: Long,
1086
+ ): Unit
1087
+ fun ffi_editor_core_rust_future_free_u32(`handle`: Long,
1088
+ ): Unit
1089
+ fun ffi_editor_core_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1090
+ ): Int
1091
+ fun ffi_editor_core_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1092
+ ): Unit
1093
+ fun ffi_editor_core_rust_future_cancel_i32(`handle`: Long,
1094
+ ): Unit
1095
+ fun ffi_editor_core_rust_future_free_i32(`handle`: Long,
1096
+ ): Unit
1097
+ fun ffi_editor_core_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1098
+ ): Int
1099
+ fun ffi_editor_core_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1100
+ ): Unit
1101
+ fun ffi_editor_core_rust_future_cancel_u64(`handle`: Long,
1102
+ ): Unit
1103
+ fun ffi_editor_core_rust_future_free_u64(`handle`: Long,
1104
+ ): Unit
1105
+ fun ffi_editor_core_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1106
+ ): Long
1107
+ fun ffi_editor_core_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1108
+ ): Unit
1109
+ fun ffi_editor_core_rust_future_cancel_i64(`handle`: Long,
1110
+ ): Unit
1111
+ fun ffi_editor_core_rust_future_free_i64(`handle`: Long,
1112
+ ): Unit
1113
+ fun ffi_editor_core_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1114
+ ): Long
1115
+ fun ffi_editor_core_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1116
+ ): Unit
1117
+ fun ffi_editor_core_rust_future_cancel_f32(`handle`: Long,
1118
+ ): Unit
1119
+ fun ffi_editor_core_rust_future_free_f32(`handle`: Long,
1120
+ ): Unit
1121
+ fun ffi_editor_core_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1122
+ ): Float
1123
+ fun ffi_editor_core_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1124
+ ): Unit
1125
+ fun ffi_editor_core_rust_future_cancel_f64(`handle`: Long,
1126
+ ): Unit
1127
+ fun ffi_editor_core_rust_future_free_f64(`handle`: Long,
1128
+ ): Unit
1129
+ fun ffi_editor_core_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1130
+ ): Double
1131
+ fun ffi_editor_core_rust_future_poll_pointer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1132
+ ): Unit
1133
+ fun ffi_editor_core_rust_future_cancel_pointer(`handle`: Long,
1134
+ ): Unit
1135
+ fun ffi_editor_core_rust_future_free_pointer(`handle`: Long,
1136
+ ): Unit
1137
+ fun ffi_editor_core_rust_future_complete_pointer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1138
+ ): Pointer
1139
+ fun ffi_editor_core_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1140
+ ): Unit
1141
+ fun ffi_editor_core_rust_future_cancel_rust_buffer(`handle`: Long,
1142
+ ): Unit
1143
+ fun ffi_editor_core_rust_future_free_rust_buffer(`handle`: Long,
1144
+ ): Unit
1145
+ fun ffi_editor_core_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1146
+ ): RustBuffer.ByValue
1147
+ fun ffi_editor_core_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1148
+ ): Unit
1149
+ fun ffi_editor_core_rust_future_cancel_void(`handle`: Long,
1150
+ ): Unit
1151
+ fun ffi_editor_core_rust_future_free_void(`handle`: Long,
1152
+ ): Unit
1153
+ fun ffi_editor_core_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1154
+ ): Unit
1155
+
1156
+ }
1157
+
1158
+ private fun uniffiCheckContractApiVersion(lib: IntegrityCheckingUniffiLib) {
1159
+ // Get the bindings contract version from our ComponentInterface
1160
+ val bindings_contract_version = 29
1161
+ // Get the scaffolding contract version by calling the into the dylib
1162
+ val scaffolding_contract_version = lib.ffi_editor_core_uniffi_contract_version()
1163
+ if (bindings_contract_version != scaffolding_contract_version) {
1164
+ throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project")
1165
+ }
1166
+ }
1167
+ @Suppress("UNUSED_PARAMETER")
1168
+ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
1169
+ if (lib.uniffi_editor_core_checksum_func_editor_core_version() != 41638.toShort()) {
1170
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1171
+ }
1172
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_apply_command() != 14484.toShort()) {
1173
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1174
+ }
1175
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_apply_input() != 29912.toShort()) {
1176
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1177
+ }
1178
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_apply_local_api() != 36451.toShort()) {
1179
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1180
+ }
1181
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_apply_native_intent() != 46364.toShort()) {
1182
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1183
+ }
1184
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_ack_outbound() != 21755.toShort()) {
1185
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1186
+ }
1187
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_detach() != 25325.toShort()) {
1188
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1189
+ }
1190
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_drive() != 55434.toShort()) {
1191
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1192
+ }
1193
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_lease_outbound() != 56190.toShort()) {
1194
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1195
+ }
1196
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_nack_outbound() != 29045.toShort()) {
1197
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1198
+ }
1199
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_peers() != 754.toShort()) {
1200
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1201
+ }
1202
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_reattach() != 44291.toShort()) {
1203
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1204
+ }
1205
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_receive() != 19926.toShort()) {
1206
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1207
+ }
1208
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_set_awareness() != 59502.toShort()) {
1209
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1210
+ }
1211
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_set_awareness_selection() != 3071.toShort()) {
1212
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1213
+ }
1214
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_socket_close() != 53946.toShort()) {
1215
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1216
+ }
1217
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_collaboration_socket_open() != 25835.toShort()) {
1218
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1219
+ }
1220
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_create() != 9333.toShort()) {
1221
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1222
+ }
1223
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_destroy() != 8349.toShort()) {
1224
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1225
+ }
1226
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_doc_to_scalar() != 62503.toShort()) {
1227
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1228
+ }
1229
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_get_content_snapshot() != 21323.toShort()) {
1230
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1231
+ }
1232
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_get_document_html() != 60959.toShort()) {
1233
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1234
+ }
1235
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_get_document_json() != 25683.toShort()) {
1236
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1237
+ }
1238
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_get_state() != 43856.toShort()) {
1239
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1240
+ }
1241
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_pin_position_epoch() != 42714.toShort()) {
1242
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1243
+ }
1244
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_redo() != 48065.toShort()) {
1245
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1246
+ }
1247
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_release_native_binding() != 2756.toShort()) {
1248
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1249
+ }
1250
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_render_native() != 16234.toShort()) {
1251
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1252
+ }
1253
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_render_update() != 13282.toShort()) {
1254
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1255
+ }
1256
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_replace_document() != 31032.toShort()) {
1257
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1258
+ }
1259
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_resolve_scalar_selection() != 26332.toShort()) {
1260
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1261
+ }
1262
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_scalar_to_doc() != 60383.toShort()) {
1263
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1264
+ }
1265
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_set_selection() != 39340.toShort()) {
1266
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1267
+ }
1268
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_snapshot_export() != 2193.toShort()) {
1269
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1270
+ }
1271
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_snapshot_restore() != 47504.toShort()) {
1272
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1273
+ }
1274
+ if (lib.uniffi_editor_core_checksum_func_editor_v2_undo() != 2492.toShort()) {
1275
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1276
+ }
1277
+ if (lib.uniffi_editor_core_checksum_func_viewer_compile() != 60070.toShort()) {
1278
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1279
+ }
1280
+ if (lib.uniffi_editor_core_checksum_method_viewercompileddocument_elements() != 50589.toShort()) {
1281
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1282
+ }
1283
+ if (lib.uniffi_editor_core_checksum_method_viewercompileddocument_is_empty() != 2370.toShort()) {
1284
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1285
+ }
1286
+ if (lib.uniffi_editor_core_checksum_method_viewercompileddocument_preferred_text_block_name() != 32137.toShort()) {
1287
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1288
+ }
1289
+ if (lib.uniffi_editor_core_checksum_method_viewercompileddocument_retained_bytes_decimal() != 13333.toShort()) {
1290
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1291
+ }
1292
+ if (lib.uniffi_editor_core_checksum_method_viewercompileddocument_semantic_key() != 2241.toShort()) {
1293
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1294
+ }
1295
+ if (lib.uniffi_editor_core_checksum_method_viewercompileddocument_trailing_empty_text_block_count() != 11698.toShort()) {
1296
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1297
+ }
1298
+ }
1299
+
1300
+ /**
1301
+ * @suppress
1302
+ */
1303
+ public fun uniffiEnsureInitialized() {
1304
+ UniffiLib.INSTANCE
1305
+ }
1306
+
1307
+ // Async support
1308
+
1309
+ // Public interface members begin here.
1310
+
1311
+
1312
+ // Interface implemented by anything that can contain an object reference.
1313
+ //
1314
+ // Such types expose a `destroy()` method that must be called to cleanly
1315
+ // dispose of the contained objects. Failure to call this method may result
1316
+ // in memory leaks.
1317
+ //
1318
+ // The easiest way to ensure this method is called is to use the `.use`
1319
+ // helper method to execute a block and destroy the object at the end.
1320
+ interface Disposable {
1321
+ fun destroy()
1322
+ companion object {
1323
+ fun destroy(vararg args: Any?) {
1324
+ for (arg in args) {
1325
+ when (arg) {
1326
+ is Disposable -> arg.destroy()
1327
+ is ArrayList<*> -> {
1328
+ for (idx in arg.indices) {
1329
+ val element = arg[idx]
1330
+ if (element is Disposable) {
1331
+ element.destroy()
1332
+ }
1333
+ }
1334
+ }
1335
+ is Map<*, *> -> {
1336
+ for (element in arg.values) {
1337
+ if (element is Disposable) {
1338
+ element.destroy()
1339
+ }
1340
+ }
1341
+ }
1342
+ is Iterable<*> -> {
1343
+ for (element in arg) {
1344
+ if (element is Disposable) {
1345
+ element.destroy()
1346
+ }
1347
+ }
1348
+ }
1349
+ }
1350
+ }
1351
+ }
1352
+ }
1353
+ }
1354
+
1355
+ /**
1356
+ * @suppress
1357
+ */
1358
+ inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
1359
+ try {
1360
+ block(this)
1361
+ } finally {
1362
+ try {
1363
+ // N.B. our implementation is on the nullable type `Disposable?`.
1364
+ this?.destroy()
1365
+ } catch (e: Throwable) {
1366
+ // swallow
1367
+ }
1368
+ }
1369
+
1370
+ /**
1371
+ * Used to instantiate an interface without an actual pointer, for fakes in tests, mostly.
1372
+ *
1373
+ * @suppress
1374
+ * */
1375
+ object NoPointer
1376
+ /**
1377
+ * The cleaner interface for Object finalization code to run.
1378
+ * This is the entry point to any implementation that we're using.
1379
+ *
1380
+ * The cleaner registers objects and returns cleanables, so now we are
1381
+ * defining a `UniffiCleaner` with a `UniffiClenaer.Cleanable` to abstract the
1382
+ * different implmentations available at compile time.
1383
+ *
1384
+ * @suppress
1385
+ */
1386
+ interface UniffiCleaner {
1387
+ interface Cleanable {
1388
+ fun clean()
1389
+ }
1390
+
1391
+ fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable
1392
+
1393
+ companion object
1394
+ }
1395
+
1396
+ // The fallback Jna cleaner, which is available for both Android, and the JVM.
1397
+ private class UniffiJnaCleaner : UniffiCleaner {
1398
+ private val cleaner = com.sun.jna.internal.Cleaner.getCleaner()
1399
+
1400
+ override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable =
1401
+ UniffiJnaCleanable(cleaner.register(value, cleanUpTask))
1402
+ }
1403
+
1404
+ private class UniffiJnaCleanable(
1405
+ private val cleanable: com.sun.jna.internal.Cleaner.Cleanable,
1406
+ ) : UniffiCleaner.Cleanable {
1407
+ override fun clean() = cleanable.clean()
1408
+ }
1409
+
1410
+
1411
+ // We decide at uniffi binding generation time whether we were
1412
+ // using Android or not.
1413
+ // There are further runtime checks to chose the correct implementation
1414
+ // of the cleaner.
1415
+ private fun UniffiCleaner.Companion.create(): UniffiCleaner =
1416
+ try {
1417
+ // For safety's sake: if the library hasn't been run in android_cleaner = true
1418
+ // mode, but is being run on Android, then we still need to think about
1419
+ // Android API versions.
1420
+ // So we check if java.lang.ref.Cleaner is there, and use that…
1421
+ java.lang.Class.forName("java.lang.ref.Cleaner")
1422
+ JavaLangRefCleaner()
1423
+ } catch (e: ClassNotFoundException) {
1424
+ // … otherwise, fallback to the JNA cleaner.
1425
+ UniffiJnaCleaner()
1426
+ }
1427
+
1428
+ private class JavaLangRefCleaner : UniffiCleaner {
1429
+ val cleaner = java.lang.ref.Cleaner.create()
1430
+
1431
+ override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable =
1432
+ JavaLangRefCleanable(cleaner.register(value, cleanUpTask))
1433
+ }
1434
+
1435
+ private class JavaLangRefCleanable(
1436
+ val cleanable: java.lang.ref.Cleaner.Cleanable
1437
+ ) : UniffiCleaner.Cleanable {
1438
+ override fun clean() = cleanable.clean()
1439
+ }
1440
+
1441
+ /**
1442
+ * @suppress
1443
+ */
1444
+ public object FfiConverterUShort: FfiConverter<UShort, Short> {
1445
+ override fun lift(value: Short): UShort {
1446
+ return value.toUShort()
1447
+ }
1448
+
1449
+ override fun read(buf: ByteBuffer): UShort {
1450
+ return lift(buf.getShort())
1451
+ }
1452
+
1453
+ override fun lower(value: UShort): Short {
1454
+ return value.toShort()
1455
+ }
1456
+
1457
+ override fun allocationSize(value: UShort) = 2UL
1458
+
1459
+ override fun write(value: UShort, buf: ByteBuffer) {
1460
+ buf.putShort(value.toShort())
1461
+ }
1462
+ }
1463
+
1464
+ /**
1465
+ * @suppress
1466
+ */
1467
+ public object FfiConverterUInt: FfiConverter<UInt, Int> {
1468
+ override fun lift(value: Int): UInt {
1469
+ return value.toUInt()
1470
+ }
1471
+
1472
+ override fun read(buf: ByteBuffer): UInt {
1473
+ return lift(buf.getInt())
1474
+ }
1475
+
1476
+ override fun lower(value: UInt): Int {
1477
+ return value.toInt()
1478
+ }
1479
+
1480
+ override fun allocationSize(value: UInt) = 4UL
1481
+
1482
+ override fun write(value: UInt, buf: ByteBuffer) {
1483
+ buf.putInt(value.toInt())
1484
+ }
1485
+ }
1486
+
1487
+ /**
1488
+ * @suppress
1489
+ */
1490
+ public object FfiConverterBoolean: FfiConverter<Boolean, Byte> {
1491
+ override fun lift(value: Byte): Boolean {
1492
+ return value.toInt() != 0
1493
+ }
1494
+
1495
+ override fun read(buf: ByteBuffer): Boolean {
1496
+ return lift(buf.get())
1497
+ }
1498
+
1499
+ override fun lower(value: Boolean): Byte {
1500
+ return if (value) 1.toByte() else 0.toByte()
1501
+ }
1502
+
1503
+ override fun allocationSize(value: Boolean) = 1UL
1504
+
1505
+ override fun write(value: Boolean, buf: ByteBuffer) {
1506
+ buf.put(lower(value))
1507
+ }
1508
+ }
1509
+
1510
+ /**
1511
+ * @suppress
1512
+ */
1513
+ public object FfiConverterString: FfiConverter<String, RustBuffer.ByValue> {
1514
+ // Note: we don't inherit from FfiConverterRustBuffer, because we use a
1515
+ // special encoding when lowering/lifting. We can use `RustBuffer.len` to
1516
+ // store our length and avoid writing it out to the buffer.
1517
+ override fun lift(value: RustBuffer.ByValue): String {
1518
+ try {
1519
+ val byteArr = ByteArray(value.len.toInt())
1520
+ value.asByteBuffer()!!.get(byteArr)
1521
+ return byteArr.toString(Charsets.UTF_8)
1522
+ } finally {
1523
+ RustBuffer.free(value)
1524
+ }
1525
+ }
1526
+
1527
+ override fun read(buf: ByteBuffer): String {
1528
+ val len = buf.getInt()
1529
+ val byteArr = ByteArray(len)
1530
+ buf.get(byteArr)
1531
+ return byteArr.toString(Charsets.UTF_8)
1532
+ }
1533
+
1534
+ fun toUtf8(value: String): ByteBuffer {
1535
+ // Make sure we don't have invalid UTF-16, check for lone surrogates.
1536
+ return Charsets.UTF_8.newEncoder().run {
1537
+ onMalformedInput(CodingErrorAction.REPORT)
1538
+ encode(CharBuffer.wrap(value))
1539
+ }
1540
+ }
1541
+
1542
+ override fun lower(value: String): RustBuffer.ByValue {
1543
+ val byteBuf = toUtf8(value)
1544
+ // Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us
1545
+ // to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`.
1546
+ val rbuf = RustBuffer.alloc(byteBuf.limit().toULong())
1547
+ rbuf.asByteBuffer()!!.put(byteBuf)
1548
+ return rbuf
1549
+ }
1550
+
1551
+ // We aren't sure exactly how many bytes our string will be once it's UTF-8
1552
+ // encoded. Allocate 3 bytes per UTF-16 code unit which will always be
1553
+ // enough.
1554
+ override fun allocationSize(value: String): ULong {
1555
+ val sizeForLength = 4UL
1556
+ val sizeForString = value.length.toULong() * 3UL
1557
+ return sizeForLength + sizeForString
1558
+ }
1559
+
1560
+ override fun write(value: String, buf: ByteBuffer) {
1561
+ val byteBuf = toUtf8(value)
1562
+ buf.putInt(byteBuf.limit())
1563
+ buf.put(byteBuf)
1564
+ }
1565
+ }
1566
+
1567
+ /**
1568
+ * @suppress
1569
+ */
1570
+ public object FfiConverterByteArray: FfiConverterRustBuffer<ByteArray> {
1571
+ override fun read(buf: ByteBuffer): ByteArray {
1572
+ val len = buf.getInt()
1573
+ val byteArr = ByteArray(len)
1574
+ buf.get(byteArr)
1575
+ return byteArr
1576
+ }
1577
+ override fun allocationSize(value: ByteArray): ULong {
1578
+ return 4UL + value.size.toULong()
1579
+ }
1580
+ override fun write(value: ByteArray, buf: ByteBuffer) {
1581
+ buf.putInt(value.size)
1582
+ buf.put(value)
1583
+ }
1584
+ }
1585
+
1586
+
1587
+ // This template implements a class for working with a Rust struct via a Pointer/Arc<T>
1588
+ // to the live Rust struct on the other side of the FFI.
1589
+ //
1590
+ // Each instance implements core operations for working with the Rust `Arc<T>` and the
1591
+ // Kotlin Pointer to work with the live Rust struct on the other side of the FFI.
1592
+ //
1593
+ // There's some subtlety here, because we have to be careful not to operate on a Rust
1594
+ // struct after it has been dropped, and because we must expose a public API for freeing
1595
+ // theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are:
1596
+ //
1597
+ // * Each instance holds an opaque pointer to the underlying Rust struct.
1598
+ // Method calls need to read this pointer from the object's state and pass it in to
1599
+ // the Rust FFI.
1600
+ //
1601
+ // * When an instance is no longer needed, its pointer should be passed to a
1602
+ // special destructor function provided by the Rust FFI, which will drop the
1603
+ // underlying Rust struct.
1604
+ //
1605
+ // * Given an instance, calling code is expected to call the special
1606
+ // `destroy` method in order to free it after use, either by calling it explicitly
1607
+ // or by using a higher-level helper like the `use` method. Failing to do so risks
1608
+ // leaking the underlying Rust struct.
1609
+ //
1610
+ // * We can't assume that calling code will do the right thing, and must be prepared
1611
+ // to handle Kotlin method calls executing concurrently with or even after a call to
1612
+ // `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`.
1613
+ //
1614
+ // * We must never allow Rust code to operate on the underlying Rust struct after
1615
+ // the destructor has been called, and must never call the destructor more than once.
1616
+ // Doing so may trigger memory unsafety.
1617
+ //
1618
+ // * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner`
1619
+ // is implemented to call the destructor when the Kotlin object becomes unreachable.
1620
+ // This is done in a background thread. This is not a panacea, and client code should be aware that
1621
+ // 1. the thread may starve if some there are objects that have poorly performing
1622
+ // `drop` methods or do significant work in their `drop` methods.
1623
+ // 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`,
1624
+ // or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html).
1625
+ //
1626
+ // If we try to implement this with mutual exclusion on access to the pointer, there is the
1627
+ // possibility of a race between a method call and a concurrent call to `destroy`:
1628
+ //
1629
+ // * Thread A starts a method call, reads the value of the pointer, but is interrupted
1630
+ // before it can pass the pointer over the FFI to Rust.
1631
+ // * Thread B calls `destroy` and frees the underlying Rust struct.
1632
+ // * Thread A resumes, passing the already-read pointer value to Rust and triggering
1633
+ // a use-after-free.
1634
+ //
1635
+ // One possible solution would be to use a `ReadWriteLock`, with each method call taking
1636
+ // a read lock (and thus allowed to run concurrently) and the special `destroy` method
1637
+ // taking a write lock (and thus blocking on live method calls). However, we aim not to
1638
+ // generate methods with any hidden blocking semantics, and a `destroy` method that might
1639
+ // block if called incorrectly seems to meet that bar.
1640
+ //
1641
+ // So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track
1642
+ // the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy`
1643
+ // has been called. These are updated according to the following rules:
1644
+ //
1645
+ // * The initial value of the counter is 1, indicating a live object with no in-flight calls.
1646
+ // The initial value for the flag is false.
1647
+ //
1648
+ // * At the start of each method call, we atomically check the counter.
1649
+ // If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted.
1650
+ // If it is nonzero them we atomically increment it by 1 and proceed with the method call.
1651
+ //
1652
+ // * At the end of each method call, we atomically decrement and check the counter.
1653
+ // If it has reached zero then we destroy the underlying Rust struct.
1654
+ //
1655
+ // * When `destroy` is called, we atomically flip the flag from false to true.
1656
+ // If the flag was already true we silently fail.
1657
+ // Otherwise we atomically decrement and check the counter.
1658
+ // If it has reached zero then we destroy the underlying Rust struct.
1659
+ //
1660
+ // Astute readers may observe that this all sounds very similar to the way that Rust's `Arc<T>` works,
1661
+ // and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`.
1662
+ //
1663
+ // The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been
1664
+ // called *and* all in-flight method calls have completed, avoiding violating any of the expectations
1665
+ // of the underlying Rust code.
1666
+ //
1667
+ // This makes a cleaner a better alternative to _not_ calling `destroy()` as
1668
+ // and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop`
1669
+ // method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner
1670
+ // thread may be starved, and the app will leak memory.
1671
+ //
1672
+ // In this case, `destroy`ing manually may be a better solution.
1673
+ //
1674
+ // The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects
1675
+ // with Rust peers are reclaimed:
1676
+ //
1677
+ // 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen:
1678
+ // 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then:
1679
+ // 3. The memory is reclaimed when the process terminates.
1680
+ //
1681
+ // [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219
1682
+ //
1683
+
1684
+
1685
+ public interface ViewerCompiledDocumentInterface {
1686
+
1687
+ fun `elements`(): List<FfiViewerElement>
1688
+
1689
+ fun `isEmpty`(): kotlin.Boolean
1690
+
1691
+ fun `preferredTextBlockName`(): kotlin.String
1692
+
1693
+ fun `retainedBytesDecimal`(): kotlin.String
1694
+
1695
+ fun `semanticKey`(): kotlin.String
1696
+
1697
+ fun `trailingEmptyTextBlockCount`(): kotlin.UInt
1698
+
1699
+ companion object
1700
+ }
1701
+
1702
+ open class ViewerCompiledDocument: Disposable, AutoCloseable, ViewerCompiledDocumentInterface
1703
+ {
1704
+
1705
+ constructor(pointer: Pointer) {
1706
+ this.pointer = pointer
1707
+ this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer))
1708
+ }
1709
+
1710
+ /**
1711
+ * This constructor can be used to instantiate a fake object. Only used for tests. Any
1712
+ * attempt to actually use an object constructed this way will fail as there is no
1713
+ * connected Rust object.
1714
+ */
1715
+ @Suppress("UNUSED_PARAMETER")
1716
+ constructor(noPointer: NoPointer) {
1717
+ this.pointer = null
1718
+ this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer))
1719
+ }
1720
+
1721
+ protected val pointer: Pointer?
1722
+ protected val cleanable: UniffiCleaner.Cleanable
1723
+
1724
+ private val wasDestroyed = AtomicBoolean(false)
1725
+ private val callCounter = AtomicLong(1)
1726
+
1727
+ override fun destroy() {
1728
+ // Only allow a single call to this method.
1729
+ // TODO: maybe we should log a warning if called more than once?
1730
+ if (this.wasDestroyed.compareAndSet(false, true)) {
1731
+ // This decrement always matches the initial count of 1 given at creation time.
1732
+ if (this.callCounter.decrementAndGet() == 0L) {
1733
+ cleanable.clean()
1734
+ }
1735
+ }
1736
+ }
1737
+
1738
+ @Synchronized
1739
+ override fun close() {
1740
+ this.destroy()
1741
+ }
1742
+
1743
+ internal inline fun <R> callWithPointer(block: (ptr: Pointer) -> R): R {
1744
+ // Check and increment the call counter, to keep the object alive.
1745
+ // This needs a compare-and-set retry loop in case of concurrent updates.
1746
+ do {
1747
+ val c = this.callCounter.get()
1748
+ if (c == 0L) {
1749
+ throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed")
1750
+ }
1751
+ if (c == Long.MAX_VALUE) {
1752
+ throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow")
1753
+ }
1754
+ } while (! this.callCounter.compareAndSet(c, c + 1L))
1755
+ // Now we can safely do the method call without the pointer being freed concurrently.
1756
+ try {
1757
+ return block(this.uniffiClonePointer())
1758
+ } finally {
1759
+ // This decrement always matches the increment we performed above.
1760
+ if (this.callCounter.decrementAndGet() == 0L) {
1761
+ cleanable.clean()
1762
+ }
1763
+ }
1764
+ }
1765
+
1766
+ // Use a static inner class instead of a closure so as not to accidentally
1767
+ // capture `this` as part of the cleanable's action.
1768
+ private class UniffiCleanAction(private val pointer: Pointer?) : Runnable {
1769
+ override fun run() {
1770
+ pointer?.let { ptr ->
1771
+ uniffiRustCall { status ->
1772
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_free_viewercompileddocument(ptr, status)
1773
+ }
1774
+ }
1775
+ }
1776
+ }
1777
+
1778
+ fun uniffiClonePointer(): Pointer {
1779
+ return uniffiRustCall() { status ->
1780
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_clone_viewercompileddocument(pointer!!, status)
1781
+ }
1782
+ }
1783
+
1784
+ override fun `elements`(): List<FfiViewerElement> {
1785
+ return FfiConverterSequenceTypeFfiViewerElement.lift(
1786
+ callWithPointer {
1787
+ uniffiRustCall() { _status ->
1788
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_method_viewercompileddocument_elements(
1789
+ it, _status)
1790
+ }
1791
+ }
1792
+ )
1793
+ }
1794
+
1795
+
1796
+ override fun `isEmpty`(): kotlin.Boolean {
1797
+ return FfiConverterBoolean.lift(
1798
+ callWithPointer {
1799
+ uniffiRustCall() { _status ->
1800
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_method_viewercompileddocument_is_empty(
1801
+ it, _status)
1802
+ }
1803
+ }
1804
+ )
1805
+ }
1806
+
1807
+
1808
+ override fun `preferredTextBlockName`(): kotlin.String {
1809
+ return FfiConverterString.lift(
1810
+ callWithPointer {
1811
+ uniffiRustCall() { _status ->
1812
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_method_viewercompileddocument_preferred_text_block_name(
1813
+ it, _status)
1814
+ }
1815
+ }
1816
+ )
1817
+ }
1818
+
1819
+
1820
+ override fun `retainedBytesDecimal`(): kotlin.String {
1821
+ return FfiConverterString.lift(
1822
+ callWithPointer {
1823
+ uniffiRustCall() { _status ->
1824
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_method_viewercompileddocument_retained_bytes_decimal(
1825
+ it, _status)
1826
+ }
1827
+ }
1828
+ )
1829
+ }
1830
+
1831
+
1832
+ override fun `semanticKey`(): kotlin.String {
1833
+ return FfiConverterString.lift(
1834
+ callWithPointer {
1835
+ uniffiRustCall() { _status ->
1836
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_method_viewercompileddocument_semantic_key(
1837
+ it, _status)
1838
+ }
1839
+ }
1840
+ )
1841
+ }
1842
+
1843
+
1844
+ override fun `trailingEmptyTextBlockCount`(): kotlin.UInt {
1845
+ return FfiConverterUInt.lift(
1846
+ callWithPointer {
1847
+ uniffiRustCall() { _status ->
1848
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_method_viewercompileddocument_trailing_empty_text_block_count(
1849
+ it, _status)
1850
+ }
1851
+ }
1852
+ )
1853
+ }
1854
+
1855
+
1856
+
1857
+
1858
+
1859
+
1860
+ companion object
1861
+
1862
+ }
1863
+
1864
+ /**
1865
+ * @suppress
1866
+ */
1867
+ public object FfiConverterTypeViewerCompiledDocument: FfiConverter<ViewerCompiledDocument, Pointer> {
1868
+
1869
+ override fun lower(value: ViewerCompiledDocument): Pointer {
1870
+ return value.uniffiClonePointer()
1871
+ }
1872
+
1873
+ override fun lift(value: Pointer): ViewerCompiledDocument {
1874
+ return ViewerCompiledDocument(value)
1875
+ }
1876
+
1877
+ override fun read(buf: ByteBuffer): ViewerCompiledDocument {
1878
+ // The Rust code always writes pointers as 8 bytes, and will
1879
+ // fail to compile if they don't fit.
1880
+ return lift(Pointer(buf.getLong()))
1881
+ }
1882
+
1883
+ override fun allocationSize(value: ViewerCompiledDocument) = 8UL
1884
+
1885
+ override fun write(value: ViewerCompiledDocument, buf: ByteBuffer) {
1886
+ // The Rust code always expects pointers written as 8 bytes,
1887
+ // and will fail to compile if they don't fit.
1888
+ buf.putLong(Pointer.nativeValue(lower(value)))
1889
+ }
1890
+ }
1891
+
1892
+
1893
+
1894
+ data class FfiError (
1895
+ var `domain`: kotlin.String,
1896
+ var `code`: kotlin.String,
1897
+ var `message`: kotlin.String,
1898
+ var `requestId`: kotlin.String?,
1899
+ var `operationIndex`: kotlin.String?,
1900
+ var `limit`: kotlin.String?,
1901
+ var `actual`: kotlin.String?,
1902
+ var `detailsJson`: kotlin.String?
1903
+ ) {
1904
+
1905
+ companion object
1906
+ }
1907
+
1908
+ /**
1909
+ * @suppress
1910
+ */
1911
+ public object FfiConverterTypeFfiError: FfiConverterRustBuffer<FfiError> {
1912
+ override fun read(buf: ByteBuffer): FfiError {
1913
+ return FfiError(
1914
+ FfiConverterString.read(buf),
1915
+ FfiConverterString.read(buf),
1916
+ FfiConverterString.read(buf),
1917
+ FfiConverterOptionalString.read(buf),
1918
+ FfiConverterOptionalString.read(buf),
1919
+ FfiConverterOptionalString.read(buf),
1920
+ FfiConverterOptionalString.read(buf),
1921
+ FfiConverterOptionalString.read(buf),
1922
+ )
1923
+ }
1924
+
1925
+ override fun allocationSize(value: FfiError) = (
1926
+ FfiConverterString.allocationSize(value.`domain`) +
1927
+ FfiConverterString.allocationSize(value.`code`) +
1928
+ FfiConverterString.allocationSize(value.`message`) +
1929
+ FfiConverterOptionalString.allocationSize(value.`requestId`) +
1930
+ FfiConverterOptionalString.allocationSize(value.`operationIndex`) +
1931
+ FfiConverterOptionalString.allocationSize(value.`limit`) +
1932
+ FfiConverterOptionalString.allocationSize(value.`actual`) +
1933
+ FfiConverterOptionalString.allocationSize(value.`detailsJson`)
1934
+ )
1935
+
1936
+ override fun write(value: FfiError, buf: ByteBuffer) {
1937
+ FfiConverterString.write(value.`domain`, buf)
1938
+ FfiConverterString.write(value.`code`, buf)
1939
+ FfiConverterString.write(value.`message`, buf)
1940
+ FfiConverterOptionalString.write(value.`requestId`, buf)
1941
+ FfiConverterOptionalString.write(value.`operationIndex`, buf)
1942
+ FfiConverterOptionalString.write(value.`limit`, buf)
1943
+ FfiConverterOptionalString.write(value.`actual`, buf)
1944
+ FfiConverterOptionalString.write(value.`detailsJson`, buf)
1945
+ }
1946
+ }
1947
+
1948
+
1949
+
1950
+ data class FfiJsonResult (
1951
+ var `value`: kotlin.String?,
1952
+ var `error`: FfiError?
1953
+ ) {
1954
+
1955
+ companion object
1956
+ }
1957
+
1958
+ /**
1959
+ * @suppress
1960
+ */
1961
+ public object FfiConverterTypeFfiJsonResult: FfiConverterRustBuffer<FfiJsonResult> {
1962
+ override fun read(buf: ByteBuffer): FfiJsonResult {
1963
+ return FfiJsonResult(
1964
+ FfiConverterOptionalString.read(buf),
1965
+ FfiConverterOptionalTypeFfiError.read(buf),
1966
+ )
1967
+ }
1968
+
1969
+ override fun allocationSize(value: FfiJsonResult) = (
1970
+ FfiConverterOptionalString.allocationSize(value.`value`) +
1971
+ FfiConverterOptionalTypeFfiError.allocationSize(value.`error`)
1972
+ )
1973
+
1974
+ override fun write(value: FfiJsonResult, buf: ByteBuffer) {
1975
+ FfiConverterOptionalString.write(value.`value`, buf)
1976
+ FfiConverterOptionalTypeFfiError.write(value.`error`, buf)
1977
+ }
1978
+ }
1979
+
1980
+
1981
+
1982
+ /**
1983
+ * One active outbound transport lease. The identifier stays canonical
1984
+ * decimal text while the y-protocols frame remains binary end-to-end.
1985
+ */
1986
+ data class FfiOutboundLease (
1987
+ var `leaseId`: kotlin.String,
1988
+ var `frame`: kotlin.ByteArray
1989
+ ) {
1990
+
1991
+ companion object
1992
+ }
1993
+
1994
+ /**
1995
+ * @suppress
1996
+ */
1997
+ public object FfiConverterTypeFfiOutboundLease: FfiConverterRustBuffer<FfiOutboundLease> {
1998
+ override fun read(buf: ByteBuffer): FfiOutboundLease {
1999
+ return FfiOutboundLease(
2000
+ FfiConverterString.read(buf),
2001
+ FfiConverterByteArray.read(buf),
2002
+ )
2003
+ }
2004
+
2005
+ override fun allocationSize(value: FfiOutboundLease) = (
2006
+ FfiConverterString.allocationSize(value.`leaseId`) +
2007
+ FfiConverterByteArray.allocationSize(value.`frame`)
2008
+ )
2009
+
2010
+ override fun write(value: FfiOutboundLease, buf: ByteBuffer) {
2011
+ FfiConverterString.write(value.`leaseId`, buf)
2012
+ FfiConverterByteArray.write(value.`frame`, buf)
2013
+ }
2014
+ }
2015
+
2016
+
2017
+
2018
+ /**
2019
+ * Explicit three-way lease result: exactly one of a retained value, a
2020
+ * queue-empty marker, or an error is selected. Empty is not encoded as an
2021
+ * empty binary frame, which keeps it distinct from valid protocol bytes.
2022
+ */
2023
+ data class FfiOutboundLeaseResult (
2024
+ var `value`: FfiOutboundLease?,
2025
+ var `empty`: kotlin.Boolean,
2026
+ var `error`: FfiError?
2027
+ ) {
2028
+
2029
+ companion object
2030
+ }
2031
+
2032
+ /**
2033
+ * @suppress
2034
+ */
2035
+ public object FfiConverterTypeFfiOutboundLeaseResult: FfiConverterRustBuffer<FfiOutboundLeaseResult> {
2036
+ override fun read(buf: ByteBuffer): FfiOutboundLeaseResult {
2037
+ return FfiOutboundLeaseResult(
2038
+ FfiConverterOptionalTypeFfiOutboundLease.read(buf),
2039
+ FfiConverterBoolean.read(buf),
2040
+ FfiConverterOptionalTypeFfiError.read(buf),
2041
+ )
2042
+ }
2043
+
2044
+ override fun allocationSize(value: FfiOutboundLeaseResult) = (
2045
+ FfiConverterOptionalTypeFfiOutboundLease.allocationSize(value.`value`) +
2046
+ FfiConverterBoolean.allocationSize(value.`empty`) +
2047
+ FfiConverterOptionalTypeFfiError.allocationSize(value.`error`)
2048
+ )
2049
+
2050
+ override fun write(value: FfiOutboundLeaseResult, buf: ByteBuffer) {
2051
+ FfiConverterOptionalTypeFfiOutboundLease.write(value.`value`, buf)
2052
+ FfiConverterBoolean.write(value.`empty`, buf)
2053
+ FfiConverterOptionalTypeFfiError.write(value.`error`, buf)
2054
+ }
2055
+ }
2056
+
2057
+
2058
+
2059
+ /**
2060
+ * One exported document snapshot: the five-field manifest as JSON plus the
2061
+ * encoded state as direct bytes (never a JSON number array).
2062
+ */
2063
+ data class FfiSnapshotExport (
2064
+ var `metadataJson`: kotlin.String,
2065
+ var `encodedState`: kotlin.ByteArray
2066
+ ) {
2067
+
2068
+ companion object
2069
+ }
2070
+
2071
+ /**
2072
+ * @suppress
2073
+ */
2074
+ public object FfiConverterTypeFfiSnapshotExport: FfiConverterRustBuffer<FfiSnapshotExport> {
2075
+ override fun read(buf: ByteBuffer): FfiSnapshotExport {
2076
+ return FfiSnapshotExport(
2077
+ FfiConverterString.read(buf),
2078
+ FfiConverterByteArray.read(buf),
2079
+ )
2080
+ }
2081
+
2082
+ override fun allocationSize(value: FfiSnapshotExport) = (
2083
+ FfiConverterString.allocationSize(value.`metadataJson`) +
2084
+ FfiConverterByteArray.allocationSize(value.`encodedState`)
2085
+ )
2086
+
2087
+ override fun write(value: FfiSnapshotExport, buf: ByteBuffer) {
2088
+ FfiConverterString.write(value.`metadataJson`, buf)
2089
+ FfiConverterByteArray.write(value.`encodedState`, buf)
2090
+ }
2091
+ }
2092
+
2093
+
2094
+
2095
+ data class FfiSnapshotExportResult (
2096
+ var `value`: FfiSnapshotExport?,
2097
+ var `error`: FfiError?
2098
+ ) {
2099
+
2100
+ companion object
2101
+ }
2102
+
2103
+ /**
2104
+ * @suppress
2105
+ */
2106
+ public object FfiConverterTypeFfiSnapshotExportResult: FfiConverterRustBuffer<FfiSnapshotExportResult> {
2107
+ override fun read(buf: ByteBuffer): FfiSnapshotExportResult {
2108
+ return FfiSnapshotExportResult(
2109
+ FfiConverterOptionalTypeFfiSnapshotExport.read(buf),
2110
+ FfiConverterOptionalTypeFfiError.read(buf),
2111
+ )
2112
+ }
2113
+
2114
+ override fun allocationSize(value: FfiSnapshotExportResult) = (
2115
+ FfiConverterOptionalTypeFfiSnapshotExport.allocationSize(value.`value`) +
2116
+ FfiConverterOptionalTypeFfiError.allocationSize(value.`error`)
2117
+ )
2118
+
2119
+ override fun write(value: FfiSnapshotExportResult, buf: ByteBuffer) {
2120
+ FfiConverterOptionalTypeFfiSnapshotExport.write(value.`value`, buf)
2121
+ FfiConverterOptionalTypeFfiError.write(value.`error`, buf)
2122
+ }
2123
+ }
2124
+
2125
+
2126
+
2127
+ data class FfiUnitResult (
2128
+ var `value`: kotlin.Boolean?,
2129
+ var `error`: FfiError?
2130
+ ) {
2131
+
2132
+ companion object
2133
+ }
2134
+
2135
+ /**
2136
+ * @suppress
2137
+ */
2138
+ public object FfiConverterTypeFfiUnitResult: FfiConverterRustBuffer<FfiUnitResult> {
2139
+ override fun read(buf: ByteBuffer): FfiUnitResult {
2140
+ return FfiUnitResult(
2141
+ FfiConverterOptionalBoolean.read(buf),
2142
+ FfiConverterOptionalTypeFfiError.read(buf),
2143
+ )
2144
+ }
2145
+
2146
+ override fun allocationSize(value: FfiUnitResult) = (
2147
+ FfiConverterOptionalBoolean.allocationSize(value.`value`) +
2148
+ FfiConverterOptionalTypeFfiError.allocationSize(value.`error`)
2149
+ )
2150
+
2151
+ override fun write(value: FfiUnitResult, buf: ByteBuffer) {
2152
+ FfiConverterOptionalBoolean.write(value.`value`, buf)
2153
+ FfiConverterOptionalTypeFfiError.write(value.`error`, buf)
2154
+ }
2155
+ }
2156
+
2157
+
2158
+
2159
+ data class FfiViewerCompileRequest (
2160
+ var `sourceKind`: FfiViewerSourceKind,
2161
+ var `source`: kotlin.String,
2162
+ var `configJson`: kotlin.String,
2163
+ var `imagesEnabled`: kotlin.Boolean,
2164
+ var `mentionPrefix`: kotlin.String?
2165
+ ) {
2166
+
2167
+ companion object
2168
+ }
2169
+
2170
+ /**
2171
+ * @suppress
2172
+ */
2173
+ public object FfiConverterTypeFfiViewerCompileRequest: FfiConverterRustBuffer<FfiViewerCompileRequest> {
2174
+ override fun read(buf: ByteBuffer): FfiViewerCompileRequest {
2175
+ return FfiViewerCompileRequest(
2176
+ FfiConverterTypeFfiViewerSourceKind.read(buf),
2177
+ FfiConverterString.read(buf),
2178
+ FfiConverterString.read(buf),
2179
+ FfiConverterBoolean.read(buf),
2180
+ FfiConverterOptionalString.read(buf),
2181
+ )
2182
+ }
2183
+
2184
+ override fun allocationSize(value: FfiViewerCompileRequest) = (
2185
+ FfiConverterTypeFfiViewerSourceKind.allocationSize(value.`sourceKind`) +
2186
+ FfiConverterString.allocationSize(value.`source`) +
2187
+ FfiConverterString.allocationSize(value.`configJson`) +
2188
+ FfiConverterBoolean.allocationSize(value.`imagesEnabled`) +
2189
+ FfiConverterOptionalString.allocationSize(value.`mentionPrefix`)
2190
+ )
2191
+
2192
+ override fun write(value: FfiViewerCompileRequest, buf: ByteBuffer) {
2193
+ FfiConverterTypeFfiViewerSourceKind.write(value.`sourceKind`, buf)
2194
+ FfiConverterString.write(value.`source`, buf)
2195
+ FfiConverterString.write(value.`configJson`, buf)
2196
+ FfiConverterBoolean.write(value.`imagesEnabled`, buf)
2197
+ FfiConverterOptionalString.write(value.`mentionPrefix`, buf)
2198
+ }
2199
+ }
2200
+
2201
+
2202
+
2203
+ data class FfiViewerCompileResult (
2204
+ var `value`: ViewerCompiledDocument?,
2205
+ var `error`: FfiError?
2206
+ ) : Disposable {
2207
+
2208
+ @Suppress("UNNECESSARY_SAFE_CALL") // codegen is much simpler if we unconditionally emit safe calls here
2209
+ override fun destroy() {
2210
+
2211
+ Disposable.destroy(
2212
+ this.`value`,
2213
+ this.`error`
2214
+ )
2215
+ }
2216
+
2217
+ companion object
2218
+ }
2219
+
2220
+ /**
2221
+ * @suppress
2222
+ */
2223
+ public object FfiConverterTypeFfiViewerCompileResult: FfiConverterRustBuffer<FfiViewerCompileResult> {
2224
+ override fun read(buf: ByteBuffer): FfiViewerCompileResult {
2225
+ return FfiViewerCompileResult(
2226
+ FfiConverterOptionalTypeViewerCompiledDocument.read(buf),
2227
+ FfiConverterOptionalTypeFfiError.read(buf),
2228
+ )
2229
+ }
2230
+
2231
+ override fun allocationSize(value: FfiViewerCompileResult) = (
2232
+ FfiConverterOptionalTypeViewerCompiledDocument.allocationSize(value.`value`) +
2233
+ FfiConverterOptionalTypeFfiError.allocationSize(value.`error`)
2234
+ )
2235
+
2236
+ override fun write(value: FfiViewerCompileResult, buf: ByteBuffer) {
2237
+ FfiConverterOptionalTypeViewerCompiledDocument.write(value.`value`, buf)
2238
+ FfiConverterOptionalTypeFfiError.write(value.`error`, buf)
2239
+ }
2240
+ }
2241
+
2242
+
2243
+
2244
+ data class FfiViewerMark (
2245
+ var `markType`: kotlin.String,
2246
+ var `attrsJson`: kotlin.String
2247
+ ) {
2248
+
2249
+ companion object
2250
+ }
2251
+
2252
+ /**
2253
+ * @suppress
2254
+ */
2255
+ public object FfiConverterTypeFfiViewerMark: FfiConverterRustBuffer<FfiViewerMark> {
2256
+ override fun read(buf: ByteBuffer): FfiViewerMark {
2257
+ return FfiViewerMark(
2258
+ FfiConverterString.read(buf),
2259
+ FfiConverterString.read(buf),
2260
+ )
2261
+ }
2262
+
2263
+ override fun allocationSize(value: FfiViewerMark) = (
2264
+ FfiConverterString.allocationSize(value.`markType`) +
2265
+ FfiConverterString.allocationSize(value.`attrsJson`)
2266
+ )
2267
+
2268
+ override fun write(value: FfiViewerMark, buf: ByteBuffer) {
2269
+ FfiConverterString.write(value.`markType`, buf)
2270
+ FfiConverterString.write(value.`attrsJson`, buf)
2271
+ }
2272
+ }
2273
+
2274
+
2275
+
2276
+ sealed class FfiViewerElement {
2277
+
2278
+ data class TextRun(
2279
+ val `text`: kotlin.String,
2280
+ val `marks`: List<FfiViewerMark>) : FfiViewerElement() {
2281
+ companion object
2282
+ }
2283
+
2284
+ data class InlineAtom(
2285
+ val `nodeType`: kotlin.String,
2286
+ val `docPos`: kotlin.UInt,
2287
+ val `attrsJson`: kotlin.String,
2288
+ val `label`: kotlin.String) : FfiViewerElement() {
2289
+ companion object
2290
+ }
2291
+
2292
+ data class BlockAtom(
2293
+ val `nodeType`: kotlin.String,
2294
+ val `docPos`: kotlin.UInt,
2295
+ val `attrsJson`: kotlin.String,
2296
+ val `label`: kotlin.String) : FfiViewerElement() {
2297
+ companion object
2298
+ }
2299
+
2300
+ data class BlockStart(
2301
+ val `nodeType`: kotlin.String,
2302
+ val `language`: kotlin.String?,
2303
+ val `depth`: kotlin.UShort,
2304
+ val `listContextJson`: kotlin.String?) : FfiViewerElement() {
2305
+ companion object
2306
+ }
2307
+
2308
+ object BlockEnd : FfiViewerElement()
2309
+
2310
+
2311
+
2312
+
2313
+ companion object
2314
+ }
2315
+
2316
+ /**
2317
+ * @suppress
2318
+ */
2319
+ public object FfiConverterTypeFfiViewerElement : FfiConverterRustBuffer<FfiViewerElement>{
2320
+ override fun read(buf: ByteBuffer): FfiViewerElement {
2321
+ return when(buf.getInt()) {
2322
+ 1 -> FfiViewerElement.TextRun(
2323
+ FfiConverterString.read(buf),
2324
+ FfiConverterSequenceTypeFfiViewerMark.read(buf),
2325
+ )
2326
+ 2 -> FfiViewerElement.InlineAtom(
2327
+ FfiConverterString.read(buf),
2328
+ FfiConverterUInt.read(buf),
2329
+ FfiConverterString.read(buf),
2330
+ FfiConverterString.read(buf),
2331
+ )
2332
+ 3 -> FfiViewerElement.BlockAtom(
2333
+ FfiConverterString.read(buf),
2334
+ FfiConverterUInt.read(buf),
2335
+ FfiConverterString.read(buf),
2336
+ FfiConverterString.read(buf),
2337
+ )
2338
+ 4 -> FfiViewerElement.BlockStart(
2339
+ FfiConverterString.read(buf),
2340
+ FfiConverterOptionalString.read(buf),
2341
+ FfiConverterUShort.read(buf),
2342
+ FfiConverterOptionalString.read(buf),
2343
+ )
2344
+ 5 -> FfiViewerElement.BlockEnd
2345
+ else -> throw RuntimeException("invalid enum value, something is very wrong!!")
2346
+ }
2347
+ }
2348
+
2349
+ override fun allocationSize(value: FfiViewerElement) = when(value) {
2350
+ is FfiViewerElement.TextRun -> {
2351
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2352
+ (
2353
+ 4UL
2354
+ + FfiConverterString.allocationSize(value.`text`)
2355
+ + FfiConverterSequenceTypeFfiViewerMark.allocationSize(value.`marks`)
2356
+ )
2357
+ }
2358
+ is FfiViewerElement.InlineAtom -> {
2359
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2360
+ (
2361
+ 4UL
2362
+ + FfiConverterString.allocationSize(value.`nodeType`)
2363
+ + FfiConverterUInt.allocationSize(value.`docPos`)
2364
+ + FfiConverterString.allocationSize(value.`attrsJson`)
2365
+ + FfiConverterString.allocationSize(value.`label`)
2366
+ )
2367
+ }
2368
+ is FfiViewerElement.BlockAtom -> {
2369
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2370
+ (
2371
+ 4UL
2372
+ + FfiConverterString.allocationSize(value.`nodeType`)
2373
+ + FfiConverterUInt.allocationSize(value.`docPos`)
2374
+ + FfiConverterString.allocationSize(value.`attrsJson`)
2375
+ + FfiConverterString.allocationSize(value.`label`)
2376
+ )
2377
+ }
2378
+ is FfiViewerElement.BlockStart -> {
2379
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2380
+ (
2381
+ 4UL
2382
+ + FfiConverterString.allocationSize(value.`nodeType`)
2383
+ + FfiConverterOptionalString.allocationSize(value.`language`)
2384
+ + FfiConverterUShort.allocationSize(value.`depth`)
2385
+ + FfiConverterOptionalString.allocationSize(value.`listContextJson`)
2386
+ )
2387
+ }
2388
+ is FfiViewerElement.BlockEnd -> {
2389
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2390
+ (
2391
+ 4UL
2392
+ )
2393
+ }
2394
+ }
2395
+
2396
+ override fun write(value: FfiViewerElement, buf: ByteBuffer) {
2397
+ when(value) {
2398
+ is FfiViewerElement.TextRun -> {
2399
+ buf.putInt(1)
2400
+ FfiConverterString.write(value.`text`, buf)
2401
+ FfiConverterSequenceTypeFfiViewerMark.write(value.`marks`, buf)
2402
+ Unit
2403
+ }
2404
+ is FfiViewerElement.InlineAtom -> {
2405
+ buf.putInt(2)
2406
+ FfiConverterString.write(value.`nodeType`, buf)
2407
+ FfiConverterUInt.write(value.`docPos`, buf)
2408
+ FfiConverterString.write(value.`attrsJson`, buf)
2409
+ FfiConverterString.write(value.`label`, buf)
2410
+ Unit
2411
+ }
2412
+ is FfiViewerElement.BlockAtom -> {
2413
+ buf.putInt(3)
2414
+ FfiConverterString.write(value.`nodeType`, buf)
2415
+ FfiConverterUInt.write(value.`docPos`, buf)
2416
+ FfiConverterString.write(value.`attrsJson`, buf)
2417
+ FfiConverterString.write(value.`label`, buf)
2418
+ Unit
2419
+ }
2420
+ is FfiViewerElement.BlockStart -> {
2421
+ buf.putInt(4)
2422
+ FfiConverterString.write(value.`nodeType`, buf)
2423
+ FfiConverterOptionalString.write(value.`language`, buf)
2424
+ FfiConverterUShort.write(value.`depth`, buf)
2425
+ FfiConverterOptionalString.write(value.`listContextJson`, buf)
2426
+ Unit
2427
+ }
2428
+ is FfiViewerElement.BlockEnd -> {
2429
+ buf.putInt(5)
2430
+ Unit
2431
+ }
2432
+ }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
2433
+ }
2434
+ }
2435
+
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+ enum class FfiViewerSourceKind {
2442
+
2443
+ JSON,
2444
+ HTML;
2445
+ companion object
2446
+ }
2447
+
2448
+
2449
+ /**
2450
+ * @suppress
2451
+ */
2452
+ public object FfiConverterTypeFfiViewerSourceKind: FfiConverterRustBuffer<FfiViewerSourceKind> {
2453
+ override fun read(buf: ByteBuffer) = try {
2454
+ FfiViewerSourceKind.values()[buf.getInt() - 1]
2455
+ } catch (e: IndexOutOfBoundsException) {
2456
+ throw RuntimeException("invalid enum value, something is very wrong!!", e)
2457
+ }
2458
+
2459
+ override fun allocationSize(value: FfiViewerSourceKind) = 4UL
2460
+
2461
+ override fun write(value: FfiViewerSourceKind, buf: ByteBuffer) {
2462
+ buf.putInt(value.ordinal + 1)
2463
+ }
2464
+ }
2465
+
2466
+
2467
+
2468
+
2469
+
2470
+
2471
+ /**
2472
+ * @suppress
2473
+ */
2474
+ public object FfiConverterOptionalUInt: FfiConverterRustBuffer<kotlin.UInt?> {
2475
+ override fun read(buf: ByteBuffer): kotlin.UInt? {
2476
+ if (buf.get().toInt() == 0) {
2477
+ return null
2478
+ }
2479
+ return FfiConverterUInt.read(buf)
2480
+ }
2481
+
2482
+ override fun allocationSize(value: kotlin.UInt?): ULong {
2483
+ if (value == null) {
2484
+ return 1UL
2485
+ } else {
2486
+ return 1UL + FfiConverterUInt.allocationSize(value)
2487
+ }
2488
+ }
2489
+
2490
+ override fun write(value: kotlin.UInt?, buf: ByteBuffer) {
2491
+ if (value == null) {
2492
+ buf.put(0)
2493
+ } else {
2494
+ buf.put(1)
2495
+ FfiConverterUInt.write(value, buf)
2496
+ }
2497
+ }
2498
+ }
2499
+
2500
+
2501
+
2502
+
2503
+ /**
2504
+ * @suppress
2505
+ */
2506
+ public object FfiConverterOptionalBoolean: FfiConverterRustBuffer<kotlin.Boolean?> {
2507
+ override fun read(buf: ByteBuffer): kotlin.Boolean? {
2508
+ if (buf.get().toInt() == 0) {
2509
+ return null
2510
+ }
2511
+ return FfiConverterBoolean.read(buf)
2512
+ }
2513
+
2514
+ override fun allocationSize(value: kotlin.Boolean?): ULong {
2515
+ if (value == null) {
2516
+ return 1UL
2517
+ } else {
2518
+ return 1UL + FfiConverterBoolean.allocationSize(value)
2519
+ }
2520
+ }
2521
+
2522
+ override fun write(value: kotlin.Boolean?, buf: ByteBuffer) {
2523
+ if (value == null) {
2524
+ buf.put(0)
2525
+ } else {
2526
+ buf.put(1)
2527
+ FfiConverterBoolean.write(value, buf)
2528
+ }
2529
+ }
2530
+ }
2531
+
2532
+
2533
+
2534
+
2535
+ /**
2536
+ * @suppress
2537
+ */
2538
+ public object FfiConverterOptionalString: FfiConverterRustBuffer<kotlin.String?> {
2539
+ override fun read(buf: ByteBuffer): kotlin.String? {
2540
+ if (buf.get().toInt() == 0) {
2541
+ return null
2542
+ }
2543
+ return FfiConverterString.read(buf)
2544
+ }
2545
+
2546
+ override fun allocationSize(value: kotlin.String?): ULong {
2547
+ if (value == null) {
2548
+ return 1UL
2549
+ } else {
2550
+ return 1UL + FfiConverterString.allocationSize(value)
2551
+ }
2552
+ }
2553
+
2554
+ override fun write(value: kotlin.String?, buf: ByteBuffer) {
2555
+ if (value == null) {
2556
+ buf.put(0)
2557
+ } else {
2558
+ buf.put(1)
2559
+ FfiConverterString.write(value, buf)
2560
+ }
2561
+ }
2562
+ }
2563
+
2564
+
2565
+
2566
+
2567
+ /**
2568
+ * @suppress
2569
+ */
2570
+ public object FfiConverterOptionalByteArray: FfiConverterRustBuffer<kotlin.ByteArray?> {
2571
+ override fun read(buf: ByteBuffer): kotlin.ByteArray? {
2572
+ if (buf.get().toInt() == 0) {
2573
+ return null
2574
+ }
2575
+ return FfiConverterByteArray.read(buf)
2576
+ }
2577
+
2578
+ override fun allocationSize(value: kotlin.ByteArray?): ULong {
2579
+ if (value == null) {
2580
+ return 1UL
2581
+ } else {
2582
+ return 1UL + FfiConverterByteArray.allocationSize(value)
2583
+ }
2584
+ }
2585
+
2586
+ override fun write(value: kotlin.ByteArray?, buf: ByteBuffer) {
2587
+ if (value == null) {
2588
+ buf.put(0)
2589
+ } else {
2590
+ buf.put(1)
2591
+ FfiConverterByteArray.write(value, buf)
2592
+ }
2593
+ }
2594
+ }
2595
+
2596
+
2597
+
2598
+
2599
+ /**
2600
+ * @suppress
2601
+ */
2602
+ public object FfiConverterOptionalTypeViewerCompiledDocument: FfiConverterRustBuffer<ViewerCompiledDocument?> {
2603
+ override fun read(buf: ByteBuffer): ViewerCompiledDocument? {
2604
+ if (buf.get().toInt() == 0) {
2605
+ return null
2606
+ }
2607
+ return FfiConverterTypeViewerCompiledDocument.read(buf)
2608
+ }
2609
+
2610
+ override fun allocationSize(value: ViewerCompiledDocument?): ULong {
2611
+ if (value == null) {
2612
+ return 1UL
2613
+ } else {
2614
+ return 1UL + FfiConverterTypeViewerCompiledDocument.allocationSize(value)
2615
+ }
2616
+ }
2617
+
2618
+ override fun write(value: ViewerCompiledDocument?, buf: ByteBuffer) {
2619
+ if (value == null) {
2620
+ buf.put(0)
2621
+ } else {
2622
+ buf.put(1)
2623
+ FfiConverterTypeViewerCompiledDocument.write(value, buf)
2624
+ }
2625
+ }
2626
+ }
2627
+
2628
+
2629
+
2630
+
2631
+ /**
2632
+ * @suppress
2633
+ */
2634
+ public object FfiConverterOptionalTypeFfiError: FfiConverterRustBuffer<FfiError?> {
2635
+ override fun read(buf: ByteBuffer): FfiError? {
2636
+ if (buf.get().toInt() == 0) {
2637
+ return null
2638
+ }
2639
+ return FfiConverterTypeFfiError.read(buf)
2640
+ }
2641
+
2642
+ override fun allocationSize(value: FfiError?): ULong {
2643
+ if (value == null) {
2644
+ return 1UL
2645
+ } else {
2646
+ return 1UL + FfiConverterTypeFfiError.allocationSize(value)
2647
+ }
2648
+ }
2649
+
2650
+ override fun write(value: FfiError?, buf: ByteBuffer) {
2651
+ if (value == null) {
2652
+ buf.put(0)
2653
+ } else {
2654
+ buf.put(1)
2655
+ FfiConverterTypeFfiError.write(value, buf)
2656
+ }
2657
+ }
2658
+ }
2659
+
2660
+
2661
+
2662
+
2663
+ /**
2664
+ * @suppress
2665
+ */
2666
+ public object FfiConverterOptionalTypeFfiOutboundLease: FfiConverterRustBuffer<FfiOutboundLease?> {
2667
+ override fun read(buf: ByteBuffer): FfiOutboundLease? {
2668
+ if (buf.get().toInt() == 0) {
2669
+ return null
2670
+ }
2671
+ return FfiConverterTypeFfiOutboundLease.read(buf)
2672
+ }
2673
+
2674
+ override fun allocationSize(value: FfiOutboundLease?): ULong {
2675
+ if (value == null) {
2676
+ return 1UL
2677
+ } else {
2678
+ return 1UL + FfiConverterTypeFfiOutboundLease.allocationSize(value)
2679
+ }
2680
+ }
2681
+
2682
+ override fun write(value: FfiOutboundLease?, buf: ByteBuffer) {
2683
+ if (value == null) {
2684
+ buf.put(0)
2685
+ } else {
2686
+ buf.put(1)
2687
+ FfiConverterTypeFfiOutboundLease.write(value, buf)
2688
+ }
2689
+ }
2690
+ }
2691
+
2692
+
2693
+
2694
+
2695
+ /**
2696
+ * @suppress
2697
+ */
2698
+ public object FfiConverterOptionalTypeFfiSnapshotExport: FfiConverterRustBuffer<FfiSnapshotExport?> {
2699
+ override fun read(buf: ByteBuffer): FfiSnapshotExport? {
2700
+ if (buf.get().toInt() == 0) {
2701
+ return null
2702
+ }
2703
+ return FfiConverterTypeFfiSnapshotExport.read(buf)
2704
+ }
2705
+
2706
+ override fun allocationSize(value: FfiSnapshotExport?): ULong {
2707
+ if (value == null) {
2708
+ return 1UL
2709
+ } else {
2710
+ return 1UL + FfiConverterTypeFfiSnapshotExport.allocationSize(value)
2711
+ }
2712
+ }
2713
+
2714
+ override fun write(value: FfiSnapshotExport?, buf: ByteBuffer) {
2715
+ if (value == null) {
2716
+ buf.put(0)
2717
+ } else {
2718
+ buf.put(1)
2719
+ FfiConverterTypeFfiSnapshotExport.write(value, buf)
2720
+ }
2721
+ }
2722
+ }
2723
+
2724
+
2725
+
2726
+
2727
+ /**
2728
+ * @suppress
2729
+ */
2730
+ public object FfiConverterSequenceTypeFfiViewerMark: FfiConverterRustBuffer<List<FfiViewerMark>> {
2731
+ override fun read(buf: ByteBuffer): List<FfiViewerMark> {
2732
+ val len = buf.getInt()
2733
+ return List<FfiViewerMark>(len) {
2734
+ FfiConverterTypeFfiViewerMark.read(buf)
2735
+ }
2736
+ }
2737
+
2738
+ override fun allocationSize(value: List<FfiViewerMark>): ULong {
2739
+ val sizeForLength = 4UL
2740
+ val sizeForItems = value.map { FfiConverterTypeFfiViewerMark.allocationSize(it) }.sum()
2741
+ return sizeForLength + sizeForItems
2742
+ }
2743
+
2744
+ override fun write(value: List<FfiViewerMark>, buf: ByteBuffer) {
2745
+ buf.putInt(value.size)
2746
+ value.iterator().forEach {
2747
+ FfiConverterTypeFfiViewerMark.write(it, buf)
2748
+ }
2749
+ }
2750
+ }
2751
+
2752
+
2753
+
2754
+
2755
+ /**
2756
+ * @suppress
2757
+ */
2758
+ public object FfiConverterSequenceTypeFfiViewerElement: FfiConverterRustBuffer<List<FfiViewerElement>> {
2759
+ override fun read(buf: ByteBuffer): List<FfiViewerElement> {
2760
+ val len = buf.getInt()
2761
+ return List<FfiViewerElement>(len) {
2762
+ FfiConverterTypeFfiViewerElement.read(buf)
2763
+ }
2764
+ }
2765
+
2766
+ override fun allocationSize(value: List<FfiViewerElement>): ULong {
2767
+ val sizeForLength = 4UL
2768
+ val sizeForItems = value.map { FfiConverterTypeFfiViewerElement.allocationSize(it) }.sum()
2769
+ return sizeForLength + sizeForItems
2770
+ }
2771
+
2772
+ override fun write(value: List<FfiViewerElement>, buf: ByteBuffer) {
2773
+ buf.putInt(value.size)
2774
+ value.iterator().forEach {
2775
+ FfiConverterTypeFfiViewerElement.write(it, buf)
2776
+ }
2777
+ }
2778
+ }
2779
+ /**
2780
+ * Return the crate version string.
2781
+ */ fun `editorCoreVersion`(): kotlin.String {
2782
+ return FfiConverterString.lift(
2783
+ uniffiRustCall() { _status ->
2784
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_core_version(
2785
+ _status)
2786
+ }
2787
+ )
2788
+ }
2789
+
2790
+ fun `editorV2ApplyCommand`(`editorId`: kotlin.String, `requestJson`: kotlin.String): FfiJsonResult {
2791
+ return FfiConverterTypeFfiJsonResult.lift(
2792
+ uniffiRustCall() { _status ->
2793
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_apply_command(
2794
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`requestJson`),_status)
2795
+ }
2796
+ )
2797
+ }
2798
+
2799
+ fun `editorV2ApplyInput`(`editorId`: kotlin.String, `requestJson`: kotlin.String): FfiJsonResult {
2800
+ return FfiConverterTypeFfiJsonResult.lift(
2801
+ uniffiRustCall() { _status ->
2802
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_apply_input(
2803
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`requestJson`),_status)
2804
+ }
2805
+ )
2806
+ }
2807
+
2808
+ fun `editorV2ApplyLocalApi`(`editorId`: kotlin.String, `requestJson`: kotlin.String): FfiJsonResult {
2809
+ return FfiConverterTypeFfiJsonResult.lift(
2810
+ uniffiRustCall() { _status ->
2811
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_apply_local_api(
2812
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`requestJson`),_status)
2813
+ }
2814
+ )
2815
+ }
2816
+
2817
+ fun `editorV2ApplyNativeIntent`(`editorId`: kotlin.String, `requestJson`: kotlin.String): FfiJsonResult {
2818
+ return FfiConverterTypeFfiJsonResult.lift(
2819
+ uniffiRustCall() { _status ->
2820
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_apply_native_intent(
2821
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`requestJson`),_status)
2822
+ }
2823
+ )
2824
+ }
2825
+
2826
+ fun `editorV2CollaborationAckOutbound`(`editorId`: kotlin.String, `generation`: kotlin.String, `leaseId`: kotlin.String): FfiJsonResult {
2827
+ return FfiConverterTypeFfiJsonResult.lift(
2828
+ uniffiRustCall() { _status ->
2829
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_ack_outbound(
2830
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`generation`),FfiConverterString.lower(`leaseId`),_status)
2831
+ }
2832
+ )
2833
+ }
2834
+
2835
+
2836
+ /**
2837
+ * Tears down transport state while retaining the editor, document, desired
2838
+ * awareness state, and pending outbox entries.
2839
+ */ fun `editorV2CollaborationDetach`(`editorId`: kotlin.String): FfiUnitResult {
2840
+ return FfiConverterTypeFfiUnitResult.lift(
2841
+ uniffiRustCall() { _status ->
2842
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_detach(
2843
+ FfiConverterString.lower(`editorId`),_status)
2844
+ }
2845
+ )
2846
+ }
2847
+
2848
+
2849
+ /**
2850
+ * Drive initial connection, reconnect eligibility, local-awareness renewal,
2851
+ * and remote-peer expiry from one Rust-owned monotonic clock operation.
2852
+ */ fun `editorV2CollaborationDrive`(`editorId`: kotlin.String, `nowMillis`: kotlin.String): FfiJsonResult {
2853
+ return FfiConverterTypeFfiJsonResult.lift(
2854
+ uniffiRustCall() { _status ->
2855
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_drive(
2856
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`nowMillis`),_status)
2857
+ }
2858
+ )
2859
+ }
2860
+
2861
+
2862
+ /**
2863
+ * Lease one retained complete outbound frame. Exactly one of value, empty,
2864
+ * or error is selected; protocol replies retain priority over document
2865
+ * updates unless a frame was already leased.
2866
+ */ fun `editorV2CollaborationLeaseOutbound`(`editorId`: kotlin.String, `generation`: kotlin.String): FfiOutboundLeaseResult {
2867
+ return FfiConverterTypeFfiOutboundLeaseResult.lift(
2868
+ uniffiRustCall() { _status ->
2869
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_lease_outbound(
2870
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`generation`),_status)
2871
+ }
2872
+ )
2873
+ }
2874
+
2875
+ fun `editorV2CollaborationNackOutbound`(`editorId`: kotlin.String, `generation`: kotlin.String, `leaseId`: kotlin.String): FfiJsonResult {
2876
+ return FfiConverterTypeFfiJsonResult.lift(
2877
+ uniffiRustCall() { _status ->
2878
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_nack_outbound(
2879
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`generation`),FfiConverterString.lower(`leaseId`),_status)
2880
+ }
2881
+ )
2882
+ }
2883
+
2884
+
2885
+ /**
2886
+ * Live awareness peer projections; client ids are decimal strings so full
2887
+ * u64 ids survive the JSON round-trip.
2888
+ */ fun `editorV2CollaborationPeers`(`editorId`: kotlin.String): FfiJsonResult {
2889
+ return FfiConverterTypeFfiJsonResult.lift(
2890
+ uniffiRustCall() { _status ->
2891
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_peers(
2892
+ FfiConverterString.lower(`editorId`),_status)
2893
+ }
2894
+ )
2895
+ }
2896
+
2897
+
2898
+ /**
2899
+ * Reopens the transport lifecycle after an explicit detach.
2900
+ */ fun `editorV2CollaborationReattach`(`editorId`: kotlin.String): FfiUnitResult {
2901
+ return FfiConverterTypeFfiUnitResult.lift(
2902
+ uniffiRustCall() { _status ->
2903
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_reattach(
2904
+ FfiConverterString.lower(`editorId`),_status)
2905
+ }
2906
+ )
2907
+ }
2908
+
2909
+ fun `editorV2CollaborationReceive`(`editorId`: kotlin.String, `generation`: kotlin.String, `message`: kotlin.ByteArray, `nowMillis`: kotlin.String): FfiJsonResult {
2910
+ return FfiConverterTypeFfiJsonResult.lift(
2911
+ uniffiRustCall() { _status ->
2912
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_receive(
2913
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`generation`),FfiConverterByteArray.lower(`message`),FfiConverterString.lower(`nowMillis`),_status)
2914
+ }
2915
+ )
2916
+ }
2917
+
2918
+
2919
+ /**
2920
+ * Publishes a typed local awareness intent; the literal JSON `null`
2921
+ * withdraws it (standard tombstone broadcast). Rust validates the closed
2922
+ * shape and owns any published sticky cursor representation.
2923
+ */ fun `editorV2CollaborationSetAwareness`(`editorId`: kotlin.String, `awarenessJson`: kotlin.String): FfiUnitResult {
2924
+ return FfiConverterTypeFfiUnitResult.lift(
2925
+ uniffiRustCall() { _status ->
2926
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_set_awareness(
2927
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`awarenessJson`),_status)
2928
+ }
2929
+ )
2930
+ }
2931
+
2932
+ fun `editorV2CollaborationSetAwarenessSelection`(`editorId`: kotlin.String, `selectionJson`: kotlin.String): FfiJsonResult {
2933
+ return FfiConverterTypeFfiJsonResult.lift(
2934
+ uniffiRustCall() { _status ->
2935
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_set_awareness_selection(
2936
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`selectionJson`),_status)
2937
+ }
2938
+ )
2939
+ }
2940
+
2941
+
2942
+ /**
2943
+ * `reason` carries no classification weight (Rust alone owns retry
2944
+ * eligibility); a policy-violation close code (1008) parks the transport
2945
+ * `Incompatible`, every other reported close is retryable.
2946
+ */ fun `editorV2CollaborationSocketClose`(`editorId`: kotlin.String, `generation`: kotlin.String, `code`: kotlin.UInt?, `reason`: kotlin.String?, `nowMillis`: kotlin.String): FfiJsonResult {
2947
+ return FfiConverterTypeFfiJsonResult.lift(
2948
+ uniffiRustCall() { _status ->
2949
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_socket_close(
2950
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`generation`),FfiConverterOptionalUInt.lower(`code`),FfiConverterOptionalString.lower(`reason`),FfiConverterString.lower(`nowMillis`),_status)
2951
+ }
2952
+ )
2953
+ }
2954
+
2955
+
2956
+ /**
2957
+ * Socket open queues framed Sync Step 1 at protocol priority and returns
2958
+ * only the frozen directive; bytes are retrieved through `lease_outbound`.
2959
+ */ fun `editorV2CollaborationSocketOpen`(`editorId`: kotlin.String, `generation`: kotlin.String, `nowMillis`: kotlin.String): FfiJsonResult {
2960
+ return FfiConverterTypeFfiJsonResult.lift(
2961
+ uniffiRustCall() { _status ->
2962
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_collaboration_socket_open(
2963
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`generation`),FfiConverterString.lower(`nowMillis`),_status)
2964
+ }
2965
+ )
2966
+ }
2967
+
2968
+ fun `editorV2Create`(`configJson`: kotlin.String, `snapshotState`: kotlin.ByteArray?): FfiJsonResult {
2969
+ return FfiConverterTypeFfiJsonResult.lift(
2970
+ uniffiRustCall() { _status ->
2971
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_create(
2972
+ FfiConverterString.lower(`configJson`),FfiConverterOptionalByteArray.lower(`snapshotState`),_status)
2973
+ }
2974
+ )
2975
+ }
2976
+
2977
+ fun `editorV2Destroy`(`editorId`: kotlin.String): FfiUnitResult {
2978
+ return FfiConverterTypeFfiUnitResult.lift(
2979
+ uniffiRustCall() { _status ->
2980
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_destroy(
2981
+ FfiConverterString.lower(`editorId`),_status)
2982
+ }
2983
+ )
2984
+ }
2985
+
2986
+ fun `editorV2DocToScalar`(`editorId`: kotlin.String, `docPos`: kotlin.UInt): FfiJsonResult {
2987
+ return FfiConverterTypeFfiJsonResult.lift(
2988
+ uniffiRustCall() { _status ->
2989
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_doc_to_scalar(
2990
+ FfiConverterString.lower(`editorId`),FfiConverterUInt.lower(`docPos`),_status)
2991
+ }
2992
+ )
2993
+ }
2994
+
2995
+ fun `editorV2GetContentSnapshot`(`editorId`: kotlin.String): FfiJsonResult {
2996
+ return FfiConverterTypeFfiJsonResult.lift(
2997
+ uniffiRustCall() { _status ->
2998
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_get_content_snapshot(
2999
+ FfiConverterString.lower(`editorId`),_status)
3000
+ }
3001
+ )
3002
+ }
3003
+
3004
+ fun `editorV2GetDocumentHtml`(`editorId`: kotlin.String): FfiJsonResult {
3005
+ return FfiConverterTypeFfiJsonResult.lift(
3006
+ uniffiRustCall() { _status ->
3007
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_get_document_html(
3008
+ FfiConverterString.lower(`editorId`),_status)
3009
+ }
3010
+ )
3011
+ }
3012
+
3013
+ fun `editorV2GetDocumentJson`(`editorId`: kotlin.String): FfiJsonResult {
3014
+ return FfiConverterTypeFfiJsonResult.lift(
3015
+ uniffiRustCall() { _status ->
3016
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_get_document_json(
3017
+ FfiConverterString.lower(`editorId`),_status)
3018
+ }
3019
+ )
3020
+ }
3021
+
3022
+ fun `editorV2GetState`(`editorId`: kotlin.String): FfiJsonResult {
3023
+ return FfiConverterTypeFfiJsonResult.lift(
3024
+ uniffiRustCall() { _status ->
3025
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_get_state(
3026
+ FfiConverterString.lower(`editorId`),_status)
3027
+ }
3028
+ )
3029
+ }
3030
+
3031
+ fun `editorV2PinPositionEpoch`(`editorId`: kotlin.String, `ownerId`: kotlin.String, `documentRevision`: kotlin.String): FfiJsonResult {
3032
+ return FfiConverterTypeFfiJsonResult.lift(
3033
+ uniffiRustCall() { _status ->
3034
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_pin_position_epoch(
3035
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`ownerId`),FfiConverterString.lower(`documentRevision`),_status)
3036
+ }
3037
+ )
3038
+ }
3039
+
3040
+ fun `editorV2Redo`(`editorId`: kotlin.String, `requestJson`: kotlin.String): FfiJsonResult {
3041
+ return FfiConverterTypeFfiJsonResult.lift(
3042
+ uniffiRustCall() { _status ->
3043
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_redo(
3044
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`requestJson`),_status)
3045
+ }
3046
+ )
3047
+ }
3048
+
3049
+ fun `editorV2ReleaseNativeBinding`(`editorId`: kotlin.String, `ownerId`: kotlin.String): FfiUnitResult {
3050
+ return FfiConverterTypeFfiUnitResult.lift(
3051
+ uniffiRustCall() { _status ->
3052
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_release_native_binding(
3053
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`ownerId`),_status)
3054
+ }
3055
+ )
3056
+ }
3057
+
3058
+ fun `editorV2RenderNative`(`editorId`: kotlin.String, `ownerId`: kotlin.String, `mirrorScalarAnchor`: kotlin.UInt?, `mirrorScalarHead`: kotlin.UInt?): FfiJsonResult {
3059
+ return FfiConverterTypeFfiJsonResult.lift(
3060
+ uniffiRustCall() { _status ->
3061
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_render_native(
3062
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`ownerId`),FfiConverterOptionalUInt.lower(`mirrorScalarAnchor`),FfiConverterOptionalUInt.lower(`mirrorScalarHead`),_status)
3063
+ }
3064
+ )
3065
+ }
3066
+
3067
+ fun `editorV2RenderUpdate`(`editorId`: kotlin.String, `mirrorScalarAnchor`: kotlin.UInt?, `mirrorScalarHead`: kotlin.UInt?): FfiJsonResult {
3068
+ return FfiConverterTypeFfiJsonResult.lift(
3069
+ uniffiRustCall() { _status ->
3070
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_render_update(
3071
+ FfiConverterString.lower(`editorId`),FfiConverterOptionalUInt.lower(`mirrorScalarAnchor`),FfiConverterOptionalUInt.lower(`mirrorScalarHead`),_status)
3072
+ }
3073
+ )
3074
+ }
3075
+
3076
+ fun `editorV2ReplaceDocument`(`editorId`: kotlin.String, `requestJson`: kotlin.String): FfiJsonResult {
3077
+ return FfiConverterTypeFfiJsonResult.lift(
3078
+ uniffiRustCall() { _status ->
3079
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_replace_document(
3080
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`requestJson`),_status)
3081
+ }
3082
+ )
3083
+ }
3084
+
3085
+ fun `editorV2ResolveScalarSelection`(`editorId`: kotlin.String, `scalarAnchor`: kotlin.UInt, `scalarHead`: kotlin.UInt): FfiJsonResult {
3086
+ return FfiConverterTypeFfiJsonResult.lift(
3087
+ uniffiRustCall() { _status ->
3088
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_resolve_scalar_selection(
3089
+ FfiConverterString.lower(`editorId`),FfiConverterUInt.lower(`scalarAnchor`),FfiConverterUInt.lower(`scalarHead`),_status)
3090
+ }
3091
+ )
3092
+ }
3093
+
3094
+ fun `editorV2ScalarToDoc`(`editorId`: kotlin.String, `scalar`: kotlin.UInt): FfiJsonResult {
3095
+ return FfiConverterTypeFfiJsonResult.lift(
3096
+ uniffiRustCall() { _status ->
3097
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_scalar_to_doc(
3098
+ FfiConverterString.lower(`editorId`),FfiConverterUInt.lower(`scalar`),_status)
3099
+ }
3100
+ )
3101
+ }
3102
+
3103
+ fun `editorV2SetSelection`(`editorId`: kotlin.String, `requestJson`: kotlin.String): FfiJsonResult {
3104
+ return FfiConverterTypeFfiJsonResult.lift(
3105
+ uniffiRustCall() { _status ->
3106
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_set_selection(
3107
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`requestJson`),_status)
3108
+ }
3109
+ )
3110
+ }
3111
+
3112
+ fun `editorV2SnapshotExport`(`editorId`: kotlin.String): FfiSnapshotExportResult {
3113
+ return FfiConverterTypeFfiSnapshotExportResult.lift(
3114
+ uniffiRustCall() { _status ->
3115
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_snapshot_export(
3116
+ FfiConverterString.lower(`editorId`),_status)
3117
+ }
3118
+ )
3119
+ }
3120
+
3121
+ fun `editorV2SnapshotRestore`(`editorId`: kotlin.String, `metadataJson`: kotlin.String, `encodedState`: kotlin.ByteArray): FfiJsonResult {
3122
+ return FfiConverterTypeFfiJsonResult.lift(
3123
+ uniffiRustCall() { _status ->
3124
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_snapshot_restore(
3125
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`metadataJson`),FfiConverterByteArray.lower(`encodedState`),_status)
3126
+ }
3127
+ )
3128
+ }
3129
+
3130
+ fun `editorV2Undo`(`editorId`: kotlin.String, `requestJson`: kotlin.String): FfiJsonResult {
3131
+ return FfiConverterTypeFfiJsonResult.lift(
3132
+ uniffiRustCall() { _status ->
3133
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_undo(
3134
+ FfiConverterString.lower(`editorId`),FfiConverterString.lower(`requestJson`),_status)
3135
+ }
3136
+ )
3137
+ }
3138
+
3139
+ fun `viewerCompile`(`request`: FfiViewerCompileRequest): FfiViewerCompileResult {
3140
+ return FfiConverterTypeFfiViewerCompileResult.lift(
3141
+ uniffiRustCall() { _status ->
3142
+ UniffiLib.INSTANCE.uniffi_editor_core_fn_func_viewer_compile(
3143
+ FfiConverterTypeFfiViewerCompileRequest.lower(`request`),_status)
3144
+ }
3145
+ )
3146
+ }