@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,933 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NativeCollaborationBridge = exports.NativeEditorBridge = void 0;
4
+ exports.normalizeActiveState = normalizeActiveState;
5
+ exports.parseEditorUpdateJson = parseEditorUpdateJson;
6
+ exports.encodeCollaborationStateBase64 = encodeCollaborationStateBase64;
7
+ exports.decodeCollaborationStateBase64 = decodeCollaborationStateBase64;
8
+ exports.parseCollaborationResultJson = parseCollaborationResultJson;
9
+ exports._resetNativeModuleCache = _resetNativeModuleCache;
10
+ const expo_modules_core_1 = require("expo-modules-core");
11
+ const react_native_1 = require("react-native");
12
+ const schemas_1 = require("./schemas");
13
+ const ERR_DESTROYED = 'NativeEditorBridge: editor has been destroyed';
14
+ const ERR_NATIVE_RESPONSE = 'NativeEditorBridge: invalid JSON response from native module';
15
+ const ERR_INVALID_ENCODED_STATE = 'NativeEditorBridge: invalid encoded collaboration state';
16
+ const BASE64_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
17
+ function normalizeActiveState(raw) {
18
+ const obj = raw ?? {};
19
+ return {
20
+ marks: (obj.marks ?? {}),
21
+ markAttrs: (obj.markAttrs ?? {}),
22
+ nodes: (obj.nodes ?? {}),
23
+ commands: (obj.commands ?? {}),
24
+ allowedMarks: (obj.allowedMarks ?? []),
25
+ insertableNodes: (obj.insertableNodes ?? []),
26
+ };
27
+ }
28
+ function parseRenderElements(json) {
29
+ if (!json || json === '[]')
30
+ return [];
31
+ try {
32
+ const parsed = JSON.parse(json);
33
+ if (parsed != null &&
34
+ typeof parsed === 'object' &&
35
+ !Array.isArray(parsed) &&
36
+ 'error' in parsed) {
37
+ throw new Error(`NativeEditorBridge: ${parsed.error}`);
38
+ }
39
+ if (!Array.isArray(parsed)) {
40
+ throw new Error(ERR_NATIVE_RESPONSE);
41
+ }
42
+ return parsed;
43
+ }
44
+ catch (e) {
45
+ if (e instanceof Error && e.message.startsWith('NativeEditorBridge:')) {
46
+ throw e;
47
+ }
48
+ throw new Error(ERR_NATIVE_RESPONSE);
49
+ }
50
+ }
51
+ function parseEditorUpdateJson(json, previousRenderBlocks) {
52
+ if (!json || json === '')
53
+ return null;
54
+ try {
55
+ const parsed = JSON.parse(json);
56
+ if ('error' in parsed) {
57
+ throw new Error(`NativeEditorBridge: ${parsed.error}`);
58
+ }
59
+ const renderBlocks = Array.isArray(parsed.renderBlocks)
60
+ ? parsed.renderBlocks
61
+ : applyRenderBlocksPatch(previousRenderBlocks, parsed.renderPatch != null && typeof parsed.renderPatch === 'object'
62
+ ? parsed.renderPatch
63
+ : undefined);
64
+ const renderPatch = parsed.renderPatch != null && typeof parsed.renderPatch === 'object'
65
+ ? parsed.renderPatch
66
+ : undefined;
67
+ return {
68
+ renderElements: Array.isArray(parsed.renderElements)
69
+ ? parsed.renderElements
70
+ : flattenRenderBlocks(renderBlocks),
71
+ renderBlocks,
72
+ renderPatch,
73
+ selection: (parsed.selection ?? { type: 'text', anchor: 0, head: 0 }),
74
+ activeState: normalizeActiveState(parsed.activeState),
75
+ historyState: (parsed.historyState ?? {
76
+ canUndo: false,
77
+ canRedo: false,
78
+ }),
79
+ documentVersion: typeof parsed.documentVersion === 'number' ? parsed.documentVersion : undefined,
80
+ };
81
+ }
82
+ catch (e) {
83
+ if (e instanceof Error && e.message.startsWith('NativeEditorBridge:')) {
84
+ throw e;
85
+ }
86
+ throw new Error(ERR_NATIVE_RESPONSE);
87
+ }
88
+ }
89
+ function flattenRenderBlocks(renderBlocks) {
90
+ if (!renderBlocks || renderBlocks.length === 0) {
91
+ return [];
92
+ }
93
+ return renderBlocks.flat();
94
+ }
95
+ function applyRenderBlocksPatch(previousRenderBlocks, renderPatch) {
96
+ if (!previousRenderBlocks || !renderPatch) {
97
+ return undefined;
98
+ }
99
+ const { startIndex, deleteCount, renderBlocks } = renderPatch;
100
+ if (!Number.isInteger(startIndex) ||
101
+ !Number.isInteger(deleteCount) ||
102
+ startIndex < 0 ||
103
+ deleteCount < 0 ||
104
+ startIndex > previousRenderBlocks.length ||
105
+ startIndex + deleteCount > previousRenderBlocks.length) {
106
+ return undefined;
107
+ }
108
+ return [
109
+ ...previousRenderBlocks.slice(0, startIndex),
110
+ ...renderBlocks,
111
+ ...previousRenderBlocks.slice(startIndex + deleteCount),
112
+ ];
113
+ }
114
+ function parseContentSnapshotJson(json) {
115
+ try {
116
+ const parsed = JSON.parse(json);
117
+ if ('error' in parsed) {
118
+ throw new Error(`NativeEditorBridge: ${parsed.error}`);
119
+ }
120
+ return {
121
+ html: typeof parsed.html === 'string' ? parsed.html : '',
122
+ json: parsed.json != null && typeof parsed.json === 'object'
123
+ ? parsed.json
124
+ : {},
125
+ };
126
+ }
127
+ catch (e) {
128
+ if (e instanceof Error && e.message.startsWith('NativeEditorBridge:')) {
129
+ throw e;
130
+ }
131
+ throw new Error(ERR_NATIVE_RESPONSE);
132
+ }
133
+ }
134
+ function parseDocumentJSON(json) {
135
+ if (!json || json === '{}')
136
+ return {};
137
+ try {
138
+ const parsed = JSON.parse(json);
139
+ if (parsed != null &&
140
+ typeof parsed === 'object' &&
141
+ 'error' in parsed) {
142
+ throw new Error(`NativeEditorBridge: ${parsed.error}`);
143
+ }
144
+ return parsed;
145
+ }
146
+ catch (e) {
147
+ if (e instanceof Error && e.message.startsWith('NativeEditorBridge:')) {
148
+ throw e;
149
+ }
150
+ throw new Error(ERR_NATIVE_RESPONSE);
151
+ }
152
+ }
153
+ function parseCollaborationPeersJson(json) {
154
+ if (!json || json === '[]')
155
+ return [];
156
+ try {
157
+ const parsed = JSON.parse(json);
158
+ return Array.isArray(parsed) ? parsed : [];
159
+ }
160
+ catch {
161
+ throw new Error(ERR_NATIVE_RESPONSE);
162
+ }
163
+ }
164
+ function parseByteArrayJson(json) {
165
+ if (!json || json === '[]')
166
+ return new Uint8Array();
167
+ try {
168
+ const parsed = JSON.parse(json);
169
+ if (!Array.isArray(parsed)) {
170
+ throw new Error(ERR_NATIVE_RESPONSE);
171
+ }
172
+ return Uint8Array.from(parsed);
173
+ }
174
+ catch (e) {
175
+ if (e instanceof Error && e.message.startsWith('NativeEditorBridge:')) {
176
+ throw e;
177
+ }
178
+ throw new Error(ERR_NATIVE_RESPONSE);
179
+ }
180
+ }
181
+ function bytesToBase64(bytes) {
182
+ let output = '';
183
+ for (let index = 0; index < bytes.length; index += 3) {
184
+ const byte1 = bytes[index] ?? 0;
185
+ const byte2 = bytes[index + 1] ?? 0;
186
+ const byte3 = bytes[index + 2] ?? 0;
187
+ const chunk = (byte1 << 16) | (byte2 << 8) | byte3;
188
+ output += BASE64_ALPHABET[(chunk >> 18) & 0x3f];
189
+ output += BASE64_ALPHABET[(chunk >> 12) & 0x3f];
190
+ output += index + 1 < bytes.length ? BASE64_ALPHABET[(chunk >> 6) & 0x3f] : '=';
191
+ output += index + 2 < bytes.length ? BASE64_ALPHABET[chunk & 0x3f] : '=';
192
+ }
193
+ return output;
194
+ }
195
+ function base64ToBytes(base64) {
196
+ const normalized = base64.replace(/\s+/g, '');
197
+ if (normalized.length === 0)
198
+ return new Uint8Array();
199
+ if (normalized.length % 4 === 1) {
200
+ throw new Error(ERR_INVALID_ENCODED_STATE);
201
+ }
202
+ const bytes = [];
203
+ for (let index = 0; index < normalized.length; index += 4) {
204
+ const chunk = normalized.slice(index, index + 4);
205
+ const values = chunk.split('').map((char, charIndex) => {
206
+ if (char === '=') {
207
+ return charIndex >= 2 ? 0 : -1;
208
+ }
209
+ const value = BASE64_ALPHABET.indexOf(char);
210
+ return value;
211
+ });
212
+ if (values[0] < 0 || values[1] < 0 || values.some((value) => value < 0)) {
213
+ throw new Error(ERR_INVALID_ENCODED_STATE);
214
+ }
215
+ const combined = (values[0] << 18) | (values[1] << 12) | (values[2] << 6) | values[3];
216
+ bytes.push((combined >> 16) & 0xff);
217
+ if (chunk[2] !== '=') {
218
+ bytes.push((combined >> 8) & 0xff);
219
+ }
220
+ if (chunk[3] !== '=') {
221
+ bytes.push(combined & 0xff);
222
+ }
223
+ }
224
+ return Uint8Array.from(bytes);
225
+ }
226
+ function normalizeEncodedStateInput(encodedState) {
227
+ if (typeof encodedState === 'string') {
228
+ return Array.from(base64ToBytes(encodedState));
229
+ }
230
+ return Array.from(encodedState);
231
+ }
232
+ function encodeCollaborationStateBase64(encodedState) {
233
+ return bytesToBase64(normalizeEncodedStateInput(encodedState));
234
+ }
235
+ function decodeCollaborationStateBase64(base64) {
236
+ return base64ToBytes(base64);
237
+ }
238
+ function normalizeDocumentJsonString(jsonString, schema) {
239
+ try {
240
+ const parsed = JSON.parse(jsonString);
241
+ const normalized = (0, schemas_1.normalizeDocumentJson)(parsed, schema);
242
+ return normalized === parsed ? jsonString : JSON.stringify(normalized);
243
+ }
244
+ catch {
245
+ return jsonString;
246
+ }
247
+ }
248
+ function parseCommandPreparationJson(json) {
249
+ if (!json)
250
+ return { ready: true };
251
+ let parsed;
252
+ try {
253
+ parsed = JSON.parse(json);
254
+ }
255
+ catch {
256
+ throw new Error(ERR_NATIVE_RESPONSE);
257
+ }
258
+ if (typeof parsed.error === 'string') {
259
+ throw new Error(`NativeEditorBridge: ${parsed.error}`);
260
+ }
261
+ const rawBlockedReason = parsed.blockedReason;
262
+ const blockedReason = rawBlockedReason === 'composition' ||
263
+ rawBlockedReason === 'detached' ||
264
+ rawBlockedReason === 'pendingUpdate' ||
265
+ rawBlockedReason === 'destroyed'
266
+ ? rawBlockedReason
267
+ : rawBlockedReason === 'unknown'
268
+ ? 'unknown'
269
+ : undefined;
270
+ return {
271
+ ready: parsed.ready !== false,
272
+ updateJSON: typeof parsed.updateJSON === 'string' ? parsed.updateJSON : undefined,
273
+ blockedReason,
274
+ };
275
+ }
276
+ function parseCollaborationResultJson(json) {
277
+ if (!json || json === '') {
278
+ return {
279
+ messages: [],
280
+ documentChanged: false,
281
+ peersChanged: false,
282
+ };
283
+ }
284
+ try {
285
+ const parsed = JSON.parse(json);
286
+ if ('error' in parsed) {
287
+ throw new Error(`NativeEditorBridge: ${parsed.error}`);
288
+ }
289
+ return {
290
+ messages: Array.isArray(parsed.messages) ? parsed.messages : [],
291
+ documentChanged: parsed.documentChanged === true,
292
+ documentJson: parsed.documentJson && typeof parsed.documentJson === 'object'
293
+ ? parsed.documentJson
294
+ : undefined,
295
+ peersChanged: parsed.peersChanged === true,
296
+ peers: Array.isArray(parsed.peers) ? parsed.peers : undefined,
297
+ };
298
+ }
299
+ catch (e) {
300
+ if (e instanceof Error && e.message.startsWith('NativeEditorBridge:')) {
301
+ throw e;
302
+ }
303
+ throw new Error(ERR_NATIVE_RESPONSE);
304
+ }
305
+ }
306
+ let _nativeModule = null;
307
+ function getNativeModule() {
308
+ if (!_nativeModule) {
309
+ _nativeModule = (0, expo_modules_core_1.requireNativeModule)('NativeEditor');
310
+ }
311
+ return _nativeModule;
312
+ }
313
+ /** @internal Reset the cached native module reference. For testing only. */
314
+ function _resetNativeModuleCache() {
315
+ _nativeModule = null;
316
+ }
317
+ class NativeEditorBridge {
318
+ constructor(editorId, schema) {
319
+ this._destroyed = false;
320
+ this._lastSelection = { type: 'text', anchor: 0, head: 0 };
321
+ this._documentVersion = 0;
322
+ this._cachedHtml = null;
323
+ this._cachedJsonString = null;
324
+ this._renderBlocksCache = null;
325
+ this._lastCommandBlocked = false;
326
+ this._lastCommandBlockedReason = null;
327
+ this._lastCommandPreflightUpdate = null;
328
+ this._lastAcceptedUpdateJson = null;
329
+ this._hasSeenDocumentVersion = false;
330
+ this._editorId = editorId;
331
+ this._schema = schema;
332
+ }
333
+ /** Create a new editor instance backed by the Rust engine. */
334
+ static create(config) {
335
+ const configObj = {};
336
+ let parsedSchema;
337
+ if (config?.maxLength != null)
338
+ configObj.maxLength = config.maxLength;
339
+ if (config?.allowBase64Images != null) {
340
+ configObj.allowBase64Images = config.allowBase64Images;
341
+ }
342
+ if (config?.schemaJson != null) {
343
+ try {
344
+ parsedSchema = JSON.parse(config.schemaJson);
345
+ configObj.schema = parsedSchema;
346
+ }
347
+ catch {
348
+ // Fall back to the default schema when the provided JSON is invalid.
349
+ }
350
+ }
351
+ const id = getNativeModule().editorCreate(JSON.stringify(configObj));
352
+ return new NativeEditorBridge(id, parsedSchema);
353
+ }
354
+ /** The underlying native editor ID. */
355
+ get editorId() {
356
+ return this._editorId;
357
+ }
358
+ /** Whether this bridge has been destroyed. */
359
+ get isDestroyed() {
360
+ return this._destroyed;
361
+ }
362
+ consumeLastCommandBlocked() {
363
+ const blocked = this._lastCommandBlocked;
364
+ this._lastCommandBlocked = false;
365
+ this._lastCommandBlockedReason = null;
366
+ return blocked;
367
+ }
368
+ consumeLastCommandBlockedReason() {
369
+ const reason = this._lastCommandBlockedReason;
370
+ this._lastCommandBlocked = false;
371
+ this._lastCommandBlockedReason = null;
372
+ return reason;
373
+ }
374
+ consumeLastCommandBlockedInfo() {
375
+ const info = {
376
+ blocked: this._lastCommandBlocked,
377
+ reason: this._lastCommandBlockedReason,
378
+ };
379
+ this._lastCommandBlocked = false;
380
+ this._lastCommandBlockedReason = null;
381
+ return info;
382
+ }
383
+ consumeLastCommandPreflightUpdate() {
384
+ const update = this._lastCommandPreflightUpdate;
385
+ this._lastCommandPreflightUpdate = null;
386
+ return update;
387
+ }
388
+ prepareForNativeCommand() {
389
+ this.assertNotDestroyed();
390
+ return this.prepareForCommand();
391
+ }
392
+ /** Destroy the editor instance and free native resources. */
393
+ destroy() {
394
+ if (this._destroyed)
395
+ return;
396
+ this._destroyed = true;
397
+ this._renderBlocksCache = null;
398
+ this._lastCommandBlocked = false;
399
+ this._lastCommandBlockedReason = null;
400
+ this._lastCommandPreflightUpdate = null;
401
+ getNativeModule().editorDestroy(this._editorId);
402
+ }
403
+ /** Set content from HTML. Returns render elements for display. */
404
+ setHtml(html) {
405
+ this.assertNotDestroyed();
406
+ this.invalidateContentCaches();
407
+ this._renderBlocksCache = null;
408
+ const json = getNativeModule().editorSetHtml(this._editorId, html);
409
+ return parseRenderElements(json);
410
+ }
411
+ /** Get content as HTML. */
412
+ getHtml() {
413
+ this.assertNotDestroyed();
414
+ if (this._cachedHtml?.version === this._documentVersion) {
415
+ return this._cachedHtml.value;
416
+ }
417
+ const html = getNativeModule().editorGetHtml(this._editorId);
418
+ this._cachedHtml = { version: this._documentVersion, value: html };
419
+ return html;
420
+ }
421
+ /** Get cached HTML without making a native roundtrip. */
422
+ getCachedHtml() {
423
+ this.assertNotDestroyed();
424
+ return this._cachedHtml?.value ?? null;
425
+ }
426
+ /** Set content from ProseMirror JSON. Returns render elements. */
427
+ setJson(doc) {
428
+ return this.setJsonString(JSON.stringify((0, schemas_1.normalizeDocumentJson)(doc, this._schema)));
429
+ }
430
+ /** Set content from a serialized ProseMirror JSON string. Returns render elements. */
431
+ setJsonString(jsonString) {
432
+ this.assertNotDestroyed();
433
+ this.invalidateContentCaches();
434
+ this._renderBlocksCache = null;
435
+ const normalizedJsonString = normalizeDocumentJsonString(jsonString, this._schema);
436
+ const json = getNativeModule().editorSetJson(this._editorId, normalizedJsonString);
437
+ return parseRenderElements(json);
438
+ }
439
+ /** Get content as raw ProseMirror JSON string. */
440
+ getJsonString() {
441
+ this.assertNotDestroyed();
442
+ if (this._cachedJsonString?.version === this._documentVersion) {
443
+ return this._cachedJsonString.value;
444
+ }
445
+ const json = getNativeModule().editorGetJson(this._editorId);
446
+ this._cachedJsonString = { version: this._documentVersion, value: json };
447
+ return json;
448
+ }
449
+ /** Get cached raw ProseMirror JSON without making a native roundtrip. */
450
+ getCachedJsonString() {
451
+ this.assertNotDestroyed();
452
+ return this._cachedJsonString?.value ?? null;
453
+ }
454
+ /** Get cached ProseMirror JSON without making a native roundtrip. */
455
+ getCachedJson() {
456
+ const json = this.getCachedJsonString();
457
+ return json == null ? null : parseDocumentJSON(json);
458
+ }
459
+ /** Get content as ProseMirror JSON. */
460
+ getJson() {
461
+ return parseDocumentJSON(this.getJsonString());
462
+ }
463
+ /** Get both HTML and JSON content in one native roundtrip. */
464
+ getContentSnapshot() {
465
+ this.assertNotDestroyed();
466
+ if (this._cachedHtml?.version === this._documentVersion &&
467
+ this._cachedJsonString?.version === this._documentVersion) {
468
+ return {
469
+ html: this._cachedHtml.value,
470
+ json: parseDocumentJSON(this._cachedJsonString.value),
471
+ };
472
+ }
473
+ const snapshot = parseContentSnapshotJson(getNativeModule().editorGetContentSnapshot(this._editorId));
474
+ this._cachedHtml = { version: this._documentVersion, value: snapshot.html };
475
+ this._cachedJsonString = {
476
+ version: this._documentVersion,
477
+ value: JSON.stringify(snapshot.json),
478
+ };
479
+ return snapshot;
480
+ }
481
+ /** Insert text at a document position. Returns the full update. */
482
+ insertText(pos, text) {
483
+ this.assertNotDestroyed();
484
+ return this.runPreparedCommand(() => getNativeModule().editorInsertText(this._editorId, pos, text));
485
+ }
486
+ /** Delete a range [from, to). Returns the full update. */
487
+ deleteRange(from, to) {
488
+ this.assertNotDestroyed();
489
+ return this.runPreparedCommand(() => getNativeModule().editorDeleteRange(this._editorId, from, to));
490
+ }
491
+ /** Replace the current selection with text atomically. */
492
+ replaceSelectionText(text) {
493
+ this.assertNotDestroyed();
494
+ return this.runPreparedCommand(() => getNativeModule().editorReplaceSelectionText(this._editorId, text));
495
+ }
496
+ /** Toggle a mark (bold, italic, etc.) on the current selection. */
497
+ toggleMark(markType) {
498
+ this.assertNotDestroyed();
499
+ return this.runPreparedCommand(() => {
500
+ const scalarSelection = this.currentScalarSelection();
501
+ return scalarSelection
502
+ ? getNativeModule().editorToggleMarkAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head, markType)
503
+ : getNativeModule().editorToggleMark(this._editorId, markType);
504
+ }, { refreshSelectionAfterPreflight: true });
505
+ }
506
+ /** Set a mark with attrs on the current selection. */
507
+ setMark(markType, attrs) {
508
+ this.assertNotDestroyed();
509
+ const attrsJson = JSON.stringify(attrs);
510
+ return this.runPreparedCommand(() => {
511
+ const scalarSelection = this.currentScalarSelection();
512
+ return scalarSelection
513
+ ? getNativeModule().editorSetMarkAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head, markType, attrsJson)
514
+ : getNativeModule().editorSetMark(this._editorId, markType, attrsJson);
515
+ }, { refreshSelectionAfterPreflight: true });
516
+ }
517
+ /** Set a mark with attrs at an explicit scalar selection. */
518
+ setMarkAtSelectionScalar(scalarAnchor, scalarHead, markType, attrs) {
519
+ this.assertNotDestroyed();
520
+ return this.runPreparedCommand(() => getNativeModule().editorSetMarkAtSelectionScalar(this._editorId, scalarAnchor, scalarHead, markType, JSON.stringify(attrs)), { cancelIfPreflightUpdated: true });
521
+ }
522
+ /** Remove a mark from the current selection. */
523
+ unsetMark(markType) {
524
+ this.assertNotDestroyed();
525
+ return this.runPreparedCommand(() => {
526
+ const scalarSelection = this.currentScalarSelection();
527
+ return scalarSelection
528
+ ? getNativeModule().editorUnsetMarkAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head, markType)
529
+ : getNativeModule().editorUnsetMark(this._editorId, markType);
530
+ }, { refreshSelectionAfterPreflight: true });
531
+ }
532
+ /** Remove a mark at an explicit scalar selection. */
533
+ unsetMarkAtSelectionScalar(scalarAnchor, scalarHead, markType) {
534
+ this.assertNotDestroyed();
535
+ return this.runPreparedCommand(() => getNativeModule().editorUnsetMarkAtSelectionScalar(this._editorId, scalarAnchor, scalarHead, markType), { cancelIfPreflightUpdated: true });
536
+ }
537
+ /** Toggle blockquote wrapping for the current block selection. */
538
+ toggleBlockquote() {
539
+ this.assertNotDestroyed();
540
+ return this.runPreparedCommand(() => {
541
+ const scalarSelection = this.currentScalarSelection();
542
+ return scalarSelection
543
+ ? getNativeModule().editorToggleBlockquoteAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head)
544
+ : getNativeModule().editorToggleBlockquote(this._editorId);
545
+ }, { refreshSelectionAfterPreflight: true });
546
+ }
547
+ /** Toggle a heading level on the current block selection. */
548
+ toggleHeading(level) {
549
+ this.assertNotDestroyed();
550
+ if (!Number.isInteger(level) || level < 1 || level > 6) {
551
+ throw new Error('NativeEditorBridge: invalid heading level');
552
+ }
553
+ return this.runPreparedCommand(() => {
554
+ const scalarSelection = this.currentScalarSelection();
555
+ return scalarSelection
556
+ ? getNativeModule().editorToggleHeadingAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head, level)
557
+ : getNativeModule().editorToggleHeading(this._editorId, level);
558
+ }, { refreshSelectionAfterPreflight: true });
559
+ }
560
+ /** Set the document selection by anchor and head positions. */
561
+ setSelection(anchor, head) {
562
+ this.assertNotDestroyed();
563
+ getNativeModule().editorSetSelection(this._editorId, anchor, head);
564
+ this._lastSelection = { type: 'text', anchor, head };
565
+ }
566
+ /** Convert a document position to a scalar position used by native text views. */
567
+ docToScalar(docPos) {
568
+ this.assertNotDestroyed();
569
+ return getNativeModule().editorDocToScalar(this._editorId, docPos);
570
+ }
571
+ /** Convert a native scalar position back to a document position. */
572
+ scalarToDoc(scalar) {
573
+ this.assertNotDestroyed();
574
+ return getNativeModule().editorScalarToDoc(this._editorId, scalar);
575
+ }
576
+ /** Get the current selection from the Rust engine (synchronous native call).
577
+ * Always returns the live selection, not a stale cache. */
578
+ getSelection() {
579
+ if (this._destroyed)
580
+ return { type: 'text', anchor: 0, head: 0 };
581
+ try {
582
+ const json = getNativeModule().editorGetSelection(this._editorId);
583
+ const sel = JSON.parse(json);
584
+ this._lastSelection = sel;
585
+ return sel;
586
+ }
587
+ catch {
588
+ return this._lastSelection;
589
+ }
590
+ }
591
+ /** Update the cached selection from native events (scalar offsets).
592
+ * Called by the React component when native selection change events arrive. */
593
+ updateSelectionFromNative(anchor, head) {
594
+ if (this._destroyed)
595
+ return;
596
+ this._lastSelection = { type: 'text', anchor, head };
597
+ }
598
+ /** Get the current full state from Rust (render elements, selection, etc.). */
599
+ getCurrentState() {
600
+ this.assertNotDestroyed();
601
+ const json = getNativeModule().editorGetCurrentState(this._editorId);
602
+ return this.parseAndNoteUpdate(json);
603
+ }
604
+ /** Get the current selection-related state without render elements. */
605
+ getSelectionState() {
606
+ this.assertNotDestroyed();
607
+ const json = getNativeModule().editorGetSelectionState(this._editorId);
608
+ return this.parseAndNoteUpdate(json);
609
+ }
610
+ /** Split the block at a position (Enter key). */
611
+ splitBlock(pos) {
612
+ this.assertNotDestroyed();
613
+ return this.runPreparedCommand(() => getNativeModule().editorSplitBlock(this._editorId, pos));
614
+ }
615
+ /** Insert HTML content at the current selection. */
616
+ insertContentHtml(html) {
617
+ this.assertNotDestroyed();
618
+ return this.runPreparedCommand(() => getNativeModule().editorInsertContentHtml(this._editorId, html));
619
+ }
620
+ /** Insert JSON content at the current selection. */
621
+ insertContentJson(doc) {
622
+ this.assertNotDestroyed();
623
+ return this.runPreparedCommand(() => getNativeModule().editorInsertContentJson(this._editorId, JSON.stringify(doc)));
624
+ }
625
+ /** Insert JSON content at an explicit scalar selection. */
626
+ insertContentJsonAtSelectionScalar(scalarAnchor, scalarHead, doc) {
627
+ return this.insertContentJsonAtSelectionScalarLazy(scalarAnchor, scalarHead, () => doc);
628
+ }
629
+ /** Insert lazily-built JSON content at an explicit scalar selection. */
630
+ insertContentJsonAtSelectionScalarLazy(scalarAnchor, scalarHead, resolveDoc) {
631
+ this.assertNotDestroyed();
632
+ return this.runPreparedCommand(() => getNativeModule().editorInsertContentJsonAtSelectionScalar(this._editorId, scalarAnchor, scalarHead, JSON.stringify(resolveDoc())), { cancelIfPreflightUpdated: true });
633
+ }
634
+ /** Replace entire document with HTML via transaction (preserves undo history). */
635
+ replaceHtml(html) {
636
+ this.assertNotDestroyed();
637
+ return this.runPreparedCommand(() => getNativeModule().editorReplaceHtml(this._editorId, html));
638
+ }
639
+ /** Replace entire document with JSON via transaction (preserves undo history). */
640
+ replaceJson(doc) {
641
+ return this.replaceJsonString(JSON.stringify((0, schemas_1.normalizeDocumentJson)(doc, this._schema)));
642
+ }
643
+ /** Replace entire document with a serialized JSON transaction. */
644
+ replaceJsonString(jsonString) {
645
+ this.assertNotDestroyed();
646
+ const normalizedJsonString = normalizeDocumentJsonString(jsonString, this._schema);
647
+ return this.runPreparedCommand(() => getNativeModule().editorReplaceJson(this._editorId, normalizedJsonString));
648
+ }
649
+ /** Undo the last operation. Returns update or null if nothing to undo. */
650
+ undo() {
651
+ this.assertNotDestroyed();
652
+ return this.runPreparedCommand(() => getNativeModule().editorUndo(this._editorId));
653
+ }
654
+ /** Redo the last undone operation. Returns update or null if nothing to redo. */
655
+ redo() {
656
+ this.assertNotDestroyed();
657
+ return this.runPreparedCommand(() => getNativeModule().editorRedo(this._editorId));
658
+ }
659
+ /** Check if undo is available. */
660
+ canUndo() {
661
+ this.assertNotDestroyed();
662
+ return getNativeModule().editorCanUndo(this._editorId);
663
+ }
664
+ /** Check if redo is available. */
665
+ canRedo() {
666
+ this.assertNotDestroyed();
667
+ return getNativeModule().editorCanRedo(this._editorId);
668
+ }
669
+ /** Toggle a list type on the current selection. Wraps if not in list, unwraps if already in that list type. */
670
+ toggleList(listType) {
671
+ this.assertNotDestroyed();
672
+ return this.runPreparedCommand(() => {
673
+ const isActive = this.getCurrentState()?.activeState?.nodes?.[listType] === true;
674
+ const scalarSelection = this.currentScalarSelection();
675
+ return isActive
676
+ ? scalarSelection
677
+ ? getNativeModule().editorUnwrapFromListAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head)
678
+ : getNativeModule().editorUnwrapFromList(this._editorId)
679
+ : scalarSelection
680
+ ? getNativeModule().editorWrapInListAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head, listType)
681
+ : getNativeModule().editorWrapInList(this._editorId, listType);
682
+ }, { refreshSelectionAfterPreflight: true });
683
+ }
684
+ /** Unwrap the current list item back to a paragraph. */
685
+ unwrapFromList() {
686
+ this.assertNotDestroyed();
687
+ return this.runPreparedCommand(() => {
688
+ const scalarSelection = this.currentScalarSelection();
689
+ return scalarSelection
690
+ ? getNativeModule().editorUnwrapFromListAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head)
691
+ : getNativeModule().editorUnwrapFromList(this._editorId);
692
+ }, { refreshSelectionAfterPreflight: true });
693
+ }
694
+ /** Indent the current list item into a nested list. */
695
+ indentListItem() {
696
+ this.assertNotDestroyed();
697
+ return this.runPreparedCommand(() => {
698
+ const scalarSelection = this.currentScalarSelection();
699
+ return scalarSelection
700
+ ? getNativeModule().editorIndentListItemAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head)
701
+ : getNativeModule().editorIndentListItem(this._editorId);
702
+ }, { refreshSelectionAfterPreflight: true });
703
+ }
704
+ /** Outdent the current list item to the parent list level. */
705
+ outdentListItem() {
706
+ this.assertNotDestroyed();
707
+ return this.runPreparedCommand(() => {
708
+ const scalarSelection = this.currentScalarSelection();
709
+ return scalarSelection
710
+ ? getNativeModule().editorOutdentListItemAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head)
711
+ : getNativeModule().editorOutdentListItem(this._editorId);
712
+ }, { refreshSelectionAfterPreflight: true });
713
+ }
714
+ /** Insert a void node (e.g. 'horizontalRule') at the current selection. */
715
+ insertNode(nodeType) {
716
+ this.assertNotDestroyed();
717
+ return this.runPreparedCommand(() => {
718
+ const scalarSelection = this.currentScalarSelection();
719
+ return scalarSelection
720
+ ? getNativeModule().editorInsertNodeAtSelectionScalar(this._editorId, scalarSelection.anchor, scalarSelection.head, nodeType)
721
+ : getNativeModule().editorInsertNode(this._editorId, nodeType);
722
+ }, { refreshSelectionAfterPreflight: true });
723
+ }
724
+ parseUpdateJson(json, options) {
725
+ this.assertNotDestroyed();
726
+ return this.parseAndNoteUpdate(json, options);
727
+ }
728
+ noteUpdate(update) {
729
+ if (!update) {
730
+ return;
731
+ }
732
+ this._lastSelection = update.selection;
733
+ if (update.renderBlocks) {
734
+ this._renderBlocksCache = update.renderBlocks;
735
+ }
736
+ if (typeof update.documentVersion !== 'number') {
737
+ this.invalidateContentCaches();
738
+ return;
739
+ }
740
+ this._hasSeenDocumentVersion = true;
741
+ if (update.documentVersion !== this._documentVersion) {
742
+ this._documentVersion = update.documentVersion;
743
+ this.invalidateContentCaches();
744
+ }
745
+ }
746
+ shouldRejectUpdate(update, json, options) {
747
+ if (!update) {
748
+ return false;
749
+ }
750
+ if (typeof update.documentVersion !== 'number') {
751
+ return (options?.rejectVersionlessAfterDocumentVersion === true &&
752
+ react_native_1.Platform.OS === 'android' &&
753
+ this._hasSeenDocumentVersion);
754
+ }
755
+ if (react_native_1.Platform.OS === 'android') {
756
+ this._hasSeenDocumentVersion = true;
757
+ }
758
+ if (update.documentVersion < this._documentVersion) {
759
+ return true;
760
+ }
761
+ if (options?.rejectSameDocumentVersion === true) {
762
+ return (update.documentVersion === this._documentVersion &&
763
+ json === this._lastAcceptedUpdateJson);
764
+ }
765
+ return false;
766
+ }
767
+ parseAndNoteUpdate(json, options) {
768
+ let update = parseEditorUpdateJson(json, this._renderBlocksCache ?? undefined);
769
+ if (this.shouldRejectUpdate(update, json, options)) {
770
+ return null;
771
+ }
772
+ if (update?.renderPatch && !update.renderBlocks) {
773
+ json = getNativeModule().editorGetCurrentState(this._editorId);
774
+ update = parseEditorUpdateJson(json, this._renderBlocksCache ?? undefined);
775
+ if (this.shouldRejectUpdate(update, json, options)) {
776
+ return null;
777
+ }
778
+ }
779
+ this.noteUpdate(update);
780
+ if (update) {
781
+ this._lastAcceptedUpdateJson = json;
782
+ }
783
+ return update;
784
+ }
785
+ prepareForCommand() {
786
+ this._lastCommandBlocked = false;
787
+ this._lastCommandBlockedReason = null;
788
+ this._lastCommandPreflightUpdate = null;
789
+ const nativeModule = getNativeModule();
790
+ const prepareForCommand = nativeModule.editorPrepareForCommand;
791
+ if (typeof prepareForCommand !== 'function') {
792
+ return true;
793
+ }
794
+ const preparation = parseCommandPreparationJson(prepareForCommand(this._editorId));
795
+ if (preparation.updateJSON) {
796
+ this._lastCommandPreflightUpdate = this.parseAndNoteUpdate(preparation.updateJSON, {
797
+ rejectVersionlessAfterDocumentVersion: true,
798
+ });
799
+ }
800
+ if (!preparation.ready) {
801
+ this._lastCommandBlocked = true;
802
+ this._lastCommandBlockedReason = preparation.blockedReason ?? 'unknown';
803
+ return false;
804
+ }
805
+ return true;
806
+ }
807
+ runPreparedCommand(mutate, options) {
808
+ if (!this.prepareForCommand()) {
809
+ return null;
810
+ }
811
+ if (options?.cancelIfPreflightUpdated === true &&
812
+ this._lastCommandPreflightUpdate != null) {
813
+ return null;
814
+ }
815
+ if (options?.refreshSelectionAfterPreflight === true && react_native_1.Platform.OS === 'android') {
816
+ this.getSelection();
817
+ }
818
+ const update = this.parseAndNoteUpdate(mutate());
819
+ if (update) {
820
+ this._lastCommandPreflightUpdate = null;
821
+ }
822
+ return update;
823
+ }
824
+ invalidateContentCaches() {
825
+ this._cachedHtml = null;
826
+ this._cachedJsonString = null;
827
+ }
828
+ assertNotDestroyed() {
829
+ if (this._destroyed) {
830
+ throw new Error(ERR_DESTROYED);
831
+ }
832
+ }
833
+ currentScalarSelection() {
834
+ const selection = this._lastSelection;
835
+ const nativeModule = getNativeModule();
836
+ if (selection.type === 'text') {
837
+ const anchor = selection.anchor ?? 0;
838
+ const head = selection.head ?? anchor;
839
+ return {
840
+ anchor: nativeModule.editorDocToScalar(this._editorId, anchor),
841
+ head: nativeModule.editorDocToScalar(this._editorId, head),
842
+ };
843
+ }
844
+ if (selection.type === 'node' && typeof selection.pos === 'number') {
845
+ const scalar = nativeModule.editorDocToScalar(this._editorId, selection.pos);
846
+ return { anchor: scalar, head: scalar };
847
+ }
848
+ return null;
849
+ }
850
+ }
851
+ exports.NativeEditorBridge = NativeEditorBridge;
852
+ class NativeCollaborationBridge {
853
+ constructor(sessionId) {
854
+ this._destroyed = false;
855
+ this._sessionId = sessionId;
856
+ }
857
+ static create(config) {
858
+ const { initialEncodedState, ...normalizedConfig } = config ?? {};
859
+ const id = getNativeModule().collaborationSessionCreate(JSON.stringify(normalizedConfig));
860
+ const bridge = new NativeCollaborationBridge(id);
861
+ if (initialEncodedState != null) {
862
+ try {
863
+ bridge.replaceEncodedState(initialEncodedState);
864
+ }
865
+ catch (error) {
866
+ bridge.destroy();
867
+ throw error;
868
+ }
869
+ }
870
+ return bridge;
871
+ }
872
+ get sessionId() {
873
+ return this._sessionId;
874
+ }
875
+ get isDestroyed() {
876
+ return this._destroyed;
877
+ }
878
+ destroy() {
879
+ if (this._destroyed)
880
+ return;
881
+ this._destroyed = true;
882
+ getNativeModule().collaborationSessionDestroy(this._sessionId);
883
+ }
884
+ getDocumentJson() {
885
+ this.assertNotDestroyed();
886
+ return parseDocumentJSON(getNativeModule().collaborationSessionGetDocumentJson(this._sessionId));
887
+ }
888
+ getEncodedState() {
889
+ this.assertNotDestroyed();
890
+ return parseByteArrayJson(getNativeModule().collaborationSessionGetEncodedState(this._sessionId));
891
+ }
892
+ getEncodedStateBase64() {
893
+ return encodeCollaborationStateBase64(this.getEncodedState());
894
+ }
895
+ getPeers() {
896
+ this.assertNotDestroyed();
897
+ return parseCollaborationPeersJson(getNativeModule().collaborationSessionGetPeersJson(this._sessionId));
898
+ }
899
+ start() {
900
+ this.assertNotDestroyed();
901
+ return parseCollaborationResultJson(getNativeModule().collaborationSessionStart(this._sessionId));
902
+ }
903
+ applyLocalDocumentJson(doc) {
904
+ this.assertNotDestroyed();
905
+ return parseCollaborationResultJson(getNativeModule().collaborationSessionApplyLocalDocumentJson(this._sessionId, JSON.stringify(doc)));
906
+ }
907
+ applyEncodedState(encodedState) {
908
+ this.assertNotDestroyed();
909
+ return parseCollaborationResultJson(getNativeModule().collaborationSessionApplyEncodedState(this._sessionId, JSON.stringify(normalizeEncodedStateInput(encodedState))));
910
+ }
911
+ replaceEncodedState(encodedState) {
912
+ this.assertNotDestroyed();
913
+ return parseCollaborationResultJson(getNativeModule().collaborationSessionReplaceEncodedState(this._sessionId, JSON.stringify(normalizeEncodedStateInput(encodedState))));
914
+ }
915
+ handleMessage(bytes) {
916
+ this.assertNotDestroyed();
917
+ return parseCollaborationResultJson(getNativeModule().collaborationSessionHandleMessage(this._sessionId, JSON.stringify(Array.from(bytes))));
918
+ }
919
+ setLocalAwareness(state) {
920
+ this.assertNotDestroyed();
921
+ return parseCollaborationResultJson(getNativeModule().collaborationSessionSetLocalAwareness(this._sessionId, JSON.stringify(state)));
922
+ }
923
+ clearLocalAwareness() {
924
+ this.assertNotDestroyed();
925
+ return parseCollaborationResultJson(getNativeModule().collaborationSessionClearLocalAwareness(this._sessionId));
926
+ }
927
+ assertNotDestroyed() {
928
+ if (this._destroyed) {
929
+ throw new Error(ERR_DESTROYED);
930
+ }
931
+ }
932
+ }
933
+ exports.NativeCollaborationBridge = NativeCollaborationBridge;