@adminide-stack/yantra-mobile 12.0.129-alpha.0 → 12.0.129

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 (360) hide show
  1. package/lib/compute.js +57 -1
  2. package/lib/compute.js.map +1 -1
  3. package/lib/features/agent-chat/NativeAgentChat.js +3 -2
  4. package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
  5. package/lib/features/apps/AppsCatalog.js +10 -0
  6. package/lib/features/apps/AppsCatalog.js.map +1 -1
  7. package/lib/features/apps/mobileAppCatalog.js +11 -0
  8. package/lib/features/apps/mobileAppCatalog.js.map +1 -1
  9. package/lib/features/canvas/AudioEditorExperience.js +448 -105
  10. package/lib/features/canvas/AudioEditorExperience.js.map +1 -1
  11. package/lib/features/canvas/CanvasAgentChatPane.js +33 -14
  12. package/lib/features/canvas/CanvasAgentChatPane.js.map +1 -1
  13. package/lib/features/canvas/CanvasBoardsGrid.js +493 -41
  14. package/lib/features/canvas/CanvasBoardsGrid.js.map +1 -1
  15. package/lib/features/canvas/CanvasChatResultCard.js.map +1 -1
  16. package/lib/features/canvas/CanvasEditToolsPanel.js +37 -1
  17. package/lib/features/canvas/CanvasEditToolsPanel.js.map +1 -1
  18. package/lib/features/canvas/CanvasExperience.js +237 -22
  19. package/lib/features/canvas/CanvasExperience.js.map +1 -1
  20. package/lib/features/canvas/CanvasGeneratePanel.js +119 -26
  21. package/lib/features/canvas/CanvasGeneratePanel.js.map +1 -1
  22. package/lib/features/canvas/CanvasLooksPanel.js +17 -6
  23. package/lib/features/canvas/CanvasLooksPanel.js.map +1 -1
  24. package/lib/features/canvas/CanvasTasksPanel.js +18 -1
  25. package/lib/features/canvas/CanvasTasksPanel.js.map +1 -1
  26. package/lib/features/canvas/DesignCategoryGallery.js +423 -0
  27. package/lib/features/canvas/DesignCategoryGallery.js.map +1 -0
  28. package/lib/features/canvas/ImageEditorExperience.js +763 -187
  29. package/lib/features/canvas/ImageEditorExperience.js.map +1 -1
  30. package/lib/features/canvas/SetStudioExperience.js +199 -11
  31. package/lib/features/canvas/SetStudioExperience.js.map +1 -1
  32. package/lib/features/canvas/VideoEditorExperience.js +59 -40
  33. package/lib/features/canvas/VideoEditorExperience.js.map +1 -1
  34. package/lib/features/canvas/VideoGeneratorExperience.js +134 -34
  35. package/lib/features/canvas/VideoGeneratorExperience.js.map +1 -1
  36. package/lib/features/canvas/aiEdit.js +4 -2
  37. package/lib/features/canvas/aiEdit.js.map +1 -1
  38. package/lib/features/canvas/audioEditor/AudioWaveform.js +96 -0
  39. package/lib/features/canvas/audioEditor/AudioWaveform.js.map +1 -0
  40. package/lib/features/canvas/audioEditor/audioPeaks.js +93 -0
  41. package/lib/features/canvas/audioEditor/audioPeaks.js.map +1 -0
  42. package/lib/features/canvas/canvasTaskSync.js +34 -7
  43. package/lib/features/canvas/canvasTaskSync.js.map +1 -1
  44. package/lib/features/canvas/canvasTasks.js +23 -3
  45. package/lib/features/canvas/canvasTasks.js.map +1 -1
  46. package/lib/features/canvas/canvasTheme.js +10 -24
  47. package/lib/features/canvas/canvasTheme.js.map +1 -1
  48. package/lib/features/canvas/canvasUi.js +1 -1
  49. package/lib/features/canvas/canvasUi.js.map +1 -1
  50. package/lib/features/canvas/createTiles.js +17 -9
  51. package/lib/features/canvas/createTiles.js.map +1 -1
  52. package/lib/features/canvas/deepLinks.js +35 -5
  53. package/lib/features/canvas/deepLinks.js.map +1 -1
  54. package/lib/features/canvas/designCatalog.js +165 -0
  55. package/lib/features/canvas/designCatalog.js.map +1 -0
  56. package/lib/features/canvas/designCategories.js +262 -0
  57. package/lib/features/canvas/designCategories.js.map +1 -0
  58. package/lib/features/canvas/editorControls.js +406 -0
  59. package/lib/features/canvas/editorControls.js.map +1 -0
  60. package/lib/features/canvas/generationModels.js +5 -3
  61. package/lib/features/canvas/generationModels.js.map +1 -1
  62. package/lib/features/canvas/generationTasks.js +162 -0
  63. package/lib/features/canvas/generationTasks.js.map +1 -0
  64. package/lib/features/canvas/generator/BottomSheet.js +167 -0
  65. package/lib/features/canvas/generator/BottomSheet.js.map +1 -0
  66. package/lib/features/canvas/generator/BusinessCardChatCard.js +155 -0
  67. package/lib/features/canvas/generator/BusinessCardChatCard.js.map +1 -0
  68. package/lib/features/canvas/generator/DirectorSheet.js +163 -0
  69. package/lib/features/canvas/generator/DirectorSheet.js.map +1 -0
  70. package/lib/features/canvas/generator/ReframePreview.js +122 -0
  71. package/lib/features/canvas/generator/ReframePreview.js.map +1 -0
  72. package/lib/features/canvas/generator/RunLogCard.js +119 -0
  73. package/lib/features/canvas/generator/RunLogCard.js.map +1 -0
  74. package/lib/features/canvas/generator/ShotPanel.js +261 -0
  75. package/lib/features/canvas/generator/ShotPanel.js.map +1 -0
  76. package/lib/features/canvas/generator/businessCardWidget.js +117 -0
  77. package/lib/features/canvas/generator/businessCardWidget.js.map +1 -0
  78. package/lib/features/canvas/generator/cameraVocabulary.js +142 -0
  79. package/lib/features/canvas/generator/cameraVocabulary.js.map +1 -0
  80. package/lib/features/canvas/generator/cinematicVocabulary.js +416 -0
  81. package/lib/features/canvas/generator/cinematicVocabulary.js.map +1 -0
  82. package/lib/features/canvas/generator/direction.js +41 -0
  83. package/lib/features/canvas/generator/direction.js.map +1 -0
  84. package/lib/features/canvas/generator/reframeGeometry.js +108 -0
  85. package/lib/features/canvas/generator/reframeGeometry.js.map +1 -0
  86. package/lib/features/canvas/generator/runLog.js +71 -0
  87. package/lib/features/canvas/generator/runLog.js.map +1 -0
  88. package/lib/features/canvas/generator/shot.js +133 -0
  89. package/lib/features/canvas/generator/shot.js.map +1 -0
  90. package/lib/features/canvas/generator/useShotSpec.js +87 -0
  91. package/lib/features/canvas/generator/useShotSpec.js.map +1 -0
  92. package/lib/features/canvas/home/HeroComposer.js +214 -0
  93. package/lib/features/canvas/home/HeroComposer.js.map +1 -0
  94. package/lib/features/canvas/home/HeroMonitor.js +225 -0
  95. package/lib/features/canvas/home/HeroMonitor.js.map +1 -0
  96. package/lib/features/canvas/home/LookDetail.js +185 -0
  97. package/lib/features/canvas/home/LookDetail.js.map +1 -0
  98. package/lib/features/canvas/home/LoopingVideo.js +37 -0
  99. package/lib/features/canvas/home/LoopingVideo.js.map +1 -0
  100. package/lib/features/canvas/home/TemplatesGallery.js +253 -0
  101. package/lib/features/canvas/home/TemplatesGallery.js.map +1 -0
  102. package/lib/features/canvas/home/heroShots.js +100 -0
  103. package/lib/features/canvas/home/heroShots.js.map +1 -0
  104. package/lib/features/canvas/homeWork.js +62 -3
  105. package/lib/features/canvas/homeWork.js.map +1 -1
  106. package/lib/features/canvas/imageEditor/ImageMarkup.js +195 -0
  107. package/lib/features/canvas/imageEditor/ImageMarkup.js.map +1 -0
  108. package/lib/features/canvas/imageEditor/imageEditOps.js +367 -0
  109. package/lib/features/canvas/imageEditor/imageEditOps.js.map +1 -0
  110. package/lib/features/canvas/nativeViewerRegistry.js.map +1 -1
  111. package/lib/features/canvas/rankedCatalogSearch.js +375 -0
  112. package/lib/features/canvas/rankedCatalogSearch.js.map +1 -0
  113. package/lib/features/canvas/recorder/CameraRecorderExperience.js +68 -20
  114. package/lib/features/canvas/recorder/CameraRecorderExperience.js.map +1 -1
  115. package/lib/features/canvas/recorder/RecordingReview.js +272 -0
  116. package/lib/features/canvas/recorder/RecordingReview.js.map +1 -0
  117. package/lib/features/canvas/recorder/RecordingsList.js +179 -0
  118. package/lib/features/canvas/recorder/RecordingsList.js.map +1 -0
  119. package/lib/features/canvas/recorder/recorderOps.js +99 -0
  120. package/lib/features/canvas/recorder/recorderOps.js.map +1 -0
  121. package/lib/features/canvas/seedanceShowcase.js +314 -0
  122. package/lib/features/canvas/seedanceShowcase.js.map +1 -0
  123. package/lib/features/canvas/serverTasks.js +149 -15
  124. package/lib/features/canvas/serverTasks.js.map +1 -1
  125. package/lib/features/canvas/sessionRenewal.js +114 -0
  126. package/lib/features/canvas/sessionRenewal.js.map +1 -0
  127. package/lib/features/canvas/set/SetViewportWebView.js +34 -1
  128. package/lib/features/canvas/set/SetViewportWebView.js.map +1 -1
  129. package/lib/features/canvas/set/agent/setTurn.js +4 -2
  130. package/lib/features/canvas/set/agent/setTurn.js.map +1 -1
  131. package/lib/features/canvas/set/setPresets.js +85 -0
  132. package/lib/features/canvas/set/setPresets.js.map +1 -0
  133. package/lib/features/canvas/set/setProject.js +4 -1
  134. package/lib/features/canvas/set/setProject.js.map +1 -1
  135. package/lib/features/canvas/studioCatalog.js +59 -4
  136. package/lib/features/canvas/studioCatalog.js.map +1 -1
  137. package/lib/features/canvas/studioLooks.js +31 -4
  138. package/lib/features/canvas/studioLooks.js.map +1 -1
  139. package/lib/features/canvas/surfaceIndex.js +1 -14
  140. package/lib/features/canvas/surfaceIndex.js.map +1 -1
  141. package/lib/features/canvas/templateSearch.js +489 -0
  142. package/lib/features/canvas/templateSearch.js.map +1 -0
  143. package/lib/features/canvas/useCanvasSession.js +28 -6
  144. package/lib/features/canvas/useCanvasSession.js.map +1 -1
  145. package/lib/features/canvas/useStudioCatalogTemplates.js +41 -5
  146. package/lib/features/canvas/useStudioCatalogTemplates.js.map +1 -1
  147. package/lib/features/canvas/videoEditor/EditorPanels.js +531 -0
  148. package/lib/features/canvas/videoEditor/EditorPanels.js.map +1 -0
  149. package/lib/features/canvas/videoEditor/agent/AgentCutPane.js +48 -4
  150. package/lib/features/canvas/videoEditor/agent/AgentCutPane.js.map +1 -1
  151. package/lib/features/canvas/videoEditor/agent/agentLoop.js +2 -0
  152. package/lib/features/canvas/videoEditor/agent/agentLoop.js.map +1 -1
  153. package/lib/features/canvas/videoEditor/agent/brainClient.js +97 -27
  154. package/lib/features/canvas/videoEditor/agent/brainClient.js.map +1 -1
  155. package/lib/features/canvas/videoEditor/agent/cutTools.js +707 -3
  156. package/lib/features/canvas/videoEditor/agent/cutTools.js.map +1 -1
  157. package/lib/features/canvas/videoEditor/audioServices.js +165 -0
  158. package/lib/features/canvas/videoEditor/audioServices.js.map +1 -0
  159. package/lib/features/canvas/videoEditor/captions.js +144 -0
  160. package/lib/features/canvas/videoEditor/captions.js.map +1 -0
  161. package/lib/features/canvas/videoEditor/compileTimeline.js +24 -16
  162. package/lib/features/canvas/videoEditor/compileTimeline.js.map +1 -1
  163. package/lib/features/canvas/videoEditor/editorModel.js +12 -2
  164. package/lib/features/canvas/videoEditor/editorModel.js.map +1 -1
  165. package/lib/features/canvas/videoEditor/exportTask.js +89 -7
  166. package/lib/features/canvas/videoEditor/exportTask.js.map +1 -1
  167. package/lib/features/canvas/videoEditor/layers.js +117 -0
  168. package/lib/features/canvas/videoEditor/layers.js.map +1 -0
  169. package/lib/features/canvas/videoEditor/remoteMediaClient.js +45 -18
  170. package/lib/features/canvas/videoEditor/remoteMediaClient.js.map +1 -1
  171. package/lib/features/canvas/videoEditor/renderTimeline.js +18 -6
  172. package/lib/features/canvas/videoEditor/renderTimeline.js.map +1 -1
  173. package/lib/features/canvas/videoEditor/revoice.js +138 -0
  174. package/lib/features/canvas/videoEditor/revoice.js.map +1 -0
  175. package/lib/features/canvas/videoEditor/storageUpload.js +34 -0
  176. package/lib/features/canvas/videoEditor/storageUpload.js.map +1 -0
  177. package/lib/features/canvas/videoEditor/textMotion.js +109 -0
  178. package/lib/features/canvas/videoEditor/textMotion.js.map +1 -0
  179. package/lib/features/canvas/videoEditor/transitions.js +31 -0
  180. package/lib/features/canvas/videoEditor/transitions.js.map +1 -0
  181. package/lib/features/chat/TemplatesChatCards.js +8 -3
  182. package/lib/features/chat/TemplatesChatCards.js.map +1 -1
  183. package/lib/features/design/DesignEditorExperience.js +674 -644
  184. package/lib/features/design/DesignEditorExperience.js.map +1 -1
  185. package/lib/features/design/DesignExperience.js +285 -538
  186. package/lib/features/design/DesignExperience.js.map +1 -1
  187. package/lib/features/design/designCore.js +2 -212
  188. package/lib/features/design/designCore.js.map +1 -1
  189. package/lib/features/design/designIndex.js +1 -50
  190. package/lib/features/design/designIndex.js.map +1 -1
  191. package/lib/features/design/doc/aiDesign.js +247 -0
  192. package/lib/features/design/doc/aiDesign.js.map +1 -0
  193. package/lib/features/design/doc/artifacts.js +280 -0
  194. package/lib/features/design/doc/artifacts.js.map +1 -0
  195. package/lib/features/design/doc/chart.js +98 -0
  196. package/lib/features/design/doc/chart.js.map +1 -0
  197. package/lib/features/design/doc/crop.js +104 -0
  198. package/lib/features/design/doc/crop.js.map +1 -0
  199. package/lib/features/design/doc/curve.js +49 -0
  200. package/lib/features/design/doc/curve.js.map +1 -0
  201. package/lib/features/design/doc/docOps.js +397 -0
  202. package/lib/features/design/doc/docOps.js.map +1 -0
  203. package/lib/features/design/doc/findReplace.js +112 -0
  204. package/lib/features/design/doc/findReplace.js.map +1 -0
  205. package/lib/features/design/doc/fonts.js +79 -0
  206. package/lib/features/design/doc/fonts.js.map +1 -0
  207. package/lib/features/design/doc/frames.js +17 -0
  208. package/lib/features/design/doc/frames.js.map +1 -0
  209. package/lib/features/design/doc/geometry.js +133 -0
  210. package/lib/features/design/doc/geometry.js.map +1 -0
  211. package/lib/features/design/doc/imageAdjust.js +203 -0
  212. package/lib/features/design/doc/imageAdjust.js.map +1 -0
  213. package/lib/features/design/doc/legacyDoc.js +107 -0
  214. package/lib/features/design/doc/legacyDoc.js.map +1 -0
  215. package/lib/features/design/doc/newDoc.js +335 -0
  216. package/lib/features/design/doc/newDoc.js.map +1 -0
  217. package/lib/features/design/doc/pageRange.js +17 -0
  218. package/lib/features/design/doc/pageRange.js.map +1 -0
  219. package/lib/features/design/doc/pathScale.js +68 -0
  220. package/lib/features/design/doc/pathScale.js.map +1 -0
  221. package/lib/features/design/doc/qr.js +62 -0
  222. package/lib/features/design/doc/qr.js.map +1 -0
  223. package/lib/features/design/doc/shapes.js +366 -0
  224. package/lib/features/design/doc/shapes.js.map +1 -0
  225. package/lib/features/design/doc/sizes.js +230 -0
  226. package/lib/features/design/doc/sizes.js.map +1 -0
  227. package/lib/features/design/doc/textEffects.js +134 -0
  228. package/lib/features/design/doc/textEffects.js.map +1 -0
  229. package/lib/features/design/doc/textLayout.js +182 -0
  230. package/lib/features/design/doc/textLayout.js.map +1 -0
  231. package/lib/features/design/doc/types.js +30 -0
  232. package/lib/features/design/doc/types.js.map +1 -0
  233. package/lib/features/design/editor/AiPanel.js +194 -0
  234. package/lib/features/design/editor/AiPanel.js.map +1 -0
  235. package/lib/features/design/editor/ChartDataPanel.js +182 -0
  236. package/lib/features/design/editor/ChartDataPanel.js.map +1 -0
  237. package/lib/features/design/editor/CropOverlay.js +199 -0
  238. package/lib/features/design/editor/CropOverlay.js.map +1 -0
  239. package/lib/features/design/editor/DesignCanvas.js +363 -0
  240. package/lib/features/design/editor/DesignCanvas.js.map +1 -0
  241. package/lib/features/design/editor/ExportSheet.js +123 -0
  242. package/lib/features/design/editor/ExportSheet.js.map +1 -0
  243. package/lib/features/design/editor/FindReplacePanel.js +93 -0
  244. package/lib/features/design/editor/FindReplacePanel.js.map +1 -0
  245. package/lib/features/design/editor/ImageTools.js +188 -0
  246. package/lib/features/design/editor/ImageTools.js.map +1 -0
  247. package/lib/features/design/editor/LayerTools.js +485 -0
  248. package/lib/features/design/editor/LayerTools.js.map +1 -0
  249. package/lib/features/design/editor/PageStrip.js +203 -0
  250. package/lib/features/design/editor/PageStrip.js.map +1 -0
  251. package/lib/features/design/editor/Slideshow.js +97 -0
  252. package/lib/features/design/editor/Slideshow.js.map +1 -0
  253. package/lib/features/design/editor/ToolPanels.js +695 -0
  254. package/lib/features/design/editor/ToolPanels.js.map +1 -0
  255. package/lib/features/design/editor/controls.js +630 -0
  256. package/lib/features/design/editor/controls.js.map +1 -0
  257. package/lib/features/design/editor/useDesignSave.js +91 -0
  258. package/lib/features/design/editor/useDesignSave.js.map +1 -0
  259. package/lib/features/design/export/exportDesign.js +170 -0
  260. package/lib/features/design/export/exportDesign.js.map +1 -0
  261. package/lib/features/design/export/pdf.js +143 -0
  262. package/lib/features/design/export/pdf.js.map +1 -0
  263. package/lib/features/design/home/DesignHome.js +688 -0
  264. package/lib/features/design/home/DesignHome.js.map +1 -0
  265. package/lib/features/design/home/studioHome.js +61 -0
  266. package/lib/features/design/home/studioHome.js.map +1 -0
  267. package/lib/features/design/pickDesignImage.js +60 -0
  268. package/lib/features/design/pickDesignImage.js.map +1 -0
  269. package/lib/features/design/render/DesignPageView.js +69 -0
  270. package/lib/features/design/render/DesignPageView.js.map +1 -0
  271. package/lib/features/design/render/PageCapture.js +288 -0
  272. package/lib/features/design/render/PageCapture.js.map +1 -0
  273. package/lib/features/design/render/TextMeasure.js +115 -0
  274. package/lib/features/design/render/TextMeasure.js.map +1 -0
  275. package/lib/features/design/render/fontRegistry.js +110 -0
  276. package/lib/features/design/render/fontRegistry.js.map +1 -0
  277. package/lib/features/design/render/layers.js +392 -0
  278. package/lib/features/design/render/layers.js.map +1 -0
  279. package/lib/features/design/render/svg.js +35 -0
  280. package/lib/features/design/render/svg.js.map +1 -0
  281. package/lib/features/design/render/svgParts.js +435 -0
  282. package/lib/features/design/render/svgParts.js.map +1 -0
  283. package/lib/features/design/surface/BoardScreen.js +529 -0
  284. package/lib/features/design/surface/BoardScreen.js.map +1 -0
  285. package/lib/features/design/surface/CompareView.js +138 -0
  286. package/lib/features/design/surface/CompareView.js.map +1 -0
  287. package/lib/features/design/surface/CreationScreen.js +294 -0
  288. package/lib/features/design/surface/CreationScreen.js.map +1 -0
  289. package/lib/features/design/surface/DesignAgentChatPane.js +444 -0
  290. package/lib/features/design/surface/DesignAgentChatPane.js.map +1 -0
  291. package/lib/features/design/surface/DesignBoards.js +441 -0
  292. package/lib/features/design/surface/DesignBoards.js.map +1 -0
  293. package/lib/features/design/surface/DesignPreview.js +159 -0
  294. package/lib/features/design/surface/DesignPreview.js.map +1 -0
  295. package/lib/features/design/surface/DesignSurfaceExperience.js +80 -0
  296. package/lib/features/design/surface/DesignSurfaceExperience.js.map +1 -0
  297. package/lib/features/design/surface/FullScreenPreview.js +59 -0
  298. package/lib/features/design/surface/FullScreenPreview.js.map +1 -0
  299. package/lib/features/design/surface/NewSystemDialog.js +122 -0
  300. package/lib/features/design/surface/NewSystemDialog.js.map +1 -0
  301. package/lib/features/design/surface/PickerSheet.js +175 -0
  302. package/lib/features/design/surface/PickerSheet.js.map +1 -0
  303. package/lib/features/design/surface/TemplatesGallery.js +156 -0
  304. package/lib/features/design/surface/TemplatesGallery.js.map +1 -0
  305. package/lib/features/design/surface/WetPaint.js +140 -0
  306. package/lib/features/design/surface/WetPaint.js.map +1 -0
  307. package/lib/features/design/surface/agentTurn.js +229 -0
  308. package/lib/features/design/surface/agentTurn.js.map +1 -0
  309. package/lib/features/design/surface/designBoard.js +218 -0
  310. package/lib/features/design/surface/designBoard.js.map +1 -0
  311. package/lib/features/design/surface/designChannel.js +186 -0
  312. package/lib/features/design/surface/designChannel.js.map +1 -0
  313. package/lib/features/design/surface/designChat.js +141 -0
  314. package/lib/features/design/surface/designChat.js.map +1 -0
  315. package/lib/features/design/surface/designConnector.js +266 -0
  316. package/lib/features/design/surface/designConnector.js.map +1 -0
  317. package/lib/features/design/surface/designDocument.js +40 -0
  318. package/lib/features/design/surface/designDocument.js.map +1 -0
  319. package/lib/features/design/surface/designExport.js +55 -0
  320. package/lib/features/design/surface/designExport.js.map +1 -0
  321. package/lib/features/design/surface/designLinks.js +64 -0
  322. package/lib/features/design/surface/designLinks.js.map +1 -0
  323. package/lib/features/design/surface/designPalette.js +24 -0
  324. package/lib/features/design/surface/designPalette.js.map +1 -0
  325. package/lib/features/design/surface/designRun.js +161 -0
  326. package/lib/features/design/surface/designRun.js.map +1 -0
  327. package/lib/features/design/surface/designTheme.js +119 -0
  328. package/lib/features/design/surface/designTheme.js.map +1 -0
  329. package/lib/features/design/surface/execStream.js +206 -0
  330. package/lib/features/design/surface/execStream.js.map +1 -0
  331. package/lib/features/design/surface/metaball.js +48 -0
  332. package/lib/features/design/surface/metaball.js.map +1 -0
  333. package/lib/features/design/surface/pickReferenceFiles.js +35 -0
  334. package/lib/features/design/surface/pickReferenceFiles.js.map +1 -0
  335. package/lib/features/design/surface/useDesignSurface.js +379 -0
  336. package/lib/features/design/surface/useDesignSurface.js.map +1 -0
  337. package/lib/features/docs/DocBlockRow.js +336 -0
  338. package/lib/features/docs/DocBlockRow.js.map +1 -0
  339. package/lib/features/docs/DocsEditorExperience.js +949 -0
  340. package/lib/features/docs/DocsEditorExperience.js.map +1 -0
  341. package/lib/features/docs/DocsToolbar.js +247 -0
  342. package/lib/features/docs/DocsToolbar.js.map +1 -0
  343. package/lib/features/docs/blocks.js +560 -0
  344. package/lib/features/docs/blocks.js.map +1 -0
  345. package/lib/features/docs/docArtifacts.js +129 -0
  346. package/lib/features/docs/docArtifacts.js.map +1 -0
  347. package/lib/features/docs/docEdits.js +201 -0
  348. package/lib/features/docs/docEdits.js.map +1 -0
  349. package/lib/features/docs/docExport.js +235 -0
  350. package/lib/features/docs/docExport.js.map +1 -0
  351. package/lib/features/docs/docShare.js +62 -0
  352. package/lib/features/docs/docShare.js.map +1 -0
  353. package/lib/features/links/openInApp.js +38 -2
  354. package/lib/features/links/openInApp.js.map +1 -1
  355. package/lib/routes.json +54 -0
  356. package/lib/screens/DesignNative/index.js +35 -0
  357. package/lib/screens/DesignNative/index.js.map +1 -0
  358. package/package.json +4 -4
  359. package/lib/features/design/exportDesign.js +0 -133
  360. package/lib/features/design/exportDesign.js.map +0 -1
