@wandelbots/nova-js 3.2.0-pr.dev-e2e-jogging-test.143.4f02caf → 3.2.0-pr.feat-v2.155.e91b019

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 (66) hide show
  1. package/README.md +60 -50
  2. package/dist/{AutoReconnectingWebsocket-BI1ckzP8.d.ts → AutoReconnectingWebsocket-CoU4ZyD2.d.cts} +1 -3
  3. package/dist/AutoReconnectingWebsocket-CoU4ZyD2.d.cts.map +1 -0
  4. package/dist/{AutoReconnectingWebsocket-Cr7f9016.d.cts → AutoReconnectingWebsocket-D0gTrkzu.d.ts} +1 -3
  5. package/dist/AutoReconnectingWebsocket-D0gTrkzu.d.ts.map +1 -0
  6. package/dist/{LoginWithAuth0-0g0wWRUC.js → LoginWithAuth0-CaX7yo7d.js} +58 -5
  7. package/dist/LoginWithAuth0-CaX7yo7d.js.map +1 -0
  8. package/dist/{LoginWithAuth0-C82OCyDy.cjs → LoginWithAuth0-DaPnTz2I.cjs} +99 -4
  9. package/dist/LoginWithAuth0-DaPnTz2I.cjs.map +1 -0
  10. package/dist/index.cjs +11 -10
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +11 -8
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.ts +11 -8
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -3
  17. package/dist/lib/v1/index.cjs +17 -19
  18. package/dist/lib/v1/index.cjs.map +1 -1
  19. package/dist/lib/v1/index.d.cts +4 -2
  20. package/dist/lib/v1/index.d.cts.map +1 -1
  21. package/dist/lib/v1/index.d.ts +4 -2
  22. package/dist/lib/v1/index.d.ts.map +1 -1
  23. package/dist/lib/v1/index.js +7 -10
  24. package/dist/lib/v1/index.js.map +1 -1
  25. package/dist/lib/v2/index.cjs +1087 -11
  26. package/dist/lib/v2/index.cjs.map +1 -1
  27. package/dist/lib/v2/index.d.cts +256 -7
  28. package/dist/lib/v2/index.d.cts.map +1 -1
  29. package/dist/lib/v2/index.d.ts +256 -7
  30. package/dist/lib/v2/index.d.ts.map +1 -1
  31. package/dist/lib/v2/index.js +1082 -12
  32. package/dist/lib/v2/index.js.map +1 -1
  33. package/dist/wandelscriptUtils-CO5GYRij.js +24 -0
  34. package/dist/wandelscriptUtils-CO5GYRij.js.map +1 -0
  35. package/dist/wandelscriptUtils-COHpTIme.d.cts +12 -0
  36. package/dist/wandelscriptUtils-COHpTIme.d.cts.map +1 -0
  37. package/dist/wandelscriptUtils-Cl3GBxOp.d.ts +12 -0
  38. package/dist/wandelscriptUtils-Cl3GBxOp.d.ts.map +1 -0
  39. package/dist/wandelscriptUtils-DwpJ4jCy.cjs +30 -0
  40. package/dist/wandelscriptUtils-DwpJ4jCy.cjs.map +1 -0
  41. package/package.json +2 -2
  42. package/src/LoginWithAuth0.ts +3 -3
  43. package/src/index.ts +1 -0
  44. package/src/lib/converters.ts +5 -23
  45. package/src/lib/v1/MotionStreamConnection.ts +1 -1
  46. package/src/lib/v1/NovaClient.ts +6 -0
  47. package/src/lib/v1/index.ts +6 -0
  48. package/src/lib/v1/mock/MockNovaInstance.ts +0 -1
  49. package/src/lib/v1/wandelscriptUtils.ts +22 -0
  50. package/src/lib/v2/ConnectedMotionGroup.ts +415 -0
  51. package/src/lib/v2/JoggerConnection.ts +647 -0
  52. package/src/lib/v2/MotionStreamConnection.ts +222 -0
  53. package/src/lib/v2/NovaClient.ts +43 -8
  54. package/src/lib/v2/index.ts +5 -0
  55. package/src/lib/v2/mock/MockNovaInstance.ts +385 -1
  56. package/src/lib/v2/motionStateUpdate.ts +76 -0
  57. package/src/lib/v2/types/vector3.ts +1 -0
  58. package/src/lib/v2/wandelscriptUtils.ts +27 -0
  59. package/dist/AutoReconnectingWebsocket-BI1ckzP8.d.ts.map +0 -1
  60. package/dist/AutoReconnectingWebsocket-Cr7f9016.d.cts.map +0 -1
  61. package/dist/LoginWithAuth0-0g0wWRUC.js.map +0 -1
  62. package/dist/LoginWithAuth0-C82OCyDy.cjs.map +0 -1
  63. package/dist/converters-DP2EIVv6.cjs +0 -108
  64. package/dist/converters-DP2EIVv6.cjs.map +0 -1
  65. package/dist/converters-DY6Lf7mb.js +0 -66
  66. package/dist/converters-DY6Lf7mb.js.map +0 -1
