@wandelbots/nova-js 3.3.3 → 3.4.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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/{AutoReconnectingWebsocket-Qcrbm3Kb.d.cts → AutoReconnectingWebsocket-By6EZkXv.d.mts} +1 -1
  3. package/dist/{AutoReconnectingWebsocket-Qcrbm3Kb.d.cts.map → AutoReconnectingWebsocket-By6EZkXv.d.mts.map} +1 -1
  4. package/dist/{AutoReconnectingWebsocket-dHe-kceU.d.mts → AutoReconnectingWebsocket-dO-Xkvgo.d.cts} +1 -1
  5. package/dist/{AutoReconnectingWebsocket-dHe-kceU.d.mts.map → AutoReconnectingWebsocket-dO-Xkvgo.d.cts.map} +1 -1
  6. package/dist/{LoginWithAuth0-DBe9CXOr.mjs → LoginWithAuth0-BAGhME4k.mjs} +1 -1
  7. package/dist/{LoginWithAuth0-DBe9CXOr.mjs.map → LoginWithAuth0-BAGhME4k.mjs.map} +1 -1
  8. package/dist/{LoginWithAuth0-iXpPiCcz.cjs → LoginWithAuth0-qpkGkrJo.cjs} +11 -7
  9. package/dist/{LoginWithAuth0-iXpPiCcz.cjs.map → LoginWithAuth0-qpkGkrJo.cjs.map} +1 -1
  10. package/dist/{NovaClient-j40sHBBq.cjs → NovaClient-CKpbwv53.cjs} +29 -29
  11. package/dist/{NovaClient-j40sHBBq.cjs.map → NovaClient-CKpbwv53.cjs.map} +1 -1
  12. package/dist/{NovaClient-PNinV5c4.d.cts → NovaClient-CZDpg0Pn.d.cts} +2 -2
  13. package/dist/{NovaClient-C0GXOu4w.d.mts.map → NovaClient-CZDpg0Pn.d.cts.map} +1 -1
  14. package/dist/{NovaClient-C0GXOu4w.d.mts → NovaClient-D8C3LxqM.d.mts} +2 -2
  15. package/dist/{NovaClient-PNinV5c4.d.cts.map → NovaClient-D8C3LxqM.d.mts.map} +1 -1
  16. package/dist/{NovaClient-C27dk3Ql.mjs → NovaClient-DImFdEQS.mjs} +2 -2
  17. package/dist/{NovaClient-C27dk3Ql.mjs.map → NovaClient-DImFdEQS.mjs.map} +1 -1
  18. package/dist/index.cjs +2 -2
  19. package/dist/index.d.cts +2 -2
  20. package/dist/index.d.cts.map +1 -1
  21. package/dist/index.d.mts +2 -2
  22. package/dist/index.mjs +2 -2
  23. package/dist/lib/v1/index.cjs +5 -5
  24. package/dist/lib/v1/index.d.cts +2 -2
  25. package/dist/lib/v1/index.d.mts +2 -2
  26. package/dist/lib/v1/index.mjs +2 -2
  27. package/dist/lib/v2/index.cjs +24 -24
  28. package/dist/lib/v2/index.cjs.map +1 -1
  29. package/dist/lib/v2/index.d.cts +1 -1
  30. package/dist/lib/v2/index.d.cts.map +1 -1
  31. package/dist/lib/v2/index.d.mts +1 -1
  32. package/dist/lib/v2/index.d.mts.map +1 -1
  33. package/dist/lib/v2/index.mjs +1 -1
  34. package/package.json +11 -11
package/README.md CHANGED
@@ -11,7 +11,7 @@ This library provides an idiomatic TypeScript client for working with the Wandel
11
11
  npm install @wandelbots/nova-js
