@openeditor/react-native-prose-editor 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +160 -0
  2. package/README.md +180 -0
  3. package/android/build.gradle +69 -0
  4. package/android/consumer-rules.pro +18 -0
  5. package/android/src/androidTest/AndroidManifest.xml +8 -0
  6. package/android/src/androidTest/java/com/apollohg/editor/MeasureHeightInstrumentedTest.kt +53 -0
  7. package/android/src/androidTest/java/com/apollohg/editor/NativeDeviceCollaborationInitialSyncTest.kt +241 -0
  8. package/android/src/androidTest/java/com/apollohg/editor/NativeDeviceImeRegressionTest.kt +338 -0
  9. package/android/src/androidTest/java/com/apollohg/editor/NativeDeviceOutsideTapTest.kt +789 -0
  10. package/android/src/androidTest/java/com/apollohg/editor/NativeDevicePerformanceTest.kt +350 -0
  11. package/android/src/androidTest/java/com/apollohg/editor/NativeEditorOutsideTapActivity.kt +5 -0
  12. package/android/src/main/assets/editor-icons/MaterialIcons.json +2236 -0
  13. package/android/src/main/assets/editor-icons/MaterialIcons.ttf +0 -0
  14. package/android/src/main/java/com/apollohg/editor/CaretGeometry.kt +50 -0
  15. package/android/src/main/java/com/apollohg/editor/EditorAddons.kt +135 -0
  16. package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +4527 -0
  17. package/android/src/main/java/com/apollohg/editor/EditorHeightBehavior.kt +14 -0
  18. package/android/src/main/java/com/apollohg/editor/EditorInputConnection.kt +999 -0
  19. package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +474 -0
  20. package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +199 -0
  21. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +3137 -0
  22. package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +561 -0
  23. package/android/src/main/java/com/apollohg/editor/NativeProseViewerExpoView.kt +315 -0
  24. package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +1413 -0
  25. package/android/src/main/java/com/apollohg/editor/PositionBridge.kt +133 -0
  26. package/android/src/main/java/com/apollohg/editor/RemoteSelectionOverlayView.kt +315 -0
  27. package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +2172 -0
  28. package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +399 -0
  29. package/android/src/sharedTest/java/com/apollohg/editor/NativePerformanceSupport.kt +482 -0
  30. package/android/src/test/java/com/apollohg/editor/CaretGeometryTest.kt +137 -0
  31. package/android/src/test/java/com/apollohg/editor/EditorEditTextHardwareKeyTest.kt +321 -0
  32. package/android/src/test/java/com/apollohg/editor/EditorInputConnectionTest.kt +4202 -0
  33. package/android/src/test/java/com/apollohg/editor/NativeEditorExpoViewTest.kt +2581 -0
  34. package/android/src/test/java/com/apollohg/editor/NativeEditorModuleTest.kt +27 -0
  35. package/android/src/test/java/com/apollohg/editor/NativePerformanceTest.kt +197 -0
  36. package/android/src/test/java/com/apollohg/editor/NativeProseViewerExpoViewTest.kt +84 -0
  37. package/android/src/test/java/com/apollohg/editor/NativeToolbarTest.kt +544 -0
  38. package/android/src/test/java/com/apollohg/editor/PositionBridgeTest.kt +461 -0
  39. package/android/src/test/java/com/apollohg/editor/RenderBridgeTest.kt +2054 -0
  40. package/android/src/test/java/com/apollohg/editor/RichTextEditorViewTest.kt +1367 -0
  41. package/app.plugin.js +62 -0
  42. package/dist/EditorTheme.d.ts +113 -0
  43. package/dist/EditorTheme.js +29 -0
  44. package/dist/EditorToolbar.d.ts +191 -0
  45. package/dist/EditorToolbar.js +1095 -0
  46. package/dist/NativeEditorBridge.d.ts +325 -0
  47. package/dist/NativeEditorBridge.js +933 -0
  48. package/dist/NativeProseViewer.d.ts +53 -0
  49. package/dist/NativeProseViewer.js +480 -0
  50. package/dist/NativeRichTextEditor.d.ts +183 -0
  51. package/dist/NativeRichTextEditor.js +2574 -0
  52. package/dist/YjsCollaboration.d.ts +90 -0
  53. package/dist/YjsCollaboration.js +743 -0
  54. package/dist/addons.d.ts +100 -0
  55. package/dist/addons.js +82 -0
  56. package/dist/heightCache.d.ts +6 -0
  57. package/dist/heightCache.js +45 -0
  58. package/dist/index.d.ts +10 -0
  59. package/dist/index.js +30 -0
  60. package/dist/schemas.d.ts +37 -0
  61. package/dist/schemas.js +263 -0
  62. package/dist/useNativeEditor.d.ts +42 -0
  63. package/dist/useNativeEditor.js +124 -0
  64. package/expo-module.config.json +9 -0
  65. package/ios/EditorAddons.swift +327 -0
  66. package/ios/EditorCore.xcframework/Info.plist +44 -0
  67. package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
  68. package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
  69. package/ios/EditorLayoutManager.swift +774 -0
  70. package/ios/EditorTheme.swift +515 -0
  71. package/ios/Generated_editor_core.swift +1513 -0
  72. package/ios/NativeEditorExpoView.swift +3593 -0
  73. package/ios/NativeEditorModule.swift +624 -0
  74. package/ios/NativeProseViewerExpoView.swift +276 -0
  75. package/ios/PositionBridge.swift +558 -0
  76. package/ios/ReactNativeProseEditor.podspec +49 -0
  77. package/ios/RenderBridge.swift +1708 -0
  78. package/ios/RichTextEditorView.swift +6150 -0
  79. package/ios/Tests/NativePerformanceTests.swift +687 -0
  80. package/ios/Tests/PositionBridgeTests.swift +706 -0
  81. package/ios/Tests/RenderBridgeTests.swift +2236 -0
  82. package/ios/Tests/RichTextEditorViewTests.swift +6548 -0
  83. package/ios/editor_coreFFI/editor_coreFFI.h +1289 -0
  84. package/ios/editor_coreFFI/module.modulemap +7 -0
  85. package/ios/editor_coreFFI.h +904 -0
  86. package/ios/editor_coreFFI.modulemap +7 -0
  87. package/package.json +74 -0
  88. package/rust/android/arm64-v8a/libeditor_core.so +0 -0
  89. package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
  90. package/rust/android/x86_64/libeditor_core.so +0 -0
  91. package/rust/bindings/kotlin/uniffi/editor_core/editor_core.kt +2563 -0
