@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.cjs
CHANGED
|
@@ -16501,7 +16501,7 @@ const createUrlWithFallback = (url, fallbackUrl) => {
|
|
|
16501
16501
|
return new URL(`${normalizeBaseUrl(fallbackUrl)}/`);
|
|
16502
16502
|
}
|
|
16503
16503
|
};
|
|
16504
|
-
const getHostname = (value) => {
|
|
16504
|
+
const getHostname$1 = (value) => {
|
|
16505
16505
|
if (!value) return null;
|
|
16506
16506
|
try {
|
|
16507
16507
|
return new URL(value).hostname;
|
|
@@ -16542,7 +16542,7 @@ function deriveAthenaAppUrl({
|
|
|
16542
16542
|
sourcePort: "8000"
|
|
16543
16543
|
});
|
|
16544
16544
|
if (workspaceAppUrl) return workspaceAppUrl;
|
|
16545
|
-
const backendHostname = getHostname(backendUrl);
|
|
16545
|
+
const backendHostname = getHostname$1(backendUrl);
|
|
16546
16546
|
if (backendHostname === "api.athenaintel.com") {
|
|
16547
16547
|
return ATHENA_ENVIRONMENT_URLS.production.appUrl;
|
|
16548
16548
|
}
|
|
@@ -16556,7 +16556,7 @@ function deriveAthenaAppUrl({
|
|
|
16556
16556
|
sourcePort: "8787"
|
|
16557
16557
|
});
|
|
16558
16558
|
if (workspaceAppUrl) return workspaceAppUrl;
|
|
16559
|
-
const apiHostname = getHostname(apiUrl);
|
|
16559
|
+
const apiHostname = getHostname$1(apiUrl);
|
|
16560
16560
|
if (apiHostname === "sync.athenaintel.com") {
|
|
16561
16561
|
return ATHENA_ENVIRONMENT_URLS.production.appUrl;
|
|
16562
16562
|
}
|
|
@@ -58661,57 +58661,276 @@ const MentionExtension = Node3.create({
|
|
|
58661
58661
|
};
|
|
58662
58662
|
}
|
|
58663
58663
|
});
|
|
58664
|
-
|
|
58665
|
-
|
|
58666
|
-
|
|
58667
|
-
|
|
58668
|
-
|
|
58669
|
-
|
|
58670
|
-
|
|
58671
|
-
|
|
58672
|
-
|
|
58673
|
-
|
|
58674
|
-
|
|
58675
|
-
|
|
58676
|
-
|
|
58677
|
-
|
|
58678
|
-
|
|
58679
|
-
|
|
58680
|
-
) :
|
|
58681
|
-
|
|
58664
|
+
function createJSONStorage(getStorage, options) {
|
|
58665
|
+
let storage;
|
|
58666
|
+
try {
|
|
58667
|
+
storage = getStorage();
|
|
58668
|
+
} catch (e) {
|
|
58669
|
+
return;
|
|
58670
|
+
}
|
|
58671
|
+
const persistStorage = {
|
|
58672
|
+
getItem: (name) => {
|
|
58673
|
+
var _a2;
|
|
58674
|
+
const parse2 = (str2) => {
|
|
58675
|
+
if (str2 === null) {
|
|
58676
|
+
return null;
|
|
58677
|
+
}
|
|
58678
|
+
return JSON.parse(str2, void 0);
|
|
58679
|
+
};
|
|
58680
|
+
const str = (_a2 = storage.getItem(name)) != null ? _a2 : null;
|
|
58681
|
+
if (str instanceof Promise) {
|
|
58682
|
+
return str.then(parse2);
|
|
58683
|
+
}
|
|
58684
|
+
return parse2(str);
|
|
58685
|
+
},
|
|
58686
|
+
setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, void 0)),
|
|
58687
|
+
removeItem: (name) => storage.removeItem(name)
|
|
58688
|
+
};
|
|
58689
|
+
return persistStorage;
|
|
58690
|
+
}
|
|
58691
|
+
const toThenable = (fn) => (input) => {
|
|
58692
|
+
try {
|
|
58693
|
+
const result = fn(input);
|
|
58694
|
+
if (result instanceof Promise) {
|
|
58695
|
+
return result;
|
|
58682
58696
|
}
|
|
58683
|
-
|
|
58684
|
-
|
|
58685
|
-
|
|
58686
|
-
|
|
58697
|
+
return {
|
|
58698
|
+
then(onFulfilled) {
|
|
58699
|
+
return toThenable(onFulfilled)(result);
|
|
58700
|
+
},
|
|
58701
|
+
catch(_onRejected) {
|
|
58702
|
+
return this;
|
|
58703
|
+
}
|
|
58687
58704
|
};
|
|
58688
|
-
|
|
58689
|
-
|
|
58690
|
-
|
|
58691
|
-
|
|
58692
|
-
|
|
58693
|
-
|
|
58694
|
-
|
|
58705
|
+
} catch (e) {
|
|
58706
|
+
return {
|
|
58707
|
+
then(_onFulfilled) {
|
|
58708
|
+
return this;
|
|
58709
|
+
},
|
|
58710
|
+
catch(onRejected) {
|
|
58711
|
+
return toThenable(onRejected)(e);
|
|
58712
|
+
}
|
|
58713
|
+
};
|
|
58714
|
+
}
|
|
58715
|
+
};
|
|
58716
|
+
const persistImpl = (config2, baseOptions) => (set2, get2, api) => {
|
|
58717
|
+
let options = {
|
|
58718
|
+
storage: createJSONStorage(() => window.localStorage),
|
|
58719
|
+
partialize: (state) => state,
|
|
58720
|
+
version: 0,
|
|
58721
|
+
merge: (persistedState, currentState) => ({
|
|
58722
|
+
...currentState,
|
|
58723
|
+
...persistedState
|
|
58724
|
+
}),
|
|
58725
|
+
...baseOptions
|
|
58726
|
+
};
|
|
58727
|
+
let hasHydrated = false;
|
|
58728
|
+
let hydrationVersion = 0;
|
|
58729
|
+
const hydrationListeners = /* @__PURE__ */ new Set();
|
|
58730
|
+
const finishHydrationListeners = /* @__PURE__ */ new Set();
|
|
58731
|
+
let storage = options.storage;
|
|
58732
|
+
if (!storage) {
|
|
58733
|
+
return config2(
|
|
58734
|
+
(...args) => {
|
|
58735
|
+
console.warn(
|
|
58736
|
+
`[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
|
|
58737
|
+
);
|
|
58738
|
+
set2(...args);
|
|
58739
|
+
},
|
|
58740
|
+
get2,
|
|
58741
|
+
api
|
|
58742
|
+
);
|
|
58743
|
+
}
|
|
58744
|
+
const setItem = () => {
|
|
58745
|
+
const state = options.partialize({ ...get2() });
|
|
58746
|
+
return storage.setItem(options.name, {
|
|
58747
|
+
state,
|
|
58748
|
+
version: options.version
|
|
58749
|
+
});
|
|
58750
|
+
};
|
|
58751
|
+
const savedSetState = api.setState;
|
|
58752
|
+
api.setState = (state, replace2) => {
|
|
58753
|
+
savedSetState(state, replace2);
|
|
58754
|
+
return setItem();
|
|
58755
|
+
};
|
|
58756
|
+
const configResult = config2(
|
|
58757
|
+
(...args) => {
|
|
58758
|
+
set2(...args);
|
|
58759
|
+
return setItem();
|
|
58760
|
+
},
|
|
58761
|
+
get2,
|
|
58762
|
+
api
|
|
58763
|
+
);
|
|
58764
|
+
api.getInitialState = () => configResult;
|
|
58765
|
+
let stateFromStorage;
|
|
58766
|
+
const hydrate = () => {
|
|
58767
|
+
var _a2, _b;
|
|
58768
|
+
if (!storage) return;
|
|
58769
|
+
const currentVersion = ++hydrationVersion;
|
|
58770
|
+
hasHydrated = false;
|
|
58771
|
+
hydrationListeners.forEach((cb) => {
|
|
58772
|
+
var _a22;
|
|
58773
|
+
return cb((_a22 = get2()) != null ? _a22 : configResult);
|
|
58774
|
+
});
|
|
58775
|
+
const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a2 = get2()) != null ? _a2 : configResult)) || void 0;
|
|
58776
|
+
return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
|
|
58777
|
+
if (deserializedStorageValue) {
|
|
58778
|
+
if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
|
|
58779
|
+
if (options.migrate) {
|
|
58780
|
+
const migration = options.migrate(
|
|
58781
|
+
deserializedStorageValue.state,
|
|
58782
|
+
deserializedStorageValue.version
|
|
58783
|
+
);
|
|
58784
|
+
if (migration instanceof Promise) {
|
|
58785
|
+
return migration.then((result) => [true, result]);
|
|
58786
|
+
}
|
|
58787
|
+
return [true, migration];
|
|
58788
|
+
}
|
|
58789
|
+
console.error(
|
|
58790
|
+
`State loaded from storage couldn't be migrated since no migrate function was provided`
|
|
58791
|
+
);
|
|
58792
|
+
} else {
|
|
58793
|
+
return [false, deserializedStorageValue.state];
|
|
58794
|
+
}
|
|
58795
|
+
}
|
|
58796
|
+
return [false, void 0];
|
|
58797
|
+
}).then((migrationResult) => {
|
|
58798
|
+
var _a22;
|
|
58799
|
+
if (currentVersion !== hydrationVersion) {
|
|
58800
|
+
return;
|
|
58801
|
+
}
|
|
58802
|
+
const [migrated, migratedState] = migrationResult;
|
|
58803
|
+
stateFromStorage = options.merge(
|
|
58804
|
+
migratedState,
|
|
58805
|
+
(_a22 = get2()) != null ? _a22 : configResult
|
|
58806
|
+
);
|
|
58807
|
+
set2(stateFromStorage, true);
|
|
58808
|
+
if (migrated) {
|
|
58809
|
+
return setItem();
|
|
58810
|
+
}
|
|
58811
|
+
}).then(() => {
|
|
58812
|
+
if (currentVersion !== hydrationVersion) {
|
|
58813
|
+
return;
|
|
58814
|
+
}
|
|
58815
|
+
postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);
|
|
58816
|
+
stateFromStorage = get2();
|
|
58817
|
+
hasHydrated = true;
|
|
58818
|
+
finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
|
|
58819
|
+
}).catch((e) => {
|
|
58820
|
+
if (currentVersion !== hydrationVersion) {
|
|
58821
|
+
return;
|
|
58822
|
+
}
|
|
58823
|
+
postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
|
|
58824
|
+
});
|
|
58825
|
+
};
|
|
58826
|
+
api.persist = {
|
|
58827
|
+
setOptions: (newOptions) => {
|
|
58828
|
+
options = {
|
|
58829
|
+
...options,
|
|
58830
|
+
...newOptions
|
|
58831
|
+
};
|
|
58832
|
+
if (newOptions.storage) {
|
|
58833
|
+
storage = newOptions.storage;
|
|
58834
|
+
}
|
|
58835
|
+
},
|
|
58836
|
+
clearStorage: () => {
|
|
58837
|
+
storage == null ? void 0 : storage.removeItem(options.name);
|
|
58838
|
+
},
|
|
58839
|
+
getOptions: () => options,
|
|
58840
|
+
rehydrate: () => hydrate(),
|
|
58841
|
+
hasHydrated: () => hasHydrated,
|
|
58842
|
+
onHydrate: (cb) => {
|
|
58843
|
+
hydrationListeners.add(cb);
|
|
58844
|
+
return () => {
|
|
58845
|
+
hydrationListeners.delete(cb);
|
|
58846
|
+
};
|
|
58847
|
+
},
|
|
58848
|
+
onFinishHydration: (cb) => {
|
|
58849
|
+
finishHydrationListeners.add(cb);
|
|
58850
|
+
return () => {
|
|
58851
|
+
finishHydrationListeners.delete(cb);
|
|
58852
|
+
};
|
|
58695
58853
|
}
|
|
58696
|
-
|
|
58697
|
-
|
|
58698
|
-
|
|
58699
|
-
|
|
58700
|
-
|
|
58701
|
-
|
|
58702
|
-
|
|
58703
|
-
|
|
58704
|
-
|
|
58705
|
-
|
|
58706
|
-
|
|
58707
|
-
|
|
58854
|
+
};
|
|
58855
|
+
if (!options.skipHydration) {
|
|
58856
|
+
hydrate();
|
|
58857
|
+
}
|
|
58858
|
+
return stateFromStorage || configResult;
|
|
58859
|
+
};
|
|
58860
|
+
const persist = persistImpl;
|
|
58861
|
+
const useAssetPanelStore = create()(
|
|
58862
|
+
persist(
|
|
58863
|
+
(set2, get2) => ({
|
|
58864
|
+
isOpen: false,
|
|
58865
|
+
tabs: [],
|
|
58866
|
+
activeTabId: null,
|
|
58867
|
+
viewMode: "tabs",
|
|
58868
|
+
isFullscreen: false,
|
|
58869
|
+
assetPanelHostCount: 0,
|
|
58870
|
+
autoOpenGeneration: 0,
|
|
58871
|
+
autoOpenedAssets: /* @__PURE__ */ new Map(),
|
|
58872
|
+
registerAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: state.assetPanelHostCount + 1 })),
|
|
58873
|
+
unregisterAssetPanelHost: () => set2((state) => ({ assetPanelHostCount: Math.max(0, state.assetPanelHostCount - 1) })),
|
|
58874
|
+
openAsset: (assetId, meta) => set2((s) => {
|
|
58875
|
+
const existing = s.tabs.find((t) => t.id === assetId);
|
|
58876
|
+
if (existing) {
|
|
58877
|
+
const tabs = meta ? s.tabs.map(
|
|
58878
|
+
(t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
|
|
58879
|
+
) : s.tabs;
|
|
58880
|
+
return { isOpen: true, tabs, activeTabId: assetId };
|
|
58881
|
+
}
|
|
58882
|
+
const newTab = {
|
|
58883
|
+
id: assetId,
|
|
58884
|
+
name: (meta == null ? void 0 : meta.name) ?? null,
|
|
58885
|
+
type: (meta == null ? void 0 : meta.type) ?? "unknown"
|
|
58886
|
+
};
|
|
58887
|
+
return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
|
|
58888
|
+
}),
|
|
58889
|
+
closeTab: (assetId) => set2((s) => {
|
|
58890
|
+
var _a2;
|
|
58891
|
+
const tabs = s.tabs.filter((t) => t.id !== assetId);
|
|
58892
|
+
if (tabs.length === 0) {
|
|
58893
|
+
return { isOpen: false, tabs: [], activeTabId: null, isFullscreen: false };
|
|
58894
|
+
}
|
|
58895
|
+
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;
|
|
58896
|
+
return { tabs, activeTabId };
|
|
58897
|
+
}),
|
|
58898
|
+
setActiveTab: (assetId) => set2({ activeTabId: assetId, viewMode: "tabs" }),
|
|
58899
|
+
setViewMode: (mode) => set2({ viewMode: mode }),
|
|
58900
|
+
closePanel: () => set2({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
|
|
58901
|
+
toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen })),
|
|
58902
|
+
resetAutoOpen: () => set2((s) => ({ autoOpenGeneration: s.autoOpenGeneration + 1 })),
|
|
58903
|
+
markAutoOpened: (assetId) => {
|
|
58904
|
+
const state = get2();
|
|
58905
|
+
if (state.autoOpenedAssets.get(assetId) === state.autoOpenGeneration) {
|
|
58906
|
+
return false;
|
|
58907
|
+
}
|
|
58908
|
+
state.autoOpenedAssets.set(assetId, state.autoOpenGeneration);
|
|
58909
|
+
return true;
|
|
58910
|
+
}
|
|
58911
|
+
}),
|
|
58912
|
+
{
|
|
58913
|
+
name: "athena-react-asset-panel",
|
|
58914
|
+
partialize: ({
|
|
58915
|
+
isOpen,
|
|
58916
|
+
tabs,
|
|
58917
|
+
activeTabId,
|
|
58918
|
+
viewMode,
|
|
58919
|
+
isFullscreen
|
|
58920
|
+
}) => ({
|
|
58921
|
+
isOpen,
|
|
58922
|
+
tabs,
|
|
58923
|
+
activeTabId,
|
|
58924
|
+
viewMode,
|
|
58925
|
+
isFullscreen
|
|
58926
|
+
}),
|
|
58927
|
+
storage: createJSONStorage(() => sessionStorage)
|
|
58708
58928
|
}
|
|
58709
|
-
|
|
58710
|
-
|
|
58711
|
-
}
|
|
58712
|
-
}));
|
|
58929
|
+
)
|
|
58930
|
+
);
|
|
58713
58931
|
const ATHENA_APP_HOSTNAMES = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
|
|
58714
58932
|
const ATHENA_PREVIEW_HOSTNAME_SUFFIX = ".previews.athenaintel.com";
|
|
58933
|
+
const ATHENA_WORKSPACE_HOSTNAME_SUFFIXES = [".app.athenaintel.com", ".staging-app.athenaintel.com"];
|
|
58715
58934
|
const ASSET_TYPE_ALIASES = {
|
|
58716
58935
|
document: "document",
|
|
58717
58936
|
notebook: "notebook",
|
|
@@ -58741,6 +58960,20 @@ const getOrigin = (value) => {
|
|
|
58741
58960
|
return null;
|
|
58742
58961
|
}
|
|
58743
58962
|
};
|
|
58963
|
+
const getHostname = (value) => {
|
|
58964
|
+
if (!value) {
|
|
58965
|
+
return null;
|
|
58966
|
+
}
|
|
58967
|
+
try {
|
|
58968
|
+
return new URL(value).hostname.toLowerCase();
|
|
58969
|
+
} catch {
|
|
58970
|
+
return null;
|
|
58971
|
+
}
|
|
58972
|
+
};
|
|
58973
|
+
const matchesHostnameOrSubdomain = ({
|
|
58974
|
+
hostname,
|
|
58975
|
+
candidateHostname
|
|
58976
|
+
}) => hostname === candidateHostname || hostname.endsWith(`.${candidateHostname}`);
|
|
58744
58977
|
const getCurrentOrigin = () => {
|
|
58745
58978
|
if (typeof window === "undefined") {
|
|
58746
58979
|
return null;
|
|
@@ -58763,7 +58996,11 @@ const isAthenaAppUrl = ({
|
|
|
58763
58996
|
appUrl
|
|
58764
58997
|
}) => {
|
|
58765
58998
|
const hostname = url.hostname.toLowerCase();
|
|
58766
|
-
if (ATHENA_APP_HOSTNAMES.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX)) {
|
|
58999
|
+
if (ATHENA_APP_HOSTNAMES.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX) || ATHENA_WORKSPACE_HOSTNAME_SUFFIXES.some((suffix) => hostname.endsWith(suffix))) {
|
|
59000
|
+
return true;
|
|
59001
|
+
}
|
|
59002
|
+
const configuredHostname = getHostname(appUrl);
|
|
59003
|
+
if (configuredHostname && matchesHostnameOrSubdomain({ hostname, candidateHostname: configuredHostname })) {
|
|
58767
59004
|
return true;
|
|
58768
59005
|
}
|
|
58769
59006
|
const configuredOrigin = getOrigin(appUrl);
|