@arbidocs/blocks 0.4.131 → 0.4.132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/agents/index.cjs +216 -216
- package/dist/agents/index.js +5 -5
- package/dist/calls/index.cjs +3 -3
- package/dist/calls/index.js +2 -2
- package/dist/chat/index.cjs +5 -5
- package/dist/chat/index.js +1 -1
- package/dist/chat/open-document.d.ts +5 -1
- package/dist/{chunk-DQCYCEDR.js → chunk-2Q7FDZAY.js} +3 -3
- package/dist/{chunk-DQCYCEDR.js.map → chunk-2Q7FDZAY.js.map} +1 -1
- package/dist/{chunk-P5ST47VY.js → chunk-3FFRYZKV.js} +3 -3
- package/dist/{chunk-P5ST47VY.js.map → chunk-3FFRYZKV.js.map} +1 -1
- package/dist/{chunk-S7PSMMRG.js → chunk-444XKG46.js} +3 -3
- package/dist/{chunk-S7PSMMRG.js.map → chunk-444XKG46.js.map} +1 -1
- package/dist/{chunk-ZV3BKLFY.cjs → chunk-44R3CCZT.cjs} +5 -5
- package/dist/{chunk-ZV3BKLFY.cjs.map → chunk-44R3CCZT.cjs.map} +1 -1
- package/dist/{chunk-7D4W3SAH.js → chunk-4RLCRFZS.js} +15 -12
- package/dist/chunk-4RLCRFZS.js.map +1 -0
- package/dist/{chunk-P5HOXWYL.js → chunk-4UMXQPNA.js} +20 -8
- package/dist/chunk-4UMXQPNA.js.map +1 -0
- package/dist/{chunk-OR4CO743.cjs → chunk-AAFX64WD.cjs} +3 -3
- package/dist/{chunk-OR4CO743.cjs.map → chunk-AAFX64WD.cjs.map} +1 -1
- package/dist/{chunk-LRD7BHAT.cjs → chunk-ARDHLU73.cjs} +13 -10
- package/dist/chunk-ARDHLU73.cjs.map +1 -0
- package/dist/{chunk-KLOSOT26.js → chunk-BMNNT27D.js} +6 -6
- package/dist/{chunk-KLOSOT26.js.map → chunk-BMNNT27D.js.map} +1 -1
- package/dist/chunk-C4WSHRR6.cjs +166 -0
- package/dist/chunk-C4WSHRR6.cjs.map +1 -0
- package/dist/{chunk-ZAVEMQ37.cjs → chunk-DWZXSPMB.cjs} +3 -3
- package/dist/{chunk-ZAVEMQ37.cjs.map → chunk-DWZXSPMB.cjs.map} +1 -1
- package/dist/{chunk-5HFPRI3W.js → chunk-FUTMU4FR.js} +3 -3
- package/dist/{chunk-5HFPRI3W.js.map → chunk-FUTMU4FR.js.map} +1 -1
- package/dist/{chunk-CDZVC32G.cjs → chunk-GZPTWHP5.cjs} +22 -10
- package/dist/chunk-GZPTWHP5.cjs.map +1 -0
- package/dist/{chunk-OUW6G4O2.cjs → chunk-HFGXA5CL.cjs} +4 -4
- package/dist/{chunk-OUW6G4O2.cjs.map → chunk-HFGXA5CL.cjs.map} +1 -1
- package/dist/{chunk-7KH4M3KY.cjs → chunk-HW2J4JMV.cjs} +8 -8
- package/dist/{chunk-7KH4M3KY.cjs.map → chunk-HW2J4JMV.cjs.map} +1 -1
- package/dist/{chunk-SWQX6CTT.cjs → chunk-JKB7WT7L.cjs} +2 -2
- package/dist/chunk-JKB7WT7L.cjs.map +1 -0
- package/dist/{chunk-S6BOINC4.cjs → chunk-OGBXV326.cjs} +7 -7
- package/dist/{chunk-S6BOINC4.cjs.map → chunk-OGBXV326.cjs.map} +1 -1
- package/dist/{chunk-DJM7DLCT.cjs → chunk-OPTBQSCV.cjs} +3 -3
- package/dist/{chunk-DJM7DLCT.cjs.map → chunk-OPTBQSCV.cjs.map} +1 -1
- package/dist/{chunk-GFYGYME3.js → chunk-OQ7RUNOC.js} +3 -3
- package/dist/{chunk-GFYGYME3.js.map → chunk-OQ7RUNOC.js.map} +1 -1
- package/dist/{chunk-W27VK32R.cjs → chunk-QUDCNT63.cjs} +17 -17
- package/dist/{chunk-W27VK32R.cjs.map → chunk-QUDCNT63.cjs.map} +1 -1
- package/dist/{chunk-OB5F4577.cjs → chunk-R26BK7YL.cjs} +4 -4
- package/dist/{chunk-OB5F4577.cjs.map → chunk-R26BK7YL.cjs.map} +1 -1
- package/dist/{chunk-A2YAC22G.js → chunk-RI6DZA5X.js} +3 -3
- package/dist/{chunk-A2YAC22G.js.map → chunk-RI6DZA5X.js.map} +1 -1
- package/dist/{chunk-7QDX2CO4.cjs → chunk-TP6PLDNM.cjs} +4 -4
- package/dist/{chunk-7QDX2CO4.cjs.map → chunk-TP6PLDNM.cjs.map} +1 -1
- package/dist/{chunk-ECERC6TI.js → chunk-VHJHY7TT.js} +3 -3
- package/dist/{chunk-ECERC6TI.js.map → chunk-VHJHY7TT.js.map} +1 -1
- package/dist/{chunk-D3N67Q4D.js → chunk-W3VYZXNS.js} +3 -3
- package/dist/{chunk-D3N67Q4D.js.map → chunk-W3VYZXNS.js.map} +1 -1
- package/dist/{chunk-JK45LSIH.cjs → chunk-WXYQ66KC.cjs} +5 -5
- package/dist/{chunk-JK45LSIH.cjs.map → chunk-WXYQ66KC.cjs.map} +1 -1
- package/dist/{chunk-ZCF2JJFA.js → chunk-Y3KA6X7B.js} +3 -3
- package/dist/{chunk-ZCF2JJFA.js.map → chunk-Y3KA6X7B.js.map} +1 -1
- package/dist/{chunk-GYCQ3FNL.js → chunk-YBLIKTJK.js} +2 -2
- package/dist/chunk-YBLIKTJK.js.map +1 -0
- package/dist/{chunk-DI35D756.js → chunk-YIF6SVSO.js} +4 -4
- package/dist/{chunk-DI35D756.js.map → chunk-YIF6SVSO.js.map} +1 -1
- package/dist/chunk-YNIBUKV5.js +163 -0
- package/dist/chunk-YNIBUKV5.js.map +1 -0
- package/dist/citations/index.cjs +12 -11
- package/dist/citations/index.js +3 -2
- package/dist/collaboration/index.cjs +42 -42
- package/dist/collaboration/index.js +2 -2
- package/dist/connect/docx.cjs +7 -5
- package/dist/connect/docx.cjs.map +1 -1
- package/dist/connect/docx.js +6 -4
- package/dist/connect/docx.js.map +1 -1
- package/dist/connect/index.cjs +129 -123
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.ts +1 -1
- package/dist/connect/index.js +77 -70
- package/dist/connect/index.js.map +1 -1
- package/dist/connection/ConnectedSettings.d.ts +8 -17
- package/dist/connection/ConnectionProvider.d.ts +5 -0
- package/dist/connection/mail/ConnectedMailComposer.d.ts +2 -3
- package/dist/connection/mail/ConnectedMailbox.d.ts +2 -3
- package/dist/connection/mail/MailComposerForm.d.ts +2 -3
- package/dist/connection/mail/index.d.ts +2 -2
- package/dist/connection/mail/mailbox.d.ts +1 -4
- package/dist/connection/mail/types.d.ts +0 -8
- package/dist/facts/index.cjs +4 -3
- package/dist/facts/index.cjs.map +1 -1
- package/dist/facts/index.js +3 -2
- package/dist/facts/index.js.map +1 -1
- package/dist/files/index.cjs +4 -4
- package/dist/files/index.js +3 -3
- package/dist/home/index.cjs +20 -19
- package/dist/home/index.cjs.map +1 -1
- package/dist/home/index.js +5 -4
- package/dist/home/index.js.map +1 -1
- package/dist/index.cjs +394 -394
- package/dist/index.d.ts +2 -1
- package/dist/index.js +11 -11
- package/dist/provider/BlocksProvider.d.ts +39 -4
- package/dist/provider/dialogs.d.ts +31 -0
- package/dist/retrieval/index.cjs +5 -4
- package/dist/retrieval/index.js +3 -2
- package/dist/settings/index.cjs +38 -38
- package/dist/settings/index.js +4 -4
- package/dist/shell/index.cjs +48 -47
- package/dist/shell/index.js +4 -3
- package/dist/studio/index.cjs +15 -14
- package/dist/studio/index.cjs.map +1 -1
- package/dist/studio/index.js +7 -6
- package/dist/studio/index.js.map +1 -1
- package/dist/workflow-canvas/index.cjs +14 -14
- package/dist/workflow-canvas/index.js +6 -6
- package/dist/workspaces/index.cjs +3 -3
- package/dist/workspaces/index.js +2 -2
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +4 -4
- package/dist/chunk-76JDDMSP.js +0 -31
- package/dist/chunk-76JDDMSP.js.map +0 -1
- package/dist/chunk-7D4W3SAH.js.map +0 -1
- package/dist/chunk-C54XEN5T.cjs +0 -34
- package/dist/chunk-C54XEN5T.cjs.map +0 -1
- package/dist/chunk-CDZVC32G.cjs.map +0 -1
- package/dist/chunk-GYCQ3FNL.js.map +0 -1
- package/dist/chunk-LRD7BHAT.cjs.map +0 -1
- package/dist/chunk-P5HOXWYL.js.map +0 -1
- package/dist/chunk-SWQX6CTT.cjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
require('../chunk-
|
|
4
|
+
var chunkARDHLU73_cjs = require('../chunk-ARDHLU73.cjs');
|
|
5
|
+
var chunkQUDCNT63_cjs = require('../chunk-QUDCNT63.cjs');
|
|
6
|
+
require('../chunk-44R3CCZT.cjs');
|
|
7
7
|
require('../chunk-S5HZBXZA.cjs');
|
|
8
8
|
require('../chunk-ZW6FPIFC.cjs');
|
|
9
9
|
var chunkLC2KJSUS_cjs = require('../chunk-LC2KJSUS.cjs');
|
|
@@ -11,20 +11,20 @@ require('../chunk-7D737FLE.cjs');
|
|
|
11
11
|
require('../chunk-N26CXGXC.cjs');
|
|
12
12
|
require('../chunk-3AFWGEDJ.cjs');
|
|
13
13
|
require('../chunk-DVUZTGVL.cjs');
|
|
14
|
-
require('../chunk-
|
|
14
|
+
require('../chunk-R26BK7YL.cjs');
|
|
15
15
|
require('../chunk-DETZZBG2.cjs');
|
|
16
16
|
require('../chunk-V4ISCZJ7.cjs');
|
|
17
17
|
require('../chunk-2EI7NCUA.cjs');
|
|
18
18
|
require('../chunk-C2CWWEHO.cjs');
|
|
19
19
|
require('../chunk-7RGLTF76.cjs');
|
|
20
|
-
require('../chunk-ULWRNGGE.cjs');
|
|
21
20
|
var chunkHM23LXUP_cjs = require('../chunk-HM23LXUP.cjs');
|
|
22
21
|
require('../chunk-7UTB4PHM.cjs');
|
|
23
22
|
var chunk32HW2Q33_cjs = require('../chunk-32HW2Q33.cjs');
|
|
24
23
|
require('../chunk-FX3K6LNZ.cjs');
|
|
25
24
|
require('../chunk-PPCATBOY.cjs');
|
|
26
25
|
require('../chunk-MHVNT4J3.cjs');
|
|
27
|
-
require('../chunk-
|
|
26
|
+
require('../chunk-C4WSHRR6.cjs');
|
|
27
|
+
require('../chunk-ULWRNGGE.cjs');
|
|
28
28
|
require('../chunk-KDG6FER6.cjs');
|
|
29
29
|
require('../chunk-DES3K4SD.cjs');
|
|
30
30
|
var react = require('react');
|
|
@@ -1605,7 +1605,7 @@ function triggerFields(trigger, clearOthers) {
|
|
|
1605
1605
|
return {
|
|
1606
1606
|
timezone: trigger.timezone,
|
|
1607
1607
|
rrule: trigger.start === "repeat" ? trigger.rrule.trim() : none,
|
|
1608
|
-
run_at: trigger.start === "once" ?
|
|
1608
|
+
run_at: trigger.start === "once" ? chunkQUDCNT63_cjs.localInputToIso(trigger.runAt) : none,
|
|
1609
1609
|
event_kind: trigger.start === "event" ? trigger.eventKind.trim() : none,
|
|
1610
1610
|
// A step signal is `workflow_signal` narrowed to one signal name.
|
|
1611
1611
|
event_filter: filter ?? none,
|
|
@@ -1664,7 +1664,7 @@ function workflowRecordToBuilder(record) {
|
|
|
1664
1664
|
...record.skill_ref ? { workflow: record.skill_ref } : { run: { kind: "prompt", promptTemplate: record.prompt } }
|
|
1665
1665
|
}
|
|
1666
1666
|
] : [];
|
|
1667
|
-
const when =
|
|
1667
|
+
const when = chunkQUDCNT63_cjs.workflowWhen(record);
|
|
1668
1668
|
return {
|
|
1669
1669
|
workflow: {
|
|
1670
1670
|
id: record.external_id,
|
|
@@ -1678,7 +1678,7 @@ function workflowRecordToBuilder(record) {
|
|
|
1678
1678
|
trigger: {
|
|
1679
1679
|
...DEFAULT_WORKFLOW_TRIGGER,
|
|
1680
1680
|
start: when === "now" ? "manual" : when,
|
|
1681
|
-
runAt:
|
|
1681
|
+
runAt: chunkQUDCNT63_cjs.isoToLocalInput(record.run_at),
|
|
1682
1682
|
rrule: record.rrule ?? "",
|
|
1683
1683
|
timezone: record.timezone || DEFAULT_WORKFLOW_TRIGGER.timezone,
|
|
1684
1684
|
eventKind: record.event_kind ?? "",
|
|
@@ -1734,7 +1734,7 @@ function triggerSummary(trigger, options = {}) {
|
|
|
1734
1734
|
case "once":
|
|
1735
1735
|
return trigger.runAt ? new Date(trigger.runAt).toLocaleString() : l.starts.once;
|
|
1736
1736
|
case "repeat":
|
|
1737
|
-
return trigger.rrule ?
|
|
1737
|
+
return trigger.rrule ? chunkQUDCNT63_cjs.describeRRule(trigger.rrule) : l.starts.repeat;
|
|
1738
1738
|
case "event":
|
|
1739
1739
|
if (isSignalTrigger(trigger))
|
|
1740
1740
|
return trigger.signal ? l.signalSummary.replace("{signal}", trigger.signal) : l.stepSignals;
|
|
@@ -1793,7 +1793,7 @@ function TriggerInspector({
|
|
|
1793
1793
|
}
|
|
1794
1794
|
)
|
|
1795
1795
|
] }),
|
|
1796
|
-
trigger.start === "repeat" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1796
|
+
trigger.start === "repeat" && /* @__PURE__ */ jsxRuntime.jsx(chunkQUDCNT63_cjs.RecurrenceBuilder, { rrule: trigger.rrule, onChange: (rrule) => set({ rrule }) }),
|
|
1797
1797
|
trigger.start === "event" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
1798
1798
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "text-xs", children: l.event }),
|
|
1799
1799
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1845,7 +1845,7 @@ function TriggerInspector({
|
|
|
1845
1845
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
1846
1846
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "text-xs", children: l.agent }),
|
|
1847
1847
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1848
|
-
|
|
1848
|
+
chunkQUDCNT63_cjs.AgentSelect,
|
|
1849
1849
|
{
|
|
1850
1850
|
agents,
|
|
1851
1851
|
value: trigger.agentId,
|
|
@@ -2682,7 +2682,7 @@ function WorkflowPreview({
|
|
|
2682
2682
|
renderIcon,
|
|
2683
2683
|
testId
|
|
2684
2684
|
}) {
|
|
2685
|
-
const run =
|
|
2685
|
+
const run = chunkQUDCNT63_cjs.useWorkflowPreview(workflow, {
|
|
2686
2686
|
resolveWorkflow: (id) => workflows.find((w) => w.id === id),
|
|
2687
2687
|
compose,
|
|
2688
2688
|
answer
|
|
@@ -2737,7 +2737,7 @@ function ConnectedWorkflowBuilder({
|
|
|
2737
2737
|
...builderProps
|
|
2738
2738
|
}) {
|
|
2739
2739
|
const l = { ...DEFAULT_CONNECTED_WORKFLOW_BUILDER_LABELS, ...connectedLabels };
|
|
2740
|
-
const { workspaceId, status, ensureWorkspaceOpen } =
|
|
2740
|
+
const { workspaceId, status, ensureWorkspaceOpen } = chunkARDHLU73_cjs.useConnection();
|
|
2741
2741
|
const members = react$2.useWorkspaceUsers(workspaceId ?? void 0, {
|
|
2742
2742
|
enabled: status === "authenticated" && !!workspaceId,
|
|
2743
2743
|
beforeFetch: ensureWorkspaceOpen
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useConnection } from '../chunk-
|
|
3
|
-
import { workflowWhen, isoToLocalInput, describeRRule, RecurrenceBuilder, AgentSelect, useWorkflowPreview, localInputToIso } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
2
|
+
import { useConnection } from '../chunk-4RLCRFZS.js';
|
|
3
|
+
import { workflowWhen, isoToLocalInput, describeRRule, RecurrenceBuilder, AgentSelect, useWorkflowPreview, localInputToIso } from '../chunk-BMNNT27D.js';
|
|
4
|
+
import '../chunk-3FFRYZKV.js';
|
|
5
5
|
import '../chunk-4XJZ6AAY.js';
|
|
6
6
|
import '../chunk-P6GHJSLR.js';
|
|
7
7
|
import { isIncompleteSignal, fromPlanSteps, layoutFromPlanSteps, WorkflowRunner, toPlanSteps } from '../chunk-54ANPPMV.js';
|
|
@@ -9,20 +9,20 @@ import '../chunk-XD2M6LIG.js';
|
|
|
9
9
|
import '../chunk-6S5FLMWG.js';
|
|
10
10
|
import '../chunk-RFXJYIDV.js';
|
|
11
11
|
import '../chunk-5LXQPP2K.js';
|
|
12
|
-
import '../chunk-
|
|
12
|
+
import '../chunk-444XKG46.js';
|
|
13
13
|
import '../chunk-EVUEIBNU.js';
|
|
14
14
|
import '../chunk-NUNKSZKU.js';
|
|
15
15
|
import '../chunk-YU2KUMGE.js';
|
|
16
16
|
import '../chunk-N5YEF3LC.js';
|
|
17
17
|
import '../chunk-4WWM3GQ5.js';
|
|
18
|
-
import '../chunk-TX2ZICS7.js';
|
|
19
18
|
import { DEFAULT_STEP_KIND_LABELS, workflowSteps, dependsOn, stepLevels, runFields, upstreamSteps, stepDependencies, canAssign, WORKFLOW_STEP_KINDS, STEP_KIND_ICONS, validateWorkflowGraph, stepConfigProblems, skillToWorkflow, assigneeName, orderSteps, stepKindOf } from '../chunk-7HAM7Y5U.js';
|
|
20
19
|
import '../chunk-AA3PT6KR.js';
|
|
21
20
|
import { TONE_DOT, TONES, isTone } from '../chunk-AUS3KBHJ.js';
|
|
22
21
|
import '../chunk-SLSBJRWW.js';
|
|
23
22
|
import '../chunk-NPLYHR2E.js';
|
|
24
23
|
import '../chunk-7F6CBP3Z.js';
|
|
25
|
-
import '../chunk-
|
|
24
|
+
import '../chunk-YNIBUKV5.js';
|
|
25
|
+
import '../chunk-TX2ZICS7.js';
|
|
26
26
|
import '../chunk-OXF2IFXG.js';
|
|
27
27
|
import '../chunk-VUNV25KB.js';
|
|
28
28
|
import { useState, useMemo, useEffect, useCallback, useRef } from 'react';
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
var chunkXZIYRKLW_cjs = require('../chunk-XZIYRKLW.cjs');
|
|
5
5
|
var chunkXAJIKT6Y_cjs = require('../chunk-XAJIKT6Y.cjs');
|
|
6
6
|
var chunk7G2LJMUG_cjs = require('../chunk-7G2LJMUG.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkR26BK7YL_cjs = require('../chunk-R26BK7YL.cjs');
|
|
8
|
+
require('../chunk-C4WSHRR6.cjs');
|
|
8
9
|
var chunkULWRNGGE_cjs = require('../chunk-ULWRNGGE.cjs');
|
|
9
|
-
require('../chunk-C54XEN5T.cjs');
|
|
10
10
|
var chunkKDG6FER6_cjs = require('../chunk-KDG6FER6.cjs');
|
|
11
11
|
require('../chunk-DES3K4SD.cjs');
|
|
12
12
|
var react = require('react');
|
|
@@ -52,7 +52,7 @@ function WorkspaceCardRoot({
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
return /* @__PURE__ */ jsxRuntime.jsx(CardContext.Provider, { value: { current, testId, labels: mergedLabels }, children: href ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
55
|
-
|
|
55
|
+
chunkR26BK7YL_cjs.ActionLink,
|
|
56
56
|
{
|
|
57
57
|
...rest,
|
|
58
58
|
href,
|
package/dist/workspaces/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { CollapsibleSection, KeyValueRow } from '../chunk-LGBAZD37.js';
|
|
3
3
|
import { MemberAvatarStack } from '../chunk-XNOASBGW.js';
|
|
4
4
|
export { RoleBadge, WorkspaceTypeBadgeView } from '../chunk-NBV56SGU.js';
|
|
5
|
-
import { ActionLink } from '../chunk-
|
|
5
|
+
import { ActionLink } from '../chunk-444XKG46.js';
|
|
6
|
+
import '../chunk-YNIBUKV5.js';
|
|
6
7
|
import { ModalHeader } from '../chunk-TX2ZICS7.js';
|
|
7
|
-
import '../chunk-76JDDMSP.js';
|
|
8
8
|
import { fromNow, fmtDate } from '../chunk-OXF2IFXG.js';
|
|
9
9
|
import '../chunk-VUNV25KB.js';
|
|
10
10
|
import { createContext, useContext, useMemo, useState, useCallback, useId } from 'react';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbidocs/coedit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.132",
|
|
4
4
|
"description": "Real-time collaboration for the ARBI native DOCX editor: a Yjs mirror of the canonical OOXML package, session, and server runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbidocs/blocks",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.132",
|
|
4
4
|
"description": "Composable, domain-neutral UI blocks for ARBI apps, organised by capability (retrieval, facts, agents, workspaces, citations, collaboration) plus shell, theme and site primitives, on top of @arbidocs/react.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -280,8 +280,8 @@
|
|
|
280
280
|
"example:test:e2e": "playwright test -c examples/custom-ui/playwright.config.ts"
|
|
281
281
|
},
|
|
282
282
|
"dependencies": {
|
|
283
|
-
"@arbidocs/client": "0.4.
|
|
284
|
-
"@arbidocs/coedit": "0.4.
|
|
283
|
+
"@arbidocs/client": "0.4.132",
|
|
284
|
+
"@arbidocs/coedit": "0.4.132",
|
|
285
285
|
"@dnd-kit/core": "^6.3.1",
|
|
286
286
|
"@dnd-kit/sortable": "^10.0.0",
|
|
287
287
|
"@dnd-kit/utilities": "^3.2.2",
|
|
@@ -324,7 +324,7 @@
|
|
|
324
324
|
"y-protocols": "^1.0.6"
|
|
325
325
|
},
|
|
326
326
|
"peerDependencies": {
|
|
327
|
-
"@arbidocs/react": "0.4.
|
|
327
|
+
"@arbidocs/react": "0.4.132",
|
|
328
328
|
"@lexical/html": "0.35.0",
|
|
329
329
|
"@lexical/link": "0.35.0",
|
|
330
330
|
"@lexical/list": "0.35.0",
|
package/dist/chunk-76JDDMSP.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { createContext, useMemo, useContext } from 'react';
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
// src/provider/BlocksProvider.tsx
|
|
6
|
-
var defaultEnvironment = {
|
|
7
|
-
navigate: (href) => {
|
|
8
|
-
if (typeof window !== "undefined") window.location.assign(href);
|
|
9
|
-
},
|
|
10
|
-
notify: () => {
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
var BlocksContext = createContext(defaultEnvironment);
|
|
14
|
-
function BlocksProvider({ children, linkComponent, navigate, notify }) {
|
|
15
|
-
const value = useMemo(
|
|
16
|
-
() => ({
|
|
17
|
-
linkComponent,
|
|
18
|
-
navigate: navigate ?? defaultEnvironment.navigate,
|
|
19
|
-
notify: notify ?? defaultEnvironment.notify
|
|
20
|
-
}),
|
|
21
|
-
[linkComponent, navigate, notify]
|
|
22
|
-
);
|
|
23
|
-
return /* @__PURE__ */ jsx(BlocksContext.Provider, { value, children });
|
|
24
|
-
}
|
|
25
|
-
function useBlocksEnvironment() {
|
|
26
|
-
return useContext(BlocksContext);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { BlocksProvider, useBlocksEnvironment };
|
|
30
|
-
//# sourceMappingURL=chunk-76JDDMSP.js.map
|
|
31
|
-
//# sourceMappingURL=chunk-76JDDMSP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider/BlocksProvider.tsx"],"names":[],"mappings":";;;;AAiBA,IAAM,kBAAA,GAAwC;AAAA,EAC5C,QAAA,EAAU,CAAC,IAAA,KAAS;AAClB,IAAA,IAAI,OAAO,MAAA,KAAW,WAAA,EAAa,MAAA,CAAO,QAAA,CAAS,OAAO,IAAI,CAAA;AAAA,EAChE,CAAA;AAAA,EACA,QAAQ,MAAM;AAAA,EAAC;AACjB,CAAA;AAEA,IAAM,aAAA,GAAgB,cAAiC,kBAAkB,CAAA;AAMlE,SAAS,eAAe,EAAE,QAAA,EAAU,aAAA,EAAe,QAAA,EAAU,QAAO,EAAwB;AACjG,EAAA,MAAM,KAAA,GAAQ,OAAA;AAAA,IACZ,OAAO;AAAA,MACL,aAAA;AAAA,MACA,QAAA,EAAU,YAAY,kBAAA,CAAmB,QAAA;AAAA,MACzC,MAAA,EAAQ,UAAU,kBAAA,CAAmB;AAAA,KACvC,CAAA;AAAA,IACA,CAAC,aAAA,EAAe,QAAA,EAAU,MAAM;AAAA,GAClC;AACA,EAAA,uBAAO,GAAA,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,OAAe,QAAA,EAAS,CAAA;AACzD;AAEO,SAAS,oBAAA,GAA0C;AACxD,EAAA,OAAO,WAAW,aAAa,CAAA;AACjC","file":"chunk-76JDDMSP.js","sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport type { BlockLinkComponent } from '../components/blockLink'\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.\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. Default: no-op. */\n notify: (message: string, kind?: 'success' | 'error' | 'info') => void\n}\n\nconst defaultEnvironment: BlocksEnvironment = {\n navigate: (href) => {\n if (typeof window !== 'undefined') window.location.assign(href)\n },\n notify: () => {},\n}\n\nconst BlocksContext = createContext<BlocksEnvironment>(defaultEnvironment)\n\nexport interface BlocksProviderProps extends Partial<BlocksEnvironment> {\n children: ReactNode\n}\n\nexport function BlocksProvider({ children, linkComponent, navigate, notify }: BlocksProviderProps) {\n const value = useMemo<BlocksEnvironment>(\n () => ({\n linkComponent,\n navigate: navigate ?? defaultEnvironment.navigate,\n notify: notify ?? defaultEnvironment.notify,\n }),\n [linkComponent, navigate, notify]\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/ConnectionProvider.tsx"],"names":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AU,OAAA,CAAQ,IAAI,QAAQ,CAAA;AAC9B,QAAA,MAAM,GAAA,GAAM,IAAA,CAAK,eAAA,CAAgB,QAAQ,CAAA;AACzC,QAAA,OAAO,MAAM;AACX,UAAA,SAAA,CAAU,OAAA,CAAQ,OAAO,QAAQ,CAAA;AACjC,UAAA,GAAA,EAAI;AAAA,QACN,CAAA;AAAA,MACF,CAAA;AAAA,MACA,SAAS,OAAO,EAAE,UAAA,EAAW,GAAI,EAAC,KAAM;AACtC,QAAA,IAAI;AACF,UAAA,IAAI,UAAA,EAAY,MAAM,IAAA,CAAK,QAAA,CAAS,SAAA,EAAU;AAAA,QAChD,CAAA,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,GAAM,WAAW,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-7D4W3SAH.js","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 arbiAccountClient,\n toProfileView,\n useArbi,\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 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\nexport function ConnectionProvider({\n config,\n children,\n}: {\n config: ArbiConnectionConfig\n children: ReactNode\n}) {\n const arbi = useArbi()\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, setWorkspaceIdState] = useState<string | null>(null)\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 workspaceIdRef = useRef<string | null>(null)\n const selectWorkspaceId = useCallback((id: string | null) => {\n workspaceIdRef.current = id\n setWorkspaceIdState(id)\n }, [])\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 const id =\n workspaceIdRef.current ??\n readPersistedWorkspace(config.apiUrl, storageUserRef.current) ??\n config.workspaceId\n if (id) await arbi.selectWorkspace(id)\n }, [arbi, 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"]}
|
package/dist/chunk-C54XEN5T.cjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var react = require('react');
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
|
|
7
|
-
// src/provider/BlocksProvider.tsx
|
|
8
|
-
var defaultEnvironment = {
|
|
9
|
-
navigate: (href) => {
|
|
10
|
-
if (typeof window !== "undefined") window.location.assign(href);
|
|
11
|
-
},
|
|
12
|
-
notify: () => {
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
var BlocksContext = react.createContext(defaultEnvironment);
|
|
16
|
-
function BlocksProvider({ children, linkComponent, navigate, notify }) {
|
|
17
|
-
const value = react.useMemo(
|
|
18
|
-
() => ({
|
|
19
|
-
linkComponent,
|
|
20
|
-
navigate: navigate ?? defaultEnvironment.navigate,
|
|
21
|
-
notify: notify ?? defaultEnvironment.notify
|
|
22
|
-
}),
|
|
23
|
-
[linkComponent, navigate, notify]
|
|
24
|
-
);
|
|
25
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BlocksContext.Provider, { value, children });
|
|
26
|
-
}
|
|
27
|
-
function useBlocksEnvironment() {
|
|
28
|
-
return react.useContext(BlocksContext);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.BlocksProvider = BlocksProvider;
|
|
32
|
-
exports.useBlocksEnvironment = useBlocksEnvironment;
|
|
33
|
-
//# sourceMappingURL=chunk-C54XEN5T.cjs.map
|
|
34
|
-
//# sourceMappingURL=chunk-C54XEN5T.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider/BlocksProvider.tsx"],"names":["createContext","useMemo","jsx","useContext"],"mappings":";;;;;;AAiBA,IAAM,kBAAA,GAAwC;AAAA,EAC5C,QAAA,EAAU,CAAC,IAAA,KAAS;AAClB,IAAA,IAAI,OAAO,MAAA,KAAW,WAAA,EAAa,MAAA,CAAO,QAAA,CAAS,OAAO,IAAI,CAAA;AAAA,EAChE,CAAA;AAAA,EACA,QAAQ,MAAM;AAAA,EAAC;AACjB,CAAA;AAEA,IAAM,aAAA,GAAgBA,oBAAiC,kBAAkB,CAAA;AAMlE,SAAS,eAAe,EAAE,QAAA,EAAU,aAAA,EAAe,QAAA,EAAU,QAAO,EAAwB;AACjG,EAAA,MAAM,KAAA,GAAQC,aAAA;AAAA,IACZ,OAAO;AAAA,MACL,aAAA;AAAA,MACA,QAAA,EAAU,YAAY,kBAAA,CAAmB,QAAA;AAAA,MACzC,MAAA,EAAQ,UAAU,kBAAA,CAAmB;AAAA,KACvC,CAAA;AAAA,IACA,CAAC,aAAA,EAAe,QAAA,EAAU,MAAM;AAAA,GAClC;AACA,EAAA,uBAAOC,cAAA,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,OAAe,QAAA,EAAS,CAAA;AACzD;AAEO,SAAS,oBAAA,GAA0C;AACxD,EAAA,OAAOC,iBAAW,aAAa,CAAA;AACjC","file":"chunk-C54XEN5T.cjs","sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport type { BlockLinkComponent } from '../components/blockLink'\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.\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. Default: no-op. */\n notify: (message: string, kind?: 'success' | 'error' | 'info') => void\n}\n\nconst defaultEnvironment: BlocksEnvironment = {\n navigate: (href) => {\n if (typeof window !== 'undefined') window.location.assign(href)\n },\n notify: () => {},\n}\n\nconst BlocksContext = createContext<BlocksEnvironment>(defaultEnvironment)\n\nexport interface BlocksProviderProps extends Partial<BlocksEnvironment> {\n children: ReactNode\n}\n\nexport function BlocksProvider({ children, linkComponent, navigate, notify }: BlocksProviderProps) {\n const value = useMemo<BlocksEnvironment>(\n () => ({\n linkComponent,\n navigate: navigate ?? defaultEnvironment.navigate,\n notify: notify ?? defaultEnvironment.notify,\n }),\n [linkComponent, navigate, notify]\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","useQuery","useMemo","loadDocxFonts","arbiQueryKeys","notify"],"mappings":";;;;;;;;;;;AAaO,SAAS,yBAAA,CAA0B;AAAA,EACxC,WAAA,GAAc,oBAAA;AAAA,EACd,GAAG;AACL,CAAA,EAAsE;AACpE,EAAA,MAAM,OAAA,GAAU,8BAA8B,WAAW,CAAA;AACzD,EAAA,MAAM,EAAE,WAAA,EAAY,GAAIA,+BAAA,EAAc;AAGtC,EAAA,MAAM,IAAA,GAAO,CAAC,KAAA,CAAM,QAAA,IAAY,CAAC,KAAA,CAAM,MAAA,IAAU,CAAC,KAAA,CAAM,YAAA,IAAgB,CAAC,KAAA,CAAM,OAAA;AAC/E,EAAAC,yCAAA,CAAwB,EAAE,UAAA,EAAY,IAAA,GAAO,MAAM,UAAA,GAAa,IAAA,EAAM,aAAa,CAAA;AACnF,EAAA,uBAAOC,cAAA,CAACC,kCAAA,EAAA,EAAkB,GAAG,KAAA,EAAO,OAAA,EAAkB,CAAA;AACxD;AAEO,SAAS,6BAAA,CAA8B,cAAc,oBAAA,EAAsB;AAChF,EAAA,MAAM,OAAOC,aAAA,EAAQ;AACrB,EAAA,MAAM,EAAE,WAAA,EAAa,MAAA,EAAQ,IAAA,EAAM,mBAAA,KAAwBJ,+BAAA,EAAc;AACzE,EAAA,MAAM,UAAUK,yBAAA,EAAe;AAC/B,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAQ,GAAIC,mBAAA,CAAS;AAAA,IACjC,UAAU,CAAC,qBAAA,EAAuB,MAAA,EAAQ,IAAA,EAAM,YAAY,WAAW,CAAA;AAAA,IACvE,OAAA,EAAS,IAAA,CAAK,UAAA,IAAc,CAAC,CAAC,WAAA;AAAA,IAC9B,SAAS,YAAY;AACnB,MAAA,MAAM,mBAAA,EAAoB;AAC1B,MAAA,OAAO,IAAA,CAAK,WAAW,SAAA,EAAU;AAAA,IACnC;AAAA,GACD,CAAA;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AAA,UAC9C,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,YACnB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,aAAa,OAAA,CAAQ,WAAA;AAAA,YACrB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,eAAe,OAAA,CAAQ;AAAA,WACxB;AAAA,SACF,CAAA;AACD,QAAA,MAAM,QAAA,GAAY,MAAM,QAAA,CAAS,IAAA,EAAK;AACtC,QAAAA,YAAA,CAAO,QAAQ,oBAAoB,CAAA;AACnC,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,CAAC,MAAM,MAAA,EAAQ,IAAA,EAAM,MAAM,OAAA,EAAS,mBAAA,EAAqB,WAAA,EAAa,OAAA,EAAS,WAAW;AAAA,GAC5F;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-CDZVC32G.cjs","sourcesContent":["import { useMemo } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useArbi, notify, 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'\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 { 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: (message, kind) => notify[kind](message),\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.success('Mention delivered.')\n return { responseIds: delivery.response_ids || [] }\n },\n getAgentStatus: async (responseId) => (await arbi.assistant.getResponse(responseId)).status,\n }),\n [arbi, apiUrl, user?.name, members, ensureWorkspaceOpen, fontBaseUrl, queries, workspaceId]\n )\n return adapter\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chat/open-document.ts"],"names":[],"mappings":";;;;AA2CO,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,IAA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AAO,CAAA,CAAE,UAAU,KAAA,CAAM,UAAA;AAEzC,IAAA,QAAA,IAAW;AACb,EAAA,OAAO,KAAA,CAAM,UAAA;AACf","file":"chunk-GYCQ3FNL.js","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.\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/connection/ConnectionProvider.tsx"],"names":["createContext","useArbi","useState","useRef","useCallback","useEffect","useMemo","jsx","AccountClientProvider","arbiAccountClient","toProfileView","useContext"],"mappings":";;;;;;;AAkEA,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,WAAA,EAAY;AAG9D,IAAM,mBAAA,GAAsB,CAAC,MAAA,EAAgB,OAAA,KAClD,CAAA,EAAG,wBAAwB,CAAA,CAAA,EAAI,MAAA,IAAU,MAAM,CAAA,CAAA,EAAI,gBAAA,CAAiB,OAAO,CAAC,CAAA,CAAA;AAG9E,IAAM,4BAA4B,CAAC,MAAA,KACjC,GAAG,wBAAwB,CAAA,CAAA,EAAI,UAAU,MAAM,CAAA,CAAA;AAEjD,SAAS,sBAAA,CAAuB,QAAgB,OAAA,EAAuC;AACrF,EAAA,IAAI,CAAC,SAAS,OAAO,IAAA;AACrB,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,YAAA,CAAa,OA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,YACf,SAAA,EAAW,EAAA;AAAA,YACX,UAAA,EAAY,IAAA;AAAA,YACZ,OAAA,EAAS,SAAS,OAAA,IAAW,IAAA;AAAA,YAC7B,OAAO,QAAA,CAAS,KAAA;AAAA,YAChB,KAAA,EAAO;AAAA,WACR,CAAA;AAAA,UACD,UAAU,QAAA,CAAS;AAAA,SACrB;AAAA,MACF,CAAA;AAAA,MACA,eAAA,EAAiB,CAAC,QAAA,KAAa;AAC7B,QAAA,SAAA,CAAU,OAAA,CAAQ,IAAI,QAAQ,CAAA;AAC9B,QAAA,MAAM,GAAA,GAAM,IAAA,CAAK,eAAA,CAAgB,QAAQ,CAAA;AACzC,QAAA,OAAO,MAAM;AACX,UAAA,SAAA,CAAU,OAAA,CAAQ,OAAO,QAAQ,CAAA;AACjC,UAAA,GAAA,EAAI;AAAA,QACN,CAAA;AAAA,MACF,CAAA;AAAA,MACA,SAAS,OAAO,EAAE,UAAA,EAAW,GAAI,EAAC,KAAM;AACtC,QAAA,IAAI;AACF,UAAA,IAAI,UAAA,EAAY,MAAM,IAAA,CAAK,QAAA,CAAS,SAAA,EAAU;AAAA,QAChD,CAAA,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-LRD7BHAT.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 arbiAccountClient,\n toProfileView,\n useArbi,\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 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\nexport function ConnectionProvider({\n config,\n children,\n}: {\n config: ArbiConnectionConfig\n children: ReactNode\n}) {\n const arbi = useArbi()\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, setWorkspaceIdState] = useState<string | null>(null)\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 workspaceIdRef = useRef<string | null>(null)\n const selectWorkspaceId = useCallback((id: string | null) => {\n workspaceIdRef.current = id\n setWorkspaceIdState(id)\n }, [])\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 const id =\n workspaceIdRef.current ??\n readPersistedWorkspace(config.apiUrl, storageUserRef.current) ??\n config.workspaceId\n if (id) await arbi.selectWorkspace(id)\n }, [arbi, 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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/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pB,aAAa,OAAA,CAAQ,WAAA;AAAA,YACrB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,eAAe,OAAA,CAAQ;AAAA,WACxB;AAAA,SACF,CAAA;AACD,QAAA,MAAM,QAAA,GAAY,MAAM,QAAA,CAAS,IAAA,EAAK;AACtC,QAAA,MAAA,CAAO,QAAQ,oBAAoB,CAAA;AACnC,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,CAAC,MAAM,MAAA,EAAQ,IAAA,EAAM,MAAM,OAAA,EAAS,mBAAA,EAAqB,WAAA,EAAa,OAAA,EAAS,WAAW;AAAA,GAC5F;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-P5HOXWYL.js","sourcesContent":["import { useMemo } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useArbi, notify, 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'\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 { 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: (message, kind) => notify[kind](message),\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.success('Mention delivered.')\n return { responseIds: delivery.response_ids || [] }\n },\n getAgentStatus: async (responseId) => (await arbi.assistant.getResponse(responseId)).status,\n }),\n [arbi, apiUrl, user?.name, members, ensureWorkspaceOpen, fontBaseUrl, queries, workspaceId]\n )\n return adapter\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chat/open-document.ts"],"names":["useRef","useEffect","useSyncExternalStore","parseVersionRef"],"mappings":";;;;;;AA2CO,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,C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AA,QAAA,IAAW;AACb,EAAA,OAAO,KAAA,CAAM,UAAA;AACf","file":"chunk-SWQX6CTT.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.\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"]}
|