@wandelbots/nova-js 4.9.0 → 4.9.1
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/Nova-BoSIa0Mn.d.mts.map +1 -1
- package/dist/v2/index.mjs +5 -2
- package/dist/v2/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/Nova.ts +5 -2
- package/src/lib/context.ts +9 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/nova-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.9.
|
|
4
|
+
"version": "4.9.1",
|
|
5
5
|
"description": "Official JS client for the Wandelbots API",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"packageManager": "pnpm@11.9.0+sha512.bd682d5d03fe525ef7c9fd6780c6884d1e756ac4c9c9fe00c538782824310dcf90e3ddc4f53835f06dfaebd5085e41855e0bcbb3b60de2ac5bbab89e5036f03b",
|
package/src/lib/Nova.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { AxiosRequestConfig } from "axios"
|
|
|
3
3
|
import axios, { isAxiosError } from "axios"
|
|
4
4
|
import { AutoReconnectingWebsocket } from "./AutoReconnectingWebsocket.ts"
|
|
5
5
|
import { availableStorage } from "./availableStorage.ts"
|
|
6
|
-
import { isLocalhostDev } from "./context.ts"
|
|
6
|
+
import { hasBrowserLocation, isLocalhostDev } from "./context.ts"
|
|
7
7
|
import { parseNovaInstanceUrl } from "./converters.ts"
|
|
8
8
|
import { guardedPageReload } from "./errorHandling.ts"
|
|
9
9
|
import { loginWithAuth0 } from "./LoginWithAuth0.ts"
|
|
@@ -70,7 +70,10 @@ export class Nova {
|
|
|
70
70
|
return request
|
|
71
71
|
})
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
// The handler below redirects the page on a 401/403/503, which only works
|
|
74
|
+
// where a location exists. React Native has a `window` without one, and
|
|
75
|
+
// there the errors bubble up to the caller as they do in node.
|
|
76
|
+
if (hasBrowserLocation) {
|
|
74
77
|
axiosInstance.interceptors.response.use(
|
|
75
78
|
(r) => r,
|
|
76
79
|
async (error) => {
|
package/src/lib/context.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
// Some general checks about the context the nova-js code is running in
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// `typeof window` alone does not tell us whether a browser is present: React
|
|
4
|
+
// Native defines `window` as an alias of `global`, and that object has no
|
|
5
|
+
// `location`. Reading a property of it throws while this module loads, which
|
|
6
|
+
// breaks the import in a native app. Code that needs the browser APIs
|
|
7
|
+
// (`window.location`, `window.sessionStorage`) has to check this instead of
|
|
8
|
+
// `typeof window`.
|
|
9
|
+
export const hasBrowserLocation =
|
|
10
|
+
typeof window !== "undefined" && typeof window.location !== "undefined"
|
|
4
11
|
|
|
5
12
|
export const isLocalhostDev =
|
|
6
|
-
|
|
13
|
+
hasBrowserLocation &&
|
|
7
14
|
window.location.hostname === "localhost" &&
|
|
8
15
|
process.env.NODE_ENV === "development"
|