@cossistant/react 0.0.20 → 0.0.22

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 (83) hide show
  1. package/conversation.d.ts +28 -0
  2. package/conversation.d.ts.map +1 -1
  3. package/hooks/index.d.ts +4 -1
  4. package/hooks/index.js +4 -1
  5. package/hooks/private/use-grouped-messages.d.ts.map +1 -1
  6. package/hooks/private/use-grouped-messages.js +3 -17
  7. package/hooks/private/use-grouped-messages.js.map +1 -1
  8. package/hooks/use-conversation-auto-seen.d.ts +1 -1
  9. package/hooks/use-conversation-auto-seen.js +30 -46
  10. package/hooks/use-conversation-auto-seen.js.map +1 -1
  11. package/hooks/use-conversation-seen.d.ts.map +1 -1
  12. package/hooks/use-conversation-seen.js +7 -3
  13. package/hooks/use-conversation-seen.js.map +1 -1
  14. package/hooks/use-new-message-sound.d.ts +23 -0
  15. package/hooks/use-new-message-sound.d.ts.map +1 -0
  16. package/hooks/use-new-message-sound.js +34 -0
  17. package/hooks/use-new-message-sound.js.map +1 -0
  18. package/hooks/use-sound-effect.d.ts +30 -0
  19. package/hooks/use-sound-effect.d.ts.map +1 -0
  20. package/hooks/use-sound-effect.js +104 -0
  21. package/hooks/use-sound-effect.js.map +1 -0
  22. package/hooks/use-typing-sound.d.ts +18 -0
  23. package/hooks/use-typing-sound.d.ts.map +1 -0
  24. package/hooks/use-typing-sound.js +38 -0
  25. package/hooks/use-typing-sound.js.map +1 -0
  26. package/index.d.ts +5 -2
  27. package/index.js +8 -6
  28. package/package.json +3 -3
  29. package/primitives/bubble.js +1 -1
  30. package/primitives/index.d.ts +3 -5
  31. package/primitives/index.js +3 -9
  32. package/primitives/index.parts.d.ts +2 -4
  33. package/primitives/index.parts.js +2 -4
  34. package/primitives/router.d.ts +19 -20
  35. package/primitives/router.d.ts.map +1 -1
  36. package/primitives/router.js +17 -11
  37. package/primitives/router.js.map +1 -1
  38. package/realtime/index.js +1 -1
  39. package/realtime/provider.js +1 -1
  40. package/realtime-events.d.ts +14 -0
  41. package/realtime-events.d.ts.map +1 -1
  42. package/schemas3.d.ts +7 -0
  43. package/schemas3.d.ts.map +1 -1
  44. package/support/components/bubble.d.ts.map +1 -1
  45. package/support/components/bubble.js +27 -4
  46. package/support/components/bubble.js.map +1 -1
  47. package/support/components/button.d.ts +1 -1
  48. package/support/components/conversation-event.js +1 -1
  49. package/support/components/conversation-event.js.map +1 -1
  50. package/support/components/conversation-timeline.d.ts.map +1 -1
  51. package/support/components/conversation-timeline.js +5 -0
  52. package/support/components/conversation-timeline.js.map +1 -1
  53. package/support/components/support-content.d.ts +2 -0
  54. package/support/components/support-content.d.ts.map +1 -1
  55. package/support/components/support-content.js +5 -2
  56. package/support/components/support-content.js.map +1 -1
  57. package/support/components/timeline-message-group.js +2 -2
  58. package/support/components/timeline-message-group.js.map +1 -1
  59. package/support/components/timeline-message-item.js +2 -2
  60. package/support/components/timeline-message-item.js.map +1 -1
  61. package/support/components/typing-indicator.d.ts.map +1 -1
  62. package/support/index.d.ts +12 -7
  63. package/support/index.d.ts.map +1 -1
  64. package/support/index.js +28 -29
  65. package/support/index.js.map +1 -1
  66. package/support/pages/conversation.d.ts.map +1 -1
  67. package/support/pages/conversation.js +19 -1
  68. package/support/pages/conversation.js.map +1 -1
  69. package/support/router.d.ts +19 -9
  70. package/support/router.d.ts.map +1 -1
  71. package/support/router.js +31 -30
  72. package/support/router.js.map +1 -1
  73. package/timeline-item.d.ts +14 -0
  74. package/timeline-item.d.ts.map +1 -1
  75. package/utils/use-render-element.d.ts.map +1 -1
  76. package/primitives/page-registry.d.ts +0 -30
  77. package/primitives/page-registry.d.ts.map +0 -1
  78. package/primitives/page-registry.js +0 -45
  79. package/primitives/page-registry.js.map +0 -1
  80. package/primitives/page.d.ts +0 -21
  81. package/primitives/page.d.ts.map +0 -1
  82. package/primitives/page.js +0 -18
  83. package/primitives/page.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.js","names":["ConversationPage: ConversationPageComponent"],"sources":["../../../src/support/pages/conversation.tsx"],"sourcesContent":["import { ConversationStatus } from \"@cossistant/types\";\nimport type { TimelineItem } from \"@cossistant/types/api/timeline-item\";\nimport { type ReactElement, useMemo } from \"react\";\nimport { useConversation } from \"../../hooks/use-conversation\";\nimport { useConversationPage } from \"../../hooks/use-conversation-page\";\nimport { useSupport } from \"../../provider\";\nimport { AvatarStack } from \"../components/avatar-stack\";\nimport { ConversationTimelineList } from \"../components/conversation-timeline\";\nimport { Header } from \"../components/header\";\nimport { MultimodalInput } from \"../components/multimodal-input\";\nimport { IdentificationTimelineTool } from \"../components/timeline-identification-tool\";\nimport { useSupportConfig, useSupportNavigation } from \"../store\";\nimport { Text, useSupportText } from \"../text\";\n\ntype ConversationPageProps = {\n\t/**\n\t * Page params object (for compatibility with Page component)\n\t */\n\tparams?: {\n\t\t/**\n\t\t * The conversation ID to display (can be PENDING_CONVERSATION_ID or a real ID).\n\t\t */\n\t\tconversationId: string;\n\n\t\t/**\n\t\t * Optional initial message to send when opening the conversation.\n\t\t */\n\t\tinitialMessage?: string;\n\n\t\t/**\n\t\t * Optional timeline items to display (for optimistic updates or initial state).\n\t\t */\n\t\titems?: TimelineItem[];\n\t};\n\n\t// Legacy direct props support (deprecated but maintained for backward compatibility)\n\tconversationId?: string;\n\tinitialMessage?: string;\n\titems?: TimelineItem[];\n};\n\n/**\n * Conversation page with message timeline and input composer.\n */\ntype ConversationPageComponent = (props: ConversationPageProps) => ReactElement;\n\nexport const ConversationPage: ConversationPageComponent = ({\n\tparams,\n\tconversationId: legacyConversationId,\n\tinitialMessage: legacyInitialMessage,\n\titems: legacyItems,\n}: ConversationPageProps) => {\n\t// Support both params object (new) and direct props (legacy)\n\tconst initialConversationId =\n\t\tparams?.conversationId ?? legacyConversationId ?? \"\";\n\tconst initialMessage = params?.initialMessage ?? legacyInitialMessage;\n\tconst passedItems = params?.items ?? legacyItems ?? [];\n\tconst { website, availableAIAgents, availableHumanAgents, visitor } =\n\t\tuseSupport();\n\tconst { navigate, replace, goBack, canGoBack } = useSupportNavigation();\n\tconst { isOpen } = useSupportConfig();\n\tconst text = useSupportText();\n\n\tconst timelineTools = useMemo(\n\t\t() => ({\n\t\t\tidentification: { component: IdentificationTimelineTool },\n\t\t}),\n\t\t[]\n\t);\n\n\t// Main conversation hook - handles all logic\n\tconst conversation = useConversationPage({\n\t\tconversationId: initialConversationId,\n\t\titems: passedItems,\n\t\tinitialMessage,\n\t\tautoSeenEnabled: isOpen,\n\t\tonConversationIdChange: (newConversationId) => {\n\t\t\t// Update navigation when conversation is created\n\t\t\treplace({\n\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\tparams: { conversationId: newConversationId },\n\t\t\t});\n\t\t},\n\t});\n\n\tconst { conversation: activeConversation } = useConversation(\n\t\tconversation.isPending ? null : conversation.conversationId,\n\t\t{ enabled: !conversation.isPending }\n\t);\n\n\tconst isConversationClosed = Boolean(\n\t\tactiveConversation &&\n\t\t\t(activeConversation.status === ConversationStatus.RESOLVED ||\n\t\t\t\tactiveConversation.status === ConversationStatus.SPAM ||\n\t\t\t\tactiveConversation.deletedAt)\n\t);\n\n\tconst handleGoBack = () => {\n\t\tif (canGoBack) {\n\t\t\tgoBack();\n\t\t} else {\n\t\t\tnavigate({ page: \"HOME\" });\n\t\t}\n\t};\n\n\treturn (\n\t\t<div className=\"flex h-full flex-col gap-0 overflow-hidden\">\n\t\t\t<Header onGoBack={handleGoBack}>\n\t\t\t\t<div className=\"flex w-full items-center justify-between gap-2 py-3\">\n\t\t\t\t\t<div className=\"flex flex-col\">\n\t\t\t\t\t\t<p className=\"font-medium text-co-primary text-sm\">\n\t\t\t\t\t\t\t{website?.name}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t\t\tclassName=\"text-co-muted-foreground text-sm\"\n\t\t\t\t\t\t\ttextKey=\"common.labels.supportOnline\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={availableAIAgents}\n\t\t\t\t\t\tgapWidth={2}\n\t\t\t\t\t\thumanAgents={availableHumanAgents}\n\t\t\t\t\t\tsize={32}\n\t\t\t\t\t\tspacing={28}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</Header>\n\n\t\t\t<ConversationTimelineList\n\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\tclassName=\"min-h-0 flex-1 px-4\"\n\t\t\t\tconversationId={conversation.conversationId}\n\t\t\t\tcurrentVisitorId={visitor?.id}\n\t\t\t\titems={conversation.items}\n\t\t\t\ttools={timelineTools}\n\t\t\t/>\n\n\t\t\t{isConversationClosed ? (\n\t\t\t\t<div className=\"m-4 flex items-center justify-center text-balance px-4 pb-6 text-center font-medium text-co-muted-foreground text-sm\">\n\t\t\t\t\t<Text as=\"p\" textKey=\"component.conversationPage.closedMessage\" />\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div className=\"flex-shrink-0 p-1\">\n\t\t\t\t\t<MultimodalInput\n\t\t\t\t\t\tdisabled={conversation.composer.isSubmitting}\n\t\t\t\t\t\terror={conversation.error}\n\t\t\t\t\t\tfiles={conversation.composer.files}\n\t\t\t\t\t\tisSubmitting={conversation.composer.isSubmitting}\n\t\t\t\t\t\tonChange={conversation.composer.setMessage}\n\t\t\t\t\t\tonFileSelect={conversation.composer.addFiles}\n\t\t\t\t\t\tonRemoveFile={conversation.composer.removeFile}\n\t\t\t\t\t\tonSubmit={conversation.composer.submit}\n\t\t\t\t\t\tplaceholder={text(\"component.multimodalInput.placeholder\")}\n\t\t\t\t\t\tvalue={conversation.composer.message}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;AA8CA,MAAaA,oBAA+C,EAC3D,QACA,gBAAgB,sBACh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AAS;IAC3B,OAAO,aAAa;IACpB,OAAO;KACN;GAED,uBACA,oBAAC;IAAI,WAAU;cACd,oBAAC;KAAK,IAAG;KAAI,SAAQ;MAA6C;KAC7D,GAEN,oBAAC;IAAI,WAAU;cACd,oBAAC;KACA,UAAU,aAAa,SAAS;KAChC,OAAO,aAAa;KACpB,OAAO,aAAa,SAAS;KAC7B,cAAc,aAAa,SAAS;KACpC,UAAU,aAAa,SAAS;KAChC,cAAc,aAAa,SAAS;KACpC,cAAc,aAAa,SAAS;KACpC,UAAU,aAAa,SAAS;KAChC,aAAa,KAAK,wCAAwC;KAC1D,OAAO,aAAa,SAAS;MAC5B;KACG;;GAEF"}
