@arbidocs/blocks 0.4.130 → 0.4.131

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 (154) hide show
  1. package/README.md +3 -4
  2. package/dist/agents/index.cjs +304 -304
  3. package/dist/agents/index.js +12 -12
  4. package/dist/calls/index.cjs +3 -3
  5. package/dist/calls/index.js +2 -2
  6. package/dist/chat/index.cjs +144 -144
  7. package/dist/chat/index.js +5 -5
  8. package/dist/chat/open-document.d.ts +1 -5
  9. package/dist/{chunk-SZX44LCT.js → chunk-26E6PHD2.js} +3 -3
  10. package/dist/{chunk-SZX44LCT.js.map → chunk-26E6PHD2.js.map} +1 -1
  11. package/dist/{chunk-2PNNCEPH.js → chunk-54ANPPMV.js} +4 -4
  12. package/dist/{chunk-2PNNCEPH.js.map → chunk-54ANPPMV.js.map} +1 -1
  13. package/dist/{chunk-FUTMU4FR.js → chunk-5HFPRI3W.js} +3 -3
  14. package/dist/{chunk-FUTMU4FR.js.map → chunk-5HFPRI3W.js.map} +1 -1
  15. package/dist/chunk-76JDDMSP.js +31 -0
  16. package/dist/chunk-76JDDMSP.js.map +1 -0
  17. package/dist/{chunk-4RLCRFZS.js → chunk-7D4W3SAH.js} +12 -15
  18. package/dist/chunk-7D4W3SAH.js.map +1 -0
  19. package/dist/{chunk-2DFDFOM7.js → chunk-7HAM7Y5U.js} +3 -3
  20. package/dist/{chunk-2DFDFOM7.js.map → chunk-7HAM7Y5U.js.map} +1 -1
  21. package/dist/{chunk-4QIIDXLF.cjs → chunk-7KH4M3KY.cjs} +10 -10
  22. package/dist/{chunk-4QIIDXLF.cjs.map → chunk-7KH4M3KY.cjs.map} +1 -1
  23. package/dist/{chunk-TP6PLDNM.cjs → chunk-7QDX2CO4.cjs} +4 -4
  24. package/dist/{chunk-TP6PLDNM.cjs.map → chunk-7QDX2CO4.cjs.map} +1 -1
  25. package/dist/{chunk-RI6DZA5X.js → chunk-A2YAC22G.js} +3 -3
  26. package/dist/{chunk-RI6DZA5X.js.map → chunk-A2YAC22G.js.map} +1 -1
  27. package/dist/{chunk-4S5IDT5F.cjs → chunk-BZF55UCE.cjs} +5 -5
  28. package/dist/{chunk-4S5IDT5F.cjs.map → chunk-BZF55UCE.cjs.map} +1 -1
  29. package/dist/chunk-C54XEN5T.cjs +34 -0
  30. package/dist/chunk-C54XEN5T.cjs.map +1 -0
  31. package/dist/{chunk-GZPTWHP5.cjs → chunk-CDZVC32G.cjs} +10 -22
  32. package/dist/chunk-CDZVC32G.cjs.map +1 -0
  33. package/dist/{chunk-PUCY3UXN.js → chunk-CXLVI3SB.js} +3 -3
  34. package/dist/{chunk-PUCY3UXN.js.map → chunk-CXLVI3SB.js.map} +1 -1
  35. package/dist/{chunk-W3VYZXNS.js → chunk-D3N67Q4D.js} +3 -3
  36. package/dist/{chunk-W3VYZXNS.js.map → chunk-D3N67Q4D.js.map} +1 -1
  37. package/dist/{chunk-KYDRUFWT.cjs → chunk-D4YR56FV.cjs} +5 -5
  38. package/dist/{chunk-KYDRUFWT.cjs.map → chunk-D4YR56FV.cjs.map} +1 -1
  39. package/dist/{chunk-QYTYW74G.js → chunk-DI35D756.js} +5 -5
  40. package/dist/{chunk-QYTYW74G.js.map → chunk-DI35D756.js.map} +1 -1
  41. package/dist/{chunk-OPTBQSCV.cjs → chunk-DJM7DLCT.cjs} +3 -3
  42. package/dist/{chunk-OPTBQSCV.cjs.map → chunk-DJM7DLCT.cjs.map} +1 -1
  43. package/dist/{chunk-2Q7FDZAY.js → chunk-DQCYCEDR.js} +3 -3
  44. package/dist/{chunk-2Q7FDZAY.js.map → chunk-DQCYCEDR.js.map} +1 -1
  45. package/dist/{chunk-VHJHY7TT.js → chunk-ECERC6TI.js} +3 -3
  46. package/dist/{chunk-VHJHY7TT.js.map → chunk-ECERC6TI.js.map} +1 -1
  47. package/dist/{chunk-OQ7RUNOC.js → chunk-GFYGYME3.js} +3 -3
  48. package/dist/{chunk-OQ7RUNOC.js.map → chunk-GFYGYME3.js.map} +1 -1
  49. package/dist/{chunk-YBLIKTJK.js → chunk-GYCQ3FNL.js} +2 -2
  50. package/dist/chunk-GYCQ3FNL.js.map +1 -0
  51. package/dist/{chunk-6AALMYPS.cjs → chunk-HM23LXUP.cjs} +3 -3
  52. package/dist/{chunk-6AALMYPS.cjs.map → chunk-HM23LXUP.cjs.map} +1 -1
  53. package/dist/{chunk-WXYQ66KC.cjs → chunk-JK45LSIH.cjs} +5 -5
  54. package/dist/{chunk-WXYQ66KC.cjs.map → chunk-JK45LSIH.cjs.map} +1 -1
  55. package/dist/{chunk-UMIY4SQS.js → chunk-KLOSOT26.js} +11 -11
  56. package/dist/{chunk-UMIY4SQS.js.map → chunk-KLOSOT26.js.map} +1 -1
  57. package/dist/{chunk-SARREDFP.cjs → chunk-LC2KJSUS.cjs} +46 -46
  58. package/dist/{chunk-SARREDFP.cjs.map → chunk-LC2KJSUS.cjs.map} +1 -1
  59. package/dist/{chunk-ARDHLU73.cjs → chunk-LRD7BHAT.cjs} +10 -13
  60. package/dist/chunk-LRD7BHAT.cjs.map +1 -0
  61. package/dist/{chunk-R26BK7YL.cjs → chunk-OB5F4577.cjs} +4 -4
  62. package/dist/{chunk-R26BK7YL.cjs.map → chunk-OB5F4577.cjs.map} +1 -1
  63. package/dist/{chunk-AAFX64WD.cjs → chunk-OR4CO743.cjs} +3 -3
  64. package/dist/{chunk-AAFX64WD.cjs.map → chunk-OR4CO743.cjs.map} +1 -1
  65. package/dist/{chunk-HFGXA5CL.cjs → chunk-OUW6G4O2.cjs} +4 -4
  66. package/dist/{chunk-HFGXA5CL.cjs.map → chunk-OUW6G4O2.cjs.map} +1 -1
  67. package/dist/{chunk-4UMXQPNA.js → chunk-P5HOXWYL.js} +8 -20
  68. package/dist/chunk-P5HOXWYL.js.map +1 -0
  69. package/dist/{chunk-GDBDHOI4.js → chunk-P5ST47VY.js} +3 -3
  70. package/dist/{chunk-GDBDHOI4.js.map → chunk-P5ST47VY.js.map} +1 -1
  71. package/dist/{chunk-OGBXV326.cjs → chunk-S6BOINC4.cjs} +7 -7
  72. package/dist/{chunk-OGBXV326.cjs.map → chunk-S6BOINC4.cjs.map} +1 -1
  73. package/dist/{chunk-444XKG46.js → chunk-S7PSMMRG.js} +3 -3
  74. package/dist/{chunk-444XKG46.js.map → chunk-S7PSMMRG.js.map} +1 -1
  75. package/dist/{chunk-JKB7WT7L.cjs → chunk-SWQX6CTT.cjs} +2 -2
  76. package/dist/chunk-SWQX6CTT.cjs.map +1 -0
  77. package/dist/{chunk-ENDP7JER.js → chunk-VW2C2AZL.js} +3 -3
  78. package/dist/{chunk-ENDP7JER.js.map → chunk-VW2C2AZL.js.map} +1 -1
  79. package/dist/{chunk-TT6XV6WM.cjs → chunk-W27VK32R.cjs} +84 -84
  80. package/dist/{chunk-TT6XV6WM.cjs.map → chunk-W27VK32R.cjs.map} +1 -1
  81. package/dist/{chunk-PJJY6CYL.cjs → chunk-WV4IDVDQ.cjs} +11 -11
  82. package/dist/{chunk-PJJY6CYL.cjs.map → chunk-WV4IDVDQ.cjs.map} +1 -1
  83. package/dist/{chunk-DWZXSPMB.cjs → chunk-ZAVEMQ37.cjs} +3 -3
  84. package/dist/{chunk-DWZXSPMB.cjs.map → chunk-ZAVEMQ37.cjs.map} +1 -1
  85. package/dist/{chunk-Y3KA6X7B.js → chunk-ZCF2JJFA.js} +3 -3
  86. package/dist/{chunk-Y3KA6X7B.js.map → chunk-ZCF2JJFA.js.map} +1 -1
  87. package/dist/{chunk-QDEODGXE.cjs → chunk-ZV3BKLFY.cjs} +5 -5
  88. package/dist/{chunk-QDEODGXE.cjs.map → chunk-ZV3BKLFY.cjs.map} +1 -1
  89. package/dist/citations/index.cjs +11 -12
  90. package/dist/citations/index.js +2 -3
  91. package/dist/collaboration/index.cjs +51 -51
  92. package/dist/collaboration/index.js +3 -3
  93. package/dist/connect/docx.cjs +5 -7
  94. package/dist/connect/docx.cjs.map +1 -1
  95. package/dist/connect/docx.js +4 -6
  96. package/dist/connect/docx.js.map +1 -1
  97. package/dist/connect/index.cjs +155 -161
  98. package/dist/connect/index.cjs.map +1 -1
  99. package/dist/connect/index.d.ts +1 -1
  100. package/dist/connect/index.js +78 -85
  101. package/dist/connect/index.js.map +1 -1
  102. package/dist/connection/ConnectedSettings.d.ts +17 -8
  103. package/dist/connection/ConnectionProvider.d.ts +0 -5
  104. package/dist/connection/mail/ConnectedMailComposer.d.ts +3 -2
  105. package/dist/connection/mail/ConnectedMailbox.d.ts +3 -2
  106. package/dist/connection/mail/MailComposerForm.d.ts +3 -2
  107. package/dist/connection/mail/index.d.ts +2 -2
  108. package/dist/connection/mail/mailbox.d.ts +4 -1
  109. package/dist/connection/mail/types.d.ts +8 -0
  110. package/dist/document-tools/index.cjs +1 -1
  111. package/dist/document-tools/index.js +1 -1
  112. package/dist/facts/index.cjs +4 -5
  113. package/dist/facts/index.cjs.map +1 -1
  114. package/dist/facts/index.js +3 -4
  115. package/dist/facts/index.js.map +1 -1
  116. package/dist/files/index.cjs +4 -4
  117. package/dist/files/index.js +3 -3
  118. package/dist/home/index.cjs +19 -20
  119. package/dist/home/index.cjs.map +1 -1
  120. package/dist/home/index.js +4 -5
  121. package/dist/home/index.js.map +1 -1
  122. package/dist/index.cjs +679 -679
  123. package/dist/index.d.ts +1 -2
  124. package/dist/index.js +24 -24
  125. package/dist/provider/BlocksProvider.d.ts +4 -39
  126. package/dist/retrieval/index.cjs +4 -5
  127. package/dist/retrieval/index.js +2 -3
  128. package/dist/settings/index.cjs +47 -47
  129. package/dist/settings/index.js +5 -5
  130. package/dist/shell/index.cjs +47 -48
  131. package/dist/shell/index.js +3 -4
  132. package/dist/site/index.cjs +5 -5
  133. package/dist/site/index.js +1 -1
  134. package/dist/studio/index.cjs +18 -19
  135. package/dist/studio/index.cjs.map +1 -1
  136. package/dist/studio/index.js +10 -11
  137. package/dist/studio/index.js.map +1 -1
  138. package/dist/workflow-canvas/index.cjs +65 -65
  139. package/dist/workflow-canvas/index.js +13 -13
  140. package/dist/workspaces/index.cjs +3 -3
  141. package/dist/workspaces/index.js +2 -2
  142. package/node_modules/@arbidocs/coedit/package.json +1 -1
  143. package/package.json +4 -4
  144. package/dist/chunk-4RLCRFZS.js.map +0 -1
  145. package/dist/chunk-4UMXQPNA.js.map +0 -1
  146. package/dist/chunk-ARDHLU73.cjs.map +0 -1
  147. package/dist/chunk-C4WSHRR6.cjs +0 -166
  148. package/dist/chunk-C4WSHRR6.cjs.map +0 -1
  149. package/dist/chunk-GZPTWHP5.cjs.map +0 -1
  150. package/dist/chunk-JKB7WT7L.cjs.map +0 -1
  151. package/dist/chunk-YBLIKTJK.js.map +0 -1
  152. package/dist/chunk-YNIBUKV5.js +0 -163
  153. package/dist/chunk-YNIBUKV5.js.map +0 -1
  154. package/dist/provider/dialogs.d.ts +0 -31
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/connection/ConnectionProvider.tsx"],"names":["createContext","ArbiSessionStateProvider","jsx","useArbi","useArbiSessionStore","useState","useArbiSessionState","useRef","useEffect","useCallback","useMemo","AccountClientProvider","arbiAccountClient","toProfileView","useContext"],"mappings":";;;;;;;AAsEA,IAAM,iBAAA,GAAoBA,oBAAsC,IAAI,CAAA;AAQpE,IAAM,wBAAA,GAA2B,wBAAA;AACjC,IAAM,cAAA,GAAiB,CAAC,MAAA,KAAmB,CAAA,iBAAA,EAAoB,MAAM,CAAA,CAAA;AACrE,SAAS,mBAAA,CAAoB,QAAgB,KAAA,EAAsB;AACjE,EAAA,IAAI;AACF,IAAA,IAAI,KAAA,SAAc,YAAA,CAAa,OAAA,CAAQ,eAAe,MAAM,CAAA,EAAG,gBAAA,CAAiB,KAAK,CAAC,CAAA;AAAA,SACjF,MAAA,CAAO,YAAA,CAAa,UAAA,CAAW,cAAA,CAAe,MAAM,CAAC,CAAA;AAAA,EAC5D,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AACA,IAAM,mBAAmB,CAAC,KAAA,KAAkB,KAAA,CAAM,IAAA,GAAO,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AAA,SAAE;AACA,UAAA,SAAA,CAAU,OAAA,EAAQ;AAAA,QACpB;AAAA,MACF;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AACX;AAEO,SAAS,aAAA,GAAiC;AAC/C,EAAA,MAAM,GAAA,GAAMC,iBAAW,iBAAiB,CAAA;AACxC,EAAA,IAAI,CAAC,GAAA,EAAK,MAAM,IAAI,MAAM,sDAAsD,CAAA;AAChF,EAAA,OAAO,GAAA;AACT;AAEO,IAAM,eAAA,GAAkB,CAAC,CAAA,KAAwB,CAAA,KAAM,UAAU,CAAA,KAAM","file":"chunk-ARDHLU73.cjs","sourcesContent":["/**\n * The demo/live connection layer for a host app. Holds auth + workspace\n * selection state and exposes it via {@link useConnection}, so every surface\n * works identically whether it's talking to a live ARBI backend or the seeded\n * demo workspace. Host-specific values (backend URL, demo identity, default\n * workspace/assistant ids) arrive once through {@link ArbiConnectionConfig}.\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react'\nimport {\n AccountClientProvider,\n ArbiSessionStateProvider,\n arbiAccountClient,\n toProfileView,\n useArbi,\n useArbiSessionState,\n useArbiSessionStore,\n type AccountClient,\n type LoginProfile,\n type ProfileView,\n} from '@arbidocs/react'\nimport type { ArbiMode, ArbiUser, ConnectionStatus, ArbiConnectionConfig } from './types'\n\ninterface ConnectionValue {\n mode: ArbiMode\n status: ConnectionStatus\n user: ArbiUser | null\n /** The selected workspace: the session state's (`useArbiSessionState`), set by `setWorkspace`. */\n workspaceId: string | null\n apiConfigured: boolean\n apiUrl: string\n /**\n * The deployment domain the user's keys are derived for (`arbi.getDeploymentDomain()`), for the\n * document tools' e-signing. `undefined` in demo mode.\n */\n deploymentDomain: string | undefined\n error: string | null\n /** Default assistant config ext_id (for the AI hooks). */\n assistantConfig?: string\n /** Fallback workspace ext_id when none is actively selected. */\n fallbackWorkspaceId?: string\n /** Authenticate. Live login when a backend is configured, otherwise the demo workspace. */\n login: (email: string, password: string) => Promise<void>\n /** One-click demo entry (no backend required). */\n enterDemo: () => void\n logout: () => void\n /**\n * Affirmatively select a workspace: opens it on the server (via the SDK),\n * updates the app-wide state, and persists the choice so it survives future\n * logins. This is the single entry point for \"the user is now in workspace X\".\n */\n setWorkspace: (id: string) => Promise<void>\n /**\n * Re-assert the selected workspace on the server session (idempotent `/open`).\n * Call before a workspace-scoped write when the session may have lost its open\n * workspace (token re-login, backend restart, session expiry) — the server\n * resolves the workspace from the session, so a dropped `/open` yields\n * \"No active workspace\" until it's re-opened.\n */\n ensureWorkspaceOpen: () => Promise<void>\n}\n\nconst ConnectionContext = createContext<ConnectionValue | null>(null)\n\n/**\n * Persist the affirmatively-selected workspace per backend AND per signed-in user, so a returning\n * user lands back in the workspace they last chose, while the next person on a shared browser\n * never starts from someone else's workspace id. Namespaced by apiUrl so distinct deployments\n * (and the demo workspace) don't clobber each other. Cleared on logout.\n */\nconst WORKSPACE_STORAGE_PREFIX = 'arbi:selectedWorkspace'\nconst sessionUserKey = (apiUrl: string) => `arbi:sessionUser:${apiUrl}`\nfunction rememberSessionUser(apiUrl: string, email: string | null) {\n try {\n if (email) window.localStorage.setItem(sessionUserKey(apiUrl), normalizeUserKey(email))\n else window.localStorage.removeItem(sessionUserKey(apiUrl))\n } catch {\n /* Storage may be unavailable. */\n }\n}\nconst normalizeUserKey = (email: string) => email.trim().toLowerCase()\n\n/** Exported for tests. */\nexport const workspaceStorageKey = (apiUrl: string, userKey: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}:${normalizeUserKey(userKey)}`\n\n/** The pre-isolation key (apiUrl only). Never read: removed so it cannot leak across users. */\nconst legacyWorkspaceStorageKey = (apiUrl: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}`\n\nfunction readPersistedWorkspace(apiUrl: string, userKey: string | null): string | null {\n if (!userKey) return null\n try {\n return window.localStorage.getItem(workspaceStorageKey(apiUrl, userKey))\n } catch {\n return null\n }\n}\n\nfunction persistWorkspace(apiUrl: string, userKey: string | null, id: string | null): void {\n if (!userKey) return\n try {\n if (id) window.localStorage.setItem(workspaceStorageKey(apiUrl, userKey), id)\n else window.localStorage.removeItem(workspaceStorageKey(apiUrl, userKey))\n window.localStorage.removeItem(legacyWorkspaceStorageKey(apiUrl))\n } catch {\n // Storage unavailable (private mode, SSR) — selection stays in-memory only.\n }\n}\n\n/** Shown on the sign-in screen after the session could not be recovered. */\nexport const SESSION_EXPIRED_MESSAGE = 'Your session expired. Sign in again.'\n\n/** The connection user for a profile: its full name, falling back to the email local part. */\nfunction userFromProfile(profile: LoginProfile, externalId?: string): ArbiUser {\n const fullName = [profile.givenName, profile.familyName]\n .map((part) => part?.trim())\n .filter(Boolean)\n .join(' ')\n return {\n name: fullName || profile.email.split('@')[0],\n email: profile.email,\n externalId,\n picture: profile.picture,\n }\n}\n\n/**\n * The connection, over the session state of the host (an `ArbiSessionStateProvider` above), else\n * its own: the selected workspace lives there, so every block reads one value.\n */\nexport function ConnectionProvider({\n config,\n children,\n}: {\n config: ArbiConnectionConfig\n children: ReactNode\n}) {\n return (\n <ArbiSessionStateProvider>\n <SessionConnectionProvider config={config}>{children}</SessionConnectionProvider>\n </ArbiSessionStateProvider>\n )\n}\n\nfunction SessionConnectionProvider({\n config,\n children,\n}: {\n config: ArbiConnectionConfig\n children: ReactNode\n}) {\n const arbi = useArbi()\n const session = useArbiSessionStore()\n const isLiveConfigured = config.apiUrl.length > 0\n const demoWorkspaceId = config.demoWorkspaceId ?? 'demo-workspace'\n\n const [status, setStatus] = useState<ConnectionStatus>(\n isLiveConfigured ? 'connecting' : 'disconnected'\n )\n const [user, setUser] = useState<ArbiUser | null>(null)\n const workspaceId = useArbiSessionState((s) => s.workspaceId)\n const selectWorkspaceId = session.setWorkspaceId\n const [mode, setMode] = useState<ArbiMode>('demo')\n const [error, setError] = useState<string | null>(null)\n // Who the persisted workspace belongs to; set at sign-in, cleared at logout.\n const storageUserRef = useRef<string | null>(null)\n\n // The SDK could not recover the session (token refused, workspace not re-openable): drop to\n // 'disconnected' with a plain message, so the host's gate sends the user to sign in instead of\n // every call failing with a raw backend error. The remembered workspace is kept for next login.\n useEffect(\n () =>\n arbi.onSessionExpired?.(() => {\n rememberSessionUser(config.apiUrl, null)\n storageUserRef.current = null\n setUser(null)\n selectWorkspaceId(null)\n setStatus('disconnected')\n setError(SESSION_EXPIRED_MESSAGE)\n }),\n [arbi, config.apiUrl, selectWorkspaceId]\n )\n\n // A saved name, picture or email reaches every surface reading `useConnection().user`.\n useEffect(\n () =>\n arbi.user.onProfileChange?.((profile) =>\n setUser((current) => (current ? userFromProfile(profile, current.externalId) : current))\n ),\n [arbi]\n )\n\n const enterDemo = useCallback(() => {\n setMode('demo')\n setStatus('demo')\n setError(null)\n setUser({ name: config.demoUser.name, email: config.demoUser.email })\n selectWorkspaceId(demoWorkspaceId)\n }, [config.demoUser.name, config.demoUser.email, demoWorkspaceId, selectWorkspaceId])\n\n const login = useCallback(\n async (email: string, password: string, restoring = false) => {\n setError(null)\n // No backend configured → run the seeded demo workspace.\n if (!isLiveConfigured) {\n enterDemo()\n return\n }\n setStatus('connecting')\n setMode('live')\n try {\n if (restoring) {\n if (!(await arbi.restoreSession(email))) {\n rememberSessionUser(config.apiUrl, null)\n setStatus('disconnected')\n return\n }\n } else await arbi.login(email, password)\n storageUserRef.current = normalizeUserKey(email)\n const workspaces = await arbi.workspaces.list()\n if (workspaces?.length) {\n // Prefer the workspace the user last affirmatively selected (persisted),\n // then the configured workspace (there may be several — e.g. a\n // marketing/KM workspace), then whichever happens to be first. Ternary\n // (not `&&`) so an empty value can't leak `\"\"` into `target`.\n const persisted = readPersistedWorkspace(config.apiUrl, storageUserRef.current)\n const preferred = persisted ?? config.workspaceId\n const target =\n (preferred ? workspaces.find((w) => w.external_id === preferred) : undefined) ??\n workspaces[0]\n await arbi.selectWorkspace(target.external_id)\n selectWorkspaceId(target.external_id)\n persistWorkspace(config.apiUrl, storageUserRef.current, target.external_id)\n }\n // The profile (name + avatar) comes with the login response. A session restored without\n // a login has none, so fall back to finding ourselves in the workspace roster; the email\n // local part is only the last resort, never the answer when a profile name exists.\n let resolved: ArbiUser = { name: email.split('@')[0], email }\n const me = arbi.user.identity()\n const profile = arbi.user.profile?.()\n if (profile) {\n resolved = userFromProfile(profile, me?.externalId)\n } else {\n try {\n const members = await arbi.workspaces.listUsers()\n const self = members.find((m) => m.user.external_id === me?.externalId)?.user\n if (self) {\n const fullName = [self.given_name, self.family_name].filter(Boolean).join(' ').trim()\n resolved = {\n name: fullName || email.split('@')[0],\n email: self.email || email,\n externalId: self.external_id,\n picture: self.picture ?? null,\n }\n } else if (me?.externalId) {\n resolved.externalId = me.externalId\n }\n } catch {\n // Roster not available (e.g. no workspace) — keep the fallback identity.\n }\n }\n setUser(resolved)\n rememberSessionUser(config.apiUrl, email)\n setStatus('authenticated')\n } catch (e) {\n // Surface the real error — no silent fallback to a fake session.\n setError(e instanceof Error ? e.message : 'Sign-in failed. Check your credentials.')\n setStatus('error')\n }\n },\n [arbi, enterDemo, isLiveConfigured, config.workspaceId, config.apiUrl, selectWorkspaceId]\n )\n\n // Run once even under StrictMode; passwords and signing keys are never stored here.\n const recoveryStarted = useRef(false)\n useEffect(() => {\n if (recoveryStarted.current || !isLiveConfigured) return\n recoveryStarted.current = true\n let email: string | null = null\n try {\n email = window.localStorage.getItem(sessionUserKey(config.apiUrl))\n } catch {\n /* unavailable */\n }\n if (email) void login(email, '', true)\n else setStatus('disconnected')\n }, [isLiveConfigured, config.apiUrl, login])\n\n const logout = useCallback(() => {\n rememberSessionUser(config.apiUrl, null)\n if (mode === 'live') {\n void arbi.logout?.()\n }\n setUser(null)\n selectWorkspaceId(null)\n persistWorkspace(config.apiUrl, storageUserRef.current, null)\n storageUserRef.current = null\n setStatus('disconnected')\n setError(null)\n }, [arbi, mode, config.apiUrl, selectWorkspaceId])\n\n // Affirmative selection: open the workspace on the server (live), then remember\n // it in state + storage so every surface — and the next login — is in sync.\n const setWorkspace = useCallback(\n async (id: string) => {\n if (mode === 'live' && arbi.isLoggedIn) {\n await arbi.selectWorkspace(id)\n }\n selectWorkspaceId(id)\n persistWorkspace(config.apiUrl, storageUserRef.current, id)\n },\n [arbi, mode, config.apiUrl, selectWorkspaceId]\n )\n\n // Re-open the selected workspace on the session if the server may have dropped\n // it. Idempotent: re-running `/open` for the already-selected workspace is safe.\n const ensureWorkspaceOpen = useCallback(async () => {\n if (mode !== 'live' || !arbi.isLoggedIn) return\n // The selected workspace as of now, not as of the last render: a flow that switches workspace\n // and then re-opens it in the same async chain (a step that creates a matter, then starts its\n // thread) must not re-open the one it just left.\n const id =\n session.getState().workspaceId ??\n readPersistedWorkspace(config.apiUrl, storageUserRef.current) ??\n config.workspaceId\n if (id) await arbi.selectWorkspace(id)\n }, [arbi, session, mode, config.apiUrl, config.workspaceId])\n\n const value = useMemo<ConnectionValue>(\n () => ({\n mode,\n status,\n user,\n workspaceId,\n apiConfigured: isLiveConfigured,\n apiUrl: config.apiUrl,\n deploymentDomain: isLiveConfigured ? arbi.getDeploymentDomain() : undefined,\n error,\n assistantConfig: config.assistantConfig,\n fallbackWorkspaceId: config.workspaceId,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n }),\n [\n mode,\n status,\n user,\n workspaceId,\n isLiveConfigured,\n config.apiUrl,\n arbi,\n config.assistantConfig,\n config.workspaceId,\n error,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n ]\n )\n\n const account = useConnectionAccount(arbi, user, logout)\n\n return (\n <ConnectionContext.Provider value={value}>\n <AccountClientProvider client={account} enabled={status === 'authenticated'}>\n {children}\n </AccountClientProvider>\n </ConnectionContext.Provider>\n )\n}\n\n/**\n * The account client of the settings blocks below: the SDK's, with sign-out going through this\n * connection (so its state is cleared too) and, for a session restored without a login (no SDK\n * profile), the connection user as the profile.\n */\nfunction useConnectionAccount(\n arbi: ReturnType<typeof useArbi>,\n user: ArbiUser | null,\n logout: () => void\n): AccountClient {\n const userRef = useRef(user)\n const logoutRef = useRef(logout)\n logoutRef.current = logout\n const listeners = useRef(new Set<() => void>())\n useEffect(() => {\n userRef.current = user\n listeners.current.forEach((listener) => listener())\n }, [user])\n return useMemo(() => {\n const base = arbiAccountClient(arbi)\n return {\n ...base,\n profile: (): ProfileView | null => {\n const own = base.profile()\n const fallback = userRef.current\n if (own || !fallback) return own\n return {\n ...toProfileView({\n givenName: '',\n familyName: null,\n picture: fallback.picture ?? null,\n email: fallback.email,\n isSso: false,\n }),\n fullName: fallback.name,\n }\n },\n onProfileChange: (listener) => {\n listeners.current.add(listener)\n const off = base.onProfileChange(listener)\n return () => {\n listeners.current.delete(listener)\n off()\n }\n },\n signOut: async ({ everywhere } = {}) => {\n try {\n if (everywhere) await arbi.sessions.logoutAll()\n } finally {\n logoutRef.current()\n }\n },\n }\n }, [arbi])\n}\n\nexport function useConnection(): ConnectionValue {\n const ctx = useContext(ConnectionContext)\n if (!ctx) throw new Error('useConnection must be used within ConnectionProvider')\n return ctx\n}\n\nexport const isAuthenticated = (s: ConnectionStatus) => s === 'demo' || s === 'authenticated'\n"]}
@@ -1,166 +0,0 @@
1
- "use client";
2
- 'use strict';
3
-
4
- var chunkULWRNGGE_cjs = require('./chunk-ULWRNGGE.cjs');
5
- var react = require('react');
6
- var lucideReact = require('lucide-react');
7
- var ui = require('@arbidocs/react/ui');
8
- var jsxRuntime = require('react/jsx-runtime');
9
- var shell = require('@arbidocs/react/shell');
10
-
11
- var UNMOUNT_DELAY_MS = 300;
12
- function PromptDialog({
13
- request,
14
- onSettle
15
- }) {
16
- const [open, setOpen] = react.useState(true);
17
- const { message, title = "Confirm", choices, icon = "alert", testId = "choice-modal" } = request;
18
- const settle = (value) => {
19
- setOpen(false);
20
- onSettle(value);
21
- };
22
- return /* @__PURE__ */ jsxRuntime.jsx(
23
- chunkULWRNGGE_cjs.ModalScaffold,
24
- {
25
- open,
26
- onOpenChange: (next) => {
27
- if (!next) settle(null);
28
- },
29
- title,
30
- icon: icon === "info" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: "h-5 w-5 text-blue-text", "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-5 w-5", "aria-hidden": "true" }),
31
- description: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "whitespace-pre-line", children: message }),
32
- showDescription: true,
33
- testId,
34
- children: /* @__PURE__ */ jsxRuntime.jsx(chunkULWRNGGE_cjs.ModalScaffold.Footer, { children: choices.map((choice) => /* @__PURE__ */ jsxRuntime.jsx(
35
- ui.Button,
36
- {
37
- variant: choice.variant ?? "default",
38
- onClick: () => settle(choice.value),
39
- "data-testid": `${testId}-${choice.value.toLowerCase()}-button`,
40
- children: choice.label
41
- },
42
- choice.value
43
- )) })
44
- }
45
- );
46
- }
47
- function choiceDialog(request) {
48
- if (typeof document === "undefined") return Promise.resolve(null);
49
- return new Promise((resolve) => {
50
- const container = document.createElement("div");
51
- document.body.appendChild(container);
52
- let settled = false;
53
- void import('react-dom/client').then(({ createRoot }) => {
54
- const root = createRoot(container);
55
- const onSettle = (value) => {
56
- if (settled) return;
57
- settled = true;
58
- resolve(value);
59
- setTimeout(() => {
60
- root.unmount();
61
- container.remove();
62
- }, UNMOUNT_DELAY_MS);
63
- };
64
- root.render(/* @__PURE__ */ jsxRuntime.jsx(PromptDialog, { request, onSettle }));
65
- });
66
- });
67
- }
68
- var CONFIRM_CHOICES = {
69
- confirm: [
70
- { label: "Cancel", value: "cancel", variant: "outline" },
71
- { label: "Confirm", value: "confirm", variant: "destructive" }
72
- ],
73
- yesno: [
74
- { label: "No", value: "no", variant: "outline" },
75
- { label: "Yes", value: "yes" }
76
- ],
77
- alert: [{ label: "OK", value: "ok" }]
78
- };
79
- var CONFIRM_TEST_ID = {
80
- confirm: "confirmation-modal",
81
- yesno: "yes-no-modal",
82
- alert: "alert-modal"
83
- };
84
- async function confirmDialog(request) {
85
- const kind = request.kind ?? "confirm";
86
- const choice = await choiceDialog({
87
- message: request.message,
88
- title: request.title ?? (kind === "alert" ? "Alert" : "Confirm"),
89
- choices: CONFIRM_CHOICES[kind],
90
- icon: kind === "alert" ? "info" : "alert",
91
- testId: CONFIRM_TEST_ID[kind]
92
- });
93
- return choice === "confirm" || choice === "yes" || choice === "ok";
94
- }
95
- var noop = () => {
96
- };
97
- var defaultEnvironment = {
98
- navigate: (href) => {
99
- if (typeof window !== "undefined") window.location.assign(href);
100
- },
101
- notify: (message, kind = "info", options) => {
102
- shell.notify[kind](message, options);
103
- },
104
- confirm: confirmDialog,
105
- choose: choiceDialog,
106
- runtimeConfig: {
107
- apiBaseUrl: "",
108
- deploymentDomain: typeof window !== "undefined" ? window.location.host : ""
109
- },
110
- openDocument: noop,
111
- openConversation: noop,
112
- openSettings: noop,
113
- openProject: noop
114
- };
115
- var BlocksContext = react.createContext(defaultEnvironment);
116
- function BlocksProvider({
117
- children,
118
- linkComponent,
119
- navigate,
120
- notify,
121
- confirm,
122
- choose,
123
- runtimeConfig,
124
- openDocument,
125
- openConversation,
126
- openSettings,
127
- openProject
128
- }) {
129
- const parent = react.useContext(BlocksContext);
130
- const value = react.useMemo(
131
- () => ({
132
- linkComponent: linkComponent ?? parent.linkComponent,
133
- navigate: navigate ?? parent.navigate,
134
- notify: notify ?? parent.notify,
135
- confirm: confirm ?? parent.confirm,
136
- choose: choose ?? parent.choose,
137
- runtimeConfig: runtimeConfig ?? parent.runtimeConfig,
138
- openDocument: openDocument ?? parent.openDocument,
139
- openConversation: openConversation ?? parent.openConversation,
140
- openSettings: openSettings ?? parent.openSettings,
141
- openProject: openProject ?? parent.openProject
142
- }),
143
- [
144
- parent,
145
- linkComponent,
146
- navigate,
147
- notify,
148
- confirm,
149
- choose,
150
- runtimeConfig,
151
- openDocument,
152
- openConversation,
153
- openSettings,
154
- openProject
155
- ]
156
- );
157
- return /* @__PURE__ */ jsxRuntime.jsx(BlocksContext.Provider, { value, children });
158
- }
159
- function useBlocksEnvironment() {
160
- return react.useContext(BlocksContext);
161
- }
162
-
163
- exports.BlocksProvider = BlocksProvider;
164
- exports.useBlocksEnvironment = useBlocksEnvironment;
165
- //# sourceMappingURL=chunk-C4WSHRR6.cjs.map
166
- //# sourceMappingURL=chunk-C4WSHRR6.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/provider/dialogs.tsx","../src/provider/BlocksProvider.tsx"],"names":["useState","jsx","ModalScaffold","Info","AlertCircle","Button","notifyStore","createContext","useContext","useMemo"],"mappings":";;;;;;;;;AA6CA,IAAM,gBAAA,GAAmB,GAAA;AAEzB,SAAS,YAAA,CAA+B;AAAA,EACtC,OAAA;AAAA,EACA;AACF,CAAA,EAGiB;AACf,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAIA,eAAS,IAAI,CAAA;AACrC,EAAA,MAAM,EAAE,SAAS,KAAA,GAAQ,SAAA,EAAW,SAAS,IAAA,GAAO,OAAA,EAAS,MAAA,GAAS,cAAA,EAAe,GAAI,OAAA;AACzF,EAAA,MAAM,MAAA,GAAS,CAAC,KAAA,KAAoB;AAClC,IAAA,OAAA,CAAQ,KAAK,CAAA;AACb,IAAA,QAAA,CAAS,KAAK,CAAA;AAAA,EAChB,CAAA;AACA,EAAA,uBACEC,cAAA;AAAA,IAACC,+BAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,YAAA,EAAc,CAAC,IAAA,KAAS;AACtB,QAAA,IAAI,CAAC,IAAA,EAAM,MAAA,CAAO,IAAI,CAAA;AAAA,MACxB,CAAA;AAAA,MACA,KAAA;AAAA,MACA,IAAA,EACE,IAAA,KAAS,MAAA,mBACPD,cAAA,CAACE,oBAAK,SAAA,EAAU,wBAAA,EAAyB,aAAA,EAAY,MAAA,EAAO,oBAE5DF,cAAA,CAACG,uBAAA,EAAA,EAAY,SAAA,EAAU,SAAA,EAAU,eAAY,MAAA,EAAO,CAA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A,MAAM,KAAA,GAAQC,aAAA;AAAA,IACZ,OAAO;AAAA,MACL,aAAA,EAAe,iBAAiB,MAAA,CAAO,aAAA;AAAA,MACvC,QAAA,EAAU,YAAY,MAAA,CAAO,QAAA;AAAA,MAC7B,MAAA,EAAQ,UAAU,MAAA,CAAO,MAAA;AAAA,MACzB,OAAA,EAAS,WAAW,MAAA,CAAO,OAAA;AAAA,MAC3B,MAAA,EAAQ,UAAU,MAAA,CAAO,MAAA;AAAA,MACzB,aAAA,EAAe,iBAAiB,MAAA,CAAO,aAAA;AAAA,MACvC,YAAA,EAAc,gBAAgB,MAAA,CAAO,YAAA;AAAA,MACrC,gBAAA,EAAkB,oBAAoB,MAAA,CAAO,gBAAA;AAAA,MAC7C,YAAA,EAAc,gBAAgB,MAAA,CAAO,YAAA;AAAA,MACrC,WAAA,EAAa,eAAe,MAAA,CAAO;AAAA,KACrC,CAAA;AAAA,IACA;AAAA,MACE,MAAA;AAAA,MACA,aAAA;AAAA,MACA,QAAA;AAAA,MACA,MAAA;AAAA,MACA,OAAA;AAAA,MACA,MAAA;AAAA,MACA,aAAA;AAAA,MACA,YAAA;AAAA,MACA,gBAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA;AACF,GACF;AACA,EAAA,uBAAOR,cAAAA,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,OAAe,QAAA,EAAS,CAAA;AACzD;AAEO,SAAS,oBAAA,GAA0C;AACxD,EAAA,OAAOO,iBAAW,aAAa,CAAA;AACjC","file":"chunk-C4WSHRR6.cjs","sourcesContent":["/**\n * Promise-based prompt dialogs — the blocks replacement for `window.confirm` / `window.alert`.\n * Each call mounts its own short-lived React root, so it works from any event handler with no\n * dialog host in the tree. Hosts reach these through `useBlocksEnvironment().confirm` / `.choose`\n * (the defaults), which lets an app swap in its own dialogs without touching callers.\n *\n * For a confirmation with a loading state, render the declarative {@link ConfirmDialog} instead.\n */\nimport { useState, type ReactElement } from 'react'\nimport { AlertCircle, Info } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { ModalScaffold } from '../settings/ModalScaffold'\n\ntype ChoiceVariant = 'default' | 'destructive' | 'outline'\n\nexport interface PromptChoice<T extends string> {\n label: string\n value: T\n variant?: ChoiceVariant\n}\n\n/** A dialog offering arbitrary choices (e.g. Overwrite / Skip / Cancel). */\nexport interface ChoiceRequest<T extends string> {\n message: string\n title?: string\n choices: PromptChoice<T>[]\n icon?: 'alert' | 'info'\n /** Dialog test id; each button is `${testId}-${value}-button`. Default `choice-modal`. */\n testId?: string\n}\n\n/**\n * `confirm` — Cancel / Confirm (destructive); `yesno` — No / Yes; `alert` — a single OK\n * (resolves true once acknowledged).\n */\nexport type ConfirmKind = 'confirm' | 'yesno' | 'alert'\n\nexport interface ConfirmRequest {\n message: string\n /** Default: \"Alert\" for `alert`, else \"Confirm\". */\n title?: string\n kind?: ConfirmKind\n}\n\n/** Close animation length before the root is unmounted. */\nconst UNMOUNT_DELAY_MS = 300\n\nfunction PromptDialog<T extends string>({\n request,\n onSettle,\n}: {\n request: ChoiceRequest<T>\n onSettle: (value: T | null) => void\n}): ReactElement {\n const [open, setOpen] = useState(true)\n const { message, title = 'Confirm', choices, icon = 'alert', testId = 'choice-modal' } = request\n const settle = (value: T | null) => {\n setOpen(false)\n onSettle(value)\n }\n return (\n <ModalScaffold\n open={open}\n onOpenChange={(next) => {\n if (!next) settle(null)\n }}\n title={title}\n icon={\n icon === 'info' ? (\n <Info className=\"h-5 w-5 text-blue-text\" aria-hidden=\"true\" />\n ) : (\n <AlertCircle className=\"h-5 w-5\" aria-hidden=\"true\" />\n )\n }\n description={<span className=\"whitespace-pre-line\">{message}</span>}\n showDescription\n testId={testId}\n >\n <ModalScaffold.Footer>\n {choices.map((choice) => (\n <Button\n key={choice.value}\n variant={choice.variant ?? 'default'}\n onClick={() => settle(choice.value)}\n data-testid={`${testId}-${choice.value.toLowerCase()}-button`}\n >\n {choice.label}\n </Button>\n ))}\n </ModalScaffold.Footer>\n </ModalScaffold>\n )\n}\n\n/** Show a choice dialog; resolves with the chosen `value`, or `null` when dismissed. */\nexport function choiceDialog<T extends string>(request: ChoiceRequest<T>): Promise<T | null> {\n if (typeof document === 'undefined') return Promise.resolve(null)\n return new Promise((resolve) => {\n const container = document.createElement('div')\n document.body.appendChild(container)\n let settled = false\n void import('react-dom/client').then(({ createRoot }) => {\n const root = createRoot(container)\n const onSettle = (value: T | null) => {\n if (settled) return\n settled = true\n resolve(value)\n setTimeout(() => {\n root.unmount()\n container.remove()\n }, UNMOUNT_DELAY_MS)\n }\n root.render(<PromptDialog request={request} onSettle={onSettle} />)\n })\n })\n}\n\nconst CONFIRM_CHOICES: Record<\n ConfirmKind,\n PromptChoice<'confirm' | 'cancel' | 'yes' | 'no' | 'ok'>[]\n> = {\n confirm: [\n { label: 'Cancel', value: 'cancel', variant: 'outline' },\n { label: 'Confirm', value: 'confirm', variant: 'destructive' },\n ],\n yesno: [\n { label: 'No', value: 'no', variant: 'outline' },\n { label: 'Yes', value: 'yes' },\n ],\n alert: [{ label: 'OK', value: 'ok' }],\n}\n\nconst CONFIRM_TEST_ID: Record<ConfirmKind, string> = {\n confirm: 'confirmation-modal',\n yesno: 'yes-no-modal',\n alert: 'alert-modal',\n}\n\n/** Show a confirmation; resolves true on Confirm / Yes / OK, false on cancel or dismissal. */\nexport async function confirmDialog(request: ConfirmRequest): Promise<boolean> {\n const kind = request.kind ?? 'confirm'\n const choice = await choiceDialog({\n message: request.message,\n title: request.title ?? (kind === 'alert' ? 'Alert' : 'Confirm'),\n choices: CONFIRM_CHOICES[kind],\n icon: kind === 'alert' ? 'info' : 'alert',\n testId: CONFIRM_TEST_ID[kind],\n })\n return choice === 'confirm' || choice === 'yes' || choice === 'ok'\n}\n","import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport {\n notify as notifyStore,\n type NotifyOptions,\n type NotifyVariant,\n} from '@arbidocs/react/shell'\nimport type { BlockLinkComponent } from '../components/blockLink'\nimport { choiceDialog, confirmDialog, type ChoiceRequest, type ConfirmRequest } from './dialogs'\n\n/** What blocks need from the host's runtime configuration (the app's `config.json`). */\nexport interface BlocksRuntimeConfig {\n /** Origin of the ARBI API; `''` means the page's own origin. */\n apiBaseUrl: string\n /** The deployment's domain, e.g. `www.arbidocs.com` (deep links, key derivation, labels). */\n deploymentDomain: string\n}\n\nexport interface OpenDocumentOptions {\n /** 1-based page to scroll to. */\n page?: number\n /** Passage (chunk) to highlight. */\n passageId?: string\n}\n\n/**\n * The only way blocks reach the host app's environment. Blocks never import a router, a toast\n * library or an app store; the host injects what it has, and every field has a safe default so a\n * block renders correctly with no provider at all. A nested provider overrides only the fields\n * it is given and inherits the rest.\n */\nexport interface BlocksEnvironment {\n /** Router-aware link (keeps navigation in-SPA). Default: a plain `<a href>`. */\n linkComponent?: BlockLinkComponent\n /** Imperative navigation for buttons and keyboard shortcuts. Default: `window.location.assign`. */\n navigate: (href: string) => void\n /** Surface a transient message (and record it in the notification centre). Default: the shared\n * `@arbidocs/react` notify store, rendered by its `<Toaster/>`. */\n notify: (message: ReactNode, kind?: NotifyVariant, options?: NotifyOptions) => void\n /** Ask the user to confirm. Default: the blocks prompt dialog. */\n confirm: (request: ConfirmRequest) => Promise<boolean>\n /** Ask the user to pick one of several choices; `null` when dismissed. Default: the blocks\n * prompt dialog. */\n choose: <T extends string>(request: ChoiceRequest<T>) => Promise<T | null>\n /** Deployment configuration. Default: same-origin API on the page's own host. */\n runtimeConfig: BlocksRuntimeConfig\n /** Open a document (optionally at a page / passage) wherever the host shows documents.\n * Default: no-op. */\n openDocument: (documentId: string, options?: OpenDocumentOptions) => void\n /** Open a conversation thread, optionally scrolled to a message. Default: no-op. */\n openConversation: (conversationId: string, options?: { messageId?: string }) => void\n /** Open the user's settings, optionally at a section. Default: no-op. */\n openSettings: (section?: string) => void\n /** Open a project. Default: no-op. */\n openProject: (projectId: string) => void\n}\n\nconst noop = () => {}\n\nconst defaultEnvironment: BlocksEnvironment = {\n navigate: (href) => {\n if (typeof window !== 'undefined') window.location.assign(href)\n },\n notify: (message, kind = 'info', options) => {\n notifyStore[kind](message, options)\n },\n confirm: confirmDialog,\n choose: choiceDialog,\n runtimeConfig: {\n apiBaseUrl: '',\n deploymentDomain: typeof window !== 'undefined' ? window.location.host : '',\n },\n openDocument: noop,\n openConversation: noop,\n openSettings: noop,\n openProject: noop,\n}\n\nconst BlocksContext = createContext<BlocksEnvironment>(defaultEnvironment)\n\nexport interface BlocksProviderProps extends Partial<BlocksEnvironment> {\n children: ReactNode\n}\n\nexport function BlocksProvider({\n children,\n linkComponent,\n navigate,\n notify,\n confirm,\n choose,\n runtimeConfig,\n openDocument,\n openConversation,\n openSettings,\n openProject,\n}: BlocksProviderProps) {\n const parent = useContext(BlocksContext)\n const value = useMemo<BlocksEnvironment>(\n () => ({\n linkComponent: linkComponent ?? parent.linkComponent,\n navigate: navigate ?? parent.navigate,\n notify: notify ?? parent.notify,\n confirm: confirm ?? parent.confirm,\n choose: choose ?? parent.choose,\n runtimeConfig: runtimeConfig ?? parent.runtimeConfig,\n openDocument: openDocument ?? parent.openDocument,\n openConversation: openConversation ?? parent.openConversation,\n openSettings: openSettings ?? parent.openSettings,\n openProject: openProject ?? parent.openProject,\n }),\n [\n parent,\n linkComponent,\n navigate,\n notify,\n confirm,\n choose,\n runtimeConfig,\n openDocument,\n openConversation,\n openSettings,\n openProject,\n ]\n )\n return <BlocksContext.Provider value={value}>{children}</BlocksContext.Provider>\n}\n\nexport function useBlocksEnvironment(): BlocksEnvironment {\n return useContext(BlocksContext)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/connection/ConnectedNativeDocxEditor.tsx"],"names":["useConnection","useRegisterOpenDocument","jsx","NativeDocxEditor","useArbi","useQueryClient","useBlocksEnvironment","useQuery","useMemo","loadDocxFonts","arbiQueryKeys"],"mappings":";;;;;;;;;;;;AAcO,SAAS,yBAAA,CAA0B;AAAA,EACxC,WAAA,GAAc,oBAAA;AAAA,EACd,GAAG;AACL,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SACF,CAAA;AACD,QAAA,MAAM,QAAA,GAAY,MAAM,QAAA,CAAS,IAAA,EAAK;AACtC,QAAA,MAAA,CAAO,sBAAsB,SAAS,CAAA;AACtC,QAAA,OAAO,EAAE,WAAA,EAAa,QAAA,CAAS,YAAA,IAAgB,EAAC,EAAE;AAAA,MACpD,CAAA;AAAA,MACA,cAAA,EAAgB,OAAO,UAAA,KAAA,CAAgB,MAAM,KAAK,SAAA,CAAU,WAAA,CAAY,UAAU,CAAA,EAAG;AAAA,KACvF,CAAA;AAAA,IACA;AAAA,MACE,IAAA;AAAA,MACA,MAAA;AAAA,MACA,IAAA,EAAM,IAAA;AAAA,MACN,OAAA;AAAA,MACA,mBAAA;AAAA,MACA,WAAA;AAAA,MACA,OAAA;AAAA,MACA,WAAA;AAAA,MACA;AAAA;AACF,GACF;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-GZPTWHP5.cjs","sourcesContent":["import { useMemo } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useArbi, arbiQueryKeys } from '@arbidocs/react'\nimport { useConnection } from './ConnectionProvider'\nimport {\n NativeDocxEditor,\n type NativeDocxAdapter,\n type NativeDocxEditorProps,\n} from '../docx/NativeDocxEditor'\nimport { loadDocxFonts } from '../docx/fonts'\nimport { useRegisterOpenDocument } from '../chat/open-document'\nimport { useBlocksEnvironment } from '../provider/BlocksProvider'\n\n/** Native Word widget bound to the standard blocks connection and SDK session. */\nexport function ConnectedNativeDocxEditor({\n fontBaseUrl = '/native-docx/fonts',\n ...props\n}: Omit<NativeDocxEditorProps, 'adapter'> & { fontBaseUrl?: string }) {\n const adapter = useConnectedNativeDocxAdapter(fontBaseUrl)\n const { workspaceId } = useConnection()\n // Drafting mode: the saved Word document being edited is what the chat is about. A history\n // snapshot, a streamed preview, an unsaved draft and an embedded body field are not.\n const live = !props.snapshot && !props.stream && !props.draftContent && !props.compact\n useRegisterOpenDocument({ documentId: live ? props.documentId : null, workspaceId })\n return <NativeDocxEditor {...props} adapter={adapter} />\n}\n\nexport function useConnectedNativeDocxAdapter(fontBaseUrl = '/native-docx/fonts') {\n const arbi = useArbi()\n const { workspaceId, apiUrl, user, ensureWorkspaceOpen } = useConnection()\n const queries = useQueryClient()\n const { notify } = useBlocksEnvironment()\n const { data: members } = useQuery({\n queryKey: ['native-docx-members', apiUrl, user?.externalId, workspaceId],\n enabled: arbi.isLoggedIn && !!workspaceId,\n queryFn: async () => {\n await ensureWorkspaceOpen()\n return arbi.workspaces.listUsers()\n },\n })\n const adapter = useMemo<NativeDocxAdapter>(\n () => ({\n request: async (path, options) => {\n await ensureWorkspaceOpen()\n return arbi.editor.request(path, options)\n },\n open: async (id) => {\n await ensureWorkspaceOpen()\n return (\n await arbi.editor.request(`/${encodeURIComponent(id)}/session`, { method: 'POST' })\n ).json()\n },\n save: async (id, state) =>\n (\n await arbi.editor.request(`/${encodeURIComponent(id)}/save`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ state }),\n })\n ).json(),\n loadFonts: () => loadDocxFonts(fontBaseUrl),\n baseUrl: apiUrl,\n author: user?.name || 'You',\n onVersionSaved: async (id) => {\n if (!workspaceId) return\n const key = arbiQueryKeys.documents(workspaceId)\n try {\n const documents = await arbi.documents.get([id])\n if (!documents.length) throw new Error('The saved version is not available yet.')\n queries.setQueryData<Awaited<ReturnType<typeof arbi.documents.list>>>(key, (previous) => [\n ...documents,\n ...(previous || []).filter(\n (doc) => !documents.some((saved) => saved.external_id === doc.external_id)\n ),\n ])\n } catch {\n await queries.invalidateQueries({ queryKey: key })\n }\n },\n notify,\n mentions: members?.map(({ user: member }) => ({\n id: member.external_id,\n name: [member.given_name, member.family_name].filter(Boolean).join(' '),\n kind: member.external_id.startsWith('agt-') ? 'agent' : 'human',\n })),\n requestAgent: async (id, request) => {\n const response = await arbi.editor.request(`/${encodeURIComponent(id)}/mentions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n comment_id: request.commentId,\n instruction: request.instruction,\n request_id: request.requestId,\n recipient_ids: request.recipientIds,\n }),\n })\n const delivery = (await response.json()) as { response_ids: string[] }\n notify('Mention delivered.', 'success')\n return { responseIds: delivery.response_ids || [] }\n },\n getAgentStatus: async (responseId) => (await arbi.assistant.getResponse(responseId)).status,\n }),\n [\n arbi,\n apiUrl,\n user?.name,\n members,\n ensureWorkspaceOpen,\n fontBaseUrl,\n queries,\n workspaceId,\n notify,\n ]\n )\n return adapter\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/chat/open-document.ts"],"names":["useRef","useEffect","useSyncExternalStore","parseVersionRef"],"mappings":";;;;;;AA+CO,SAAS,mBAAmB,KAAA,EAA0C;AAC3E,EAAA,MAAM,EAAE,UAAA,EAAY,OAAA,EAAS,WAAA,EAAa,cAAA,EAAgB,cAAa,GAAI,KAAA;AAC3E,EAAA,IAAI,CAAC,UAAA,IAAc,OAAA,IAAW,WAAA,IAAe,gBAAgB,OAAO,IAAA;AACpE,EAAA,IACE,YAAA,EAAc,YAAY,UAAA,IAC1B,CAAC,cAAc,SAAA,EAAW,WAAA,EAAY,CAAE,QAAA,CAAS,OAAO,CAAA;AAExD,IAAA,OAAO,IAAA;AAET,EAAA,IAAI,YAAA,CAAa,WAAA,KAAgB,UAAA,EAAY,OAAO,IAAA;AACpD,EAAA,OAAO,UAAA;AACT;AAkBA,IAAI,UAAmB,EAAC;AACxB,IAAM,SAAA,uBAAgB,GAAA,EAAgB;AAEtC,SAAS,UAAU,QAAA,EAAkC;AACnD,EAAA,SAAA,CAAU,IAAI,QAAQ,CAAA;AACtB,EAAA,OAAO,MAAM,SAAA,CAAU,MAAA,CAAO,QAAQ,CAAA;AACxC;AAEA,SAAS,IAAA,GAAO;AACd,EAAA,SAAA,CAAU,OAAA,CAAQ,CAAC,CAAA,KAAM,CAAA,EAAG,CAAA;AAC9B;AAEA,IAAM,GAAA,GAAM,MAAyB,OAAA,CAAQ,OAAA,CAAQ,SAAS,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AAA,QAAA,IAAW;AACb,EAAA,OAAO,KAAA,CAAM,UAAA;AACf","file":"chunk-JKB7WT7L.cjs","sourcesContent":["import { useEffect, useRef, useSyncExternalStore } from 'react'\nimport { parseVersionRef } from '@arbidocs/react/artifacts'\n\n/**\n * Drafting mode: the saved document open beside the chat is what a chat turn is about.\n *\n * A viewer registers the document it shows (`useRegisterOpenDocument`); every assistant turn names\n * it (`active_artifact_ext_id`, read with `takeOpenDocumentForTurn` as the question is sent), so the\n * server binds the live document to the turn: a Word document is read on demand and edited as\n * tracked changes in the open editor, and what the assistant saves becomes a child version of it.\n * The request carries a reference, never the content.\n *\n * The open document is always the subject, also while one of its earlier versions is on screen\n * read-only: a version still names its document. Sending a turn then returns the viewer to the live\n * document (`showLive`), where the assistant's edits appear as they are made. (Pinning a specific\n * version as a source is a separate feature: it does not go through here.)\n *\n * A module-level registry (not React context), like `useChatSurface`, so a viewer and a chat agree\n * wherever they sit in the tree; the most recently opened document wins and closing it hands back\n * to the one before. It is not the session state's viewing document (`useArbiSessionState`): it\n * holds what mounted viewers can draft in (saved documents only, with the callback that shows the\n * live one again), and a turn reads it outside React. A viewer on the session's viewing document\n * passes that as `shownId` (it may be a version reference, resolved here the same way as\n * `selectViewingDocumentId` does).\n */\n\n/** What a viewer knows about the document it shows. */\nexport interface SavedDocumentInput {\n /** The document (`doc-…`), never a version reference. */\n documentId: string | null | undefined\n /** An unsaved draft (client-minted id, no backend record). */\n isDraft: boolean\n /** Still streaming: nothing is persisted yet. */\n isStreaming: boolean\n /** An image, audio or video artifact: there is no text to draft in. */\n isBlobArtifact: boolean\n /** The loaded document record. */\n documentData:\n | { external_id?: string | null; wp_type?: string | null; file_name?: string | null }\n | null\n | undefined\n}\n\n/**\n * The saved, content-backed document a chat can draft in, or null. Only a saved artifact or Word\n * document counts: drafts, an artifact still streaming and blob artifacts do not.\n */\nexport function savedDocumentIdFor(input: SavedDocumentInput): string | null {\n const { documentId, isDraft, isStreaming, isBlobArtifact, documentData } = input\n if (!documentId || isDraft || isStreaming || isBlobArtifact) return null\n if (\n documentData?.wp_type !== 'artifact' &&\n !documentData?.file_name?.toLowerCase().endsWith('.docx')\n )\n return null\n // A stale record of the previously viewed document is not this one.\n if (documentData.external_id !== documentId) return null\n return documentId\n}\n\nexport interface OpenDocumentRegistration {\n /** The saved document the viewer shows (`doc-…`); null or empty registers nothing. */\n documentId: string | null | undefined\n /** What is on screen: the document itself, or one of its earlier versions (`doc-…@v2`). */\n shownId?: string | null\n /** Show the live document again. Called when a turn starts while an earlier version is shown. */\n showLive?: () => void\n /** The workspace the document belongs to; a chat in another workspace does not draft in it. */\n workspaceId?: string | null\n}\n\ninterface Entry {\n documentId: string\n current: () => OpenDocumentRegistration\n}\n\nlet entries: Entry[] = []\nconst listeners = new Set<() => void>()\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nfunction emit() {\n listeners.forEach((l) => l())\n}\n\nconst top = (): Entry | undefined => entries[entries.length - 1]\n\n/**\n * Registers the document a viewer shows as the open document while the caller is mounted and\n * `documentId` is set. Pass `savedDocumentIdFor(...)`, or the id of a document known to be saved.\n */\nexport function useRegisterOpenDocument(registration: OpenDocumentRegistration): void {\n const latest = useRef(registration)\n useEffect(() => {\n latest.current = registration\n })\n const { documentId } = registration\n useEffect(() => {\n if (!documentId) return\n const entry: Entry = { documentId, current: () => latest.current }\n entries = [...entries, entry]\n emit()\n return () => {\n entries = entries.filter((e) => e !== entry)\n emit()\n }\n }, [documentId])\n}\n\n/** The open document's id, or null. Re-renders when another document opens or it closes. */\nexport function useOpenDocumentId(): string | null {\n return useSyncExternalStore(\n subscribe,\n () => top()?.documentId ?? null,\n () => null\n )\n}\n\n/**\n * The document an assistant turn about to be sent drafts in, or null. Call it once per turn as the\n * question is sent: when an earlier version of the document is on screen, the viewer returns to the\n * live document, where the assistant's edits appear. With `workspaceId`, a document registered in\n * another workspace is not named (and its viewer is left alone).\n */\nexport function takeOpenDocumentForTurn(options?: { workspaceId?: string | null }): string | null {\n const entry = top()\n if (!entry) return null\n const { shownId, showLive, workspaceId } = entry.current()\n if (options?.workspaceId && workspaceId && options.workspaceId !== workspaceId) return null\n if (\n shownId &&\n shownId !== entry.documentId &&\n parseVersionRef(shownId).docId === entry.documentId\n )\n showLive?.()\n return entry.documentId\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/chat/open-document.ts"],"names":[],"mappings":";;;;AA+CO,SAAS,mBAAmB,KAAA,EAA0C;AAC3E,EAAA,MAAM,EAAE,UAAA,EAAY,OAAA,EAAS,WAAA,EAAa,cAAA,EAAgB,cAAa,GAAI,KAAA;AAC3E,EAAA,IAAI,CAAC,UAAA,IAAc,OAAA,IAAW,WAAA,IAAe,gBAAgB,OAAO,IAAA;AACpE,EAAA,IACE,YAAA,EAAc,YAAY,UAAA,IAC1B,CAAC,cAAc,SAAA,EAAW,WAAA,EAAY,CAAE,QAAA,CAAS,OAAO,CAAA;AAExD,IAAA,OAAO,IAAA;AAET,EAAA,IAAI,YAAA,CAAa,WAAA,KAAgB,UAAA,EAAY,OAAO,IAAA;AACpD,EAAA,OAAO,UAAA;AACT;AAkBA,IAAI,UAAmB,EAAC;AACxB,IAAM,SAAA,uBAAgB,GAAA,EAAgB;AAEtC,SAAS,UAAU,QAAA,EAAkC;AACnD,EAAA,SAAA,CAAU,IAAI,QAAQ,CAAA;AACtB,EAAA,OAAO,MAAM,SAAA,CAAU,MAAA,CAAO,QAAQ,CAAA;AACxC;AAEA,SAAS,IAAA,GAAO;AACd,EAAA,SAAA,CAAU,OAAA,CAAQ,CAAC,CAAA,KAAM,CAAA,EAAG,CAAA;AAC9B;AAEA,IAAM,GAAA,GAAM,MAAyB,OAAA,CAAQ,OAAA,CAAQ,SAAS,CAAC,CAAA;AAMxD,SAAS,wBAAwB,YAAA,EAA8C;AACpF,EAAA,MAAM,MAAA,GAAS,OAAO,YAAY,CAAA;AAClC,EAAA,SAAA,CAAU,MAAM;AACd,I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'@arbidocs/react/artifacts'\n\n/**\n * Drafting mode: the saved document open beside the chat is what a chat turn is about.\n *\n * A viewer registers the document it shows (`useRegisterOpenDocument`); every assistant turn names\n * it (`active_artifact_ext_id`, read with `takeOpenDocumentForTurn` as the question is sent), so the\n * server binds the live document to the turn: a Word document is read on demand and edited as\n * tracked changes in the open editor, and what the assistant saves becomes a child version of it.\n * The request carries a reference, never the content.\n *\n * The open document is always the subject, also while one of its earlier versions is on screen\n * read-only: a version still names its document. Sending a turn then returns the viewer to the live\n * document (`showLive`), where the assistant's edits appear as they are made. (Pinning a specific\n * version as a source is a separate feature: it does not go through here.)\n *\n * A module-level registry (not React context), like `useChatSurface`, so a viewer and a chat agree\n * wherever they sit in the tree; the most recently opened document wins and closing it hands back\n * to the one before. It is not the session state's viewing document (`useArbiSessionState`): it\n * holds what mounted viewers can draft in (saved documents only, with the callback that shows the\n * live one again), and a turn reads it outside React. A viewer on the session's viewing document\n * passes that as `shownId` (it may be a version reference, resolved here the same way as\n * `selectViewingDocumentId` does).\n */\n\n/** What a viewer knows about the document it shows. */\nexport interface SavedDocumentInput {\n /** The document (`doc-…`), never a version reference. */\n documentId: string | null | undefined\n /** An unsaved draft (client-minted id, no backend record). */\n isDraft: boolean\n /** Still streaming: nothing is persisted yet. */\n isStreaming: boolean\n /** An image, audio or video artifact: there is no text to draft in. */\n isBlobArtifact: boolean\n /** The loaded document record. */\n documentData:\n | { external_id?: string | null; wp_type?: string | null; file_name?: string | null }\n | null\n | undefined\n}\n\n/**\n * The saved, content-backed document a chat can draft in, or null. Only a saved artifact or Word\n * document counts: drafts, an artifact still streaming and blob artifacts do not.\n */\nexport function savedDocumentIdFor(input: SavedDocumentInput): string | null {\n const { documentId, isDraft, isStreaming, isBlobArtifact, documentData } = input\n if (!documentId || isDraft || isStreaming || isBlobArtifact) return null\n if (\n documentData?.wp_type !== 'artifact' &&\n !documentData?.file_name?.toLowerCase().endsWith('.docx')\n )\n return null\n // A stale record of the previously viewed document is not this one.\n if (documentData.external_id !== documentId) return null\n return documentId\n}\n\nexport interface OpenDocumentRegistration {\n /** The saved document the viewer shows (`doc-…`); null or empty registers nothing. */\n documentId: string | null | undefined\n /** What is on screen: the document itself, or one of its earlier versions (`doc-…@v2`). */\n shownId?: string | null\n /** Show the live document again. Called when a turn starts while an earlier version is shown. */\n showLive?: () => void\n /** The workspace the document belongs to; a chat in another workspace does not draft in it. */\n workspaceId?: string | null\n}\n\ninterface Entry {\n documentId: string\n current: () => OpenDocumentRegistration\n}\n\nlet entries: Entry[] = []\nconst listeners = new Set<() => void>()\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nfunction emit() {\n listeners.forEach((l) => l())\n}\n\nconst top = (): Entry | undefined => entries[entries.length - 1]\n\n/**\n * Registers the document a viewer shows as the open document while the caller is mounted and\n * `documentId` is set. Pass `savedDocumentIdFor(...)`, or the id of a document known to be saved.\n */\nexport function useRegisterOpenDocument(registration: OpenDocumentRegistration): void {\n const latest = useRef(registration)\n useEffect(() => {\n latest.current = registration\n })\n const { documentId } = registration\n useEffect(() => {\n if (!documentId) return\n const entry: Entry = { documentId, current: () => latest.current }\n entries = [...entries, entry]\n emit()\n return () => {\n entries = entries.filter((e) => e !== entry)\n emit()\n }\n }, [documentId])\n}\n\n/** The open document's id, or null. Re-renders when another document opens or it closes. */\nexport function useOpenDocumentId(): string | null {\n return useSyncExternalStore(\n subscribe,\n () => top()?.documentId ?? null,\n () => null\n )\n}\n\n/**\n * The document an assistant turn about to be sent drafts in, or null. Call it once per turn as the\n * question is sent: when an earlier version of the document is on screen, the viewer returns to the\n * live document, where the assistant's edits appear. With `workspaceId`, a document registered in\n * another workspace is not named (and its viewer is left alone).\n */\nexport function takeOpenDocumentForTurn(options?: { workspaceId?: string | null }): string | null {\n const entry = top()\n if (!entry) return null\n const { shownId, showLive, workspaceId } = entry.current()\n if (options?.workspaceId && workspaceId && options.workspaceId !== workspaceId) return null\n if (\n shownId &&\n shownId !== entry.documentId &&\n parseVersionRef(shownId).docId === entry.documentId\n )\n showLive?.()\n return entry.documentId\n}\n"]}
@@ -1,163 +0,0 @@
1
- "use client";
2
- import { ModalScaffold } from './chunk-TX2ZICS7.js';
3
- import { createContext, useState, useContext, useMemo } from 'react';
4
- import { Info, AlertCircle } from 'lucide-react';
5
- import { Button } from '@arbidocs/react/ui';
6
- import { jsx } from 'react/jsx-runtime';
7
- import { notify } from '@arbidocs/react/shell';
8
-
9
- var UNMOUNT_DELAY_MS = 300;
10
- function PromptDialog({
11
- request,
12
- onSettle
13
- }) {
14
- const [open, setOpen] = useState(true);
15
- const { message, title = "Confirm", choices, icon = "alert", testId = "choice-modal" } = request;
16
- const settle = (value) => {
17
- setOpen(false);
18
- onSettle(value);
19
- };
20
- return /* @__PURE__ */ jsx(
21
- ModalScaffold,
22
- {
23
- open,
24
- onOpenChange: (next) => {
25
- if (!next) settle(null);
26
- },
27
- title,
28
- icon: icon === "info" ? /* @__PURE__ */ jsx(Info, { className: "h-5 w-5 text-blue-text", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(AlertCircle, { className: "h-5 w-5", "aria-hidden": "true" }),
29
- description: /* @__PURE__ */ jsx("span", { className: "whitespace-pre-line", children: message }),
30
- showDescription: true,
31
- testId,
32
- children: /* @__PURE__ */ jsx(ModalScaffold.Footer, { children: choices.map((choice) => /* @__PURE__ */ jsx(
33
- Button,
34
- {
35
- variant: choice.variant ?? "default",
36
- onClick: () => settle(choice.value),
37
- "data-testid": `${testId}-${choice.value.toLowerCase()}-button`,
38
- children: choice.label
39
- },
40
- choice.value
41
- )) })
42
- }
43
- );
44
- }
45
- function choiceDialog(request) {
46
- if (typeof document === "undefined") return Promise.resolve(null);
47
- return new Promise((resolve) => {
48
- const container = document.createElement("div");
49
- document.body.appendChild(container);
50
- let settled = false;
51
- void import('react-dom/client').then(({ createRoot }) => {
52
- const root = createRoot(container);
53
- const onSettle = (value) => {
54
- if (settled) return;
55
- settled = true;
56
- resolve(value);
57
- setTimeout(() => {
58
- root.unmount();
59
- container.remove();
60
- }, UNMOUNT_DELAY_MS);
61
- };
62
- root.render(/* @__PURE__ */ jsx(PromptDialog, { request, onSettle }));
63
- });
64
- });
65
- }
66
- var CONFIRM_CHOICES = {
67
- confirm: [
68
- { label: "Cancel", value: "cancel", variant: "outline" },
69
- { label: "Confirm", value: "confirm", variant: "destructive" }
70
- ],
71
- yesno: [
72
- { label: "No", value: "no", variant: "outline" },
73
- { label: "Yes", value: "yes" }
74
- ],
75
- alert: [{ label: "OK", value: "ok" }]
76
- };
77
- var CONFIRM_TEST_ID = {
78
- confirm: "confirmation-modal",
79
- yesno: "yes-no-modal",
80
- alert: "alert-modal"
81
- };
82
- async function confirmDialog(request) {
83
- const kind = request.kind ?? "confirm";
84
- const choice = await choiceDialog({
85
- message: request.message,
86
- title: request.title ?? (kind === "alert" ? "Alert" : "Confirm"),
87
- choices: CONFIRM_CHOICES[kind],
88
- icon: kind === "alert" ? "info" : "alert",
89
- testId: CONFIRM_TEST_ID[kind]
90
- });
91
- return choice === "confirm" || choice === "yes" || choice === "ok";
92
- }
93
- var noop = () => {
94
- };
95
- var defaultEnvironment = {
96
- navigate: (href) => {
97
- if (typeof window !== "undefined") window.location.assign(href);
98
- },
99
- notify: (message, kind = "info", options) => {
100
- notify[kind](message, options);
101
- },
102
- confirm: confirmDialog,
103
- choose: choiceDialog,
104
- runtimeConfig: {
105
- apiBaseUrl: "",
106
- deploymentDomain: typeof window !== "undefined" ? window.location.host : ""
107
- },
108
- openDocument: noop,
109
- openConversation: noop,
110
- openSettings: noop,
111
- openProject: noop
112
- };
113
- var BlocksContext = createContext(defaultEnvironment);
114
- function BlocksProvider({
115
- children,
116
- linkComponent,
117
- navigate,
118
- notify,
119
- confirm,
120
- choose,
121
- runtimeConfig,
122
- openDocument,
123
- openConversation,
124
- openSettings,
125
- openProject
126
- }) {
127
- const parent = useContext(BlocksContext);
128
- const value = useMemo(
129
- () => ({
130
- linkComponent: linkComponent ?? parent.linkComponent,
131
- navigate: navigate ?? parent.navigate,
132
- notify: notify ?? parent.notify,
133
- confirm: confirm ?? parent.confirm,
134
- choose: choose ?? parent.choose,
135
- runtimeConfig: runtimeConfig ?? parent.runtimeConfig,
136
- openDocument: openDocument ?? parent.openDocument,
137
- openConversation: openConversation ?? parent.openConversation,
138
- openSettings: openSettings ?? parent.openSettings,
139
- openProject: openProject ?? parent.openProject
140
- }),
141
- [
142
- parent,
143
- linkComponent,
144
- navigate,
145
- notify,
146
- confirm,
147
- choose,
148
- runtimeConfig,
149
- openDocument,
150
- openConversation,
151
- openSettings,
152
- openProject
153
- ]
154
- );
155
- return /* @__PURE__ */ jsx(BlocksContext.Provider, { value, children });
156
- }
157
- function useBlocksEnvironment() {
158
- return useContext(BlocksContext);
159
- }
160
-
161
- export { BlocksProvider, useBlocksEnvironment };
162
- //# sourceMappingURL=chunk-YNIBUKV5.js.map
163
- //# sourceMappingURL=chunk-YNIBUKV5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/provider/dialogs.tsx","../src/provider/BlocksProvider.tsx"],"names":["notifyStore","jsx"],"mappings":";;;;;;;AA6CA,IAAM,gBAAA,GAAmB,GAAA;AAEzB,SAAS,YAAA,CAA+B;AAAA,EACtC,OAAA;AAAA,EACA;AACF,CAAA,EAGiB;AACf,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,IAAI,CAAA;AACrC,EAAA,MAAM,EAAE,SAAS,KAAA,GAAQ,SAAA,EAAW,SAAS,IAAA,GAAO,OAAA,EAAS,MAAA,GAAS,cAAA,EAAe,GAAI,OAAA;AACzF,EAAA,MAAM,MAAA,GAAS,CAAC,KAAA,KAAoB;AAClC,IAAA,OAAA,CAAQ,KAAK,CAAA;AACb,IAAA,QAAA,CAAS,KAAK,CAAA;AAAA,EAChB,CAAA;AACA,EAAA,uBACE,GAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,YAAA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;AACjC","file":"chunk-YNIBUKV5.js","sourcesContent":["/**\n * Promise-based prompt dialogs — the blocks replacement for `window.confirm` / `window.alert`.\n * Each call mounts its own short-lived React root, so it works from any event handler with no\n * dialog host in the tree. Hosts reach these through `useBlocksEnvironment().confirm` / `.choose`\n * (the defaults), which lets an app swap in its own dialogs without touching callers.\n *\n * For a confirmation with a loading state, render the declarative {@link ConfirmDialog} instead.\n */\nimport { useState, type ReactElement } from 'react'\nimport { AlertCircle, Info } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { ModalScaffold } from '../settings/ModalScaffold'\n\ntype ChoiceVariant = 'default' | 'destructive' | 'outline'\n\nexport interface PromptChoice<T extends string> {\n label: string\n value: T\n variant?: ChoiceVariant\n}\n\n/** A dialog offering arbitrary choices (e.g. Overwrite / Skip / Cancel). */\nexport interface ChoiceRequest<T extends string> {\n message: string\n title?: string\n choices: PromptChoice<T>[]\n icon?: 'alert' | 'info'\n /** Dialog test id; each button is `${testId}-${value}-button`. Default `choice-modal`. */\n testId?: string\n}\n\n/**\n * `confirm` — Cancel / Confirm (destructive); `yesno` — No / Yes; `alert` — a single OK\n * (resolves true once acknowledged).\n */\nexport type ConfirmKind = 'confirm' | 'yesno' | 'alert'\n\nexport interface ConfirmRequest {\n message: string\n /** Default: \"Alert\" for `alert`, else \"Confirm\". */\n title?: string\n kind?: ConfirmKind\n}\n\n/** Close animation length before the root is unmounted. */\nconst UNMOUNT_DELAY_MS = 300\n\nfunction PromptDialog<T extends string>({\n request,\n onSettle,\n}: {\n request: ChoiceRequest<T>\n onSettle: (value: T | null) => void\n}): ReactElement {\n const [open, setOpen] = useState(true)\n const { message, title = 'Confirm', choices, icon = 'alert', testId = 'choice-modal' } = request\n const settle = (value: T | null) => {\n setOpen(false)\n onSettle(value)\n }\n return (\n <ModalScaffold\n open={open}\n onOpenChange={(next) => {\n if (!next) settle(null)\n }}\n title={title}\n icon={\n icon === 'info' ? (\n <Info className=\"h-5 w-5 text-blue-text\" aria-hidden=\"true\" />\n ) : (\n <AlertCircle className=\"h-5 w-5\" aria-hidden=\"true\" />\n )\n }\n description={<span className=\"whitespace-pre-line\">{message}</span>}\n showDescription\n testId={testId}\n >\n <ModalScaffold.Footer>\n {choices.map((choice) => (\n <Button\n key={choice.value}\n variant={choice.variant ?? 'default'}\n onClick={() => settle(choice.value)}\n data-testid={`${testId}-${choice.value.toLowerCase()}-button`}\n >\n {choice.label}\n </Button>\n ))}\n </ModalScaffold.Footer>\n </ModalScaffold>\n )\n}\n\n/** Show a choice dialog; resolves with the chosen `value`, or `null` when dismissed. */\nexport function choiceDialog<T extends string>(request: ChoiceRequest<T>): Promise<T | null> {\n if (typeof document === 'undefined') return Promise.resolve(null)\n return new Promise((resolve) => {\n const container = document.createElement('div')\n document.body.appendChild(container)\n let settled = false\n void import('react-dom/client').then(({ createRoot }) => {\n const root = createRoot(container)\n const onSettle = (value: T | null) => {\n if (settled) return\n settled = true\n resolve(value)\n setTimeout(() => {\n root.unmount()\n container.remove()\n }, UNMOUNT_DELAY_MS)\n }\n root.render(<PromptDialog request={request} onSettle={onSettle} />)\n })\n })\n}\n\nconst CONFIRM_CHOICES: Record<\n ConfirmKind,\n PromptChoice<'confirm' | 'cancel' | 'yes' | 'no' | 'ok'>[]\n> = {\n confirm: [\n { label: 'Cancel', value: 'cancel', variant: 'outline' },\n { label: 'Confirm', value: 'confirm', variant: 'destructive' },\n ],\n yesno: [\n { label: 'No', value: 'no', variant: 'outline' },\n { label: 'Yes', value: 'yes' },\n ],\n alert: [{ label: 'OK', value: 'ok' }],\n}\n\nconst CONFIRM_TEST_ID: Record<ConfirmKind, string> = {\n confirm: 'confirmation-modal',\n yesno: 'yes-no-modal',\n alert: 'alert-modal',\n}\n\n/** Show a confirmation; resolves true on Confirm / Yes / OK, false on cancel or dismissal. */\nexport async function confirmDialog(request: ConfirmRequest): Promise<boolean> {\n const kind = request.kind ?? 'confirm'\n const choice = await choiceDialog({\n message: request.message,\n title: request.title ?? (kind === 'alert' ? 'Alert' : 'Confirm'),\n choices: CONFIRM_CHOICES[kind],\n icon: kind === 'alert' ? 'info' : 'alert',\n testId: CONFIRM_TEST_ID[kind],\n })\n return choice === 'confirm' || choice === 'yes' || choice === 'ok'\n}\n","import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport {\n notify as notifyStore,\n type NotifyOptions,\n type NotifyVariant,\n} from '@arbidocs/react/shell'\nimport type { BlockLinkComponent } from '../components/blockLink'\nimport { choiceDialog, confirmDialog, type ChoiceRequest, type ConfirmRequest } from './dialogs'\n\n/** What blocks need from the host's runtime configuration (the app's `config.json`). */\nexport interface BlocksRuntimeConfig {\n /** Origin of the ARBI API; `''` means the page's own origin. */\n apiBaseUrl: string\n /** The deployment's domain, e.g. `www.arbidocs.com` (deep links, key derivation, labels). */\n deploymentDomain: string\n}\n\nexport interface OpenDocumentOptions {\n /** 1-based page to scroll to. */\n page?: number\n /** Passage (chunk) to highlight. */\n passageId?: string\n}\n\n/**\n * The only way blocks reach the host app's environment. Blocks never import a router, a toast\n * library or an app store; the host injects what it has, and every field has a safe default so a\n * block renders correctly with no provider at all. A nested provider overrides only the fields\n * it is given and inherits the rest.\n */\nexport interface BlocksEnvironment {\n /** Router-aware link (keeps navigation in-SPA). Default: a plain `<a href>`. */\n linkComponent?: BlockLinkComponent\n /** Imperative navigation for buttons and keyboard shortcuts. Default: `window.location.assign`. */\n navigate: (href: string) => void\n /** Surface a transient message (and record it in the notification centre). Default: the shared\n * `@arbidocs/react` notify store, rendered by its `<Toaster/>`. */\n notify: (message: ReactNode, kind?: NotifyVariant, options?: NotifyOptions) => void\n /** Ask the user to confirm. Default: the blocks prompt dialog. */\n confirm: (request: ConfirmRequest) => Promise<boolean>\n /** Ask the user to pick one of several choices; `null` when dismissed. Default: the blocks\n * prompt dialog. */\n choose: <T extends string>(request: ChoiceRequest<T>) => Promise<T | null>\n /** Deployment configuration. Default: same-origin API on the page's own host. */\n runtimeConfig: BlocksRuntimeConfig\n /** Open a document (optionally at a page / passage) wherever the host shows documents.\n * Default: no-op. */\n openDocument: (documentId: string, options?: OpenDocumentOptions) => void\n /** Open a conversation thread, optionally scrolled to a message. Default: no-op. */\n openConversation: (conversationId: string, options?: { messageId?: string }) => void\n /** Open the user's settings, optionally at a section. Default: no-op. */\n openSettings: (section?: string) => void\n /** Open a project. Default: no-op. */\n openProject: (projectId: string) => void\n}\n\nconst noop = () => {}\n\nconst defaultEnvironment: BlocksEnvironment = {\n navigate: (href) => {\n if (typeof window !== 'undefined') window.location.assign(href)\n },\n notify: (message, kind = 'info', options) => {\n notifyStore[kind](message, options)\n },\n confirm: confirmDialog,\n choose: choiceDialog,\n runtimeConfig: {\n apiBaseUrl: '',\n deploymentDomain: typeof window !== 'undefined' ? window.location.host : '',\n },\n openDocument: noop,\n openConversation: noop,\n openSettings: noop,\n openProject: noop,\n}\n\nconst BlocksContext = createContext<BlocksEnvironment>(defaultEnvironment)\n\nexport interface BlocksProviderProps extends Partial<BlocksEnvironment> {\n children: ReactNode\n}\n\nexport function BlocksProvider({\n children,\n linkComponent,\n navigate,\n notify,\n confirm,\n choose,\n runtimeConfig,\n openDocument,\n openConversation,\n openSettings,\n openProject,\n}: BlocksProviderProps) {\n const parent = useContext(BlocksContext)\n const value = useMemo<BlocksEnvironment>(\n () => ({\n linkComponent: linkComponent ?? parent.linkComponent,\n navigate: navigate ?? parent.navigate,\n notify: notify ?? parent.notify,\n confirm: confirm ?? parent.confirm,\n choose: choose ?? parent.choose,\n runtimeConfig: runtimeConfig ?? parent.runtimeConfig,\n openDocument: openDocument ?? parent.openDocument,\n openConversation: openConversation ?? parent.openConversation,\n openSettings: openSettings ?? parent.openSettings,\n openProject: openProject ?? parent.openProject,\n }),\n [\n parent,\n linkComponent,\n navigate,\n notify,\n confirm,\n choose,\n runtimeConfig,\n openDocument,\n openConversation,\n openSettings,\n openProject,\n ]\n )\n return <BlocksContext.Provider value={value}>{children}</BlocksContext.Provider>\n}\n\nexport function useBlocksEnvironment(): BlocksEnvironment {\n return useContext(BlocksContext)\n}\n"]}
@@ -1,31 +0,0 @@
1
- type ChoiceVariant = 'default' | 'destructive' | 'outline';
2
- export interface PromptChoice<T extends string> {
3
- label: string;
4
- value: T;
5
- variant?: ChoiceVariant;
6
- }
7
- /** A dialog offering arbitrary choices (e.g. Overwrite / Skip / Cancel). */
8
- export interface ChoiceRequest<T extends string> {
9
- message: string;
10
- title?: string;
11
- choices: PromptChoice<T>[];
12
- icon?: 'alert' | 'info';
13
- /** Dialog test id; each button is `${testId}-${value}-button`. Default `choice-modal`. */
14
- testId?: string;
15
- }
16
- /**
17
- * `confirm` — Cancel / Confirm (destructive); `yesno` — No / Yes; `alert` — a single OK
18
- * (resolves true once acknowledged).
19
- */
20
- export type ConfirmKind = 'confirm' | 'yesno' | 'alert';
21
- export interface ConfirmRequest {
22
- message: string;
23
- /** Default: "Alert" for `alert`, else "Confirm". */
24
- title?: string;
25
- kind?: ConfirmKind;
26
- }
27
- /** Show a choice dialog; resolves with the chosen `value`, or `null` when dismissed. */
28
- export declare function choiceDialog<T extends string>(request: ChoiceRequest<T>): Promise<T | null>;
29
- /** Show a confirmation; resolves true on Confirm / Yes / OK, false on cancel or dismissal. */
30
- export declare function confirmDialog(request: ConfirmRequest): Promise<boolean>;
31
- export {};