@apollohg/react-native-rich-text-editor 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +160 -0
- package/README.md +259 -0
- package/RUST-STANDARD-LIBRARY-NOTICES.html +8266 -0
- package/ReactNativeProseEditor.podspec +59 -0
- package/THIRD_PARTY_NOTICES.md +31155 -0
- package/android/build.gradle +188 -0
- package/android/consumer-rules.pro +18 -0
- package/android/expo/build.gradle +17 -0
- package/android/src/debug/java/com/apollohg/editor/viewer/PreparedProseDrawInstrumentation.kt +7 -0
- package/android/src/main/assets/editor-icons/MaterialIcons.json +2236 -0
- package/android/src/main/assets/editor-icons/MaterialIcons.ttf +0 -0
- package/android/src/main/java/com/apollohg/editor/AndroidApiCompat.kt +19 -0
- package/android/src/main/java/com/apollohg/editor/AndroidCollaborationTransport.kt +860 -0
- package/android/src/main/java/com/apollohg/editor/CaretGeometry.kt +91 -0
- package/android/src/main/java/com/apollohg/editor/CodeHighlighting.kt +141 -0
- package/android/src/main/java/com/apollohg/editor/DecodedBitmapBudget.kt +250 -0
- package/android/src/main/java/com/apollohg/editor/EditorAddons.kt +133 -0
- package/android/src/main/java/com/apollohg/editor/EditorBlockSpacing.kt +51 -0
- package/android/src/main/java/com/apollohg/editor/EditorBoxDrawable.kt +16 -0
- package/android/src/main/java/com/apollohg/editor/EditorBoxDrawing.kt +234 -0
- package/android/src/main/java/com/apollohg/editor/EditorCheckboxSpan.kt +87 -0
- package/android/src/main/java/com/apollohg/editor/EditorCodeHighlighting.kt +120 -0
- package/android/src/main/java/com/apollohg/editor/EditorDecorationLayer.java +18 -0
- package/android/src/main/java/com/apollohg/editor/EditorDocumentLayout.kt +626 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +1042 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextAnnotations.kt +191 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextCaret.kt +100 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextClipboard.kt +101 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextComposition.kt +220 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextConfiguration.kt +316 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextCorrection.kt +303 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextDeferredUpdates.kt +327 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextDeletion.kt +258 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextDiagnostics.kt +83 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextDragDrop.kt +67 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextExternalComposition.kt +357 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextHardwareInput.kt +277 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextImages.kt +280 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextInputLifecycle.kt +183 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextInputPreparation.kt +79 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextInputTraits.kt +384 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextLayout.kt +100 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextNativeMutation.kt +243 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextPlaceholder.kt +154 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextRenderPatch.kt +347 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextRendering.kt +313 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextRustCommands.kt +281 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextSelection.kt +352 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextState.kt +113 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextTaskMarkers.kt +92 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextTextCommit.kt +327 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextToolbar.kt +84 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextUpdates.kt +245 -0
- package/android/src/main/java/com/apollohg/editor/EditorGlyphHeightCursorDrawable.kt +42 -0
- package/android/src/main/java/com/apollohg/editor/EditorHeightBehavior.kt +13 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputConnection.kt +923 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputCoordinates.kt +191 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputCorrection.kt +107 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputCursorGeometry.kt +128 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputSnapshots.kt +134 -0
- package/android/src/main/java/com/apollohg/editor/EditorInputSurroundingDeletion.kt +321 -0
- package/android/src/main/java/com/apollohg/editor/EditorKeyboardToolbarView.kt +851 -0
- package/android/src/main/java/com/apollohg/editor/EditorMentionStyle.kt +192 -0
- package/android/src/main/java/com/apollohg/editor/EditorReconciliationWatcher.kt +46 -0
- package/android/src/main/java/com/apollohg/editor/EditorStyleSheet.kt +303 -0
- package/android/src/main/java/com/apollohg/editor/EditorStyleSheetSpans.kt +253 -0
- package/android/src/main/java/com/apollohg/editor/EditorSurfaceInputConnection.kt +67 -0
- package/android/src/main/java/com/apollohg/editor/EditorTextDecorationDrawing.kt +143 -0
- package/android/src/main/java/com/apollohg/editor/EditorTextSurface.kt +712 -0
- package/android/src/main/java/com/apollohg/editor/EditorTextSurfaceDragDrop.kt +94 -0
- package/android/src/main/java/com/apollohg/editor/EditorTextSurfaceInteraction.kt +708 -0
- package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +650 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Adapter.kt +912 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2AdapterMutations.kt +402 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2AdapterRendering.kt +123 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2AdapterSelection.kt +203 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Backend.kt +120 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Driver.kt +87 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Registry.kt +97 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2RenderValidation.kt +409 -0
- package/android/src/main/java/com/apollohg/editor/ExpoAutoGrowStyleSizePublisher.kt +34 -0
- package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +266 -0
- package/android/src/main/java/com/apollohg/editor/ImeTextCoordinateMapper.kt +102 -0
- package/android/src/main/java/com/apollohg/editor/KeyboardToolbarImeAnimationController.kt +101 -0
- package/android/src/main/java/com/apollohg/editor/MentionSuggestionChipView.kt +234 -0
- package/android/src/main/java/com/apollohg/editor/NativeCollaborationTransportRegistry.kt +493 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +813 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewAtoms.kt +68 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewBinding.kt +126 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewDiagnostics.kt +208 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewErrors.kt +146 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewEvents.kt +150 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewExternalComposition.kt +39 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewFocus.kt +176 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewLifecycle.kt +302 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewMentions.kt +259 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewNativeActions.kt +179 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewOutsideTap.kt +214 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewPendingUpdates.kt +376 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewProperties.kt +234 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewPropertyRetries.kt +197 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewToolbar.kt +285 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewTypes.kt +28 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewUpdates.kt +271 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +687 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorOutsideTapDispatcher.kt +380 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorV2Numbers.kt +45 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorViewRegistry.kt +372 -0
- package/android/src/main/java/com/apollohg/editor/NativeImagePipeline.kt +22 -0
- package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +193 -0
- package/android/src/main/java/com/apollohg/editor/NativeToolbarIcons.kt +177 -0
- package/android/src/main/java/com/apollohg/editor/NativeToolbarItem.kt +274 -0
- package/android/src/main/java/com/apollohg/editor/OkHttpCollaborationSocket.kt +102 -0
- package/android/src/main/java/com/apollohg/editor/OrderedListMarkerFormatter.kt +130 -0
- package/android/src/main/java/com/apollohg/editor/PointerTransparentView.java +18 -0
- package/android/src/main/java/com/apollohg/editor/PositionBridge.kt +128 -0
- package/android/src/main/java/com/apollohg/editor/ProseViewerView.kt +854 -0
- package/android/src/main/java/com/apollohg/editor/RemoteSelectionOverlayView.kt +314 -0
- package/android/src/main/java/com/apollohg/editor/RenderBlockSpans.kt +314 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +224 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridgeBlockStyles.kt +407 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridgeElements.kt +544 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridgeInlineAndAtoms.kt +631 -0
- package/android/src/main/java/com/apollohg/editor/RenderBridgeParagraphs.kt +215 -0
- package/android/src/main/java/com/apollohg/editor/RenderImageDecoder.kt +748 -0
- package/android/src/main/java/com/apollohg/editor/RenderImageLoader.kt +900 -0
- package/android/src/main/java/com/apollohg/editor/RenderLayoutConstants.kt +117 -0
- package/android/src/main/java/com/apollohg/editor/RenderMediaSpans.kt +337 -0
- package/android/src/main/java/com/apollohg/editor/RenderParagraphSpans.kt +182 -0
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +951 -0
- package/android/src/main/java/com/apollohg/editor/SharedNativeImagePipeline.kt +78 -0
- package/android/src/main/java/com/apollohg/editor/UniffiEditorV2Backend.kt +261 -0
- package/android/src/main/java/com/apollohg/editor/viewer/AndroidProseLayoutEngine.kt +1656 -0
- package/android/src/main/java/com/apollohg/editor/viewer/FabricAttachmentSidecars.kt +80 -0
- package/android/src/main/java/com/apollohg/editor/viewer/FabricLeaseHandleBridge.kt +59 -0
- package/android/src/main/java/com/apollohg/editor/viewer/FallbackSelectionGeometry.kt +450 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseDrawingView.kt +678 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseInstrumentation.kt +608 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseLayout.kt +186 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseLayoutCache.kt +393 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseLayoutRegistry.kt +828 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseTheme.kt +316 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseViewerManager.kt +900 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedProseViewerPackage.kt +16 -0
- package/android/src/main/java/com/apollohg/editor/viewer/PreparedViewerAtoms.kt +89 -0
- package/android/src/main/java/com/apollohg/editor/viewer/ViewerCodeHighlighting.kt +91 -0
- package/android/src/main/java/com/apollohg/editor/viewer/ViewerDocument.kt +453 -0
- package/android/src/main/java/com/apollohg/editor/viewer/ViewerFontEnvironment.kt +282 -0
- package/android/src/main/java/com/apollohg/editor/viewer/ViewerImagePipeline.kt +460 -0
- package/android/src/main/jni/CMakeLists.txt +85 -0
- package/android/src/main/jni/PreparedProseViewerMeasurementsManager.cpp +334 -0
- package/android/src/main/jni/ReactNativeProseEditorSpec.h +17 -0
- package/android/src/main/jni/reactnativeproseeditor.h +6 -0
- package/android/src/main/res/values/attrs.xml +6 -0
- package/android/src/release/java/com/apollohg/editor/viewer/PreparedProseDrawInstrumentation.kt +9 -0
- package/app.plugin.js +62 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseMeasurementsManager.h +62 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerComponentDescriptor.h +30 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerShadowNode.cpp +192 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerShadowNode.h +46 -0
- package/common/cpp/react/renderer/components/PreparedProseViewer/PreparedProseViewerState.h +145 -0
- package/dist/AtomHost.d.ts +17 -0
- package/dist/AtomHost.js +135 -0
- package/dist/DefaultAtomChip.d.ts +2 -0
- package/dist/DefaultAtomChip.js +22 -0
- package/dist/EditorAddon.d.ts +32 -0
- package/dist/EditorAddon.js +29 -0
- package/dist/EditorAddonNormalization.d.ts +6 -0
- package/dist/EditorAddonNormalization.js +48 -0
- package/dist/EditorMentionThemeNormalization.d.ts +8 -0
- package/dist/EditorMentionThemeNormalization.js +22 -0
- package/dist/EditorMentionThemeValidation.d.ts +12 -0
- package/dist/EditorMentionThemeValidation.js +95 -0
- package/dist/EditorStyleSheet.d.ts +4 -0
- package/dist/EditorStyleSheet.js +10 -0
- package/dist/EditorStyleSheetNormalization.d.ts +3 -0
- package/dist/EditorStyleSheetNormalization.js +226 -0
- package/dist/EditorStyleSheetTypes.d.ts +151 -0
- package/dist/EditorStyleSheetTypes.js +2 -0
- package/dist/EditorTheme.d.ts +117 -0
- package/dist/EditorTheme.js +41 -0
- package/dist/EditorToolbar.d.ts +4 -0
- package/dist/EditorToolbar.js +17 -0
- package/dist/EditorToolbarComponent.d.ts +13 -0
- package/dist/EditorToolbarComponent.js +24 -0
- package/dist/EditorToolbarItems.d.ts +9 -0
- package/dist/EditorToolbarItems.js +58 -0
- package/dist/EditorToolbarRegistry.d.ts +59 -0
- package/dist/EditorToolbarRegistry.js +175 -0
- package/dist/EditorToolbarTypes.d.ts +273 -0
- package/dist/EditorToolbarTypes.js +2 -0
- package/dist/EditorToolbarVisuals.d.ts +154 -0
- package/dist/EditorToolbarVisuals.js +228 -0
- package/dist/EditorUpdateRevision.d.ts +8 -0
- package/dist/EditorUpdateRevision.js +22 -0
- package/dist/ExternalTextComposition.d.ts +45 -0
- package/dist/ExternalTextComposition.js +537 -0
- package/dist/ImageLoadingPolicy.d.ts +54 -0
- package/dist/ImageLoadingPolicy.js +60 -0
- package/dist/NativeEditorBoundaryError.d.ts +111 -0
- package/dist/NativeEditorBoundaryError.js +268 -0
- package/dist/NativeEditorBridge.d.ts +9 -0
- package/dist/NativeEditorBridge.js +37 -0
- package/dist/NativeEditorCollaborationTransport.d.ts +154 -0
- package/dist/NativeEditorCollaborationTransport.js +275 -0
- package/dist/NativeEditorCreateConfig.d.ts +16 -0
- package/dist/NativeEditorCreateConfig.js +249 -0
- package/dist/NativeEditorCreateJson.d.ts +76 -0
- package/dist/NativeEditorCreateJson.js +474 -0
- package/dist/NativeEditorCreateValidation.d.ts +32 -0
- package/dist/NativeEditorCreateValidation.js +150 -0
- package/dist/NativeEditorDocumentBridge.d.ts +72 -0
- package/dist/NativeEditorDocumentBridge.js +305 -0
- package/dist/NativeEditorDocumentHandle.d.ts +70 -0
- package/dist/NativeEditorDocumentHandle.js +89 -0
- package/dist/NativeEditorLocalAwareness.d.ts +34 -0
- package/dist/NativeEditorLocalAwareness.js +153 -0
- package/dist/NativeEditorNativeModule.d.ts +48 -0
- package/dist/NativeEditorNativeModule.js +34 -0
- package/dist/NativeEditorRenderNormalization.d.ts +22 -0
- package/dist/NativeEditorRenderNormalization.js +274 -0
- package/dist/NativeEditorResultNormalization.d.ts +108 -0
- package/dist/NativeEditorResultNormalization.js +400 -0
- package/dist/NativeEditorTypes.d.ts +318 -0
- package/dist/NativeEditorTypes.js +15 -0
- package/dist/NativeEditorV2Decimal.d.ts +5 -0
- package/dist/NativeEditorV2Decimal.js +18 -0
- package/dist/NativeProseViewer.d.ts +122 -0
- package/dist/NativeProseViewer.js +130 -0
- package/dist/NativeRichTextEditor.d.ts +3 -0
- package/dist/NativeRichTextEditor.js +6 -0
- package/dist/ResourceLimits.d.ts +100 -0
- package/dist/ResourceLimits.js +80 -0
- package/dist/RichTextEditor.d.ts +4 -0
- package/dist/RichTextEditor.js +25 -0
- package/dist/RichTextEditorNativeTypes.d.ts +122 -0
- package/dist/RichTextEditorNativeTypes.js +2 -0
- package/dist/RichTextEditorNativeView.d.ts +12 -0
- package/dist/RichTextEditorNativeView.js +15 -0
- package/dist/RichTextEditorSerialization.d.ts +53 -0
- package/dist/RichTextEditorSerialization.js +283 -0
- package/dist/RichTextEditorTypes.d.ts +281 -0
- package/dist/RichTextEditorTypes.js +2 -0
- package/dist/ViewerConfiguration.d.ts +22 -0
- package/dist/ViewerConfiguration.js +6 -0
- package/dist/YjsCollaboration.d.ts +146 -0
- package/dist/YjsCollaboration.js +496 -0
- package/dist/addons.d.ts +193 -0
- package/dist/addons.js +122 -0
- package/dist/atomConstants.d.ts +3 -0
- package/dist/atomConstants.js +6 -0
- package/dist/atomInstances.d.ts +35 -0
- package/dist/atomInstances.js +79 -0
- package/dist/atomPolicy.d.ts +4 -0
- package/dist/atomPolicy.js +47 -0
- package/dist/atomUpdates.d.ts +2 -0
- package/dist/atomUpdates.js +38 -0
- package/dist/atoms.d.ts +92 -0
- package/dist/atoms.js +222 -0
- package/dist/attributeValidation.d.ts +4 -0
- package/dist/attributeValidation.js +97 -0
- package/dist/contentExpression.d.ts +6 -0
- package/dist/contentExpression.js +335 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +78 -0
- package/dist/listMarkers.d.ts +15 -0
- package/dist/listMarkers.js +21 -0
- package/dist/schemaDefinition.d.ts +143 -0
- package/dist/schemaDefinition.js +206 -0
- package/dist/schemaDocument.d.ts +17 -0
- package/dist/schemaDocument.js +69 -0
- package/dist/schemaDocumentConstruction.d.ts +5 -0
- package/dist/schemaDocumentConstruction.js +125 -0
- package/dist/schemaNormalization.d.ts +29 -0
- package/dist/schemaNormalization.js +313 -0
- package/dist/schemaPresets.d.ts +68 -0
- package/dist/schemaPresets.js +198 -0
- package/dist/schemaResolution.d.ts +9 -0
- package/dist/schemaResolution.js +211 -0
- package/dist/schemas.d.ts +5 -0
- package/dist/schemas.js +28 -0
- package/dist/specs/PreparedProseViewerNativeComponent.d.ts +37 -0
- package/dist/specs/PreparedProseViewerNativeComponent.js +6 -0
- package/dist/useEditorToolbarInteractions.d.ts +12 -0
- package/dist/useEditorToolbarInteractions.js +218 -0
- package/dist/useEditorToolbarItems.d.ts +8 -0
- package/dist/useEditorToolbarItems.js +280 -0
- package/dist/useEditorToolbarPresentation.d.ts +4 -0
- package/dist/useEditorToolbarPresentation.js +203 -0
- package/dist/useEditorToolbarState.d.ts +63 -0
- package/dist/useEditorToolbarState.js +108 -0
- package/dist/useFocusPreservingFrames.d.ts +17 -0
- package/dist/useFocusPreservingFrames.js +108 -0
- package/dist/useNativeEditor.d.ts +66 -0
- package/dist/useNativeEditor.js +370 -0
- package/dist/useRichTextEditorCommands.d.ts +21 -0
- package/dist/useRichTextEditorCommands.js +299 -0
- package/dist/useRichTextEditorEvents.d.ts +18 -0
- package/dist/useRichTextEditorEvents.js +216 -0
- package/dist/useRichTextEditorMentions.d.ts +11 -0
- package/dist/useRichTextEditorMentions.js +316 -0
- package/dist/useRichTextEditorPresentation.d.ts +5 -0
- package/dist/useRichTextEditorPresentation.js +178 -0
- package/dist/useRichTextEditorState.d.ts +180 -0
- package/dist/useRichTextEditorState.js +405 -0
- package/dist/useRichTextEditorUpdates.d.ts +10 -0
- package/dist/useRichTextEditorUpdates.js +308 -0
- package/dist/useViewerAtoms.d.ts +38 -0
- package/dist/useViewerAtoms.js +288 -0
- package/expo-module.config.json +13 -0
- package/ios/EditorAddons.swift +354 -0
- package/ios/EditorCodeHighlighting.swift +184 -0
- package/ios/EditorCore.xcframework/Info.plist +44 -0
- package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
- package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
- package/ios/EditorInteractionOverlays.swift +697 -0
- package/ios/EditorLayoutManager.swift +971 -0
- package/ios/EditorNodeTypes.swift +37 -0
- package/ios/EditorStyleSheet.swift +461 -0
- package/ios/EditorTextView+AttributedPatch.swift +305 -0
- package/ios/EditorTextView+Binding.swift +61 -0
- package/ios/EditorTextView+Caret.swift +333 -0
- package/ios/EditorTextView+Commands.swift +203 -0
- package/ios/EditorTextView+Delegate.swift +65 -0
- package/ios/EditorTextView+Diagnostics.swift +225 -0
- package/ios/EditorTextView+DragDrop.swift +290 -0
- package/ios/EditorTextView+ExternalComposition.swift +364 -0
- package/ios/EditorTextView+Images.swift +354 -0
- package/ios/EditorTextView+InputTraits.swift +200 -0
- package/ios/EditorTextView+KeyboardInput.swift +318 -0
- package/ios/EditorTextView+Layout.swift +245 -0
- package/ios/EditorTextView+MarkedText.swift +267 -0
- package/ios/EditorTextView+NativeInputLifecycle.swift +372 -0
- package/ios/EditorTextView+NativeMutation.swift +471 -0
- package/ios/EditorTextView+Reconciliation.swift +97 -0
- package/ios/EditorTextView+RenderPatch.swift +573 -0
- package/ios/EditorTextView+Rendering.swift +539 -0
- package/ios/EditorTextView+Selection.swift +542 -0
- package/ios/EditorTextView.swift +953 -0
- package/ios/EditorTheme.swift +626 -0
- package/ios/EditorV2Adapter+Commands.swift +204 -0
- package/ios/EditorV2Adapter+Envelope.swift +238 -0
- package/ios/EditorV2Adapter+Mutation.swift +392 -0
- package/ios/EditorV2Adapter+Registry.swift +185 -0
- package/ios/EditorV2Adapter+RenderState.swift +360 -0
- package/ios/EditorV2Adapter+RenderValidation.swift +420 -0
- package/ios/EditorV2Adapter+Selection.swift +329 -0
- package/ios/EditorV2Adapter+TextCommands.swift +430 -0
- package/ios/EditorV2Adapter.swift +376 -0
- package/ios/EditorV2Shadow.swift +353 -0
- package/ios/Generated_editor_core.swift +2378 -0
- package/ios/NativeCodeHighlighting.swift +159 -0
- package/ios/NativeCollaborationSocket.swift +144 -0
- package/ios/NativeCollaborationTransport+Protocol.swift +258 -0
- package/ios/NativeCollaborationTransport+Socket.swift +379 -0
- package/ios/NativeCollaborationTransport+Validation.swift +103 -0
- package/ios/NativeCollaborationTransport.swift +322 -0
- package/ios/NativeCollaborationTransportRegistry.swift +521 -0
- package/ios/NativeEditorExpoView+AccessoryRetry.swift +219 -0
- package/ios/NativeEditorExpoView+Binding.swift +268 -0
- package/ios/NativeEditorExpoView+Diagnostics.swift +66 -0
- package/ios/NativeEditorExpoView+Events.swift +131 -0
- package/ios/NativeEditorExpoView+Focus.swift +169 -0
- package/ios/NativeEditorExpoView+MentionRetry.swift +288 -0
- package/ios/NativeEditorExpoView+Mentions.swift +288 -0
- package/ios/NativeEditorExpoView+Properties.swift +300 -0
- package/ios/NativeEditorExpoView+Toolbar.swift +86 -0
- package/ios/NativeEditorExpoView+Updates.swift +312 -0
- package/ios/NativeEditorExpoView.swift +349 -0
- package/ios/NativeEditorModule.swift +856 -0
- package/ios/NativeEditorViewRegistry.swift +226 -0
- package/ios/NativeToolbar+ButtonStyle.swift +214 -0
- package/ios/NativeToolbar+Buttons.swift +228 -0
- package/ios/NativeToolbar+Diagnostics.swift +114 -0
- package/ios/NativeToolbar+Menu.swift +101 -0
- package/ios/NativeToolbar+Models.swift +519 -0
- package/ios/NativeToolbar+Placeholder.swift +39 -0
- package/ios/NativeToolbar.swift +612 -0
- package/ios/OrderedListMarkerFormatter.swift +103 -0
- package/ios/PositionBridge.swift +596 -0
- package/ios/ProseViewerView.swift +462 -0
- package/ios/RenderBridge+Atoms.swift +288 -0
- package/ios/RenderBridge+Attachments.swift +246 -0
- package/ios/RenderBridge+BlockBoundaries.swift +313 -0
- package/ios/RenderBridge+Style.swift +343 -0
- package/ios/RenderBridge.swift +704 -0
- package/ios/RichTextEditorView.swift +930 -0
- package/ios/SharedNativeImagePipeline+Cache.swift +189 -0
- package/ios/SharedNativeImagePipeline+Transport.swift +328 -0
- package/ios/SharedNativeImagePipeline.swift +533 -0
- package/ios/Viewer/CoreTextProseLayoutEngine+AttributedText.swift +436 -0
- package/ios/Viewer/CoreTextProseLayoutEngine+Models.swift +322 -0
- package/ios/Viewer/CoreTextProseLayoutEngine.swift +635 -0
- package/ios/Viewer/Fabric/PREPPreparedProseViewerComponentView.h +4 -0
- package/ios/Viewer/Fabric/PREPPreparedProseViewerComponentView.mm +767 -0
- package/ios/Viewer/Fabric/PreparedProseMeasurementsManager.mm +118 -0
- package/ios/Viewer/NativeSVGImageDecoder.h +9 -0
- package/ios/Viewer/NativeSVGImageDecoder.mm +106 -0
- package/ios/Viewer/NativeSVGPreflight.h +11 -0
- package/ios/Viewer/NativeSVGPreflight.mm +219 -0
- package/ios/Viewer/PreparedProseDrawingView.swift +639 -0
- package/ios/Viewer/PreparedProseInstrumentation.swift +387 -0
- package/ios/Viewer/PreparedProseLayout.swift +326 -0
- package/ios/Viewer/PreparedProseLayoutCache.swift +766 -0
- package/ios/Viewer/PreparedProseLayoutRegistry+Artifacts.swift +377 -0
- package/ios/Viewer/PreparedProseLayoutRegistry+Fabric.swift +582 -0
- package/ios/Viewer/PreparedProseLayoutRegistry+FabricOwnership.swift +128 -0
- package/ios/Viewer/PreparedProseLayoutRegistry.swift +381 -0
- package/ios/Viewer/ViewerDocument.swift +575 -0
- package/ios/Viewer/ViewerFontEnvironment.swift +283 -0
- package/ios/Viewer/ViewerImagePipeline.swift +478 -0
- package/ios/editor_coreFFI/editor_coreFFI.h +1023 -0
- package/ios/editor_coreFFI/module.modulemap +7 -0
- package/package.json +151 -0
- package/react-native.config.js +17 -0
- package/rust/android/arm64-v8a/libeditor_core.so +0 -0
- package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
- package/rust/android/x86/libeditor_core.so +0 -0
- package/rust/android/x86_64/libeditor_core.so +0 -0
- package/rust/bindings/kotlin/uniffi/editor_core/editor_core.kt +3146 -0
- package/src/AtomHost.tsx +180 -0
- package/src/DefaultAtomChip.tsx +27 -0
- package/src/EditorAddon.ts +65 -0
- package/src/EditorAddonNormalization.ts +49 -0
- package/src/EditorMentionThemeNormalization.ts +25 -0
- package/src/EditorMentionThemeValidation.ts +133 -0
- package/src/EditorStyleSheet.ts +9 -0
- package/src/EditorStyleSheetNormalization.ts +219 -0
- package/src/EditorStyleSheetTypes.ts +189 -0
- package/src/EditorTheme.ts +196 -0
- package/src/EditorToolbar.tsx +31 -0
- package/src/EditorToolbarComponent.tsx +23 -0
- package/src/EditorToolbarItems.tsx +64 -0
- package/src/EditorToolbarRegistry.tsx +254 -0
- package/src/EditorToolbarTypes.tsx +322 -0
- package/src/EditorToolbarVisuals.tsx +270 -0
- package/src/EditorUpdateRevision.ts +26 -0
- package/src/ExternalTextComposition.ts +658 -0
- package/src/ImageLoadingPolicy.ts +125 -0
- package/src/NativeEditorBoundaryError.ts +345 -0
- package/src/NativeEditorBridge.ts +93 -0
- package/src/NativeEditorCollaborationTransport.ts +493 -0
- package/src/NativeEditorCreateConfig.ts +326 -0
- package/src/NativeEditorCreateJson.ts +579 -0
- package/src/NativeEditorCreateValidation.ts +178 -0
- package/src/NativeEditorDocumentBridge.ts +485 -0
- package/src/NativeEditorDocumentHandle.ts +168 -0
- package/src/NativeEditorLocalAwareness.ts +168 -0
- package/src/NativeEditorNativeModule.ts +97 -0
- package/src/NativeEditorRenderNormalization.ts +320 -0
- package/src/NativeEditorResultNormalization.ts +469 -0
- package/src/NativeEditorTypes.ts +366 -0
- package/src/NativeEditorV2Decimal.ts +13 -0
- package/src/NativeProseViewer.tsx +356 -0
- package/src/NativeRichTextEditor.tsx +33 -0
- package/src/ResourceLimits.ts +187 -0
- package/src/RichTextEditor.tsx +27 -0
- package/src/RichTextEditorNativeTypes.tsx +144 -0
- package/src/RichTextEditorNativeView.tsx +21 -0
- package/src/RichTextEditorSerialization.tsx +381 -0
- package/src/RichTextEditorTypes.tsx +327 -0
- package/src/ViewerConfiguration.ts +23 -0
- package/src/YjsCollaboration.ts +692 -0
- package/src/addons.ts +311 -0
- package/src/atomConstants.ts +3 -0
- package/src/atomInstances.ts +123 -0
- package/src/atomPolicy.ts +47 -0
- package/src/atomUpdates.ts +52 -0
- package/src/atoms.ts +379 -0
- package/src/attributeValidation.ts +116 -0
- package/src/contentExpression.ts +338 -0
- package/src/index.ts +295 -0
- package/src/listMarkers.ts +18 -0
- package/src/schemaDefinition.ts +395 -0
- package/src/schemaDocument.ts +92 -0
- package/src/schemaDocumentConstruction.ts +148 -0
- package/src/schemaNormalization.ts +367 -0
- package/src/schemaPresets.ts +250 -0
- package/src/schemaResolution.ts +242 -0
- package/src/schemas.ts +43 -0
- package/src/specs/PreparedProseViewerNativeComponent.ts +40 -0
- package/src/useEditorToolbarInteractions.tsx +329 -0
- package/src/useEditorToolbarItems.tsx +390 -0
- package/src/useEditorToolbarPresentation.tsx +483 -0
- package/src/useEditorToolbarState.tsx +172 -0
- package/src/useFocusPreservingFrames.ts +171 -0
- package/src/useNativeEditor.ts +534 -0
- package/src/useRichTextEditorCommands.tsx +478 -0
- package/src/useRichTextEditorEvents.tsx +342 -0
- package/src/useRichTextEditorMentions.tsx +441 -0
- package/src/useRichTextEditorPresentation.tsx +563 -0
- package/src/useRichTextEditorState.tsx +620 -0
- package/src/useRichTextEditorUpdates.tsx +403 -0
- package/src/useViewerAtoms.tsx +427 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BASE64_ALPHABET = exports.MAX_COLLABORATION_ADAPTER_FRAME_BYTES = exports.MAX_COLLABORATION_ADAPTER_FRAMES = exports.MAX_COLLABORATION_ADAPTER_TIMEOUT_MILLIS = exports.MAX_COLLABORATION_PROTOCOL_BYTES = exports.MAX_COLLABORATION_PROTOCOLS = exports.COLLABORATION_PROTOCOL_TOKEN = void 0;
|
|
4
|
+
exports.collaborationProtocolAdapterDescriptor = collaborationProtocolAdapterDescriptor;
|
|
5
|
+
exports.collaborationTransportWireConfig = collaborationTransportWireConfig;
|
|
6
|
+
exports.serializeCollaborationProtocolAdapterResult = serializeCollaborationProtocolAdapterResult;
|
|
7
|
+
exports.normalizeNativeCollaborationTransportDiagnostics = normalizeNativeCollaborationTransportDiagnostics;
|
|
8
|
+
exports.encodeNativeCollaborationProtocolBytes = encodeNativeCollaborationProtocolBytes;
|
|
9
|
+
exports.decodeNativeCollaborationProtocolBytes = decodeNativeCollaborationProtocolBytes;
|
|
10
|
+
exports.normalizeNativeCollaborationTransportEvent = normalizeNativeCollaborationTransportEvent;
|
|
11
|
+
const NativeEditorBoundaryError_1 = require("./NativeEditorBoundaryError");
|
|
12
|
+
const NativeEditorResultNormalization_1 = require("./NativeEditorResultNormalization");
|
|
13
|
+
const NativeEditorCreateJson_1 = require("./NativeEditorCreateJson");
|
|
14
|
+
exports.COLLABORATION_PROTOCOL_TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
15
|
+
exports.MAX_COLLABORATION_PROTOCOLS = 16;
|
|
16
|
+
exports.MAX_COLLABORATION_PROTOCOL_BYTES = 128;
|
|
17
|
+
exports.MAX_COLLABORATION_ADAPTER_TIMEOUT_MILLIS = 60000;
|
|
18
|
+
exports.MAX_COLLABORATION_ADAPTER_FRAMES = 16;
|
|
19
|
+
exports.MAX_COLLABORATION_ADAPTER_FRAME_BYTES = 64 * 1024;
|
|
20
|
+
function collaborationProtocolAdapterDescriptor(value) {
|
|
21
|
+
if (value === null ||
|
|
22
|
+
typeof value !== 'object' ||
|
|
23
|
+
!Array.isArray(value.protocols) ||
|
|
24
|
+
value.protocols.length < 1 ||
|
|
25
|
+
value.protocols.length > exports.MAX_COLLABORATION_PROTOCOLS ||
|
|
26
|
+
typeof value.onOpen !== 'function' ||
|
|
27
|
+
typeof value.onMessage !== 'function') {
|
|
28
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: invalid collaboration protocol adapter');
|
|
29
|
+
}
|
|
30
|
+
const protocols = value.protocols.map((protocol) => {
|
|
31
|
+
if (typeof protocol !== 'string' ||
|
|
32
|
+
protocol.length === 0 ||
|
|
33
|
+
(0, NativeEditorCreateJson_1.utf8V2JsonByteLength)(protocol) > exports.MAX_COLLABORATION_PROTOCOL_BYTES ||
|
|
34
|
+
!exports.COLLABORATION_PROTOCOL_TOKEN.test(protocol)) {
|
|
35
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: invalid collaboration WebSocket subprotocol');
|
|
36
|
+
}
|
|
37
|
+
return protocol;
|
|
38
|
+
});
|
|
39
|
+
if (new Set(protocols).size !== protocols.length) {
|
|
40
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: duplicate collaboration WebSocket subprotocol');
|
|
41
|
+
}
|
|
42
|
+
const timeoutMillis = value.timeoutMillis;
|
|
43
|
+
if (timeoutMillis !== undefined &&
|
|
44
|
+
(!Number.isSafeInteger(timeoutMillis) ||
|
|
45
|
+
timeoutMillis < 1 ||
|
|
46
|
+
timeoutMillis > exports.MAX_COLLABORATION_ADAPTER_TIMEOUT_MILLIS)) {
|
|
47
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: invalid collaboration protocol adapter timeout');
|
|
48
|
+
}
|
|
49
|
+
const rawTerminalCloseCodes = value.terminalCloseCodes;
|
|
50
|
+
if (rawTerminalCloseCodes !== undefined &&
|
|
51
|
+
(!Array.isArray(rawTerminalCloseCodes) ||
|
|
52
|
+
rawTerminalCloseCodes.some((code) => !Number.isSafeInteger(code) || code < 1000 || code > 4999))) {
|
|
53
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: invalid collaboration terminal close code');
|
|
54
|
+
}
|
|
55
|
+
const terminalCloseCodes = rawTerminalCloseCodes === undefined ? undefined : [...rawTerminalCloseCodes];
|
|
56
|
+
if (terminalCloseCodes !== undefined &&
|
|
57
|
+
new Set(terminalCloseCodes).size !== terminalCloseCodes.length) {
|
|
58
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: duplicate collaboration terminal close code');
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
protocols,
|
|
62
|
+
...(timeoutMillis === undefined ? {} : { timeoutMillis }),
|
|
63
|
+
...(terminalCloseCodes === undefined ? {} : { terminalCloseCodes }),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function collaborationTransportWireConfig(config) {
|
|
67
|
+
if (config === null ||
|
|
68
|
+
typeof config !== 'object' ||
|
|
69
|
+
typeof config.url !== 'string' ||
|
|
70
|
+
typeof config.connect !== 'boolean') {
|
|
71
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: invalid collaboration transport configuration');
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
url: config.url,
|
|
75
|
+
connect: config.connect,
|
|
76
|
+
...(config.protocolAdapter === undefined
|
|
77
|
+
? {}
|
|
78
|
+
: {
|
|
79
|
+
protocolAdapter: collaborationProtocolAdapterDescriptor(config.protocolAdapter),
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function serializeCollaborationProtocolAdapterResult(value) {
|
|
84
|
+
if (value === null ||
|
|
85
|
+
typeof value !== 'object' ||
|
|
86
|
+
(value.action !== 'continue' && value.action !== 'ready' && value.action !== 'reject') ||
|
|
87
|
+
(value.frames !== undefined &&
|
|
88
|
+
(!Array.isArray(value.frames) ||
|
|
89
|
+
value.frames.length > exports.MAX_COLLABORATION_ADAPTER_FRAMES))) {
|
|
90
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: invalid collaboration protocol adapter result');
|
|
91
|
+
}
|
|
92
|
+
const frames = (value.frames ?? []).map((frame) => {
|
|
93
|
+
if (frame === null || typeof frame !== 'object') {
|
|
94
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: invalid collaboration protocol adapter frame');
|
|
95
|
+
}
|
|
96
|
+
if (frame.type === 'text' && typeof frame.data === 'string') {
|
|
97
|
+
if ((0, NativeEditorCreateJson_1.utf8V2JsonByteLength)(frame.data) > exports.MAX_COLLABORATION_ADAPTER_FRAME_BYTES) {
|
|
98
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: collaboration protocol adapter frame is too large');
|
|
99
|
+
}
|
|
100
|
+
return { type: 'text', data: frame.data };
|
|
101
|
+
}
|
|
102
|
+
if (frame.type === 'binary' &&
|
|
103
|
+
frame.data instanceof Uint8Array &&
|
|
104
|
+
frame.data.byteLength <= exports.MAX_COLLABORATION_ADAPTER_FRAME_BYTES) {
|
|
105
|
+
return {
|
|
106
|
+
type: 'binary',
|
|
107
|
+
data: encodeNativeCollaborationProtocolBytes(frame.data),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: invalid collaboration protocol adapter frame');
|
|
111
|
+
});
|
|
112
|
+
return JSON.stringify({
|
|
113
|
+
action: value.action,
|
|
114
|
+
...(frames.length === 0 ? {} : { frames }),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function normalizeNativeCollaborationTransportDiagnostics(value) {
|
|
118
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value))
|
|
119
|
+
return null;
|
|
120
|
+
const transportState = (0, NativeEditorResultNormalization_1.whitelisted)(value.transportState, NativeEditorResultNormalization_1.V2_TRANSPORT_STATES);
|
|
121
|
+
const nextDeadlineMillis = value.nextDeadlineMillis === null
|
|
122
|
+
? null
|
|
123
|
+
: (0, NativeEditorResultNormalization_1.normalizeNativeEditorV2DecimalId)(value.nextDeadlineMillis);
|
|
124
|
+
const remoteCommitApplied = (0, NativeEditorResultNormalization_1.optionalBoolean)(value.remoteCommitApplied);
|
|
125
|
+
const peersChanged = (0, NativeEditorResultNormalization_1.optionalBoolean)(value.peersChanged);
|
|
126
|
+
const renewedLocal = (0, NativeEditorResultNormalization_1.optionalBoolean)(value.renewedLocal);
|
|
127
|
+
const expiredPeerCount = (0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.expiredPeerCount);
|
|
128
|
+
if (typeof value.wakeReason !== 'string' ||
|
|
129
|
+
transportState == null ||
|
|
130
|
+
(value.nextDeadlineMillis !== null && nextDeadlineMillis == null) ||
|
|
131
|
+
remoteCommitApplied == null ||
|
|
132
|
+
peersChanged == null ||
|
|
133
|
+
renewedLocal == null ||
|
|
134
|
+
expiredPeerCount == null) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
wakeReason: value.wakeReason,
|
|
139
|
+
transportState,
|
|
140
|
+
nextDeadlineMillis,
|
|
141
|
+
remoteCommitApplied,
|
|
142
|
+
peersChanged,
|
|
143
|
+
renewedLocal,
|
|
144
|
+
expiredPeerCount,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
exports.BASE64_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
148
|
+
function encodeNativeCollaborationProtocolBytes(bytes) {
|
|
149
|
+
let encoded = '';
|
|
150
|
+
for (let index = 0; index < bytes.length; index += 3) {
|
|
151
|
+
const first = bytes[index];
|
|
152
|
+
const second = index + 1 < bytes.length ? bytes[index + 1] : 0;
|
|
153
|
+
const third = index + 2 < bytes.length ? bytes[index + 2] : 0;
|
|
154
|
+
const value = (first << 16) | (second << 8) | third;
|
|
155
|
+
encoded += exports.BASE64_ALPHABET[(value >>> 18) & 63];
|
|
156
|
+
encoded += exports.BASE64_ALPHABET[(value >>> 12) & 63];
|
|
157
|
+
encoded += index + 1 < bytes.length ? exports.BASE64_ALPHABET[(value >>> 6) & 63] : '=';
|
|
158
|
+
encoded += index + 2 < bytes.length ? exports.BASE64_ALPHABET[value & 63] : '=';
|
|
159
|
+
}
|
|
160
|
+
return encoded;
|
|
161
|
+
}
|
|
162
|
+
function decodeNativeCollaborationProtocolBytes(value) {
|
|
163
|
+
if (value.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(value))
|
|
164
|
+
return null;
|
|
165
|
+
const firstPadding = value.indexOf('=');
|
|
166
|
+
if (firstPadding >= 0 && firstPadding < value.length - 2)
|
|
167
|
+
return null;
|
|
168
|
+
const outputLength = (value.length / 4) * 3 - (value.endsWith('==') ? 2 : value.endsWith('=') ? 1 : 0);
|
|
169
|
+
const bytes = new Uint8Array(outputLength);
|
|
170
|
+
let outputIndex = 0;
|
|
171
|
+
for (let index = 0; index < value.length; index += 4) {
|
|
172
|
+
const first = exports.BASE64_ALPHABET.indexOf(value[index]);
|
|
173
|
+
const second = exports.BASE64_ALPHABET.indexOf(value[index + 1]);
|
|
174
|
+
const third = value[index + 2] === '=' ? 0 : exports.BASE64_ALPHABET.indexOf(value[index + 2]);
|
|
175
|
+
const fourth = value[index + 3] === '=' ? 0 : exports.BASE64_ALPHABET.indexOf(value[index + 3]);
|
|
176
|
+
if (first < 0 || second < 0 || third < 0 || fourth < 0)
|
|
177
|
+
return null;
|
|
178
|
+
const decoded = (first << 18) | (second << 12) | (third << 6) | fourth;
|
|
179
|
+
if (outputIndex < outputLength)
|
|
180
|
+
bytes[outputIndex++] = (decoded >>> 16) & 0xff;
|
|
181
|
+
if (outputIndex < outputLength)
|
|
182
|
+
bytes[outputIndex++] = (decoded >>> 8) & 0xff;
|
|
183
|
+
if (outputIndex < outputLength)
|
|
184
|
+
bytes[outputIndex++] = decoded & 0xff;
|
|
185
|
+
}
|
|
186
|
+
return bytes;
|
|
187
|
+
}
|
|
188
|
+
function normalizeNativeCollaborationTransportEvent(value) {
|
|
189
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value))
|
|
190
|
+
return null;
|
|
191
|
+
const editorId = (0, NativeEditorResultNormalization_1.normalizeNativeEditorV2DecimalId)(value.editorId);
|
|
192
|
+
const eventSequence = (0, NativeEditorResultNormalization_1.normalizeNativeEditorV2DecimalId)(value.eventSequence);
|
|
193
|
+
const generation = value.generation === null ? null : (0, NativeEditorResultNormalization_1.normalizeNativeEditorV2DecimalId)(value.generation);
|
|
194
|
+
if (editorId == null ||
|
|
195
|
+
editorId === '0' ||
|
|
196
|
+
eventSequence == null ||
|
|
197
|
+
eventSequence === '0' ||
|
|
198
|
+
(value.generation !== null && generation == null)) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
if (value.kind === 'state') {
|
|
202
|
+
const state = (0, NativeEditorResultNormalization_1.normalizeNativeEditorV2StateValue)(value.state);
|
|
203
|
+
const peers = (0, NativeEditorResultNormalization_1.normalizeNativeEditorV2PeersValue)({ peers: value.peers });
|
|
204
|
+
const diagnostics = normalizeNativeCollaborationTransportDiagnostics(value.diagnostics);
|
|
205
|
+
if (state == null || peers == null || diagnostics == null)
|
|
206
|
+
return null;
|
|
207
|
+
return {
|
|
208
|
+
editorId,
|
|
209
|
+
eventSequence,
|
|
210
|
+
generation,
|
|
211
|
+
kind: 'state',
|
|
212
|
+
state,
|
|
213
|
+
peers,
|
|
214
|
+
diagnostics,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
if (value.kind === 'error') {
|
|
218
|
+
const error = (0, NativeEditorBoundaryError_1.normalizeNativeEditorV2Error)({ error: value.error });
|
|
219
|
+
if (error == null)
|
|
220
|
+
return null;
|
|
221
|
+
return {
|
|
222
|
+
editorId,
|
|
223
|
+
eventSequence,
|
|
224
|
+
generation,
|
|
225
|
+
kind: 'error',
|
|
226
|
+
error: (0, NativeEditorBoundaryError_1.nativeEditorV2ErrorToException)(error),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (value.kind === 'protocolAdapter') {
|
|
230
|
+
const eventId = (0, NativeEditorResultNormalization_1.normalizeNativeEditorV2DecimalId)(value.eventId);
|
|
231
|
+
if (generation == null ||
|
|
232
|
+
typeof value.attemptId !== 'string' ||
|
|
233
|
+
value.attemptId.length === 0 ||
|
|
234
|
+
eventId == null ||
|
|
235
|
+
eventId === '0' ||
|
|
236
|
+
(value.negotiatedProtocol !== null && typeof value.negotiatedProtocol !== 'string') ||
|
|
237
|
+
(value.phase !== 'open' && value.phase !== 'message')) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
const base = {
|
|
241
|
+
editorId,
|
|
242
|
+
eventSequence,
|
|
243
|
+
generation,
|
|
244
|
+
kind: 'protocolAdapter',
|
|
245
|
+
attemptId: value.attemptId,
|
|
246
|
+
eventId,
|
|
247
|
+
negotiatedProtocol: value.negotiatedProtocol,
|
|
248
|
+
};
|
|
249
|
+
if (value.phase === 'open') {
|
|
250
|
+
if (value.frame !== undefined)
|
|
251
|
+
return null;
|
|
252
|
+
return { ...base, phase: 'open' };
|
|
253
|
+
}
|
|
254
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value.frame) || typeof value.frame.data !== 'string')
|
|
255
|
+
return null;
|
|
256
|
+
if (value.frame.type === 'text') {
|
|
257
|
+
return {
|
|
258
|
+
...base,
|
|
259
|
+
phase: 'message',
|
|
260
|
+
frame: { type: 'text', data: value.frame.data },
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
if (value.frame.type === 'binary') {
|
|
264
|
+
const data = decodeNativeCollaborationProtocolBytes(value.frame.data);
|
|
265
|
+
if (data == null)
|
|
266
|
+
return null;
|
|
267
|
+
return {
|
|
268
|
+
...base,
|
|
269
|
+
phase: 'message',
|
|
270
|
+
frame: { type: 'binary', data },
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ResolvedDocumentSchema } from './schemas';
|
|
2
|
+
import { type NativeEditorCreateConfig } from './NativeEditorTypes';
|
|
3
|
+
export declare function normalizeV2CreatePolicy(value: Record<string, unknown>): Record<string, unknown>;
|
|
4
|
+
export declare function normalizeV2SnapshotMetadata(value: unknown): Record<string, unknown>;
|
|
5
|
+
export declare function buildV2CreateRequestUnchecked(config: NativeEditorCreateConfig): {
|
|
6
|
+
envelope: Record<string, unknown>;
|
|
7
|
+
limits: NativeEditorCreateConfig['limits'];
|
|
8
|
+
snapshotState: Uint8Array | null;
|
|
9
|
+
};
|
|
10
|
+
export declare function cloneAndFreezeDescriptorValue<T>(value: T): T;
|
|
11
|
+
export declare function cloneAndFreezeDocumentDescriptor(descriptor: ResolvedDocumentSchema): ResolvedDocumentSchema;
|
|
12
|
+
export declare function buildV2CreateRequest(config: NativeEditorCreateConfig): {
|
|
13
|
+
configJson: string;
|
|
14
|
+
snapshotState: Uint8Array | null;
|
|
15
|
+
documentDescriptor: ResolvedDocumentSchema;
|
|
16
|
+
};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeV2CreatePolicy = normalizeV2CreatePolicy;
|
|
4
|
+
exports.normalizeV2SnapshotMetadata = normalizeV2SnapshotMetadata;
|
|
5
|
+
exports.buildV2CreateRequestUnchecked = buildV2CreateRequestUnchecked;
|
|
6
|
+
exports.cloneAndFreezeDescriptorValue = cloneAndFreezeDescriptorValue;
|
|
7
|
+
exports.cloneAndFreezeDocumentDescriptor = cloneAndFreezeDocumentDescriptor;
|
|
8
|
+
exports.buildV2CreateRequest = buildV2CreateRequest;
|
|
9
|
+
const schemas_1 = require("./schemas");
|
|
10
|
+
const NativeEditorCreateValidation_1 = require("./NativeEditorCreateValidation");
|
|
11
|
+
const NativeEditorCreateJson_1 = require("./NativeEditorCreateJson");
|
|
12
|
+
const NativeEditorResultNormalization_1 = require("./NativeEditorResultNormalization");
|
|
13
|
+
function normalizeV2CreatePolicy(value) {
|
|
14
|
+
const policy = (0, NativeEditorCreateValidation_1.normalizeV2CreateRecord)(value, NativeEditorCreateValidation_1.V2_CREATE_POLICY_KEYS, 'policy');
|
|
15
|
+
const maxLength = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(policy, 'maxLength');
|
|
16
|
+
if (maxLength !== undefined &&
|
|
17
|
+
(typeof maxLength !== 'number' ||
|
|
18
|
+
!Number.isSafeInteger(maxLength) ||
|
|
19
|
+
maxLength < 0 ||
|
|
20
|
+
maxLength > NativeEditorCreateValidation_1.V2_CREATE_MAX_U32)) {
|
|
21
|
+
(0, NativeEditorCreateJson_1.invalidV2JsonValue)('policy.maxLength');
|
|
22
|
+
}
|
|
23
|
+
for (const key of ['readOnly', 'allowBase64Images']) {
|
|
24
|
+
const value = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(policy, key);
|
|
25
|
+
if (value !== undefined && typeof value !== 'boolean') {
|
|
26
|
+
(0, NativeEditorCreateJson_1.invalidV2JsonValue)(`policy.${key}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const inputFilter = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(policy, 'inputFilter');
|
|
30
|
+
if (inputFilter !== undefined && typeof inputFilter !== 'string') {
|
|
31
|
+
(0, NativeEditorCreateJson_1.invalidV2JsonValue)('policy.inputFilter');
|
|
32
|
+
}
|
|
33
|
+
return policy;
|
|
34
|
+
}
|
|
35
|
+
function normalizeV2SnapshotMetadata(value) {
|
|
36
|
+
const metadata = (0, NativeEditorCreateValidation_1.normalizeV2CreateRecord)(value, NativeEditorCreateValidation_1.V2_CREATE_SNAPSHOT_METADATA_KEYS, 'snapshot metadata');
|
|
37
|
+
const formatVersion = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(metadata, 'formatVersion');
|
|
38
|
+
if (typeof formatVersion !== 'number' ||
|
|
39
|
+
!Number.isSafeInteger(formatVersion) ||
|
|
40
|
+
formatVersion < 0 ||
|
|
41
|
+
formatVersion > NativeEditorCreateValidation_1.V2_CREATE_MAX_U32) {
|
|
42
|
+
(0, NativeEditorCreateJson_1.invalidV2JsonValue)('snapshot metadata.formatVersion');
|
|
43
|
+
}
|
|
44
|
+
for (const key of ['documentId', 'lineageId', 'fragmentName', 'schemaFingerprint']) {
|
|
45
|
+
if (typeof (0, NativeEditorCreateValidation_1.ownV2CreateValue)(metadata, key) !== 'string') {
|
|
46
|
+
(0, NativeEditorCreateJson_1.invalidV2JsonValue)(`snapshot metadata.${key}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return metadata;
|
|
50
|
+
}
|
|
51
|
+
function buildV2CreateRequestUnchecked(config) {
|
|
52
|
+
if (!(0, NativeEditorCreateValidation_1.isV2CreateRecord)(config)) {
|
|
53
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: invalid v2 create config');
|
|
54
|
+
}
|
|
55
|
+
(0, NativeEditorCreateValidation_1.requireKnownV2CreateKeys)(config, NativeEditorCreateValidation_1.V2_CREATE_CONFIG_KEYS, 'config');
|
|
56
|
+
const initializationValue = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(config, 'initialization');
|
|
57
|
+
if (!(0, NativeEditorCreateValidation_1.isV2CreateRecord)(initializationValue)) {
|
|
58
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: invalid v2 create config');
|
|
59
|
+
}
|
|
60
|
+
const jsonTraversal = {
|
|
61
|
+
seen: new WeakSet(),
|
|
62
|
+
work: 0,
|
|
63
|
+
};
|
|
64
|
+
const policyValue = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(config, 'policy');
|
|
65
|
+
const policy = policyValue === undefined
|
|
66
|
+
? undefined
|
|
67
|
+
: normalizeV2CreatePolicy(policyValue);
|
|
68
|
+
const limitsValue = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(config, 'limits');
|
|
69
|
+
let limits;
|
|
70
|
+
if (limitsValue !== undefined) {
|
|
71
|
+
(0, NativeEditorCreateValidation_1.requireKnownV2CreateKeys)(limitsValue, NativeEditorCreateValidation_1.V2_CREATE_LIMIT_KEYS, 'limits');
|
|
72
|
+
limits = (0, NativeEditorCreateValidation_1.emptyV2CreateRecord)();
|
|
73
|
+
for (const [group, keys] of [
|
|
74
|
+
['resource', NativeEditorCreateValidation_1.V2_CREATE_RESOURCE_LIMIT_KEYS],
|
|
75
|
+
['editing', NativeEditorCreateValidation_1.V2_CREATE_EDITING_LIMIT_KEYS],
|
|
76
|
+
['collaboration', NativeEditorCreateValidation_1.V2_CREATE_COLLABORATION_LIMIT_KEYS],
|
|
77
|
+
]) {
|
|
78
|
+
const overrides = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(limitsValue, group);
|
|
79
|
+
if (overrides !== undefined) {
|
|
80
|
+
limits[group] = (0, NativeEditorCreateValidation_1.normalizeV2CreateRecord)(overrides, keys, `${group} limits`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const envelope = (0, NativeEditorCreateValidation_1.emptyV2CreateRecord)();
|
|
85
|
+
const schema = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(config, 'schema');
|
|
86
|
+
if (schema === null) {
|
|
87
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: invalid schema for v2 create');
|
|
88
|
+
}
|
|
89
|
+
if (schema !== undefined) {
|
|
90
|
+
if (!(0, NativeEditorCreateValidation_1.isV2CreateRecord)(schema)) {
|
|
91
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: invalid schema for v2 create');
|
|
92
|
+
}
|
|
93
|
+
envelope.schema = (0, NativeEditorCreateJson_1.normalizeV2JsonValue)(schema, 'schema', jsonTraversal);
|
|
94
|
+
}
|
|
95
|
+
const fragmentName = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(config, 'fragmentName');
|
|
96
|
+
if (fragmentName !== undefined && typeof fragmentName !== 'string') {
|
|
97
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: invalid fragmentName for v2 create');
|
|
98
|
+
}
|
|
99
|
+
if (fragmentName !== undefined)
|
|
100
|
+
envelope.fragmentName = fragmentName;
|
|
101
|
+
let snapshotState = null;
|
|
102
|
+
const initialization = initializationValue;
|
|
103
|
+
const initializationType = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(initialization, 'type');
|
|
104
|
+
const initializationKeys = typeof initializationType === 'string'
|
|
105
|
+
? NativeEditorCreateValidation_1.V2_CREATE_INITIALIZATION_KEYS[initializationType]
|
|
106
|
+
: undefined;
|
|
107
|
+
if (initializationKeys === undefined) {
|
|
108
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: unknown v2 initialization type');
|
|
109
|
+
}
|
|
110
|
+
(0, NativeEditorCreateValidation_1.requireKnownV2CreateKeys)(initialization, initializationKeys, 'initialization');
|
|
111
|
+
switch (initializationType) {
|
|
112
|
+
case 'localEmpty': {
|
|
113
|
+
const localEmpty = (0, NativeEditorCreateValidation_1.emptyV2CreateRecord)();
|
|
114
|
+
localEmpty.type = 'localEmpty';
|
|
115
|
+
envelope.initialization = localEmpty;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case 'localJson': {
|
|
119
|
+
const json = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(initialization, 'json');
|
|
120
|
+
if (!(0, NativeEditorCreateValidation_1.isV2CreateRecord)(json)) {
|
|
121
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: invalid localJson initialization for v2 create');
|
|
122
|
+
}
|
|
123
|
+
const localJson = (0, NativeEditorCreateValidation_1.emptyV2CreateRecord)();
|
|
124
|
+
localJson.type = 'localJson';
|
|
125
|
+
localJson.json = (0, NativeEditorCreateJson_1.normalizeV2JsonValue)(json, 'localJson initialization', jsonTraversal);
|
|
126
|
+
envelope.initialization = localJson;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case 'localHtml': {
|
|
130
|
+
const html = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(initialization, 'html');
|
|
131
|
+
if (typeof html !== 'string') {
|
|
132
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: invalid localHtml initialization for v2 create');
|
|
133
|
+
}
|
|
134
|
+
const localHtml = (0, NativeEditorCreateValidation_1.emptyV2CreateRecord)();
|
|
135
|
+
localHtml.type = 'localHtml';
|
|
136
|
+
localHtml.html = html;
|
|
137
|
+
envelope.initialization = localHtml;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 'room': {
|
|
141
|
+
const documentId = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(initialization, 'documentId');
|
|
142
|
+
const lineageId = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(initialization, 'lineageId');
|
|
143
|
+
if (typeof documentId !== 'string' || typeof lineageId !== 'string') {
|
|
144
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: invalid room initialization for v2 create');
|
|
145
|
+
}
|
|
146
|
+
const room = (0, NativeEditorCreateValidation_1.emptyV2CreateRecord)();
|
|
147
|
+
room.type = 'room';
|
|
148
|
+
room.documentId = documentId;
|
|
149
|
+
room.lineageId = lineageId;
|
|
150
|
+
const snapshot = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(initialization, 'snapshot');
|
|
151
|
+
if (snapshot !== undefined) {
|
|
152
|
+
(0, NativeEditorCreateValidation_1.requireKnownV2CreateKeys)(snapshot, NativeEditorCreateValidation_1.V2_CREATE_ROOM_SNAPSHOT_KEYS, 'room snapshot');
|
|
153
|
+
const metadataValue = (0, NativeEditorCreateValidation_1.ownV2CreateValue)(snapshot, 'metadata');
|
|
154
|
+
const metadata = normalizeV2SnapshotMetadata(metadataValue);
|
|
155
|
+
room.snapshot = metadata;
|
|
156
|
+
snapshotState = (0, NativeEditorResultNormalization_1.requireV2Bytes)((0, NativeEditorCreateValidation_1.ownV2CreateValue)(snapshot, 'encodedState'), 'snapshot encodedState');
|
|
157
|
+
}
|
|
158
|
+
envelope.initialization = room;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
default:
|
|
162
|
+
throw (0, NativeEditorCreateValidation_1.invalidV2CreateRequestError)('NativeEditorBridge: unknown v2 initialization type');
|
|
163
|
+
}
|
|
164
|
+
if (policy !== undefined)
|
|
165
|
+
envelope.policy = policy;
|
|
166
|
+
if (limits !== undefined)
|
|
167
|
+
envelope.limits = limits;
|
|
168
|
+
return {
|
|
169
|
+
envelope,
|
|
170
|
+
limits: limits,
|
|
171
|
+
snapshotState,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function cloneAndFreezeDescriptorValue(value) {
|
|
175
|
+
if (value == null || typeof value !== 'object')
|
|
176
|
+
return value;
|
|
177
|
+
const setOwnValue = (target, key, child) => {
|
|
178
|
+
Object.defineProperty(target, key, {
|
|
179
|
+
value: child,
|
|
180
|
+
writable: true,
|
|
181
|
+
enumerable: true,
|
|
182
|
+
configurable: true,
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
const cloneRoot = (Array.isArray(value) ? [] : {});
|
|
186
|
+
const clones = new Map([[value, cloneRoot]]);
|
|
187
|
+
const pending = [{ source: value, target: cloneRoot }];
|
|
188
|
+
const created = [cloneRoot];
|
|
189
|
+
while (pending.length > 0) {
|
|
190
|
+
const current = pending.pop();
|
|
191
|
+
if (current === undefined)
|
|
192
|
+
break;
|
|
193
|
+
const keys = Array.isArray(current.source)
|
|
194
|
+
? Array.from({ length: current.source.length }, (_, index) => String(index))
|
|
195
|
+
: Object.keys(current.source);
|
|
196
|
+
for (const key of keys) {
|
|
197
|
+
const child = current.source[key];
|
|
198
|
+
if (child == null || typeof child !== 'object') {
|
|
199
|
+
setOwnValue(current.target, key, child);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const existing = clones.get(child);
|
|
203
|
+
if (existing !== undefined) {
|
|
204
|
+
setOwnValue(current.target, key, existing);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const childClone = (Array.isArray(child) ? [] : {});
|
|
208
|
+
clones.set(child, childClone);
|
|
209
|
+
created.push(childClone);
|
|
210
|
+
setOwnValue(current.target, key, childClone);
|
|
211
|
+
pending.push({
|
|
212
|
+
source: child,
|
|
213
|
+
target: childClone,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
for (let index = created.length - 1; index >= 0; index -= 1) {
|
|
218
|
+
Object.freeze(created[index]);
|
|
219
|
+
}
|
|
220
|
+
return cloneRoot;
|
|
221
|
+
}
|
|
222
|
+
function cloneAndFreezeDocumentDescriptor(descriptor) {
|
|
223
|
+
return Object.freeze({
|
|
224
|
+
schema: cloneAndFreezeDescriptorValue(descriptor.schema),
|
|
225
|
+
documentNodeName: descriptor.documentNodeName,
|
|
226
|
+
emptyDocument: cloneAndFreezeDescriptorValue(descriptor.emptyDocument),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function buildV2CreateRequest(config) {
|
|
230
|
+
let normalized;
|
|
231
|
+
try {
|
|
232
|
+
normalized = buildV2CreateRequestUnchecked(config);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
const message = error instanceof NativeEditorCreateValidation_1.NativeEditorCreateConfigError
|
|
236
|
+
? error.message
|
|
237
|
+
: 'NativeEditorBridge: invalid v2 create config';
|
|
238
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)(message);
|
|
239
|
+
}
|
|
240
|
+
(0, NativeEditorCreateValidation_1.validateV2CreateLimits)(normalized.limits);
|
|
241
|
+
const documentDescriptor = cloneAndFreezeDocumentDescriptor((0, schemas_1.resolveDocumentDescriptor)(normalized.envelope.schema, normalized.limits?.resource));
|
|
242
|
+
try {
|
|
243
|
+
const configJson = (0, NativeEditorCreateJson_1.serializeV2CreateEnvelope)(normalized.envelope);
|
|
244
|
+
return { configJson, snapshotState: normalized.snapshotState, documentDescriptor };
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
throw (0, NativeEditorResultNormalization_1.invalidV2RequestError)('NativeEditorBridge: invalid v2 create config');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export declare function invalidV2JsonValue(label: string): never;
|
|
2
|
+
export interface V2JsonNormalizationTraversal {
|
|
3
|
+
readonly seen: WeakSet<object>;
|
|
4
|
+
work: number;
|
|
5
|
+
}
|
|
6
|
+
export interface V2JsonNormalizationBudget {
|
|
7
|
+
bytes: number;
|
|
8
|
+
}
|
|
9
|
+
export type V2JsonNormalizationTarget = Record<string, unknown> | unknown[] | null;
|
|
10
|
+
export interface V2JsonNormalizationValueFrame {
|
|
11
|
+
readonly type: 'value';
|
|
12
|
+
readonly value: unknown;
|
|
13
|
+
readonly depth: number;
|
|
14
|
+
readonly target: V2JsonNormalizationTarget;
|
|
15
|
+
readonly key: string | number | null;
|
|
16
|
+
}
|
|
17
|
+
export interface V2JsonNormalizationArrayFrame {
|
|
18
|
+
readonly type: 'array';
|
|
19
|
+
readonly value: unknown[];
|
|
20
|
+
readonly normalized: unknown[];
|
|
21
|
+
readonly keys: readonly PropertyKey[];
|
|
22
|
+
readonly length: number;
|
|
23
|
+
readonly depth: number;
|
|
24
|
+
readonly nextKeyIndex: number;
|
|
25
|
+
readonly elementCount: number;
|
|
26
|
+
}
|
|
27
|
+
export interface V2JsonNormalizationObjectFrame {
|
|
28
|
+
readonly type: 'object';
|
|
29
|
+
readonly value: Record<string, unknown>;
|
|
30
|
+
readonly normalized: Record<string, unknown>;
|
|
31
|
+
readonly keys: readonly PropertyKey[];
|
|
32
|
+
readonly depth: number;
|
|
33
|
+
readonly nextKeyIndex: number;
|
|
34
|
+
readonly fieldCount: number;
|
|
35
|
+
}
|
|
36
|
+
export type V2JsonNormalizationFrame = V2JsonNormalizationValueFrame | V2JsonNormalizationArrayFrame | V2JsonNormalizationObjectFrame;
|
|
37
|
+
export interface V2JsonSerializationState {
|
|
38
|
+
bytes: number;
|
|
39
|
+
work: number;
|
|
40
|
+
}
|
|
41
|
+
export interface V2JsonSerializationValueFrame {
|
|
42
|
+
readonly type: 'value';
|
|
43
|
+
readonly value: unknown;
|
|
44
|
+
readonly depth: number;
|
|
45
|
+
}
|
|
46
|
+
export interface V2JsonSerializationArrayFrame {
|
|
47
|
+
readonly type: 'array';
|
|
48
|
+
readonly value: unknown[];
|
|
49
|
+
readonly length: number;
|
|
50
|
+
readonly depth: number;
|
|
51
|
+
readonly index: number;
|
|
52
|
+
}
|
|
53
|
+
export interface V2JsonSerializationObjectFrame {
|
|
54
|
+
readonly type: 'object';
|
|
55
|
+
readonly value: Record<string, unknown>;
|
|
56
|
+
readonly keys: readonly string[];
|
|
57
|
+
readonly depth: number;
|
|
58
|
+
readonly index: number;
|
|
59
|
+
}
|
|
60
|
+
export type V2JsonSerializationFrame = V2JsonSerializationValueFrame | V2JsonSerializationArrayFrame | V2JsonSerializationObjectFrame;
|
|
61
|
+
export declare function chargeV2JsonWork(state: V2JsonNormalizationTraversal, label: string): void;
|
|
62
|
+
export declare function chargeV2JsonBytes(budget: V2JsonNormalizationBudget, amount: number, label: string): void;
|
|
63
|
+
export declare function chargeV2JsonSerializationWork(state: V2JsonSerializationState, label: string): void;
|
|
64
|
+
export declare function chargeV2JsonSerializationBytes(state: V2JsonSerializationState, amount: number, label: string): void;
|
|
65
|
+
export declare function utf8V2JsonByteLength(value: string): number;
|
|
66
|
+
export declare function serializeV2JsonNumber(value: number, label: string): string;
|
|
67
|
+
export declare function chargeV2JsonStringBytes(value: string, budget: V2JsonNormalizationBudget, label: string): void;
|
|
68
|
+
export declare function normalizeV2JsonValue(value: unknown, label: string, traversal: V2JsonNormalizationTraversal, budget?: V2JsonNormalizationBudget): unknown;
|
|
69
|
+
export declare class V2JsonSerializationWriter {
|
|
70
|
+
private readonly _chunks;
|
|
71
|
+
private _current;
|
|
72
|
+
append(value: string, state: V2JsonSerializationState, label: string): void;
|
|
73
|
+
finish(): string;
|
|
74
|
+
}
|
|
75
|
+
export declare function appendV2JsonString(writer: V2JsonSerializationWriter, value: string, state: V2JsonSerializationState, label: string): void;
|
|
76
|
+
export declare function serializeV2CreateEnvelope(value: Record<string, unknown>): string;
|