local-operator-ui 0.2.3 → 0.3.0

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.
Binary file
Binary file
@@ -2966,16 +2966,19 @@ var Action;
2966
2966
  Action2["Replace"] = "REPLACE";
2967
2967
  })(Action || (Action = {}));
2968
2968
  const PopStateEventType = "popstate";
2969
- function createBrowserHistory(options) {
2969
+ function createHashHistory(options) {
2970
2970
  if (options === void 0) {
2971
2971
  options = {};
2972
2972
  }
2973
- function createBrowserLocation(window2, globalHistory) {
2973
+ function createHashLocation(window2, globalHistory) {
2974
2974
  let {
2975
- pathname,
2976
- search: search2,
2977
- hash: hash2
2978
- } = window2.location;
2975
+ pathname = "/",
2976
+ search: search2 = "",
2977
+ hash: hash2 = ""
2978
+ } = parsePath(window2.location.hash.substr(1));
2979
+ if (!pathname.startsWith("/") && !pathname.startsWith(".")) {
2980
+ pathname = "/" + pathname;
2981
+ }
2979
2982
  return createLocation(
2980
2983
  "",
2981
2984
  {
@@ -2988,10 +2991,20 @@ function createBrowserHistory(options) {
2988
2991
  globalHistory.state && globalHistory.state.key || "default"
2989
2992
  );
2990
2993
  }
2991
- function createBrowserHref(window2, to) {
2992
- return typeof to === "string" ? to : createPath(to);
2994
+ function createHashHref(window2, to) {
2995
+ let base = window2.document.querySelector("base");
2996
+ let href = "";
2997
+ if (base && base.getAttribute("href")) {
2998
+ let url = window2.location.href;
2999
+ let hashIndex = url.indexOf("#");
3000
+ href = hashIndex === -1 ? url : url.slice(0, hashIndex);
3001
+ }
3002
+ return href + "#" + (typeof to === "string" ? to : createPath(to));
3003
+ }
3004
+ function validateHashLocation(location, to) {
3005
+ warning(location.pathname.charAt(0) === "/", "relative pathnames are not supported in hash history.push(" + JSON.stringify(to) + ")");
2993
3006
  }
2994
- return getUrlBasedHistory(createBrowserLocation, createBrowserHref, null, options);
3007
+ return getUrlBasedHistory(createHashLocation, createHashHref, validateHashLocation, options);
2995
3008
  }
2996
3009
  function invariant(value, message2) {
2997
3010
  if (value === false || value === null || typeof value === "undefined") {
@@ -3104,6 +3117,7 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
3104
3117
  function push2(to, state) {
3105
3118
  action = Action.Push;
3106
3119
  let location = createLocation(history.location, to, state);
3120
+ if (validateLocation) validateLocation(location, to);
3107
3121
  index2 = getIndex() + 1;
3108
3122
  let historyState = getHistoryState(location, index2);
3109
3123
  let url = history.createHref(location);
@@ -3126,6 +3140,7 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
3126
3140
  function replace2(to, state) {
3127
3141
  action = Action.Replace;
3128
3142
  let location = createLocation(history.location, to, state);
3143
+ if (validateLocation) validateLocation(location, to);
3129
3144
  index2 = getIndex();
3130
3145
  let historyState = getHistoryState(location, index2);
3131
3146
  let url = history.createHref(location);
@@ -4134,16 +4149,16 @@ try {
4134
4149
  }
4135
4150
  const START_TRANSITION = "startTransition";
4136
4151
  const startTransitionImpl = React[START_TRANSITION];
4137
- function BrowserRouter(_ref4) {
4152
+ function HashRouter(_ref5) {
4138
4153
  let {
4139
4154
  basename: basename2,
4140
4155
  children,
4141
4156
  future,
4142
4157
  window: window2
4143
- } = _ref4;
4158
+ } = _ref5;
4144
4159
  let historyRef = reactExports.useRef();
4145
4160
  if (historyRef.current == null) {
4146
- historyRef.current = createBrowserHistory({
4161
+ historyRef.current = createHashHistory({
4147
4162
  window: window2,
4148
4163
  v5Compat: true
4149
4164
  });
@@ -34519,16 +34534,32 @@ const ChatLayout = ({ sidebar, content: content2 }) => {
34519
34534
  /* @__PURE__ */ jsxRuntimeExports.jsx(ContentContainer$4, { children: content2 })
34520
34535
  ] });
34521
34536
  };
34537
+ const normalizePath = (path2) => {
34538
+ return path2.replace(/\\/g, "/");
34539
+ };
34540
+ const getCurrentPath = () => {
34541
+ if (window.location.hash) {
34542
+ return normalizePath(window.location.hash.substring(1));
34543
+ }
34544
+ return normalizePath(window.location.pathname);
34545
+ };
34546
+ const pathIncludes = (path2, segment) => {
34547
+ return normalizePath(path2).includes(segment);
34548
+ };
34522
34549
  const useAgentRouteParam = () => {
34523
34550
  const { agentId } = useParams();
34524
34551
  const navigate = useNavigate();
34552
+ const getCurrentBasePath = () => {
34553
+ const currentPath = getCurrentPath();
34554
+ return pathIncludes(currentPath, "/chat") ? "chat" : "agents";
34555
+ };
34525
34556
  const navigateToAgent = (id, path2) => {
34526
34557
  if (!id) return;
34527
- const basePath = path2 || (window.location.pathname.includes("/chat") ? "chat" : "agents");
34558
+ const basePath = path2 || getCurrentBasePath();
34528
34559
  navigate(`/${basePath}/${id}`);
34529
34560
  };
34530
34561
  const clearAgentId = (path2) => {
34531
- const basePath = path2 || (window.location.pathname.includes("/chat") ? "chat" : "agents");
34562
+ const basePath = path2 || getCurrentBasePath();
34532
34563
  navigate(`/${basePath}`);
34533
34564
  };
34534
34565
  return {
@@ -34538,14 +34569,14 @@ const useAgentRouteParam = () => {
34538
34569
  };
34539
34570
  };
34540
34571
  const useCurrentView = () => {
34541
- const path2 = window.location.pathname;
34542
- if (path2.startsWith("/chat")) {
34572
+ const currentPath = getCurrentPath();
34573
+ if (pathIncludes(currentPath, "/chat")) {
34543
34574
  return "chat";
34544
34575
  }
34545
- if (path2.startsWith("/agents")) {
34576
+ if (pathIncludes(currentPath, "/agents")) {
34546
34577
  return "agents";
34547
34578
  }
34548
- if (path2.startsWith("/settings")) {
34579
+ if (pathIncludes(currentPath, "/settings")) {
34549
34580
  return "settings";
34550
34581
  }
34551
34582
  return "chat";
@@ -114865,7 +114896,7 @@ document.addEventListener("DOMContentLoaded", () => {
114865
114896
  root2.render(
114866
114897
  /* @__PURE__ */ jsxRuntimeExports.jsx(React$1.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(ThemeProvider, { children: [
114867
114898
  /* @__PURE__ */ jsxRuntimeExports.jsx(CssBaseline, {}),
114868
- /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BrowserRouter, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(App, {}) }) }),
114899
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(HashRouter, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(App, {}) }) }),
114869
114900
  /* @__PURE__ */ jsxRuntimeExports.jsx(ThemedToastContainer, {}),
114870
114901
  false
114871
114902
  ] }) }) })
@@ -8,7 +8,7 @@
8
8
  <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
9
9
  <meta http-equiv="Content-Security-Policy"
10
10
  content="default-src 'self'; connect-src 'self' http://localhost:1111 http://127.0.0.1:1111; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: http://localhost:1111 http://127.0.0.1:1111; media-src 'self' http://localhost:1111 http://127.0.0.1:1111; font-src 'self'" />
11
- <script type="module" crossorigin src="./assets/index-CLRsdWoU.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-Co8kqjrD.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="./assets/error-boundary-GcWSKAk-.js">
13
13
  <link rel="stylesheet" crossorigin href="./assets/error-boundary-B9KBGB-g.css">
14
14
  <link rel="stylesheet" crossorigin href="./assets/index-94BTFuhu.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "local-operator-ui",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "productName": "Local Operator",
5
5
  "description": "User interface for the Local Operator agent environment",
6
6
  "main": "./out/main/index.js",