12
12
  ```
13
13
 
14
- If you develop a React application we also provide a set of [React components](https://github.com/wandelbotsgmbh/wandelbots-js-react-components). It includes a [Robot Jogging Panel](https://wandelbotsgmbh.github.io/wandelbots-js-react-components/?path=/docs/jogging-joggingpanel--docs), a [Robot Visualization](https://wandelbotsgmbh.github.io/wandelbots-js-react-components/?path=/docs/3d-view-robot--docs) and other useful UI widgets.
14
+ If you develop a React application we also provide a set of [React components](https://github.com/wandelbotsgmbh/wandelbots-js-react-components). It includes a [Robot Jogging Panel](https://wandelbotsgmbh.github.io/wandelbots-js-react-components/?path=/docs/jogging-joggingpanel--docs), a [Robot Visualization](https://wandelbotsgmbh.github.io/wandelbots-js-react-components/?path=/docs/3d-view-robot-robot--docs) and other useful UI widgets.
15
15
 
16
16
  ## Table of contents
17
17
 
@@ -66,4 +66,4 @@ declare class AutoReconnectingWebsocket extends ReconnectingWebSocket {
66
66
  }
67
67
  //#endregion
68
68
  export { MockNovaInstance as n, MockNovaInstance$1 as r, AutoReconnectingWebsocket as t };
69
- //# sourceMappingURL=AutoReconnectingWebsocket-Qcrbm3Kb.d.cts.map
69
+ //# sourceMappingURL=AutoReconnectingWebsocket-By6EZkXv.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AutoReconnectingWebsocket-Qcrbm3Kb.d.cts","names":[],"sources":["../src/lib/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;AACwB,cADX,kBAAA,CACW;EAGZ,SAAA,WAAA,EAHY,yBAGZ,EAAA;EACC,gBAAA,CAAA,MAAA,EADD,0BACC,CAAA,EAAR,OAAQ,CAAA,aAAA,CAAA;EAAR,yBAAA,CAAA,MAAA,EAg8B+B,yBAh8B/B,CAAA,EAAA,IAAA;EAg8B+B,sBAAA,CAAA,MAAA,EAkOH,yBAlOG,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;;;AAr8BpC;AACwB,cCNX,gBAAA,CDMW;EAGZ,SAAA,WAAA,ECRY,yBDQZ,EAAA;EACC,gBAAA,CAAA,MAAA,ECND,0BDMC,CAAA,ECLR,ODKQ,CCLA,aDKA,CAAA;EAAR,yBAAA,CAAA,MAAA,EC4b+B,yBD5b/B,CAAA,EAAA,IAAA;EAg8B+B,sBAAA,CAAA,MAAA,ECreH,yBDqeG,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;cEh9BvB,yBAAA,SAAkC,qBAAA;EFWlC,SAAA,IAAA,EAAA;IACW,IAAA,CAAA,EEJX,kBFIW,GEJW,gBFIX;IAGZ,SAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EACC,CAAA;EAAR,oBAAA,CAAA,EEfoB,YFepB;EAg8B+B,SAAA,EAAA,MAAA;EAkOH,QAAA,EAAA,OAAA;EAAyB,WAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,EAAA;WE1qC7C,qBAAsB;;;EDFtB,SAAA,CAAA,SAAgB,EAAA,MAAA,CAAA,EAAA,IAAA;EACL,QAAA,CAAA,IAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAGZ;;;;EAieqB,OAAA,CAAA,CAAA,EAAA,IAAA;EAAyB;;;YCzZ5C;EAlFD;;;EACY,MAAA,CAAA,CAAA,EA+FX,OA/FW,CAAA,IAAA,CAAA;EAOZ;;;;;EAwGO,YAAA,CAAA,CAAA,EAAA,OAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA;EA4BD;;;;iBAAA,QAAA"}
1
+ {"version":3,"file":"AutoReconnectingWebsocket-By6EZkXv.d.mts","names":[],"sources":["../src/lib/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;AACwB,cADX,kBAAA,CACW;EAGZ,SAAA,WAAA,EAHY,yBAGZ,EAAA;EACC,gBAAA,CAAA,MAAA,EADD,0BACC,CAAA,EAAR,OAAQ,CAAA,aAAA,CAAA;EAAR,yBAAA,CAAA,MAAA,EAg8B+B,yBAh8B/B,CAAA,EAAA,IAAA;EAg8B+B,sBAAA,CAAA,MAAA,EAkOH,yBAlOG,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;;;AAr8BpC;AACwB,cCNX,gBAAA,CDMW;EAGZ,SAAA,WAAA,ECRY,yBDQZ,EAAA;EACC,gBAAA,CAAA,MAAA,ECND,0BDMC,CAAA,ECLR,ODKQ,CCLA,aDKA,CAAA;EAAR,yBAAA,CAAA,MAAA,EC4b+B,yBD5b/B,CAAA,EAAA,IAAA;EAg8B+B,sBAAA,CAAA,MAAA,ECreH,yBDqeG,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;cEh9BvB,yBAAA,SAAkC,qBAAA;EFWlC,SAAA,IAAA,EAAA;IACW,IAAA,CAAA,EEJX,kBFIW,GEJW,gBFIX;IAGZ,SAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EACC,CAAA;EAAR,oBAAA,CAAA,EEfoB,YFepB;EAg8B+B,SAAA,EAAA,MAAA;EAkOH,QAAA,EAAA,OAAA;EAAyB,WAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,EAAA;WE1qC7C,qBAAsB;;;EDFtB,SAAA,CAAA,SAAgB,EAAA,MAAA,CAAA,EAAA,IAAA;EACL,QAAA,CAAA,IAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAGZ;;;;EAieqB,OAAA,CAAA,CAAA,EAAA,IAAA;EAAyB;;;YCzZ5C;EAlFD;;;EACY,MAAA,CAAA,CAAA,EA+FX,OA/FW,CAAA,IAAA,CAAA;EAOZ;;;;;EAwGO,YAAA,CAAA,CAAA,EAAA,OAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA;EA4BD;;;;iBAAA,QAAA"}
@@ -66,4 +66,4 @@ declare class AutoReconnectingWebsocket extends ReconnectingWebSocket {
66
66
  }
67
67
  //#endregion
68
68
  export { MockNovaInstance as n, MockNovaInstance$1 as r, AutoReconnectingWebsocket as t };
69
- //# sourceMappingURL=AutoReconnectingWebsocket-dHe-kceU.d.mts.map
69
+ //# sourceMappingURL=AutoReconnectingWebsocket-dO-Xkvgo.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AutoReconnectingWebsocket-dHe-kceU.d.mts","names":[],"sources":["../src/lib/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;AACwB,cADX,kBAAA,CACW;EAGZ,SAAA,WAAA,EAHY,yBAGZ,EAAA;EACC,gBAAA,CAAA,MAAA,EADD,0BACC,CAAA,EAAR,OAAQ,CAAA,aAAA,CAAA;EAAR,yBAAA,CAAA,MAAA,EAg8B+B,yBAh8B/B,CAAA,EAAA,IAAA;EAg8B+B,sBAAA,CAAA,MAAA,EAkOH,yBAlOG,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;;;AAr8BpC;AACwB,cCNX,gBAAA,CDMW;EAGZ,SAAA,WAAA,ECRY,yBDQZ,EAAA;EACC,gBAAA,CAAA,MAAA,ECND,0BDMC,CAAA,ECLR,ODKQ,CCLA,aDKA,CAAA;EAAR,yBAAA,CAAA,MAAA,EC4b+B,yBD5b/B,CAAA,EAAA,IAAA;EAg8B+B,sBAAA,CAAA,MAAA,ECreH,yBDqeG,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;cEh9BvB,yBAAA,SAAkC,qBAAA;EFWlC,SAAA,IAAA,EAAA;IACW,IAAA,CAAA,EEJX,kBFIW,GEJW,gBFIX;IAGZ,SAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EACC,CAAA;EAAR,oBAAA,CAAA,EEfoB,YFepB;EAg8B+B,SAAA,EAAA,MAAA;EAkOH,QAAA,EAAA,OAAA;EAAyB,WAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,EAAA;WE1qC7C,qBAAsB;;;EDFtB,SAAA,CAAA,SAAgB,EAAA,MAAA,CAAA,EAAA,IAAA;EACL,QAAA,CAAA,IAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAGZ;;;;EAieqB,OAAA,CAAA,CAAA,EAAA,IAAA;EAAyB;;;YCzZ5C;EAlFD;;;EACY,MAAA,CAAA,CAAA,EA+FX,OA/FW,CAAA,IAAA,CAAA;EAOZ;;;;;EAwGO,YAAA,CAAA,CAAA,EAAA,OAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA;EA4BD;;;;iBAAA,QAAA"}
1
+ {"version":3,"file":"AutoReconnectingWebsocket-dO-Xkvgo.d.cts","names":[],"sources":["../src/lib/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"sourcesContent":[],"mapp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AAA,CAAA,CAAA;EA4BD;;;;iBAAA,QAAA"}
@@ -298,4 +298,4 @@ const loginWithAuth0 = async (instanceUrl) => {
298
298
 
299
299
  //#endregion
300
300
  export { isSameCoordinateSystem as a, parseUrl as c, tryParseUrl as d, tryStringifyJson as f, degreesToRadians as i, radiansToDegrees as l, AutoReconnectingWebsocket as m, loginWithAuth0 as n, makeUrlQueryString as o, availableStorage as p, XYZ_TO_VECTOR as r, parseNovaInstanceUrl as s, getAuth0Config as t, tryParseJson as u };
301
- //# sourceMappingURL=LoginWithAuth0-DBe9CXOr.mjs.map
301
+ //# sourceMappingURL=LoginWithAuth0-BAGhME4k.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoginWithAuth0-DBe9CXOr.mjs","names":["opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n }"],"sources":["../src/lib/AutoReconnectingWebsocket.ts","../src/lib/availableStorage.ts","../src/lib/converters.ts","../src/LoginWithAuth0.ts"],"sourcesContent":["import ReconnectingWebSocket, { type ErrorEvent } from \"reconnecting-websocket\"\nimport type * as v1 from \"./v1/mock/MockNovaInstance\"\nimport type * as v2 from \"./v2/mock/MockNovaInstance\"\n\nexport class AutoReconnectingWebsocket extends ReconnectingWebSocket {\n receivedFirstMessage?: MessageEvent\n targetUrl: string\n disposed = false\n\n constructor(\n targetUrl: string,\n readonly opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n } = {},\n ) {\n console.log(\"Opening websocket to\", targetUrl)\n\n super(() => this.targetUrl || targetUrl, undefined, {\n startClosed: true,\n })\n\n // Reconnecting websocket doesn't set this properly with startClosed\n Object.defineProperty(this, \"url\", {\n get() {\n return this.targetUrl\n },\n })\n\n this.targetUrl = targetUrl\n\n this.addEventListener(\"open\", () => {\n console.log(`Websocket to ${this.url} opened`)\n })\n\n this.addEventListener(\"message\", (ev) => {\n if (!this.receivedFirstMessage) {\n this.receivedFirstMessage = ev\n }\n })\n\n this.addEventListener(\"close\", () => {\n console.log(`Websocket to ${this.url} closed`)\n })\n\n const origReconnect = this.reconnect\n this.reconnect = () => {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketConnection(this)\n } else {\n origReconnect.apply(this)\n }\n }\n\n this.reconnect()\n }\n\n changeUrl(targetUrl: string) {\n this.receivedFirstMessage = undefined\n this.targetUrl = targetUrl\n this.reconnect()\n }\n\n sendJson(data: unknown) {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketMessage(this, JSON.stringify(data))\n } else {\n this.send(JSON.stringify(data))\n }\n }\n\n /**\n * Permanently close this websocket and indicate that\n * this object should not be used again.\n **/\n dispose() {\n this.close()\n this.disposed = true\n if (this.opts.onDispose) {\n this.opts.onDispose()\n }\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the OPEN state. */\n async opened() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.OPEN) {\n resolve()\n } else {\n this.addEventListener(\"open\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the CLOSED state. */\n async closed() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.CLOSED) {\n resolve()\n } else {\n this.addEventListener(\"close\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves when the first message\n * is received from the websocket. Resolves immediately if\n * the first message has already been received.\n */\n async firstMessage() {\n if (this.receivedFirstMessage) {\n return this.receivedFirstMessage\n }\n\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.receivedFirstMessage = ev\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n\n /**\n * Returns a promise that resolves when the next message\n * is received from the websocket.\n */\n async nextMessage() {\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n}\n","/**\n * Safety wrapper around browser localStorage providing context availability\n * checks and JSON parsing\n */\nclass AvailableStorage {\n available = typeof window !== \"undefined\" && !!window.localStorage\n\n getJSON<T>(key: string): Partial<T> | null {\n if (!this.available) return null\n\n const result = window.localStorage.getItem(key)\n if (result === null) return null\n\n try {\n return JSON.parse(result)\n } catch (err) {\n return null\n }\n }\n\n setJSON(key: string, obj: unknown) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, JSON.stringify(obj))\n }\n\n delete(key: string) {\n if (!this.available) return null\n\n window.localStorage.removeItem(key)\n }\n\n setString(key: string, value: string) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, value)\n }\n\n getString(key: string): string | null {\n if (!this.available) return null\n\n return window.localStorage.getItem(key)\n }\n}\n\nexport const availableStorage = new AvailableStorage()\n","export type URLParseOptions = {\n /**\n * Ignore any scheme in the input string and force this scheme instead.\n */\n scheme?: \"http\" | \"https\"\n /**\n * If the input string does not include a scheme, use this as the default\n * scheme.\n */\n defaultScheme?: \"http\" | \"https\"\n}\n\n/**\n * Parse a string as a URL, with options to enforce or default the scheme.\n */\nexport function parseUrl(url: string, options: URLParseOptions = {}): URL {\n const { scheme, defaultScheme } = options\n\n const schemeRegex = /^[a-zA-Z]+:\\/\\//\n\n if (scheme) {\n // Force the scheme by removing any existing scheme and prepending the desired one\n url = url.replace(schemeRegex, \"\")\n url = `${scheme}://${url}`\n } else if (defaultScheme && !schemeRegex.test(url)) {\n // No scheme is present, add the default one\n url = `${defaultScheme}://${url}`\n }\n\n return new URL(url)\n}\n\n/**\n * Attempt to parse a string as a URL; return undefined if we can't\n */\nexport function tryParseUrl(\n url: string,\n options: URLParseOptions = {},\n): URL | undefined {\n try {\n return parseUrl(url, options)\n } catch {\n return undefined\n }\n}\n\n/**\n * Permissively parse a NOVA instance URL from a config variable.\n * If scheme is not specified, defaults to https for *.wandelbots.io hosts,\n * and http otherwise.\n * Throws an error if a valid URL could not be determined.\n */\nexport function parseNovaInstanceUrl(url: string): URL {\n const testUrl = tryParseUrl(url, { defaultScheme: \"http\" })\n if (testUrl?.host.endsWith(\".wandelbots.io\")) {\n return parseUrl(url, { defaultScheme: \"https\" })\n } else {\n return parseUrl(url, { defaultScheme: \"http\" })\n }\n}\n\n/** Try to parse something as JSON; return undefined if we can't */\n// biome-ignore lint/suspicious/noExplicitAny: it's json\nexport function tryParseJson(json: unknown): any {\n try {\n return JSON.parse(json as string)\n } catch {\n return undefined\n }\n}\n\n/** Try to turn something into JSON; return undefined if we can't */\nexport function tryStringifyJson(json: unknown): string | undefined {\n try {\n return JSON.stringify(json)\n } catch {\n return undefined\n }\n}\n\n/**\n * Converts object parameters to query string.\n * e.g. { a: \"1\", b: \"2\" } => \"?a=1&b=2\"\n * {} => \"\"\n */\nexport function makeUrlQueryString(obj: Record<string, string>): string {\n const str = new URLSearchParams(obj).toString()\n return str ? `?${str}` : \"\"\n}\n\n/** Convert radians to degrees */\nexport function radiansToDegrees(radians: number): number {\n return radians * (180 / Math.PI)\n}\n\n/** Convert degrees to radians */\nexport function degreesToRadians(degrees: number): number {\n return degrees * (Math.PI / 180)\n}\n\n/**\n * Check for coordinate system id equivalence, accounting for the \"world\" default\n * on empty/undefined values.\n */\nexport function isSameCoordinateSystem(\n firstCoordSystem: string | undefined,\n secondCoordSystem: string | undefined,\n) {\n if (!firstCoordSystem) firstCoordSystem = \"world\"\n if (!secondCoordSystem) secondCoordSystem = \"world\"\n\n return firstCoordSystem === secondCoordSystem\n}\n\n/**\n * Helpful const for converting {x, y, z} to [x, y, z] and vice versa\n */\nexport const XYZ_TO_VECTOR = { x: 0, y: 1, z: 2 }\n","/**\n * Mapping of stages to Auth0 configurations.\n * The client ids are public identifiers for a specific auth0 application\n * and are safe to include in client-side code.\n * https://auth0.com/docs/get-started/applications/application-settings\n */\nconst auth0ConfigMap = {\n dev: {\n domain: `https://auth.portal.dev.wandelbots.io`,\n clientId: \"fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha\",\n },\n stg: {\n domain: `https://auth.portal.stg.wandelbots.io`,\n clientId: \"joVDeD9e786WzFNSGCqoVq7HNkWt5j6s\",\n },\n prod: {\n domain: `https://auth.portal.wandelbots.io`,\n clientId: \"J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2\",\n },\n}\n\n/** Determine which Auth0 configuration to use based on instance URL */\nexport const getAuth0Config = (instanceUrl: URL) => {\n if (instanceUrl.host.endsWith(\".dev.wandelbots.io\")) return auth0ConfigMap.dev\n if (instanceUrl.host.endsWith(\".stg.wandelbots.io\")) return auth0ConfigMap.stg\n if (instanceUrl.host.endsWith(\".wandelbots.io\")) return auth0ConfigMap.prod\n throw new Error(\n `Unable to authenticate with NOVA instance \"${instanceUrl}\". Auth0 login is only supported for cloud instances with hosts of the form \"**.wandelbots.io\".`,\n )\n}\n\n/**\n * Initializes Auth0 login process using redirect if necessary and retrieves an access token.\n * Returns null when an access token should not be needed to authenticate (i.e. cookie auth\n * when deployed on the instance domain)\n */\nexport const loginWithAuth0 = async (\n instanceUrl: URL,\n): Promise<string | null> => {\n if (typeof window === \"undefined\") {\n throw new Error(\n `Access token must be set to use NovaClient when not in a browser environment.`,\n )\n }\n\n if (instanceUrl.origin === window.location.origin) {\n // When deployed on the instance itself, our auth is handled by cookies\n // and no access token is needed-- just need to reload the page and it'll\n // login again / set cookie as needed\n window.location.reload()\n throw new Error(\n \"Failed to reload page to get auth details, please refresh manually\",\n )\n }\n\n // If we're on localhost or another domain, we need to do the full oauth flow\n // Note this will ONLY work for origins which are whitelisted as a redirect_uri\n // in the auth0 config, currently\n const { Auth0Client } = await import(\"@auth0/auth0-spa-js\")\n\n const auth0Config = getAuth0Config(instanceUrl)\n\n const auth0Client = new Auth0Client({\n domain: auth0Config.domain,\n clientId: auth0Config.clientId ?? \"\",\n useRefreshTokens: false,\n authorizationParams: {\n audience: \"nova-api\",\n redirect_uri: window.location.origin,\n },\n })\n\n // If the URL includes a redirect result, handle it\n if (\n window.location.search.includes(\"code=\") &&\n window.location.search.includes(\"state=\")\n ) {\n const { appState } = await auth0Client.handleRedirectCallback()\n // Return to the URL the user was originally on before the redirect\n window.history.replaceState(\n {},\n document.title,\n appState?.returnTo || window.location.pathname,\n )\n } else {\n // Initiate login with redirect\n await auth0Client.loginWithRedirect()\n }\n\n // Once logged in, retrieve the access token silently\n const accessToken = await auth0Client.getTokenSilently()\n return accessToken\n}\n"],"mappings":";;;AAIA,IAAa,4BAAb,cAA+C,sBAAsB;CAKnE,YACE,WACA,AAASA,OAGL,EAAE,EACN;AACA,UAAQ,IAAI,wBAAwB,UAAU;AAE9C,cAAY,KAAK,aAAa,WAAW,QAAW,EAClD,aAAa,MACd,CAAC;EATO;kBAJA;AAgBT,SAAO,eAAe,MAAM,OAAO,EACjC,MAAM;AACJ,UAAO,KAAK;KAEf,CAAC;AAEF,OAAK,YAAY;AAEjB,OAAK,iBAAiB,cAAc;AAClC,WAAQ,IAAI,gBAAgB,KAAK,IAAI,SAAS;IAC9C;AAEF,OAAK,iBAAiB,YAAY,OAAO;AACvC,OAAI,CAAC,KAAK,qBACR,MAAK,uBAAuB;IAE9B;AAEF,OAAK,iBAAiB,eAAe;AACnC,WAAQ,IAAI,gBAAgB,KAAK,IAAI,SAAS;IAC9C;EAEF,MAAM,gBAAgB,KAAK;AAC3B,OAAK,kBAAkB;AACrB,OAAI,KAAK,KAAK,KACZ,MAAK,KAAK,KAAK,0BAA0B,KAAK;OAE9C,eAAc,MAAM,KAAK;;AAI7B,OAAK,WAAW;;CAGlB,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AY,KAAK,SAAS,qBAAqB,CAAE,QAAO,eAAe;AAC3E,KAAI,YAAY,KAAK,SAAS,iBAAiB,CAAE,QAAO,eAAe;AACvE,OAAM,IAAI,MACR,8CAA8C,YAAY,iGAC3D;;;;;;;AAQH,MAAa,iBAAiB,OAC5B,gBAC2B;AAC3B,KAAI,OAAO,WAAW,YACpB,OAAM,IAAI,MACR,gFACD;AAGH,KAAI,YAAY,WAAW,OAAO,SAAS,QAAQ;AAIjD,SAAO,SAAS,QAAQ;AACxB,QAAM,IAAI,MACR,qEACD;;CAMH,MAAM,EAAE,gBAAgB,MAAM,OAAO;CAErC,MAAM,cAAc,eAAe,YAAY;CAE/C,MAAM,cAAc,IAAI,YAAY;EAClC,QAAQ,YAAY;EACpB,UAAU,YAAY,YAAY;EAClC,kBAAkB;EAClB,qBAAqB;GACnB,UAAU;GACV,cAAc,OAAO,SAAS;GAC/B;EACF,CAAC;AAGF,KACE,OAAO,SAAS,OAAO,SAAS,QAAQ,IACxC,OAAO,SAAS,OAAO,SAAS,SAAS,EACzC;EACA,MAAM,EAAE,aAAa,MAAM,YAAY,wBAAwB;AAE/D,SAAO,QAAQ,aACb,EAAE,EACF,SAAS,OACT,UAAU,YAAY,OAAO,SAAS,SACvC;OAGD,OAAM,YAAY,mBAAmB;AAKvC,QADoB,MAAM,YAAY,kBAAkB"}
1
+ {"version":3,"file":"LoginWithAuth0-BAGhME4k.mjs","names":["opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n }"],"sources":["../src/lib/AutoReconnectingWebsocket.ts","../src/lib/availableStorage.ts","../src/lib/converters.ts","../src/LoginWithAuth0.ts"],"sourcesContent":["import ReconnectingWebSocket, { type ErrorEvent } from \"reconnecting-websocket\"\nimport type * as v1 from \"./v1/mock/MockNovaInstance\"\nimport type * as v2 from \"./v2/mock/MockNovaInstance\"\n\nexport class AutoReconnectingWebsocket extends ReconnectingWebSocket {\n receivedFirstMessage?: MessageEvent\n targetUrl: string\n disposed = false\n\n constructor(\n targetUrl: string,\n readonly opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n } = {},\n ) {\n console.log(\"Opening websocket to\", targetUrl)\n\n super(() => this.targetUrl || targetUrl, undefined, {\n startClosed: true,\n })\n\n // Reconnecting websocket doesn't set this properly with startClosed\n Object.defineProperty(this, \"url\", {\n get() {\n return this.targetUrl\n },\n })\n\n this.targetUrl = targetUrl\n\n this.addEventListener(\"open\", () => {\n console.log(`Websocket to ${this.url} opened`)\n })\n\n this.addEventListener(\"message\", (ev) => {\n if (!this.receivedFirstMessage) {\n this.receivedFirstMessage = ev\n }\n })\n\n this.addEventListener(\"close\", () => {\n console.log(`Websocket to ${this.url} closed`)\n })\n\n const origReconnect = this.reconnect\n this.reconnect = () => {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketConnection(this)\n } else {\n origReconnect.apply(this)\n }\n }\n\n this.reconnect()\n }\n\n changeUrl(targetUrl: string) {\n this.receivedFirstMessage = undefined\n this.targetUrl = targetUrl\n this.reconnect()\n }\n\n sendJson(data: unknown) {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketMessage(this, JSON.stringify(data))\n } else {\n this.send(JSON.stringify(data))\n }\n }\n\n /**\n * Permanently close this websocket and indicate that\n * this object should not be used again.\n **/\n dispose() {\n this.close()\n this.disposed = true\n if (this.opts.onDispose) {\n this.opts.onDispose()\n }\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the OPEN state. */\n async opened() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.OPEN) {\n resolve()\n } else {\n this.addEventListener(\"open\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the CLOSED state. */\n async closed() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.CLOSED) {\n resolve()\n } else {\n this.addEventListener(\"close\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves when the first message\n * is received from the websocket. Resolves immediately if\n * the first message has already been received.\n */\n async firstMessage() {\n if (this.receivedFirstMessage) {\n return this.receivedFirstMessage\n }\n\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.receivedFirstMessage = ev\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n\n /**\n * Returns a promise that resolves when the next message\n * is received from the websocket.\n */\n async nextMessage() {\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n}\n","/**\n * Safety wrapper around browser localStorage providing context availability\n * checks and JSON parsing\n */\nclass AvailableStorage {\n available = typeof window !== \"undefined\" && !!window.localStorage\n\n getJSON<T>(key: string): Partial<T> | null {\n if (!this.available) return null\n\n const result = window.localStorage.getItem(key)\n if (result === null) return null\n\n try {\n return JSON.parse(result)\n } catch (err) {\n return null\n }\n }\n\n setJSON(key: string, obj: unknown) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, JSON.stringify(obj))\n }\n\n delete(key: string) {\n if (!this.available) return null\n\n window.localStorage.removeItem(key)\n }\n\n setString(key: string, value: string) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, value)\n }\n\n getString(key: string): string | null {\n if (!this.available) return null\n\n return window.localStorage.getItem(key)\n }\n}\n\nexport const availableStorage = new AvailableStorage()\n","export type URLParseOptions = {\n /**\n * Ignore any scheme in the input string and force this scheme instead.\n */\n scheme?: \"http\" | \"https\"\n /**\n * If the input string does not include a scheme, use this as the default\n * scheme.\n */\n defaultScheme?: \"http\" | \"https\"\n}\n\n/**\n * Parse a string as a URL, with options to enforce or default the scheme.\n */\nexport function parseUrl(url: string, options: URLParseOptions = {}): URL {\n const { scheme, defaultScheme } = options\n\n const schemeRegex = /^[a-zA-Z]+:\\/\\//\n\n if (scheme) {\n // Force the scheme by removing any existing scheme and prepending the desired one\n url = url.replace(schemeRegex, \"\")\n url = `${scheme}://${url}`\n } else if (defaultScheme && !schemeRegex.test(url)) {\n // No scheme is present, add the default one\n url = `${defaultScheme}://${url}`\n }\n\n return new URL(url)\n}\n\n/**\n * Attempt to parse a string as a URL; return undefined if we can't\n */\nexport function tryParseUrl(\n url: string,\n options: URLParseOptions = {},\n): URL | undefined {\n try {\n return parseUrl(url, options)\n } catch {\n return undefined\n }\n}\n\n/**\n * Permissively parse a NOVA instance URL from a config variable.\n * If scheme is not specified, defaults to https for *.wandelbots.io hosts,\n * and http otherwise.\n * Throws an error if a valid URL could not be determined.\n */\nexport function parseNovaInstanceUrl(url: string): URL {\n const testUrl = tryParseUrl(url, { defaultScheme: \"http\" })\n if (testUrl?.host.endsWith(\".wandelbots.io\")) {\n return parseUrl(url, { defaultScheme: \"https\" })\n } else {\n return parseUrl(url, { defaultScheme: \"http\" })\n }\n}\n\n/** Try to parse something as JSON; return undefined if we can't */\n// biome-ignore lint/suspicious/noExplicitAny: it's json\nexport function tryParseJson(json: unknown): any {\n try {\n return JSON.parse(json as string)\n } catch {\n return undefined\n }\n}\n\n/** Try to turn something into JSON; return undefined if we can't */\nexport function tryStringifyJson(json: unknown): string | undefined {\n try {\n return JSON.stringify(json)\n } catch {\n return undefined\n }\n}\n\n/**\n * Converts object parameters to query string.\n * e.g. { a: \"1\", b: \"2\" } => \"?a=1&b=2\"\n * {} => \"\"\n */\nexport function makeUrlQueryString(obj: Record<string, string>): string {\n const str = new URLSearchParams(obj).toString()\n return str ? `?${str}` : \"\"\n}\n\n/** Convert radians to degrees */\nexport function radiansToDegrees(radians: number): number {\n return radians * (180 / Math.PI)\n}\n\n/** Convert degrees to radians */\nexport function degreesToRadians(degrees: number): number {\n return degrees * (Math.PI / 180)\n}\n\n/**\n * Check for coordinate system id equivalence, accounting for the \"world\" default\n * on empty/undefined values.\n */\nexport function isSameCoordinateSystem(\n firstCoordSystem: string | undefined,\n secondCoordSystem: string | undefined,\n) {\n if (!firstCoordSystem) firstCoordSystem = \"world\"\n if (!secondCoordSystem) secondCoordSystem = \"world\"\n\n return firstCoordSystem === secondCoordSystem\n}\n\n/**\n * Helpful const for converting {x, y, z} to [x, y, z] and vice versa\n */\nexport const XYZ_TO_VECTOR = { x: 0, y: 1, z: 2 }\n","/**\n * Mapping of stages to Auth0 configurations.\n * The client ids are public identifiers for a specific auth0 application\n * and are safe to include in client-side code.\n * https://auth0.com/docs/get-started/applications/application-settings\n */\nconst auth0ConfigMap = {\n dev: {\n domain: `https://auth.portal.dev.wandelbots.io`,\n clientId: \"fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha\",\n },\n stg: {\n domain: `https://auth.portal.stg.wandelbots.io`,\n clientId: \"joVDeD9e786WzFNSGCqoVq7HNkWt5j6s\",\n },\n prod: {\n domain: `https://auth.portal.wandelbots.io`,\n clientId: \"J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2\",\n },\n}\n\n/** Determine which Auth0 configuration to use based on instance URL */\nexport const getAuth0Config = (instanceUrl: URL) => {\n if (instanceUrl.host.endsWith(\".dev.wandelbots.io\")) return auth0ConfigMap.dev\n if (instanceUrl.host.endsWith(\".stg.wandelbots.io\")) return auth0ConfigMap.stg\n if (instanceUrl.host.endsWith(\".wandelbots.io\")) return auth0ConfigMap.prod\n throw new Error(\n `Unable to authenticate with NOVA instance \"${instanceUrl}\". Auth0 login is only supported for cloud instances with hosts of the form \"**.wandelbots.io\".`,\n )\n}\n\n/**\n * Initializes Auth0 login process using redirect if necessary and retrieves an access token.\n * Returns null when an access token should not be needed to authenticate (i.e. cookie auth\n * when deployed on the instance domain)\n */\nexport const loginWithAuth0 = async (\n instanceUrl: URL,\n): Promise<string | null> => {\n if (typeof window === \"undefined\") {\n throw new Error(\n `Access token must be set to use NovaClient when not in a browser environment.`,\n )\n }\n\n if (instanceUrl.origin === window.location.origin) {\n // When deployed on the instance itself, our auth is handled by cookies\n // and no access token is needed-- just need to reload the page and it'll\n // login again / set cookie as needed\n window.location.reload()\n throw new Error(\n \"Failed to reload page to get auth details, please refresh manually\",\n )\n }\n\n // If we're on localhost or another domain, we need to do the full oauth flow\n // Note this will ONLY work for origins which are whitelisted as a redirect_uri\n // in the auth0 config, currently\n const { Auth0Client } = await import(\"@auth0/auth0-spa-js\")\n\n const auth0Config = getAuth0Config(instanceUrl)\n\n const auth0Client = new Auth0Client({\n domain: auth0Config.domain,\n clientId: auth0Config.clientId ?? \"\",\n useRefreshTokens: false,\n authorizationParams: {\n audience: \"nova-api\",\n redirect_uri: window.location.origin,\n },\n })\n\n // If the URL includes a redirect result, handle it\n if (\n window.location.search.includes(\"code=\") &&\n window.location.search.includes(\"state=\")\n ) {\n const { appState } = await auth0Client.handleRedirectCallback()\n // Return to the URL the user was originally on before the redirect\n window.history.replaceState(\n {},\n document.title,\n appState?.returnTo || window.location.pathname,\n )\n } else {\n // Initiate login with redirect\n await auth0Client.loginWithRedirect()\n }\n\n // Once logged in, retrieve the access token silently\n const accessToken = await auth0Client.getTokenSilently()\n return accessToken\n}\n"],"mappings":";;;AAIA,IAAa,4BAAb,cAA+C,sBAAsB;CAKnE,YACE,WACA,AAASA,OAGL,EAAE,EACN;AACA,UAAQ,IAAI,wBAAwB,UAAU;AAE9C,cAAY,KAAK,aAAa,WAAW,QAAW,EAClD,aAAa,MACd,CAAC;EATO;kBAJA;AAgBT,SAAO,eAAe,MAAM,OAAO,EACjC,MAAM;AACJ,UAAO,KAAK;KAEf,CAAC;AAEF,OAAK,YAA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AY,kBAAkB"}
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
15
19
  }
