@mgamadeus/ddd-agents 0.0.0-stage → 0.1.0-alpha.21
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 +21 -0
- package/README.md +14 -2
- package/dist/chat.js +5263 -0
- package/dist/chat.js.map +1 -0
- package/dist/chunks/AgentsConversationClientContext-C4T7g_Qk.js +22 -0
- package/dist/chunks/AgentsConversationClientContext-C4T7g_Qk.js.map +1 -0
- package/dist/chunks/ConversationMarkdown-W7NHglmL.js +399 -0
- package/dist/chunks/ConversationMarkdown-W7NHglmL.js.map +1 -0
- package/dist/chunks/WebSearchResultsConversationWidget-BvnLWHyi.js +5059 -0
- package/dist/chunks/WebSearchResultsConversationWidget-BvnLWHyi.js.map +1 -0
- package/dist/chunks/canvas-behaviours-BRFR1ALE.js +45 -0
- package/dist/chunks/canvas-behaviours-BRFR1ALE.js.map +1 -0
- package/dist/chunks/canvas-feature-flags-BmmxC3bz.js +11 -0
- package/dist/chunks/canvas-feature-flags-BmmxC3bz.js.map +1 -0
- package/dist/chunks/canvasBodies-9SuF6NAB.js +289 -0
- package/dist/chunks/canvasBodies-9SuF6NAB.js.map +1 -0
- package/dist/chunks/d3-7.6.1.min.js-DTmPafrl.js +6 -0
- package/dist/chunks/d3-7.6.1.min.js-DTmPafrl.js.map +1 -0
- package/dist/chunks/decide-canvas-open-Ct-wnNEJ.js +20 -0
- package/dist/chunks/decide-canvas-open-Ct-wnNEJ.js.map +1 -0
- package/dist/chunks/widget-image-readiness-signal-DeOuL89j.js +25 -0
- package/dist/chunks/widget-image-readiness-signal-DeOuL89j.js.map +1 -0
- package/dist/chunks/widget-name-resolver-DyIY6Zu4.js +9736 -0
- package/dist/chunks/widget-name-resolver-DyIY6Zu4.js.map +1 -0
- package/dist/chunks/withPollingChangeSubscription-BLDAWF-o.js +251 -0
- package/dist/chunks/withPollingChangeSubscription-BLDAWF-o.js.map +1 -0
- package/dist/client-testing.js +346 -0
- package/dist/client-testing.js.map +1 -0
- package/dist/client.js +16 -0
- package/dist/client.js.map +1 -0
- package/dist/contract.js +31 -0
- package/dist/contract.js.map +1 -0
- package/dist/image-render.js +334 -0
- package/dist/image-render.js.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/kit.js +13 -0
- package/dist/kit.js.map +1 -0
- package/dist/preview.js +733 -0
- package/dist/preview.js.map +1 -0
- package/dist/renderer.js +115 -0
- package/dist/renderer.js.map +1 -0
- package/dist/styles.css +6768 -0
- package/dist/types/chat/AgentChat/AgentChat.d.ts +37 -0
- package/dist/types/chat/AgentChatActivityHistory/AgentChatActivityHistory.d.ts +6 -0
- package/dist/types/chat/AgentChatActivityIndicator/AgentChatActivityIndicator.d.ts +8 -0
- package/dist/types/chat/CanvasPane/CanvasPane.d.ts +15 -0
- package/dist/types/chat/CanvasResizeHandle/CanvasResizeHandle.d.ts +10 -0
- package/dist/types/chat/CanvasResizeHandle/use-canvas-resize.d.ts +43 -0
- package/dist/types/chat/ConversationClosedBar/ConversationClosedBar.d.ts +10 -0
- package/dist/types/chat/ConversationErrorCard/ConversationErrorCard.d.ts +13 -0
- package/dist/types/chat/ConversationIntroCard/ConversationIntroCard.d.ts +10 -0
- package/dist/types/chat/ConversationLoadingStates.d.ts +2 -0
- package/dist/types/chat/ConversationMessage/ConversationCallMarkerChip/ConversationCallMarkerChip.d.ts +14 -0
- package/dist/types/chat/ConversationMessage/ConversationCallMarkerChip/VoiceBarsIcon/VoiceBarsIcon.d.ts +8 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageSystem/ConversationMessageSystem.d.ts +8 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageSystem/ConversationMessageSystemHeader/ConversationMessageSystemHeader.d.ts +9 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageUser/ConversationMessageUser.d.ts +7 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageUser/ConversationMessageUserWidgets.d.ts +14 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageHeader/ConversationMessageHeader.d.ts +7 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageThinking/ConversationMessageThinking.d.ts +7 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageWidgets.d.ts +29 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageWidgets/copyRichToClipboard.d.ts +1 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageWidgets/hooks/useFreshMessageBlockReveal.d.ts +14 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageWidgets/hooks/useStreamingText.d.ts +8 -0
- package/dist/types/chat/ConversationMessage/ConversationMessageWidgets/hooks/useTypewriter.d.ts +12 -0
- package/dist/types/chat/ConversationMessage/ConversationTaskInstructionDisclosure/ConversationTaskInstructionDisclosure.d.ts +12 -0
- package/dist/types/chat/ConversationMessageInput/ConversationMessageInput.d.ts +111 -0
- package/dist/types/chat/ConversationMessageInput/ConversationMessageInputAttachments/ConversationMessageInputAttachmentPreviewCard.d.ts +34 -0
- package/dist/types/chat/ConversationMessageInput/ConversationMessageInputAttachments/ConversationMessageInputAttachmentsErrorBox.d.ts +22 -0
- package/dist/types/chat/ConversationMessageInput/ConversationMessageInputAttachments/ConversationMessageInputAttachmentsPreviewStrip.d.ts +12 -0
- package/dist/types/chat/ConversationMessageInput/ConversationMessageInputAttachments/convert-bytes-to-size-string.d.ts +2 -0
- package/dist/types/chat/ConversationMessageInput/ConversationMessageInputComposerWidgets/ConversationMessageInputComposerWidgets.d.ts +12 -0
- package/dist/types/chat/ConversationMessageList/ConversationMessageList.d.ts +75 -0
- package/dist/types/chat/ConversationScrollToLatestMessageButton/ConversationScrollToLatestMessageButton.d.ts +6 -0
- package/dist/types/chat/ConversationSuggestionCard/ConversationSuggestionCard.d.ts +7 -0
- package/dist/types/chat/ConversationView.d.ts +216 -0
- package/dist/types/chat/ConversationViewBody/ConversationViewBody.d.ts +214 -0
- package/dist/types/chat/ConversationViewBody/hooks/useIsMessagesBottomOutOfView.d.ts +2 -0
- package/dist/types/chat/ConversationViewBody/hooks/usePinQuestionOnSend.d.ts +24 -0
- package/dist/types/chat/assistant-message-has-renderable-markdown.d.ts +13 -0
- package/dist/types/chat/chat-assistant-identity.d.ts +24 -0
- package/dist/types/chat/chat-message.d.ts +11 -0
- package/dist/types/chat/controller/AgentChatController.d.ts +97 -0
- package/dist/types/chat/controller/activity-ticker.d.ts +120 -0
- package/dist/types/chat/controller/changed-messages-request.d.ts +12 -0
- package/dist/types/chat/controller/chat-scroll-target.d.ts +10 -0
- package/dist/types/chat/controller/conversation-change-signal-rules.d.ts +64 -0
- package/dist/types/chat/controller/derive-agent-activity.d.ts +31 -0
- package/dist/types/chat/controller/merge-activity-elements.d.ts +25 -0
- package/dist/types/chat/controller/pending-start-request.d.ts +38 -0
- package/dist/types/chat/controller/use-activity-ticker.d.ts +60 -0
- package/dist/types/chat/controller/use-conversation-activity.d.ts +38 -0
- package/dist/types/chat/controller/use-conversation-live-updates.d.ts +30 -0
- package/dist/types/chat/controller/use-conversation-message-pages.d.ts +24 -0
- package/dist/types/chat/controller/use-conversation-scroll-jump.d.ts +47 -0
- package/dist/types/chat/controller/use-conversation-search.d.ts +31 -0
- package/dist/types/chat/controller/use-conversation-signals.d.ts +44 -0
- package/dist/types/chat/controller/use-debounced-semantic-search.d.ts +15 -0
- package/dist/types/chat/conversation-send-message.d.ts +43 -0
- package/dist/types/chat/last-wire-message-is-unanswered-user-message.d.ts +22 -0
- package/dist/types/chat/normalize-server-message-to-markdown.d.ts +23 -0
- package/dist/types/chat/store/agents-chat-state.d.ts +132 -0
- package/dist/types/chat/store/conversation-error-type.d.ts +32 -0
- package/dist/types/chat/store/create-agents-chat-store.d.ts +23 -0
- package/dist/types/chat/store/index.d.ts +5 -0
- package/dist/types/chat/store/merge-chat-messages.d.ts +20 -0
- package/dist/types/chat/store/reduce-agents-chat-state.d.ts +7 -0
- package/dist/types/chat/store/use-agents-chat-store.d.ts +22 -0
- package/dist/types/chat/strip-pre-call-message-marker.d.ts +12 -0
- package/dist/types/chat/use-canvas-shell-transitions.d.ts +25 -0
- package/dist/types/client/AgentsConversationClient.d.ts +93 -0
- package/dist/types/client/AgentsConversationClientContext.d.ts +17 -0
- package/dist/types/client/polling/createPollingConversationChangeSubscription.d.ts +62 -0
- package/dist/types/client/polling/withPollingChangeSubscription.d.ts +11 -0
- package/dist/types/client/testing/createInMemoryAgentsConversationClient.d.ts +139 -0
- package/dist/types/contract/conversation.d.ts +370 -0
- package/dist/types/entries/chat.d.ts +21 -0
- package/dist/types/entries/client-testing.d.ts +1 -0
- package/dist/types/entries/client.d.ts +4 -0
- package/dist/types/entries/contract.d.ts +1 -0
- package/dist/types/entries/image-render.d.ts +9 -0
- package/dist/types/entries/index.d.ts +9 -0
- package/dist/types/entries/kit.d.ts +4 -0
- package/dist/types/entries/preview.d.ts +8 -0
- package/dist/types/entries/renderer.d.ts +15 -0
- package/dist/types/entries/widgets.d.ts +16 -0
- package/dist/types/image-render/ComposedViewEmailDataTimes/ComposedViewEmailDataTimes.d.ts +15 -0
- package/dist/types/image-render/WidgetImageRender.d.ts +55 -0
- package/dist/types/image-render/WidgetImageRenderContext.d.ts +14 -0
- package/dist/types/image-render/composed-view-data-times.d.ts +20 -0
- package/dist/types/image-render/frozen-widget-requests.d.ts +2 -0
- package/dist/types/image-render/live-widget-requests.d.ts +4 -0
- package/dist/types/image-render/widget-image-google-map.d.ts +7 -0
- package/dist/types/image-render/widget-image-readiness-signal.d.ts +16 -0
- package/dist/types/image-render/widget-image-readiness.d.ts +9 -0
- package/dist/types/image-render/widget-image-render.types.d.ts +47 -0
- package/dist/types/kit/ComposedViewConversationWidget.d.ts +14 -0
- package/dist/types/kit/ComposedViewDataSourceLoader.d.ts +20 -0
- package/dist/types/kit/ComposedViewRenderer.d.ts +30 -0
- package/dist/types/kit/ComposedViewSlotErrorBoundary.d.ts +23 -0
- package/dist/types/kit/ModelText/ModelText.d.ts +12 -0
- package/dist/types/kit/components/embedding/EmbeddedConversationWidget.d.ts +26 -0
- package/dist/types/kit/components/map/map-full-screen-instance.d.ts +26 -0
- package/dist/types/kit/components/map/map-presentation-context.d.ts +8 -0
- package/dist/types/kit/components/text/shared/text-node-values.d.ts +39 -0
- package/dist/types/kit/composed-view-component-types.d.ts +61 -0
- package/dist/types/kit/composed-view-components.d.ts +7 -0
- package/dist/types/kit/composed-view-tones.d.ts +20 -0
- package/dist/types/kit/entity-detail/EntityDetailCanvasBody.d.ts +9 -0
- package/dist/types/kit/entity-detail/entity-detail-bodies.d.ts +32 -0
- package/dist/types/kit/entity-detail/entity-detail-name.d.ts +9 -0
- package/dist/types/kit/hooks/use-debounced-value.d.ts +2 -0
- package/dist/types/kit/map-full-screen/MapFullScreenCanvasBody.d.ts +11 -0
- package/dist/types/preview/WidgetPreviewHost.d.ts +20 -0
- package/dist/types/preview/preview-stub-components.d.ts +3 -0
- package/dist/types/preview/widget-preview-fixtures.d.ts +17 -0
- package/dist/types/preview/widget-preview-hydration.d.ts +10 -0
- package/dist/types/preview/widget-preview-readiness.d.ts +27 -0
- package/dist/types/preview/widget-preview-requests.d.ts +16 -0
- package/dist/types/preview/widget-preview-signal.d.ts +10 -0
- package/dist/types/preview/widget-preview.types.d.ts +134 -0
- package/dist/types/provider/AgentsProvider.d.ts +33 -0
- package/dist/types/provider/class-names.d.ts +7 -0
- package/dist/types/provider/components/default-components.d.ts +3 -0
- package/dist/types/provider/components/icon-names.d.ts +9 -0
- package/dist/types/provider/components/index.d.ts +39 -0
- package/dist/types/provider/components/types.d.ts +463 -0
- package/dist/types/provider/environment.d.ts +262 -0
- package/dist/types/provider/index.d.ts +4 -0
- package/dist/types/renderer/ConversationDeepLinkedWidget.d.ts +18 -0
- package/dist/types/renderer/ConversationMarkdown.d.ts +21 -0
- package/dist/types/renderer/ConversationWidgetActions/ConversationWidgetActions.d.ts +7 -0
- package/dist/types/renderer/ConversationWidgetCallbacksContext.d.ts +234 -0
- package/dist/types/renderer/ConversationWidgetContext.d.ts +32 -0
- package/dist/types/renderer/ConversationWidgetErrorBoundary.d.ts +25 -0
- package/dist/types/renderer/ConversationWidgetHost.d.ts +36 -0
- package/dist/types/renderer/ConversationWidgetRenderContext.d.ts +3 -0
- package/dist/types/renderer/MarkdownLink.d.ts +6 -0
- package/dist/types/renderer/WindowedWidget/WindowedWidget.d.ts +16 -0
- package/dist/types/renderer/_access/ConversationWidgetFeatureGate.d.ts +21 -0
- package/dist/types/renderer/_agent-space/ConversationWidgetAgentSpaceFrame.d.ts +12 -0
- package/dist/types/renderer/_agent-space/ConversationWidgetAgentSpaceHeader.d.ts +15 -0
- package/dist/types/renderer/_agent-space/agent-space-name.hydrator.d.ts +7 -0
- package/dist/types/renderer/_agent-space/declared-agent-space-key-field-name.d.ts +8 -0
- package/dist/types/renderer/_agent-space/use-resolved-conversation-widget-agent-space-key.d.ts +16 -0
- package/dist/types/renderer/_agent-space/widget-agent-space-key-attribute.d.ts +13 -0
- package/dist/types/renderer/balanced-json-object.d.ts +12 -0
- package/dist/types/renderer/canvas/CanvasRestoreOnMount.d.ts +19 -0
- package/dist/types/renderer/canvas/canvas-behaviours.d.ts +84 -0
- package/dist/types/renderer/canvas/canvas-body-props.d.ts +18 -0
- package/dist/types/renderer/canvas/canvas-feature-flags.d.ts +11 -0
- package/dist/types/renderer/canvas/canvas-reducers.d.ts +46 -0
- package/dist/types/renderer/canvas/canvas-state.d.ts +107 -0
- package/dist/types/renderer/canvas/canvasBodies.d.ts +19 -0
- package/dist/types/renderer/canvas/canvasStorage.d.ts +25 -0
- package/dist/types/renderer/canvas/decide-canvas-open.d.ts +32 -0
- package/dist/types/renderer/canvas/entity-detail-instance.d.ts +27 -0
- package/dist/types/renderer/canvas/find-widget-fences-in-markdown.d.ts +32 -0
- package/dist/types/renderer/canvas/use-anchor-widget-payload.d.ts +8 -0
- package/dist/types/renderer/composer-widget-fence.d.ts +30 -0
- package/dist/types/renderer/conversation-composer-widget.d.ts +13 -0
- package/dist/types/renderer/conversation-widget-props.d.ts +54 -0
- package/dist/types/renderer/conversation-widget-state-partition.d.ts +31 -0
- package/dist/types/renderer/conversationWidgetAstPlugin.d.ts +11 -0
- package/dist/types/renderer/conversationWidgetRegistry.d.ts +74 -0
- package/dist/types/renderer/detect-unrendered-widgets.d.ts +42 -0
- package/dist/types/renderer/markdown-contains-widget.d.ts +13 -0
- package/dist/types/renderer/reference-naked-widget-json.d.ts +1 -0
- package/dist/types/renderer/remarkWidgetFencePlugin.d.ts +22 -0
- package/dist/types/renderer/render-report/widget-render-report-collector.d.ts +57 -0
- package/dist/types/renderer/render-report/widget-render-report.d.ts +29 -0
- package/dist/types/renderer/repair-malformed-widget-fences.d.ts +11 -0
- package/dist/types/renderer/resolve-deep-linkable-widget.d.ts +25 -0
- package/dist/types/renderer/restoreTextDirectivesPlugin.d.ts +12 -0
- package/dist/types/renderer/widget-click-signal-sources.d.ts +15 -0
- package/dist/types/renderer/widget-fence-json.d.ts +16 -0
- package/dist/types/renderer/widget-fence-syntax.d.ts +25 -0
- package/dist/types/renderer/widget-hydration/index.d.ts +8 -0
- package/dist/types/renderer/widget-hydration/section-hydration.d.ts +41 -0
- package/dist/types/renderer/widget-hydration/use-widget-hydration.d.ts +27 -0
- package/dist/types/renderer/widget-hydration/widget-hydration-state-store.d.ts +27 -0
- package/dist/types/renderer/widget-hydration/widget-hydration.reducer.d.ts +39 -0
- package/dist/types/renderer/widget-hydration/widget-hydration.registry.d.ts +7 -0
- package/dist/types/renderer/widget-hydration/widget-hydration.slice.d.ts +8 -0
- package/dist/types/renderer/widget-hydration/widget-hydration.types.d.ts +27 -0
- package/dist/types/renderer/widget-name-resolver.d.ts +22 -0
- package/dist/types/renderer/widget-tree/bounded-json.d.ts +23 -0
- package/dist/types/renderer/widget-tree/composed-node-schema.d.ts +143 -0
- package/dist/types/renderer/widget-tree/composed-view-data-sources.d.ts +41 -0
- package/dist/types/renderer/widget-tree/composed-view-tree.d.ts +111 -0
- package/dist/types/renderer/widget-tree/expression/evaluate-expression.d.ts +65 -0
- package/dist/types/renderer/widget-tree/expression/parse-expression.d.ts +71 -0
- package/dist/types/renderer/widget-tree/resolve-composed-view-values.d.ts +49 -0
- package/dist/types/renderer/widget-tree/use-composed-view-state.d.ts +16 -0
- package/dist/types/renderer/widget-windowing.d.ts +25 -0
- package/dist/types/widgets/CanvasWidgetCard/CanvasWidgetCard.d.ts +79 -0
- package/dist/types/widgets/CanvasWidgetCard/CanvasWidgetSwitch.d.ts +61 -0
- package/dist/types/widgets/CanvasWidgetCard/canvas-for-message-widget.d.ts +8 -0
- package/dist/types/widgets/CanvasWidgetCard/use-canvas-viable.d.ts +15 -0
- package/dist/types/widgets/ClockConversationWidget/ClockConversationWidget.d.ts +11 -0
- package/dist/types/widgets/ClockConversationWidget/ClockWidget/AnalogClockFace.d.ts +12 -0
- package/dist/types/widgets/ClockConversationWidget/ClockWidget/ClockRow.d.ts +23 -0
- package/dist/types/widgets/ClockConversationWidget/ClockWidget/ClockWidget.d.ts +21 -0
- package/dist/types/widgets/ClockConversationWidget/ClockWidget/DayNightGlyph.d.ts +8 -0
- package/dist/types/widgets/ClockConversationWidget/shared/clock-time.d.ts +52 -0
- package/dist/types/widgets/ClockConversationWidget/shared/clock-widget-payload.d.ts +23 -0
- package/dist/types/widgets/ClockConversationWidget/shared/use-clock-settings.d.ts +18 -0
- package/dist/types/widgets/ConceptExplainerConversationWidget/ConceptExplainerConversationWidget.d.ts +14 -0
- package/dist/types/widgets/ConceptExplainerConversationWidget/ConceptExplainerWidget/ConceptExplainerWidget.d.ts +27 -0
- package/dist/types/widgets/ConceptExplainerConversationWidget/shared/ConceptExplainerTextView.d.ts +11 -0
- package/dist/types/widgets/ConceptExplainerConversationWidget/shared/concept-explainer-type.d.ts +89 -0
- package/dist/types/widgets/ConceptExplainerConversationWidget/shared/concept-explainer-types.d.ts +17 -0
- package/dist/types/widgets/ConceptExplainerConversationWidget/shared/concept-explainer-widget-payload.d.ts +25 -0
- package/dist/types/widgets/ConceptExplainerConversationWidget/shared/use-concept-explainer-language.d.ts +8 -0
- package/dist/types/widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsCanvas.d.ts +9 -0
- package/dist/types/widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsCanvasBody.d.ts +7 -0
- package/dist/types/widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsConversationWidget.d.ts +15 -0
- package/dist/types/widgets/ConversationSearchResultsConversationWidget/shared/conversation-search-results-widget-payload.d.ts +42 -0
- package/dist/types/widgets/ConversationSearchResultsConversationWidget/shared/search-hit-excerpt.d.ts +1 -0
- package/dist/types/widgets/CurrencyConverterConversationWidget/CurrencyConverterConversationWidget.d.ts +8 -0
- package/dist/types/widgets/CurrencyConverterConversationWidget/CurrencyConverterWidget/CurrencyConverterWidget.d.ts +17 -0
- package/dist/types/widgets/CurrencyConverterConversationWidget/CurrencyConverterWidget/CurrencyLabel/CurrencyLabel.d.ts +9 -0
- package/dist/types/widgets/CurrencyConverterConversationWidget/shared/currency-converter-widget-payload.d.ts +22 -0
- package/dist/types/widgets/CurrencyConverterConversationWidget/shared/currency-display.d.ts +30 -0
- package/dist/types/widgets/CustomVisualizationConversationWidget/CustomVisualizationConversationWidget.d.ts +11 -0
- package/dist/types/widgets/CustomVisualizationConversationWidget/CustomVisualizationWidget/CustomVisualizationFrame.d.ts +14 -0
- package/dist/types/widgets/CustomVisualizationConversationWidget/CustomVisualizationWidget/CustomVisualizationWidget.d.ts +15 -0
- package/dist/types/widgets/CustomVisualizationConversationWidget/shared/custom-visualization-frame-protocol.d.ts +77 -0
- package/dist/types/widgets/CustomVisualizationConversationWidget/shared/custom-visualization-libraries.d.ts +25 -0
- package/dist/types/widgets/CustomVisualizationConversationWidget/shared/custom-visualization-sandbox-config.d.ts +21 -0
- package/dist/types/widgets/CustomVisualizationConversationWidget/shared/custom-visualization-widget-payload.d.ts +55 -0
- package/dist/types/widgets/CustomVisualizationConversationWidget/shared/read-custom-visualization-theme.d.ts +5 -0
- package/dist/types/widgets/EntityMentionConversationWidget/EntityMentionAskButton/EntityMentionAskButton.d.ts +13 -0
- package/dist/types/widgets/EntityMentionConversationWidget/EntityMentionCard/EntityMentionCard.d.ts +11 -0
- package/dist/types/widgets/EntityMentionConversationWidget/EntityMentionConversationWidget.d.ts +9 -0
- package/dist/types/widgets/EntityMentionConversationWidget/shared/entity-mention-presentation.d.ts +4 -0
- package/dist/types/widgets/EntityMentionConversationWidget/shared/entity-mention.d.ts +33 -0
- package/dist/types/widgets/EntityMentionConversationWidget/shared/use-entity-mention-composer.d.ts +17 -0
- package/dist/types/widgets/MultiChoiceConversationWidget/MultiChoiceConversationWidget.d.ts +2 -0
- package/dist/types/widgets/MultiChoiceConversationWidget/shared/multi-choice-widget-payload.d.ts +16 -0
- package/dist/types/widgets/QuickRepliesConversationWidget/QuickRepliesConversationWidget.d.ts +38 -0
- package/dist/types/widgets/QuickRepliesConversationWidget/shared/quick-replies-widget-payload.d.ts +20 -0
- package/dist/types/widgets/SuggestedActions/SuggestedActions.d.ts +10 -0
- package/dist/types/widgets/ToolTraceConversationWidget/ToolTraceConversationWidget.d.ts +8 -0
- package/dist/types/widgets/WebSearchResultsConversationWidget/SourceFavicon.d.ts +10 -0
- package/dist/types/widgets/WebSearchResultsConversationWidget/WebSearchAnswer.d.ts +6 -0
- package/dist/types/widgets/WebSearchResultsConversationWidget/WebSearchReferences.d.ts +12 -0
- package/dist/types/widgets/WebSearchResultsConversationWidget/WebSearchResultsCanvas.d.ts +10 -0
- package/dist/types/widgets/WebSearchResultsConversationWidget/WebSearchResultsCanvasBody.d.ts +7 -0
- package/dist/types/widgets/WebSearchResultsConversationWidget/WebSearchResultsConversationWidget.d.ts +14 -0
- package/dist/types/widgets/WebSearchResultsConversationWidget/WebSearchSourcesList.d.ts +10 -0
- package/dist/types/widgets/WebSearchResultsConversationWidget/shared/display-hostname.d.ts +9 -0
- package/dist/types/widgets/WebSearchResultsConversationWidget/shared/web-search-results-widget-payload.d.ts +30 -0
- package/dist/types/widgets/WritingDraftConversationWidget/WritingDraftConversationWidget.d.ts +14 -0
- package/dist/types/widgets/WritingDraftConversationWidget/WritingDraftWidget/WritingDraftBody.d.ts +9 -0
- package/dist/types/widgets/WritingDraftConversationWidget/WritingDraftWidget/WritingDraftWidget.d.ts +44 -0
- package/dist/types/widgets/WritingDraftConversationWidget/shared/draft-mail-link.d.ts +17 -0
- package/dist/types/widgets/WritingDraftConversationWidget/shared/draft-plain-text.d.ts +7 -0
- package/dist/types/widgets/WritingDraftConversationWidget/shared/remark-draft-line-breaks.d.ts +13 -0
- package/dist/types/widgets/WritingDraftConversationWidget/shared/writing-draft-widget-payload.d.ts +23 -0
- package/dist/types/widgets/_shared/ConversationWidgetButton.d.ts +4 -0
- package/dist/types/widgets/_shared/DonePill.d.ts +14 -0
- package/dist/types/widgets/_shared/modern/WidgetKpiValue.d.ts +24 -0
- package/dist/types/widgets/_shared/modern/WidgetListRow.d.ts +14 -0
- package/dist/types/widgets/_shared/modern/WidgetStatusChip.d.ts +8 -0
- package/dist/types/widgets/_shared/modern/WidgetSurface.d.ts +13 -0
- package/dist/types/widgets/_shared/modern/WidgetSurfaceSkeleton.d.ts +11 -0
- package/dist/types/widgets/_shared/modern/index.d.ts +16 -0
- package/dist/types/widgets/_shared/skeleton-primitives.d.ts +20 -0
- package/dist/types/widgets/_shared/use-stack-when-wrapped.d.ts +6 -0
- package/dist/types/widgets/_shared/widget-payload-validation.d.ts +22 -0
- package/dist/widgets.js +84 -0
- package/dist/widgets.js.map +1 -0
- package/package.json +147 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RegisteredWidget, WidgetHydratorOptions } from "./widget-hydration.types";
|
|
2
|
+
export declare const registerWidgetHydrator: <TPayload = unknown, TData = unknown>(type: string, options: WidgetHydratorOptions<TPayload, TData>) => void;
|
|
3
|
+
export declare const getWidgetHydrator: <TPayload = unknown, TData = unknown>(type: string) => RegisteredWidget<TPayload, TData> | undefined;
|
|
4
|
+
export declare const hasWidgetHydrator: (type: string) => boolean;
|
|
5
|
+
/** Every registered hydrator type — the widget preview answers them from its fixture (`widget-preview-hydration.ts`). */
|
|
6
|
+
export declare const listWidgetHydratorTypes: () => string[];
|
|
7
|
+
export declare const unregisterWidgetHydrator: (type: string) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WidgetHydrationSliceState, WidgetMemory } from "./widget-hydration.types";
|
|
2
|
+
export { WidgetHydrationReducer, WidgetHydrationSlice } from "./widget-hydration.reducer";
|
|
3
|
+
/** A store state that carries the widget hydration state. */
|
|
4
|
+
interface StateWithWidgetHydration {
|
|
5
|
+
AIExtensionsWidgetHydration?: WidgetHydrationSliceState;
|
|
6
|
+
}
|
|
7
|
+
export declare const selectWidgetMemory: (key: string) => (state: StateWithWidgetHydration) => WidgetMemory | undefined;
|
|
8
|
+
export declare const useWidgetMemory: (key: string) => WidgetMemory<unknown> | undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type WidgetHydrationStatus = "idle" | "loading" | "success" | "error";
|
|
2
|
+
export interface WidgetMemory<TData = unknown> {
|
|
3
|
+
data: TData | null;
|
|
4
|
+
status: WidgetHydrationStatus;
|
|
5
|
+
error: string | null;
|
|
6
|
+
loadingInstanceId: string | null;
|
|
7
|
+
inFlight: boolean;
|
|
8
|
+
requestId: number;
|
|
9
|
+
lastLoadedAt: number | null;
|
|
10
|
+
}
|
|
11
|
+
export interface WidgetHydrationSliceState {
|
|
12
|
+
widgets: Record<string, WidgetMemory>;
|
|
13
|
+
}
|
|
14
|
+
export interface WidgetHydratorContext {
|
|
15
|
+
signal: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
export type WidgetHydrator<TPayload = unknown, TData = unknown> = (payload: TPayload, ctx: WidgetHydratorContext) => Promise<TData>;
|
|
18
|
+
export interface WidgetHydratorOptions<TPayload = unknown, TData = unknown> {
|
|
19
|
+
hydrator: WidgetHydrator<TPayload, TData>;
|
|
20
|
+
deriveKey?: (type: string, payload: TPayload) => string;
|
|
21
|
+
isPayloadEqual?: (prev: TPayload | undefined, next: TPayload) => boolean;
|
|
22
|
+
refetchOnNewInstance?: boolean;
|
|
23
|
+
staleMs?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface RegisteredWidget<TPayload = unknown, TData = unknown> extends Required<Omit<WidgetHydratorOptions<TPayload, TData>, "isPayloadEqual">> {
|
|
26
|
+
isPayloadEqual: (prev: TPayload | undefined, next: TPayload) => boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE resolution rule (see the file header): exact canonical match, else — only for a name ending in `Directive` —
|
|
3
|
+
* strip that legacy suffix once and match again. Undefined = no such widget. Every lookup in the pipeline goes through
|
|
4
|
+
* this function (the fence plugin, the AST plugin, the drawer-reset scan, the unrendered-widget detector), so a name
|
|
5
|
+
* that renders in one place renders in all of them.
|
|
6
|
+
*/
|
|
7
|
+
export declare const resolveCanonicalWidgetName: (requestedName: string, canonicalNames: ReadonlySet<string>) => string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve a model-supplied ```widget `type` — or the name on a stored message's `::<Name>` node — to a registered
|
|
10
|
+
* widget name. `QuickReplies` matches exactly; the legacy `QuickRepliesDirective` resolves to the same canonical
|
|
11
|
+
* `QuickReplies`. Shared by the render plugin (which DROPS an unresolved block) and the unrendered-widget detector
|
|
12
|
+
* (which REPORTS it), so both agree exactly on what counts as a valid widget.
|
|
13
|
+
*/
|
|
14
|
+
export declare const resolveWidgetName: (type: string) => string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The closest VALID widget names to an unknown `type` the model emitted — a deterministic similarity shortlist (no
|
|
17
|
+
* LLM): substring containment + shared PascalCase tokens + edit-distance proximity as the tiebreaker. A candidate is
|
|
18
|
+
* kept only when it genuinely resembles the type (containment, a shared word, or a very close spelling) — proximity
|
|
19
|
+
* alone is too loose across ~60 widget names. Returned as the canonical (short) names, which is what a corrected
|
|
20
|
+
* emission should use; empty when nothing is close.
|
|
21
|
+
*/
|
|
22
|
+
export declare const closestWidgetNames: (type: string, limit?: number) => string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded walks over decoded JSON: the widget payloads come from the model, so no
|
|
3
|
+
* walk may recurse without a bound, run in the size of a shared sub-structure, or throw. The depth rule is the
|
|
4
|
+
* backend's: a block is decoded with `json_decode(…, depth: 32)` (`WidgetBlocks.php`), which admits 31 nested
|
|
5
|
+
* containers — a deeper block is MALFORMED there and is dropped here the same way.
|
|
6
|
+
*/
|
|
7
|
+
/** The deepest container nesting `json_decode(…, 32)` admits (the top-level object counts as 1). */
|
|
8
|
+
export declare const MAX_JSON_CONTAINER_DEPTH = 31;
|
|
9
|
+
/** Whether `value` nests containers deeper than `maxDepth` — iterative, never throws. */
|
|
10
|
+
export declare const exceedsJsonContainerDepth: (value: unknown, maxDepth?: number) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The value as `json_decode(…, true)` sees it: an object whose keys are `"0"`, `"1"`, … in order is a LIST there
|
|
13
|
+
* (`array_is_list`), so it becomes an array here. Bounded by the depth rule (call it on a value within the depth).
|
|
14
|
+
*/
|
|
15
|
+
export declare const normalizeToPhpArrays: (value: unknown, depth?: number) => unknown;
|
|
16
|
+
/**
|
|
17
|
+
* The size of a value as a TREE (every container and scalar counted where it appears) — a shared sub-structure counts
|
|
18
|
+
* once per use, as serialising it would. Memoised per object, so the cost is the number of DISTINCT objects even for a
|
|
19
|
+
* DAG whose tree is exponential; the result saturates at `Number.MAX_SAFE_INTEGER`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const structuralSizeOf: (value: unknown, depth?: number) => number;
|
|
22
|
+
/** `JSON.stringify(value, null, 2)` — or undefined once the text would pass `maxLength` (checked before it is built). */
|
|
23
|
+
export declare const stringifyWithinLimit: (value: unknown, maxLength: number) => string | undefined;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE schema of the `ComposedView` kit, GENERATED by the backend from its classes (`ComposedViewNodeSchema.php`) —
|
|
3
|
+
* never edited by hand. The committed file holds the types the package's own classes declare; an app adds the node
|
|
4
|
+
* types, widgets, data sources and entity types its classes declare as its part (`AgentsEnvironment.composedNodeSchemaApplicationPart`,
|
|
5
|
+
* generated by the app's backend the same way), and `getComposedNodeSchema()` reads both. The frontend parser, the
|
|
6
|
+
* renderer and the evaluator read the node types, slots, props, size classes and budgets from here, so both sides apply
|
|
7
|
+
* the same contract. `kit/_ComposedViewRenderer.spec.tsx` checks that every node type has a registered component and
|
|
8
|
+
* every component a node type.
|
|
9
|
+
*/
|
|
10
|
+
export type ComposedNodeCategory = "inline" | "block" | "data" | "media" | "input" | "layout" | "heavy";
|
|
11
|
+
export type ComposedSizeClass = "compact" | "regular" | "full";
|
|
12
|
+
export type ComposedPropType = "string" | "number" | "boolean" | "array" | "object" | "event";
|
|
13
|
+
export interface ComposedNodeSlotSchema {
|
|
14
|
+
name: string;
|
|
15
|
+
acceptsCategories: ComposedNodeCategory[];
|
|
16
|
+
acceptsNodeTypes: string[];
|
|
17
|
+
minChildren: number;
|
|
18
|
+
maxChildren: number | null;
|
|
19
|
+
sizeClass: ComposedSizeClass;
|
|
20
|
+
description: string;
|
|
21
|
+
/** The node prop the slot's size class follows (a Grid's `columns`); absent = the size class is fixed. */
|
|
22
|
+
sizeClassFromProp?: string;
|
|
23
|
+
/** Prop value (as text) → size class; a value not listed keeps `sizeClass`. */
|
|
24
|
+
sizeClassesByPropValue?: Record<string, ComposedSizeClass>;
|
|
25
|
+
/** A heavy node (a map, an embedded widget) may sit in the slot while it is compact. */
|
|
26
|
+
acceptsHeavyWhenCompact?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ComposedNodePropSchema {
|
|
29
|
+
name: string;
|
|
30
|
+
types: ComposedPropType[];
|
|
31
|
+
isRequired: boolean;
|
|
32
|
+
isBindable: boolean;
|
|
33
|
+
allowedValues: Array<string | number | boolean> | null;
|
|
34
|
+
description: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The type's part in the source rule (`ComposedViewNode::buildSourcingSchemaArray()`): a data node that `needsSource`
|
|
38
|
+
* and holds inline figures in its subtree — written rows in a `rowsProps` prop, a written figure in a `figureProps`
|
|
39
|
+
* prop — needs its `source`, a source on a data node around it, or a node that `namesSources` in the tree.
|
|
40
|
+
*/
|
|
41
|
+
export interface ComposedNodeSourcingSchema {
|
|
42
|
+
needsSource: boolean;
|
|
43
|
+
namesSources: boolean;
|
|
44
|
+
rowsProps: string[];
|
|
45
|
+
figureProps: string[];
|
|
46
|
+
}
|
|
47
|
+
export interface ComposedNodeTypeSchema {
|
|
48
|
+
categories: ComposedNodeCategory[];
|
|
49
|
+
providesItemScope: boolean;
|
|
50
|
+
summary: string;
|
|
51
|
+
props: ComposedNodePropSchema[];
|
|
52
|
+
slots: ComposedNodeSlotSchema[];
|
|
53
|
+
/** Absent for a type that takes no part in the source rule. */
|
|
54
|
+
sourcing?: ComposedNodeSourcingSchema;
|
|
55
|
+
/** The prop that lists the node's choices (`ComposedViewNode::OPTIONS_PROP_NAME`); absent without choices. */
|
|
56
|
+
optionsProp?: string;
|
|
57
|
+
/** The prop a node that repeats its children repeats over (`ComposedViewNode::ITEMS_PROP_NAME`). */
|
|
58
|
+
itemsProp?: string;
|
|
59
|
+
/** The node sends the state of the inputs inside it (`Form`); absent otherwise. */
|
|
60
|
+
submitsInputs?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface ComposedViewBudgets {
|
|
63
|
+
maxSourceBytes: number;
|
|
64
|
+
maxNodes: number;
|
|
65
|
+
maxDepth: number;
|
|
66
|
+
maxStateKeys: number;
|
|
67
|
+
maxStateStringLength: number;
|
|
68
|
+
maxComputedExpressions: number;
|
|
69
|
+
maxExpressionSourceLength: number;
|
|
70
|
+
maxExpressionAstNodes: number;
|
|
71
|
+
maxComputedDependencyDepth: number;
|
|
72
|
+
maxOperationsPerUpdate: number;
|
|
73
|
+
maxCollectionItems: number;
|
|
74
|
+
maxAllocatedItemsPerEvaluation: number;
|
|
75
|
+
maxRepeatRows: number;
|
|
76
|
+
maxRenderedNodes: number;
|
|
77
|
+
maxInlineArrayItems: number;
|
|
78
|
+
maxInlineCells: number;
|
|
79
|
+
maxTextLength: number;
|
|
80
|
+
maxActions: number;
|
|
81
|
+
maxInputUpdatesPerSecond: number;
|
|
82
|
+
maxSourceRequestsPerTreePerMinute: number;
|
|
83
|
+
}
|
|
84
|
+
export interface ComposedDataSourceSchema {
|
|
85
|
+
summary: string;
|
|
86
|
+
/** The client endpoint, method and path with `{param}` placeholders. */
|
|
87
|
+
clientEndpoint: string;
|
|
88
|
+
/** Where the rows sit in the response (`$` or `$.field`). */
|
|
89
|
+
rowsPath: string;
|
|
90
|
+
freshnessSeconds: number;
|
|
91
|
+
params: Array<{
|
|
92
|
+
name: string;
|
|
93
|
+
type: string;
|
|
94
|
+
isRequired: boolean;
|
|
95
|
+
description: string;
|
|
96
|
+
}>;
|
|
97
|
+
columns: Array<{
|
|
98
|
+
name: string;
|
|
99
|
+
type: string;
|
|
100
|
+
description: string;
|
|
101
|
+
}>;
|
|
102
|
+
}
|
|
103
|
+
export interface ComposedNodeSchema {
|
|
104
|
+
version: number;
|
|
105
|
+
budgets: ComposedViewBudgets;
|
|
106
|
+
categories: ComposedNodeCategory[];
|
|
107
|
+
sizeClasses: ComposedSizeClass[];
|
|
108
|
+
actionTypes: string[];
|
|
109
|
+
bindingKinds: string[];
|
|
110
|
+
findingCodes: string[];
|
|
111
|
+
/** The codes of findings that drop nothing — the block mounts with the code as a note. */
|
|
112
|
+
noteFindingCodes: string[];
|
|
113
|
+
nodeTypes: Record<string, ComposedNodeTypeSchema>;
|
|
114
|
+
embeddableWidgets: Record<string, {
|
|
115
|
+
sizeClass: ComposedSizeClass;
|
|
116
|
+
}>;
|
|
117
|
+
/** Every registered widget type: a `Widget` node naming one its slot refuses is lifted out of the tree. */
|
|
118
|
+
widgetTypes?: string[];
|
|
119
|
+
dataSources: Record<string, ComposedDataSourceSchema>;
|
|
120
|
+
entityTypes: string[];
|
|
121
|
+
}
|
|
122
|
+
/** The sections of the schema an app adds for the types its own classes declare; every section is optional. */
|
|
123
|
+
export type ComposedNodeSchemaApplicationPart = Partial<Pick<ComposedNodeSchema, "nodeTypes" | "embeddableWidgets" | "widgetTypes" | "dataSources" | "entityTypes">>;
|
|
124
|
+
/**
|
|
125
|
+
* The package's committed schema, typed: its budgets and rules and the types the package itself declares. A reader of
|
|
126
|
+
* types an app may add (node types, widgets, data sources, entity types) reads `getComposedNodeSchema()`.
|
|
127
|
+
*/
|
|
128
|
+
export declare const composedNodeSchema: ComposedNodeSchema;
|
|
129
|
+
/** A schema with an app's part added: every section holds both sides' types, sorted by type name. */
|
|
130
|
+
export declare const addComposedNodeSchemaApplicationPart: (schema: ComposedNodeSchema, applicationPart: ComposedNodeSchemaApplicationPart) => ComposedNodeSchema;
|
|
131
|
+
/**
|
|
132
|
+
* The schema the readers apply: the package's schema with the part the app declares
|
|
133
|
+
* (`AgentsEnvironment.composedNodeSchemaApplicationPart`); the package's schema alone when the app declares none.
|
|
134
|
+
* Read at call time — an app installs its environment after this module is loaded. The same object while the part is.
|
|
135
|
+
*/
|
|
136
|
+
export declare const getComposedNodeSchema: () => ComposedNodeSchema;
|
|
137
|
+
/**
|
|
138
|
+
* The slot of one node — `ComposedViewNodeSlot::buildForNodeProps()`: its size class read from the node's
|
|
139
|
+
* `sizeClassFromProp` (a Grid with `columns: 3` gives compact cells); the declaration itself otherwise.
|
|
140
|
+
*/
|
|
141
|
+
export declare const resolveComposedSlotForNodeProps: (slot: ComposedNodeSlotSchema, nodeProps: Record<string, unknown>) => ComposedNodeSlotSchema;
|
|
142
|
+
/** Whether a size class fits a slot's size class (compact ≤ regular ≤ full). */
|
|
143
|
+
export declare const sizeClassFitsSlot: (sizeClass: ComposedSizeClass, slotSizeClass: ComposedSizeClass) => boolean;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ComposedNodeSchema } from "./composed-node-schema";
|
|
2
|
+
import { ComposedViewTree, JsonValue } from "./composed-view-tree";
|
|
3
|
+
import type { ExpressionValue } from "./expression/evaluate-expression";
|
|
4
|
+
/**
|
|
5
|
+
* The frontend side of the `$source` data path: a registered source is read through the existing
|
|
6
|
+
* widget-hydration mechanism (`widget-hydration/`), so the e-mail capture waits for it like for any self-hydrating
|
|
7
|
+
* widget. A source is added with TWO files: the backend `<Name>ComposedViewDataSource` (endpoint, params,
|
|
8
|
+
* columns — exported into the schema) and the frontend fetcher `<name>.composed-data-source.ts` anywhere below
|
|
9
|
+
* `widgets/` exporting `composedViewDataSourceFetcher` (it reads the endpoint through the generated SDK store and returns
|
|
10
|
+
* the response; the rows are taken at the schema's `rowsPath`). The read rights are the endpoint's own entity rights,
|
|
11
|
+
* server-side — the fetcher passes the agent space key and the parameters, nothing else.
|
|
12
|
+
*/
|
|
13
|
+
export interface ComposedViewDataSourceFetcher {
|
|
14
|
+
/** The source name (the backend `NAME`). */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Reads the source for an agent space and the resolved parameters; resolves with the endpoint's response. */
|
|
17
|
+
fetchResponse: (params: Record<string, ExpressionValue>, agentSpaceKey: number | undefined, signal: AbortSignal) => Promise<unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface ComposedViewDataSourcePayload {
|
|
20
|
+
params: Record<string, ExpressionValue>;
|
|
21
|
+
agentSpaceKey: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** The hydration type a source registers under. */
|
|
24
|
+
export declare const composedViewDataSourceHydrationType: (dataSourceName: string) => string;
|
|
25
|
+
/** The rows at a schema `rowsPath` (`$`, `$.field`, `$.a.b`) of a response; undefined when the path does not hold a list. */
|
|
26
|
+
export declare const readRowsAtPath: (response: unknown, rowsPath: string) => ExpressionValue[] | undefined;
|
|
27
|
+
/** Registers a fetcher as a widget hydrator; the rows land in the hydration memory like any widget's data. */
|
|
28
|
+
export declare const registerComposedViewDataSourceFetcher: (fetcher: ComposedViewDataSourceFetcher, schema?: ComposedNodeSchema) => void;
|
|
29
|
+
/** Whether a fetcher is registered for a source name. */
|
|
30
|
+
export declare const hasComposedViewDataSourceFetcher: (dataSourceName: string) => boolean;
|
|
31
|
+
/** One `$source` binding of a tree, with its parameters as written (`$state` bindings inside). */
|
|
32
|
+
export interface ComposedViewSourceBinding {
|
|
33
|
+
/** The binding's identity in the tree: name + parameters as written. */
|
|
34
|
+
bindingKey: string;
|
|
35
|
+
dataSourceName: string;
|
|
36
|
+
writtenParams: Record<string, JsonValue>;
|
|
37
|
+
}
|
|
38
|
+
/** Every distinct `$source` binding of a tree — its datasets and every node's props — in tree order. */
|
|
39
|
+
export declare const collectComposedViewSourceBindings: (tree: ComposedViewTree) => ComposedViewSourceBinding[];
|
|
40
|
+
/** The parameters with their `$state` bindings resolved against the instance state. */
|
|
41
|
+
export declare const resolveComposedViewSourceParams: (writtenParams: Record<string, JsonValue>, state: Record<string, ExpressionValue>) => Record<string, ExpressionValue>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ComposedNodeSchema, ComposedNodeSlotSchema } from "./composed-node-schema";
|
|
2
|
+
/**
|
|
3
|
+
* The `ComposedView` tree as typed objects: the frontend twin of the backend reader
|
|
4
|
+
* `ComposedViewTreeReading.php`. The fence plugin hands the widget its `payload` string; this module turns it into
|
|
5
|
+
* {@link ComposedViewTree} — state, datasets, computed expressions, actions and the node tree — and applies THE SAME
|
|
6
|
+
* rules as the backend, read from the generated schema: unknown types, slot mismatches, undeclared props, bad bindings,
|
|
7
|
+
* budgets and three backticks are dropped where they stand and reported as findings; the rest is kept. A `set` on an
|
|
8
|
+
* undeclared name declares it with null; a choice state outside its choices, a set state nothing reads and an `$item`
|
|
9
|
+
* field missing from resolved `$from` rows are kept with a note (`noteFindingCodes` of the schema). The shared
|
|
10
|
+
* fixture `composed-view-parity.json` holds both readers to the same kept tree and the same finding codes.
|
|
11
|
+
*
|
|
12
|
+
* Never throws, never evaluates anything (expressions are compiled by `expression/`).
|
|
13
|
+
*/
|
|
14
|
+
export type ComposedViewFindingCode = "INVALID_NODE" | "INVALID_PROP" | "UNKNOWN_BINDING" | "INVALID_EXPRESSION" | "INVALID_STATE" | "INVALID_ACTION" | "BUDGET_EXCEEDED" | "INLINE_VALUE_WITHOUT_SOURCE" | "INVALID_INITIAL_CHOICE" | "UNREAD_STATE" | "UNKNOWN_ITEM_KEY" | "INVALID_SLOT_NODE_COUNT" | "WIDGET_LIFTED";
|
|
15
|
+
export interface ComposedViewFinding {
|
|
16
|
+
code: ComposedViewFindingCode;
|
|
17
|
+
path: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
export type ComposedViewBindingKind = "state" | "computed" | "data" | "item" | "from" | "source";
|
|
21
|
+
/** A bound value (`{"$state":"x"}` …), see `ComposedViewBinding.php`. */
|
|
22
|
+
export interface ComposedViewBinding {
|
|
23
|
+
kind: ComposedViewBindingKind | string;
|
|
24
|
+
target: string;
|
|
25
|
+
path: string | null;
|
|
26
|
+
sourceParams: Record<string, unknown>;
|
|
27
|
+
isWellFormed: boolean;
|
|
28
|
+
/** The wire value itself (a `$from` carries its resolution state and snapshot inside, written when the row is stored). */
|
|
29
|
+
wireValue: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
32
|
+
[key: string]: JsonValue;
|
|
33
|
+
};
|
|
34
|
+
export interface ComposedViewNode {
|
|
35
|
+
type: string;
|
|
36
|
+
id: string | null;
|
|
37
|
+
/** The kept props: literals and bindings as JSON values. */
|
|
38
|
+
props: Record<string, JsonValue>;
|
|
39
|
+
/** The kept nodes per slot name (`children` = the default slot), in wire order. */
|
|
40
|
+
nodesBySlotName: Record<string, ComposedViewNode[]>;
|
|
41
|
+
}
|
|
42
|
+
export interface ComposedViewAction {
|
|
43
|
+
type: string;
|
|
44
|
+
[field: string]: JsonValue;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A `Widget` node the reader LIFTED out of the tree (`ComposedViewTreeReading::$liftedWidgetNodesByPath`):
|
|
48
|
+
* its wire path, the widget's canonical name and its fields — shown as its own widget after the view.
|
|
49
|
+
*/
|
|
50
|
+
export interface ComposedViewLiftedWidget {
|
|
51
|
+
path: string;
|
|
52
|
+
widget: string;
|
|
53
|
+
fields: Record<string, JsonValue>;
|
|
54
|
+
}
|
|
55
|
+
export interface ComposedViewTree {
|
|
56
|
+
title: string | null;
|
|
57
|
+
state: Record<string, string | number | boolean | null>;
|
|
58
|
+
data: Record<string, JsonValue>;
|
|
59
|
+
computed: Record<string, string>;
|
|
60
|
+
actions: Record<string, ComposedViewAction>;
|
|
61
|
+
view: ComposedViewNode | null;
|
|
62
|
+
findings: ComposedViewFinding[];
|
|
63
|
+
/** The widgets lifted out of the tree, reading order — never part of `view`. */
|
|
64
|
+
liftedWidgets: ComposedViewLiftedWidget[];
|
|
65
|
+
}
|
|
66
|
+
/** The binding a wire value stands for, or null for a literal — `ComposedViewBinding::fromWireValue()`. */
|
|
67
|
+
export declare const readComposedViewBinding: (wireValue: unknown) => ComposedViewBinding | null;
|
|
68
|
+
/**
|
|
69
|
+
* The field an `$item` binding names in one row — `ComposedViewBinding::readRowField()`: the key as written, else for a
|
|
70
|
+
* dotted name (`author.name`) the path through the row's nested objects. `found` tells a null field from a missing one.
|
|
71
|
+
*/
|
|
72
|
+
export declare const readComposedViewRowField: (row: unknown, fieldName: string) => {
|
|
73
|
+
found: boolean;
|
|
74
|
+
value: unknown;
|
|
75
|
+
};
|
|
76
|
+
/** `ComposedViewTreeReading::findIdentifiersOfExpression()` — identifiers outside string literals, not after a `.`. */
|
|
77
|
+
export declare const findComposedViewExpressionIdentifiers: (expressionSource: string) => string[];
|
|
78
|
+
/** Nodes in a subtree, the node included. */
|
|
79
|
+
export declare const countComposedViewNodes: (node: ComposedViewNode) => number;
|
|
80
|
+
/**
|
|
81
|
+
* The tree of the decoded block fields (without `type`), read and checked against `schema`. Fields nested deeper than
|
|
82
|
+
* the backend decodes give no view; objects keyed `"0"`, `"1"`, … are lists, as `json_decode` makes them.
|
|
83
|
+
*/
|
|
84
|
+
export declare const readComposedViewTree: (widgetFields: Record<string, unknown>, schema?: ComposedNodeSchema) => ComposedViewTree;
|
|
85
|
+
/**
|
|
86
|
+
* The tree of a widget `payload` (the fence's non-`type` fields as a JSON string). A payload that is not a JSON object
|
|
87
|
+
* gives an empty tree; one over the source budget (counted on the canonical bytes, `measureComposedViewSourceBytes`)
|
|
88
|
+
* gives no view and one `BUDGET_EXCEEDED` finding, as on the backend.
|
|
89
|
+
*/
|
|
90
|
+
export declare const parseComposedViewTree: (payload: string, schema?: ComposedNodeSchema) => ComposedViewTree;
|
|
91
|
+
/**
|
|
92
|
+
* The bytes the source budget counts — `ComposedViewTreeReading::measureSourceBytes()`: the fields without `type` as
|
|
93
|
+
* compact JSON, so the written fence's whitespace never decides; the legacy `writtenSyntax` field some stored fences carry
|
|
94
|
+
* (`WidgetBlock::LEGACY_WRITTEN_SYNTAX_FIELD`) does not count.
|
|
95
|
+
*/
|
|
96
|
+
export declare const measureComposedViewSourceBytes: (widgetFields: Record<string, unknown>) => number;
|
|
97
|
+
/** The node in its wire form — `ComposedViewNode::toWireArray()`. */
|
|
98
|
+
export declare const composedViewNodeToWire: (node: ComposedViewNode) => Record<string, JsonValue>;
|
|
99
|
+
/** The kept tree in its wire form — `ComposedViewConversationWidget::getWidgetFields()` (empty parts left out). */
|
|
100
|
+
export declare const composedViewTreeToWire: (tree: ComposedViewTree) => Record<string, JsonValue>;
|
|
101
|
+
/** `ComposedViewNode::getNodesOfSubtreeByPath()` — every node of a subtree with its kept-tree path, depth first. */
|
|
102
|
+
export declare const getComposedViewSubtreeNodesByPath: (node: ComposedViewNode, path: string) => Array<[string, ComposedViewNode]>;
|
|
103
|
+
/** Every node of a subtree, depth first, the node first. */
|
|
104
|
+
export declare const getComposedViewSubtreeNodes: (node: ComposedViewNode) => ComposedViewNode[];
|
|
105
|
+
/** The slot schema of a node type, or undefined. */
|
|
106
|
+
export declare const findComposedViewSlotSchema: (nodeType: string, slotName: string, schema?: ComposedNodeSchema) => ComposedNodeSlotSchema | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Whether a kept view shows nothing: every node of it is a layout node (a Grid, a Stack or a Surface without a node to
|
|
109
|
+
* hold). The renderer shows the explicit fallback line instead — never a title over an empty Grid.
|
|
110
|
+
*/
|
|
111
|
+
export declare const isComposedViewWithoutContent: (view: ComposedViewNode, schema?: ComposedNodeSchema) => boolean;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ComposedViewBudgets } from "../composed-node-schema";
|
|
2
|
+
/**
|
|
3
|
+
* The evaluator of the `ComposedView` expression language. Values are JSON values; one value
|
|
4
|
+
* means "empty": `undefined` — a missing name or member, a division by zero, a non-finite result, an operation on an
|
|
5
|
+
* empty or wrongly typed operand all give it, and it renders as nothing. Member access reads OWN properties of arrays and
|
|
6
|
+
* plain objects only (never `__proto__`, `constructor`, `prototype`, never a method). Every evaluated node and every
|
|
7
|
+
* element a function walks is charged against ONE operation budget per state update (`maxOperationsPerUpdate`), so a
|
|
8
|
+
* nested `map` / `filter` / `sortBy` cannot run away; collections are capped (`maxCollectionItems`), the elements
|
|
9
|
+
* allocated for intermediate collections are charged by their size as a tree (`maxAllocatedItemsPerEvaluation`), and a
|
|
10
|
+
* text result may not pass `maxTextLength`.
|
|
11
|
+
*/
|
|
12
|
+
export type ExpressionValue = string | number | boolean | null | undefined | ExpressionValue[] | {
|
|
13
|
+
[key: string]: ExpressionValue;
|
|
14
|
+
};
|
|
15
|
+
/** Why an expression gave no value: it did not compile, it ran over a budget, or it read itself (a cycle). */
|
|
16
|
+
export type ExpressionErrorCode = "INVALID_EXPRESSION" | "BUDGET_EXCEEDED";
|
|
17
|
+
export declare class ExpressionBudgetExceededError extends Error {
|
|
18
|
+
}
|
|
19
|
+
/** The budget counters of one state update, shared by every expression it evaluates. */
|
|
20
|
+
export declare class ExpressionBudget {
|
|
21
|
+
readonly budgets: ComposedViewBudgets;
|
|
22
|
+
operationsLeft: number;
|
|
23
|
+
allocatedItemsLeft: number;
|
|
24
|
+
constructor(budgets: ComposedViewBudgets);
|
|
25
|
+
charge(operations?: number): void;
|
|
26
|
+
allocate(items: number): void;
|
|
27
|
+
checkCollection(items: ExpressionValue[]): void;
|
|
28
|
+
/** A text result may not pass `maxTextLength` — checked on the lengths BEFORE the text is built. */
|
|
29
|
+
checkTextLength(textLength: number): void;
|
|
30
|
+
/** The containers this update's expressions built, with their size as a tree (a shared one counted per use). */
|
|
31
|
+
protected readonly createdValueSizes: WeakMap<object, number>;
|
|
32
|
+
/**
|
|
33
|
+
* Charges a container an expression just built by its size as a TREE — a value built from earlier results counts
|
|
34
|
+
* them again wherever it repeats them, so `{l: o, r: o}` over `o` doubles and a chain of such values cannot grow
|
|
35
|
+
* past the allocation budget. A value the expression did not build (a dataset) counts 1.
|
|
36
|
+
*/
|
|
37
|
+
allocateCreatedValue(createdValue: ExpressionValue[] | Record<string, ExpressionValue>): void;
|
|
38
|
+
}
|
|
39
|
+
/** Where a name comes from: lambda parameters first, then the tree's names (state, datasets, computed). */
|
|
40
|
+
export type ExpressionNameResolver = (name: string) => ExpressionValue;
|
|
41
|
+
export type ExpressionEvaluationResult = {
|
|
42
|
+
ok: true;
|
|
43
|
+
value: ExpressionValue;
|
|
44
|
+
} | {
|
|
45
|
+
ok: false;
|
|
46
|
+
errorCode: ExpressionErrorCode;
|
|
47
|
+
message: string;
|
|
48
|
+
};
|
|
49
|
+
/** Compiles (cached) and evaluates one expression; never throws. */
|
|
50
|
+
export declare const evaluateExpression: (source: string, resolveName: ExpressionNameResolver, budget: ExpressionBudget) => ExpressionEvaluationResult;
|
|
51
|
+
export interface ComputedValuesResult {
|
|
52
|
+
values: Record<string, ExpressionValue>;
|
|
53
|
+
errors: Record<string, {
|
|
54
|
+
errorCode: ExpressionErrorCode;
|
|
55
|
+
message: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Every computed value of a tree for one state: each expression evaluated once, in dependency order (a computed value
|
|
60
|
+
* may read state, datasets and other computed values), under ONE budget. A cycle or a dependency chain deeper than
|
|
61
|
+
* `maxComputedDependencyDepth` leaves the values involved empty with `INVALID_EXPRESSION`.
|
|
62
|
+
*/
|
|
63
|
+
export declare const computeComposedViewValues: (computed: Record<string, string>, state: Record<string, ExpressionValue>, datasets: Record<string, ExpressionValue>, budgets: ComposedViewBudgets) => ComputedValuesResult;
|
|
64
|
+
/** The tree names a computed expression reads, for its dependency list (empty when it does not compile). */
|
|
65
|
+
export declare const findExpressionDependencies: (source: string, maxAstNodes: number) => string[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parser of the `ComposedView` expression language — our own tokenizer and recursive-descent
|
|
3
|
+
* parser, never `eval` or `new Function`. The language is closed:
|
|
4
|
+
*
|
|
5
|
+
* literals 12, 3.5, "text", 'text', true, false, null, [a, b], {name: expr, "key": expr}
|
|
6
|
+
* names a state, dataset or computed name; a lambda parameter
|
|
7
|
+
* member a.b, a["b"], a[0] (own properties of JSON values only — checked when evaluating)
|
|
8
|
+
* operators + - * / % == != < <= > >= && || ! unary - cond ? a : b
|
|
9
|
+
* calls one of the closed functions (`EXPRESSION_FUNCTION_NAMES`), e.g. sum(rows, r => r.visits)
|
|
10
|
+
* lambdas x => expr, (x) => expr, (x, i) => expr — only as an argument of a call
|
|
11
|
+
*
|
|
12
|
+
* There are no statements, assignments, loops or method calls; a call names a function of the closed list, never a
|
|
13
|
+
* value. The AST node count is capped (`maxExpressionAstNodes`); an expression over it does not compile.
|
|
14
|
+
*/
|
|
15
|
+
export type ExpressionNode = {
|
|
16
|
+
kind: "literal";
|
|
17
|
+
value: string | number | boolean | null;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "name";
|
|
20
|
+
name: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "array";
|
|
23
|
+
elements: ExpressionNode[];
|
|
24
|
+
} | {
|
|
25
|
+
kind: "object";
|
|
26
|
+
entries: Array<{
|
|
27
|
+
key: string;
|
|
28
|
+
value: ExpressionNode;
|
|
29
|
+
}>;
|
|
30
|
+
} | {
|
|
31
|
+
kind: "member";
|
|
32
|
+
object: ExpressionNode;
|
|
33
|
+
property: ExpressionNode;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "unary";
|
|
36
|
+
operator: "!" | "-";
|
|
37
|
+
operand: ExpressionNode;
|
|
38
|
+
} | {
|
|
39
|
+
kind: "binary";
|
|
40
|
+
operator: string;
|
|
41
|
+
left: ExpressionNode;
|
|
42
|
+
right: ExpressionNode;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "conditional";
|
|
45
|
+
test: ExpressionNode;
|
|
46
|
+
consequent: ExpressionNode;
|
|
47
|
+
alternate: ExpressionNode;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "call";
|
|
50
|
+
functionName: string;
|
|
51
|
+
args: ExpressionNode[];
|
|
52
|
+
} | {
|
|
53
|
+
kind: "lambda";
|
|
54
|
+
params: string[];
|
|
55
|
+
body: ExpressionNode;
|
|
56
|
+
};
|
|
57
|
+
/** The closed function list (the evaluator implements exactly these). */
|
|
58
|
+
export declare const EXPRESSION_FUNCTION_NAMES: readonly ["round", "floor", "ceil", "abs", "min", "max", "sum", "avg", "count", "len", "filter", "map", "sortBy", "first", "last", "concat", "join", "string", "number", "fixed", "percent"];
|
|
59
|
+
export type ExpressionFunctionName = (typeof EXPRESSION_FUNCTION_NAMES)[number];
|
|
60
|
+
export type ExpressionCompileResult = {
|
|
61
|
+
ok: true;
|
|
62
|
+
ast: ExpressionNode;
|
|
63
|
+
nodeCount: number;
|
|
64
|
+
} | {
|
|
65
|
+
ok: false;
|
|
66
|
+
error: string;
|
|
67
|
+
};
|
|
68
|
+
/** Compiles an expression once (cached by source and node budget); never throws. */
|
|
69
|
+
export declare const compileExpression: (source: string, maxAstNodes: number) => ExpressionCompileResult;
|
|
70
|
+
/** The names an expression reads (lambda parameters excluded) — the computed dependency graph. */
|
|
71
|
+
export declare const collectExpressionNames: (ast: ExpressionNode, boundNames?: ReadonlySet<string>) => Set<string>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ExpressionValue } from "./expression/evaluate-expression";
|
|
2
|
+
import { JsonValue } from "./composed-view-tree";
|
|
3
|
+
/**
|
|
4
|
+
* Turns bound props and datasets of a `ComposedView` tree into values. A binding is resolved in the
|
|
5
|
+
* browser from what the tree already holds: `$state` (the instance state), `$computed` (the evaluated expressions),
|
|
6
|
+
* `$data` (a dataset), `$item` (a field of the current row of an item scope — a dotted `author.name` reads a nested
|
|
7
|
+
* object, `readComposedViewRowField`), `$from` (the snapshot the backend writes INTO the
|
|
8
|
+
* binding when the row is stored — `{"$from": {"toolCall", "path", "state": "resolved", "value": …}}`;
|
|
9
|
+
* before that the binding is `pending`) and `$source` (a registered data source the frontend hydrates through the
|
|
10
|
+
* widget-hydration mechanism, `composed-view-data-sources.ts`; looked up by its binding key, `pending` until the rows
|
|
11
|
+
* arrive). A value that does not resolve is `undefined` and the prop renders empty.
|
|
12
|
+
*/
|
|
13
|
+
export type ResolvedBindingStatus = "resolved" | "pending" | "failed";
|
|
14
|
+
export interface ComposedViewValueScope {
|
|
15
|
+
state: Record<string, ExpressionValue>;
|
|
16
|
+
computed: Record<string, ExpressionValue>;
|
|
17
|
+
datasets: Record<string, ExpressionValue>;
|
|
18
|
+
/**
|
|
19
|
+
* Each dataset's binding status (`resolveComposedViewDatasets().statusByDatasetName`): a prop bound with `$data` to a
|
|
20
|
+
* dataset whose `$from` / `$source` is still pending is pending itself, exactly like a direct `$from` binding.
|
|
21
|
+
*/
|
|
22
|
+
datasetStatuses?: Record<string, ResolvedBindingStatus>;
|
|
23
|
+
/** The current row of the innermost item scope (`Repeat`), when inside one. */
|
|
24
|
+
item?: ExpressionValue;
|
|
25
|
+
/** The hydrated `$source` values, by binding key (`composedViewSourceBindingKey`). */
|
|
26
|
+
sources?: Record<string, ComposedViewSourceValue>;
|
|
27
|
+
}
|
|
28
|
+
export interface ComposedViewSourceValue {
|
|
29
|
+
status: ResolvedBindingStatus;
|
|
30
|
+
value: ExpressionValue;
|
|
31
|
+
}
|
|
32
|
+
/** The identity of a `$source` wire value — its name and parameters as written; null for another value. */
|
|
33
|
+
export declare const composedViewSourceBindingKey: (wireValue: unknown) => string | null;
|
|
34
|
+
export interface ResolvedComposedViewDatasets {
|
|
35
|
+
datasets: Record<string, ExpressionValue>;
|
|
36
|
+
statusByDatasetName: Record<string, ResolvedBindingStatus>;
|
|
37
|
+
}
|
|
38
|
+
/** The value and status a `$from` binding's stored snapshot carries. */
|
|
39
|
+
export declare const readFromBindingSnapshot: (fromBindingObject: Record<string, unknown>) => {
|
|
40
|
+
status: ResolvedBindingStatus;
|
|
41
|
+
value: ExpressionValue;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The tree's datasets as values: inline rows as written, `$from` from its snapshot, `$source` from
|
|
45
|
+
* `sourceValuesByBindingKey` (filled by the data-source hydration; pending without).
|
|
46
|
+
*/
|
|
47
|
+
export declare const resolveComposedViewDatasets: (data: Record<string, JsonValue>, sourceValuesByBindingKey?: Record<string, ComposedViewSourceValue>) => ResolvedComposedViewDatasets;
|
|
48
|
+
/** One prop value with its bindings resolved (nested bindings in inline data included). */
|
|
49
|
+
export declare const resolveComposedViewValue: (wireValue: JsonValue | undefined, scope: ComposedViewValueScope, onBindingStatus?: (status: ResolvedBindingStatus) => void) => ExpressionValue;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComposedViewBudgets } from "./composed-node-schema";
|
|
2
|
+
import type { ComposedViewTree } from "./composed-view-tree";
|
|
3
|
+
/**
|
|
4
|
+
* The local state of one `ComposedView` instance: initialised from the tree's `state`, changed only by
|
|
5
|
+
* the tree's own inputs (`onChange: {"set": …}`) and the `resetState` action — never written anywhere, so a replayed
|
|
6
|
+
* message's inputs stay usable. Budgets: a string longer than `maxStateStringLength` is cut, a name the tree did
|
|
7
|
+
* not declare is ignored, and at most `maxInputUpdatesPerSecond` updates per second are applied (a dragged slider
|
|
8
|
+
* cannot flood the evaluator). A new tree (the payload changed under the same instance) starts from its own state.
|
|
9
|
+
*/
|
|
10
|
+
export type ComposedViewStateValue = string | number | boolean | null;
|
|
11
|
+
export interface ComposedViewStateStore {
|
|
12
|
+
state: Record<string, ComposedViewStateValue>;
|
|
13
|
+
setStateValue: (name: string, value: unknown) => void;
|
|
14
|
+
resetState: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const useComposedViewState: (tree: ComposedViewTree, budgets: ComposedViewBudgets) => ComposedViewStateStore;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Viewport-windowing for chat widgets. Heavy interactive widgets (maps, lists, hydrating components) are mounted ONLY
|
|
4
|
+
* while near the viewport and unmounted back to a placeholder when far away — so a long conversation keeps a CONSTANT
|
|
5
|
+
* number of widgets mounted no matter how far you scroll. Two thresholds give hysteresis (reveal early, hide late) so a
|
|
6
|
+
* small scroll wobble never thrashes mount/unmount.
|
|
7
|
+
*
|
|
8
|
+
* The IntersectionObserver root is the chat scroll container, supplied via {@link WidgetWindowRootContext} by the chat
|
|
9
|
+
* host (ConversationViewBody). Observers are POOLED per (root, margin): all placeholders share two observers, not two each.
|
|
10
|
+
*/
|
|
11
|
+
export declare const WidgetWindowRootContext: React.Context<HTMLElement | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Drives a widget's mounted/unmounted state from its viewport proximity.
|
|
14
|
+
*
|
|
15
|
+
* - `pinned` (the freshly-delivered widget) → always revealed, never observed: a live widget must not unmount while its
|
|
16
|
+
* one-shot effects (canvas auto-open) are in play, and re-mounting it later would re-fire them.
|
|
17
|
+
* - otherwise: starts at `initialRevealed` (the cheap index-window guess for first paint), then the reveal observer
|
|
18
|
+
* mounts it when it scrolls within REVEAL_MARGIN and the hide observer unmounts it past HIDE_MARGIN.
|
|
19
|
+
*
|
|
20
|
+
* Returns `[revealed, reveal]` — `reveal` lets the placeholder force a manual mount (the "Show" affordance).
|
|
21
|
+
*/
|
|
22
|
+
export declare const useWidgetWindow: (targetRef: RefObject<HTMLElement | null>, options: {
|
|
23
|
+
initialRevealed: boolean;
|
|
24
|
+
pinned: boolean;
|
|
25
|
+
}) => [boolean, () => void];
|