1
+ {"version":3,"file":"conversation.js","names":["ConversationPage: ConversationPageComponent"],"sources":["../../../src/support/pages/conversation.tsx"],"sourcesContent":["import { ConversationStatus } from \"@cossistant/types\";\nimport type { TimelineItem } from \"@cossistant/types/api/timeline-item\";\nimport { type ReactElement, useEffect, useMemo, useRef } from \"react\";\nimport { useConversation } from \"../../hooks/use-conversation\";\nimport { useConversationPage } from \"../../hooks/use-conversation-page\";\nimport { useNewMessageSound } from \"../../hooks/use-new-message-sound\";\nimport { useSupport } from \"../../provider\";\nimport { AvatarStack } from \"../components/avatar-stack\";\nimport { ConversationTimelineList } from \"../components/conversation-timeline\";\nimport { Header } from \"../components/header\";\nimport { MultimodalInput } from \"../components/multimodal-input\";\nimport { IdentificationTimelineTool } from \"../components/timeline-identification-tool\";\nimport { useSupportConfig, useSupportNavigation } from \"../store\";\nimport { Text, useSupportText } from \"../text\";\n\ntype ConversationPageProps = {\n\t/**\n\t * Page params object (for compatibility with Page component)\n\t */\n\tparams?: {\n\t\t/**\n\t\t * The conversation ID to display (can be PENDING_CONVERSATION_ID or a real ID).\n\t\t */\n\t\tconversationId: string;\n\n\t\t/**\n\t\t * Optional initial message to send when opening the conversation.\n\t\t */\n\t\tinitialMessage?: string;\n\n\t\t/**\n\t\t * Optional timeline items to display (for optimistic updates or initial state).\n\t\t */\n\t\titems?: TimelineItem[];\n\t};\n\n\t// Legacy direct props support (deprecated but maintained for backward compatibility)\n\tconversationId?: string;\n\tinitialMessage?: string;\n\titems?: TimelineItem[];\n};\n\n/**\n * Conversation page with message timeline and input composer.\n */\ntype ConversationPageComponent = (props: ConversationPageProps) => ReactElement;\n\nexport const ConversationPage: ConversationPageComponent = ({\n\tparams,\n\tconversationId: legacyConversationId,\n\tinitialMessage: legacyInitialMessage,\n\titems: legacyItems,\n}: ConversationPageProps) => {\n\t// Support both params object (new) and direct props (legacy)\n\tconst initialConversationId =\n\t\tparams?.conversationId ?? legacyConversationId ?? \"\";\n\tconst initialMessage = params?.initialMessage ?? legacyInitialMessage;\n\tconst passedItems = params?.items ?? legacyItems ?? [];\n\tconst { website, availableAIAgents, availableHumanAgents, visitor } =\n\t\tuseSupport();\n\tconst { navigate, replace, goBack, canGoBack } = useSupportNavigation();\n\tconst { isOpen } = useSupportConfig();\n\tconst text = useSupportText();\n\tconst playNewMessageSound = useNewMessageSound({\n\t\tvolume: 0.7,\n\t\tplaybackRate: 1.0,\n\t});\n\tconst previousItemsRef = useRef<TimelineItem[]>([]);\n\n\tconst timelineTools = useMemo(\n\t\t() => ({\n\t\t\tidentification: { component: IdentificationTimelineTool },\n\t\t}),\n\t\t[]\n\t);\n\n\t// Main conversation hook - handles all logic\n\tconst conversation = useConversationPage({\n\t\tconversationId: initialConversationId,\n\t\titems: passedItems,\n\t\tinitialMessage,\n\t\tautoSeenEnabled: isOpen,\n\t\tonConversationIdChange: (newConversationId) => {\n\t\t\t// Update navigation when conversation is created\n\t\t\treplace({\n\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\tparams: { conversationId: newConversationId },\n\t\t\t});\n\t\t},\n\t});\n\n\tconst { conversation: activeConversation } = useConversation(\n\t\tconversation.isPending ? null : conversation.conversationId,\n\t\t{ enabled: !conversation.isPending }\n\t);\n\n\tconst isConversationClosed = Boolean(\n\t\tactiveConversation &&\n\t\t\t(activeConversation.status === ConversationStatus.RESOLVED ||\n\t\t\t\tactiveConversation.status === ConversationStatus.SPAM ||\n\t\t\t\tactiveConversation.deletedAt)\n\t);\n\n\tconst handleGoBack = () => {\n\t\tif (canGoBack) {\n\t\t\tgoBack();\n\t\t} else {\n\t\t\tnavigate({ page: \"HOME\" });\n\t\t}\n\t};\n\n\t// Play sound when new messages arrive from agents (not visitor)\n\tuseEffect(() => {\n\t\tconst currentItems = conversation.items;\n\t\tconst previousItems = previousItemsRef.current;\n\n\t\t// Check if there are new items\n\t\tif (currentItems.length > previousItems.length) {\n\t\t\t// Find the new items\n\t\t\tconst newItems = currentItems.slice(previousItems.length);\n\n\t\t\t// Play sound only if new message is from agent (not visitor)\n\t\t\tfor (const item of newItems) {\n\t\t\t\tif (item.type === \"message\" && !item.visitorId) {\n\t\t\t\t\tplayNewMessageSound();\n\t\t\t\t\tbreak; // Only play once per batch\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Update the ref\n\t\tpreviousItemsRef.current = currentItems;\n\t}, [conversation.items, playNewMessageSound]);\n\n\treturn (\n\t\t<div className=\"flex h-full flex-col gap-0 overflow-hidden\">\n\t\t\t<Header onGoBack={handleGoBack}>\n\t\t\t\t<div className=\"flex w-full items-center justify-between gap-2 py-3\">\n\t\t\t\t\t<div className=\"flex flex-col\">\n\t\t\t\t\t\t<p className=\"font-medium text-co-primary text-sm\">\n\t\t\t\t\t\t\t{website?.name}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t\t\tclassName=\"text-co-muted-foreground text-sm\"\n\t\t\t\t\t\t\ttextKey=\"common.labels.supportOnline\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={availableAIAgents}\n\t\t\t\t\t\tgapWidth={2}\n\t\t\t\t\t\thumanAgents={availableHumanAgents}\n\t\t\t\t\t\tsize={32}\n\t\t\t\t\t\tspacing={28}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</Header>\n\n\t\t\t<ConversationTimelineList\n\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\tclassName=\"min-h-0 flex-1 px-4\"\n\t\t\t\tconversationId={conversation.conversationId}\n\t\t\t\tcurrentVisitorId={visitor?.id}\n\t\t\t\titems={conversation.items}\n\t\t\t\ttools={timelineTools}\n\t\t\t/>\n\n\t\t\t{isConversationClosed ? (\n\t\t\t\t<div className=\"m-4 flex items-center justify-center text-balance px-4 pb-6 text-center font-medium text-co-muted-foreground text-sm\">\n\t\t\t\t\t<Text as=\"p\" textKey=\"component.conversationPage.closedMessage\" />\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div className=\"flex-shrink-0 p-1\">\n\t\t\t\t\t<MultimodalInput\n\t\t\t\t\t\tdisabled={conversation.composer.isSubmitting}\n\t\t\t\t\t\terror={conversation.error}\n\t\t\t\t\t\tfiles={conversation.composer.files}\n\t\t\t\t\t\tisSubmitting={conversation.composer.isSubmitting}\n\t\t\t\t\t\tonChange={conversation.composer.setMessage}\n\t\t\t\t\t\tonFileSelect={conversation.composer.addFiles}\n\t\t\t\t\t\tonRemoveFile={conversation.composer.removeFile}\n\t\t\t\t\t\tonSubmit={conversation.composer.submit}\n\t\t\t\t\t\tplaceholder={text(\"component.multimodalInput.placeholder\")}\n\t\t\t\t\t\tvalue={conversation.composer.message}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA+CA,MAAaA,oBAA+C,EAC3D,QACA,gBAAgB,sBAChB,gBAAgB,sBAChB,OAAO,kBACqB;CAE5B,MAAM,wBACL,QAAQ,kBAAkB,wBAAwB;CACnD,MAAM,iBAAiB,QAAQ,kBAAkB;CACjD,MAAM,cAAc,QAAQ,SAAS,eAAe,EAAE;CACtD,MAAM,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,oBAAC;OAAE,WAAU;iBACX,SAAS;QACP,EACJ,oBAAC;OACA,IAAG;OACH,WAAU;OACV,SAAQ;QACP;OACG,EACN,oBAAC;MACA,UAAU;MACV,UAAU;MACV,aAAa;MACb,MAAM;MACN,SAAS;OACR;MACG;KACE;GAET,oBAAC;IACmB;IACG;IACtB,WAAU;IACV,gBAAgB,aAAa;IAC7B,kBAAkB,SAAS;IAC3B,OAAO,aAAa;IACpB,OAAO;KACN;GAED,uBACA,oBAAC;IAAI,WAAU;cACd,oBAAC;KAAK,IAAG;KAAI,SAAQ;MAA6C;KAC7D,GAEN,oBAAC;IAAI,WAAU;cACd,oBAAC;KACA,UAAU,aAAa,SAAS;KAChC,OAAO,aAAa;KACpB,OAAO,aAAa,SAAS;KAC7B,cAAc,aAAa,SAAS;KACpC,UAAU,aAAa,SAAS;KAChC,cAAc,aAAa,SAAS;KACpC,cAAc,aAAa,SAAS;KACpC,UAAU,aAAa,SAAS;KAChC,aAAa,KAAK,wCAAwC;KAC1D,OAAO,aAAa,SAAS;MAC5B;KACG;;GAEF"}
@@ -1,19 +1,29 @@
1
1
  import React from "react";
2
+ import { RouteRegistry } from "@cossistant/core";
2
3
 
3
4
  //#region src/support/router.d.ts
4
-
5
+ type CustomPage<K extends keyof RouteRegistry = keyof RouteRegistry> = {
6
+ name: K;
7
+ component: React.ComponentType<{
8
+ params?: RouteRegistry[K];
9
+ }>;
10
+ };
11
+ type SupportRouterProps = {
12
+ customPages?: CustomPage[];
13
+ children?: React.ReactNode;
14
+ };
5
15
  /**
6
16
  * Router with default support pages (HOME, ARTICLES, CONVERSATION, CONVERSATION_HISTORY).
7
- * Add custom pages as children.
17
+ * Add custom pages via customPages prop.
8
18
  *
9
19
  * @example
10
- * <SupportRouter>
11
- * <Page name="SETTINGS" component={SettingsPage} />
12
- * </SupportRouter>
20
+ * <SupportRouter
21
+ * customPages={[
22
+ * { name: "SETTINGS", component: SettingsPage }
23
+ * ]}
24
+ * />
13
25
  */
14
- declare const SupportRouter: React.FC<{
15
- children?: React.ReactNode;
16
- }>;
26
+ declare const SupportRouter: React.FC<SupportRouterProps>;
17
27
  //#endregion
18
- export { SupportRouter };
28
+ export { CustomPage, SupportRouter, SupportRouterProps };
19
29
  //# sourceMappingURL=router.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","names":[],"sources":["../../src/support/router.tsx"],"sourcesContent":[],"mappings":";;;;;;AAiBA;;;;;;;cAAa,eAAe,KAAA,CAAM;aAAgB,KAAA,CAAM"}
1
+ {"version":3,"file":"router.d.ts","names":[],"sources":["../../src/support/router.tsx"],"sourcesContent":[],"mappings":";;;;KAWY,2BAA2B,sBAAsB;QACtD;EADK,SAAA,EAEA,KAAA,CAAM,aAFI,CAAA;IAAiB,MAAA,CAAA,EAEI,aAFJ,CAEkB,CAFlB,CAAA;EAAsB,CAAA,CAAA;CACtD;AACoC,KAG/B,kBAAA,GAH+B;EAAc,WAAA,CAAA,EAI1C,UAJ0C,EAAA;EAA7C,QAAM,CAAA,EAKN,KAAA,CAAM,SALA;CAAa;AAG/B;AAgBA;;;;;;;;;;cAAa,eAAe,KAAA,CAAM,GAAG"}
package/support/router.js CHANGED
@@ -1,4 +1,3 @@
1
- import { Page } from "../primitives/page.js";
2
1
  import { Router } from "../primitives/router.js";
3
2
  import { useSupportNavigation } from "./store/support-store.js";
4
3
  import { ArticlesPage } from "./pages/articles.js";
@@ -10,39 +9,41 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
9
  //#region src/support/router.tsx
11
10
  /**
12
11
  * Router with default support pages (HOME, ARTICLES, CONVERSATION, CONVERSATION_HISTORY).
13
- * Add custom pages as children.
12
+ * Add custom pages via customPages prop.
14
13
  *
15
14
  * @example
16
- * <SupportRouter>
17
- * <Page name="SETTINGS" component={SettingsPage} />
18
- * </SupportRouter>
15
+ * <SupportRouter
16
+ * customPages={[
17
+ * { name: "SETTINGS", component: SettingsPage }
18
+ * ]}
19
+ * />
19
20
  */
20
- const SupportRouter = ({ children }) => {
21
+ const SupportRouter = ({ customPages = [], children }) => {
21
22
  const { current } = useSupportNavigation();
22
- return /* @__PURE__ */ jsxs(Fragment, { children: [
23
- /* @__PURE__ */ jsx(Page, {
24
- component: HomePage,
25
- name: "HOME"
26
- }),
27
- /* @__PURE__ */ jsx(Page, {
28
- component: ArticlesPage,
29
- name: "ARTICLES"
30
- }),
31
- /* @__PURE__ */ jsx(Page, {
32
- component: ConversationPage,
33
- name: "CONVERSATION"
34
- }),
35
- /* @__PURE__ */ jsx(Page, {
36
- component: ConversationHistoryPage,
37
- name: "CONVERSATION_HISTORY"
38
- }),
39
- children,
40
- /* @__PURE__ */ jsx(Router, {
41
- fallback: HomePage,
42
- page: current.page,
43
- params: current.params
44
- })
45
- ] });
23
+ const allPages = [...[
24
+ {
25
+ name: "HOME",
26
+ component: HomePage
27
+ },
28
+ {
29
+ name: "ARTICLES",
30
+ component: ArticlesPage
31
+ },
32
+ {
33
+ name: "CONVERSATION",
34
+ component: ConversationPage
35
+ },
36
+ {
37
+ name: "CONVERSATION_HISTORY",
38
+ component: ConversationHistoryPage
39
+ }
40
+ ], ...customPages];
41
+ return /* @__PURE__ */ jsxs(Fragment, { children: [children, /* @__PURE__ */ jsx(Router, {
42
+ fallback: HomePage,
43
+ page: current.page,
44
+ pages: allPages,
45
+ params: current.params
46
+ })] });
46
47
  };
47
48
 
48
49
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","names":["SupportRouter: React.FC<{ children?: React.ReactNode }>","Primitive.Page","Primitive.Router"],"sources":["../../src/support/router.tsx"],"sourcesContent":["import type React from \"react\";\nimport * as Primitive from \"../primitives\";\nimport { ArticlesPage } from \"./pages/articles\";\nimport { ConversationPage } from \"./pages/conversation\";\nimport { ConversationHistoryPage } from \"./pages/conversation-history\";\nimport { HomePage } from \"./pages/home\";\nimport { useSupportNavigation } from \"./store/support-store\";\n\n/**\n * Router with default support pages (HOME, ARTICLES, CONVERSATION, CONVERSATION_HISTORY).\n * Add custom pages as children.\n *\n * @example\n * <SupportRouter>\n * <Page name=\"SETTINGS\" component={SettingsPage} />\n * </SupportRouter>\n */\nexport const SupportRouter: React.FC<{ children?: React.ReactNode }> = ({\n\tchildren,\n}) => {\n\tconst { current } = useSupportNavigation();\n\n\treturn (\n\t\t<>\n\t\t\t{/* Register default pages */}\n\t\t\t<Primitive.Page\n\t\t\t\tcomponent={HomePage as React.ComponentType<{ params?: unknown }>}\n\t\t\t\tname=\"HOME\"\n\t\t\t/>\n\t\t\t<Primitive.Page\n\t\t\t\tcomponent={ArticlesPage as React.ComponentType<{ params?: unknown }>}\n\t\t\t\tname=\"ARTICLES\"\n\t\t\t/>\n\t\t\t<Primitive.Page\n\t\t\t\tcomponent={\n\t\t\t\t\tConversationPage as React.ComponentType<{ params?: unknown }>\n\t\t\t\t}\n\t\t\t\tname=\"CONVERSATION\"\n\t\t\t/>\n\t\t\t<Primitive.Page\n\t\t\t\tcomponent={\n\t\t\t\t\tConversationHistoryPage as React.ComponentType<{ params?: unknown }>\n\t\t\t\t}\n\t\t\t\tname=\"CONVERSATION_HISTORY\"\n\t\t\t/>\n\n\t\t\t{/* Allow custom pages via children */}\n\t\t\t{children}\n\n\t\t\t{/* Render using primitive router */}\n\t\t\t<Primitive.Router\n\t\t\t\tfallback={HomePage as React.ComponentType<{ params?: unknown }>}\n\t\t\t\tpage={current.page as string}\n\t\t\t\tparams={current.params}\n\t\t\t/>\n\t\t</>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,MAAaA,iBAA2D,EACvE,eACK;CACL,MAAM,EAAE,YAAY,sBAAsB;AAE1C,QACC;EAEC,oBAACC;GACA,WAAW;GACX,MAAK;IACJ;EACF,oBAACA;GACA,WAAW;GACX,MAAK;IACJ;EACF,oBAACA;GACA,WACC;GAED,MAAK;IACJ;EACF,oBAACA;GACA,WACC;GAED,MAAK;IACJ;EAGD;EAGD,oBAACC;GACA,UAAU;GACV,MAAM,QAAQ;GACd,QAAQ,QAAQ;IACf;KACA"}
1
+ {"version":3,"file":"router.js","names":["SupportRouter: React.FC<SupportRouterProps>","Primitive.Router"],"sources":["../../src/support/router.tsx"],"sourcesContent":["import type { RouteRegistry } from \"@cossistant/core\";\nimport type React from \"react\";\nimport type { PageDefinition } from \"../primitives\";\nimport * as Primitive from \"../primitives\";\nimport { ArticlesPage } from \"./pages/articles\";\nimport { ConversationPage } from \"./pages/conversation\";\nimport { ConversationHistoryPage } from \"./pages/conversation-history\";\nimport { HomePage } from \"./pages/home\";\nimport { useSupportNavigation } from \"./store/support-store\";\n\n// Type for custom pages that ensures they match RouteRegistry\nexport type CustomPage<K extends keyof RouteRegistry = keyof RouteRegistry> = {\n\tname: K;\n\tcomponent: React.ComponentType<{ params?: RouteRegistry[K] }>;\n};\n\nexport type SupportRouterProps = {\n\tcustomPages?: CustomPage[];\n\tchildren?: React.ReactNode;\n};\n\n/**\n * Router with default support pages (HOME, ARTICLES, CONVERSATION, CONVERSATION_HISTORY).\n * Add custom pages via customPages prop.\n *\n * @example\n * <SupportRouter\n * customPages={[\n * { name: \"SETTINGS\", component: SettingsPage }\n * ]}\n * />\n */\nexport const SupportRouter: React.FC<SupportRouterProps> = ({\n\tcustomPages = [],\n\tchildren,\n}) => {\n\tconst { current } = useSupportNavigation();\n\n\t// Define all pages with proper typing\n\tconst builtInPages = [\n\t\t{\n\t\t\tname: \"HOME\",\n\t\t\tcomponent: HomePage,\n\t\t},\n\t\t{\n\t\t\tname: \"ARTICLES\",\n\t\t\tcomponent: ArticlesPage,\n\t\t},\n\t\t{\n\t\t\tname: \"CONVERSATION\",\n\t\t\tcomponent: ConversationPage,\n\t\t},\n\t\t{\n\t\t\tname: \"CONVERSATION_HISTORY\",\n\t\t\tcomponent: ConversationHistoryPage,\n\t\t},\n\t] as PageDefinition<keyof RouteRegistry>[];\n\n\t// Combine built-in and custom pages\n\tconst allPages = [...builtInPages, ...customPages] as PageDefinition<\n\t\tkeyof RouteRegistry\n\t>[];\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Primitive.Router\n\t\t\t\tfallback={HomePage as React.ComponentType<{ params?: unknown }>}\n\t\t\t\tpage={current.page}\n\t\t\t\tpages={allPages}\n\t\t\t\tparams={current.params}\n\t\t\t/>\n\t\t</>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,MAAaA,iBAA+C,EAC3D,cAAc,EAAE,EAChB,eACK;CACL,MAAM,EAAE,YAAY,sBAAsB;CAuB1C,MAAM,WAAW,CAAC,GApBG;EACpB;GACC,MAAM;GACN,WAAW;GACX;EACD;GACC,MAAM;GACN,WAAW;GACX;EACD;GACC,MAAM;GACN,WAAW;GACX;EACD;GACC,MAAM;GACN,WAAW;GACX;EACD,EAGkC,GAAG,YAAY;AAIlD,QACC,4CACE,UACD,oBAACC;EACA,UAAU;EACV,MAAM,QAAQ;EACd,OAAO;EACP,QAAQ,QAAQ;GACf,IACA"}
@@ -61,6 +61,13 @@ declare const timelineItemSchema: ZodObject<{
61
61
  mediaType: ZodString;
62
62
  fileName: ZodOptional<ZodString>;
63
63
  size: ZodOptional<ZodNumber>;
64
+ }, $strip>, ZodObject<{
65
+ type: ZodLiteral<"metadata">;
66
+ source: ZodEnum<{
67
+ email: "email";
68
+ widget: "widget";
69
+ api: "api";
70
+ }>;
64
71
  }, $strip>]>>;
65
72
  userId: ZodNullable<ZodString>;
66
73
  aiAgentId: ZodNullable<ZodString>;
@@ -131,6 +138,13 @@ declare const getConversationTimelineItemsResponseSchema: ZodObject<{
131
138
  mediaType: ZodString;
132
139
  fileName: ZodOptional<ZodString>;
133
140
  size: ZodOptional<ZodNumber>;
141
+ }, $strip>, ZodObject<{
142
+ type: ZodLiteral<"metadata">;
143
+ source: ZodEnum<{
144
+ email: "email";
145
+ widget: "widget";
146
+ api: "api";
147
+ }>;
134
148
  }, $strip>]>>;
