@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
@@ -5,7 +5,6 @@ import * as pathToRegexp from "path-to-regexp"
5
5
  import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
6
6
 
7
7
  /**
8
- * EXPERIMENTAL
9
8
  * Ultra-simplified mock Nova server for testing stuff
10
9
  */
11
10
  export class MockNovaInstance {
@@ -15,6 +14,391 @@ export class MockNovaInstance {
15
14
  config: InternalAxiosRequestConfig,
16
15
  ): Promise<AxiosResponse> {
17
16
  const apiHandlers = [
17
+ {
18
+ method: "GET",
19
+ path: "/cells/:cellId/controllers/:controllerId/state",
20
+ handle() {
21
+ return {
22
+ mode: "MODE_CONTROL",
23
+ last_error: [],
24
+ timestamp: "2025-10-16T09:19:26.634534092Z",
25
+ sequence_number: 1054764,
26
+ controller: "mock-ur5e",
27
+ operation_mode: "OPERATION_MODE_AUTO",
28
+ safety_state: "SAFETY_STATE_NORMAL",
29
+ velocity_override: 100,
30
+ motion_groups: [
31
+ {
32
+ timestamp: "2025-10-16T09:19:26.634534092Z",
33
+ sequence_number: 1054764,
34
+ motion_group: "0@mock-ur5e",
35
+ controller: "mock-ur5e",
36
+ joint_position: [
37
+ 1.487959623336792, -1.8501918315887451, 1.8003005981445312,
38
+ 6.034560203552246, 1.4921919107437134, 1.593459963798523,
39
+ ],
40
+ joint_limit_reached: {
41
+ limit_reached: [false, false, false, false, false, false],
42
+ },
43
+ joint_torque: [],
44
+ joint_current: [0, 0, 0, 0, 0, 0],
45
+ flange_pose: {
46
+ position: [
47
+ 107.6452433732927, -409.0402987746852, 524.2402132330305,
48
+ ],
49
+ orientation: [
50
+ 0.9874434028353319, -0.986571714997442, 1.3336589451098142,
51
+ ],
52
+ },
53
+ tcp: "Flange",
54
+ tcp_pose: {
55
+ position: [
56
+ 107.6452433732927, -409.0402987746852, 524.2402132330305,
57
+ ],
58
+ orientation: [
59
+ 0.9874434028353319, -0.986571714997442, 1.3336589451098142,
60
+ ],
61
+ },
62
+ payload: "",
63
+ coordinate_system: "",
64
+ standstill: true,
65
+ },
66
+ ],
67
+ }
68
+ },
69
+ },
70
+ // Add more mock requests here...
71
+ {
72
+ method: "GET",
73
+ path: "/cells/:cellId/controllers/:controllerId/motion-groups/:motionGroupId/description",
74
+ handle() {
75
+ return {
76
+ motion_group_model: "UniversalRobots_UR5e",
77
+ mounting: {
78
+ position: [0, 0, 0],
79
+ orientation: [0, 0, 0],
80
+ },
81
+ tcps: {
82
+ Flange: {
83
+ name: "Default-Flange",
84
+ pose: {
85
+ position: [0, 0, 0],
86
+ orientation: [0, 0, 0],
87
+ },
88
+ },
89
+ "complex-tcp-position": {
90
+ name: "Complex TCP Position",
91
+ pose: {
92
+ position: [-200, 300, 150],
93
+ orientation: [
94
+ -0.12139440409113832, -0.06356210998212003,
95
+ -0.2023240068185639,
96
+ ],
97
+ },
98
+ },
99
+ "offset-150mm-xy": {
100
+ name: "-150mm XY Offset",
101
+ pose: {
102
+ position: [-150, -150, 0],
103
+ orientation: [0, 0, 0],
104
+ },
105
+ },
106
+ "rotated-90deg-z": {
107
+ name: "90° Z Axis Rotation",
108
+ pose: {
109
+ position: [0, 0, 0],
110
+ orientation: [0, 0, 1.5708],
111
+ },
112
+ },
113
+ },
114
+ payloads: {
115
+ "FPay-0": {
116
+ name: "FPay-0",
117
+ payload: 0,
118
+ center_of_mass: [0, 0, 0],
119
+ moment_of_inertia: [0, 0, 0],
120
+ },
121
+ },
122
+ cycle_time: 8,
123
+ dh_parameters: [
124
+ {
125
+ alpha: 1.5707963267948966,
126
+ d: 162.25,
127
+ },
128
+ {
129
+ a: -425,
130
+ },
131
+ {
132
+ a: -392.2,
133
+ },
134
+ {
135
+ alpha: 1.5707963267948966,
136
+ d: 133.3,
137
+ },
138
+ {
139
+ alpha: -1.5707963267948966,
140
+ d: 99.7,
141
+ },
142
+ {
143
+ d: 99.6,
144
+ },
145
+ ],
146
+ operation_limits: {
147
+ auto_limits: {
148
+ joints: [
149
+ {
150
+ position: {
151
+ lower_limit: -6.283185307179586,
152
+ upper_limit: 6.283185307179586,
153
+ },
154
+ velocity: 3.34159255027771,
155
+ acceleration: 40,
156
+ torque: 150,
157
+ },
158
+ {
159
+ position: {
160
+ lower_limit: -6.283185307179586,
161
+ upper_limit: 6.283185307179586,
162
+ },
163
+ velocity: 3.34159255027771,
164
+ acceleration: 40,
165
+ torque: 150,
166
+ },
167
+ {
168
+ position: {
169
+ lower_limit: -6.283185307179586,
170
+ upper_limit: 6.283185307179586,
171
+ },
172
+ velocity: 3.34159255027771,
173
+ acceleration: 40,
174
+ torque: 150,
175
+ },
176
+ {
177
+ position: {
178
+ lower_limit: -6.283185307179586,
179
+ upper_limit: 6.283185307179586,
180
+ },
181
+ velocity: 3.34159255027771,
182
+ acceleration: 40,
183
+ torque: 28,
184
+ },
185
+ {
186
+ position: {
187
+ lower_limit: -6.283185307179586,
188
+ upper_limit: 6.283185307179586,
189
+ },
190
+ velocity: 3.34159255027771,
191
+ acceleration: 40,
192
+ torque: 28,
193
+ },
194
+ {
195
+ position: {
196
+ lower_limit: -6.283185307179586,
197
+ upper_limit: 6.283185307179586,
198
+ },
199
+ velocity: 3.34159255027771,
200
+ acceleration: 40,
201
+ torque: 28,
202
+ },
203
+ ],
204
+ tcp: {
205
+ velocity: 5000,
206
+ },
207
+ elbow: {
208
+ velocity: 5000,
209
+ },
210
+ flange: {
211
+ velocity: 5000,
212
+ },
213
+ },
214
+ manual_limits: {
215
+ joints: [
216
+ {
217
+ position: {
218
+ lower_limit: -6.283185307179586,
219
+ upper_limit: 6.283185307179586,
220
+ },
221
+ velocity: 3.34159255027771,
222
+ acceleration: 40,
223
+ torque: 150,
224
+ },
225
+ {
226
+ position: {
227
+ lower_limit: -6.283185307179586,
228
+ upper_limit: 6.283185307179586,
229
+ },
230
+ velocity: 3.34159255027771,
231
+ acceleration: 40,
232
+ torque: 150,
233
+ },
234
+ {
235
+ position: {
236
+ lower_limit: -6.283185307179586,
237
+ upper_limit: 6.283185307179586,
238
+ },
239
+ velocity: 3.34159255027771,
240
+ acceleration: 40,
241
+ torque: 150,
242
+ },
243
+ {
244
+ position: {
245
+ lower_limit: -6.283185307179586,
246
+ upper_limit: 6.283185307179586,
247
+ },
248
+ velocity: 3.34159255027771,
249
+ acceleration: 40,
250
+ torque: 28,
251
+ },
252
+ {
253
+ position: {
254
+ lower_limit: -6.283185307179586,
255
+ upper_limit: 6.283185307179586,
256
+ },
257
+ velocity: 3.34159255027771,
258
+ acceleration: 40,
259
+ torque: 28,
260
+ },
261
+ {
262
+ position: {
263
+ lower_limit: -6.283185307179586,
264
+ upper_limit: 6.283185307179586,
265
+ },
266
+ velocity: 3.34159255027771,
267
+ acceleration: 40,
268
+ torque: 28,
269
+ },
270
+ ],
271
+ tcp: {
272
+ velocity: 5000,
273
+ },
274
+ },
275
+ manual_t1_limits: {
276
+ joints: [
277
+ {
278
+ position: {
279
+ lower_limit: -6.283185307179586,
280
+ upper_limit: 6.283185307179586,
281
+ },
282
+ velocity: 3.34159255027771,
283
+ acceleration: 40,
284
+ torque: 150,
285
+ },
286
+ {
287
+ position: {
288
+ lower_limit: -6.283185307179586,
289
+ upper_limit: 6.283185307179586,
290
+ },
291
+ velocity: 3.34159255027771,
292
+ acceleration: 40,
293
+ torque: 150,
294
+ },
295
+ {
296
+ position: {
297
+ lower_limit: -6.283185307179586,
298
+ upper_limit: 6.283185307179586,
299
+ },
300
+ velocity: 3.34159255027771,
301
+ acceleration: 40,
302
+ torque: 150,
303
+ },
304
+ {
305
+ position: {
306
+ lower_limit: -6.283185307179586,
307
+ upper_limit: 6.283185307179586,
308
+ },
309
+ velocity: 3.34159255027771,
310
+ acceleration: 40,
311
+ torque: 28,
312
+ },
313
+ {
314
+ position: {
315
+ lower_limit: -6.283185307179586,
316
+ upper_limit: 6.283185307179586,
317
+ },
318
+ velocity: 3.34159255027771,
319
+ acceleration: 40,
320
+ torque: 28,
321
+ },
322
+ {
323
+ position: {
324
+ lower_limit: -6.283185307179586,
325
+ upper_limit: 6.283185307179586,
326
+ },
327
+ velocity: 3.34159255027771,
328
+ acceleration: 40,
329
+ torque: 28,
330
+ },
331
+ ],
332
+ tcp: {
333
+ velocity: 5000,
334
+ },
335
+ },
336
+ manual_t2_limits: {
337
+ joints: [
338
+ {
339
+ position: {
340
+ lower_limit: -6.283185307179586,
341
+ upper_limit: 6.283185307179586,
342
+ },
343
+ velocity: 3.34159255027771,
344
+ acceleration: 40,
345
+ torque: 150,
346
+ },
347
+ {
348
+ position: {
349
+ lower_limit: -6.283185307179586,
350
+ upper_limit: 6.283185307179586,
351
+ },
352
+ velocity: 3.34159255027771,
353
+ acceleration: 40,
354
+ torque: 150,
355
+ },
356
+ {
357
+ position: {
358
+ lower_limit: -6.283185307179586,
359
+ upper_limit: 6.283185307179586,
360
+ },
361
+ velocity: 3.34159255027771,
362
+ acceleration: 40,
363
+ torque: 150,
364
+ },
365
+ {
366
+ position: {
367
+ lower_limit: -6.283185307179586,
368
+ upper_limit: 6.283185307179586,
369
+ },
370
+ velocity: 3.34159255027771,
371
+ acceleration: 40,
372
+ torque: 28,
373
+ },
374
+ {
375
+ position: {
376
+ lower_limit: -6.283185307179586,
377
+ upper_limit: 6.283185307179586,
378
+ },
379
+ velocity: 3.34159255027771,
380
+ acceleration: 40,
381
+ torque: 28,
382
+ },
383
+ {
384
+ position: {
385
+ lower_limit: -6.283185307179586,
386
+ upper_limit: 6.283185307179586,
387
+ },
388
+ velocity: 3.34159255027771,
389
+ acceleration: 40,
390
+ torque: 28,
391
+ },
392
+ ],
393
+ tcp: {
394
+ velocity: 5000,
395
+ },
396
+ },
397
+ },
398
+ serial_number: "WBVirtualRobot",
399
+ }
400
+ },
401
+ },
18
402
  {
19
403
  method: "GET",
20
404
  path: "/cells/:cellId/controllers",
@@ -0,0 +1,76 @@
1
+ import type { MotionGroupState, Pose } from "@wandelbots/nova-api/v2"
2
+
3
+ export function jointValuesEqual(
4
+ oldJointValues: number[],
5
+ newJointValues: number[],
6
+ changeDeltaThreshold: number,
7
+ ): boolean {
8
+ if (newJointValues.length !== oldJointValues.length) {
9
+ return true
10
+ }
11
+
12
+ for (let jointIndex = 0; jointIndex < newJointValues.length; jointIndex++) {
13
+ if (
14
+ // biome-ignore lint/style/noNonNullAssertion: legacy code
15
+ Math.abs(newJointValues[jointIndex]! - oldJointValues[jointIndex]!) >
16
+ changeDeltaThreshold
17
+ ) {
18
+ return false
19
+ }
20
+ }
21
+
22
+ return true
23
+ }
24
+
25
+ export function poseEqual(
26
+ oldTcp: Pose | undefined,
27
+ newTcp: Pose | undefined,
28
+ changeDeltaThreshold: number,
29
+ ): boolean {
30
+ // undefined -> defined (+reverse) transition
31
+ if ((oldTcp === undefined && newTcp) || (oldTcp && newTcp === undefined)) {
32
+ return false
33
+ }
34
+
35
+ // Poses might be incomplete (missing orientation or position)
36
+ if (
37
+ oldTcp?.orientation === undefined ||
38
+ newTcp?.orientation === undefined ||
39
+ oldTcp?.position === undefined ||
40
+ newTcp?.position === undefined
41
+ ) {
42
+ return false
43
+ }
44
+
45
+ // the typechecker cannot resolve states to "!= undefined" if "&&" is used
46
+ if (oldTcp === undefined || newTcp === undefined) {
47
+ return true
48
+ }
49
+
50
+ let changedDelta = 0
51
+ changedDelta += Math.abs(oldTcp.orientation[0] - newTcp.orientation[0])
52
+ changedDelta += Math.abs(oldTcp.orientation[1] - newTcp.orientation[1])
53
+ changedDelta += Math.abs(oldTcp.orientation[2] - newTcp.orientation[2])
54
+ changedDelta += Math.abs(oldTcp.position[0] - newTcp.position[0])
55
+ changedDelta += Math.abs(oldTcp.position[1] - newTcp.position[1])
56
+ changedDelta += Math.abs(oldTcp.position[2] - newTcp.position[2])
57
+
58
+ return changedDelta <= changeDeltaThreshold
59
+ }
60
+
61
+ // Runs poseEqual check + coordinate system/tcp name equality
62
+ export function tcpMotionEqual(
63
+ oldMotionState: MotionGroupState,
64
+ newMotionState: MotionGroupState,
65
+ changeDeltaThreshold: number,
66
+ ): boolean {
67
+ return (
68
+ oldMotionState.coordinate_system === newMotionState.coordinate_system &&
69
+ oldMotionState.tcp === newMotionState.tcp &&
70
+ poseEqual(
71
+ oldMotionState.tcp_pose,
72
+ newMotionState.tcp_pose,
73
+ changeDeltaThreshold,
74
+ )
75
+ )
76
+ }
@@ -0,0 +1 @@
1
+ export type Vector3Simple = [number, number, number]
@@ -0,0 +1,27 @@
1
+ import type { Pose } from "@wandelbots/nova-api/v2"
2
+
3
+ /**
4
+ * Convert a Pose object representing a motion group position
5
+ * into a string which represents that pose in Wandelscript.
6
+ */
7
+ export function poseToWandelscriptString(
8
+ pose: Pick<Pose, "position" | "orientation">,
9
+ ) {
10
+ const position = [
11
+ pose.position?.[0] ?? 0,
12
+ pose.position?.[1] ?? 0,
13
+ pose.position?.[2] ?? 0,
14
+ ]
15
+
16
+ const orientation = [
17
+ pose.orientation?.[0] ?? 0,
18
+ pose.orientation?.[1] ?? 0,
19
+ pose.orientation?.[2] ?? 0,
20
+ ]
21
+
22
+ const positionValues = position.map((v) => v.toFixed(1))
23
+ // Rotation needs more precision since it's in radians
24
+ const rotationValues = orientation.map((v) => v.toFixed(4))
25
+
26
+ return `(${positionValues.concat(rotationValues).join(", ")})`
27
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"AutoReconnectingWebsocket-BI1ckzP8.d.ts","names":[],"sources":["../src/lib/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;AACwB,cADX,kBAAA,CACW;WAGZ,WAAA,EAHY,yBAGZ,EAAA;kBACC,CAAA,MAAA,EADD,0BACC,CAAA,EAAR,OAAQ,CAAA,aAAA,CAAA;2BAAR,CAAA,MAAA,EAg8B+B,yBAh8B/B,CAAA,EAAA,IAAA;wBAg8B+B,CAAA,MAAA,EAkOH,yBAlOG,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;;;AAr8BpC;;AACwB,cCPX,gBAAA,CDOW;WAGZ,WAAA,ECTY,yBDSZ,EAAA;kBACC,CAAA,MAAA,ECPD,0BDOC,CAAA,ECNR,ODMQ,CCNA,aDMA,CAAA;2BAAR,CAAA,MAAA,ECqqB+B,yBDrqB/B,CAAA,EAAA,IAAA;wBAg8B+B,CAAA,MAAA,EC/DH,yBD+DG,EAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;cEj9BvB,yBAAA,SAAkC,qBAAA;EFYlC,SAAA,IAAA,EAAA;IAAgB,IAAA,CAAA,EEJhB,kBFIgB,GEJM,gBFIN;IACL,SAAA,CAAA,EAAA,GAAA,GAAA,IAAA;;sBAIX,CAAA,EEhBY,YFgBZ;WAAR,EAAA,MAAA;UAg8B+B,EAAA,OAAA;aAkOH,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,EAAA;IAAyB,IAAA,CAAA,EE3qC7C,kBF2qC6C,GE3qCvB,gBF2qCuB;;;;EC7qC7C,QAAA,CAAA,IAAA,EAAA,OAAgB,CAAA,EAAA,IAAA;EAAA;;;;SAKxB,CAAA,CAAA,EAAA,IAAA;;;;YCuES;;;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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AutoReconnectingWebsocket-Cr7f9016.d.cts","names":[],"sources":["../src/lib/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"sourcesContent":[],"mappings":";;;;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0 @@
1
- {"version":3,"file":"LoginWithAuth0-0g0wWRUC.js","names":["opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n }"],"sources":["../src/lib/AutoReconnectingWebsocket.ts","../src/lib/availableStorage.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","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.includes(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev\n if (instanceUrl.includes(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg\n if (instanceUrl.includes(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,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,OAA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"file":"LoginWithAuth0-C82OCyDy.cjs","names":["ReconnectingWebSocket","opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n }"],"sources":["../src/lib/AutoReconnectingWebsocket.ts","../src/lib/availableStorage.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","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.includes(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev\n if (instanceUrl.includes(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg\n if (instanceUrl.includes(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,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
@@ -1,108 +0,0 @@
1
-
2
- //#region src/lib/converters.ts
3
- /** Try to parse something as JSON; return undefined if we can't */
4
- function tryParseJson(json) {
5
- try {
6
- return JSON.parse(json);
7
- } catch {
8
- return;
9
- }
10
- }
11
- /** Try to turn something into JSON; return undefined if we can't */
12
- function tryStringifyJson(json) {
13
- try {
14
- return JSON.stringify(json);
15
- } catch {
16
- return;
17
- }
18
- }
19
- /**
20
- * Converts object parameters to query string.
21
- * e.g. { a: "1", b: "2" } => "?a=1&b=2"
22
- * {} => ""
23
- */
24
- function makeUrlQueryString(obj) {
25
- const str = new URLSearchParams(obj).toString();
26
- return str ? `?${str}` : "";
27
- }
28
- /** Convert radians to degrees */
29
- function radiansToDegrees(radians) {
30
- return radians * (180 / Math.PI);
31
- }
32
- /** Convert degrees to radians */
33
- function degreesToRadians(degrees) {
34
- return degrees * (Math.PI / 180);
35
- }
36
- /**
37
- * Convert a Pose object representing a motion group position
38
- * into a string which represents that pose in Wandelscript.
39
- */
40
- function poseToWandelscriptString(pose) {
41
- const position = [
42
- pose.position.x,
43
- pose.position.y,
44
- pose.position.z
45
- ];
46
- const orientation = [
47
- pose.orientation?.x ?? 0,
48
- pose.orientation?.y ?? 0,
49
- pose.orientation?.z ?? 0
50
- ];
51
- const positionValues = position.map((v) => v.toFixed(1));
52
- const rotationValues = orientation.map((v) => v.toFixed(4));
53
- return `(${positionValues.concat(rotationValues).join(", ")})`;
54
- }
55
- /**
56
- * Check for coordinate system id equivalence, accounting for the "world" default
57
- * on empty/undefined values.
58
- */
59
- function isSameCoordinateSystem(firstCoordSystem, secondCoordSystem) {
60
- if (!firstCoordSystem) firstCoordSystem = "world";
61
- if (!secondCoordSystem) secondCoordSystem = "world";
62
- return firstCoordSystem === secondCoordSystem;
63
- }
64
-
65
- //#endregion
66
- Object.defineProperty(exports, 'degreesToRadians', {
67
- enumerable: true,
68
- get: function () {
69
- return degreesToRadians;
70
- }
71
- });
72
- Object.defineProperty(exports, 'isSameCoordinateSystem', {
73
- enumerable: true,
74
- get: function () {
75
- return isSameCoordinateSystem;
76
- }
77
- });
78
- Object.defineProperty(exports, 'makeUrlQueryString', {
79
- enumerable: true,
80
- get: function () {
81
- return makeUrlQueryString;
82
- }
83
- });
84
- Object.defineProperty(exports, 'poseToWandelscriptString', {
85
- enumerable: true,
86
- get: function () {
87
- return poseToWandelscriptString;
88
- }
89
- });
90
- Object.defineProperty(exports, 'radiansToDegrees', {
91
- enumerable: true,
92
- get: function () {
93
- return radiansToDegrees;
94
- }
95
- });
96
- Object.defineProperty(exports, 'tryParseJson', {
97
- enumerable: true,
98
- get: function () {
99
- return tryParseJson;
100
- }
101
- });
102
- Object.defineProperty(exports, 'tryStringifyJson', {
103
- enumerable: true,
104
- get: function () {
105
- return tryStringifyJson;
106
- }
107
- });
108
- //# sourceMappingURL=converters-DP2EIVv6.cjs.map