@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,2378 @@
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
+ // swiftlint:disable all
5
+ import Foundation
6
+
7
+ // Depending on the consumer's build setup, the low-level FFI code
8
+ // might be in a separate module, or it might be compiled inline into
9
+ // this module. This is a bit of light hackery to work with both.
10
+ #if canImport(editor_coreFFI)
11
+ import editor_coreFFI
12
+ #endif
13
+
14
+ fileprivate extension RustBuffer {
15
+ // Allocate a new buffer, copying the contents of a `UInt8` array.
16
+ init(bytes: [UInt8]) {
17
+ let rbuf = bytes.withUnsafeBufferPointer { ptr in
18
+ RustBuffer.from(ptr)
19
+ }
20
+ self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
21
+ }
22
+
23
+ static func empty() -> RustBuffer {
24
+ RustBuffer(capacity: 0, len:0, data: nil)
25
+ }
26
+
27
+ static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
28
+ try! rustCall { ffi_editor_core_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
29
+ }
30
+
31
+ // Frees the buffer in place.
32
+ // The buffer must not be used after this is called.
33
+ func deallocate() {
34
+ try! rustCall { ffi_editor_core_rustbuffer_free(self, $0) }
35
+ }
36
+ }
37
+
38
+ fileprivate extension ForeignBytes {
39
+ init(bufferPointer: UnsafeBufferPointer<UInt8>) {
40
+ self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
41
+ }
42
+ }
43
+
44
+ // For every type used in the interface, we provide helper methods for conveniently
45
+ // lifting and lowering that type from C-compatible data, and for reading and writing
46
+ // values of that type in a buffer.
47
+
48
+ // Helper classes/extensions that don't change.
49
+ // Someday, this will be in a library of its own.
50
+
51
+ fileprivate extension Data {
52
+ init(rustBuffer: RustBuffer) {
53
+ self.init(
54
+ bytesNoCopy: rustBuffer.data!,
55
+ count: Int(rustBuffer.len),
56
+ deallocator: .none
57
+ )
58
+ }
59
+ }
60
+
61
+ // Define reader functionality. Normally this would be defined in a class or
62
+ // struct, but we use standalone functions instead in order to make external
63
+ // types work.
64
+ //
65
+ // With external types, one swift source file needs to be able to call the read
66
+ // method on another source file's FfiConverter, but then what visibility
67
+ // should Reader have?
68
+ // - If Reader is fileprivate, then this means the read() must also
69
+ // be fileprivate, which doesn't work with external types.
70
+ // - If Reader is internal/public, we'll get compile errors since both source
71
+ // files will try define the same type.
72
+ //
73
+ // Instead, the read() method and these helper functions input a tuple of data
74
+
75
+ fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) {
76
+ (data: data, offset: 0)
77
+ }
78
+
79
+ // Reads an integer at the current offset, in big-endian order, and advances
80
+ // the offset on success. Throws if reading the integer would move the
81
+ // offset past the end of the buffer.
82
+ fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
83
+ let range = reader.offset..<reader.offset + MemoryLayout<T>.size
84
+ guard reader.data.count >= range.upperBound else {
85
+ throw UniffiInternalError.bufferOverflow
86
+ }
87
+ if T.self == UInt8.self {
88
+ let value = reader.data[reader.offset]
89
+ reader.offset += 1
90
+ return value as! T
91
+ }
92
+ var value: T = 0
93
+ let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)})
94
+ reader.offset = range.upperBound
95
+ return value.bigEndian
96
+ }
97
+
98
+ // Reads an arbitrary number of bytes, to be used to read
99
+ // raw bytes, this is useful when lifting strings
100
+ fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> {
101
+ let range = reader.offset..<(reader.offset+count)
102
+ guard reader.data.count >= range.upperBound else {
103
+ throw UniffiInternalError.bufferOverflow
104
+ }
105
+ var value = [UInt8](repeating: 0, count: count)
106
+ value.withUnsafeMutableBufferPointer({ buffer in
107
+ reader.data.copyBytes(to: buffer, from: range)
108
+ })
109
+ reader.offset = range.upperBound
110
+ return value
111
+ }
112
+
113
+ // Reads a float at the current offset.
114
+ fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
115
+ return Float(bitPattern: try readInt(&reader))
116
+ }
117
+
118
+ // Reads a float at the current offset.
119
+ fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
120
+ return Double(bitPattern: try readInt(&reader))
121
+ }
122
+
123
+ // Indicates if the offset has reached the end of the buffer.
124
+ fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
125
+ return reader.offset < reader.data.count
126
+ }
127
+
128
+ // Define writer functionality. Normally this would be defined in a class or
129
+ // struct, but we use standalone functions instead in order to make external
130
+ // types work. See the above discussion on Readers for details.
131
+
132
+ fileprivate func createWriter() -> [UInt8] {
133
+ return []
134
+ }
135
+
136
+ fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
137
+ writer.append(contentsOf: byteArr)
138
+ }
139
+
140
+ // Writes an integer in big-endian order.
141
+ //
142
+ // Warning: make sure what you are trying to write
143
+ // is in the correct type!
144
+ fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
145
+ var value = value.bigEndian
146
+ withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
147
+ }
148
+
149
+ fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) {
150
+ writeInt(&writer, value.bitPattern)
151
+ }
152
+
153
+ fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
154
+ writeInt(&writer, value.bitPattern)
155
+ }
156
+
157
+ // Protocol for types that transfer other types across the FFI. This is
158
+ // analogous to the Rust trait of the same name.
159
+ fileprivate protocol FfiConverter {
160
+ associatedtype FfiType
161
+ associatedtype SwiftType
162
+
163
+ static func lift(_ value: FfiType) throws -> SwiftType
164
+ static func lower(_ value: SwiftType) -> FfiType
165
+ static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType
166
+ static func write(_ value: SwiftType, into buf: inout [UInt8])
167
+ }
168
+
169
+ // Types conforming to `Primitive` pass themselves directly over the FFI.
170
+ fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
171
+
172
+ extension FfiConverterPrimitive {
173
+ #if swift(>=5.8)
174
+ @_documentation(visibility: private)
175
+ #endif
176
+ public static func lift(_ value: FfiType) throws -> SwiftType {
177
+ return value
178
+ }
179
+
180
+ #if swift(>=5.8)
181
+ @_documentation(visibility: private)
182
+ #endif
183
+ public static func lower(_ value: SwiftType) -> FfiType {
184
+ return value
185
+ }
186
+ }
187
+
188
+ // Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
189
+ // Used for complex types where it's hard to write a custom lift/lower.
190
+ fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
191
+
192
+ extension FfiConverterRustBuffer {
193
+ #if swift(>=5.8)
194
+ @_documentation(visibility: private)
195
+ #endif
196
+ public static func lift(_ buf: RustBuffer) throws -> SwiftType {
197
+ var reader = createReader(data: Data(rustBuffer: buf))
198
+ let value = try read(from: &reader)
199
+ if hasRemaining(reader) {
200
+ throw UniffiInternalError.incompleteData
201
+ }
202
+ buf.deallocate()
203
+ return value
204
+ }
205
+
206
+ #if swift(>=5.8)
207
+ @_documentation(visibility: private)
208
+ #endif
209
+ public static func lower(_ value: SwiftType) -> RustBuffer {
210
+ var writer = createWriter()
211
+ write(value, into: &writer)
212
+ return RustBuffer(bytes: writer)
213
+ }
214
+ }
215
+ // An error type for FFI errors. These errors occur at the UniFFI level, not
216
+ // the library level.
217
+ fileprivate enum UniffiInternalError: LocalizedError {
218
+ case bufferOverflow
219
+ case incompleteData
220
+ case unexpectedOptionalTag
221
+ case unexpectedEnumCase
222
+ case unexpectedNullPointer
223
+ case unexpectedRustCallStatusCode
224
+ case unexpectedRustCallError
225
+ case unexpectedStaleHandle
226
+ case rustPanic(_ message: String)
227
+
228
+ public var errorDescription: String? {
229
+ switch self {
230
+ case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
231
+ case .incompleteData: return "The buffer still has data after lifting its containing value"
232
+ case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1"
233
+ case .unexpectedEnumCase: return "Raw enum value doesn't match any cases"
234
+ case .unexpectedNullPointer: return "Raw pointer value was null"
235
+ case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code"
236
+ case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified"
237
+ case .unexpectedStaleHandle: return "The object in the handle map has been dropped already"
238
+ case let .rustPanic(message): return message
239
+ }
240
+ }
241
+ }
242
+
243
+ fileprivate extension NSLock {
244
+ func withLock<T>(f: () throws -> T) rethrows -> T {
245
+ self.lock()
246
+ defer { self.unlock() }
247
+ return try f()
248
+ }
249
+ }
250
+
251
+ fileprivate let CALL_SUCCESS: Int8 = 0
252
+ fileprivate let CALL_ERROR: Int8 = 1
253
+ fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2
254
+ fileprivate let CALL_CANCELLED: Int8 = 3
255
+
256
+ fileprivate extension RustCallStatus {
257
+ init() {
258
+ self.init(
259
+ code: CALL_SUCCESS,
260
+ errorBuf: RustBuffer.init(
261
+ capacity: 0,
262
+ len: 0,
263
+ data: nil
264
+ )
265
+ )
266
+ }
267
+ }
268
+
269
+ private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
270
+ let neverThrow: ((RustBuffer) throws -> Never)? = nil
271
+ return try makeRustCall(callback, errorHandler: neverThrow)
272
+ }
273
+
274
+ private func rustCallWithError<T, E: Swift.Error>(
275
+ _ errorHandler: @escaping (RustBuffer) throws -> E,
276
+ _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
277
+ try makeRustCall(callback, errorHandler: errorHandler)
278
+ }
279
+
280
+ private func makeRustCall<T, E: Swift.Error>(
281
+ _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
282
+ errorHandler: ((RustBuffer) throws -> E)?
283
+ ) throws -> T {
284
+ uniffiEnsureEditorCoreInitialized()
285
+ var callStatus = RustCallStatus.init()
286
+ let returnedVal = callback(&callStatus)
287
+ try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
288
+ return returnedVal
289
+ }
290
+
291
+ private func uniffiCheckCallStatus<E: Swift.Error>(
292
+ callStatus: RustCallStatus,
293
+ errorHandler: ((RustBuffer) throws -> E)?
294
+ ) throws {
295
+ switch callStatus.code {
296
+ case CALL_SUCCESS:
297
+ return
298
+
299
+ case CALL_ERROR:
300
+ if let errorHandler = errorHandler {
301
+ throw try errorHandler(callStatus.errorBuf)
302
+ } else {
303
+ callStatus.errorBuf.deallocate()
304
+ throw UniffiInternalError.unexpectedRustCallError
305
+ }
306
+
307
+ case CALL_UNEXPECTED_ERROR:
308
+ // When the rust code sees a panic, it tries to construct a RustBuffer
309
+ // with the message. But if that code panics, then it just sends back
310
+ // an empty buffer.
311
+ if callStatus.errorBuf.len > 0 {
312
+ throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
313
+ } else {
314
+ callStatus.errorBuf.deallocate()
315
+ throw UniffiInternalError.rustPanic("Rust panic")
316
+ }
317
+
318
+ case CALL_CANCELLED:
319
+ fatalError("Cancellation not supported yet")
320
+
321
+ default:
322
+ throw UniffiInternalError.unexpectedRustCallStatusCode
323
+ }
324
+ }
325
+
326
+ private func uniffiTraitInterfaceCall<T>(
327
+ callStatus: UnsafeMutablePointer<RustCallStatus>,
328
+ makeCall: () throws -> T,
329
+ writeReturn: (T) -> ()
330
+ ) {
331
+ do {
332
+ try writeReturn(makeCall())
333
+ } catch let error {
334
+ callStatus.pointee.code = CALL_UNEXPECTED_ERROR
335
+ callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
336
+ }
337
+ }
338
+
339
+ private func uniffiTraitInterfaceCallWithError<T, E>(
340
+ callStatus: UnsafeMutablePointer<RustCallStatus>,
341
+ makeCall: () throws -> T,
342
+ writeReturn: (T) -> (),
343
+ lowerError: (E) -> RustBuffer
344
+ ) {
345
+ do {
346
+ try writeReturn(makeCall())
347
+ } catch let error as E {
348
+ callStatus.pointee.code = CALL_ERROR
349
+ callStatus.pointee.errorBuf = lowerError(error)
350
+ } catch {
351
+ callStatus.pointee.code = CALL_UNEXPECTED_ERROR
352
+ callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
353
+ }
354
+ }
355
+ fileprivate final class UniffiHandleMap<T>: @unchecked Sendable {
356
+ // All mutation happens with this lock held, which is why we implement @unchecked Sendable.
357
+ private let lock = NSLock()
358
+ private var map: [UInt64: T] = [:]
359
+ private var currentHandle: UInt64 = 1
360
+
361
+ func insert(obj: T) -> UInt64 {
362
+ lock.withLock {
363
+ let handle = currentHandle
364
+ currentHandle += 1
365
+ map[handle] = obj
366
+ return handle
367
+ }
368
+ }
369
+
370
+ func get(handle: UInt64) throws -> T {
371
+ try lock.withLock {
372
+ guard let obj = map[handle] else {
373
+ throw UniffiInternalError.unexpectedStaleHandle
374
+ }
375
+ return obj
376
+ }
377
+ }
378
+
379
+ @discardableResult
380
+ func remove(handle: UInt64) throws -> T {
381
+ try lock.withLock {
382
+ guard let obj = map.removeValue(forKey: handle) else {
383
+ throw UniffiInternalError.unexpectedStaleHandle
384
+ }
385
+ return obj
386
+ }
387
+ }
388
+
389
+ var count: Int {
390
+ get {
391
+ map.count
392
+ }
393
+ }
394
+ }
395
+
396
+
397
+ // Public interface members begin here.
398
+
399
+
400
+ #if swift(>=5.8)
401
+ @_documentation(visibility: private)
402
+ #endif
403
+ fileprivate struct FfiConverterUInt16: FfiConverterPrimitive {
404
+ typealias FfiType = UInt16
405
+ typealias SwiftType = UInt16
406
+
407
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt16 {
408
+ return try lift(readInt(&buf))
409
+ }
410
+
411
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
412
+ writeInt(&buf, lower(value))
413
+ }
414
+ }
415
+
416
+ #if swift(>=5.8)
417
+ @_documentation(visibility: private)
418
+ #endif
419
+ fileprivate struct FfiConverterUInt32: FfiConverterPrimitive {
420
+ typealias FfiType = UInt32
421
+ typealias SwiftType = UInt32
422
+
423
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 {
424
+ return try lift(readInt(&buf))
425
+ }
426
+
427
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
428
+ writeInt(&buf, lower(value))
429
+ }
430
+ }
431
+
432
+ #if swift(>=5.8)
433
+ @_documentation(visibility: private)
434
+ #endif
435
+ fileprivate struct FfiConverterBool : FfiConverter {
436
+ typealias FfiType = Int8
437
+ typealias SwiftType = Bool
438
+
439
+ public static func lift(_ value: Int8) throws -> Bool {
440
+ return value != 0
441
+ }
442
+
443
+ public static func lower(_ value: Bool) -> Int8 {
444
+ return value ? 1 : 0
445
+ }
446
+
447
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
448
+ return try lift(readInt(&buf))
449
+ }
450
+
451
+ public static func write(_ value: Bool, into buf: inout [UInt8]) {
452
+ writeInt(&buf, lower(value))
453
+ }
454
+ }
455
+
456
+ #if swift(>=5.8)
457
+ @_documentation(visibility: private)
458
+ #endif
459
+ fileprivate struct FfiConverterString: FfiConverter {
460
+ typealias SwiftType = String
461
+ typealias FfiType = RustBuffer
462
+
463
+ public static func lift(_ value: RustBuffer) throws -> String {
464
+ defer {
465
+ value.deallocate()
466
+ }
467
+ if value.data == nil {
468
+ return String()
469
+ }
470
+ let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
471
+ return String(bytes: bytes, encoding: String.Encoding.utf8)!
472
+ }
473
+
474
+ public static func lower(_ value: String) -> RustBuffer {
475
+ return value.utf8CString.withUnsafeBufferPointer { ptr in
476
+ // The swift string gives us int8_t, we want uint8_t.
477
+ ptr.withMemoryRebound(to: UInt8.self) { ptr in
478
+ // The swift string gives us a trailing null byte, we don't want it.
479
+ let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
480
+ return RustBuffer.from(buf)
481
+ }
482
+ }
483
+ }
484
+
485
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
486
+ let len: Int32 = try readInt(&buf)
487
+ return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
488
+ }
489
+
490
+ public static func write(_ value: String, into buf: inout [UInt8]) {
491
+ let len = Int32(value.utf8.count)
492
+ writeInt(&buf, len)
493
+ writeBytes(&buf, value.utf8)
494
+ }
495
+ }
496
+
497
+ #if swift(>=5.8)
498
+ @_documentation(visibility: private)
499
+ #endif
500
+ fileprivate struct FfiConverterData: FfiConverterRustBuffer {
501
+ typealias SwiftType = Data
502
+
503
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
504
+ let len: Int32 = try readInt(&buf)
505
+ return Data(try readBytes(&buf, count: Int(len)))
506
+ }
507
+
508
+ public static func write(_ value: Data, into buf: inout [UInt8]) {
509
+ let len = Int32(value.count)
510
+ writeInt(&buf, len)
511
+ writeBytes(&buf, value)
512
+ }
513
+ }
514
+
515
+
516
+
517
+
518
+ public protocol ViewerCompiledDocumentProtocol: AnyObject, Sendable {
519
+
520
+ func elements() -> [FfiViewerElement]
521
+
522
+ func isEmpty() -> Bool
523
+
524
+ func preferredTextBlockName() -> String
525
+
526
+ func retainedBytesDecimal() -> String
527
+
528
+ func semanticKey() -> String
529
+
530
+ func trailingEmptyTextBlockCount() -> UInt32
531
+
532
+ }
533
+ open class ViewerCompiledDocument: ViewerCompiledDocumentProtocol, @unchecked Sendable {
534
+ fileprivate let pointer: UnsafeMutableRawPointer!
535
+
536
+ /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
537
+ #if swift(>=5.8)
538
+ @_documentation(visibility: private)
539
+ #endif
540
+ public struct NoPointer {
541
+ public init() {}
542
+ }
543
+
544
+ // TODO: We'd like this to be `private` but for Swifty reasons,
545
+ // we can't implement `FfiConverter` without making this `required` and we can't
546
+ // make it `required` without making it `public`.
547
+ #if swift(>=5.8)
548
+ @_documentation(visibility: private)
549
+ #endif
550
+ required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
551
+ self.pointer = pointer
552
+ }
553
+
554
+ // This constructor can be used to instantiate a fake object.
555
+ // - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
556
+ //
557
+ // - Warning:
558
+ // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing [Pointer] the FFI lower functions will crash.
559
+ #if swift(>=5.8)
560
+ @_documentation(visibility: private)
561
+ #endif
562
+ public init(noPointer: NoPointer) {
563
+ self.pointer = nil
564
+ }
565
+
566
+ #if swift(>=5.8)
567
+ @_documentation(visibility: private)
568
+ #endif
569
+ public func uniffiClonePointer() -> UnsafeMutableRawPointer {
570
+ return try! rustCall { uniffi_editor_core_fn_clone_viewercompileddocument(self.pointer, $0) }
571
+ }
572
+ // No primary constructor declared for this class.
573
+
574
+ deinit {
575
+ guard let pointer = pointer else {
576
+ return
577
+ }
578
+
579
+ try! rustCall { uniffi_editor_core_fn_free_viewercompileddocument(pointer, $0) }
580
+ }
581
+
582
+
583
+
584
+
585
+ open func elements() -> [FfiViewerElement] {
586
+ return try! FfiConverterSequenceTypeFfiViewerElement.lift(try! rustCall() {
587
+ uniffi_editor_core_fn_method_viewercompileddocument_elements(self.uniffiClonePointer(),$0
588
+ )
589
+ })
590
+ }
591
+
592
+ open func isEmpty() -> Bool {
593
+ return try! FfiConverterBool.lift(try! rustCall() {
594
+ uniffi_editor_core_fn_method_viewercompileddocument_is_empty(self.uniffiClonePointer(),$0
595
+ )
596
+ })
597
+ }
598
+
599
+ open func preferredTextBlockName() -> String {
600
+ return try! FfiConverterString.lift(try! rustCall() {
601
+ uniffi_editor_core_fn_method_viewercompileddocument_preferred_text_block_name(self.uniffiClonePointer(),$0
602
+ )
603
+ })
604
+ }
605
+
606
+ open func retainedBytesDecimal() -> String {
607
+ return try! FfiConverterString.lift(try! rustCall() {
608
+ uniffi_editor_core_fn_method_viewercompileddocument_retained_bytes_decimal(self.uniffiClonePointer(),$0
609
+ )
610
+ })
611
+ }
612
+
613
+ open func semanticKey() -> String {
614
+ return try! FfiConverterString.lift(try! rustCall() {
615
+ uniffi_editor_core_fn_method_viewercompileddocument_semantic_key(self.uniffiClonePointer(),$0
616
+ )
617
+ })
618
+ }
619
+
620
+ open func trailingEmptyTextBlockCount() -> UInt32 {
621
+ return try! FfiConverterUInt32.lift(try! rustCall() {
622
+ uniffi_editor_core_fn_method_viewercompileddocument_trailing_empty_text_block_count(self.uniffiClonePointer(),$0
623
+ )
624
+ })
625
+ }
626
+
627
+
628
+ }
629
+
630
+
631
+ #if swift(>=5.8)
632
+ @_documentation(visibility: private)
633
+ #endif
634
+ public struct FfiConverterTypeViewerCompiledDocument: FfiConverter {
635
+
636
+ typealias FfiType = UnsafeMutableRawPointer
637
+ typealias SwiftType = ViewerCompiledDocument
638
+
639
+ public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ViewerCompiledDocument {
640
+ return ViewerCompiledDocument(unsafeFromRawPointer: pointer)
641
+ }
642
+
643
+ public static func lower(_ value: ViewerCompiledDocument) -> UnsafeMutableRawPointer {
644
+ return value.uniffiClonePointer()
645
+ }
646
+
647
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ViewerCompiledDocument {
648
+ let v: UInt64 = try readInt(&buf)
649
+ // The Rust code won't compile if a pointer won't fit in a UInt64.
650
+ // We have to go via `UInt` because that's the thing that's the size of a pointer.
651
+ let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
652
+ if (ptr == nil) {
653
+ throw UniffiInternalError.unexpectedNullPointer
654
+ }
655
+ return try lift(ptr!)
656
+ }
657
+
658
+ public static func write(_ value: ViewerCompiledDocument, into buf: inout [UInt8]) {
659
+ // This fiddling is because `Int` is the thing that's the same size as a pointer.
660
+ // The Rust code won't compile if a pointer won't fit in a `UInt64`.
661
+ writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
662
+ }
663
+ }
664
+
665
+
666
+ #if swift(>=5.8)
667
+ @_documentation(visibility: private)
668
+ #endif
669
+ public func FfiConverterTypeViewerCompiledDocument_lift(_ pointer: UnsafeMutableRawPointer) throws -> ViewerCompiledDocument {
670
+ return try FfiConverterTypeViewerCompiledDocument.lift(pointer)
671
+ }
672
+
673
+ #if swift(>=5.8)
674
+ @_documentation(visibility: private)
675
+ #endif
676
+ public func FfiConverterTypeViewerCompiledDocument_lower(_ value: ViewerCompiledDocument) -> UnsafeMutableRawPointer {
677
+ return FfiConverterTypeViewerCompiledDocument.lower(value)
678
+ }
679
+
680
+
681
+
682
+
683
+ public struct FfiError {
684
+ public var domain: String
685
+ public var code: String
686
+ public var message: String
687
+ public var requestId: String?
688
+ public var operationIndex: String?
689
+ public var limit: String?
690
+ public var actual: String?
691
+ public var detailsJson: String?
692
+
693
+ // Default memberwise initializers are never public by default, so we
694
+ // declare one manually.
695
+ public init(domain: String, code: String, message: String, requestId: String?, operationIndex: String?, limit: String?, actual: String?, detailsJson: String?) {
696
+ self.domain = domain
697
+ self.code = code
698
+ self.message = message
699
+ self.requestId = requestId
700
+ self.operationIndex = operationIndex
701
+ self.limit = limit
702
+ self.actual = actual
703
+ self.detailsJson = detailsJson
704
+ }
705
+ }
706
+
707
+ #if compiler(>=6)
708
+ extension FfiError: Sendable {}
709
+ #endif
710
+
711
+
712
+ extension FfiError: Equatable, Hashable {
713
+ public static func ==(lhs: FfiError, rhs: FfiError) -> Bool {
714
+ if lhs.domain != rhs.domain {
715
+ return false
716
+ }
717
+ if lhs.code != rhs.code {
718
+ return false
719
+ }
720
+ if lhs.message != rhs.message {
721
+ return false
722
+ }
723
+ if lhs.requestId != rhs.requestId {
724
+ return false
725
+ }
726
+ if lhs.operationIndex != rhs.operationIndex {
727
+ return false
728
+ }
729
+ if lhs.limit != rhs.limit {
730
+ return false
731
+ }
732
+ if lhs.actual != rhs.actual {
733
+ return false
734
+ }
735
+ if lhs.detailsJson != rhs.detailsJson {
736
+ return false
737
+ }
738
+ return true
739
+ }
740
+
741
+ public func hash(into hasher: inout Hasher) {
742
+ hasher.combine(domain)
743
+ hasher.combine(code)
744
+ hasher.combine(message)
745
+ hasher.combine(requestId)
746
+ hasher.combine(operationIndex)
747
+ hasher.combine(limit)
748
+ hasher.combine(actual)
749
+ hasher.combine(detailsJson)
750
+ }
751
+ }
752
+
753
+
754
+
755
+ #if swift(>=5.8)
756
+ @_documentation(visibility: private)
757
+ #endif
758
+ public struct FfiConverterTypeFfiError: FfiConverterRustBuffer {
759
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiError {
760
+ return
761
+ try FfiError(
762
+ domain: FfiConverterString.read(from: &buf),
763
+ code: FfiConverterString.read(from: &buf),
764
+ message: FfiConverterString.read(from: &buf),
765
+ requestId: FfiConverterOptionString.read(from: &buf),
766
+ operationIndex: FfiConverterOptionString.read(from: &buf),
767
+ limit: FfiConverterOptionString.read(from: &buf),
768
+ actual: FfiConverterOptionString.read(from: &buf),
769
+ detailsJson: FfiConverterOptionString.read(from: &buf)
770
+ )
771
+ }
772
+
773
+ public static func write(_ value: FfiError, into buf: inout [UInt8]) {
774
+ FfiConverterString.write(value.domain, into: &buf)
775
+ FfiConverterString.write(value.code, into: &buf)
776
+ FfiConverterString.write(value.message, into: &buf)
777
+ FfiConverterOptionString.write(value.requestId, into: &buf)
778
+ FfiConverterOptionString.write(value.operationIndex, into: &buf)
779
+ FfiConverterOptionString.write(value.limit, into: &buf)
780
+ FfiConverterOptionString.write(value.actual, into: &buf)
781
+ FfiConverterOptionString.write(value.detailsJson, into: &buf)
782
+ }
783
+ }
784
+
785
+
786
+ #if swift(>=5.8)
787
+ @_documentation(visibility: private)
788
+ #endif
789
+ public func FfiConverterTypeFfiError_lift(_ buf: RustBuffer) throws -> FfiError {
790
+ return try FfiConverterTypeFfiError.lift(buf)
791
+ }
792
+
793
+ #if swift(>=5.8)
794
+ @_documentation(visibility: private)
795
+ #endif
796
+ public func FfiConverterTypeFfiError_lower(_ value: FfiError) -> RustBuffer {
797
+ return FfiConverterTypeFfiError.lower(value)
798
+ }
799
+
800
+
801
+ public struct FfiJsonResult {
802
+ public var value: String?
803
+ public var error: FfiError?
804
+
805
+ // Default memberwise initializers are never public by default, so we
806
+ // declare one manually.
807
+ public init(value: String?, error: FfiError?) {
808
+ self.value = value
809
+ self.error = error
810
+ }
811
+ }
812
+
813
+ #if compiler(>=6)
814
+ extension FfiJsonResult: Sendable {}
815
+ #endif
816
+
817
+
818
+ extension FfiJsonResult: Equatable, Hashable {
819
+ public static func ==(lhs: FfiJsonResult, rhs: FfiJsonResult) -> Bool {
820
+ if lhs.value != rhs.value {
821
+ return false
822
+ }
823
+ if lhs.error != rhs.error {
824
+ return false
825
+ }
826
+ return true
827
+ }
828
+
829
+ public func hash(into hasher: inout Hasher) {
830
+ hasher.combine(value)
831
+ hasher.combine(error)
832
+ }
833
+ }
834
+
835
+
836
+
837
+ #if swift(>=5.8)
838
+ @_documentation(visibility: private)
839
+ #endif
840
+ public struct FfiConverterTypeFfiJsonResult: FfiConverterRustBuffer {
841
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiJsonResult {
842
+ return
843
+ try FfiJsonResult(
844
+ value: FfiConverterOptionString.read(from: &buf),
845
+ error: FfiConverterOptionTypeFfiError.read(from: &buf)
846
+ )
847
+ }
848
+
849
+ public static func write(_ value: FfiJsonResult, into buf: inout [UInt8]) {
850
+ FfiConverterOptionString.write(value.value, into: &buf)
851
+ FfiConverterOptionTypeFfiError.write(value.error, into: &buf)
852
+ }
853
+ }
854
+
855
+
856
+ #if swift(>=5.8)
857
+ @_documentation(visibility: private)
858
+ #endif
859
+ public func FfiConverterTypeFfiJsonResult_lift(_ buf: RustBuffer) throws -> FfiJsonResult {
860
+ return try FfiConverterTypeFfiJsonResult.lift(buf)
861
+ }
862
+
863
+ #if swift(>=5.8)
864
+ @_documentation(visibility: private)
865
+ #endif
866
+ public func FfiConverterTypeFfiJsonResult_lower(_ value: FfiJsonResult) -> RustBuffer {
867
+ return FfiConverterTypeFfiJsonResult.lower(value)
868
+ }
869
+
870
+
871
+ /**
872
+ * One active outbound transport lease. The identifier stays canonical
873
+ * decimal text while the y-protocols frame remains binary end-to-end.
874
+ */
875
+ public struct FfiOutboundLease {
876
+ public var leaseId: String
877
+ public var frame: Data
878
+
879
+ // Default memberwise initializers are never public by default, so we
880
+ // declare one manually.
881
+ public init(leaseId: String, frame: Data) {
882
+ self.leaseId = leaseId
883
+ self.frame = frame
884
+ }
885
+ }
886
+
887
+ #if compiler(>=6)
888
+ extension FfiOutboundLease: Sendable {}
889
+ #endif
890
+
891
+
892
+ extension FfiOutboundLease: Equatable, Hashable {
893
+ public static func ==(lhs: FfiOutboundLease, rhs: FfiOutboundLease) -> Bool {
894
+ if lhs.leaseId != rhs.leaseId {
895
+ return false
896
+ }
897
+ if lhs.frame != rhs.frame {
898
+ return false
899
+ }
900
+ return true
901
+ }
902
+
903
+ public func hash(into hasher: inout Hasher) {
904
+ hasher.combine(leaseId)
905
+ hasher.combine(frame)
906
+ }
907
+ }
908
+
909
+
910
+
911
+ #if swift(>=5.8)
912
+ @_documentation(visibility: private)
913
+ #endif
914
+ public struct FfiConverterTypeFfiOutboundLease: FfiConverterRustBuffer {
915
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiOutboundLease {
916
+ return
917
+ try FfiOutboundLease(
918
+ leaseId: FfiConverterString.read(from: &buf),
919
+ frame: FfiConverterData.read(from: &buf)
920
+ )
921
+ }
922
+
923
+ public static func write(_ value: FfiOutboundLease, into buf: inout [UInt8]) {
924
+ FfiConverterString.write(value.leaseId, into: &buf)
925
+ FfiConverterData.write(value.frame, into: &buf)
926
+ }
927
+ }
928
+
929
+
930
+ #if swift(>=5.8)
931
+ @_documentation(visibility: private)
932
+ #endif
933
+ public func FfiConverterTypeFfiOutboundLease_lift(_ buf: RustBuffer) throws -> FfiOutboundLease {
934
+ return try FfiConverterTypeFfiOutboundLease.lift(buf)
935
+ }
936
+
937
+ #if swift(>=5.8)
938
+ @_documentation(visibility: private)
939
+ #endif
940
+ public func FfiConverterTypeFfiOutboundLease_lower(_ value: FfiOutboundLease) -> RustBuffer {
941
+ return FfiConverterTypeFfiOutboundLease.lower(value)
942
+ }
943
+
944
+
945
+ /**
946
+ * Explicit three-way lease result: exactly one of a retained value, a
947
+ * queue-empty marker, or an error is selected. Empty is not encoded as an
948
+ * empty binary frame, which keeps it distinct from valid protocol bytes.
949
+ */
950
+ public struct FfiOutboundLeaseResult {
951
+ public var value: FfiOutboundLease?
952
+ public var empty: Bool
953
+ public var error: FfiError?
954
+
955
+ // Default memberwise initializers are never public by default, so we
956
+ // declare one manually.
957
+ public init(value: FfiOutboundLease?, empty: Bool, error: FfiError?) {
958
+ self.value = value
959
+ self.empty = empty
960
+ self.error = error
961
+ }
962
+ }
963
+
964
+ #if compiler(>=6)
965
+ extension FfiOutboundLeaseResult: Sendable {}
966
+ #endif
967
+
968
+
969
+ extension FfiOutboundLeaseResult: Equatable, Hashable {
970
+ public static func ==(lhs: FfiOutboundLeaseResult, rhs: FfiOutboundLeaseResult) -> Bool {
971
+ if lhs.value != rhs.value {
972
+ return false
973
+ }
974
+ if lhs.empty != rhs.empty {
975
+ return false
976
+ }
977
+ if lhs.error != rhs.error {
978
+ return false
979
+ }
980
+ return true
981
+ }
982
+
983
+ public func hash(into hasher: inout Hasher) {
984
+ hasher.combine(value)
985
+ hasher.combine(empty)
986
+ hasher.combine(error)
987
+ }
988
+ }
989
+
990
+
991
+
992
+ #if swift(>=5.8)
993
+ @_documentation(visibility: private)
994
+ #endif
995
+ public struct FfiConverterTypeFfiOutboundLeaseResult: FfiConverterRustBuffer {
996
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiOutboundLeaseResult {
997
+ return
998
+ try FfiOutboundLeaseResult(
999
+ value: FfiConverterOptionTypeFfiOutboundLease.read(from: &buf),
1000
+ empty: FfiConverterBool.read(from: &buf),
1001
+ error: FfiConverterOptionTypeFfiError.read(from: &buf)
1002
+ )
1003
+ }
1004
+
1005
+ public static func write(_ value: FfiOutboundLeaseResult, into buf: inout [UInt8]) {
1006
+ FfiConverterOptionTypeFfiOutboundLease.write(value.value, into: &buf)
1007
+ FfiConverterBool.write(value.empty, into: &buf)
1008
+ FfiConverterOptionTypeFfiError.write(value.error, into: &buf)
1009
+ }
1010
+ }
1011
+
1012
+
1013
+ #if swift(>=5.8)
1014
+ @_documentation(visibility: private)
1015
+ #endif
1016
+ public func FfiConverterTypeFfiOutboundLeaseResult_lift(_ buf: RustBuffer) throws -> FfiOutboundLeaseResult {
1017
+ return try FfiConverterTypeFfiOutboundLeaseResult.lift(buf)
1018
+ }
1019
+
1020
+ #if swift(>=5.8)
1021
+ @_documentation(visibility: private)
1022
+ #endif
1023
+ public func FfiConverterTypeFfiOutboundLeaseResult_lower(_ value: FfiOutboundLeaseResult) -> RustBuffer {
1024
+ return FfiConverterTypeFfiOutboundLeaseResult.lower(value)
1025
+ }
1026
+
1027
+
1028
+ /**
1029
+ * One exported document snapshot: the five-field manifest as JSON plus the
1030
+ * encoded state as direct bytes (never a JSON number array).
1031
+ */
1032
+ public struct FfiSnapshotExport {
1033
+ public var metadataJson: String
1034
+ public var encodedState: Data
1035
+
1036
+ // Default memberwise initializers are never public by default, so we
1037
+ // declare one manually.
1038
+ public init(metadataJson: String, encodedState: Data) {
1039
+ self.metadataJson = metadataJson
1040
+ self.encodedState = encodedState
1041
+ }
1042
+ }
1043
+
1044
+ #if compiler(>=6)
1045
+ extension FfiSnapshotExport: Sendable {}
1046
+ #endif
1047
+
1048
+
1049
+ extension FfiSnapshotExport: Equatable, Hashable {
1050
+ public static func ==(lhs: FfiSnapshotExport, rhs: FfiSnapshotExport) -> Bool {
1051
+ if lhs.metadataJson != rhs.metadataJson {
1052
+ return false
1053
+ }
1054
+ if lhs.encodedState != rhs.encodedState {
1055
+ return false
1056
+ }
1057
+ return true
1058
+ }
1059
+
1060
+ public func hash(into hasher: inout Hasher) {
1061
+ hasher.combine(metadataJson)
1062
+ hasher.combine(encodedState)
1063
+ }
1064
+ }
1065
+
1066
+
1067
+
1068
+ #if swift(>=5.8)
1069
+ @_documentation(visibility: private)
1070
+ #endif
1071
+ public struct FfiConverterTypeFfiSnapshotExport: FfiConverterRustBuffer {
1072
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiSnapshotExport {
1073
+ return
1074
+ try FfiSnapshotExport(
1075
+ metadataJson: FfiConverterString.read(from: &buf),
1076
+ encodedState: FfiConverterData.read(from: &buf)
1077
+ )
1078
+ }
1079
+
1080
+ public static func write(_ value: FfiSnapshotExport, into buf: inout [UInt8]) {
1081
+ FfiConverterString.write(value.metadataJson, into: &buf)
1082
+ FfiConverterData.write(value.encodedState, into: &buf)
1083
+ }
1084
+ }
1085
+
1086
+
1087
+ #if swift(>=5.8)
1088
+ @_documentation(visibility: private)
1089
+ #endif
1090
+ public func FfiConverterTypeFfiSnapshotExport_lift(_ buf: RustBuffer) throws -> FfiSnapshotExport {
1091
+ return try FfiConverterTypeFfiSnapshotExport.lift(buf)
1092
+ }
1093
+
1094
+ #if swift(>=5.8)
1095
+ @_documentation(visibility: private)
1096
+ #endif
1097
+ public func FfiConverterTypeFfiSnapshotExport_lower(_ value: FfiSnapshotExport) -> RustBuffer {
1098
+ return FfiConverterTypeFfiSnapshotExport.lower(value)
1099
+ }
1100
+
1101
+
1102
+ public struct FfiSnapshotExportResult {
1103
+ public var value: FfiSnapshotExport?
1104
+ public var error: FfiError?
1105
+
1106
+ // Default memberwise initializers are never public by default, so we
1107
+ // declare one manually.
1108
+ public init(value: FfiSnapshotExport?, error: FfiError?) {
1109
+ self.value = value
1110
+ self.error = error
1111
+ }
1112
+ }
1113
+
1114
+ #if compiler(>=6)
1115
+ extension FfiSnapshotExportResult: Sendable {}
1116
+ #endif
1117
+
1118
+
1119
+ extension FfiSnapshotExportResult: Equatable, Hashable {
1120
+ public static func ==(lhs: FfiSnapshotExportResult, rhs: FfiSnapshotExportResult) -> Bool {
1121
+ if lhs.value != rhs.value {
1122
+ return false
1123
+ }
1124
+ if lhs.error != rhs.error {
1125
+ return false
1126
+ }
1127
+ return true
1128
+ }
1129
+
1130
+ public func hash(into hasher: inout Hasher) {
1131
+ hasher.combine(value)
1132
+ hasher.combine(error)
1133
+ }
1134
+ }
1135
+
1136
+
1137
+
1138
+ #if swift(>=5.8)
1139
+ @_documentation(visibility: private)
1140
+ #endif
1141
+ public struct FfiConverterTypeFfiSnapshotExportResult: FfiConverterRustBuffer {
1142
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiSnapshotExportResult {
1143
+ return
1144
+ try FfiSnapshotExportResult(
1145
+ value: FfiConverterOptionTypeFfiSnapshotExport.read(from: &buf),
1146
+ error: FfiConverterOptionTypeFfiError.read(from: &buf)
1147
+ )
1148
+ }
1149
+
1150
+ public static func write(_ value: FfiSnapshotExportResult, into buf: inout [UInt8]) {
1151
+ FfiConverterOptionTypeFfiSnapshotExport.write(value.value, into: &buf)
1152
+ FfiConverterOptionTypeFfiError.write(value.error, into: &buf)
1153
+ }
1154
+ }
1155
+
1156
+
1157
+ #if swift(>=5.8)
1158
+ @_documentation(visibility: private)
1159
+ #endif
1160
+ public func FfiConverterTypeFfiSnapshotExportResult_lift(_ buf: RustBuffer) throws -> FfiSnapshotExportResult {
1161
+ return try FfiConverterTypeFfiSnapshotExportResult.lift(buf)
1162
+ }
1163
+
1164
+ #if swift(>=5.8)
1165
+ @_documentation(visibility: private)
1166
+ #endif
1167
+ public func FfiConverterTypeFfiSnapshotExportResult_lower(_ value: FfiSnapshotExportResult) -> RustBuffer {
1168
+ return FfiConverterTypeFfiSnapshotExportResult.lower(value)
1169
+ }
1170
+
1171
+
1172
+ public struct FfiUnitResult {
1173
+ public var value: Bool?
1174
+ public var error: FfiError?
1175
+
1176
+ // Default memberwise initializers are never public by default, so we
1177
+ // declare one manually.
1178
+ public init(value: Bool?, error: FfiError?) {
1179
+ self.value = value
1180
+ self.error = error
1181
+ }
1182
+ }
1183
+
1184
+ #if compiler(>=6)
1185
+ extension FfiUnitResult: Sendable {}
1186
+ #endif
1187
+
1188
+
1189
+ extension FfiUnitResult: Equatable, Hashable {
1190
+ public static func ==(lhs: FfiUnitResult, rhs: FfiUnitResult) -> Bool {
1191
+ if lhs.value != rhs.value {
1192
+ return false
1193
+ }
1194
+ if lhs.error != rhs.error {
1195
+ return false
1196
+ }
1197
+ return true
1198
+ }
1199
+
1200
+ public func hash(into hasher: inout Hasher) {
1201
+ hasher.combine(value)
1202
+ hasher.combine(error)
1203
+ }
1204
+ }
1205
+
1206
+
1207
+
1208
+ #if swift(>=5.8)
1209
+ @_documentation(visibility: private)
1210
+ #endif
1211
+ public struct FfiConverterTypeFfiUnitResult: FfiConverterRustBuffer {
1212
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiUnitResult {
1213
+ return
1214
+ try FfiUnitResult(
1215
+ value: FfiConverterOptionBool.read(from: &buf),
1216
+ error: FfiConverterOptionTypeFfiError.read(from: &buf)
1217
+ )
1218
+ }
1219
+
1220
+ public static func write(_ value: FfiUnitResult, into buf: inout [UInt8]) {
1221
+ FfiConverterOptionBool.write(value.value, into: &buf)
1222
+ FfiConverterOptionTypeFfiError.write(value.error, into: &buf)
1223
+ }
1224
+ }
1225
+
1226
+
1227
+ #if swift(>=5.8)
1228
+ @_documentation(visibility: private)
1229
+ #endif
1230
+ public func FfiConverterTypeFfiUnitResult_lift(_ buf: RustBuffer) throws -> FfiUnitResult {
1231
+ return try FfiConverterTypeFfiUnitResult.lift(buf)
1232
+ }
1233
+
1234
+ #if swift(>=5.8)
1235
+ @_documentation(visibility: private)
1236
+ #endif
1237
+ public func FfiConverterTypeFfiUnitResult_lower(_ value: FfiUnitResult) -> RustBuffer {
1238
+ return FfiConverterTypeFfiUnitResult.lower(value)
1239
+ }
1240
+
1241
+
1242
+ public struct FfiViewerCompileRequest {
1243
+ public var sourceKind: FfiViewerSourceKind
1244
+ public var source: String
1245
+ public var configJson: String
1246
+ public var imagesEnabled: Bool
1247
+ public var mentionPrefix: String?
1248
+
1249
+ // Default memberwise initializers are never public by default, so we
1250
+ // declare one manually.
1251
+ public init(sourceKind: FfiViewerSourceKind, source: String, configJson: String, imagesEnabled: Bool, mentionPrefix: String?) {
1252
+ self.sourceKind = sourceKind
1253
+ self.source = source
1254
+ self.configJson = configJson
1255
+ self.imagesEnabled = imagesEnabled
1256
+ self.mentionPrefix = mentionPrefix
1257
+ }
1258
+ }
1259
+
1260
+ #if compiler(>=6)
1261
+ extension FfiViewerCompileRequest: Sendable {}
1262
+ #endif
1263
+
1264
+
1265
+ extension FfiViewerCompileRequest: Equatable, Hashable {
1266
+ public static func ==(lhs: FfiViewerCompileRequest, rhs: FfiViewerCompileRequest) -> Bool {
1267
+ if lhs.sourceKind != rhs.sourceKind {
1268
+ return false
1269
+ }
1270
+ if lhs.source != rhs.source {
1271
+ return false
1272
+ }
1273
+ if lhs.configJson != rhs.configJson {
1274
+ return false
1275
+ }
1276
+ if lhs.imagesEnabled != rhs.imagesEnabled {
1277
+ return false
1278
+ }
1279
+ if lhs.mentionPrefix != rhs.mentionPrefix {
1280
+ return false
1281
+ }
1282
+ return true
1283
+ }
1284
+
1285
+ public func hash(into hasher: inout Hasher) {
1286
+ hasher.combine(sourceKind)
1287
+ hasher.combine(source)
1288
+ hasher.combine(configJson)
1289
+ hasher.combine(imagesEnabled)
1290
+ hasher.combine(mentionPrefix)
1291
+ }
1292
+ }
1293
+
1294
+
1295
+
1296
+ #if swift(>=5.8)
1297
+ @_documentation(visibility: private)
1298
+ #endif
1299
+ public struct FfiConverterTypeFfiViewerCompileRequest: FfiConverterRustBuffer {
1300
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiViewerCompileRequest {
1301
+ return
1302
+ try FfiViewerCompileRequest(
1303
+ sourceKind: FfiConverterTypeFfiViewerSourceKind.read(from: &buf),
1304
+ source: FfiConverterString.read(from: &buf),
1305
+ configJson: FfiConverterString.read(from: &buf),
1306
+ imagesEnabled: FfiConverterBool.read(from: &buf),
1307
+ mentionPrefix: FfiConverterOptionString.read(from: &buf)
1308
+ )
1309
+ }
1310
+
1311
+ public static func write(_ value: FfiViewerCompileRequest, into buf: inout [UInt8]) {
1312
+ FfiConverterTypeFfiViewerSourceKind.write(value.sourceKind, into: &buf)
1313
+ FfiConverterString.write(value.source, into: &buf)
1314
+ FfiConverterString.write(value.configJson, into: &buf)
1315
+ FfiConverterBool.write(value.imagesEnabled, into: &buf)
1316
+ FfiConverterOptionString.write(value.mentionPrefix, into: &buf)
1317
+ }
1318
+ }
1319
+
1320
+
1321
+ #if swift(>=5.8)
1322
+ @_documentation(visibility: private)
1323
+ #endif
1324
+ public func FfiConverterTypeFfiViewerCompileRequest_lift(_ buf: RustBuffer) throws -> FfiViewerCompileRequest {
1325
+ return try FfiConverterTypeFfiViewerCompileRequest.lift(buf)
1326
+ }
1327
+
1328
+ #if swift(>=5.8)
1329
+ @_documentation(visibility: private)
1330
+ #endif
1331
+ public func FfiConverterTypeFfiViewerCompileRequest_lower(_ value: FfiViewerCompileRequest) -> RustBuffer {
1332
+ return FfiConverterTypeFfiViewerCompileRequest.lower(value)
1333
+ }
1334
+
1335
+
1336
+ public struct FfiViewerCompileResult {
1337
+ public var value: ViewerCompiledDocument?
1338
+ public var error: FfiError?
1339
+
1340
+ // Default memberwise initializers are never public by default, so we
1341
+ // declare one manually.
1342
+ public init(value: ViewerCompiledDocument?, error: FfiError?) {
1343
+ self.value = value
1344
+ self.error = error
1345
+ }
1346
+ }
1347
+
1348
+ #if compiler(>=6)
1349
+ extension FfiViewerCompileResult: Sendable {}
1350
+ #endif
1351
+
1352
+
1353
+
1354
+ #if swift(>=5.8)
1355
+ @_documentation(visibility: private)
1356
+ #endif
1357
+ public struct FfiConverterTypeFfiViewerCompileResult: FfiConverterRustBuffer {
1358
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiViewerCompileResult {
1359
+ return
1360
+ try FfiViewerCompileResult(
1361
+ value: FfiConverterOptionTypeViewerCompiledDocument.read(from: &buf),
1362
+ error: FfiConverterOptionTypeFfiError.read(from: &buf)
1363
+ )
1364
+ }
1365
+
1366
+ public static func write(_ value: FfiViewerCompileResult, into buf: inout [UInt8]) {
1367
+ FfiConverterOptionTypeViewerCompiledDocument.write(value.value, into: &buf)
1368
+ FfiConverterOptionTypeFfiError.write(value.error, into: &buf)
1369
+ }
1370
+ }
1371
+
1372
+
1373
+ #if swift(>=5.8)
1374
+ @_documentation(visibility: private)
1375
+ #endif
1376
+ public func FfiConverterTypeFfiViewerCompileResult_lift(_ buf: RustBuffer) throws -> FfiViewerCompileResult {
1377
+ return try FfiConverterTypeFfiViewerCompileResult.lift(buf)
1378
+ }
1379
+
1380
+ #if swift(>=5.8)
1381
+ @_documentation(visibility: private)
1382
+ #endif
1383
+ public func FfiConverterTypeFfiViewerCompileResult_lower(_ value: FfiViewerCompileResult) -> RustBuffer {
1384
+ return FfiConverterTypeFfiViewerCompileResult.lower(value)
1385
+ }
1386
+
1387
+
1388
+ public struct FfiViewerMark {
1389
+ public var markType: String
1390
+ public var attrsJson: String
1391
+
1392
+ // Default memberwise initializers are never public by default, so we
1393
+ // declare one manually.
1394
+ public init(markType: String, attrsJson: String) {
1395
+ self.markType = markType
1396
+ self.attrsJson = attrsJson
1397
+ }
1398
+ }
1399
+
1400
+ #if compiler(>=6)
1401
+ extension FfiViewerMark: Sendable {}
1402
+ #endif
1403
+
1404
+
1405
+ extension FfiViewerMark: Equatable, Hashable {
1406
+ public static func ==(lhs: FfiViewerMark, rhs: FfiViewerMark) -> Bool {
1407
+ if lhs.markType != rhs.markType {
1408
+ return false
1409
+ }
1410
+ if lhs.attrsJson != rhs.attrsJson {
1411
+ return false
1412
+ }
1413
+ return true
1414
+ }
1415
+
1416
+ public func hash(into hasher: inout Hasher) {
1417
+ hasher.combine(markType)
1418
+ hasher.combine(attrsJson)
1419
+ }
1420
+ }
1421
+
1422
+
1423
+
1424
+ #if swift(>=5.8)
1425
+ @_documentation(visibility: private)
1426
+ #endif
1427
+ public struct FfiConverterTypeFfiViewerMark: FfiConverterRustBuffer {
1428
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiViewerMark {
1429
+ return
1430
+ try FfiViewerMark(
1431
+ markType: FfiConverterString.read(from: &buf),
1432
+ attrsJson: FfiConverterString.read(from: &buf)
1433
+ )
1434
+ }
1435
+
1436
+ public static func write(_ value: FfiViewerMark, into buf: inout [UInt8]) {
1437
+ FfiConverterString.write(value.markType, into: &buf)
1438
+ FfiConverterString.write(value.attrsJson, into: &buf)
1439
+ }
1440
+ }
1441
+
1442
+
1443
+ #if swift(>=5.8)
1444
+ @_documentation(visibility: private)
1445
+ #endif
1446
+ public func FfiConverterTypeFfiViewerMark_lift(_ buf: RustBuffer) throws -> FfiViewerMark {
1447
+ return try FfiConverterTypeFfiViewerMark.lift(buf)
1448
+ }
1449
+
1450
+ #if swift(>=5.8)
1451
+ @_documentation(visibility: private)
1452
+ #endif
1453
+ public func FfiConverterTypeFfiViewerMark_lower(_ value: FfiViewerMark) -> RustBuffer {
1454
+ return FfiConverterTypeFfiViewerMark.lower(value)
1455
+ }
1456
+
1457
+ // Note that we don't yet support `indirect` for enums.
1458
+ // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
1459
+
1460
+ public enum FfiViewerElement {
1461
+
1462
+ case textRun(text: String, marks: [FfiViewerMark]
1463
+ )
1464
+ case inlineAtom(nodeType: String, docPos: UInt32, attrsJson: String, label: String
1465
+ )
1466
+ case blockAtom(nodeType: String, docPos: UInt32, attrsJson: String, label: String
1467
+ )
1468
+ case blockStart(nodeType: String, language: String?, depth: UInt16, listContextJson: String?
1469
+ )
1470
+ case blockEnd
1471
+ }
1472
+
1473
+
1474
+ #if compiler(>=6)
1475
+ extension FfiViewerElement: Sendable {}
1476
+ #endif
1477
+
1478
+ #if swift(>=5.8)
1479
+ @_documentation(visibility: private)
1480
+ #endif
1481
+ public struct FfiConverterTypeFfiViewerElement: FfiConverterRustBuffer {
1482
+ typealias SwiftType = FfiViewerElement
1483
+
1484
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiViewerElement {
1485
+ let variant: Int32 = try readInt(&buf)
1486
+ switch variant {
1487
+
1488
+ case 1: return .textRun(text: try FfiConverterString.read(from: &buf), marks: try FfiConverterSequenceTypeFfiViewerMark.read(from: &buf)
1489
+ )
1490
+
1491
+ case 2: return .inlineAtom(nodeType: try FfiConverterString.read(from: &buf), docPos: try FfiConverterUInt32.read(from: &buf), attrsJson: try FfiConverterString.read(from: &buf), label: try FfiConverterString.read(from: &buf)
1492
+ )
1493
+
1494
+ case 3: return .blockAtom(nodeType: try FfiConverterString.read(from: &buf), docPos: try FfiConverterUInt32.read(from: &buf), attrsJson: try FfiConverterString.read(from: &buf), label: try FfiConverterString.read(from: &buf)
1495
+ )
1496
+
1497
+ case 4: return .blockStart(nodeType: try FfiConverterString.read(from: &buf), language: try FfiConverterOptionString.read(from: &buf), depth: try FfiConverterUInt16.read(from: &buf), listContextJson: try FfiConverterOptionString.read(from: &buf)
1498
+ )
1499
+
1500
+ case 5: return .blockEnd
1501
+
1502
+ default: throw UniffiInternalError.unexpectedEnumCase
1503
+ }
1504
+ }
1505
+
1506
+ public static func write(_ value: FfiViewerElement, into buf: inout [UInt8]) {
1507
+ switch value {
1508
+
1509
+
1510
+ case let .textRun(text,marks):
1511
+ writeInt(&buf, Int32(1))
1512
+ FfiConverterString.write(text, into: &buf)
1513
+ FfiConverterSequenceTypeFfiViewerMark.write(marks, into: &buf)
1514
+
1515
+
1516
+ case let .inlineAtom(nodeType,docPos,attrsJson,label):
1517
+ writeInt(&buf, Int32(2))
1518
+ FfiConverterString.write(nodeType, into: &buf)
1519
+ FfiConverterUInt32.write(docPos, into: &buf)
1520
+ FfiConverterString.write(attrsJson, into: &buf)
1521
+ FfiConverterString.write(label, into: &buf)
1522
+
1523
+
1524
+ case let .blockAtom(nodeType,docPos,attrsJson,label):
1525
+ writeInt(&buf, Int32(3))
1526
+ FfiConverterString.write(nodeType, into: &buf)
1527
+ FfiConverterUInt32.write(docPos, into: &buf)
1528
+ FfiConverterString.write(attrsJson, into: &buf)
1529
+ FfiConverterString.write(label, into: &buf)
1530
+
1531
+
1532
+ case let .blockStart(nodeType,language,depth,listContextJson):
1533
+ writeInt(&buf, Int32(4))
1534
+ FfiConverterString.write(nodeType, into: &buf)
1535
+ FfiConverterOptionString.write(language, into: &buf)
1536
+ FfiConverterUInt16.write(depth, into: &buf)
1537
+ FfiConverterOptionString.write(listContextJson, into: &buf)
1538
+
1539
+
1540
+ case .blockEnd:
1541
+ writeInt(&buf, Int32(5))
1542
+
1543
+ }
1544
+ }
1545
+ }
1546
+
1547
+
1548
+ #if swift(>=5.8)
1549
+ @_documentation(visibility: private)
1550
+ #endif
1551
+ public func FfiConverterTypeFfiViewerElement_lift(_ buf: RustBuffer) throws -> FfiViewerElement {
1552
+ return try FfiConverterTypeFfiViewerElement.lift(buf)
1553
+ }
1554
+
1555
+ #if swift(>=5.8)
1556
+ @_documentation(visibility: private)
1557
+ #endif
1558
+ public func FfiConverterTypeFfiViewerElement_lower(_ value: FfiViewerElement) -> RustBuffer {
1559
+ return FfiConverterTypeFfiViewerElement.lower(value)
1560
+ }
1561
+
1562
+
1563
+ extension FfiViewerElement: Equatable, Hashable {}
1564
+
1565
+
1566
+
1567
+
1568
+
1569
+
1570
+ // Note that we don't yet support `indirect` for enums.
1571
+ // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
1572
+
1573
+ public enum FfiViewerSourceKind {
1574
+
1575
+ case json
1576
+ case html
1577
+ }
1578
+
1579
+
1580
+ #if compiler(>=6)
1581
+ extension FfiViewerSourceKind: Sendable {}
1582
+ #endif
1583
+
1584
+ #if swift(>=5.8)
1585
+ @_documentation(visibility: private)
1586
+ #endif
1587
+ public struct FfiConverterTypeFfiViewerSourceKind: FfiConverterRustBuffer {
1588
+ typealias SwiftType = FfiViewerSourceKind
1589
+
1590
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiViewerSourceKind {
1591
+ let variant: Int32 = try readInt(&buf)
1592
+ switch variant {
1593
+
1594
+ case 1: return .json
1595
+
1596
+ case 2: return .html
1597
+
1598
+ default: throw UniffiInternalError.unexpectedEnumCase
1599
+ }
1600
+ }
1601
+
1602
+ public static func write(_ value: FfiViewerSourceKind, into buf: inout [UInt8]) {
1603
+ switch value {
1604
+
1605
+
1606
+ case .json:
1607
+ writeInt(&buf, Int32(1))
1608
+
1609
+
1610
+ case .html:
1611
+ writeInt(&buf, Int32(2))
1612
+
1613
+ }
1614
+ }
1615
+ }
1616
+
1617
+
1618
+ #if swift(>=5.8)
1619
+ @_documentation(visibility: private)
1620
+ #endif
1621
+ public func FfiConverterTypeFfiViewerSourceKind_lift(_ buf: RustBuffer) throws -> FfiViewerSourceKind {
1622
+ return try FfiConverterTypeFfiViewerSourceKind.lift(buf)
1623
+ }
1624
+
1625
+ #if swift(>=5.8)
1626
+ @_documentation(visibility: private)
1627
+ #endif
1628
+ public func FfiConverterTypeFfiViewerSourceKind_lower(_ value: FfiViewerSourceKind) -> RustBuffer {
1629
+ return FfiConverterTypeFfiViewerSourceKind.lower(value)
1630
+ }
1631
+
1632
+
1633
+ extension FfiViewerSourceKind: Equatable, Hashable {}
1634
+
1635
+
1636
+
1637
+
1638
+
1639
+
1640
+ #if swift(>=5.8)
1641
+ @_documentation(visibility: private)
1642
+ #endif
1643
+ fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer {
1644
+ typealias SwiftType = UInt32?
1645
+
1646
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1647
+ guard let value = value else {
1648
+ writeInt(&buf, Int8(0))
1649
+ return
1650
+ }
1651
+ writeInt(&buf, Int8(1))
1652
+ FfiConverterUInt32.write(value, into: &buf)
1653
+ }
1654
+
1655
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1656
+ switch try readInt(&buf) as Int8 {
1657
+ case 0: return nil
1658
+ case 1: return try FfiConverterUInt32.read(from: &buf)
1659
+ default: throw UniffiInternalError.unexpectedOptionalTag
1660
+ }
1661
+ }
1662
+ }
1663
+
1664
+ #if swift(>=5.8)
1665
+ @_documentation(visibility: private)
1666
+ #endif
1667
+ fileprivate struct FfiConverterOptionBool: FfiConverterRustBuffer {
1668
+ typealias SwiftType = Bool?
1669
+
1670
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1671
+ guard let value = value else {
1672
+ writeInt(&buf, Int8(0))
1673
+ return
1674
+ }
1675
+ writeInt(&buf, Int8(1))
1676
+ FfiConverterBool.write(value, into: &buf)
1677
+ }
1678
+
1679
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1680
+ switch try readInt(&buf) as Int8 {
1681
+ case 0: return nil
1682
+ case 1: return try FfiConverterBool.read(from: &buf)
1683
+ default: throw UniffiInternalError.unexpectedOptionalTag
1684
+ }
1685
+ }
1686
+ }
1687
+
1688
+ #if swift(>=5.8)
1689
+ @_documentation(visibility: private)
1690
+ #endif
1691
+ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
1692
+ typealias SwiftType = String?
1693
+
1694
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1695
+ guard let value = value else {
1696
+ writeInt(&buf, Int8(0))
1697
+ return
1698
+ }
1699
+ writeInt(&buf, Int8(1))
1700
+ FfiConverterString.write(value, into: &buf)
1701
+ }
1702
+
1703
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1704
+ switch try readInt(&buf) as Int8 {
1705
+ case 0: return nil
1706
+ case 1: return try FfiConverterString.read(from: &buf)
1707
+ default: throw UniffiInternalError.unexpectedOptionalTag
1708
+ }
1709
+ }
1710
+ }
1711
+
1712
+ #if swift(>=5.8)
1713
+ @_documentation(visibility: private)
1714
+ #endif
1715
+ fileprivate struct FfiConverterOptionData: FfiConverterRustBuffer {
1716
+ typealias SwiftType = Data?
1717
+
1718
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1719
+ guard let value = value else {
1720
+ writeInt(&buf, Int8(0))
1721
+ return
1722
+ }
1723
+ writeInt(&buf, Int8(1))
1724
+ FfiConverterData.write(value, into: &buf)
1725
+ }
1726
+
1727
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1728
+ switch try readInt(&buf) as Int8 {
1729
+ case 0: return nil
1730
+ case 1: return try FfiConverterData.read(from: &buf)
1731
+ default: throw UniffiInternalError.unexpectedOptionalTag
1732
+ }
1733
+ }
1734
+ }
1735
+
1736
+ #if swift(>=5.8)
1737
+ @_documentation(visibility: private)
1738
+ #endif
1739
+ fileprivate struct FfiConverterOptionTypeViewerCompiledDocument: FfiConverterRustBuffer {
1740
+ typealias SwiftType = ViewerCompiledDocument?
1741
+
1742
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1743
+ guard let value = value else {
1744
+ writeInt(&buf, Int8(0))
1745
+ return
1746
+ }
1747
+ writeInt(&buf, Int8(1))
1748
+ FfiConverterTypeViewerCompiledDocument.write(value, into: &buf)
1749
+ }
1750
+
1751
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1752
+ switch try readInt(&buf) as Int8 {
1753
+ case 0: return nil
1754
+ case 1: return try FfiConverterTypeViewerCompiledDocument.read(from: &buf)
1755
+ default: throw UniffiInternalError.unexpectedOptionalTag
1756
+ }
1757
+ }
1758
+ }
1759
+
1760
+ #if swift(>=5.8)
1761
+ @_documentation(visibility: private)
1762
+ #endif
1763
+ fileprivate struct FfiConverterOptionTypeFfiError: FfiConverterRustBuffer {
1764
+ typealias SwiftType = FfiError?
1765
+
1766
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1767
+ guard let value = value else {
1768
+ writeInt(&buf, Int8(0))
1769
+ return
1770
+ }
1771
+ writeInt(&buf, Int8(1))
1772
+ FfiConverterTypeFfiError.write(value, into: &buf)
1773
+ }
1774
+
1775
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1776
+ switch try readInt(&buf) as Int8 {
1777
+ case 0: return nil
1778
+ case 1: return try FfiConverterTypeFfiError.read(from: &buf)
1779
+ default: throw UniffiInternalError.unexpectedOptionalTag
1780
+ }
1781
+ }
1782
+ }
1783
+
1784
+ #if swift(>=5.8)
1785
+ @_documentation(visibility: private)
1786
+ #endif
1787
+ fileprivate struct FfiConverterOptionTypeFfiOutboundLease: FfiConverterRustBuffer {
1788
+ typealias SwiftType = FfiOutboundLease?
1789
+
1790
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1791
+ guard let value = value else {
1792
+ writeInt(&buf, Int8(0))
1793
+ return
1794
+ }
1795
+ writeInt(&buf, Int8(1))
1796
+ FfiConverterTypeFfiOutboundLease.write(value, into: &buf)
1797
+ }
1798
+
1799
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1800
+ switch try readInt(&buf) as Int8 {
1801
+ case 0: return nil
1802
+ case 1: return try FfiConverterTypeFfiOutboundLease.read(from: &buf)
1803
+ default: throw UniffiInternalError.unexpectedOptionalTag
1804
+ }
1805
+ }
1806
+ }
1807
+
1808
+ #if swift(>=5.8)
1809
+ @_documentation(visibility: private)
1810
+ #endif
1811
+ fileprivate struct FfiConverterOptionTypeFfiSnapshotExport: FfiConverterRustBuffer {
1812
+ typealias SwiftType = FfiSnapshotExport?
1813
+
1814
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1815
+ guard let value = value else {
1816
+ writeInt(&buf, Int8(0))
1817
+ return
1818
+ }
1819
+ writeInt(&buf, Int8(1))
1820
+ FfiConverterTypeFfiSnapshotExport.write(value, into: &buf)
1821
+ }
1822
+
1823
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1824
+ switch try readInt(&buf) as Int8 {
1825
+ case 0: return nil
1826
+ case 1: return try FfiConverterTypeFfiSnapshotExport.read(from: &buf)
1827
+ default: throw UniffiInternalError.unexpectedOptionalTag
1828
+ }
1829
+ }
1830
+ }
1831
+
1832
+ #if swift(>=5.8)
1833
+ @_documentation(visibility: private)
1834
+ #endif
1835
+ fileprivate struct FfiConverterSequenceTypeFfiViewerMark: FfiConverterRustBuffer {
1836
+ typealias SwiftType = [FfiViewerMark]
1837
+
1838
+ public static func write(_ value: [FfiViewerMark], into buf: inout [UInt8]) {
1839
+ let len = Int32(value.count)
1840
+ writeInt(&buf, len)
1841
+ for item in value {
1842
+ FfiConverterTypeFfiViewerMark.write(item, into: &buf)
1843
+ }
1844
+ }
1845
+
1846
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FfiViewerMark] {
1847
+ let len: Int32 = try readInt(&buf)
1848
+ var seq = [FfiViewerMark]()
1849
+ seq.reserveCapacity(Int(len))
1850
+ for _ in 0 ..< len {
1851
+ seq.append(try FfiConverterTypeFfiViewerMark.read(from: &buf))
1852
+ }
1853
+ return seq
1854
+ }
1855
+ }
1856
+
1857
+ #if swift(>=5.8)
1858
+ @_documentation(visibility: private)
1859
+ #endif
1860
+ fileprivate struct FfiConverterSequenceTypeFfiViewerElement: FfiConverterRustBuffer {
1861
+ typealias SwiftType = [FfiViewerElement]
1862
+
1863
+ public static func write(_ value: [FfiViewerElement], into buf: inout [UInt8]) {
1864
+ let len = Int32(value.count)
1865
+ writeInt(&buf, len)
1866
+ for item in value {
1867
+ FfiConverterTypeFfiViewerElement.write(item, into: &buf)
1868
+ }
1869
+ }
1870
+
1871
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FfiViewerElement] {
1872
+ let len: Int32 = try readInt(&buf)
1873
+ var seq = [FfiViewerElement]()
1874
+ seq.reserveCapacity(Int(len))
1875
+ for _ in 0 ..< len {
1876
+ seq.append(try FfiConverterTypeFfiViewerElement.read(from: &buf))
1877
+ }
1878
+ return seq
1879
+ }
1880
+ }
1881
+ /**
1882
+ * Return the crate version string.
1883
+ */
1884
+ public func editorCoreVersion() -> String {
1885
+ return try! FfiConverterString.lift(try! rustCall() {
1886
+ uniffi_editor_core_fn_func_editor_core_version($0
1887
+ )
1888
+ })
1889
+ }
1890
+ public func editorV2ApplyCommand(editorId: String, requestJson: String) -> FfiJsonResult {
1891
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
1892
+ uniffi_editor_core_fn_func_editor_v2_apply_command(
1893
+ FfiConverterString.lower(editorId),
1894
+ FfiConverterString.lower(requestJson),$0
1895
+ )
1896
+ })
1897
+ }
1898
+ public func editorV2ApplyInput(editorId: String, requestJson: String) -> FfiJsonResult {
1899
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
1900
+ uniffi_editor_core_fn_func_editor_v2_apply_input(
1901
+ FfiConverterString.lower(editorId),
1902
+ FfiConverterString.lower(requestJson),$0
1903
+ )
1904
+ })
1905
+ }
1906
+ public func editorV2ApplyLocalApi(editorId: String, requestJson: String) -> FfiJsonResult {
1907
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
1908
+ uniffi_editor_core_fn_func_editor_v2_apply_local_api(
1909
+ FfiConverterString.lower(editorId),
1910
+ FfiConverterString.lower(requestJson),$0
1911
+ )
1912
+ })
1913
+ }
1914
+ public func editorV2ApplyNativeIntent(editorId: String, requestJson: String) -> FfiJsonResult {
1915
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
1916
+ uniffi_editor_core_fn_func_editor_v2_apply_native_intent(
1917
+ FfiConverterString.lower(editorId),
1918
+ FfiConverterString.lower(requestJson),$0
1919
+ )
1920
+ })
1921
+ }
1922
+ public func editorV2CollaborationAckOutbound(editorId: String, generation: String, leaseId: String) -> FfiJsonResult {
1923
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
1924
+ uniffi_editor_core_fn_func_editor_v2_collaboration_ack_outbound(
1925
+ FfiConverterString.lower(editorId),
1926
+ FfiConverterString.lower(generation),
1927
+ FfiConverterString.lower(leaseId),$0
1928
+ )
1929
+ })
1930
+ }
1931
+ /**
1932
+ * Tears down transport state while retaining the editor, document, desired
1933
+ * awareness state, and pending outbox entries.
1934
+ */
1935
+ public func editorV2CollaborationDetach(editorId: String) -> FfiUnitResult {
1936
+ return try! FfiConverterTypeFfiUnitResult_lift(try! rustCall() {
1937
+ uniffi_editor_core_fn_func_editor_v2_collaboration_detach(
1938
+ FfiConverterString.lower(editorId),$0
1939
+ )
1940
+ })
1941
+ }
1942
+ /**
1943
+ * Drive initial connection, reconnect eligibility, local-awareness renewal,
1944
+ * and remote-peer expiry from one Rust-owned monotonic clock operation.
1945
+ */
1946
+ public func editorV2CollaborationDrive(editorId: String, nowMillis: String) -> FfiJsonResult {
1947
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
1948
+ uniffi_editor_core_fn_func_editor_v2_collaboration_drive(
1949
+ FfiConverterString.lower(editorId),
1950
+ FfiConverterString.lower(nowMillis),$0
1951
+ )
1952
+ })
1953
+ }
1954
+ /**
1955
+ * Lease one retained complete outbound frame. Exactly one of value, empty,
1956
+ * or error is selected; protocol replies retain priority over document
1957
+ * updates unless a frame was already leased.
1958
+ */
1959
+ public func editorV2CollaborationLeaseOutbound(editorId: String, generation: String) -> FfiOutboundLeaseResult {
1960
+ return try! FfiConverterTypeFfiOutboundLeaseResult_lift(try! rustCall() {
1961
+ uniffi_editor_core_fn_func_editor_v2_collaboration_lease_outbound(
1962
+ FfiConverterString.lower(editorId),
1963
+ FfiConverterString.lower(generation),$0
1964
+ )
1965
+ })
1966
+ }
1967
+ public func editorV2CollaborationNackOutbound(editorId: String, generation: String, leaseId: String) -> FfiJsonResult {
1968
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
1969
+ uniffi_editor_core_fn_func_editor_v2_collaboration_nack_outbound(
1970
+ FfiConverterString.lower(editorId),
1971
+ FfiConverterString.lower(generation),
1972
+ FfiConverterString.lower(leaseId),$0
1973
+ )
1974
+ })
1975
+ }
1976
+ /**
1977
+ * Live awareness peer projections; client ids are decimal strings so full
1978
+ * u64 ids survive the JSON round-trip.
1979
+ */
1980
+ public func editorV2CollaborationPeers(editorId: String) -> FfiJsonResult {
1981
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
1982
+ uniffi_editor_core_fn_func_editor_v2_collaboration_peers(
1983
+ FfiConverterString.lower(editorId),$0
1984
+ )
1985
+ })
1986
+ }
1987
+ /**
1988
+ * Reopens the transport lifecycle after an explicit detach.
1989
+ */
1990
+ public func editorV2CollaborationReattach(editorId: String) -> FfiUnitResult {
1991
+ return try! FfiConverterTypeFfiUnitResult_lift(try! rustCall() {
1992
+ uniffi_editor_core_fn_func_editor_v2_collaboration_reattach(
1993
+ FfiConverterString.lower(editorId),$0
1994
+ )
1995
+ })
1996
+ }
1997
+ public func editorV2CollaborationReceive(editorId: String, generation: String, message: Data, nowMillis: String) -> FfiJsonResult {
1998
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
1999
+ uniffi_editor_core_fn_func_editor_v2_collaboration_receive(
2000
+ FfiConverterString.lower(editorId),
2001
+ FfiConverterString.lower(generation),
2002
+ FfiConverterData.lower(message),
2003
+ FfiConverterString.lower(nowMillis),$0
2004
+ )
2005
+ })
2006
+ }
2007
+ /**
2008
+ * Publishes a typed local awareness intent; the literal JSON `null`
2009
+ * withdraws it (standard tombstone broadcast). Rust validates the closed
2010
+ * shape and owns any published sticky cursor representation.
2011
+ */
2012
+ public func editorV2CollaborationSetAwareness(editorId: String, awarenessJson: String) -> FfiUnitResult {
2013
+ return try! FfiConverterTypeFfiUnitResult_lift(try! rustCall() {
2014
+ uniffi_editor_core_fn_func_editor_v2_collaboration_set_awareness(
2015
+ FfiConverterString.lower(editorId),
2016
+ FfiConverterString.lower(awarenessJson),$0
2017
+ )
2018
+ })
2019
+ }
2020
+ public func editorV2CollaborationSetAwarenessSelection(editorId: String, selectionJson: String) -> FfiJsonResult {
2021
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2022
+ uniffi_editor_core_fn_func_editor_v2_collaboration_set_awareness_selection(
2023
+ FfiConverterString.lower(editorId),
2024
+ FfiConverterString.lower(selectionJson),$0
2025
+ )
2026
+ })
2027
+ }
2028
+ /**
2029
+ * `reason` carries no classification weight (Rust alone owns retry
2030
+ * eligibility); a policy-violation close code (1008) parks the transport
2031
+ * `Incompatible`, every other reported close is retryable.
2032
+ */
2033
+ public func editorV2CollaborationSocketClose(editorId: String, generation: String, code: UInt32?, reason: String?, nowMillis: String) -> FfiJsonResult {
2034
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2035
+ uniffi_editor_core_fn_func_editor_v2_collaboration_socket_close(
2036
+ FfiConverterString.lower(editorId),
2037
+ FfiConverterString.lower(generation),
2038
+ FfiConverterOptionUInt32.lower(code),
2039
+ FfiConverterOptionString.lower(reason),
2040
+ FfiConverterString.lower(nowMillis),$0
2041
+ )
2042
+ })
2043
+ }
2044
+ /**
2045
+ * Socket open queues framed Sync Step 1 at protocol priority and returns
2046
+ * only the frozen directive; bytes are retrieved through `lease_outbound`.
2047
+ */
2048
+ public func editorV2CollaborationSocketOpen(editorId: String, generation: String, nowMillis: String) -> FfiJsonResult {
2049
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2050
+ uniffi_editor_core_fn_func_editor_v2_collaboration_socket_open(
2051
+ FfiConverterString.lower(editorId),
2052
+ FfiConverterString.lower(generation),
2053
+ FfiConverterString.lower(nowMillis),$0
2054
+ )
2055
+ })
2056
+ }
2057
+ public func editorV2Create(configJson: String, snapshotState: Data?) -> FfiJsonResult {
2058
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2059
+ uniffi_editor_core_fn_func_editor_v2_create(
2060
+ FfiConverterString.lower(configJson),
2061
+ FfiConverterOptionData.lower(snapshotState),$0
2062
+ )
2063
+ })
2064
+ }
2065
+ public func editorV2Destroy(editorId: String) -> FfiUnitResult {
2066
+ return try! FfiConverterTypeFfiUnitResult_lift(try! rustCall() {
2067
+ uniffi_editor_core_fn_func_editor_v2_destroy(
2068
+ FfiConverterString.lower(editorId),$0
2069
+ )
2070
+ })
2071
+ }
2072
+ public func editorV2DocToScalar(editorId: String, docPos: UInt32) -> FfiJsonResult {
2073
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2074
+ uniffi_editor_core_fn_func_editor_v2_doc_to_scalar(
2075
+ FfiConverterString.lower(editorId),
2076
+ FfiConverterUInt32.lower(docPos),$0
2077
+ )
2078
+ })
2079
+ }
2080
+ public func editorV2GetContentSnapshot(editorId: String) -> FfiJsonResult {
2081
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2082
+ uniffi_editor_core_fn_func_editor_v2_get_content_snapshot(
2083
+ FfiConverterString.lower(editorId),$0
2084
+ )
2085
+ })
2086
+ }
2087
+ public func editorV2GetDocumentHtml(editorId: String) -> FfiJsonResult {
2088
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2089
+ uniffi_editor_core_fn_func_editor_v2_get_document_html(
2090
+ FfiConverterString.lower(editorId),$0
2091
+ )
2092
+ })
2093
+ }
2094
+ public func editorV2GetDocumentJson(editorId: String) -> FfiJsonResult {
2095
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2096
+ uniffi_editor_core_fn_func_editor_v2_get_document_json(
2097
+ FfiConverterString.lower(editorId),$0
2098
+ )
2099
+ })
2100
+ }
2101
+ public func editorV2GetState(editorId: String) -> FfiJsonResult {
2102
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2103
+ uniffi_editor_core_fn_func_editor_v2_get_state(
2104
+ FfiConverterString.lower(editorId),$0
2105
+ )
2106
+ })
2107
+ }
2108
+ public func editorV2PinPositionEpoch(editorId: String, ownerId: String, documentRevision: String) -> FfiJsonResult {
2109
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2110
+ uniffi_editor_core_fn_func_editor_v2_pin_position_epoch(
2111
+ FfiConverterString.lower(editorId),
2112
+ FfiConverterString.lower(ownerId),
2113
+ FfiConverterString.lower(documentRevision),$0
2114
+ )
2115
+ })
2116
+ }
2117
+ public func editorV2Redo(editorId: String, requestJson: String) -> FfiJsonResult {
2118
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2119
+ uniffi_editor_core_fn_func_editor_v2_redo(
2120
+ FfiConverterString.lower(editorId),
2121
+ FfiConverterString.lower(requestJson),$0
2122
+ )
2123
+ })
2124
+ }
2125
+ public func editorV2ReleaseNativeBinding(editorId: String, ownerId: String) -> FfiUnitResult {
2126
+ return try! FfiConverterTypeFfiUnitResult_lift(try! rustCall() {
2127
+ uniffi_editor_core_fn_func_editor_v2_release_native_binding(
2128
+ FfiConverterString.lower(editorId),
2129
+ FfiConverterString.lower(ownerId),$0
2130
+ )
2131
+ })
2132
+ }
2133
+ public func editorV2RenderNative(editorId: String, ownerId: String, mirrorScalarAnchor: UInt32?, mirrorScalarHead: UInt32?) -> FfiJsonResult {
2134
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2135
+ uniffi_editor_core_fn_func_editor_v2_render_native(
2136
+ FfiConverterString.lower(editorId),
2137
+ FfiConverterString.lower(ownerId),
2138
+ FfiConverterOptionUInt32.lower(mirrorScalarAnchor),
2139
+ FfiConverterOptionUInt32.lower(mirrorScalarHead),$0
2140
+ )
2141
+ })
2142
+ }
2143
+ public func editorV2RenderUpdate(editorId: String, mirrorScalarAnchor: UInt32?, mirrorScalarHead: UInt32?) -> FfiJsonResult {
2144
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2145
+ uniffi_editor_core_fn_func_editor_v2_render_update(
2146
+ FfiConverterString.lower(editorId),
2147
+ FfiConverterOptionUInt32.lower(mirrorScalarAnchor),
2148
+ FfiConverterOptionUInt32.lower(mirrorScalarHead),$0
2149
+ )
2150
+ })
2151
+ }
2152
+ public func editorV2ReplaceDocument(editorId: String, requestJson: String) -> FfiJsonResult {
2153
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2154
+ uniffi_editor_core_fn_func_editor_v2_replace_document(
2155
+ FfiConverterString.lower(editorId),
2156
+ FfiConverterString.lower(requestJson),$0
2157
+ )
2158
+ })
2159
+ }
2160
+ public func editorV2ResolveScalarSelection(editorId: String, scalarAnchor: UInt32, scalarHead: UInt32) -> FfiJsonResult {
2161
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2162
+ uniffi_editor_core_fn_func_editor_v2_resolve_scalar_selection(
2163
+ FfiConverterString.lower(editorId),
2164
+ FfiConverterUInt32.lower(scalarAnchor),
2165
+ FfiConverterUInt32.lower(scalarHead),$0
2166
+ )
2167
+ })
2168
+ }
2169
+ public func editorV2ScalarToDoc(editorId: String, scalar: UInt32) -> FfiJsonResult {
2170
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2171
+ uniffi_editor_core_fn_func_editor_v2_scalar_to_doc(
2172
+ FfiConverterString.lower(editorId),
2173
+ FfiConverterUInt32.lower(scalar),$0
2174
+ )
2175
+ })
2176
+ }
2177
+ public func editorV2SetSelection(editorId: String, requestJson: String) -> FfiJsonResult {
2178
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2179
+ uniffi_editor_core_fn_func_editor_v2_set_selection(
2180
+ FfiConverterString.lower(editorId),
2181
+ FfiConverterString.lower(requestJson),$0
2182
+ )
2183
+ })
2184
+ }
2185
+ public func editorV2SnapshotExport(editorId: String) -> FfiSnapshotExportResult {
2186
+ return try! FfiConverterTypeFfiSnapshotExportResult_lift(try! rustCall() {
2187
+ uniffi_editor_core_fn_func_editor_v2_snapshot_export(
2188
+ FfiConverterString.lower(editorId),$0
2189
+ )
2190
+ })
2191
+ }
2192
+ public func editorV2SnapshotRestore(editorId: String, metadataJson: String, encodedState: Data) -> FfiJsonResult {
2193
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2194
+ uniffi_editor_core_fn_func_editor_v2_snapshot_restore(
2195
+ FfiConverterString.lower(editorId),
2196
+ FfiConverterString.lower(metadataJson),
2197
+ FfiConverterData.lower(encodedState),$0
2198
+ )
2199
+ })
2200
+ }
2201
+ public func editorV2Undo(editorId: String, requestJson: String) -> FfiJsonResult {
2202
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2203
+ uniffi_editor_core_fn_func_editor_v2_undo(
2204
+ FfiConverterString.lower(editorId),
2205
+ FfiConverterString.lower(requestJson),$0
2206
+ )
2207
+ })
2208
+ }
2209
+ public func viewerCompile(request: FfiViewerCompileRequest) -> FfiViewerCompileResult {
2210
+ return try! FfiConverterTypeFfiViewerCompileResult_lift(try! rustCall() {
2211
+ uniffi_editor_core_fn_func_viewer_compile(
2212
+ FfiConverterTypeFfiViewerCompileRequest_lower(request),$0
2213
+ )
2214
+ })
2215
+ }
2216
+
2217
+ private enum InitializationResult {
2218
+ case ok
2219
+ case contractVersionMismatch
2220
+ case apiChecksumMismatch
2221
+ }
2222
+ // Use a global variable to perform the versioning checks. Swift ensures that
2223
+ // the code inside is only computed once.
2224
+ private let initializationResult: InitializationResult = {
2225
+ // Get the bindings contract version from our ComponentInterface
2226
+ let bindings_contract_version = 29
2227
+ // Get the scaffolding contract version by calling the into the dylib
2228
+ let scaffolding_contract_version = ffi_editor_core_uniffi_contract_version()
2229
+ if bindings_contract_version != scaffolding_contract_version {
2230
+ return InitializationResult.contractVersionMismatch
2231
+ }
2232
+ if (uniffi_editor_core_checksum_func_editor_core_version() != 41638) {
2233
+ return InitializationResult.apiChecksumMismatch
2234
+ }
2235
+ if (uniffi_editor_core_checksum_func_editor_v2_apply_command() != 14484) {
2236
+ return InitializationResult.apiChecksumMismatch
2237
+ }
2238
+ if (uniffi_editor_core_checksum_func_editor_v2_apply_input() != 29912) {
2239
+ return InitializationResult.apiChecksumMismatch
2240
+ }
2241
+ if (uniffi_editor_core_checksum_func_editor_v2_apply_local_api() != 36451) {
2242
+ return InitializationResult.apiChecksumMismatch
2243
+ }
2244
+ if (uniffi_editor_core_checksum_func_editor_v2_apply_native_intent() != 46364) {
2245
+ return InitializationResult.apiChecksumMismatch
2246
+ }
2247
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_ack_outbound() != 21755) {
2248
+ return InitializationResult.apiChecksumMismatch
2249
+ }
2250
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_detach() != 25325) {
2251
+ return InitializationResult.apiChecksumMismatch
2252
+ }
2253
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_drive() != 55434) {
2254
+ return InitializationResult.apiChecksumMismatch
2255
+ }
2256
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_lease_outbound() != 56190) {
2257
+ return InitializationResult.apiChecksumMismatch
2258
+ }
2259
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_nack_outbound() != 29045) {
2260
+ return InitializationResult.apiChecksumMismatch
2261
+ }
2262
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_peers() != 754) {
2263
+ return InitializationResult.apiChecksumMismatch
2264
+ }
2265
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_reattach() != 44291) {
2266
+ return InitializationResult.apiChecksumMismatch
2267
+ }
2268
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_receive() != 19926) {
2269
+ return InitializationResult.apiChecksumMismatch
2270
+ }
2271
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_set_awareness() != 59502) {
2272
+ return InitializationResult.apiChecksumMismatch
2273
+ }
2274
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_set_awareness_selection() != 3071) {
2275
+ return InitializationResult.apiChecksumMismatch
2276
+ }
2277
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_socket_close() != 53946) {
2278
+ return InitializationResult.apiChecksumMismatch
2279
+ }
2280
+ if (uniffi_editor_core_checksum_func_editor_v2_collaboration_socket_open() != 25835) {
2281
+ return InitializationResult.apiChecksumMismatch
2282
+ }
2283
+ if (uniffi_editor_core_checksum_func_editor_v2_create() != 9333) {
2284
+ return InitializationResult.apiChecksumMismatch
2285
+ }
2286
+ if (uniffi_editor_core_checksum_func_editor_v2_destroy() != 8349) {
2287
+ return InitializationResult.apiChecksumMismatch
2288
+ }
2289
+ if (uniffi_editor_core_checksum_func_editor_v2_doc_to_scalar() != 62503) {
2290
+ return InitializationResult.apiChecksumMismatch
2291
+ }
2292
+ if (uniffi_editor_core_checksum_func_editor_v2_get_content_snapshot() != 21323) {
2293
+ return InitializationResult.apiChecksumMismatch
2294
+ }
2295
+ if (uniffi_editor_core_checksum_func_editor_v2_get_document_html() != 60959) {
2296
+ return InitializationResult.apiChecksumMismatch
2297
+ }
2298
+ if (uniffi_editor_core_checksum_func_editor_v2_get_document_json() != 25683) {
2299
+ return InitializationResult.apiChecksumMismatch
2300
+ }
2301
+ if (uniffi_editor_core_checksum_func_editor_v2_get_state() != 43856) {
2302
+ return InitializationResult.apiChecksumMismatch
2303
+ }
2304
+ if (uniffi_editor_core_checksum_func_editor_v2_pin_position_epoch() != 42714) {
2305
+ return InitializationResult.apiChecksumMismatch
2306
+ }
2307
+ if (uniffi_editor_core_checksum_func_editor_v2_redo() != 48065) {
2308
+ return InitializationResult.apiChecksumMismatch
2309
+ }
2310
+ if (uniffi_editor_core_checksum_func_editor_v2_release_native_binding() != 2756) {
2311
+ return InitializationResult.apiChecksumMismatch
2312
+ }
2313
+ if (uniffi_editor_core_checksum_func_editor_v2_render_native() != 16234) {
2314
+ return InitializationResult.apiChecksumMismatch
2315
+ }
2316
+ if (uniffi_editor_core_checksum_func_editor_v2_render_update() != 13282) {
2317
+ return InitializationResult.apiChecksumMismatch
2318
+ }
2319
+ if (uniffi_editor_core_checksum_func_editor_v2_replace_document() != 31032) {
2320
+ return InitializationResult.apiChecksumMismatch
2321
+ }
2322
+ if (uniffi_editor_core_checksum_func_editor_v2_resolve_scalar_selection() != 26332) {
2323
+ return InitializationResult.apiChecksumMismatch
2324
+ }
2325
+ if (uniffi_editor_core_checksum_func_editor_v2_scalar_to_doc() != 60383) {
2326
+ return InitializationResult.apiChecksumMismatch
2327
+ }
2328
+ if (uniffi_editor_core_checksum_func_editor_v2_set_selection() != 39340) {
2329
+ return InitializationResult.apiChecksumMismatch
2330
+ }
2331
+ if (uniffi_editor_core_checksum_func_editor_v2_snapshot_export() != 2193) {
2332
+ return InitializationResult.apiChecksumMismatch
2333
+ }
2334
+ if (uniffi_editor_core_checksum_func_editor_v2_snapshot_restore() != 47504) {
2335
+ return InitializationResult.apiChecksumMismatch
2336
+ }
2337
+ if (uniffi_editor_core_checksum_func_editor_v2_undo() != 2492) {
2338
+ return InitializationResult.apiChecksumMismatch
2339
+ }
2340
+ if (uniffi_editor_core_checksum_func_viewer_compile() != 60070) {
2341
+ return InitializationResult.apiChecksumMismatch
2342
+ }
2343
+ if (uniffi_editor_core_checksum_method_viewercompileddocument_elements() != 50589) {
2344
+ return InitializationResult.apiChecksumMismatch
2345
+ }
2346
+ if (uniffi_editor_core_checksum_method_viewercompileddocument_is_empty() != 2370) {
2347
+ return InitializationResult.apiChecksumMismatch
2348
+ }
2349
+ if (uniffi_editor_core_checksum_method_viewercompileddocument_preferred_text_block_name() != 32137) {
2350
+ return InitializationResult.apiChecksumMismatch
2351
+ }
2352
+ if (uniffi_editor_core_checksum_method_viewercompileddocument_retained_bytes_decimal() != 13333) {
2353
+ return InitializationResult.apiChecksumMismatch
2354
+ }
2355
+ if (uniffi_editor_core_checksum_method_viewercompileddocument_semantic_key() != 2241) {
2356
+ return InitializationResult.apiChecksumMismatch
2357
+ }
2358
+ if (uniffi_editor_core_checksum_method_viewercompileddocument_trailing_empty_text_block_count() != 11698) {
2359
+ return InitializationResult.apiChecksumMismatch
2360
+ }
2361
+
2362
+ return InitializationResult.ok
2363
+ }()
2364
+
2365
+ // Make the ensure init function public so that other modules which have external type references to
2366
+ // our types can call it.
2367
+ public func uniffiEnsureEditorCoreInitialized() {
2368
+ switch initializationResult {
2369
+ case .ok:
2370
+ break
2371
+ case .contractVersionMismatch:
2372
+ fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
2373
+ case .apiChecksumMismatch:
2374
+ fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
2375
+ }
2376
+ }
2377
+
2378
+ // swiftlint:enable all