@athenaintel/react 0.10.36 → 0.10.37
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 +8 -1
- package/dist/assets/AthenaAssetEmbed.d.ts +4 -1
- package/dist/assets/asset-embed-messages.d.ts +14 -0
- package/dist/index.cjs +25 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -3
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { AppendDocumentToolUI } from './tools/append-document-tool-ui';
|
|
|
27
27
|
export { getAssetInfo, tryParseJson } from './tools/asset-utils';
|
|
28
28
|
export { AthenaAssetEmbed } from './assets/AthenaAssetEmbed';
|
|
29
29
|
export type { AthenaAssetEmbedProps } from './assets/AthenaAssetEmbed';
|
|
30
|
-
export type { AthenaAssetCitationBehavior, AthenaAssetCitationClickEvent, AthenaAssetCitationReference, } from './assets/asset-embed-messages';
|
|
30
|
+
export type { AthenaAssetCitationAction, AthenaAssetCitationActionEvent, AthenaAssetCitationBehavior, AthenaAssetCitationClickEvent, AthenaAssetCitationReference, } from './assets/asset-embed-messages';
|
|
31
31
|
export { AssetPanel } from './assets/AssetPanel';
|
|
32
32
|
export type { AssetPanelProps } from './assets/AssetPanel';
|
|
33
33
|
export { AthenaLayout } from './assets/AthenaLayout';
|
package/dist/index.js
CHANGED
|
@@ -56215,6 +56215,7 @@ const AthenaUserMessage = ({
|
|
|
56215
56215
|
const ATHENA_ASSET_EMBED_READY_MESSAGE = "athena:asset-embed-ready";
|
|
56216
56216
|
const ATHENA_ASSET_EMBED_CONFIG_MESSAGE = "athena:asset-embed-config";
|
|
56217
56217
|
const ATHENA_ASSET_CITATION_CLICK_MESSAGE = "athena:asset-citation-click";
|
|
56218
|
+
const ATHENA_ASSET_CITATION_ACTION_MESSAGE = "athena:asset-citation-action";
|
|
56218
56219
|
function resolveAthenaAssetCitationBehavior({
|
|
56219
56220
|
citationBehavior,
|
|
56220
56221
|
hasCitationClickHandler
|
|
@@ -56222,12 +56223,22 @@ function resolveAthenaAssetCitationBehavior({
|
|
|
56222
56223
|
if (citationBehavior === "host" && !hasCitationClickHandler) return "browser";
|
|
56223
56224
|
return citationBehavior ?? (hasCitationClickHandler ? "host" : "browser");
|
|
56224
56225
|
}
|
|
56226
|
+
function resolveAthenaAssetCitationActionBehavior({
|
|
56227
|
+
citationActionBehavior,
|
|
56228
|
+
hasCitationActionHandler
|
|
56229
|
+
}) {
|
|
56230
|
+
if (citationActionBehavior === "host" && !hasCitationActionHandler) return "browser";
|
|
56231
|
+
return citationActionBehavior ?? (hasCitationActionHandler ? "host" : "browser");
|
|
56232
|
+
}
|
|
56225
56233
|
function isAthenaAssetEmbedReadyEvent(value) {
|
|
56226
56234
|
return typeof value === "object" && value !== null && "type" in value && value.type === ATHENA_ASSET_EMBED_READY_MESSAGE && "version" in value && value.version === 1;
|
|
56227
56235
|
}
|
|
56228
56236
|
function isAthenaAssetCitationClickEvent(value) {
|
|
56229
56237
|
return typeof value === "object" && value !== null && "type" in value && value.type === ATHENA_ASSET_CITATION_CLICK_MESSAGE && "version" in value && value.version === 1 && "reference" in value && typeof value.reference === "object" && value.reference !== null && "id" in value.reference && typeof value.reference.id === "string";
|
|
56230
56238
|
}
|
|
56239
|
+
function isAthenaAssetCitationActionEvent(value) {
|
|
56240
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === ATHENA_ASSET_CITATION_ACTION_MESSAGE && "version" in value && value.version === 1 && "action" in value && value.action === "open-in-spaces" && "reference" in value && typeof value.reference === "object" && value.reference !== null && "id" in value.reference && typeof value.reference.id === "string";
|
|
56241
|
+
}
|
|
56231
56242
|
function buildAssetEmbedRequestBody({
|
|
56232
56243
|
assetId,
|
|
56233
56244
|
readOnly,
|
|
@@ -56478,6 +56489,8 @@ const AthenaAssetEmbed = ({
|
|
|
56478
56489
|
expiresInSeconds,
|
|
56479
56490
|
citationBehavior,
|
|
56480
56491
|
onCitationClick,
|
|
56492
|
+
citationActionBehavior,
|
|
56493
|
+
onCitationAction,
|
|
56481
56494
|
onLoad,
|
|
56482
56495
|
onError,
|
|
56483
56496
|
loadingFallback,
|
|
@@ -56513,6 +56526,10 @@ const AthenaAssetEmbed = ({
|
|
|
56513
56526
|
citationBehavior,
|
|
56514
56527
|
hasCitationClickHandler: !!onCitationClick
|
|
56515
56528
|
});
|
|
56529
|
+
const effectiveCitationActionBehavior = resolveAthenaAssetCitationActionBehavior({
|
|
56530
|
+
citationActionBehavior,
|
|
56531
|
+
hasCitationActionHandler: !!onCitationAction
|
|
56532
|
+
});
|
|
56516
56533
|
const sendConfig = useCallback(() => {
|
|
56517
56534
|
var _a2, _b;
|
|
56518
56535
|
if (!targetOrigin) return;
|
|
@@ -56521,11 +56538,12 @@ const AthenaAssetEmbed = ({
|
|
|
56521
56538
|
type: ATHENA_ASSET_EMBED_CONFIG_MESSAGE,
|
|
56522
56539
|
version: 1,
|
|
56523
56540
|
...athenaConfig.token ? { token: athenaConfig.token } : {},
|
|
56524
|
-
citationBehavior: effectiveCitationBehavior
|
|
56541
|
+
citationBehavior: effectiveCitationBehavior,
|
|
56542
|
+
citationActionBehavior: effectiveCitationActionBehavior
|
|
56525
56543
|
},
|
|
56526
56544
|
targetOrigin
|
|
56527
56545
|
);
|
|
56528
|
-
}, [athenaConfig, effectiveCitationBehavior, targetOrigin]);
|
|
56546
|
+
}, [athenaConfig, effectiveCitationActionBehavior, effectiveCitationBehavior, targetOrigin]);
|
|
56529
56547
|
useEffect(() => {
|
|
56530
56548
|
if (!embedUrl || !targetOrigin) return;
|
|
56531
56549
|
const handleMessage = (event) => {
|
|
@@ -56537,11 +56555,15 @@ const AthenaAssetEmbed = ({
|
|
|
56537
56555
|
}
|
|
56538
56556
|
if (isAthenaAssetCitationClickEvent(event.data)) {
|
|
56539
56557
|
onCitationClick == null ? void 0 : onCitationClick(event.data);
|
|
56558
|
+
return;
|
|
56559
|
+
}
|
|
56560
|
+
if (isAthenaAssetCitationActionEvent(event.data)) {
|
|
56561
|
+
onCitationAction == null ? void 0 : onCitationAction(event.data);
|
|
56540
56562
|
}
|
|
56541
56563
|
};
|
|
56542
56564
|
window.addEventListener("message", handleMessage);
|
|
56543
56565
|
return () => window.removeEventListener("message", handleMessage);
|
|
56544
|
-
}, [embedUrl, onCitationClick, sendConfig, targetOrigin]);
|
|
56566
|
+
}, [embedUrl, onCitationAction, onCitationClick, sendConfig, targetOrigin]);
|
|
56545
56567
|
useEffect(() => {
|
|
56546
56568
|
if (!embedUrl) return;
|
|
56547
56569
|
sendConfig();
|