16
20
  return to;
17
21
  };
@@ -411,4 +415,4 @@ Object.defineProperty(exports, 'tryStringifyJson', {
411
415
  return tryStringifyJson;
412
416
  }
413
417
  });
414
- //# sourceMappingURL=LoginWithAuth0-iXpPiCcz.cjs.map
418
+ //# sourceMappingURL=LoginWithAuth0-qpkGkrJo.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoginWithAuth0-iXpPiCcz.cjs","names":["ReconnectingWebSocket","opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n }"],"sources":["../src/lib/AutoReconnectingWebsocket.ts","../src/lib/availableStorage.ts","../src/lib/converters.ts","../src/LoginWithAuth0.ts"],"sourcesContent":["import ReconnectingWebSocket, { type ErrorEvent } from \"reconnecting-websocket\"\nimport type * as v1 from \"./v1/mock/MockNovaInstance\"\nimport type * as v2 from \"./v2/mock/MockNovaInstance\"\n\nexport class AutoReconnectingWebsocket extends ReconnectingWebSocket {\n receivedFirstMessage?: MessageEvent\n targetUrl: string\n disposed = false\n\n constructor(\n targetUrl: string,\n readonly opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n } = {},\n ) {\n console.log(\"Opening websocket to\", targetUrl)\n\n super(() => this.targetUrl || targetUrl, undefined, {\n startClosed: true,\n })\n\n // Reconnecting websocket doesn't set this properly with startClosed\n Object.defineProperty(this, \"url\", {\n get() {\n return this.targetUrl\n },\n })\n\n this.targetUrl = targetUrl\n\n this.addEventListener(\"open\", () => {\n console.log(`Websocket to ${this.url} opened`)\n })\n\n this.addEventListener(\"message\", (ev) => {\n if (!this.receivedFirstMessage) {\n this.receivedFirstMessage = ev\n }\n })\n\n this.addEventListener(\"close\", () => {\n console.log(`Websocket to ${this.url} closed`)\n })\n\n const origReconnect = this.reconnect\n this.reconnect = () => {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketConnection(this)\n } else {\n origReconnect.apply(this)\n }\n }\n\n this.reconnect()\n }\n\n changeUrl(targetUrl: string) {\n this.receivedFirstMessage = undefined\n this.targetUrl = targetUrl\n this.reconnect()\n }\n\n sendJson(data: unknown) {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketMessage(this, JSON.stringify(data))\n } else {\n this.send(JSON.stringify(data))\n }\n }\n\n /**\n * Permanently close this websocket and indicate that\n * this object should not be used again.\n **/\n dispose() {\n this.close()\n this.disposed = true\n if (this.opts.onDispose) {\n this.opts.onDispose()\n }\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the OPEN state. */\n async opened() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.OPEN) {\n resolve()\n } else {\n this.addEventListener(\"open\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the CLOSED state. */\n async closed() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.CLOSED) {\n resolve()\n } else {\n this.addEventListener(\"close\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves when the first message\n * is received from the websocket. Resolves immediately if\n * the first message has already been received.\n */\n async firstMessage() {\n if (this.receivedFirstMessage) {\n return this.receivedFirstMessage\n }\n\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.receivedFirstMessage = ev\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n\n /**\n * Returns a promise that resolves when the next message\n * is received from the websocket.\n */\n async nextMessage() {\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n}\n","/**\n * Safety wrapper around browser localStorage providing context availability\n * checks and JSON parsing\n */\nclass AvailableStorage {\n available = typeof window !== \"undefined\" && !!window.localStorage\n\n getJSON<T>(key: string): Partial<T> | null {\n if (!this.available) return null\n\n const result = window.localStorage.getItem(key)\n if (result === null) return null\n\n try {\n return JSON.parse(result)\n } catch (err) {\n return null\n }\n }\n\n setJSON(key: string, obj: unknown) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, JSON.stringify(obj))\n }\n\n delete(key: string) {\n if (!this.available) return null\n\n window.localStorage.removeItem(key)\n }\n\n setString(key: string, value: string) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, value)\n }\n\n getString(key: string): string | null {\n if (!this.available) return null\n\n return window.localStorage.getItem(key)\n }\n}\n\nexport const availableStorage = new AvailableStorage()\n","export type URLParseOptions = {\n /**\n * Ignore any scheme in the input string and force this scheme instead.\n */\n scheme?: \"http\" | \"https\"\n /**\n * If the input string does not include a scheme, use this as the default\n * scheme.\n */\n defaultScheme?: \"http\" | \"https\"\n}\n\n/**\n * Parse a string as a URL, with options to enforce or default the scheme.\n */\nexport function parseUrl(url: string, options: URLParseOptions = {}): URL {\n const { scheme, defaultScheme } = options\n\n const schemeRegex = /^[a-zA-Z]+:\\/\\//\n\n if (scheme) {\n // Force the scheme by removing any existing scheme and prepending the desired one\n url = url.replace(schemeRegex, \"\")\n url = `${scheme}://${url}`\n } else if (defaultScheme && !schemeRegex.test(url)) {\n // No scheme is present, add the default one\n url = `${defaultScheme}://${url}`\n }\n\n return new URL(url)\n}\n\n/**\n * Attempt to parse a string as a URL; return undefined if we can't\n */\nexport function tryParseUrl(\n url: string,\n options: URLParseOptions = {},\n): URL | undefined {\n try {\n return parseUrl(url, options)\n } catch {\n return undefined\n }\n}\n\n/**\n * Permissively parse a NOVA instance URL from a config variable.\n * If scheme is not specified, defaults to https for *.wandelbots.io hosts,\n * and http otherwise.\n * Throws an error if a valid URL could not be determined.\n */\nexport function parseNovaInstanceUrl(url: string): URL {\n const testUrl = tryParseUrl(url, { defaultScheme: \"http\" })\n if (testUrl?.host.endsWith(\".wandelbots.io\")) {\n return parseUrl(url, { defaultScheme: \"https\" })\n } else {\n return parseUrl(url, { defaultScheme: \"http\" })\n }\n}\n\n/** Try to parse something as JSON; return undefined if we can't */\n// biome-ignore lint/suspicious/noExplicitAny: it's json\nexport function tryParseJson(json: unknown): any {\n try {\n return JSON.parse(json as string)\n } catch {\n return undefined\n }\n}\n\n/** Try to turn something into JSON; return undefined if we can't */\nexport function tryStringifyJson(json: unknown): string | undefined {\n try {\n return JSON.stringify(json)\n } catch {\n return undefined\n }\n}\n\n/**\n * Converts object parameters to query string.\n * e.g. { a: \"1\", b: \"2\" } => \"?a=1&b=2\"\n * {} => \"\"\n */\nexport function makeUrlQueryString(obj: Record<string, string>): string {\n const str = new URLSearchParams(obj).toString()\n return str ? `?${str}` : \"\"\n}\n\n/** Convert radians to degrees */\nexport function radiansToDegrees(radians: number): number {\n return radians * (180 / Math.PI)\n}\n\n/** Convert degrees to radians */\nexport function degreesToRadians(degrees: number): number {\n return degrees * (Math.PI / 180)\n}\n\n/**\n * Check for coordinate system id equivalence, accounting for the \"world\" default\n * on empty/undefined values.\n */\nexport function isSameCoordinateSystem(\n firstCoordSystem: string | undefined,\n secondCoordSystem: string | undefined,\n) {\n if (!firstCoordSystem) firstCoordSystem = \"world\"\n if (!secondCoordSystem) secondCoordSystem = \"world\"\n\n return firstCoordSystem === secondCoordSystem\n}\n\n/**\n * Helpful const for converting {x, y, z} to [x, y, z] and vice versa\n */\nexport const XYZ_TO_VECTOR = { x: 0, y: 1, z: 2 }\n","/**\n * Mapping of stages to Auth0 configurations.\n * The client ids are public identifiers for a specific auth0 application\n * and are safe to include in client-side code.\n * https://auth0.com/docs/get-started/applications/application-settings\n */\nconst auth0ConfigMap = {\n dev: {\n domain: `https://auth.portal.dev.wandelbots.io`,\n clientId: \"fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha\",\n },\n stg: {\n domain: `https://auth.portal.stg.wandelbots.io`,\n clientId: \"joVDeD9e786WzFNSGCqoVq7HNkWt5j6s\",\n },\n prod: {\n domain: `https://auth.portal.wandelbots.io`,\n clientId: \"J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2\",\n },\n}\n\n/** Determine which Auth0 configuration to use based on instance URL */\nexport const getAuth0Config = (instanceUrl: URL) => {\n if (instanceUrl.host.endsWith(\".dev.wandelbots.io\")) return auth0ConfigMap.dev\n if (instanceUrl.host.endsWith(\".stg.wandelbots.io\")) return auth0ConfigMap.stg\n if (instanceUrl.host.endsWith(\".wandelbots.io\")) return auth0ConfigMap.prod\n throw new Error(\n `Unable to authenticate with NOVA instance \"${instanceUrl}\". Auth0 login is only supported for cloud instances with hosts of the form \"**.wandelbots.io\".`,\n )\n}\n\n/**\n * Initializes Auth0 login process using redirect if necessary and retrieves an access token.\n * Returns null when an access token should not be needed to authenticate (i.e. cookie auth\n * when deployed on the instance domain)\n */\nexport const loginWithAuth0 = async (\n instanceUrl: URL,\n): Promise<string | null> => {\n if (typeof window === \"undefined\") {\n throw new Error(\n `Access token must be set to use NovaClient when not in a browser environment.`,\n )\n }\n\n if (instanceUrl.origin === window.location.origin) {\n // When deployed on the instance itself, our auth is handled by cookies\n // and no access token is needed-- just need to reload the page and it'll\n // login again / set cookie as needed\n window.location.reload()\n throw new Error(\n \"Failed to reload page to get auth details, please refresh manually\",\n )\n }\n\n // If we're on localhost or another domain, we need to do the full oauth flow\n // Note this will ONLY work for origins which are whitelisted as a redirect_uri\n // in the auth0 config, currently\n const { Auth0Client } = await import(\"@auth0/auth0-spa-js\")\n\n const auth0Config = getAuth0Config(instanceUrl)\n\n const auth0Client = new Auth0Client({\n domain: auth0Config.domain,\n clientId: auth0Config.clientId ?? \"\",\n useRefreshTokens: false,\n authorizationParams: {\n audience: \"nova-api\",\n redirect_uri: window.location.origin,\n },\n })\n\n // If the URL includes a redirect result, handle it\n if (\n window.location.search.includes(\"code=\") &&\n window.location.search.includes(\"state=\")\n ) {\n const { appState } = await auth0Client.handleRedirectCallback()\n // Return to the URL the user was originally on before the redirect\n window.history.replaceState(\n {},\n document.title,\n appState?.returnTo || window.location.pathname,\n )\n } else {\n // Initiate login with redirect\n await auth0Client.loginWithRedirect()\n }\n\n // Once logged in, retrieve the access token silently\n const accessToken = await auth0Client.getTokenSilently()\n return accessToken\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAa,4BAAb,cAA+CA,+BAAsB;CAKnE,YACE,WACA,AAASC,OAGL,EAAE,EACN;AACA,UAAQ,IAAI,wBAAwB,UAAU;AAE9C,cAAY,KAAK,aAAa,WAAW,QAAW,EAClD,aAAa,MACd,CAAC;EATO;kBAJA;AAgBT,SAAO,eAAe,MA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,OAAO,SAAS,SACvC;OAGD,OAAM,YAAY,mBAAmB;AAKvC,QADoB,MAAM,YAAY,kBAAkB"}
1
+ {"version":3,"file":"LoginWithAuth0-qpkGkrJo.cjs","names":["ReconnectingWebSocket","opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n }"],"sources":["../src/lib/AutoReconnectingWebsocket.ts","../src/lib/availableStorage.ts","../src/lib/converters.ts","../src/LoginWithAuth0.ts"],"sourcesContent":["import ReconnectingWebSocket, { type ErrorEvent } from \"reconnecting-websocket\"\nimport type * as v1 from \"./v1/mock/MockNovaInstance\"\nimport type * as v2 from \"./v2/mock/MockNovaInstance\"\n\nexport class AutoReconnectingWebsocket extends ReconnectingWebSocket {\n receivedFirstMessage?: MessageEvent\n targetUrl: string\n disposed = false\n\n constructor(\n targetUrl: string,\n readonly opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n } = {},\n ) {\n console.log(\"Opening websocket to\", targetUrl)\n\n super(() => this.targetUrl || targetUrl, undefined, {\n startClosed: true,\n })\n\n // Reconnecting websocket doesn't set this properly with startClosed\n Object.defineProperty(this, \"url\", {\n get() {\n return this.targetUrl\n },\n })\n\n this.targetUrl = targetUrl\n\n this.addEventListener(\"open\", () => {\n console.log(`Websocket to ${this.url} opened`)\n })\n\n this.addEventListener(\"message\", (ev) => {\n if (!this.receivedFirstMessage) {\n this.receivedFirstMessage = ev\n }\n })\n\n this.addEventListener(\"close\", () => {\n console.log(`Websocket to ${this.url} closed`)\n })\n\n const origReconnect = this.reconnect\n this.reconnect = () => {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketConnection(this)\n } else {\n origReconnect.apply(this)\n }\n }\n\n this.reconnect()\n }\n\n changeUrl(targetUrl: string) {\n this.receivedFirstMessage = undefined\n this.targetUrl = targetUrl\n this.reconnect()\n }\n\n sendJson(data: unknown) {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketMessage(this, JSON.stringify(data))\n } else {\n this.send(JSON.stringify(data))\n }\n }\n\n /**\n * Permanently close this websocket and indicate that\n * this object should not be used again.\n **/\n dispose() {\n this.close()\n this.disposed = true\n if (this.opts.onDispose) {\n this.opts.onDispose()\n }\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the OPEN state. */\n async opened() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.OPEN) {\n resolve()\n } else {\n this.addEventListener(\"open\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the CLOSED state. */\n async closed() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.CLOSED) {\n resolve()\n } else {\n this.addEventListener(\"close\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves when the first message\n * is received from the websocket. Resolves immediately if\n * the first message has already been received.\n */\n async firstMessage() {\n if (this.receivedFirstMessage) {\n return this.receivedFirstMessage\n }\n\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.receivedFirstMessage = ev\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n\n /**\n * Returns a promise that resolves when the next message\n * is received from the websocket.\n */\n async nextMessage() {\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n}\n","/**\n * Safety wrapper around browser localStorage providing context availability\n * checks and JSON parsing\n */\nclass AvailableStorage {\n available = typeof window !== \"undefined\" && !!window.localStorage\n\n getJSON<T>(key: string): Partial<T> | null {\n if (!this.available) return null\n\n const result = window.localStorage.getItem(key)\n if (result === null) return null\n\n try {\n return JSON.parse(result)\n } catch (err) {\n return null\n }\n }\n\n setJSON(key: string, obj: unknown) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, JSON.stringify(obj))\n }\n\n delete(key: string) {\n if (!this.available) return null\n\n window.localStorage.removeItem(key)\n }\n\n setString(key: string, value: string) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, value)\n }\n\n getString(key: string): string | null {\n if (!this.available) return null\n\n return window.localStorage.getItem(key)\n }\n}\n\nexport const availableStorage = new AvailableStorage()\n","export type URLParseOptions = {\n /**\n * Ignore any scheme in the input string and force this scheme instead.\n */\n scheme?: \"http\" | \"https\"\n /**\n * If the input string does not include a scheme, use this as the default\n * scheme.\n */\n defaultScheme?: \"http\" | \"https\"\n}\n\n/**\n * Parse a string as a URL, with options to enforce or default the scheme.\n */\nexport function parseUrl(url: string, options: URLParseOptions = {}): URL {\n const { scheme, defaultScheme } = options\n\n const schemeRegex = /^[a-zA-Z]+:\\/\\//\n\n if (scheme) {\n // Force the scheme by removing any existing scheme and prepending the desired one\n url = url.replace(schemeRegex, \"\")\n url = `${scheme}://${url}`\n } else if (defaultScheme && !schemeRegex.test(url)) {\n // No scheme is present, add the default one\n url = `${defaultScheme}://${url}`\n }\n\n return new URL(url)\n}\n\n/**\n * Attempt to parse a string as a URL; return undefined if we can't\n */\nexport function tryParseUrl(\n url: string,\n options: URLParseOptions = {},\n): URL | undefined {\n try {\n return parseUrl(url, options)\n } catch {\n return undefined\n }\n}\n\n/**\n * Permissively parse a NOVA instance URL from a config variable.\n * If scheme is not specified, defaults to https for *.wandelbots.io hosts,\n * and http otherwise.\n * Throws an error if a valid URL could not be determined.\n */\nexport function parseNovaInstanceUrl(url: string): URL {\n const testUrl = tryParseUrl(url, { defaultScheme: \"http\" })\n if (testUrl?.host.endsWith(\".wandelbots.io\")) {\n return parseUrl(url, { defaultScheme: \"https\" })\n } else {\n return parseUrl(url, { defaultScheme: \"http\" })\n }\n}\n\n/** Try to parse something as JSON; return undefined if we can't */\n// biome-ignore lint/suspicious/noExplicitAny: it's json\nexport function tryParseJson(json: unknown): any {\n try {\n return JSON.parse(json as string)\n } catch {\n return undefined\n }\n}\n\n/** Try to turn something into JSON; return undefined if we can't */\nexport function tryStringifyJson(json: unknown): string | undefined {\n try {\n return JSON.stringify(json)\n } catch {\n return undefined\n }\n}\n\n/**\n * Converts object parameters to query string.\n * e.g. { a: \"1\", b: \"2\" } => \"?a=1&b=2\"\n * {} => \"\"\n */\nexport function makeUrlQueryString(obj: Record<string, string>): string {\n const str = new URLSearchParams(obj).toString()\n return str ? `?${str}` : \"\"\n}\n\n/** Convert radians to degrees */\nexport function radiansToDegrees(radians: number): number {\n return radians * (180 / Math.PI)\n}\n\n/** Convert degrees to radians */\nexport function degreesToRadians(degrees: number): number {\n return degrees * (Math.PI / 180)\n}\n\n/**\n * Check for coordinate system id equivalence, accounting for the \"world\" default\n * on empty/undefined values.\n */\nexport function isSameCoordinateSystem(\n firstCoordSystem: string | undefined,\n secondCoordSystem: string | undefined,\n) {\n if (!firstCoordSystem) firstCoordSystem = \"world\"\n if (!secondCoordSystem) secondCoordSystem = \"world\"\n\n return firstCoordSystem === secondCoordSystem\n}\n\n/**\n * Helpful const for converting {x, y, z} to [x, y, z] and vice versa\n */\nexport const XYZ_TO_VECTOR = { x: 0, y: 1, z: 2 }\n","/**\n * Mapping of stages to Auth0 configurations.\n * The client ids are public identifiers for a specific auth0 application\n * and are safe to include in client-side code.\n * https://auth0.com/docs/get-started/applications/application-settings\n */\nconst auth0ConfigMap = {\n dev: {\n domain: `https://auth.portal.dev.wandelbots.io`,\n clientId: \"fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha\",\n },\n stg: {\n domain: `https://auth.portal.stg.wandelbots.io`,\n clientId: \"joVDeD9e786WzFNSGCqoVq7HNkWt5j6s\",\n },\n prod: {\n domain: `https://auth.portal.wandelbots.io`,\n clientId: \"J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2\",\n },\n}\n\n/** Determine which Auth0 configuration to use based on instance URL */\nexport const getAuth0Config = (instanceUrl: URL) => {\n if (instanceUrl.host.endsWith(\".dev.wandelbots.io\")) return auth0ConfigMap.dev\n if (instanceUrl.host.endsWith(\".stg.wandelbots.io\")) return auth0ConfigMap.stg\n if (instanceUrl.host.endsWith(\".wandelbots.io\")) return auth0ConfigMap.prod\n throw new Error(\n `Unable to authenticate with NOVA instance \"${instanceUrl}\". Auth0 login is only supported for cloud instances with hosts of the form \"**.wandelbots.io\".`,\n )\n}\n\n/**\n * Initializes Auth0 login process using redirect if necessary and retrieves an access token.\n * Returns null when an access token should not be needed to authenticate (i.e. cookie auth\n * when deployed on the instance domain)\n */\nexport const loginWithAuth0 = async (\n instanceUrl: URL,\n): Promise<string | null> => {\n if (typeof window === \"undefined\") {\n throw new Error(\n `Access token must be set to use NovaClient when not in a browser environment.`,\n )\n }\n\n if (instanceUrl.origin === window.location.origin) {\n // When deployed on the instance itself, our auth is handled by cookies\n // and no access token is needed-- just need to reload the page and it'll\n // login again / set cookie as needed\n window.location.reload()\n throw new Error(\n \"Failed to reload page to get auth details, please refresh manually\",\n )\n }\n\n // If we're on localhost or another domain, we need to do the full oauth flow\n // Note this will ONLY work for origins which are whitelisted as a redirect_uri\n // in the auth0 config, currently\n const { Auth0Client } = await import(\"@auth0/auth0-spa-js\")\n\n const auth0Config = getAuth0Config(instanceUrl)\n\n const auth0Client = new Auth0Client({\n domain: auth0Config.domain,\n clientId: auth0Config.clientId ?? \"\",\n useRefreshTokens: false,\n authorizationParams: {\n audience: \"nova-api\",\n redirect_uri: window.location.origin,\n },\n })\n\n // If the URL includes a redirect result, handle it\n if (\n window.location.search.includes(\"code=\") &&\n window.location.search.includes(\"state=\")\n ) {\n const { appState } = await auth0Client.handleRedirectCallback()\n // Return to the URL the user was originally on before the redirect\n window.history.replaceState(\n {},\n document.title,\n appState?.returnTo || window.location.pathname,\n )\n } else {\n // Initiate login with redirect\n await auth0Client.loginWithRedirect()\n }\n\n // Once logged in, retrieve the access token silently\n const accessToken = await auth0Client.getTokenSilently()\n return accessToken\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAa,4BAAb,cAA+CA,+BAAsB;CAKnE,YACE,WACA,AAASC,OAGL,EAAE,EACN;AACA,UAAQ,IAAI,wBAAwB,UAAU;AAE9C,cAAY,KAAK,aAAa,WAAW,QAAW,EAClD,aAAa,MACd,CAAC;EATO;kBAJA;AAgBT,SAAO,eAAe,MAAM,OAAO,EACjC,MAAM;AACJ,UAAO,KAAK;KAEf,CAAC;AAEF,OAAK,YAAY;AAEjB,OAAK,iBAAiB,cAAc;AAClC,WAAQ,IAAI,gBAAgB,KAAK,IAAI,SAAS;IAC9C;AAEF,OAAK,iBAAiB,YAAY,OAAO;AACvC,OAAI,CAAC,KAAK,qBACR,MAAK,uBAAuB;IAE9B;AAEF,OAAK,iBAAiB,eAAe;AACnC,WAAQ,IAAI,gBAAgB,KAAK,IAAI,SAAS;IAC9C;EAEF,MAAM,gBAAgB,KAAK;AAC3B,OAAK,kBAAkB;AACrB,OAAI,KAAK,KAAK,KACZ,MAAK,KAAK,KAAK,0BAA0B,KAAK;OAE9C,eAAc,MAAM,KAAK;;AAI7B,OAAK,WAAW;;CAGlB,UAAU,WAAmB;AAC3B,OAAK,uBAAuB;AAC5B,OAAK,YAAY;AACjB,OAAK,WAAW;;CAGlB,SAAS,MAAe;AACtB,MAAI,KAAK,KAAK,KACZ,MAAK,KAAK,KAAK,uBAAuB,MAAM,KAAK,UAAU,KAAK,CAAC;MAEjE,MAAK,KAAK,KAAK,UAAU,KAAK,CAAC;;;;;;CAQnC,UAAU;AACR,OAAK,OAAO;AACZ,OAAK,WAAW;AAChB,MAAI,KA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D,SAAO,SAAS,QAAQ;AACxB,QAAM,IAAI,MACR,qEACD;;CAMH,MAAM,EAAE,gBAAgB,MAAM,OAAO;CAErC,MAAM,cAAc,eAAe,YAAY;CAE/C,MAAM,cAAc,IAAI,YAAY;EAClC,QAAQ,YAAY;EACpB,UAAU,YAAY,YAAY;EAClC,kBAAkB;EAClB,qBAAqB;GACnB,UAAU;GACV,cAAc,OAAO,SAAS;GAC/B;EACF,CAAC;AAGF,KACE,OAAO,SAAS,OAAO,SAAS,QAAQ,IACxC,OAAO,SAAS,OAAO,SAAS,SAAS,EACzC;EACA,MAAM,EAAE,aAAa,MAAM,YAAY,wBAAwB;AAE/D,SAAO,QAAQ,aACb,EAAE,EACF,SAAS,OACT,UAAU,YAAY,OAAO,SAAS,SACvC;OAGD,OAAM,YAAY,mBAAmB;AAKvC,QADoB,MAAM,YAAY,kBAAkB"}
@@ -1,4 +1,4 @@
1
- const require_LoginWithAuth0 = require('./LoginWithAuth0-iXpPiCcz.cjs');
1
+ const require_LoginWithAuth0 = require('./LoginWithAuth0-qpkGkrJo.cjs');
2
2
  let axios = require("axios");
3
3
  axios = require_LoginWithAuth0.__toESM(axios);
4
4
  let url_join = require("url-join");
@@ -7,7 +7,7 @@ let mobx = require("mobx");
7
7
  let three = require("three");
8
8
  three = require_LoginWithAuth0.__toESM(three);
9
9
  let three_src_math_Vector3_js = require("three/src/math/Vector3.js");
10
- let __wandelbots_nova_api_v1 = require("@wandelbots/nova-api/v1");
10
+ let _wandelbots_nova_api_v1 = require("@wandelbots/nova-api/v1");
11
11
  let path_to_regexp = require("path-to-regexp");
12
12
  path_to_regexp = require_LoginWithAuth0.__toESM(path_to_regexp);
13
13
 
@@ -581,32 +581,32 @@ var NovaCellAPIClient = class {
581
581
  constructor(cellId, opts) {
582
582
  this.cellId = cellId;
583
583
  this.opts = opts;
584
- this.system = this.withUnwrappedResponsesOnly(__wandelbots_nova_api_v1.SystemApi);
585
- this.cell = this.withUnwrappedResponsesOnly(__wandelbots_nova_api_v1.CellApi);
586
- this.deviceConfig = this.withCellId(__wandelbots_nova_api_v1.DeviceConfigurationApi);
587
- this.motionGroup = this.withCellId(__wandelbots_nova_api_v1.MotionGroupApi);
588
- this.motionGroupInfos = this.withCellId(__wandelbots_nova_api_v1.MotionGroupInfosApi);
589
- this.controller = this.withCellId(__wandelbots_nova_api_v1.ControllerApi);
590
- this.program = this.withCellId(__wandelbots_nova_api_v1.ProgramApi);
591
- this.programValues = this.withCellId(__wandelbots_nova_api_v1.ProgramValuesApi);
592
- this.controllerIOs = this.withCellId(__wandelbots_nova_api_v1.ControllerIOsApi);
593
- this.motionGroupKinematic = this.withCellId(__wandelbots_nova_api_v1.MotionGroupKinematicApi);
594
- this.motion = this.withCellId(__wandelbots_nova_api_v1.MotionApi);
595
- this.coordinateSystems = this.withCellId(__wandelbots_nova_api_v1.CoordinateSystemsApi);
596
- this.application = this.withCellId(__wandelbots_nova_api_v1.ApplicationApi);
597
- this.applicationGlobal = this.withUnwrappedResponsesOnly(__wandelbots_nova_api_v1.ApplicationApi);
598
- this.motionGroupJogging = this.withCellId(__wandelbots_nova_api_v1.MotionGroupJoggingApi);
599
- this.virtualRobot = this.withCellId(__wandelbots_nova_api_v1.VirtualRobotApi);
600
- this.virtualRobotSetup = this.withCellId(__wandelbots_nova_api_v1.VirtualRobotSetupApi);
601
- this.virtualRobotMode = this.withCellId(__wandelbots_nova_api_v1.VirtualRobotModeApi);
602
- this.virtualRobotBehavior = this.withCellId(__wandelbots_nova_api_v1.VirtualRobotBehaviorApi);
603
- this.libraryProgramMetadata = this.withCellId(__wandelbots_nova_api_v1.LibraryProgramMetadataApi);
604
- this.libraryProgram = this.withCellId(__wandelbots_nova_api_v1.LibraryProgramApi);
605
- this.libraryRecipeMetadata = this.withCellId(__wandelbots_nova_api_v1.LibraryRecipeMetadataApi);
606
- this.libraryRecipe = this.withCellId(__wandelbots_nova_api_v1.LibraryRecipeApi);
607
- this.storeObject = this.withCellId(__wandelbots_nova_api_v1.StoreObjectApi);
608
- this.storeCollisionComponents = this.withCellId(__wandelbots_nova_api_v1.StoreCollisionComponentsApi);
609
- this.storeCollisionScenes = this.withCellId(__wandelbots_nova_api_v1.StoreCollisionScenesApi);
584
+ this.system = this.withUnwrappedResponsesOnly(_wandelbots_nova_api_v1.SystemApi);
585
+ this.cell = this.withUnwrappedResponsesOnly(_wandelbots_nova_api_v1.CellApi);
586
+ this.deviceConfig = this.withCellId(_wandelbots_nova_api_v1.DeviceConfigurationApi);
587
+ this.motionGroup = this.withCellId(_wandelbots_nova_api_v1.MotionGroupApi);
588
+ this.motionGroupInfos = this.withCellId(_wandelbots_nova_api_v1.MotionGroupInfosApi);
589
+ this.controller = this.withCellId(_wandelbots_nova_api_v1.ControllerApi);
590
+ this.program = this.withCellId(_wandelbots_nova_api_v1.ProgramApi);
591
+ this.programValues = this.withCellId(_wandelbots_nova_api_v1.ProgramValuesApi);
592
+ this.controllerIOs = this.withCellId(_wandelbots_nova_api_v1.ControllerIOsApi);
593
+ this.motionGroupKinematic = this.withCellId(_wandelbots_nova_api_v1.MotionGroupKinematicApi);
594
+ this.motion = this.withCellId(_wandelbots_nova_api_v1.MotionApi);
595
+ this.coordinateSystems = this.withCellId(_wandelbots_nova_api_v1.CoordinateSystemsApi);
596
+ this.application = this.withCellId(_wandelbots_nova_api_v1.ApplicationApi);
597
+ this.applicationGlobal = this.withUnwrappedResponsesOnly(_wandelbots_nova_api_v1.ApplicationApi);
598
+ this.motionGroupJogging = this.withCellId(_wandelbots_nova_api_v1.MotionGroupJoggingApi);
599
+ this.virtualRobot = this.withCellId(_wandelbots_nova_api_v1.VirtualRobotApi);
600
+ this.virtualRobotSetup = this.withCellId(_wandelbots_nova_api_v1.VirtualRobotSetupApi);
601
+ this.virtualRobotMode = this.withCellId(_wandelbots_nova_api_v1.VirtualRobotModeApi);
602
+ this.virtualRobotBehavior = this.withCellId(_wandelbots_nova_api_v1.VirtualRobotBehaviorApi);
603
+ this.libraryProgramMetadata = this.withCellId(_wandelbots_nova_api_v1.LibraryProgramMetadataApi);
604
+ this.libraryProgram = this.withCellId(_wandelbots_nova_api_v1.LibraryProgramApi);
605
+ this.libraryRecipeMetadata = this.withCellId(_wandelbots_nova_api_v1.LibraryRecipeMetadataApi);
606
+ this.libraryRecipe = this.withCellId(_wandelbots_nova_api_v1.LibraryRecipeApi);
607
+ this.storeObject = this.withCellId(_wandelbots_nova_api_v1.StoreObjectApi);
608
+ this.storeCollisionComponents = this.withCellId(_wandelbots_nova_api_v1.StoreCollisionComponentsApi);
609
+ this.storeCollisionScenes = this.withCellId(_wandelbots_nova_api_v1.StoreCollisionScenesApi);
610
610
  }
611
611
  /**
612
612
  * Some TypeScript sorcery which alters the API class methods so you don't
@@ -2040,4 +2040,4 @@ Object.defineProperty(exports, 'poseToWandelscriptString', {
2040
2040
  return poseToWandelscriptString;
2041
2041
  }
2042
2042
  });
2043
- //# sourceMappingURL=NovaClient-j40sHBBq.cjs.map
2043
+ //# sourceMappingURL=NovaClient-CKpbwv53.cjs.map