package/README.md CHANGED
@@ -20,14 +20,15 @@ If you develop an React application we also provide a set of [React components](
20
20
  - [API calls](#api-calls)
21
21
  - [Opening websockets](#opening-websockets)
22
22
  - [Connect to a motion group](#connect-to-a-motion-group)
23
- - [Execute Wandelscript](#execute-wandelscript)
24
23
  - [Jogging](#jogging)
25
24
  - [Stopping the jogger](#stopping-the-jogger)
26
- - [Rotating a joint](#rotating-a-joint)
27
- - [Moving a TCP](#moving-the-tcp)
28
- - [Rotating a TCP](#rotating-the-tcp)
25
+ - [Jogging: Rotating a joint](#jogging-rotating-a-joint-rotatejoints)
26
+ - [Jogging: Moving a TCP](#jogging-moving-a-tcp-translatetcp)
27
+ - [Jogging: Rotating a TCP](#jogging-rotating-a-tcp-rotatetcp)
28
+ - [Trajectory: Plan and run incremental motion](#trajectory-plan-and-run-incremental-motion-runincrementalcartesianmotion)
29
29
  - [Post-jogging cleanup](#post-jogging-cleanup)
30
30
  - [Jogging UI Panel](#jogging-ui-panel)
31
+ - [Execute Wandelscript (V1)](#execute-wandelscript-v1)
31
32
 
32
33
  ## Basic usage
33
34
 
@@ -39,7 +40,6 @@ import { NovaClient } from "@wandelbots/nova-js"
39
40
  const nova = new NovaClient({
40
41
  instanceUrl: "https://example.instance.wandelbots.io",
41
42
  cellId: "cell",
42
-
43
43
  // Access token is given in the developer portal UI when you create an instance
44
44
  accessToken: "...",
45
45
  })
@@ -47,15 +47,12 @@ const nova = new NovaClient({
47
47
 
48
48
  ## API Version Support
49
49
 
50
- This library primarily supports **Nova API v1**, which provides full functionality including motion group connections, jogging, program execution, and all the features documented below.
51
-
52
- **Nova API v2** support is currently **experimental and limited**. While v2 API endpoints are accessible through the NovaCellAPIClient, many of the higher-level abstractions (like `connectMotionGroup`, `connectJogger`, and `ProgramStateConnection`) are not yet available for v2.
50
+ This library supports **Nova API v1** and **v2**, which provides extra functionality including motion group connections, jogging, and all the features documented below. Please note that except for Wandelscript execution, usage of **API v1** is deprecated and not reccomended.
53
51
 
54
- For v2 usage:
52
+ V1 usage:
55
53
 
56
54
  ```ts
57
- // Note: v2 support is experimental
58
- import { NovaClient } from "@wandelbots/nova-js/v2"
55
+ import { NovaClient } from "@wandelbots/nova-js/v1"
59
56
 
60
57
  const nova = new NovaClient({
61
58
  instanceUrl: "https://example.instance.wandelbots.io",
@@ -63,12 +60,10 @@ const nova = new NovaClient({
63
60
  accessToken: "...",
64
61
  })
65
62
 
66
- // Direct API access is available
67
- const { controllers } = await nova.api.controller.listRobotControllers()
63
+ // Deprecated API version is still callable
64
+ const { instances } = await nova.api.controller.listControllers()
68
65
  ```
69
66
 
70
- We recommend using **v1** for production applications until v2 support is fully implemented.
71
-
72
67
  ## API calls
73
68
 
74
69
  You can make calls to the REST API via `nova.api`, which contains a bunch of namespaced methods for each endpoint generated from the OpenAPI spec and documentation.
@@ -76,11 +71,11 @@ You can make calls to the REST API via `nova.api`, which contains a bunch of nam
76
71
  For example, to list the controllers configured in your cell:
77
72
 
78
73
  ```ts
79
- const { instances } = await nova.api.controller.listControllers()
80
- // -> e.g. [{ controller: "ur5e", model_name: "UniversalRobots::Controller", ... }, ...]
74
+ const controllerIds = await nova.api.controller.listRobotControllers()
75
+ // -> e.g. ["ur5e", ...]
81
76
  ```
82
77
 
83
- Documentation for the various API endpoints is available on your Nova instance at `/api/v1/ui` (public documentation site is in the works)
78
+ Documentation for the various API endpoints is available on your Nova instance at `/api/v2/ui` or on [portal.wandelbots.io](https://portal.wandelbots.io/docs/api/v2/ui/)
84
79
 
85
80
  ## Opening websockets
86
81
 
@@ -114,43 +109,40 @@ This connected motion group opens a websocket and listens to changes of the curr
114
109
 
115
110
  ```ts
116
111
  const newJoints =
117
- activeRobot.rapidlyChangingMotionState.state.joint_position.joints
112
+ activeRobot.rapidlyChangingMotionState.joint_position
118
113
  ```
119
114
 
120
- To render a visual representation, you can use the `robot` component of the [react components](https://wandelbotsgmbh.github.io/wandelbots-js-react-components/?path=/docs/3d-view-robot--docs).
121
-
122
- ## Execute Wandelscript
123
-
124
- The `ProgramStateConnection` provides an object which allows to execute and stop a given Wandelscript.
115
+ **Api V2 change:** Please not that joints are now directly accessible in `rapidlyChangingMotionState.joint_position`, previously there were nested in `.rapidlyChangingMotionState.state.joint_position.joints`.
125
116
 
126
- ```ts
127
- import script from "./example.ws"
128
- ...
129
- programRunner.executeProgram(script)
130
- ```
131
-
132
- You can `stop` the current execution or listen to state updates of your wandelscript code by observing the `programRunner.executionState`.
117
+ To render a visual representation, you can use the `robot` component of the [react components](https://wandelbotsgmbh.github.io/wandelbots-js-react-components/?path=/docs/3d-view-robot--docs).
133
118
 
134
119
  ## Jogging
135
120
 
136
121
  Jogging in a robotics context generally refers to the manual movement of the robot via direct human input. The Wandelbots platform provides websocket-based jogging methods which can be used to build similar jogging interfaces to those found on teach pendants.
137
122
 
138
123
  ```ts
139
- const jogger = await nova.connectJogger(`some-motion-group-id`)
124
+ const jogger = await nova.connectJogger(`some-motion-group-id`) // or to set options
125
+ // const jogger = await nova.connectJogger(`some-motion-group-id`, { options })
140
126
  ```
141
127
 
142
- The jogger has two mutually exclusive modes. You must set the appropriate jogging mode before starting a jogging motion; this ensures that the motion is ready to start immediately when called with minimal delay.
128
+ The jogger's mode is set to "off" first. You'll need to set it to "jogging" or "trajectory" to be able to
129
+ send movement commands
143
130
 
144
131
  ```ts
145
- // Set the jogger to "joint" mode, enabling continuous joint rotations.
146
- await jogger.setJoggingMode("joint")
147
-
148
- // Set the jogger to "tcp" mode, enabling continuous translation
149
- // and rotation movements of the tool center point.
150
- await jogger.setJoggingMode("tcp", {
151
- tcpId: "flange",
152
- coordSystemId: "world",
132
+ // Set jogger to "jogging" mode and sends InitializeJoggingRequest to API
133
+ await jogger.setJoggingMode("jogging")
134
+
135
+ // You can update options afeter initializing like this:
136
+ await jogger.updateOptions({
137
+ tcp: "Flange", // TCP id
138
+ timeout: 3000 // How long the promise should wait when server does not respond to init request
139
+ orientation: "mode",
153
140
  })
141
+
142
+ // For planned motions, use "trajectory" mode
143
+ await jogger.setJoggingMode("trajectory")
144
+ await jogger.rotateTCP({...}) // Error: Continuous jogging websocket not connected; ...
145
+ await jogger.runIncrementalCartesianMotion({...}) // Plan and run trajectory
154
146
  ```
155
147
 
156
148
  ### Stopping the jogger
@@ -165,42 +157,48 @@ As a failsafe, the server will also stop any jogging motions when it detects the
165
157
 
166
158
  However, you should never totally rely on any software being able to stop the robot: always have the hardware emergency stop button within reach just in case!
167
159
 
168
- ### Rotating a joint
160
+ ### Jogging: Rotating a joint `rotateJoints`
169
161
 
170
- Requires `joint` mode. This example starts joint 0 of the robot rotating in a positive direction at 1 radian per second:
162
+ This example starts joint 0 of the robot rotating in a positive direction at 1 radian per second:
171
163
 
172
164
  ```ts
173
- await jogger.startJointRotation({
165
+ await jogger.rotateJoints({
174
166
  joint: 0,
175
167
  direction: "+",
176
168
  velocityRadsPerSec: 1,
177
169
  })
178
170
  ```
179
171
 
180
- ### Moving a TCP
172
+ ### Jogging: Moving a TCP `translateTCP`
181
173
 
182
- Requires `tcp` mode. This example starts moving a TCP in a positive direction along the X axis of the specified coordinate system, at a velocity of 10 millimeters per second:
174
+ This example starts moving a TCP in a positive direction along the X axis of the specified coordinate system, at a velocity of 10 millimeters per second:
183
175
 
184
176
  ```ts
185
- await jogger.startTCPTranslation({
177
+ await jogger.translateTCP({
186
178
  axis: "x",
187
179
  direction: "+",
188
180
  velocityMmPerSec: 10,
189
181
  })
190
182
  ```
191
183
 
192
- ### Rotating a TCP
184
+ ### Jogging: Rotating a TCP `rotateTCP`
193
185
 
194
- Requires `tcp` mode. This example starts rotating the TCP in a positive direction around the X axis of the specified coordinate system, at a velocity of 1 radians per second:
186
+ This example starts rotating the TCP in a positive direction around the X axis of the specified coordinate system, at a velocity of 1 radians per second:
195
187
 
196
188
  ```ts
197
- await jogger.startTCPRotation({
189
+ await jogger.rotateTCP({
198
190
  axis: "x",
199
191
  direction: "+",
200
192
  velocityRadsPerSec: 1,
201
193
  })
202
194
  ```
203
195
 
196
+ ### Trajectory: Plan and run incremental motion `runIncrementalCartesianMotion`
197
+
198
+ ```ts
199
+ await jogger.runIncrementalCartesianMotion({...})
200
+ ```
201
+
204
202
  ### Post-jogging cleanup
205
203
 
206
204
  When you are done with a jogger, make sure to call dispose:
@@ -215,6 +213,18 @@ This will close any open websockets and ensure things are left in a good state.
215
213
 
216
214
  You can use the [Jogging Panel](https://wandelbotsgmbh.github.io/wandelbots-js-react-components/?path=/docs/jogging-joggingpanel--docs) from the [react components](https://github.com/wandelbotsgmbh/wandelbots-js-react-components) library to get a easy to use visualization component.
217
215
 
216
+ ## Execute Wandelscript (V1)
217
+
218
+ The `ProgramStateConnection` provides an object which allows to execute and stop a given Wandelscript.
219
+
220
+ ```ts
221
+ import script from "./example.ws"
222
+ ...
223
+ programRunner.executeProgram(script)
224
+ ```
225
+
226
+ You can `stop` the current execution or listen to state updates of your wandelscript code by observing the `programRunner.executionState`.
227
+
218
228
  ## Contributing
219
229
 
220
230
  If you would like to contribute a change to this repository, see [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -4,7 +4,6 @@ import { AxiosResponse, InternalAxiosRequestConfig } from "axios";
4
4
  //#region src/lib/v1/mock/MockNovaInstance.d.ts
5
5
 
6
6
  /**
7
- * EXPERIMENTAL
8
7
  * Ultra-simplified mock Nova server for testing stuff
9
8
  */
10
9
  declare class MockNovaInstance$1 {
@@ -16,7 +15,6 @@ declare class MockNovaInstance$1 {
16
15
  //#endregion
17
16
  //#region src/lib/v2/mock/MockNovaInstance.d.ts
18
17
  /**
19
- * EXPERIMENTAL
20
18
  * Ultra-simplified mock Nova server for testing stuff
21
19
  */
22
20
  declare class MockNovaInstance {
@@ -68,4 +66,4 @@ declare class AutoReconnectingWebsocket extends ReconnectingWebSocket {
68
66
  }
69
67
  //#endregion
70
68
  export { AutoReconnectingWebsocket, MockNovaInstance, MockNovaInstance$1 };
71
- //# sourceMappingURL=AutoReconnectingWebsocket-BI1ckzP8.d.ts.map
69
+ //# sourceMappingURL=AutoReconnectingWebsocket-CoU4ZyD2.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoReconnectingWebsocket-CoU4ZyD2.d.cts","names":[],"sources":["../src/lib/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;AAA6B,cAAhB,kBAAA,CAAgB;WACL,WAAA,EAAA,yBAAA,EAAA;kBAGZ,CAAA,MAAA,EAAA,0BAAA,CAAA,EACP,OADO,CACC,aADD,CAAA;2BACC,CAAA,MAAA,EAg8BuB,yBAh8BvB,CAAA,EAAA,IAAA;wBAAR,CAAA,MAAA,EAkqC4B,yBAlqC5B,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;;;AALL;AAA6B,cCNhB,gBAAA,CDMgB;WACL,WAAA,ECNA,yBDMA,EAAA;kBAGZ,CAAA,MAAA,ECNA,0BDMA,CAAA,ECLP,ODKO,CCLC,aDKD,CAAA;2BACC,CAAA,MAAA,ECsiCuB,yBDtiCvB,CAAA,EAAA,IAAA;wBAAR,CAAA,MAAA,ECkwC4B,yBDlwC5B,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;cEhBQ,yBAAA,SAAkC,qBAAA;EFWlC,SAAA,IAAA,EAAA;IAAgB,IAAA,CAAA,EEHhB,kBFGgB,GEHM,gBFGN;IACL,SAAA,CAAA,EAAA,GAAA,GAAA,IAAA;;sBAIX,CAAA,EEfY,YFeZ;WAAR,EAAA,MAAA;UAg8B+B,EAAA,OAAA;aAkOH,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,EAAA;IAAyB,IAAA,CAAA,EE1qC7C,kBF0qC6C,GE1qCvB,gBF0qCuB;;;;EC7qC7C,QAAA,CAAA,IAAA,EAAA,OAAgB,CAAA,EAAA,IAAA;EAAA;;;;SAKxB,CAAA,CAAA,EAAA,IAAA;;;;YCwES;;;AAlFd;EAAuC,MAAA,CAAA,CAAA,EAgGzB,OAhGyB,CAAA,IAAA,CAAA;;;;;;cAkFzB,CAAA,CAAA,EA8BM,OA9BN,CA8BM,YA9BN,CAAA,GAAA,CAAA,CAAA;;;;;aA0DK,CAAA,CAAA,EAAA,OAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA"}
@@ -4,7 +4,6 @@ import { AxiosResponse, InternalAxiosRequestConfig } from "axios";
4
4
  //#region src/lib/v1/mock/MockNovaInstance.d.ts
5
5
 
6
6
  /**
7
- * EXPERIMENTAL
8
7
  * Ultra-simplified mock Nova server for testing stuff
9
8
  */
10
9
  declare class MockNovaInstance$1 {
@@ -16,7 +15,6 @@ declare class MockNovaInstance$1 {
16
15
  //#endregion
17
16
  //#region src/lib/v2/mock/MockNovaInstance.d.ts
18
17
  /**
19
- * EXPERIMENTAL
20
18
  * Ultra-simplified mock Nova server for testing stuff
21
19
  */
22
20
  declare class MockNovaInstance {
@@ -68,4 +66,4 @@ declare class AutoReconnectingWebsocket extends ReconnectingWebSocket {
68
66
  }
69
67
  //#endregion
70
68
  export { AutoReconnectingWebsocket, MockNovaInstance, MockNovaInstance$1 };
71
- //# sourceMappingURL=AutoReconnectingWebsocket-Cr7f9016.d.cts.map
69
+ //# sourceMappingURL=AutoReconnectingWebsocket-D0gTrkzu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoReconnectingWebsocket-D0gTrkzu.d.ts","names":[],"sources":["../src/lib/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;AAA6B,cAAhB,kBAAA,CAAgB;WACL,WAAA,EAAA,yBAAA,EA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ion
157
+ //#region src/lib/converters.ts
158
+ /** Try to parse something as JSON; return undefined if we can't */
159
+ function tryParseJson(json) {
160
+ try {
161
+ return JSON.parse(json);
162
+ } catch {
163
+ return;
164
+ }
165
+ }
166
+ /** Try to turn something into JSON; return undefined if we can't */
167
+ function tryStringifyJson(json) {
168
+ try {
169
+ return JSON.stringify(json);
170
+ } catch {
171
+ return;
172
+ }
173
+ }
174
+ /**
175
+ * Converts object parameters to query string.
176
+ * e.g. { a: "1", b: "2" } => "?a=1&b=2"
177
+ * {} => ""
178
+ */
179
+ function makeUrlQueryString(obj) {
180
+ const str = new URLSearchParams(obj).toString();
181
+ return str ? `?${str}` : "";
182
+ }
183
+ /** Convert radians to degrees */
184
+ function radiansToDegrees(radians) {
185
+ return radians * (180 / Math.PI);
186
+ }
187
+ /** Convert degrees to radians */
188
+ function degreesToRadians(degrees) {
189
+ return degrees * (Math.PI / 180);
190
+ }
191
+ /**
192
+ * Check for coordinate system id equivalence, accounting for the "world" default
193
+ * on empty/undefined values.
194
+ */
195
+ function isSameCoordinateSystem(firstCoordSystem, secondCoordSystem) {
196
+ if (!firstCoordSystem) firstCoordSystem = "world";
197
+ if (!secondCoordSystem) secondCoordSystem = "world";
198
+ return firstCoordSystem === secondCoordSystem;
199
+ }
200
+ /**
201
+ * Helpful const for converting {x, y, z} to [x, y, z] and vice versa
202
+ */
203
+ const XYZ_TO_VECTOR = {
204
+ x: 0,
205
+ y: 1,
206
+ z: 2
207
+ };
208
+
156
209
  //#endregion
157
210
  //#region src/LoginWithAuth0.ts
158
211
  const DOMAIN_SUFFIX = "wandelbots.io";
@@ -178,9 +231,9 @@ const auth0ConfigMap = {
178
231
  };
179
232
  /** Determine which Auth0 configuration to use based on instance URL */
180
233
  const getAuth0Config = (instanceUrl) => {
181
- if (instanceUrl.includes(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev;
182
- if (instanceUrl.includes(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg;
183
- if (instanceUrl.includes(DOMAIN_SUFFIX)) return auth0ConfigMap.prod;
234
+ if (instanceUrl.endsWith(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev;
235
+ if (instanceUrl.endsWith(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg;
236
+ if (instanceUrl.endsWith(DOMAIN_SUFFIX)) return auth0ConfigMap.prod;
184
237
  throw new Error("Unsupported instance URL. Cannot determine Auth0 configuration.");
185
238
  };
186
239
  /**
@@ -213,5 +266,5 @@ const loginWithAuth0 = async (instanceUrl) => {
213
266
  };
214
267
 
215
268
  //#endregion
216
- export { AutoReconnectingWebsocket, availableStorage, loginWithAuth0 };
217
- //# sourceMappingURL=LoginWithAuth0-0g0wWRUC.js.map
269
+ export { AutoReconnectingWebsocket, XYZ_TO_VECTOR, availableStorage, degreesToRadians, isSameCoordinateSystem, loginWithAuth0, makeUrlQueryString, radiansToDegrees, tryParseJson, tryStringifyJson };
270
+ //# sourceMappingURL=LoginWithAuth0-CaX7yo7d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoginWithAuth0-CaX7yo7d.js","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","/** 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","const DOMAIN_SUFFIX = \"wandelbots.io\"\n\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.${DOMAIN_SUFFIX}`,\n clientId: \"fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha\",\n },\n stg: {\n domain: `https://auth.portal.stg.${DOMAIN_SUFFIX}`,\n clientId: \"joVDeD9e786WzFNSGCqoVq7HNkWt5j6s\",\n },\n prod: {\n domain: `https://auth.portal.${DOMAIN_SUFFIX}`,\n clientId: \"J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2\",\n },\n}\n\n/** Determine which Auth0 configuration to use based on instance URL */\nconst getAuth0Config = (instanceUrl: string) => {\n if (instanceUrl.endsWith(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev\n if (instanceUrl.endsWith(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg\n if (instanceUrl.endsWith(DOMAIN_SUFFIX)) return auth0ConfigMap.prod\n throw new Error(\n \"Unsupported instance URL. Cannot determine Auth0 configuration.\",\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: string,\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 const auth0Config = getAuth0Config(instanceUrl)\n\n if (new URL(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 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,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SAAS,OAAO,gBAAgB,CAAE,QAAO,eAAe;AACxE,KAAI,YAAY,SAAS,OAAO,gBAAgB,CAAE,QAAO,eAAe;AACxE,KAAI,YAAY,SAAS,cAAc,CAAE,QAAO,eAAe;AAC/D,OAAM,IAAI,MACR,kEACD;;;;;;;AAQH,MAAa,iBAAiB,OAC5B,gBAC2B;AAC3B,KAAI,OAAO,WAAW,YACpB,OAAM,IAAI,MACR,gFACD;CAGH,MAAM,cAAc,eAAe,YAAY;AAE/C,KAAI,IAAI,IAAI,YAAY,CAAC,WAAW,OAAO,SAAS,QAAQ;AAI1D,SAAO,SAAS,QAAQ;AACxB,QAAM,IAAI,MACR,qEACD;;CAMH,MAAM,EAAE,gBAAgB,MAAM,OAAO;CAErC,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"}
@@ -177,6 +177,59 @@ var AvailableStorage = class {
177
177
  };
178
178
  const availableStorage = new AvailableStorage();
179
179
 
180
+ //#endregion
181
+ //#region src/lib/converters.ts
182
+ /** Try to parse something as JSON; return undefined if we can't */
183
+ function tryParseJson(json) {
184
+ try {
185
+ return JSON.parse(json);
186
+ } catch {
187
+ return;
188
+ }
189
+ }
190
+ /** Try to turn something into JSON; return undefined if we can't */
191
+ function tryStringifyJson(json) {
192
+ try {
193
+ return JSON.stringify(json);
194
+ } catch {
195
+ return;
196
+ }
197
+ }
198
+ /**
199
+ * Converts object parameters to query string.
200
+ * e.g. { a: "1", b: "2" } => "?a=1&b=2"
201
+ * {} => ""
202
+ */
203
+ function makeUrlQueryString(obj) {
204
+ const str = new URLSearchParams(obj).toString();
205
+ return str ? `?${str}` : "";
206
+ }
207
+ /** Convert radians to degrees */
208
+ function radiansToDegrees(radians) {
209
+ return radians * (180 / Math.PI);
210
+ }
211
+ /** Convert degrees to radians */
212
+ function degreesToRadians(degrees) {
213
+ return degrees * (Math.PI / 180);
214
+ }
215
+ /**
216
+ * Check for coordinate system id equivalence, accounting for the "world" default
217
+ * on empty/undefined values.
218
+ */
219
+ function isSameCoordinateSystem(firstCoordSystem, secondCoordSystem) {
220
+ if (!firstCoordSystem) firstCoordSystem = "world";
221
+ if (!secondCoordSystem) secondCoordSystem = "world";
222
+ return firstCoordSystem === secondCoordSystem;
223
+ }
224
+ /**
225
+ * Helpful const for converting {x, y, z} to [x, y, z] and vice versa
226
+ */
227
+ const XYZ_TO_VECTOR = {
228
+ x: 0,
229
+ y: 1,
230
+ z: 2
231
+ };
232
+
180
233
  //#endregion
181
234
  //#region src/LoginWithAuth0.ts
182
235
  const DOMAIN_SUFFIX = "wandelbots.io";
@@ -202,9 +255,9 @@ const auth0ConfigMap = {
202
255
  };
203
256
  /** Determine which Auth0 configuration to use based on instance URL */
204
257
  const getAuth0Config = (instanceUrl) => {
205
- if (instanceUrl.includes(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev;
206
- if (instanceUrl.includes(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg;
207
- if (instanceUrl.includes(DOMAIN_SUFFIX)) return auth0ConfigMap.prod;
258
+ if (instanceUrl.endsWith(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev;
259
+ if (instanceUrl.endsWith(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg;
260
+ if (instanceUrl.endsWith(DOMAIN_SUFFIX)) return auth0ConfigMap.prod;
208
261
  throw new Error("Unsupported instance URL. Cannot determine Auth0 configuration.");
209
262
  };
210
263
  /**
@@ -243,6 +296,12 @@ Object.defineProperty(exports, 'AutoReconnectingWebsocket', {
243
296
  return AutoReconnectingWebsocket;
244
297
  }
245
298
  });
299
+ Object.defineProperty(exports, 'XYZ_TO_VECTOR', {
300
+ enumerable: true,
301
+ get: function () {
302
+ return XYZ_TO_VECTOR;
303
+ }
304
+ });
246
305
  Object.defineProperty(exports, '__toESM', {
247
306
  enumerable: true,
248
307
  get: function () {
@@ -255,10 +314,46 @@ Object.defineProperty(exports, 'availableStorage', {
255
314
  return availableStorage;
256
315
  }
257
316
  });
317
+ Object.defineProperty(exports, 'degreesToRadians', {
318
+ enumerable: true,
319
+ get: function () {
320
+ return degreesToRadians;
321
+ }
322
+ });
323
+ Object.defineProperty(exports, 'isSameCoordinateSystem', {
324
+ enumerable: true,
325
+ get: function () {
326
+ return isSameCoordinateSystem;
327
+ }
328
+ });
258
329
  Object.defineProperty(exports, 'loginWithAuth0', {
259
330
  enumerable: true,
260
331
  get: function () {
261
332
  return loginWithAuth0;
262
333
  }
263
334
  });
264
- //# sourceMappingURL=LoginWithAuth0-C82OCyDy.cjs.map
335
+ Object.defineProperty(exports, 'makeUrlQueryString', {
336
+ enumerable: true,
337
+ get: function () {
338
+ return makeUrlQueryString;
339
+ }
340
+ });
341
+ Object.defineProperty(exports, 'radiansToDegrees', {
342
+ enumerable: true,
343
+ get: function () {
344
+ return radiansToDegrees;
345
+ }
346
+ });
347
+ Object.defineProperty(exports, 'tryParseJson', {
348
+ enumerable: true,
349
+ get: function () {
350
+ return tryParseJson;
351
+ }
352
+ });
353
+ Object.defineProperty(exports, 'tryStringifyJson', {
354
+ enumerable: true,
355
+ get: function () {
356
+ return tryStringifyJson;
357
+ }
358
+ });
359
+ //# sourceMappingURL=LoginWithAuth0-DaPnTz2I.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoginWithAuth0-DaPnTz2I.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","/** 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","const DOMAIN_SUFFIX = \"wandelbots.io\"\n\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.${DOMAIN_SUFFIX}`,\n clientId: \"fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha\",\n },\n stg: {\n domain: `https://auth.portal.stg.${DOMAIN_SUFFIX}`,\n clientId: \"joVDeD9e786WzFNSGCqoVq7HNkWt5j6s\",\n },\n prod: {\n domain: `https://auth.portal.${DOMAIN_SUFFIX}`,\n clientId: \"J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2\",\n },\n}\n\n/** Determine which Auth0 configuration to use based on instance URL */\nconst getAuth0Config = (instanceUrl: string) => {\n if (instanceUrl.endsWith(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev\n if (instanceUrl.endsWith(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg\n if (instanceUrl.endsWith(DOMAIN_SUFFIX)) return auth0ConfigMap.prod\n throw new Error(\n \"Unsupported instance URL. Cannot determine Auth0 configuration.\",\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: string,\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 const auth0Config = getAuth0Config(instanceUrl)\n\n if (new URL(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 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;;CA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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"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- const require_LoginWithAuth0 = require('./LoginWithAuth0-C82OCyDy.cjs');
2
- const require_converters = require('./converters-DP2EIVv6.cjs');
1
+ const require_LoginWithAuth0 = require('./LoginWithAuth0-DaPnTz2I.cjs');
2
+ const require_wandelscriptUtils = require('./wandelscriptUtils-DwpJ4jCy.cjs');
3
3
  let axios = require("axios");
4
4
  axios = require_LoginWithAuth0.__toESM(axios);
5
5
 
@@ -28,22 +28,23 @@ function makeErrorMessage(err) {
28
28
  else return `${err.message} from ${err.config.method?.toUpperCase() || "accessing"} ${err.config.url}`;
29
29
  } else if (err instanceof Error) return err.message;
30
30
  else if (typeof err === "string") return err;
31
- else if (typeof err === "object") return require_converters.tryStringifyJson(err) || `Unserializable object ${err}`;
31
+ else if (typeof err === "object") return require_LoginWithAuth0.tryStringifyJson(err) || `Unserializable object ${err}`;
32
32
  return `${err}`;
33
33
  }
34
34
 
35
35
  //#endregion
36
36
  exports.AutoReconnectingWebsocket = require_LoginWithAuth0.AutoReconnectingWebsocket;
37
+ exports.XYZ_TO_VECTOR = require_LoginWithAuth0.XYZ_TO_VECTOR;
37
38
  exports.availableStorage = require_LoginWithAuth0.availableStorage;
38
- exports.degreesToRadians = require_converters.degreesToRadians;
39
+ exports.degreesToRadians = require_LoginWithAuth0.degreesToRadians;
39
40
  exports.delay = delay;
40
- exports.isSameCoordinateSystem = require_converters.isSameCoordinateSystem;
41
+ exports.isSameCoordinateSystem = require_LoginWithAuth0.isSameCoordinateSystem;
41
42
  exports.loginWithAuth0 = require_LoginWithAuth0.loginWithAuth0;
42
43
  exports.makeErrorMessage = makeErrorMessage;
43
44
  exports.makeShortErrorMessage = makeShortErrorMessage;
44
- exports.makeUrlQueryString = require_converters.makeUrlQueryString;
45
- exports.poseToWandelscriptString = require_converters.poseToWandelscriptString;
46
- exports.radiansToDegrees = require_converters.radiansToDegrees;
47
- exports.tryParseJson = require_converters.tryParseJson;
48
- exports.tryStringifyJson = require_converters.tryStringifyJson;
45
+ exports.makeUrlQueryString = require_LoginWithAuth0.makeUrlQueryString;
46
+ exports.poseToWandelscriptString = require_wandelscriptUtils.poseToWandelscriptString;
47
+ exports.radiansToDegrees = require_LoginWithAuth0.radiansToDegrees;
48
+ exports.tryParseJson = require_LoginWithAuth0.tryParseJson;
49
+ exports.tryStringifyJson = require_LoginWithAuth0.tryStringifyJson;
49
50
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["AxiosError","tryStringifyJson"],"sources":["../src/lib/errorHandling.ts"],"sourcesContent":["import { AxiosError } from \"axios\"\nimport { tryStringifyJson } from \"./converters\"\n\nexport function delay(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\n/**\n * @deprecated Use makeErrorMessage instead and truncate the error for display as needed, or make a situation-specific localized error message based on a response code\n */\nexport function makeShortErrorMessage(err: unknown) {\n return makeErrorMessage(err)\n}\n\n/**\n * Attempts to make a helpful error message from an unknown thrown error\n * or promise rejection.\n *\n * This function is mainly to aid debugging and good bug reports. For\n * expected errors encountered by end users, it's more ideal to catch\n * the specific error code and provide a localized app-specific error message.\n */\nexport function makeErrorMessage(err: unknown): string {\n if (err instanceof AxiosError) {\n if (err.response) {\n return `${err.response?.status} ${err.response?.statusText} from ${err.response?.config.method?.toUpperCase() || \"accessing\"} ${err.response?.config.url}: ${JSON.stringify(err.response?.data)}`\n } else if (err.config) {\n if (err.code === \"ERR_NETWORK\") {\n return `${err.message} from ${err.config.method?.toUpperCase() || \"accessing\"} ${err.config.url}. This error can happen because of either connection issues or server CORS policy.`\n } else {\n return `${err.message} from ${err.config.method?.toUpperCase() || \"accessing\"} ${err.config.url}`\n }\n }\n } else if (err instanceof Error) {\n return err.message\n } else if (typeof err === \"string\") {\n return err\n } else if (typeof err === \"object\") {\n return tryStringifyJson(err) || `Unserializable object ${err}`\n }\n\n return `${err}`\n}\n"],"mappings":";;;;;;AAGA,SAAgB,MAAM,IAAY;AAChC,QAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;;;;;AAM1D,SAAgB,sBAAsB,KAAc;AAClD,QAAO,iBAAiB,IAAI;;;;;;;;;;AAW9B,SAAgB,iBAAiB,KAAsB;AACrD,KAAI,eAAeA,kBACjB;MAAI,IAAI,SACN,QAAO,GAAG,IAAI,UAAU,OAAO,GAAG,IAAI,UAAU,WAAW,QAAQ,IAAI,UAAU,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,UAAU,OAAO,IAAI,IAAI,KAAK,UAAU,IAAI,UAAU,KAAK;WACtL,IAAI,OACb,KAAI,IAAI,SAAS,cACf,QAAO,GAAG,IAAI,QAAQ,QAAQ,IAAI,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,OAAO,IAAI;MAEhG,QAAO,GAAG,IAAI,QAAQ,QAAQ,IAAI,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,OAAO;YAGvF,eAAe,MACxB,QAAO,IAAI;UACF,OAAO,QAAQ,SACxB,QAAO;UACE,OAAO,QAAQ,SACxB,QAAOC,oCAAiB,IAAI,IAAI,yBAAyB;AAG3D,QAAO,GAAG"}
1
+ {"version":3,"file":"index.cjs","names":["AxiosError","tryStringifyJson"],"sources":["../src/lib/errorHandling.ts"],"sourcesContent":["import { AxiosError } from \"axios\"\nimport { tryStringifyJson } from \"./converters\"\n\nexport function delay(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\n/**\n * @deprecated Use makeErrorMessage instead and truncate the error for display as needed, or make a situation-specific localized error message based on a response code\n */\nexport function makeShortErrorMessage(err: unknown) {\n return makeErrorMessage(err)\n}\n\n/**\n * Attempts to make a helpful error message from an unknown thrown error\n * or promise rejection.\n *\n * This function is mainly to aid debugging and good bug reports. For\n * expected errors encountered by end users, it's more ideal to catch\n * the specific error code and provide a localized app-specific error message.\n */\nexport function makeErrorMessage(err: unknown): string {\n if (err instanceof AxiosError) {\n if (err.response) {\n return `${err.response?.status} ${err.response?.statusText} from ${err.response?.config.method?.toUpperCase() || \"accessing\"} ${err.response?.config.url}: ${JSON.stringify(err.response?.data)}`\n } else if (err.config) {\n if (err.code === \"ERR_NETWORK\") {\n return `${err.message} from ${err.config.method?.toUpperCase() || \"accessing\"} ${err.config.url}. This error can happen because of either connection issues or server CORS policy.`\n } else {\n return `${err.message} from ${err.config.method?.toUpperCase() || \"accessing\"} ${err.config.url}`\n }\n }\n } else if (err instanceof Error) {\n return err.message\n } else if (typeof err === \"string\") {\n return err\n } else if (typeof err === \"object\") {\n return tryStringifyJson(err) || `Unserializable object ${err}`\n }\n\n return `${err}`\n}\n"],"mappings":";;;;;;AAGA,SAAgB,MAAM,IAAY;AAChC,QAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC;;;;;AAM1D,SAAgB,sBAAsB,KAAc;AAClD,QAAO,iBAAiB,IAAI;;;;;;;;;;AAW9B,SAAgB,iBAAiB,KAAsB;AACrD,KAAI,eAAeA,kBACjB;MAAI,IAAI,SACN,QAAO,GAAG,IAAI,UAAU,OAAO,GAAG,IAAI,UAAU,WAAW,QAAQ,IAAI,UAAU,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,UAAU,OAAO,IAAI,IAAI,KAAK,UAAU,IAAI,UAAU,KAAK;WACtL,IAAI,OACb,KAAI,IAAI,SAAS,cACf,QAAO,GAAG,IAAI,QAAQ,QAAQ,IAAI,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,OAAO,IAAI;MAEhG,QAAO,GAAG,IAAI,QAAQ,QAAQ,IAAI,OAAO,QAAQ,aAAa,IAAI,YAAY,GAAG,IAAI,OAAO;YAGvF,eAAe,MACxB,QAAO,IAAI;UACF,OAAO,QAAQ,SACxB,QAAO;UACE,OAAO,QAAQ,SACxB,QAAOC,wCAAiB,IAAI,IAAI,yBAAyB;AAG3D,QAAO,GAAG"}