@athenaintel/react 0.9.14 → 0.9.15
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/dist/index.cjs +286 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +286 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { EmptyMessagePartComponent } from '@assistant-ui/react';
|
|
|
7
7
|
import { FC } from 'react';
|
|
8
8
|
import { ForwardRefExoticComponent } from 'react';
|
|
9
9
|
import { JSX } from 'react/jsx-runtime';
|
|
10
|
+
import { PersistOptions } from 'zustand/middleware';
|
|
10
11
|
import * as React_2 from 'react';
|
|
11
12
|
import { ReactNode } from 'react';
|
|
12
13
|
import { ReasoningMessagePartComponent } from '@assistant-ui/react';
|
|
@@ -1025,7 +1026,19 @@ export declare interface UseAssetEmbedResult {
|
|
|
1025
1026
|
error: string | null;
|
|
1026
1027
|
}
|
|
1027
1028
|
|
|
1028
|
-
export declare const useAssetPanelStore: UseBoundStore<StoreApi<AssetPanelState
|
|
1029
|
+
export declare const useAssetPanelStore: UseBoundStore<Omit<StoreApi<AssetPanelState>, "setState" | "persist"> & {
|
|
1030
|
+
setState(partial: AssetPanelState | Partial<AssetPanelState> | ((state: AssetPanelState) => AssetPanelState | Partial<AssetPanelState>), replace?: false | undefined): unknown;
|
|
1031
|
+
setState(state: AssetPanelState | ((state: AssetPanelState) => AssetPanelState), replace: true): unknown;
|
|
1032
|
+
persist: {
|
|
1033
|
+
setOptions: (options: Partial<PersistOptions<AssetPanelState, unknown, unknown>>) => void;
|
|
1034
|
+
clearStorage: () => void;
|
|
1035
|
+
rehydrate: () => Promise<void> | void;
|
|
1036
|
+
hasHydrated: () => boolean;
|
|
1037
|
+
onHydrate: (fn: (state: AssetPanelState) => void) => () => void;
|
|
1038
|
+
onFinishHydration: (fn: (state: AssetPanelState) => void) => () => void;
|
|
1039
|
+
getOptions: () => Partial<PersistOptions<AssetPanelState, unknown, unknown>>;
|
|
1040
|
+
};
|
|
1041
|
+
}>;
|
|
1029
1042
|
|
|
1030
1043
|
export declare const useAthenaCitationLinkHandler: () => AthenaCitationLinkHandler;
|
|
1031
1044
|
|
package/dist/index.js
CHANGED
|
@@ -16483,7 +16483,7 @@ const createUrlWithFallback = (url, fallbackUrl) => {
|
|
|
16483
16483
|
return new URL(`${normalizeBaseUrl(fallbackUrl)}/`);
|
|
16484
16484
|
}
|
|
16485
16485
|
};
|
|
16486
|
-
const getHostname = (value) => {
|
|
16486
|
+
const getHostname$1 = (value) => {
|
|
16487
16487
|
if (!value) return null;
|
|
16488
16488
|
try {
|
|
16489
16489
|
return new URL(value).hostname;
|
|
@@ -16524,7 +16524,7 @@ function deriveAthenaAppUrl({
|
|
|
16524
16524
|
sourcePort: "8000"
|
|
16525
16525
|
});
|
|
16526
16526
|
if (workspaceAppUrl) return workspaceAppUrl;
|
|
16527
|
-
const backendHostname = getHostname(backendUrl);
|
|
16527
|
+
const backendHostname = getHostname$1(backendUrl);
|
|
16528
16528
|
if (backendHostname === "api.athenaintel.com") {
|
|
16529
16529
|
return ATHENA_ENVIRONMENT_URLS.production.appUrl;
|
|
16530
16530
|
}
|
|
@@ -16538,7 +16538,7 @@ function deriveAthenaAppUrl({
|
|
|
16538
16538
|
sourcePort: "8787"
|
|
16539
16539
|
});
|
|
16540
16540
|
if (workspaceAppUrl) return workspaceAppUrl;
|
|
16541
|
-
const apiHostname = getHostname(apiUrl);
|
|
16541
|
+
const apiHostname = getHostname$1(apiUrl);
|
|
16542
16542
|
if (apiHostname === "sync.athenaintel.com") {
|
|
16543
16543
|
return ATHENA_ENVIRONMENT_URLS.production.appUrl;
|
|
16544
16544
|
}
|
|
@@ -58643,57 +58643,276 @@ const MentionExtension = Node3.create({
|
|
|
58643
58643
|
};
|
|
58644
58644
|
}
|
|
58645
58645
|
});
|
|
58646
|
-
|
|
58647
|
-
|
|
58648
|
-
|
|
58649
|
-
|
|
58650
|
-
|
|
58651
|
-
|
|
58652
|
-
|
|
58653
|
-
|
|
58654
|
-
|
|
58655
|
-
|
|
58656
|
-
|
|
58657
|
-
|
|
58658
|
-
|
|
58659
|
-
|
|
58660
|
-
|
|
58661
|
-
|
|
58662
|
-
) :
|
|
58663
|
-
|
|
58646
|
+
function createJSONStorage(getStorage, options) {
|
|
58647
|
+
let storage;
|
|
58648
|
+
try {
|
|
58649
|
+
storage = getStorage();
|
|
58650
|
+
} catch (e) {
|
|
58651
|
+
return;
|
|
58652
|
+
}
|
|
58653
|
+
const persistStorage = {
|
|
58654
|
+
getItem: (name) => {
|
|
58655
|
+
var _a2;
|
|
58656
|
+
const parse2 = (str2) => {
|
|
58657
|
+
if (str2 === null) {
|
|
58658
|
+
return null;
|
|
58659
|
+
}
|
|
58660
|
+
return JSON.parse(str2, void 0);
|
|
58661
|
+
};
|
|
58662
|
+
const str = (_a2 = storage.getItem(name)) != null ? _a2 : null;
|
|
58663
|
+
if (str instanceof Promise) {
|
|
58664
|
+
return str.then(parse2);
|
|
58665
|
+
}
|
|
58666
|
+
return parse2(str);
|
|
58667
|
+
},
|
|
58668
|
+
setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, void 0)),
|
|
58669
|
+
removeItem: (name) => storage.removeItem(name)
|
|
58670
|
+
};
|
|
58671
|
+
return persistStorage;
|
|
58672
|
+
}
|
|
58673
|
+
const toThenable = (fn) => (input) => {
|
|
58674
|
+
try {
|
|
58675
|
+
const result = fn(input);
|
|
58676
|
+
if (result instanceof Promise) {
|
|
58677
|
+
return result;
|
|
58664
58678
|
}
|
|
58665
|
-
|
|
58666
|
-
|
|
58667
|
-
|
|
58668
|
-
|
|
58679
|
+
return {
|
|
58680
|
+
then(onFulfilled) {
|
|
58681
|
+
return toThenable(onFulfilled)(result);
|
|
58682
|
+
},
|
|
58683
|
+
catch(_onRejected) {
|
|
58684
|
+
return this;
|
|
58685
|
+
}
|
|
58669
58686
|
};
|
|
58670
|
-
|
|
58671
|
-
|
|
58672
|
-
|
|
58673
|
-
|
|
58674
|
-
|
|
58675
|
-
|
|
58676
|
-
|
|
58687
|
+
} catch (e) {
|
|
58688
|
+
return {
|
|
58689
|
+
then(_onFulfilled) {
|
|
58690
|
+
return this;
|
|
58691
|
+
},
|
|
58692
|
+
catch(onRejected) {
|
|
58693
|
+
return toThenable(onRejected)(e);
|
|
58694
|
+
}
|
|
58695
|
+
};
|
|
58696
|
+
}
|
|
58697
|
+
};
|
|
58698
|
+
const persistImpl = (config2, baseOptions) => (set2, get2, api) => {
|
|
58699
|
+
let options = {
|
|
58700
|
+
storage: createJSONStorage(() => window.localStorage),
|
|
58701
|
+
partialize: (state) => state,
|
|
58702
|
+
version: 0,
|
|
58703
|
+
merge: (persistedState, currentState) => ({
|
|
58704
|
+
...currentState,
|
|
58705
|
+
...persistedState
|
|
58706
|
+
}),
|
|
58707
|
+
...baseOptions
|
|
58708
|
+
};
|
|
58709
|
+
let hasHydrated = false;
|
|
58710
|
+
let hydrationVersion = 0;
|
|
58711
|
+
const hydrationListeners = /* @__PURE__ */ new Set();
|
|
58712
|
+
const finishHydrationListeners = /* @__PURE__ */ new Set();
|
|
58713
|
+
let storage = options.storage;
|
|
58714
|
+
if (!storage) {
|
|
58715
|
+
return config2(
|
|
58716
|
+
(...args) => {
|
|
58717
|
+
console.warn(
|
|
58718
|
+
`[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
|
|
58719
|
+
);
|
|
58720
|
+
set2(...args);
|
|
58721
|
+
},
|
|
58722
|
+
get2,
|
|
58723
|
+
api
|
|
58724
|
+
);
|
|
58725
|
+
}
|
|
58726
|
+
const setItem = () => {
|
|
58727
|
+
const state = options.partialize({ ...get2() });
|
|
58728
|
+
return storage.setItem(options.name, {
|
|
58729
|
+
state,
|
|
58730
|
+
version: options.version
|
|
58731
|
+
});
|
|
58732
|
+
};
|
|
58733
|
+
const savedSetState = api.setState;
|
|
58734
|
+
api.setState = (state, replace2) => {
|
|
58735
|
+
savedSetState(state, replace2);
|
|
58736
|
+
return setItem();
|
|
58737
|
+
};
|
|
58738
|
+
const configResult = config2(
|
|
58739
|
+
(...args) => {
|
|
58740
|
+
set2(...args);
|
|
58741
|
+
return setItem();
|
|
58742
|
+
},
|
|
58743
|
+
get2,
|
|
58744
|
+
api
|
|
58745
|
+
);
|
|
58746
|
+
api.getInitialState = () => configResult;
|
|
58747
|
+
let stateFromStorage;
|
|
58748
|
+
const hydrate = () => {
|
|
58749
|
+
var _a2, _b;
|
|
58750
|
+
if (!storage) return;
|
|
58751
|
+
const currentVersion = ++hydrationVersion;
|
|
58752
|
+
hasHydrated = false;
|
|
58753
|
+
hydrationListeners.forEach((cb) => {
|
|
58754
|
+
var _a22;
|
|
58755
|
+
return cb((_a22 = get2()) != null ? _a22 : configResult);
|
|
58756
|
+
});
|
|
58757
|
+
const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a2 = get2()) != null ? _a2 : configResult)) || void 0;
|
|
58758
|
+
return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
|
|
58759
|
+
if (deserializedStorageValue) {
|
|
58760
|
+
if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
|
|
58761
|
+
if (options.migrate) {
|
|
58762
|
+
const migration = options.migrate(
|
|
58763
|
+
deserializedStorageValue.state,
|
|
58764
|
+
deserializedStorageValue.version
|
|
58765
|
+
);
|
|
58766
|
+
if (migration instanceof Promise) {
|
|
58767
|
+
return migration.then((result) => [true, result]);
|
|
58768
|
+
}
|
|
58769
|
+
return [true, migration];
|
|
58770
|
+
}
|
|
58771
|
+
console.error(
|
|
58772
|
+
`State loaded from storage couldn't be migrated since no migrate function was provided`
|
|
58773
|
+
);
|
|
58774
|
+
} else {
|
|
58775
|
+
return [false, deserializedStorageValue.state];
|
|
58776
|
+
}
|
|
58777
|
+
}
|
|
58778
|
+
return [false, void 0];
|
|
58779
|
+
}).then((migrationResult) => {
|
|
58780
|
+
var _a22;
|
|
58781
|
+
if (currentVersion !== hydrationVersion) {
|
|
58782
|
+
return;
|
|
58783
|
+
}
|
|
58784
|
+
const [migrated, migratedState] = migrationResult;
|
|
58785
|
+
stateFromStorage = options.merge(
|
|
58786
|
+
migratedState,
|
|
58787
|
+
(_a22 = get2()) != null ? _a22 : configResult
|
|
58788
|
+
);
|
|
58789
|
+
set2(stateFromStorage, true);
|
|
58790
|
+
if (migrated) {
|
|
58791
|
+
return setItem();
|
|
58792
|
+
}
|
|
58793
|
+
}).then(() => {
|
|
58794
|
+
if (currentVersion !== hydrationVersion) {
|
|
58795
|
+
return;
|
|
58796
|
+
}
|
|
58797
|
+
postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);
|
|
58798
|
+
stateFromStorage = get2();
|
|
58799
|
+
hasHydrated = true;
|
|
58800
|
+
finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
|
|
58801
|
+
}).catch((e) => {
|
|
58802
|
+
if (currentVersion !== hydrationVersion) {
|
|
58803
|
+
return;
|
|
58804
|
+
}
|
|
58805
|
+
postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
|
|
58806
|
+
});
|
|
58807
|
+
};
|
|
58808
|
+
api.persist = {
|
|
58809
|
+
setOptions: (newOptions) => {
|
|
58810
|
+
options = {
|
|
58811
|
+
...options,
|
|
58812
|
+
...newOptions
|
|
58813
|
+
};
|
|
58814
|
+
if (newOptions.storage) {
|
|
58815
|
+
storage = newOptions.storage;
|
|
58816
|
+
}
|
|
58817
|
+
},
|
|
58818
|
+
clearStorage: () => {
|
|
58819
|
+
storage == null ? void 0 : storage.removeItem(options.name);
|
|
58820
|
+
},
|
|
58821
|
+
getOptions: () => options,
|
|
58822
|
+
rehydrate: () => hydrate(),
|
|
58823
|
+
hasHydrated: () => hasHydrated,
|
|
58824
|
+
onHydrate: (cb) => {
|
|
58825
|
+
hydrationListeners.add(cb);
|
|
58826
|
+
return () => {
|
|
58827
|
+
hydrationListeners.delete(cb);
|
|
58828
|
+
};
|
|
58829
|
+
},
|
|
58830
|
+
onFinishHydration: (cb) => {
|
|
58831
|
+
finishHydrationListeners.add(cb);
|
|
58832
|
+
return () => {
|
|
58833
|
+
finishHydrationListeners.delete(cb);
|
|
58834
|
+
};
|
|
58677
58835
|
}
|
|
58678
|
-
|
|
58679
|
-
|
|
58680
|
-
|
|
58681
|
-
|
|
58682
|
-
|
|
58683
|
-
|
|
58684
|
-
|
|
58685
|
-
|
|
58686
|
-
|
|
58687
|
-
|
|
58688
|
-
|
|
58689
|
-
|
|
58836
|
+
};
|
|
58837
|
+
if (!options.skipHydration) {
|
|
58838
|
+
hydrate();
|
|
58839
|
+
}
|
|
58840
|
+
return stateFromStorage || configResult;
|
|
58841
|
+
};
|
|
58842
|
+
const persist = persistImpl;
|
|
58843
|
+
const useAssetPanelStore = create()(
|
|
58844
|
+
persist(
|
|
58845
|
+
(set2, get2) => ({
|
|
58846
|
+
isOpen: false,
|
|
58847
|
+
tabs: [],
|
|
58848
|
+
activeTabId: null,
|
|
58849
|
+
viewMode: "tabs",
|
|
58850
|
+
isFullscreen: false,
|
|
58851
|
+
assetPanelHostCount: 0,
|
|
58852
|
+
autoOpenGeneration: 0,
|
|
58853
|
+
autoOpenedAssets: /* @__PURE__ */ new Map(),
|
|
58854
|
+
registerAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: state.assetPanelHostCount + 1 })),
|
|
58855
|
+
unregisterAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: Math.max(0, state.assetPanelHostCount - 1) })),
|
|
58856
|
+
openAsset: (assetId, meta) => set2((s) => {
|
|
58857
|
+
const existing = s.tabs.find((t) => t.id === assetId);
|
|
58858
|
+
if (existing) {
|
|
58859
|
+
const tabs = meta ? s.tabs.map(
|
|
58860
|
+
(t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
|
|
58861
|
+
) : s.tabs;
|
|
58862
|
+
return { isOpen: true, tabs, activeTabId: assetId };
|
|
58863
|
+
}
|
|
58864
|
+
const newTab = {
|
|
58865
|
+
id: assetId,
|
|
58866
|
+
name: (meta == null ? void 0 : meta.name) ?? null,
|
|
58867
|
+
type: (meta == null ? void 0 : meta.type) ?? "unknown"
|
|
58868
|
+
};
|
|
58869
|
+
return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
|
|
58870
|
+
}),
|
|
58871
|
+
closeTab: (assetId) => set2((s) => {
|
|
58872
|
+
var _a2;
|
|
58873
|
+
const tabs = s.tabs.filter((t) => t.id !== assetId);
|
|
58874
|
+
if (tabs.length === 0) {
|
|
58875
|
+
return { isOpen: false, tabs: [], activeTabId: null, isFullscreen: false };
|
|
58876
|
+
}
|
|
58877
|
+
const activeTabId = s.activeTabId === assetId ? ((_a2 = tabs[Math.min(s.tabs.findIndex((t) => t.id === assetId), tabs.length - 1)]) == null ? void 0 : _a2.id) ?? null : s.activeTabId;
|
|
58878
|
+
return { tabs, activeTabId };
|
|
58879
|
+
}),
|
|
58880
|
+
setActiveTab: (assetId) => set2({ activeTabId: assetId, viewMode: "tabs" }),
|
|
58881
|
+
setViewMode: (mode) => set2({ viewMode: mode }),
|
|
58882
|
+
closePanel: () => set2({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
|
|
58883
|
+
toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen })),
|
|
58884
|
+
resetAutoOpen: () => set2((s) => ({ autoOpenGeneration: s.autoOpenGeneration + 1 })),
|
|
58885
|
+
markAutoOpened: (assetId) => {
|
|
58886
|
+
const state = get2();
|
|
58887
|
+
if (state.autoOpenedAssets.get(assetId) === state.autoOpenGeneration) {
|
|
58888
|
+
return false;
|
|
58889
|
+
}
|
|
58890
|
+
state.autoOpenedAssets.set(assetId, state.autoOpenGeneration);
|
|
58891
|
+
return true;
|
|
58892
|
+
}
|
|
58893
|
+
}),
|
|
58894
|
+
{
|
|
58895
|
+
name: "athena-react-asset-panel",
|
|
58896
|
+
partialize: ({
|
|
58897
|
+
isOpen,
|
|
58898
|
+
tabs,
|
|
58899
|
+
activeTabId,
|
|
58900
|
+
viewMode,
|
|
58901
|
+
isFullscreen
|
|
58902
|
+
}) => ({
|
|
58903
|
+
isOpen,
|
|
58904
|
+
tabs,
|
|
58905
|
+
activeTabId,
|
|
58906
|
+
viewMode,
|
|
58907
|
+
isFullscreen
|
|
58908
|
+
}),
|
|
58909
|
+
storage: createJSONStorage(() => sessionStorage)
|
|
58690
58910
|
}
|
|
58691
|
-
|
|
58692
|
-
|
|
58693
|
-
}
|
|
58694
|
-
}));
|
|
58911
|
+
)
|
|
58912
|
+
);
|
|
58695
58913
|
const ATHENA_APP_HOSTNAMES = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
|
|
58696
58914
|
const ATHENA_PREVIEW_HOSTNAME_SUFFIX = ".previews.athenaintel.com";
|
|
58915
|
+
const ATHENA_WORKSPACE_HOSTNAME_SUFFIXES = [".app.athenaintel.com", ".staging-app.athenaintel.com"];
|
|
58697
58916
|
const ASSET_TYPE_ALIASES = {
|
|
58698
58917
|
document: "document",
|
|
58699
58918
|
notebook: "notebook",
|
|
@@ -58723,6 +58942,20 @@ const getOrigin = (value) => {
|
|
|
58723
58942
|
return null;
|
|
58724
58943
|
}
|
|
58725
58944
|
};
|
|
58945
|
+
const getHostname = (value) => {
|
|
58946
|
+
if (!value) {
|
|
58947
|
+
return null;
|
|
58948
|
+
}
|
|
58949
|
+
try {
|
|
58950
|
+
return new URL(value).hostname.toLowerCase();
|
|
58951
|
+
} catch {
|
|
58952
|
+
return null;
|
|
58953
|
+
}
|
|
58954
|
+
};
|
|
58955
|
+
const matchesHostnameOrSubdomain = ({
|
|
58956
|
+
hostname,
|
|
58957
|
+
candidateHostname
|
|
58958
|
+
}) => hostname === candidateHostname || hostname.endsWith(`.${candidateHostname}`);
|
|
58726
58959
|
const getCurrentOrigin = () => {
|
|
58727
58960
|
if (typeof window === "undefined") {
|
|
58728
58961
|
return null;
|
|
@@ -58745,7 +58978,11 @@ const isAthenaAppUrl = ({
|
|
|
58745
58978
|
appUrl
|
|
58746
58979
|
}) => {
|
|
58747
58980
|
const hostname = url.hostname.toLowerCase();
|
|
58748
|
-
if (ATHENA_APP_HOSTNAMES.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX)) {
|
|
58981
|
+
if (ATHENA_APP_HOSTNAMES.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX) || ATHENA_WORKSPACE_HOSTNAME_SUFFIXES.some((suffix) => hostname.endsWith(suffix))) {
|
|
58982
|
+
return true;
|
|
58983
|
+
}
|
|
58984
|
+
const configuredHostname = getHostname(appUrl);
|
|
58985
|
+
if (configuredHostname && matchesHostnameOrSubdomain({ hostname, candidateHostname: configuredHostname })) {
|
|
58749
58986
|
return true;
|
|
58750
58987
|
}
|
|
58751
58988
|
const configuredOrigin = getOrigin(appUrl);
|