@@ -0,0 +1,949 @@
1
+ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useMemo,useRef,useState,useCallback,useEffect}from'react';import {useWindowDimensions,Keyboard,Alert,View,ActivityIndicator,Text,TextInput,KeyboardAvoidingView,FlatList,Modal,Platform,StyleSheet}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {useCanvasTheme,themedStyles}from'../canvas/canvasTheme.js';import {ActionButton,Pressable,SPACE,RADIUS,TYPE}from'../canvas/canvasUi.js';import {useSafeInsets}from'../canvas/withRemoteSafeArea.js';import {createDesignImagePicker}from'../design/pickDesignImage.js';import {emptyDocument,serialiseBlocks,flattenBlocks,updateBlock,isTextBlock,findBlock,inlineToRuns,runsText,applyTextChange,activeStyles,newBlock,moveBlock,outdentBlock,indentBlock,linkAt,toggleStyle,splitRuns,setLink,outlineOf,setColor,withTableCellRuns,tableCellRuns}from'./blocks.js';import {backspaceAtStart,applyLines,setBlockRuns,insertBlockAfter,deleteBlock,duplicateBlock,setBlockType}from'./docEdits.js';import {newDocId,loadOwnedDocArtifact,buildDocArtifact,saveDocArtifact}from'./docArtifacts.js';import {blocksToMarkdown,blocksToHtml,standaloneHtml,toWordHtml}from'./docExport.js';import {shareText,shareFile,sharePdf}from'./docShare.js';import {DocBlockRow}from'./DocBlockRow.js';import {ColorRow,DocsToolbar}from'./DocsToolbar.js';var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ const SAVE_DEBOUNCE_MS = 1200;
21
+ const HISTORY_LIMIT = 100;
22
+ const TYPING_COALESCE_MS = 1e3;
23
+ const commonAffixes = (a, b) => {
24
+ let prefix = 0;
25
+ const max = Math.min(a.length, b.length);
26
+ while (prefix < max && a[prefix] === b[prefix]) prefix += 1;
27
+ let suffix = 0;
28
+ while (suffix < max - prefix && a[a.length - 1 - suffix] === b[b.length - 1 - suffix]) suffix += 1;
29
+ return {
30
+ prefix,
31
+ suffix
32
+ };
33
+ };
34
+ function statusLabel(save) {
35
+ if (save.status === "saving") return "Saving...";
36
+ if (save.status === "saved") return "Saved";
37
+ if (save.status === "error") return save.error || "Not saved";
38
+ return "";
39
+ }
40
+ function DocsEditorExperience({
41
+ token,
42
+ indexUrl,
43
+ docId,
44
+ sessionId,
45
+ onClose,
46
+ onPickLocalMedia,
47
+ uploadMedia,
48
+ testID
49
+ }) {
50
+ const theme = useCanvasTheme();
51
+ const styles = makeStyles(theme);
52
+ const insets = useSafeInsets();
53
+ const {
54
+ width
55
+ } = useWindowDimensions();
56
+ const pageWidth = Math.min(width, 760) - SPACE.lg * 2;
57
+ const index = useMemo(() => indexUrl ? {
58
+ url: indexUrl,
59
+ token
60
+ } : null, [indexUrl, token]);
61
+ const pickImage = useMemo(() => createDesignImagePicker(onPickLocalMedia, uploadMedia), [onPickLocalMedia, uploadMedia]);
62
+ const idRef = useRef(docId && docId.startsWith("doc:") ? docId.trim() : newDocId());
63
+ const keepRef = useRef(sessionId ? {
64
+ sessionId
65
+ } : {});
66
+ const [phase, setPhase] = useState(docId ? "loading" : "ready");
67
+ const [loadError, setLoadError] = useState(null);
68
+ const [doc, setDoc] = useState(() => ({
69
+ title: "",
70
+ blocks: emptyDocument()
71
+ }));
72
+ const docRef = useRef(doc);
73
+ const past = useRef([]);
74
+ const future = useRef([]);
75
+ const lastEdit = useRef({
76
+ key: "",
77
+ at: 0
78
+ });
79
+ const [, setHistoryTick] = useState(0);
80
+ const [nonces, setNonces] = useState({});
81
+ const [epoch, setEpoch] = useState(0);
82
+ const savedRef = useRef(doc);
83
+ const [save, setSave] = useState({
84
+ status: "idle"
85
+ });
86
+ const commit = useCallback((next, coalesceKey) => {
87
+ const now = Date.now();
88
+ const last = lastEdit.current;
89
+ if (!coalesceKey || coalesceKey !== last.key || now - last.at > TYPING_COALESCE_MS) {
90
+ past.current.push(docRef.current);
91
+ if (past.current.length > HISTORY_LIMIT) past.current.shift();
92
+ }
93
+ lastEdit.current = {
94
+ key: coalesceKey != null ? coalesceKey : "",
95
+ at: now
96
+ };
97
+ future.current = [];
98
+ docRef.current = next;
99
+ setDoc(next);
100
+ setHistoryTick((n) => n + 1);
101
+ }, []);
102
+ const editBlocks = useCallback((blocks, coalesceKey) => {
103
+ if (blocks === docRef.current.blocks) return;
104
+ commit(__spreadProps(__spreadValues({}, docRef.current), {
105
+ blocks
106
+ }), coalesceKey);
107
+ }, [commit]);
108
+ const restore = useCallback((from, to) => {
109
+ const snap = from.current.pop();
110
+ if (!snap) return;
111
+ to.current.push(docRef.current);
112
+ lastEdit.current = {
113
+ key: "",
114
+ at: 0
115
+ };
116
+ docRef.current = snap;
117
+ setDoc(snap);
118
+ setEpoch((n) => n + 1);
119
+ setHistoryTick((n) => n + 1);
120
+ }, []);
121
+ const undo = useCallback(() => restore(past, future), [restore]);
122
+ const redo = useCallback(() => restore(future, past), [restore]);
123
+ const load = useCallback(async () => {
124
+ var _a;
125
+ if (!docId) return;
126
+ if (!index) {
127
+ setPhase("error");
128
+ setLoadError("Docs cannot be opened from this build.");
129
+ return;
130
+ }
131
+ setPhase("loading");
132
+ const result = await loadOwnedDocArtifact(index, docId);
133
+ if (result.artifact) {
134
+ const {
135
+ artifact
136
+ } = result;
137
+ idRef.current = artifact.id;
138
+ keepRef.current = __spreadValues(__spreadValues(__spreadValues({}, artifact.sessionId ? {
139
+ sessionId: artifact.sessionId
140
+ } : {}), artifact.thumbUrl ? {
141
+ thumbUrl: artifact.thumbUrl
142
+ } : {}), artifact.exportUrl ? {
143
+ exportUrl: artifact.exportUrl
144
+ } : {});
145
+ const snap = {
146
+ title: (_a = artifact.doc.title) != null ? _a : "",
147
+ blocks: artifact.doc.blocks.length ? artifact.doc.blocks : emptyDocument()
148
+ };
149
+ docRef.current = snap;
150
+ savedRef.current = snap;
151
+ past.current = [];
152
+ future.current = [];
153
+ setDoc(snap);
154
+ setEpoch((n) => n + 1);
155
+ setPhase("ready");
156
+ return;
157
+ }
158
+ setLoadError(result.error);
159
+ setPhase(result.error ? "error" : "missing");
160
+ }, [docId, index]);
161
+ useEffect(() => {
162
+ void load();
163
+ }, [load]);
164
+ const startNew = useCallback(() => {
165
+ idRef.current = newDocId();
166
+ const snap = {
167
+ title: "",
168
+ blocks: emptyDocument()
169
+ };
170
+ docRef.current = snap;
171
+ savedRef.current = snap;
172
+ past.current = [];
173
+ future.current = [];
174
+ setDoc(snap);
175
+ setPhase("ready");
176
+ }, []);
177
+ const savingRef = useRef(null);
178
+ const flush = useCallback(async () => {
179
+ if (savingRef.current) await savingRef.current;
180
+ const snap = docRef.current;
181
+ if (snap === savedRef.current) return true;
182
+ if (!index) {
183
+ setSave({
184
+ status: "error",
185
+ error: "Not saved: this build has no doc index."
186
+ });
187
+ return false;
188
+ }
189
+ const job = (async () => {
190
+ setSave({
191
+ status: "saving"
192
+ });
193
+ const artifact = buildDocArtifact(idRef.current, {
194
+ version: 2,
195
+ title: snap.title.trim(),
196
+ blocks: serialiseBlocks(snap.blocks),
197
+ updatedAt: Date.now()
198
+ }, keepRef.current);
199
+ const result = await saveDocArtifact(index, artifact);
200
+ if (result.ok) {
201
+ savedRef.current = snap;
202
+ setSave({
203
+ status: "saved"
204
+ });
205
+ } else {
206
+ setSave({
207
+ status: "error",
208
+ error: result.error
209
+ });
210
+ }
211
+ return result.ok;
212
+ })();
213
+ savingRef.current = job;
214
+ try {
215
+ return await job;
216
+ } finally {
217
+ savingRef.current = null;
218
+ }
219
+ }, [index]);
220
+ useEffect(() => {
221
+ if (phase !== "ready" || doc === savedRef.current) return void 0;
222
+ const timer = setTimeout(() => void flush(), SAVE_DEBOUNCE_MS);
223
+ return () => clearTimeout(timer);
224
+ }, [doc, phase, flush]);
225
+ const close = useCallback(async () => {
226
+ Keyboard.dismiss();
227
+ if (phase !== "ready" || docRef.current === savedRef.current) {
228
+ onClose();
229
+ return;
230
+ }
231
+ const ok = await flush();
232
+ if (ok) {
233
+ onClose();
234
+ return;
235
+ }
236
+ Alert.alert("Not saved", "Your latest edits could not be saved. Leave anyway?", [{
237
+ text: "Stay",
238
+ style: "cancel"
239
+ }, {
240
+ text: "Leave",
241
+ style: "destructive",
242
+ onPress: onClose
243
+ }]);
244
+ }, [phase, flush, onClose]);
245
+ const inputs = useRef(/* @__PURE__ */ new Map());
246
+ const selRef = useRef(null);
247
+ const [focusedId, setFocusedId] = useState(null);
248
+ const [selTick, setSelTick] = useState(0);
249
+ const pendingStyles = useRef(null);
250
+ const pendingFocus = useRef(null);
251
+ const listRef = useRef(null);
252
+ const [colorsOpen, setColorsOpen] = useState(false);
253
+ const [sheet, setSheet] = useState(null);
254
+ const [notice, setNotice] = useState(null);
255
+ useEffect(() => {
256
+ if (!notice) return void 0;
257
+ const timer = setTimeout(() => setNotice(null), 3200);
258
+ return () => clearTimeout(timer);
259
+ }, [notice]);
260
+ const flat = useMemo(() => flattenBlocks(doc.blocks), [doc.blocks]);
261
+ const focusBlock = useCallback((id, at) => {
262
+ pendingFocus.current = {
263
+ id,
264
+ at
265
+ };
266
+ setFocusedId(id);
267
+ }, []);
268
+ useEffect(() => {
269
+ const target = pendingFocus.current;
270
+ if (!target) return void 0;
271
+ let tries = 0;
272
+ let frame = null;
273
+ const attempt = () => {
274
+ var _a;
275
+ const input = inputs.current.get(target.id);
276
+ if (input) {
277
+ pendingFocus.current = null;
278
+ input.focus();
279
+ setTimeout(() => {
280
+ var _a2;
281
+ return (_a2 = input.setSelection) == null ? void 0 : _a2.call(input, target.at, target.at);
282
+ }, 30);
283
+ selRef.current = {
284
+ id: target.id,
285
+ start: target.at,
286
+ end: target.at
287
+ };
288
+ return;
289
+ }
290
+ const i = flat.findIndex((f) => f.block.id === target.id);
291
+ if (tries === 0 && i >= 0) (_a = listRef.current) == null ? void 0 : _a.scrollToIndex({
292
+ index: i,
293
+ viewPosition: 0.3,
294
+ animated: true
295
+ });
296
+ tries += 1;
297
+ if (tries < 10) frame = setTimeout(attempt, 50);
298
+ };
299
+ attempt();
300
+ return () => {
301
+ if (frame) clearTimeout(frame);
302
+ };
303
+ });
304
+ const handlers = useRef(null);
305
+ handlers.current = {
306
+ registerInput: (id, input) => {
307
+ if (input) inputs.current.set(id, input);
308
+ else inputs.current.delete(id);
309
+ },
310
+ onChangeText: (id, text) => {
311
+ const block = findBlock(docRef.current.blocks, id);
312
+ if (!block) return;
313
+ const prevRuns = inlineToRuns(block.content);
314
+ const prevText = runsText(prevRuns);
315
+ const runs = applyTextChange(prevRuns, text, void 0, pendingStyles.current);
316
+ pendingStyles.current = null;
317
+ if (block.type !== "codeBlock" && text.includes("\n")) {
318
+ const {
319
+ suffix
320
+ } = commonAffixes(prevText, text);
321
+ const result = applyLines(docRef.current.blocks, id, runs, suffix);
322
+ editBlocks(result.blocks);
323
+ setNonces((n) => {
324
+ var _a;
325
+ return __spreadProps(__spreadValues({}, n), {
326
+ [id]: ((_a = n[id]) != null ? _a : 0) + 1
327
+ });
328
+ });
329
+ if (result.focus) focusBlock(result.focus.id, result.focus.at);
330
+ return;
331
+ }
332
+ editBlocks(setBlockRuns(docRef.current.blocks, id, runs), `type:${id}`);
333
+ },
334
+ onSelection: (id, start, end) => {
335
+ const prev = selRef.current;
336
+ selRef.current = {
337
+ id,
338
+ start,
339
+ end
340
+ };
341
+ if (!prev || prev.id !== id || prev.start !== start || prev.end !== end) setSelTick((n) => n + 1);
342
+ },
343
+ onFocusBlock: (id) => {
344
+ var _a, _b;
345
+ if (((_a = selRef.current) == null ? void 0 : _a.id) !== id) {
346
+ pendingStyles.current = null;
347
+ if (!isTextBlock((_b = findBlock(docRef.current.blocks, id)) != null ? _b : {
348
+ type: ""
349
+ })) selRef.current = {
350
+ id,
351
+ start: 0,
352
+ end: 0
353
+ };
354
+ }
355
+ setFocusedId(id);
356
+ setColorsOpen(false);
357
+ },
358
+ onBackspace: (id) => {
359
+ const sel = selRef.current;
360
+ if (!sel || sel.id !== id || sel.start !== 0 || sel.end !== 0) return;
361
+ const result = backspaceAtStart(docRef.current.blocks, id);
362
+ if (!result) return;
363
+ editBlocks(result.blocks);
364
+ if (result.focus) {
365
+ if (result.focus.id !== id) setNonces((n) => {
366
+ var _a;
367
+ return __spreadProps(__spreadValues({}, n), {
368
+ [result.focus.id]: ((_a = n[result.focus.id]) != null ? _a : 0) + 1
369
+ });
370
+ });
371
+ focusBlock(result.focus.id, result.focus.at);
372
+ }
373
+ },
374
+ onToggleCheck: (id) => {
375
+ editBlocks(updateBlock(docRef.current.blocks, id, (b) => {
376
+ var _a;
377
+ return __spreadProps(__spreadValues({}, b), {
378
+ props: __spreadProps(__spreadValues({}, b.props), {
379
+ checked: !((_a = b.props) == null ? void 0 : _a.checked)
380
+ })
381
+ });
382
+ }));
383
+ },
384
+ onCaption: (id, caption) => {
385
+ editBlocks(updateBlock(docRef.current.blocks, id, (b) => __spreadProps(__spreadValues({}, b), {
386
+ props: __spreadProps(__spreadValues({}, b.props), {
387
+ caption
388
+ })
389
+ })), `caption:${id}`);
390
+ },
391
+ onCellText: (id, row, col, text) => {
392
+ editBlocks(updateBlock(docRef.current.blocks, id, (b) => {
393
+ const table = b.content;
394
+ if (!table || !Array.isArray(table.rows)) return b;
395
+ const rows = table.rows.map((r, ri) => ri !== row ? r : __spreadProps(__spreadValues({}, r), {
396
+ cells: r.cells.map((cell, ci) => ci !== col ? cell : withTableCellRuns(cell, applyTextChange(tableCellRuns(cell), text)))
397
+ }));
398
+ return __spreadProps(__spreadValues({}, b), {
399
+ content: __spreadProps(__spreadValues({}, table), {
400
+ rows
401
+ })
402
+ });
403
+ }), `cell:${id}:${row}:${col}`);
404
+ }
405
+ };
406
+ const stableHandlers = useMemo(() => ({
407
+ registerInput: (...a) => handlers.current.registerInput(...a),
408
+ onChangeText: (...a) => handlers.current.onChangeText(...a),
409
+ onSelection: (...a) => handlers.current.onSelection(...a),
410
+ onFocusBlock: (...a) => handlers.current.onFocusBlock(...a),
411
+ onBackspace: (...a) => handlers.current.onBackspace(...a),
412
+ onToggleCheck: (...a) => handlers.current.onToggleCheck(...a),
413
+ onCaption: (...a) => handlers.current.onCaption(...a),
414
+ onCellText: (...a) => handlers.current.onCellText(...a)
415
+ }), []);
416
+ const focused = focusedId ? findBlock(doc.blocks, focusedId) : null;
417
+ const toolbarState = useMemo(() => {
418
+ var _a, _b, _c;
419
+ if (!focused) return null;
420
+ const sel = ((_a = selRef.current) == null ? void 0 : _a.id) === focused.id ? selRef.current : null;
421
+ const runs = inlineToRuns(focused.content);
422
+ const active = sel ? activeStyles(runs, sel.start, sel.end) : /* @__PURE__ */ new Set();
423
+ if (pendingStyles.current) {
424
+ for (const key of ["bold", "italic", "underline", "strike", "code"]) {
425
+ if (pendingStyles.current[key]) active.add(key);
426
+ else active.delete(key);
427
+ }
428
+ }
429
+ return {
430
+ blockType: focused.type,
431
+ level: focused.type === "heading" ? Number((_b = focused.props) == null ? void 0 : _b.level) || 1 : void 0,
432
+ textBlock: isTextBlock(focused),
433
+ active,
434
+ align: typeof ((_c = focused.props) == null ? void 0 : _c.textAlignment) === "string" ? focused.props.textAlignment : "left",
435
+ canImage: Boolean(pickImage)
436
+ };
437
+ }, [focused, selTick, pickImage]);
438
+ const applyToSelection = useCallback((fn) => {
439
+ const sel = selRef.current;
440
+ if (!sel) return;
441
+ const block = findBlock(docRef.current.blocks, sel.id);
442
+ if (!block || !isTextBlock(block)) return;
443
+ const runs = inlineToRuns(block.content);
444
+ editBlocks(setBlockRuns(docRef.current.blocks, sel.id, fn(runs, sel.start, sel.end)));
445
+ }, [editBlocks]);
446
+ const insertImage = useCallback(async () => {
447
+ var _a, _b;
448
+ if (!pickImage) return;
449
+ try {
450
+ setNotice("Adding picture...");
451
+ const picked = await pickImage();
452
+ if (!picked) {
453
+ setNotice(null);
454
+ return;
455
+ }
456
+ const block = newBlock("image", {
457
+ url: picked.src,
458
+ name: (_b = (_a = picked.src.split("/").pop()) == null ? void 0 : _a.split("?")[0]) != null ? _b : ""
459
+ });
460
+ editBlocks(insertBlockAfter(docRef.current.blocks, focusedId, block));
461
+ setFocusedId(block.id);
462
+ setNotice(null);
463
+ } catch (err) {
464
+ setNotice(err instanceof Error ? err.message : "Could not add that picture.");
465
+ }
466
+ }, [pickImage, editBlocks, focusedId]);
467
+ const onToolbar = useCallback((action) => {
468
+ var _a, _b, _c, _d, _e, _f, _g, _h;
469
+ const id = focusedId;
470
+ if (action.type === "done") {
471
+ Keyboard.dismiss();
472
+ setColorsOpen(false);
473
+ return;
474
+ }
475
+ if (action.type === "image") {
476
+ void insertImage();
477
+ return;
478
+ }
479
+ if (action.type === "table") {
480
+ const table = newBlock("table");
481
+ const after = newBlock("paragraph");
482
+ let blocks2 = insertBlockAfter(docRef.current.blocks, id, table);
483
+ blocks2 = insertBlockAfter(blocks2, table.id, after);
484
+ editBlocks(blocks2);
485
+ setFocusedId(table.id);
486
+ return;
487
+ }
488
+ if (!id) return;
489
+ const blocks = docRef.current.blocks;
490
+ switch (action.type) {
491
+ case "blockType": {
492
+ const block = findBlock(blocks, id);
493
+ if (!block) return;
494
+ const same = block.type === action.blockType && (action.level === void 0 || Number((_a = block.props) == null ? void 0 : _a.level) === action.level);
495
+ const type = same && action.blockType !== "paragraph" && action.blockType !== "heading" ? "paragraph" : action.blockType;
496
+ editBlocks(setBlockType(blocks, id, type, type === "heading" ? {
497
+ level: (_b = action.level) != null ? _b : 1
498
+ } : {}));
499
+ return;
500
+ }
501
+ case "style": {
502
+ const sel = selRef.current;
503
+ if (sel && sel.id === id && sel.end === sel.start) {
504
+ const block = findBlock(blocks, id);
505
+ const on = activeStyles(inlineToRuns(block == null ? void 0 : block.content), sel.start, sel.end);
506
+ const base = (_c = pendingStyles.current) != null ? _c : {};
507
+ const armed = __spreadValues({}, base);
508
+ if (!pendingStyles.current) for (const s of on) armed[s] = true;
509
+ if (armed[action.style]) delete armed[action.style];
510
+ else armed[action.style] = true;
511
+ pendingStyles.current = armed;
512
+ setSelTick((n) => n + 1);
513
+ return;
514
+ }
515
+ applyToSelection((runs, start, end) => toggleStyle(runs, start, end, action.style));
516
+ return;
517
+ }
518
+ case "link": {
519
+ const sel = selRef.current;
520
+ if (!sel || sel.id !== id) return;
521
+ const block = findBlock(blocks, id);
522
+ const runs = inlineToRuns(block == null ? void 0 : block.content);
523
+ let {
524
+ start,
525
+ end
526
+ } = sel;
527
+ const existing = (_d = linkAt(runs, start)) != null ? _d : start > 0 ? linkAt(runs, start - 1) : null;
528
+ if (start === end && existing) {
529
+ let pos = 0;
530
+ for (const run of runs) {
531
+ const runEnd = pos + run.text.length;
532
+ if (run.href === existing && start >= pos && start <= runEnd) {
533
+ start = pos;
534
+ end = runEnd;
535
+ break;
536
+ }
537
+ pos = runEnd;
538
+ }
539
+ }
540
+ setSheet({
541
+ type: "link",
542
+ id,
543
+ start,
544
+ end,
545
+ href: existing != null ? existing : ""
546
+ });
547
+ return;
548
+ }
549
+ case "colors":
550
+ setColorsOpen((open) => !open);
551
+ return;
552
+ case "align":
553
+ editBlocks(updateBlock(blocks, id, (b) => __spreadProps(__spreadValues({}, b), {
554
+ props: __spreadProps(__spreadValues({}, b.props), {
555
+ textAlignment: action.align
556
+ })
557
+ })));
558
+ return;
559
+ case "indent":
560
+ editBlocks(indentBlock(blocks, id));
561
+ focusBlock(id, (_f = (_e = selRef.current) == null ? void 0 : _e.start) != null ? _f : 0);
562
+ return;
563
+ case "outdent":
564
+ editBlocks(outdentBlock(blocks, id));
565
+ focusBlock(id, (_h = (_g = selRef.current) == null ? void 0 : _g.start) != null ? _h : 0);
566
+ return;
567
+ case "move":
568
+ editBlocks(moveBlock(blocks, id, action.dir));
569
+ return;
570
+ case "duplicate":
571
+ editBlocks(duplicateBlock(blocks, id));
572
+ return;
573
+ case "delete": {
574
+ const result = deleteBlock(blocks, id);
575
+ editBlocks(result.blocks);
576
+ if (result.focus) focusBlock(result.focus.id, result.focus.at);
577
+ else setFocusedId(null);
578
+ return;
579
+ }
580
+ }
581
+ }, [focusedId, editBlocks, applyToSelection, insertImage, focusBlock]);
582
+ const applyLink = useCallback((href) => {
583
+ if (!sheet || typeof sheet !== "object") return;
584
+ const clean = href.trim();
585
+ const url = clean && !/^[a-z][a-z0-9+.-]*:/i.test(clean) ? `https://${clean}` : clean;
586
+ const {
587
+ id,
588
+ start,
589
+ end
590
+ } = sheet;
591
+ const block = findBlock(docRef.current.blocks, id);
592
+ if (!block) return;
593
+ let runs = inlineToRuns(block.content);
594
+ if (start === end) {
595
+ if (!url) return;
596
+ const [before, after] = splitRuns(runs, start);
597
+ runs = [...before, {
598
+ text: url,
599
+ styles: {},
600
+ href: url
601
+ }, ...after];
602
+ } else {
603
+ runs = setLink(runs, start, end, url || null);
604
+ }
605
+ editBlocks(setBlockRuns(docRef.current.blocks, id, runs));
606
+ setNonces((n) => {
607
+ var _a;
608
+ return __spreadProps(__spreadValues({}, n), {
609
+ [id]: ((_a = n[id]) != null ? _a : 0) + 1
610
+ });
611
+ });
612
+ setSheet(null);
613
+ }, [sheet, editBlocks]);
614
+ const outline = useMemo(() => sheet === "outline" ? outlineOf(doc.blocks) : [], [sheet, doc.blocks]);
615
+ const jumpTo = useCallback((id) => {
616
+ var _a;
617
+ setSheet(null);
618
+ const i = flat.findIndex((f) => f.block.id === id);
619
+ if (i >= 0) (_a = listRef.current) == null ? void 0 : _a.scrollToIndex({
620
+ index: i,
621
+ viewPosition: 0.1,
622
+ animated: true
623
+ });
624
+ const block = findBlock(docRef.current.blocks, id);
625
+ focusBlock(id, runsText(inlineToRuns(block == null ? void 0 : block.content)).length);
626
+ }, [flat, focusBlock]);
627
+ const exportAs = useCallback(async (format) => {
628
+ setSheet(null);
629
+ const {
630
+ title: rawTitle,
631
+ blocks
632
+ } = docRef.current;
633
+ const title = rawTitle.trim() || "Untitled doc";
634
+ try {
635
+ if (format === "md") {
636
+ await shareText(`${rawTitle.trim() ? `# ${rawTitle.trim()}
637
+
638
+ ` : ""}${blocksToMarkdown(blocks)}`, title);
639
+ return;
640
+ }
641
+ const body = blocksToHtml(blocks);
642
+ if (format === "html") await shareFile(title, "html", standaloneHtml(title, body), "text/html");
643
+ else if (format === "pdf") await sharePdf(title, standaloneHtml(title, body));
644
+ else {
645
+ const outcome = await shareFile(title, "doc", toWordHtml(title, body), "application/msword");
646
+ if (outcome === "saved") setNotice("Saved for Word.");
647
+ }
648
+ } catch (err) {
649
+ setNotice(err instanceof Error ? err.message : "Could not export this doc.");
650
+ }
651
+ }, []);
652
+ if (phase !== "ready") {
653
+ return /* @__PURE__ */ jsx(View, { style: [styles.root, styles.center, {
654
+ paddingTop: insets.top
655
+ }], testID, children: phase === "loading" ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.edInk }) : /* @__PURE__ */ jsxs(View, { style: styles.message, children: [
656
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "file-document-outline", size: 36, color: theme.mutedForeground }),
657
+ /* @__PURE__ */ jsx(Text, { style: styles.messageTitle, children: phase === "missing" ? "This doc is not in your docs" : "Could not open this doc" }),
658
+ loadError ? /* @__PURE__ */ jsx(Text, { style: styles.messageBody, children: loadError }) : null,
659
+ phase === "error" && index ? /* @__PURE__ */ jsx(ActionButton, { label: "Try again", onPress: () => void load() }) : null,
660
+ /* @__PURE__ */ jsx(ActionButton, { label: "Start a new doc", variant: "secondary", onPress: startNew }),
661
+ /* @__PURE__ */ jsx(ActionButton, { label: "Back", variant: "secondary", onPress: onClose })
662
+ ] }) });
663
+ }
664
+ const header = /* @__PURE__ */ jsx(TextInput, { defaultValue: doc.title, onChangeText: (title) => commit(__spreadProps(__spreadValues({}, docRef.current), {
665
+ title
666
+ }), "title"), onFocus: () => setFocusedId(null), placeholder: "Untitled doc", placeholderTextColor: theme.mutedForeground, style: styles.titleInput, multiline: true, scrollEnabled: false, blurOnSubmit: true, returnKeyType: "next", onSubmitEditing: () => {
667
+ const first = flat.find((f) => isTextBlock(f.block));
668
+ if (first) focusBlock(first.block.id, 0);
669
+ }, accessibilityLabel: "Doc title" }, `title-${epoch}`);
670
+ const footer = /* @__PURE__ */ jsx(Pressable, { onPress: () => {
671
+ const last = doc.blocks[doc.blocks.length - 1];
672
+ if (last && isTextBlock(last) && !runsText(inlineToRuns(last.content))) {
673
+ focusBlock(last.id, 0);
674
+ return;
675
+ }
676
+ const block = newBlock("paragraph");
677
+ editBlocks([...docRef.current.blocks, block]);
678
+ focusBlock(block.id, 0);
679
+ }, style: styles.tail, accessibilityRole: "button", accessibilityLabel: "Write at the end" });
680
+ const topButton = (icon, label, onPress, disabled) => /* @__PURE__ */ jsx(Pressable, { onPress, disabled, hitSlop: 6, style: [styles.topButton, disabled && styles.disabled], accessibilityRole: "button", accessibilityLabel: label, children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: icon, size: 22, color: theme.edInk }) });
681
+ return /* @__PURE__ */ jsxs(KeyboardAvoidingView, { style: [styles.root, {
682
+ paddingTop: insets.top
683
+ }], behavior: Platform.OS === "ios" ? "padding" : void 0, testID, children: [
684
+ /* @__PURE__ */ jsxs(View, { style: styles.topBar, children: [
685
+ topButton("chevron-left", "Back", () => void close()),
686
+ /* @__PURE__ */ jsxs(View, { style: styles.titleWrap, children: [
687
+ /* @__PURE__ */ jsx(Text, { style: styles.barTitle, numberOfLines: 1, children: doc.title.trim() || "Untitled doc" }),
688
+ /* @__PURE__ */ jsx(Text, { style: [styles.status, save.status === "error" && {
689
+ color: theme.edDanger
690
+ }], numberOfLines: 1, children: statusLabel(save) })
691
+ ] }),
692
+ topButton("undo", "Undo", undo, past.current.length === 0),
693
+ topButton("redo", "Redo", redo, future.current.length === 0),
694
+ topButton("format-list-text", "Outline", () => setSheet("outline")),
695
+ topButton("export-variant", "Export", () => setSheet("export"))
696
+ ] }),
697
+ /* @__PURE__ */ jsx(FlatList, { ref: listRef, data: flat, keyExtractor: (item) => item.block.id, renderItem: ({
698
+ item
699
+ }) => {
700
+ var _a;
701
+ return /* @__PURE__ */ jsx(DocBlockRow, { flat: item, selected: item.block.id === focusedId && !isTextBlock(item.block), nonce: ((_a = nonces[item.block.id]) != null ? _a : 0) + epoch * 1e3, width: pageWidth, theme, handlers: stableHandlers });
702
+ }, extraData: `${focusedId}:${epoch}:${JSON.stringify(nonces)}`, ListHeaderComponent: header, ListFooterComponent: footer, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "none", removeClippedSubviews: false, contentContainerStyle: [styles.page, {
703
+ width: pageWidth + SPACE.lg * 2
704
+ }], style: styles.list, onScrollToIndexFailed: (info) => {
705
+ var _a;
706
+ return (_a = listRef.current) == null ? void 0 : _a.scrollToOffset({
707
+ offset: info.averageItemLength * info.index,
708
+ animated: true
709
+ });
710
+ } }),
711
+ notice ? /* @__PURE__ */ jsx(View, { pointerEvents: "none", style: styles.toast, children: /* @__PURE__ */ jsx(Text, { style: styles.toastText, numberOfLines: 2, children: notice }) }) : null,
712
+ colorsOpen && (toolbarState == null ? void 0 : toolbarState.textBlock) ? /* @__PURE__ */ jsx(ColorRow, { theme, onPick: (key, color) => {
713
+ const sel = selRef.current;
714
+ if (sel && sel.start === sel.end && focusedId) {
715
+ editBlocks(updateBlock(docRef.current.blocks, focusedId, (b) => __spreadProps(__spreadValues({}, b), {
716
+ props: __spreadProps(__spreadValues({}, b.props), {
717
+ [key]: color
718
+ })
719
+ })));
720
+ } else {
721
+ applyToSelection((runs, start, end) => setColor(runs, start, end, key, color));
722
+ }
723
+ } }) : null,
724
+ toolbarState ? /* @__PURE__ */ jsx(DocsToolbar, { state: toolbarState, theme, onAction: onToolbar }) : /* @__PURE__ */ jsx(View, { style: {
725
+ height: insets.bottom
726
+ } }),
727
+ /* @__PURE__ */ jsx(Modal, { visible: sheet !== null, transparent: true, animationType: "slide", onRequestClose: () => setSheet(null), children: /* @__PURE__ */ jsxs(KeyboardAvoidingView, { style: styles.fill, behavior: Platform.OS === "ios" ? "padding" : void 0, children: [
728
+ /* @__PURE__ */ jsx(Pressable, { style: styles.scrim, onPress: () => setSheet(null), accessibilityLabel: "Close" }),
729
+ /* @__PURE__ */ jsxs(View, { style: [styles.sheet, {
730
+ paddingBottom: insets.bottom + SPACE.lg
731
+ }], children: [
732
+ sheet === "outline" ? /* @__PURE__ */ jsxs(Fragment, { children: [
733
+ /* @__PURE__ */ jsx(Text, { style: styles.sheetTitle, children: "Outline" }),
734
+ outline.length === 0 ? /* @__PURE__ */ jsx(Text, { style: styles.sheetEmpty, children: "Headings you add show here." }) : /* @__PURE__ */ jsx(FlatList, { data: outline, keyExtractor: (e) => e.id, style: styles.outlineList, renderItem: ({
735
+ item
736
+ }) => /* @__PURE__ */ jsx(Pressable, { onPress: () => jumpTo(item.id), style: ({
737
+ pressed
738
+ }) => [styles.outlineRow, {
739
+ paddingLeft: SPACE.md + (item.level - 1) * SPACE.lg
740
+ }, pressed && styles.pressed], accessibilityRole: "button", children: /* @__PURE__ */ jsx(Text, { style: [styles.outlineText, item.level === 1 && styles.outlineH1], numberOfLines: 2, children: item.text }) }) })
741
+ ] }) : null,
742
+ sheet === "export" ? /* @__PURE__ */ jsxs(Fragment, { children: [
743
+ /* @__PURE__ */ jsx(Text, { style: styles.sheetTitle, children: "Export" }),
744
+ [{
745
+ id: "pdf",
746
+ icon: "file-pdf-box",
747
+ label: "PDF",
748
+ hint: "Print or save as PDF"
749
+ }, {
750
+ id: "doc",
751
+ icon: "file-word-outline",
752
+ label: "Word",
753
+ hint: "Opens in Word and Google Docs"
754
+ }, {
755
+ id: "html",
756
+ icon: "language-html5",
757
+ label: "Web page",
758
+ hint: "A standalone HTML file"
759
+ }, {
760
+ id: "md",
761
+ icon: "language-markdown-outline",
762
+ label: "Markdown",
763
+ hint: "Plain text with formatting marks"
764
+ }].map((opt) => /* @__PURE__ */ jsxs(Pressable, { onPress: () => void exportAs(opt.id), style: ({
765
+ pressed
766
+ }) => [styles.exportRow, pressed && styles.pressed], accessibilityRole: "button", accessibilityLabel: `Export as ${opt.label}`, children: [
767
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: opt.icon, size: 24, color: theme.edInk }),
768
+ /* @__PURE__ */ jsxs(View, { style: styles.exportText, children: [
769
+ /* @__PURE__ */ jsx(Text, { style: styles.exportLabel, children: opt.label }),
770
+ /* @__PURE__ */ jsx(Text, { style: styles.exportHint, children: opt.hint })
771
+ ] })
772
+ ] }, opt.id))
773
+ ] }) : null,
774
+ sheet && typeof sheet === "object" ? /* @__PURE__ */ jsx(LinkForm, { sheet, theme, onApply: applyLink, onCancel: () => setSheet(null) }) : null
775
+ ] })
776
+ ] }) })
777
+ ] });
778
+ }
779
+ function LinkForm({
780
+ sheet,
781
+ theme,
782
+ onApply,
783
+ onCancel
784
+ }) {
785
+ const styles = makeStyles(theme);
786
+ const [href, setHref] = useState(sheet.href);
787
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
788
+ /* @__PURE__ */ jsx(Text, { style: styles.sheetTitle, children: sheet.href ? "Edit link" : "Add link" }),
789
+ /* @__PURE__ */ jsx(TextInput, { value: href, onChangeText: setHref, autoFocus: true, autoCapitalize: "none", autoCorrect: false, keyboardType: "url", placeholder: "https://", placeholderTextColor: theme.mutedForeground, style: styles.linkInput, onSubmitEditing: () => onApply(href), returnKeyType: "done" }),
790
+ /* @__PURE__ */ jsxs(View, { style: styles.linkActions, children: [
791
+ sheet.href ? /* @__PURE__ */ jsx(ActionButton, { label: "Remove", variant: "secondary", onPress: () => onApply("") }) : null,
792
+ /* @__PURE__ */ jsx(ActionButton, { label: "Cancel", variant: "secondary", onPress: onCancel }),
793
+ /* @__PURE__ */ jsx(ActionButton, { label: "Apply", onPress: () => onApply(href), disabled: !href.trim() })
794
+ ] })
795
+ ] });
796
+ }
797
+ const makeStyles = themedStyles((t) => StyleSheet.create({
798
+ root: {
799
+ flex: 1,
800
+ backgroundColor: t.background
801
+ },
802
+ fill: {
803
+ flex: 1
804
+ },
805
+ center: {
806
+ alignItems: "center",
807
+ justifyContent: "center"
808
+ },
809
+ message: {
810
+ alignItems: "center",
811
+ gap: SPACE.md,
812
+ padding: SPACE.xl
813
+ },
814
+ messageTitle: __spreadProps(__spreadValues({}, TYPE.title), {
815
+ color: t.foreground,
816
+ textAlign: "center"
817
+ }),
818
+ messageBody: __spreadProps(__spreadValues({}, TYPE.body), {
819
+ color: t.mutedForeground,
820
+ textAlign: "center"
821
+ }),
822
+ topBar: {
823
+ flexDirection: "row",
824
+ alignItems: "center",
825
+ paddingHorizontal: SPACE.xs,
826
+ height: 52,
827
+ borderBottomWidth: StyleSheet.hairlineWidth,
828
+ borderBottomColor: t.border
829
+ },
830
+ topButton: {
831
+ width: 40,
832
+ height: 40,
833
+ alignItems: "center",
834
+ justifyContent: "center"
835
+ },
836
+ disabled: {
837
+ opacity: 0.35
838
+ },
839
+ titleWrap: {
840
+ flex: 1,
841
+ paddingHorizontal: SPACE.xs
842
+ },
843
+ barTitle: __spreadProps(__spreadValues({}, TYPE.label), {
844
+ color: t.foreground
845
+ }),
846
+ status: __spreadProps(__spreadValues({}, TYPE.caption), {
847
+ color: t.mutedForeground
848
+ }),
849
+ list: {
850
+ flex: 1
851
+ },
852
+ page: {
853
+ alignSelf: "center",
854
+ paddingHorizontal: SPACE.lg,
855
+ paddingTop: SPACE.lg
856
+ },
857
+ titleInput: __spreadProps(__spreadValues({}, TYPE.display), {
858
+ fontSize: 32,
859
+ lineHeight: 40,
860
+ color: t.foreground,
861
+ padding: 0,
862
+ marginBottom: SPACE.md
863
+ }),
864
+ tail: {
865
+ minHeight: 240
866
+ },
867
+ toast: {
868
+ position: "absolute",
869
+ left: SPACE.lg,
870
+ right: SPACE.lg,
871
+ bottom: 72,
872
+ padding: SPACE.md,
873
+ borderRadius: RADIUS.md,
874
+ backgroundColor: t.edInk
875
+ },
876
+ toastText: __spreadProps(__spreadValues({}, TYPE.label), {
877
+ color: t.edOnInk,
878
+ textAlign: "center"
879
+ }),
880
+ scrim: {
881
+ flex: 1,
882
+ backgroundColor: "rgba(0,0,0,0.35)"
883
+ },
884
+ sheet: {
885
+ backgroundColor: t.surface,
886
+ borderTopLeftRadius: RADIUS.xl,
887
+ borderTopRightRadius: RADIUS.xl,
888
+ paddingTop: SPACE.lg,
889
+ paddingHorizontal: SPACE.lg,
890
+ maxHeight: "75%"
891
+ },
892
+ sheetTitle: __spreadProps(__spreadValues({}, TYPE.title), {
893
+ color: t.foreground,
894
+ marginBottom: SPACE.md
895
+ }),
896
+ sheetEmpty: __spreadProps(__spreadValues({}, TYPE.body), {
897
+ color: t.mutedForeground,
898
+ paddingVertical: SPACE.lg
899
+ }),
900
+ outlineList: {
901
+ flexGrow: 0
902
+ },
903
+ outlineRow: {
904
+ paddingVertical: SPACE.md,
905
+ paddingRight: SPACE.md,
906
+ borderRadius: RADIUS.sm
907
+ },
908
+ outlineText: __spreadProps(__spreadValues({}, TYPE.body), {
909
+ color: t.inkSoft
910
+ }),
911
+ outlineH1: {
912
+ fontWeight: "600",
913
+ color: t.foreground
914
+ },
915
+ pressed: {
916
+ backgroundColor: t.tint(0.06)
917
+ },
918
+ exportRow: {
919
+ flexDirection: "row",
920
+ alignItems: "center",
921
+ gap: SPACE.md,
922
+ paddingVertical: SPACE.md,
923
+ paddingHorizontal: SPACE.sm,
924
+ borderRadius: RADIUS.md
925
+ },
926
+ exportText: {
927
+ flex: 1
928
+ },
929
+ exportLabel: __spreadProps(__spreadValues({}, TYPE.label), {
930
+ color: t.foreground
931
+ }),
932
+ exportHint: __spreadProps(__spreadValues({}, TYPE.caption), {
933
+ color: t.mutedForeground
934
+ }),
935
+ linkInput: __spreadProps(__spreadValues({}, TYPE.body), {
936
+ color: t.foreground,
937
+ borderWidth: 1,
938
+ borderColor: t.borderStrong,
939
+ borderRadius: RADIUS.md,
940
+ paddingHorizontal: SPACE.md,
941
+ paddingVertical: SPACE.sm,
942
+ marginBottom: SPACE.md
943
+ }),
944
+ linkActions: {
945
+ flexDirection: "row",
946
+ justifyContent: "flex-end",
947
+ gap: SPACE.sm
948
+ }
949
+ }));export{DocsEditorExperience};//# sourceMappingURL=DocsEditorExperience.js.map