@@ -0,0 +1,1513 @@
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 FfiConverterUInt8: FfiConverterPrimitive {
404
+ typealias FfiType = UInt8
405
+ typealias SwiftType = UInt8
406
+
407
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt8 {
408
+ return try lift(readInt(&buf))
409
+ }
410
+
411
+ public static func write(_ value: UInt8, 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 FfiConverterUInt64: FfiConverterPrimitive {
436
+ typealias FfiType = UInt64
437
+ typealias SwiftType = UInt64
438
+
439
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 {
440
+ return try lift(readInt(&buf))
441
+ }
442
+
443
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
444
+ writeInt(&buf, lower(value))
445
+ }
446
+ }
447
+
448
+ #if swift(>=5.8)
449
+ @_documentation(visibility: private)
450
+ #endif
451
+ fileprivate struct FfiConverterBool : FfiConverter {
452
+ typealias FfiType = Int8
453
+ typealias SwiftType = Bool
454
+
455
+ public static func lift(_ value: Int8) throws -> Bool {
456
+ return value != 0
457
+ }
458
+
459
+ public static func lower(_ value: Bool) -> Int8 {
460
+ return value ? 1 : 0
461
+ }
462
+
463
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
464
+ return try lift(readInt(&buf))
465
+ }
466
+
467
+ public static func write(_ value: Bool, into buf: inout [UInt8]) {
468
+ writeInt(&buf, lower(value))
469
+ }
470
+ }
471
+
472
+ #if swift(>=5.8)
473
+ @_documentation(visibility: private)
474
+ #endif
475
+ fileprivate struct FfiConverterString: FfiConverter {
476
+ typealias SwiftType = String
477
+ typealias FfiType = RustBuffer
478
+
479
+ public static func lift(_ value: RustBuffer) throws -> String {
480
+ defer {
481
+ value.deallocate()
482
+ }
483
+ if value.data == nil {
484
+ return String()
485
+ }
486
+ let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
487
+ return String(bytes: bytes, encoding: String.Encoding.utf8)!
488
+ }
489
+
490
+ public static func lower(_ value: String) -> RustBuffer {
491
+ return value.utf8CString.withUnsafeBufferPointer { ptr in
492
+ // The swift string gives us int8_t, we want uint8_t.
493
+ ptr.withMemoryRebound(to: UInt8.self) { ptr in
494
+ // The swift string gives us a trailing null byte, we don't want it.
495
+ let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
496
+ return RustBuffer.from(buf)
497
+ }
498
+ }
499
+ }
500
+
501
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
502
+ let len: Int32 = try readInt(&buf)
503
+ return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
504
+ }
505
+
506
+ public static func write(_ value: String, into buf: inout [UInt8]) {
507
+ let len = Int32(value.utf8.count)
508
+ writeInt(&buf, len)
509
+ writeBytes(&buf, value.utf8)
510
+ }
511
+ }
512
+ /**
513
+ * Apply a durable Yjs encoded state/update represented as a JSON byte array.
514
+ */
515
+ public func collaborationSessionApplyEncodedState(id: UInt64, encodedStateJson: String) -> String {
516
+ return try! FfiConverterString.lift(try! rustCall() {
517
+ uniffi_editor_core_fn_func_collaboration_session_apply_encoded_state(
518
+ FfiConverterUInt64.lower(id),
519
+ FfiConverterString.lower(encodedStateJson),$0
520
+ )
521
+ })
522
+ }
523
+ /**
524
+ * Apply a local ProseMirror JSON snapshot to the collaboration session.
525
+ */
526
+ public func collaborationSessionApplyLocalDocumentJson(id: UInt64, json: String) -> String {
527
+ return try! FfiConverterString.lift(try! rustCall() {
528
+ uniffi_editor_core_fn_func_collaboration_session_apply_local_document_json(
529
+ FfiConverterUInt64.lower(id),
530
+ FfiConverterString.lower(json),$0
531
+ )
532
+ })
533
+ }
534
+ /**
535
+ * Clear the local awareness payload for a collaboration session.
536
+ */
537
+ public func collaborationSessionClearLocalAwareness(id: UInt64) -> String {
538
+ return try! FfiConverterString.lift(try! rustCall() {
539
+ uniffi_editor_core_fn_func_collaboration_session_clear_local_awareness(
540
+ FfiConverterUInt64.lower(id),$0
541
+ )
542
+ })
543
+ }
544
+ /**
545
+ * Create a Yjs collaboration session backed by yrs.
546
+ */
547
+ public func collaborationSessionCreate(configJson: String) -> UInt64 {
548
+ return try! FfiConverterUInt64.lift(try! rustCall() {
549
+ uniffi_editor_core_fn_func_collaboration_session_create(
550
+ FfiConverterString.lower(configJson),$0
551
+ )
552
+ })
553
+ }
554
+ /**
555
+ * Destroy a collaboration session and free its resources.
556
+ */
557
+ public func collaborationSessionDestroy(id: UInt64) {try! rustCall() {
558
+ uniffi_editor_core_fn_func_collaboration_session_destroy(
559
+ FfiConverterUInt64.lower(id),$0
560
+ )
561
+ }
562
+ }
563
+ /**
564
+ * Return the current shared ProseMirror JSON document for a collaboration session.
565
+ */
566
+ public func collaborationSessionGetDocumentJson(id: UInt64) -> String {
567
+ return try! FfiConverterString.lift(try! rustCall() {
568
+ uniffi_editor_core_fn_func_collaboration_session_get_document_json(
569
+ FfiConverterUInt64.lower(id),$0
570
+ )
571
+ })
572
+ }
573
+ /**
574
+ * Return the current shared Yjs document state as a JSON byte array.
575
+ */
576
+ public func collaborationSessionGetEncodedState(id: UInt64) -> String {
577
+ return try! FfiConverterString.lift(try! rustCall() {
578
+ uniffi_editor_core_fn_func_collaboration_session_get_encoded_state(
579
+ FfiConverterUInt64.lower(id),$0
580
+ )
581
+ })
582
+ }
583
+ /**
584
+ * Return the current awareness peers for a collaboration session.
585
+ */
586
+ public func collaborationSessionGetPeersJson(id: UInt64) -> String {
587
+ return try! FfiConverterString.lift(try! rustCall() {
588
+ uniffi_editor_core_fn_func_collaboration_session_get_peers_json(
589
+ FfiConverterUInt64.lower(id),$0
590
+ )
591
+ })
592
+ }
593
+ /**
594
+ * Apply an incoming y-sync binary message encoded as a JSON byte array.
595
+ */
596
+ public func collaborationSessionHandleMessage(id: UInt64, messageJson: String) -> String {
597
+ return try! FfiConverterString.lift(try! rustCall() {
598
+ uniffi_editor_core_fn_func_collaboration_session_handle_message(
599
+ FfiConverterUInt64.lower(id),
600
+ FfiConverterString.lower(messageJson),$0
601
+ )
602
+ })
603
+ }
604
+ /**
605
+ * Replace the collaboration document with a durable Yjs encoded state/update.
606
+ */
607
+ public func collaborationSessionReplaceEncodedState(id: UInt64, encodedStateJson: String) -> String {
608
+ return try! FfiConverterString.lift(try! rustCall() {
609
+ uniffi_editor_core_fn_func_collaboration_session_replace_encoded_state(
610
+ FfiConverterUInt64.lower(id),
611
+ FfiConverterString.lower(encodedStateJson),$0
612
+ )
613
+ })
614
+ }
615
+ /**
616
+ * Update the local awareness payload for a collaboration session.
617
+ */
618
+ public func collaborationSessionSetLocalAwareness(id: UInt64, awarenessJson: String) -> String {
619
+ return try! FfiConverterString.lift(try! rustCall() {
620
+ uniffi_editor_core_fn_func_collaboration_session_set_local_awareness(
621
+ FfiConverterUInt64.lower(id),
622
+ FfiConverterString.lower(awarenessJson),$0
623
+ )
624
+ })
625
+ }
626
+ /**
627
+ * Start the sync handshake for a collaboration session.
628
+ */
629
+ public func collaborationSessionStart(id: UInt64) -> String {
630
+ return try! FfiConverterString.lift(try! rustCall() {
631
+ uniffi_editor_core_fn_func_collaboration_session_start(
632
+ FfiConverterUInt64.lower(id),$0
633
+ )
634
+ })
635
+ }
636
+ /**
637
+ * Check if redo is available.
638
+ */
639
+ public func editorCanRedo(id: UInt64) -> Bool {
640
+ return try! FfiConverterBool.lift(try! rustCall() {
641
+ uniffi_editor_core_fn_func_editor_can_redo(
642
+ FfiConverterUInt64.lower(id),$0
643
+ )
644
+ })
645
+ }
646
+ /**
647
+ * Check if undo is available.
648
+ */
649
+ public func editorCanUndo(id: UInt64) -> Bool {
650
+ return try! FfiConverterBool.lift(try! rustCall() {
651
+ uniffi_editor_core_fn_func_editor_can_undo(
652
+ FfiConverterUInt64.lower(id),$0
653
+ )
654
+ })
655
+ }
656
+ /**
657
+ * Return the crate version string.
658
+ */
659
+ public func editorCoreVersion() -> String {
660
+ return try! FfiConverterString.lift(try! rustCall() {
661
+ uniffi_editor_core_fn_func_editor_core_version($0
662
+ )
663
+ })
664
+ }
665
+ /**
666
+ * Create a new editor from a JSON config object.
667
+ *
668
+ * Config fields (all optional):
669
+ * - `"schema"`: custom schema definition (see `Schema::from_json`)
670
+ * - `"maxLength"`: maximum document length in characters
671
+ * - `"readOnly"`: if `true`, rejects non-API mutations
672
+ * - `"inputFilter"`: regex pattern; only matching characters are inserted
673
+ * - `"allowBase64Images"`: if `true`, parses `<img src="data:image/...">` as image nodes
674
+ *
675
+ * An empty object creates a default editor.
676
+ * Falls back to the default Tiptap schema when `"schema"` is absent or invalid.
677
+ */
678
+ public func editorCreate(configJson: String) -> UInt64 {
679
+ return try! FfiConverterUInt64.lift(try! rustCall() {
680
+ uniffi_editor_core_fn_func_editor_create(
681
+ FfiConverterString.lower(configJson),$0
682
+ )
683
+ })
684
+ }
685
+ /**
686
+ * Delete a scalar range then split the block (Enter with selection). Returns an update.
687
+ */
688
+ public func editorDeleteAndSplitScalar(id: UInt64, scalarFrom: UInt32, scalarTo: UInt32) -> String {
689
+ return try! FfiConverterString.lift(try! rustCall() {
690
+ uniffi_editor_core_fn_func_editor_delete_and_split_scalar(
691
+ FfiConverterUInt64.lower(id),
692
+ FfiConverterUInt32.lower(scalarFrom),
693
+ FfiConverterUInt32.lower(scalarTo),$0
694
+ )
695
+ })
696
+ }
697
+ /**
698
+ * Delete backward relative to an explicit scalar selection. Returns an update JSON string.
699
+ */
700
+ public func editorDeleteBackwardAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32) -> String {
701
+ return try! FfiConverterString.lift(try! rustCall() {
702
+ uniffi_editor_core_fn_func_editor_delete_backward_at_selection_scalar(
703
+ FfiConverterUInt64.lower(id),
704
+ FfiConverterUInt32.lower(scalarAnchor),
705
+ FfiConverterUInt32.lower(scalarHead),$0
706
+ )
707
+ })
708
+ }
709
+ /**
710
+ * Delete a range. Returns an update JSON string.
711
+ */
712
+ public func editorDeleteRange(id: UInt64, from: UInt32, to: UInt32) -> String {
713
+ return try! FfiConverterString.lift(try! rustCall() {
714
+ uniffi_editor_core_fn_func_editor_delete_range(
715
+ FfiConverterUInt64.lower(id),
716
+ FfiConverterUInt32.lower(from),
717
+ FfiConverterUInt32.lower(to),$0
718
+ )
719
+ })
720
+ }
721
+ /**
722
+ * Delete content between two scalar offsets. Returns an update JSON string.
723
+ */
724
+ public func editorDeleteScalarRange(id: UInt64, scalarFrom: UInt32, scalarTo: UInt32) -> String {
725
+ return try! FfiConverterString.lift(try! rustCall() {
726
+ uniffi_editor_core_fn_func_editor_delete_scalar_range(
727
+ FfiConverterUInt64.lower(id),
728
+ FfiConverterUInt32.lower(scalarFrom),
729
+ FfiConverterUInt32.lower(scalarTo),$0
730
+ )
731
+ })
732
+ }
733
+ /**
734
+ * Destroy an editor instance, freeing its resources.
735
+ */
736
+ public func editorDestroy(id: UInt64) {try! rustCall() {
737
+ uniffi_editor_core_fn_func_editor_destroy(
738
+ FfiConverterUInt64.lower(id),$0
739
+ )
740
+ }
741
+ }
742
+ /**
743
+ * Convert a document position to a rendered-text scalar offset.
744
+ */
745
+ public func editorDocToScalar(id: UInt64, docPos: UInt32) -> UInt32 {
746
+ return try! FfiConverterUInt32.lift(try! rustCall() {
747
+ uniffi_editor_core_fn_func_editor_doc_to_scalar(
748
+ FfiConverterUInt64.lower(id),
749
+ FfiConverterUInt32.lower(docPos),$0
750
+ )
751
+ })
752
+ }
753
+ /**
754
+ * Get both HTML and ProseMirror JSON content in one payload.
755
+ */
756
+ public func editorGetContentSnapshot(id: UInt64) -> String {
757
+ return try! FfiConverterString.lift(try! rustCall() {
758
+ uniffi_editor_core_fn_func_editor_get_content_snapshot(
759
+ FfiConverterUInt64.lower(id),$0
760
+ )
761
+ })
762
+ }
763
+ /**
764
+ * Get the current editor state (render elements, selection, active state,
765
+ * history state) without performing any edits. Used by native views to pull
766
+ * initial state when binding to an already-loaded editor.
767
+ */
768
+ public func editorGetCurrentState(id: UInt64) -> String {
769
+ return try! FfiConverterString.lift(try! rustCall() {
770
+ uniffi_editor_core_fn_func_editor_get_current_state(
771
+ FfiConverterUInt64.lower(id),$0
772
+ )
773
+ })
774
+ }
775
+ /**
776
+ * Get the editor's content as HTML.
777
+ */
778
+ public func editorGetHtml(id: UInt64) -> String {
779
+ return try! FfiConverterString.lift(try! rustCall() {
780
+ uniffi_editor_core_fn_func_editor_get_html(
781
+ FfiConverterUInt64.lower(id),$0
782
+ )
783
+ })
784
+ }
785
+ /**
786
+ * Get the editor's content as ProseMirror JSON.
787
+ */
788
+ public func editorGetJson(id: UInt64) -> String {
789
+ return try! FfiConverterString.lift(try! rustCall() {
790
+ uniffi_editor_core_fn_func_editor_get_json(
791
+ FfiConverterUInt64.lower(id),$0
792
+ )
793
+ })
794
+ }
795
+ /**
796
+ * Get the current selection as JSON.
797
+ */
798
+ public func editorGetSelection(id: UInt64) -> String {
799
+ return try! FfiConverterString.lift(try! rustCall() {
800
+ uniffi_editor_core_fn_func_editor_get_selection(
801
+ FfiConverterUInt64.lower(id),$0
802
+ )
803
+ })
804
+ }
805
+ /**
806
+ * Get the current selection-related editor state without render elements.
807
+ */
808
+ public func editorGetSelectionState(id: UInt64) -> String {
809
+ return try! FfiConverterString.lift(try! rustCall() {
810
+ uniffi_editor_core_fn_func_editor_get_selection_state(
811
+ FfiConverterUInt64.lower(id),$0
812
+ )
813
+ })
814
+ }
815
+ /**
816
+ * Indent the current list item into a nested list. Returns an update JSON string.
817
+ */
818
+ public func editorIndentListItem(id: UInt64) -> String {
819
+ return try! FfiConverterString.lift(try! rustCall() {
820
+ uniffi_editor_core_fn_func_editor_indent_list_item(
821
+ FfiConverterUInt64.lower(id),$0
822
+ )
823
+ })
824
+ }
825
+ /**
826
+ * Indent the list item at an explicit scalar selection. Returns an update JSON string.
827
+ */
828
+ public func editorIndentListItemAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32) -> String {
829
+ return try! FfiConverterString.lift(try! rustCall() {
830
+ uniffi_editor_core_fn_func_editor_indent_list_item_at_selection_scalar(
831
+ FfiConverterUInt64.lower(id),
832
+ FfiConverterUInt32.lower(scalarAnchor),
833
+ FfiConverterUInt32.lower(scalarHead),$0
834
+ )
835
+ })
836
+ }
837
+ /**
838
+ * Insert HTML content at the current selection. Returns an update JSON string.
839
+ */
840
+ public func editorInsertContentHtml(id: UInt64, html: String) -> String {
841
+ return try! FfiConverterString.lift(try! rustCall() {
842
+ uniffi_editor_core_fn_func_editor_insert_content_html(
843
+ FfiConverterUInt64.lower(id),
844
+ FfiConverterString.lower(html),$0
845
+ )
846
+ })
847
+ }
848
+ /**
849
+ * Insert JSON content at the current selection. Returns an update JSON string.
850
+ */
851
+ public func editorInsertContentJson(id: UInt64, json: String) -> String {
852
+ return try! FfiConverterString.lift(try! rustCall() {
853
+ uniffi_editor_core_fn_func_editor_insert_content_json(
854
+ FfiConverterUInt64.lower(id),
855
+ FfiConverterString.lower(json),$0
856
+ )
857
+ })
858
+ }
859
+ /**
860
+ * Insert JSON content at an explicit scalar selection. Returns an update JSON string.
861
+ */
862
+ public func editorInsertContentJsonAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32, json: String) -> String {
863
+ return try! FfiConverterString.lift(try! rustCall() {
864
+ uniffi_editor_core_fn_func_editor_insert_content_json_at_selection_scalar(
865
+ FfiConverterUInt64.lower(id),
866
+ FfiConverterUInt32.lower(scalarAnchor),
867
+ FfiConverterUInt32.lower(scalarHead),
868
+ FfiConverterString.lower(json),$0
869
+ )
870
+ })
871
+ }
872
+ /**
873
+ * Insert a void node at the current selection. Returns an update JSON string.
874
+ */
875
+ public func editorInsertNode(id: UInt64, nodeType: String) -> String {
876
+ return try! FfiConverterString.lift(try! rustCall() {
877
+ uniffi_editor_core_fn_func_editor_insert_node(
878
+ FfiConverterUInt64.lower(id),
879
+ FfiConverterString.lower(nodeType),$0
880
+ )
881
+ })
882
+ }
883
+ /**
884
+ * Insert a node at an explicit scalar selection. Returns an update JSON string.
885
+ */
886
+ public func editorInsertNodeAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32, nodeType: String) -> String {
887
+ return try! FfiConverterString.lift(try! rustCall() {
888
+ uniffi_editor_core_fn_func_editor_insert_node_at_selection_scalar(
889
+ FfiConverterUInt64.lower(id),
890
+ FfiConverterUInt32.lower(scalarAnchor),
891
+ FfiConverterUInt32.lower(scalarHead),
892
+ FfiConverterString.lower(nodeType),$0
893
+ )
894
+ })
895
+ }
896
+ /**
897
+ * Insert text at a position. Returns an update JSON string.
898
+ */
899
+ public func editorInsertText(id: UInt64, pos: UInt32, text: String) -> String {
900
+ return try! FfiConverterString.lift(try! rustCall() {
901
+ uniffi_editor_core_fn_func_editor_insert_text(
902
+ FfiConverterUInt64.lower(id),
903
+ FfiConverterUInt32.lower(pos),
904
+ FfiConverterString.lower(text),$0
905
+ )
906
+ })
907
+ }
908
+ /**
909
+ * Insert text at a scalar offset. Returns an update JSON string.
910
+ */
911
+ public func editorInsertTextScalar(id: UInt64, scalarPos: UInt32, text: String) -> String {
912
+ return try! FfiConverterString.lift(try! rustCall() {
913
+ uniffi_editor_core_fn_func_editor_insert_text_scalar(
914
+ FfiConverterUInt64.lower(id),
915
+ FfiConverterUInt32.lower(scalarPos),
916
+ FfiConverterString.lower(text),$0
917
+ )
918
+ })
919
+ }
920
+ /**
921
+ * Outdent the current list item to the parent list level. Returns an update JSON string.
922
+ */
923
+ public func editorOutdentListItem(id: UInt64) -> String {
924
+ return try! FfiConverterString.lift(try! rustCall() {
925
+ uniffi_editor_core_fn_func_editor_outdent_list_item(
926
+ FfiConverterUInt64.lower(id),$0
927
+ )
928
+ })
929
+ }
930
+ /**
931
+ * Outdent the list item at an explicit scalar selection. Returns an update JSON string.
932
+ */
933
+ public func editorOutdentListItemAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32) -> String {
934
+ return try! FfiConverterString.lift(try! rustCall() {
935
+ uniffi_editor_core_fn_func_editor_outdent_list_item_at_selection_scalar(
936
+ FfiConverterUInt64.lower(id),
937
+ FfiConverterUInt32.lower(scalarAnchor),
938
+ FfiConverterUInt32.lower(scalarHead),$0
939
+ )
940
+ })
941
+ }
942
+ /**
943
+ * Redo. Returns an update JSON string, or empty string if nothing to redo.
944
+ */
945
+ public func editorRedo(id: UInt64) -> String {
946
+ return try! FfiConverterString.lift(try! rustCall() {
947
+ uniffi_editor_core_fn_func_editor_redo(
948
+ FfiConverterUInt64.lower(id),$0
949
+ )
950
+ })
951
+ }
952
+ /**
953
+ * Replace entire document content with HTML via a transaction (preserves history).
954
+ */
955
+ public func editorReplaceHtml(id: UInt64, html: String) -> String {
956
+ return try! FfiConverterString.lift(try! rustCall() {
957
+ uniffi_editor_core_fn_func_editor_replace_html(
958
+ FfiConverterUInt64.lower(id),
959
+ FfiConverterString.lower(html),$0
960
+ )
961
+ })
962
+ }
963
+ /**
964
+ * Replace entire document content with JSON via a transaction (preserves history).
965
+ */
966
+ public func editorReplaceJson(id: UInt64, json: String) -> String {
967
+ return try! FfiConverterString.lift(try! rustCall() {
968
+ uniffi_editor_core_fn_func_editor_replace_json(
969
+ FfiConverterUInt64.lower(id),
970
+ FfiConverterString.lower(json),$0
971
+ )
972
+ })
973
+ }
974
+ /**
975
+ * Replace the current selection with plain text. Returns an update JSON string.
976
+ */
977
+ public func editorReplaceSelectionText(id: UInt64, text: String) -> String {
978
+ return try! FfiConverterString.lift(try! rustCall() {
979
+ uniffi_editor_core_fn_func_editor_replace_selection_text(
980
+ FfiConverterUInt64.lower(id),
981
+ FfiConverterString.lower(text),$0
982
+ )
983
+ })
984
+ }
985
+ /**
986
+ * Replace a scalar range with text (atomic delete + insert). Returns an update JSON string.
987
+ */
988
+ public func editorReplaceTextScalar(id: UInt64, scalarFrom: UInt32, scalarTo: UInt32, text: String) -> String {
989
+ return try! FfiConverterString.lift(try! rustCall() {
990
+ uniffi_editor_core_fn_func_editor_replace_text_scalar(
991
+ FfiConverterUInt64.lower(id),
992
+ FfiConverterUInt32.lower(scalarFrom),
993
+ FfiConverterUInt32.lower(scalarTo),
994
+ FfiConverterString.lower(text),$0
995
+ )
996
+ })
997
+ }
998
+ /**
999
+ * Resize an image node at a document position. Returns an update JSON string.
1000
+ */
1001
+ public func editorResizeImageAtDocPos(id: UInt64, docPos: UInt32, width: UInt32, height: UInt32) -> String {
1002
+ return try! FfiConverterString.lift(try! rustCall() {
1003
+ uniffi_editor_core_fn_func_editor_resize_image_at_doc_pos(
1004
+ FfiConverterUInt64.lower(id),
1005
+ FfiConverterUInt32.lower(docPos),
1006
+ FfiConverterUInt32.lower(width),
1007
+ FfiConverterUInt32.lower(height),$0
1008
+ )
1009
+ })
1010
+ }
1011
+ /**
1012
+ * Convert a rendered-text scalar offset to a document position.
1013
+ */
1014
+ public func editorScalarToDoc(id: UInt64, scalar: UInt32) -> UInt32 {
1015
+ return try! FfiConverterUInt32.lift(try! rustCall() {
1016
+ uniffi_editor_core_fn_func_editor_scalar_to_doc(
1017
+ FfiConverterUInt64.lower(id),
1018
+ FfiConverterUInt32.lower(scalar),$0
1019
+ )
1020
+ })
1021
+ }
1022
+ /**
1023
+ * Set the editor's content from an HTML string. Returns render elements as JSON.
1024
+ */
1025
+ public func editorSetHtml(id: UInt64, html: String) -> String {
1026
+ return try! FfiConverterString.lift(try! rustCall() {
1027
+ uniffi_editor_core_fn_func_editor_set_html(
1028
+ FfiConverterUInt64.lower(id),
1029
+ FfiConverterString.lower(html),$0
1030
+ )
1031
+ })
1032
+ }
1033
+ /**
1034
+ * Set the editor's content from a ProseMirror JSON string.
1035
+ */
1036
+ public func editorSetJson(id: UInt64, json: String) -> String {
1037
+ return try! FfiConverterString.lift(try! rustCall() {
1038
+ uniffi_editor_core_fn_func_editor_set_json(
1039
+ FfiConverterUInt64.lower(id),
1040
+ FfiConverterString.lower(json),$0
1041
+ )
1042
+ })
1043
+ }
1044
+ /**
1045
+ * Set a mark with attrs on the current selection. Returns an update JSON string.
1046
+ */
1047
+ public func editorSetMark(id: UInt64, markName: String, attrsJson: String) -> String {
1048
+ return try! FfiConverterString.lift(try! rustCall() {
1049
+ uniffi_editor_core_fn_func_editor_set_mark(
1050
+ FfiConverterUInt64.lower(id),
1051
+ FfiConverterString.lower(markName),
1052
+ FfiConverterString.lower(attrsJson),$0
1053
+ )
1054
+ })
1055
+ }
1056
+ /**
1057
+ * Set a mark with attrs at an explicit scalar selection. Returns an update JSON string.
1058
+ */
1059
+ public func editorSetMarkAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32, markName: String, attrsJson: String) -> String {
1060
+ return try! FfiConverterString.lift(try! rustCall() {
1061
+ uniffi_editor_core_fn_func_editor_set_mark_at_selection_scalar(
1062
+ FfiConverterUInt64.lower(id),
1063
+ FfiConverterUInt32.lower(scalarAnchor),
1064
+ FfiConverterUInt32.lower(scalarHead),
1065
+ FfiConverterString.lower(markName),
1066
+ FfiConverterString.lower(attrsJson),$0
1067
+ )
1068
+ })
1069
+ }
1070
+ /**
1071
+ * Set the selection. Anchor and head are document positions.
1072
+ */
1073
+ public func editorSetSelection(id: UInt64, anchor: UInt32, head: UInt32) {try! rustCall() {
1074
+ uniffi_editor_core_fn_func_editor_set_selection(
1075
+ FfiConverterUInt64.lower(id),
1076
+ FfiConverterUInt32.lower(anchor),
1077
+ FfiConverterUInt32.lower(head),$0
1078
+ )
1079
+ }
1080
+ }
1081
+ /**
1082
+ * Set the selection from scalar offsets, converting to document positions internally.
1083
+ */
1084
+ public func editorSetSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32) {try! rustCall() {
1085
+ uniffi_editor_core_fn_func_editor_set_selection_scalar(
1086
+ FfiConverterUInt64.lower(id),
1087
+ FfiConverterUInt32.lower(scalarAnchor),
1088
+ FfiConverterUInt32.lower(scalarHead),$0
1089
+ )
1090
+ }
1091
+ }
1092
+ /**
1093
+ * Split the block at a position (Enter key). Returns an update JSON string.
1094
+ */
1095
+ public func editorSplitBlock(id: UInt64, pos: UInt32) -> String {
1096
+ return try! FfiConverterString.lift(try! rustCall() {
1097
+ uniffi_editor_core_fn_func_editor_split_block(
1098
+ FfiConverterUInt64.lower(id),
1099
+ FfiConverterUInt32.lower(pos),$0
1100
+ )
1101
+ })
1102
+ }
1103
+ /**
1104
+ * Split a block at a scalar offset. Returns an update JSON string.
1105
+ */
1106
+ public func editorSplitBlockScalar(id: UInt64, scalarPos: UInt32) -> String {
1107
+ return try! FfiConverterString.lift(try! rustCall() {
1108
+ uniffi_editor_core_fn_func_editor_split_block_scalar(
1109
+ FfiConverterUInt64.lower(id),
1110
+ FfiConverterUInt32.lower(scalarPos),$0
1111
+ )
1112
+ })
1113
+ }
1114
+ /**
1115
+ * Toggle a blockquote around the current block selection. Returns an update JSON string.
1116
+ */
1117
+ public func editorToggleBlockquote(id: UInt64) -> String {
1118
+ return try! FfiConverterString.lift(try! rustCall() {
1119
+ uniffi_editor_core_fn_func_editor_toggle_blockquote(
1120
+ FfiConverterUInt64.lower(id),$0
1121
+ )
1122
+ })
1123
+ }
1124
+ /**
1125
+ * Toggle a blockquote at an explicit scalar selection. Returns an update JSON string.
1126
+ */
1127
+ public func editorToggleBlockquoteAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32) -> String {
1128
+ return try! FfiConverterString.lift(try! rustCall() {
1129
+ uniffi_editor_core_fn_func_editor_toggle_blockquote_at_selection_scalar(
1130
+ FfiConverterUInt64.lower(id),
1131
+ FfiConverterUInt32.lower(scalarAnchor),
1132
+ FfiConverterUInt32.lower(scalarHead),$0
1133
+ )
1134
+ })
1135
+ }
1136
+ /**
1137
+ * Toggle a heading level on the current text-block selection. Returns an update JSON string.
1138
+ */
1139
+ public func editorToggleHeading(id: UInt64, level: UInt8) -> String {
1140
+ return try! FfiConverterString.lift(try! rustCall() {
1141
+ uniffi_editor_core_fn_func_editor_toggle_heading(
1142
+ FfiConverterUInt64.lower(id),
1143
+ FfiConverterUInt8.lower(level),$0
1144
+ )
1145
+ })
1146
+ }
1147
+ /**
1148
+ * Toggle a heading level at an explicit scalar selection. Returns an update JSON string.
1149
+ */
1150
+ public func editorToggleHeadingAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32, level: UInt8) -> String {
1151
+ return try! FfiConverterString.lift(try! rustCall() {
1152
+ uniffi_editor_core_fn_func_editor_toggle_heading_at_selection_scalar(
1153
+ FfiConverterUInt64.lower(id),
1154
+ FfiConverterUInt32.lower(scalarAnchor),
1155
+ FfiConverterUInt32.lower(scalarHead),
1156
+ FfiConverterUInt8.lower(level),$0
1157
+ )
1158
+ })
1159
+ }
1160
+ /**
1161
+ * Toggle a mark on the current selection. Returns an update JSON string.
1162
+ */
1163
+ public func editorToggleMark(id: UInt64, markName: String) -> String {
1164
+ return try! FfiConverterString.lift(try! rustCall() {
1165
+ uniffi_editor_core_fn_func_editor_toggle_mark(
1166
+ FfiConverterUInt64.lower(id),
1167
+ FfiConverterString.lower(markName),$0
1168
+ )
1169
+ })
1170
+ }
1171
+ /**
1172
+ * Toggle a mark at an explicit scalar selection. Returns an update JSON string.
1173
+ */
1174
+ public func editorToggleMarkAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32, markName: String) -> String {
1175
+ return try! FfiConverterString.lift(try! rustCall() {
1176
+ uniffi_editor_core_fn_func_editor_toggle_mark_at_selection_scalar(
1177
+ FfiConverterUInt64.lower(id),
1178
+ FfiConverterUInt32.lower(scalarAnchor),
1179
+ FfiConverterUInt32.lower(scalarHead),
1180
+ FfiConverterString.lower(markName),$0
1181
+ )
1182
+ })
1183
+ }
1184
+ /**
1185
+ * Toggle the checked state of the task item at an explicit scalar selection.
1186
+ */
1187
+ public func editorToggleTaskItemCheckedAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32) -> String {
1188
+ return try! FfiConverterString.lift(try! rustCall() {
1189
+ uniffi_editor_core_fn_func_editor_toggle_task_item_checked_at_selection_scalar(
1190
+ FfiConverterUInt64.lower(id),
1191
+ FfiConverterUInt32.lower(scalarAnchor),
1192
+ FfiConverterUInt32.lower(scalarHead),$0
1193
+ )
1194
+ })
1195
+ }
1196
+ /**
1197
+ * Undo. Returns an update JSON string, or empty string if nothing to undo.
1198
+ */
1199
+ public func editorUndo(id: UInt64) -> String {
1200
+ return try! FfiConverterString.lift(try! rustCall() {
1201
+ uniffi_editor_core_fn_func_editor_undo(
1202
+ FfiConverterUInt64.lower(id),$0
1203
+ )
1204
+ })
1205
+ }
1206
+ /**
1207
+ * Remove a mark from the current selection. Returns an update JSON string.
1208
+ */
1209
+ public func editorUnsetMark(id: UInt64, markName: String) -> String {
1210
+ return try! FfiConverterString.lift(try! rustCall() {
1211
+ uniffi_editor_core_fn_func_editor_unset_mark(
1212
+ FfiConverterUInt64.lower(id),
1213
+ FfiConverterString.lower(markName),$0
1214
+ )
1215
+ })
1216
+ }
1217
+ /**
1218
+ * Remove a mark at an explicit scalar selection. Returns an update JSON string.
1219
+ */
1220
+ public func editorUnsetMarkAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32, markName: String) -> String {
1221
+ return try! FfiConverterString.lift(try! rustCall() {
1222
+ uniffi_editor_core_fn_func_editor_unset_mark_at_selection_scalar(
1223
+ FfiConverterUInt64.lower(id),
1224
+ FfiConverterUInt32.lower(scalarAnchor),
1225
+ FfiConverterUInt32.lower(scalarHead),
1226
+ FfiConverterString.lower(markName),$0
1227
+ )
1228
+ })
1229
+ }
1230
+ /**
1231
+ * Unwrap the current list item back to a paragraph. Returns an update JSON string.
1232
+ */
1233
+ public func editorUnwrapFromList(id: UInt64) -> String {
1234
+ return try! FfiConverterString.lift(try! rustCall() {
1235
+ uniffi_editor_core_fn_func_editor_unwrap_from_list(
1236
+ FfiConverterUInt64.lower(id),$0
1237
+ )
1238
+ })
1239
+ }
1240
+ /**
1241
+ * Unwrap the list item at an explicit scalar selection. Returns an update JSON string.
1242
+ */
1243
+ public func editorUnwrapFromListAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32) -> String {
1244
+ return try! FfiConverterString.lift(try! rustCall() {
1245
+ uniffi_editor_core_fn_func_editor_unwrap_from_list_at_selection_scalar(
1246
+ FfiConverterUInt64.lower(id),
1247
+ FfiConverterUInt32.lower(scalarAnchor),
1248
+ FfiConverterUInt32.lower(scalarHead),$0
1249
+ )
1250
+ })
1251
+ }
1252
+ /**
1253
+ * Wrap the current selection in a list. Returns an update JSON string.
1254
+ */
1255
+ public func editorWrapInList(id: UInt64, listType: String) -> String {
1256
+ return try! FfiConverterString.lift(try! rustCall() {
1257
+ uniffi_editor_core_fn_func_editor_wrap_in_list(
1258
+ FfiConverterUInt64.lower(id),
1259
+ FfiConverterString.lower(listType),$0
1260
+ )
1261
+ })
1262
+ }
1263
+ /**
1264
+ * Wrap or convert a list at an explicit scalar selection. Returns an update JSON string.
1265
+ */
1266
+ public func editorWrapInListAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32, listType: String) -> String {
1267
+ return try! FfiConverterString.lift(try! rustCall() {
1268
+ uniffi_editor_core_fn_func_editor_wrap_in_list_at_selection_scalar(
1269
+ FfiConverterUInt64.lower(id),
1270
+ FfiConverterUInt32.lower(scalarAnchor),
1271
+ FfiConverterUInt32.lower(scalarHead),
1272
+ FfiConverterString.lower(listType),$0
1273
+ )
1274
+ })
1275
+ }
1276
+
1277
+ private enum InitializationResult {
1278
+ case ok
1279
+ case contractVersionMismatch
1280
+ case apiChecksumMismatch
1281
+ }
1282
+ // Use a global variable to perform the versioning checks. Swift ensures that
1283
+ // the code inside is only computed once.
1284
+ private let initializationResult: InitializationResult = {
1285
+ // Get the bindings contract version from our ComponentInterface
1286
+ let bindings_contract_version = 29
1287
+ // Get the scaffolding contract version by calling the into the dylib
1288
+ let scaffolding_contract_version = ffi_editor_core_uniffi_contract_version()
1289
+ if bindings_contract_version != scaffolding_contract_version {
1290
+ return InitializationResult.contractVersionMismatch
1291
+ }
1292
+ if (uniffi_editor_core_checksum_func_collaboration_session_apply_encoded_state() != 4684) {
1293
+ return InitializationResult.apiChecksumMismatch
1294
+ }
1295
+ if (uniffi_editor_core_checksum_func_collaboration_session_apply_local_document_json() != 396) {
1296
+ return InitializationResult.apiChecksumMismatch
1297
+ }
1298
+ if (uniffi_editor_core_checksum_func_collaboration_session_clear_local_awareness() != 48044) {
1299
+ return InitializationResult.apiChecksumMismatch
1300
+ }
1301
+ if (uniffi_editor_core_checksum_func_collaboration_session_create() != 60237) {
1302
+ return InitializationResult.apiChecksumMismatch
1303
+ }
1304
+ if (uniffi_editor_core_checksum_func_collaboration_session_destroy() != 56261) {
1305
+ return InitializationResult.apiChecksumMismatch
1306
+ }
1307
+ if (uniffi_editor_core_checksum_func_collaboration_session_get_document_json() != 44139) {
1308
+ return InitializationResult.apiChecksumMismatch
1309
+ }
1310
+ if (uniffi_editor_core_checksum_func_collaboration_session_get_encoded_state() != 16895) {
1311
+ return InitializationResult.apiChecksumMismatch
1312
+ }
1313
+ if (uniffi_editor_core_checksum_func_collaboration_session_get_peers_json() != 46461) {
1314
+ return InitializationResult.apiChecksumMismatch
1315
+ }
1316
+ if (uniffi_editor_core_checksum_func_collaboration_session_handle_message() != 25528) {
1317
+ return InitializationResult.apiChecksumMismatch
1318
+ }
1319
+ if (uniffi_editor_core_checksum_func_collaboration_session_replace_encoded_state() != 53994) {
1320
+ return InitializationResult.apiChecksumMismatch
1321
+ }
1322
+ if (uniffi_editor_core_checksum_func_collaboration_session_set_local_awareness() != 63617) {
1323
+ return InitializationResult.apiChecksumMismatch
1324
+ }
1325
+ if (uniffi_editor_core_checksum_func_collaboration_session_start() != 54751) {
1326
+ return InitializationResult.apiChecksumMismatch
1327
+ }
1328
+ if (uniffi_editor_core_checksum_func_editor_can_redo() != 15854) {
1329
+ return InitializationResult.apiChecksumMismatch
1330
+ }
1331
+ if (uniffi_editor_core_checksum_func_editor_can_undo() != 52062) {
1332
+ return InitializationResult.apiChecksumMismatch
1333
+ }
1334
+ if (uniffi_editor_core_checksum_func_editor_core_version() != 41638) {
1335
+ return InitializationResult.apiChecksumMismatch
1336
+ }
1337
+ if (uniffi_editor_core_checksum_func_editor_create() != 19812) {
1338
+ return InitializationResult.apiChecksumMismatch
1339
+ }
1340
+ if (uniffi_editor_core_checksum_func_editor_delete_and_split_scalar() != 13764) {
1341
+ return InitializationResult.apiChecksumMismatch
1342
+ }
1343
+ if (uniffi_editor_core_checksum_func_editor_delete_backward_at_selection_scalar() != 7697) {
1344
+ return InitializationResult.apiChecksumMismatch
1345
+ }
1346
+ if (uniffi_editor_core_checksum_func_editor_delete_range() != 6109) {
1347
+ return InitializationResult.apiChecksumMismatch
1348
+ }
1349
+ if (uniffi_editor_core_checksum_func_editor_delete_scalar_range() != 60098) {
1350
+ return InitializationResult.apiChecksumMismatch
1351
+ }
1352
+ if (uniffi_editor_core_checksum_func_editor_destroy() != 35774) {
1353
+ return InitializationResult.apiChecksumMismatch
1354
+ }
1355
+ if (uniffi_editor_core_checksum_func_editor_doc_to_scalar() != 48291) {
1356
+ return InitializationResult.apiChecksumMismatch
1357
+ }
1358
+ if (uniffi_editor_core_checksum_func_editor_get_content_snapshot() != 32837) {
1359
+ return InitializationResult.apiChecksumMismatch
1360
+ }
1361
+ if (uniffi_editor_core_checksum_func_editor_get_current_state() != 13946) {
1362
+ return InitializationResult.apiChecksumMismatch
1363
+ }
1364
+ if (uniffi_editor_core_checksum_func_editor_get_html() != 28868) {
1365
+ return InitializationResult.apiChecksumMismatch
1366
+ }
1367
+ if (uniffi_editor_core_checksum_func_editor_get_json() != 8212) {
1368
+ return InitializationResult.apiChecksumMismatch
1369
+ }
1370
+ if (uniffi_editor_core_checksum_func_editor_get_selection() != 20571) {
1371
+ return InitializationResult.apiChecksumMismatch
1372
+ }
1373
+ if (uniffi_editor_core_checksum_func_editor_get_selection_state() != 16471) {
1374
+ return InitializationResult.apiChecksumMismatch
1375
+ }
1376
+ if (uniffi_editor_core_checksum_func_editor_indent_list_item() != 10818) {
1377
+ return InitializationResult.apiChecksumMismatch
1378
+ }
1379
+ if (uniffi_editor_core_checksum_func_editor_indent_list_item_at_selection_scalar() != 13664) {
1380
+ return InitializationResult.apiChecksumMismatch
1381
+ }
1382
+ if (uniffi_editor_core_checksum_func_editor_insert_content_html() != 62700) {
1383
+ return InitializationResult.apiChecksumMismatch
1384
+ }
1385
+ if (uniffi_editor_core_checksum_func_editor_insert_content_json() != 56904) {
1386
+ return InitializationResult.apiChecksumMismatch
1387
+ }
1388
+ if (uniffi_editor_core_checksum_func_editor_insert_content_json_at_selection_scalar() != 51362) {
1389
+ return InitializationResult.apiChecksumMismatch
1390
+ }
1391
+ if (uniffi_editor_core_checksum_func_editor_insert_node() != 22371) {
1392
+ return InitializationResult.apiChecksumMismatch
1393
+ }
1394
+ if (uniffi_editor_core_checksum_func_editor_insert_node_at_selection_scalar() != 32254) {
1395
+ return InitializationResult.apiChecksumMismatch
1396
+ }
1397
+ if (uniffi_editor_core_checksum_func_editor_insert_text() != 22584) {
1398
+ return InitializationResult.apiChecksumMismatch
1399
+ }
1400
+ if (uniffi_editor_core_checksum_func_editor_insert_text_scalar() != 30263) {
1401
+ return InitializationResult.apiChecksumMismatch
1402
+ }
1403
+ if (uniffi_editor_core_checksum_func_editor_outdent_list_item() != 55796) {
1404
+ return InitializationResult.apiChecksumMismatch
1405
+ }
1406
+ if (uniffi_editor_core_checksum_func_editor_outdent_list_item_at_selection_scalar() != 32672) {
1407
+ return InitializationResult.apiChecksumMismatch
1408
+ }
1409
+ if (uniffi_editor_core_checksum_func_editor_redo() != 26508) {
1410
+ return InitializationResult.apiChecksumMismatch
1411
+ }
1412
+ if (uniffi_editor_core_checksum_func_editor_replace_html() != 41778) {
1413
+ return InitializationResult.apiChecksumMismatch
1414
+ }
1415
+ if (uniffi_editor_core_checksum_func_editor_replace_json() != 28738) {
1416
+ return InitializationResult.apiChecksumMismatch
1417
+ }
1418
+ if (uniffi_editor_core_checksum_func_editor_replace_selection_text() != 11138) {
1419
+ return InitializationResult.apiChecksumMismatch
1420
+ }
1421
+ if (uniffi_editor_core_checksum_func_editor_replace_text_scalar() != 45475) {
1422
+ return InitializationResult.apiChecksumMismatch
1423
+ }
1424
+ if (uniffi_editor_core_checksum_func_editor_resize_image_at_doc_pos() != 36353) {
1425
+ return InitializationResult.apiChecksumMismatch
1426
+ }
1427
+ if (uniffi_editor_core_checksum_func_editor_scalar_to_doc() != 40126) {
1428
+ return InitializationResult.apiChecksumMismatch
1429
+ }
1430
+ if (uniffi_editor_core_checksum_func_editor_set_html() != 11045) {
1431
+ return InitializationResult.apiChecksumMismatch
1432
+ }
1433
+ if (uniffi_editor_core_checksum_func_editor_set_json() != 18497) {
1434
+ return InitializationResult.apiChecksumMismatch
1435
+ }
1436
+ if (uniffi_editor_core_checksum_func_editor_set_mark() != 29349) {
1437
+ return InitializationResult.apiChecksumMismatch
1438
+ }
1439
+ if (uniffi_editor_core_checksum_func_editor_set_mark_at_selection_scalar() != 43994) {
1440
+ return InitializationResult.apiChecksumMismatch
1441
+ }
1442
+ if (uniffi_editor_core_checksum_func_editor_set_selection() != 28236) {
1443
+ return InitializationResult.apiChecksumMismatch
1444
+ }
1445
+ if (uniffi_editor_core_checksum_func_editor_set_selection_scalar() != 16443) {
1446
+ return InitializationResult.apiChecksumMismatch
1447
+ }
1448
+ if (uniffi_editor_core_checksum_func_editor_split_block() != 52038) {
1449
+ return InitializationResult.apiChecksumMismatch
1450
+ }
1451
+ if (uniffi_editor_core_checksum_func_editor_split_block_scalar() != 47554) {
1452
+ return InitializationResult.apiChecksumMismatch
1453
+ }
1454
+ if (uniffi_editor_core_checksum_func_editor_toggle_blockquote() != 25804) {
1455
+ return InitializationResult.apiChecksumMismatch
1456
+ }
1457
+ if (uniffi_editor_core_checksum_func_editor_toggle_blockquote_at_selection_scalar() != 58523) {
1458
+ return InitializationResult.apiChecksumMismatch
1459
+ }
1460
+ if (uniffi_editor_core_checksum_func_editor_toggle_heading() != 7099) {
1461
+ return InitializationResult.apiChecksumMismatch
1462
+ }
1463
+ if (uniffi_editor_core_checksum_func_editor_toggle_heading_at_selection_scalar() != 54315) {
1464
+ return InitializationResult.apiChecksumMismatch
1465
+ }
1466
+ if (uniffi_editor_core_checksum_func_editor_toggle_mark() != 30661) {
1467
+ return InitializationResult.apiChecksumMismatch
1468
+ }
1469
+ if (uniffi_editor_core_checksum_func_editor_toggle_mark_at_selection_scalar() != 61751) {
1470
+ return InitializationResult.apiChecksumMismatch
1471
+ }
1472
+ if (uniffi_editor_core_checksum_func_editor_toggle_task_item_checked_at_selection_scalar() != 1217) {
1473
+ return InitializationResult.apiChecksumMismatch
1474
+ }
1475
+ if (uniffi_editor_core_checksum_func_editor_undo() != 28689) {
1476
+ return InitializationResult.apiChecksumMismatch
1477
+ }
1478
+ if (uniffi_editor_core_checksum_func_editor_unset_mark() != 47985) {
1479
+ return InitializationResult.apiChecksumMismatch
1480
+ }
1481
+ if (uniffi_editor_core_checksum_func_editor_unset_mark_at_selection_scalar() != 54992) {
1482
+ return InitializationResult.apiChecksumMismatch
1483
+ }
1484
+ if (uniffi_editor_core_checksum_func_editor_unwrap_from_list() != 41875) {
1485
+ return InitializationResult.apiChecksumMismatch
1486
+ }
1487
+ if (uniffi_editor_core_checksum_func_editor_unwrap_from_list_at_selection_scalar() != 57899) {
1488
+ return InitializationResult.apiChecksumMismatch
1489
+ }
1490
+ if (uniffi_editor_core_checksum_func_editor_wrap_in_list() != 32846) {
1491
+ return InitializationResult.apiChecksumMismatch
1492
+ }
1493
+ if (uniffi_editor_core_checksum_func_editor_wrap_in_list_at_selection_scalar() != 6459) {
1494
+ return InitializationResult.apiChecksumMismatch
1495
+ }
1496
+
1497
+ return InitializationResult.ok
1498
+ }()
1499
+
1500
+ // Make the ensure init function public so that other modules which have external type references to
1501
+ // our types can call it.
1502
+ public func uniffiEnsureEditorCoreInitialized() {
1503
+ switch initializationResult {
1504
+ case .ok:
1505
+ break
1506
+ case .contractVersionMismatch:
1507
+ fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
1508
+ case .apiChecksumMismatch:
1509
+ fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1510
+ }
1511
+ }
1512
+
1513
+ // swiftlint:enable all