135
149
  userId: ZodNullable<ZodString>;
136
150
  aiAgentId: ZodNullable<ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"timeline-item.d.ts","names":[],"sources":["../../types/src/api/timeline-item.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAgMY,cA9EC,kBA8ED,EA9EmB,SA8EgB,CAAA;EAIlC,EAAA,aAAA,UAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA9BD,kBAAA,GAAqB,cAAe;KAEpC,YAAA,GAAe,cAAe;cAS7B,2CAAyC;;;;AAmBC,KAJ3C,mCAAA,GAAsC,MAIK,CAAA,OAH/C,yCAG+C,CAAA;AAAA,cAA1C,0CAA0C,EAAA,SAAA,CAAA;EAiB3C,KAAA,UAAA,UAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAAA,oCAAA,GAAuC,cAC3C"}
1
+ {"version":3,"file":"timeline-item.d.ts","names":[],"sources":["../../types/src/api/timeline-item.ts"],"sourcesContent":[],"mappings":";;;;;;;;cA4Ha,oBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmFwB,SAAA,WAAA;EAAA,SAAA,aAAA,YAAA,UAAA,CAAA,CAAA;AAiBvD,CAAA,QAAY,CAAA;KAhDA,kBAAA,GAAqB,cAAe;KAEpC,YAAA,GAAe,cAAe;cAU7B,2CAAyC;;;;KAe1C,mCAAA,GAAsC,cAC1C;cAGK,4CAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiB3C,oCAAA,GAAuC,cAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-render-element.d.ts","names":[],"sources":["../../src/utils/use-render-element.tsx"],"sourcesContent":[],"mappings":";;;;AAI+B,KAE1B,YAAA,GAAY,MAAS,GAAA,CAAI,iBAAA;AAAiB,KAE1C,SAAA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1C,SAAA,CAAA,KAAS,CAAA,GAAA,MAAA,GAAA,CAA4B,CAAA,KAAK,EAAL,KAAK,EAAA,GAAA,MAAA,CAAA;AAAA,KAE1C,QAAA,CAAA,KAAQ,EAAA,KAAA,CAAA,GAAA,CAAA,KAAA,EACL,KADK,EAAA,KAAA,EAEL,KAFK,EAAA,GAGR,OAAA,CAAM,YAHE;KAKR,WAJG,CAAA,KAAA,EAAA,YAI4B,YAJ5B,CAAA,GAAA;EACA,MAAA,CAAA,EAIE,OAAA,CAAM,YAJR,GAIuB,QAJvB,CAIgC,GAAA,CAAI,iBAJpC,CAIsD,GAJtD,CAAA,EAI4D,KAJ5D,CAAA;EACH,SAAM,CAAA,EAIE,SAJF,CAIY,KAJZ,CAAA;EAAY,OAAA,CAAA,EAAA,OAAA;AAAA,CAAA;KAQlB,YAN+B,CAAA,KAAA,EAAA,YAMC,YAND,CAAA,GAAA;EAC1B,KAAM,CAAA,EAMP,KANO;EAAwB,GAAI,CAAA,EAOrC,OAAA,CAAM,GAP+B,CAAA,GAAA,CAAA;EAAkB,KAAA,CAAA,EAQrD,OARqD,CAQ7C,GAAA,CAAI,iBARyC,CAQvB,GARuB,CAAA,CAAA;EAAM,OAAA,CAAA,EAAA,OAAA;CAArC;;;;AAK1B,iBAyBW,gBAzBC,CAAA,cA0BF,MA1BE,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,YA2BJ,YA3BI,CAAA,CAAA,GAAA,EA6BX,GA7BW,EAAA,cAAA,EA8BA,WA9BA,CA8BY,KA9BZ,EA8BmB,GA9BnB,CAAA,EAAA,MAAA,CAAA,EA+BP,YA/BO,CA+BM,KA/BN,EA+Ba,GA/Bb,CAAA,CAAA,EAgCd,OAAA,CAAM,YAhCQ,GAAA,IAAA"}
@@ -1,30 +0,0 @@
1
- import React from "react";
2
-
3
- //#region src/primitives/page-registry.d.ts
4
- type PageComponent<P = unknown> = React.ComponentType<{
5
- params?: P;
6
- }>;
7
- type PageRegistry = Map<string, PageComponent>;
8
- /**
9
- * Context provider for declarative page registration.
10
- *
11
- * @example
12
- * <PageRegistryProvider>
13
- * <Page name="HOME" component={HomePage} />
14
- * <Router page={currentPage} />
15
- * </PageRegistryProvider>
16
- */
17
- declare const PageRegistryProvider: React.FC<{
18
- children: React.ReactNode;
19
- }>;
20
- /**
21
- * Access the page registry (used internally by Router and Page).
22
- */
23
- declare const usePageRegistry: () => PageRegistry;
24
- /**
25
- * Register a page in the registry (used internally by Page component).
26
- */
27
- declare const useRegisterPage: (name: string, component: PageComponent) => void;
28
- //#endregion
29
- export { PageRegistryProvider, usePageRegistry, useRegisterPage };
30
- //# sourceMappingURL=page-registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"page-registry.d.ts","names":[],"sources":["../../src/primitives/page-registry.tsx"],"sourcesContent":[],"mappings":";;;KAEK,6BAA6B,KAAA,CAAM;WAAyB;AAFC,CAAA,CAAA;AAEb,KAEhD,YAAA,GAAe,GAAH,CAAA,MAAA,EAAe,aAAA,CAAZ;AAapB;AAeA;AAKA;;;;;;;cApBa,sBAAsB,KAAA,CAAM;YAAe,KAAA,CAAM;;;;;cAejD,uBAAe;;;;cAKf,2CAA4C"}
@@ -1,45 +0,0 @@
1
- import React, { createContext, useContext, useMemo } from "react";
2
- import { jsx } from "react/jsx-runtime";
3
-
4
- //#region src/primitives/page-registry.tsx
5
- const PageRegistryContext = createContext(/* @__PURE__ */ new Map());
6
- /**
7
- * Context provider for declarative page registration.
8
- *
9
- * @example
10
- * <PageRegistryProvider>
11
- * <Page name="HOME" component={HomePage} />
12
- * <Router page={currentPage} />
13
- * </PageRegistryProvider>
14
- */
15
- const PageRegistryProvider = ({ children }) => {
16
- const registry = useMemo(() => /* @__PURE__ */ new Map(), []);
17
- return /* @__PURE__ */ jsx(PageRegistryContext.Provider, {
18
- value: registry,
19
- children
20
- });
21
- };
22
- /**
23
- * Access the page registry (used internally by Router and Page).
24
- */
25
- const usePageRegistry = () => useContext(PageRegistryContext);
26
- /**
27
- * Register a page in the registry (used internally by Page component).
28
- */
29
- const useRegisterPage = (name, component) => {
30
- const registry = usePageRegistry();
31
- React.useEffect(() => {
32
- registry.set(name, component);
33
- return () => {
34
- registry.delete(name);
35
- };
36
- }, [
37
- name,
38
- component,
39
- registry
40
- ]);
41
- };
42
-
43
- //#endregion
44
- export { PageRegistryProvider, usePageRegistry, useRegisterPage };
45
- //# sourceMappingURL=page-registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"page-registry.js","names":["PageRegistryProvider: React.FC<{ children: React.ReactNode }>"],"sources":["../../src/primitives/page-registry.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\";\n\ntype PageComponent<P = unknown> = React.ComponentType<{ params?: P }>;\n\ntype PageRegistry = Map<string, PageComponent>;\n\nconst PageRegistryContext = createContext<PageRegistry>(new Map());\n\n/**\n * Context provider for declarative page registration.\n *\n * @example\n * <PageRegistryProvider>\n * <Page name=\"HOME\" component={HomePage} />\n * <Router page={currentPage} />\n * </PageRegistryProvider>\n */\nexport const PageRegistryProvider: React.FC<{ children: React.ReactNode }> = ({\n\tchildren,\n}) => {\n\tconst registry = useMemo(() => new Map<string, PageComponent>(), []);\n\n\treturn (\n\t\t<PageRegistryContext.Provider value={registry}>\n\t\t\t{children}\n\t\t</PageRegistryContext.Provider>\n\t);\n};\n\n/**\n * Access the page registry (used internally by Router and Page).\n */\nexport const usePageRegistry = () => useContext(PageRegistryContext);\n\n/**\n * Register a page in the registry (used internally by Page component).\n */\nexport const useRegisterPage = (name: string, component: PageComponent) => {\n\tconst registry = usePageRegistry();\n\n\tReact.useEffect(() => {\n\t\tregistry.set(name, component);\n\t\treturn () => {\n\t\t\tregistry.delete(name);\n\t\t};\n\t}, [name, component, registry]);\n};\n"],"mappings":";;;;AAMA,MAAM,sBAAsB,8BAA4B,IAAI,KAAK,CAAC;;;;;;;;;;AAWlE,MAAaA,wBAAiE,EAC7E,eACK;CACL,MAAM,WAAW,8BAAc,IAAI,KAA4B,EAAE,EAAE,CAAC;AAEpE,QACC,oBAAC,oBAAoB;EAAS,OAAO;EACnC;GAC6B;;;;;AAOjC,MAAa,wBAAwB,WAAW,oBAAoB;;;;AAKpE,MAAa,mBAAmB,MAAc,cAA6B;CAC1E,MAAM,WAAW,iBAAiB;AAElC,OAAM,gBAAgB;AACrB,WAAS,IAAI,MAAM,UAAU;AAC7B,eAAa;AACZ,YAAS,OAAO,KAAK;;IAEpB;EAAC;EAAM;EAAW;EAAS,CAAC"}
@@ -1,21 +0,0 @@
1
- //#region src/primitives/page.d.ts
2
- type PageProps<Params = unknown> = {
3
- name: string;
4
- component: React.ComponentType<{
5
- params?: Params;
6
- }>;
7
- };
8
- /**
9
- * Declaratively register a page component.
10
- *
11
- * @example
12
- * <Page name="HOME" component={HomePage} />
13
- * <Page name="SETTINGS" component={SettingsPage} />
14
- */
15
- declare function Page<Params = unknown>({
16
- name,
17
- component
18
- }: PageProps<Params>): null;
19
- //#endregion
20
- export { Page, PageProps };
21
- //# sourceMappingURL=page.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"page.d.ts","names":[],"sources":["../../src/primitives/page.tsx"],"sourcesContent":[],"mappings":";KAEY;EAAA,IAAA,EAAA,MAAS;EAYL,SAAI,EAVR,KAAA,CAAM,aAUE,CAAA;IACnB,MAAA,CAAA,EAX0C,MAW1C;EACA,CAAA,CAAA;CACY;;;;;;;;iBAHG;;;GAGb,UAAU"}
@@ -1,18 +0,0 @@
1
- import { useRegisterPage } from "./page-registry.js";
2
-
3
- //#region src/primitives/page.tsx
4
- /**
5
- * Declaratively register a page component.
6
- *
7
- * @example
8
- * <Page name="HOME" component={HomePage} />
9
- * <Page name="SETTINGS" component={SettingsPage} />
10
- */
11
- function Page({ name, component }) {
12
- useRegisterPage(name, component);
13
- return null;
14
- }
15
-
16
- //#endregion
17
- export { Page };
18
- //# sourceMappingURL=page.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"page.js","names":[],"sources":["../../src/primitives/page.tsx"],"sourcesContent":["import { useRegisterPage } from \"./page-registry\";\n\nexport type PageProps<Params = unknown> = {\n\tname: string;\n\tcomponent: React.ComponentType<{ params?: Params }>;\n};\n\n/**\n * Declaratively register a page component.\n *\n * @example\n * <Page name=\"HOME\" component={HomePage} />\n * <Page name=\"SETTINGS\" component={SettingsPage} />\n */\nexport function Page<Params = unknown>({\n\tname,\n\tcomponent,\n}: PageProps<Params>): null {\n\tuseRegisterPage(name, component as React.ComponentType<{ params?: unknown }>);\n\treturn null;\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAgB,KAAuB,EACtC,MACA,aAC2B;AAC3B,iBAAgB,MAAM,UAAuD;AAC7E,QAAO"}