@wandelbots/nova-js 3.11.0 → 3.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/{AutoReconnectingWebsocket-DNOF9mpz.d.cts → AutoReconnectingWebsocket-1K2J1NA4.d.cts} +5 -5
  2. package/dist/AutoReconnectingWebsocket-1K2J1NA4.d.cts.map +1 -0
  3. package/dist/{AutoReconnectingWebsocket-DNOF9mpz.d.mts → AutoReconnectingWebsocket-1K2J1NA4.d.mts} +5 -5
  4. package/dist/AutoReconnectingWebsocket-1K2J1NA4.d.mts.map +1 -0
  5. package/dist/{context-Dmy8AyY7.cjs → context-TPb5fGlK.cjs} +8 -7
  6. package/dist/context-TPb5fGlK.cjs.map +1 -0
  7. package/dist/{context-BQk3xGAI.mjs → context-kT2C20EX.mjs} +8 -7
  8. package/dist/context-kT2C20EX.mjs.map +1 -0
  9. package/dist/index.cjs +2 -2
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +3 -3
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +3 -3
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +2 -2
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/{lib/deprecated/v1 → v1}/index.cjs +8 -6
  18. package/dist/v1/index.cjs.map +1 -0
  19. package/dist/{lib/deprecated/v1 → v1}/index.d.cts +3 -3
  20. package/dist/v1/index.d.cts.map +1 -0
  21. package/dist/{lib/deprecated/v1 → v1}/index.d.mts +3 -3
  22. package/dist/v1/index.d.mts.map +1 -0
  23. package/dist/{lib/deprecated/v1 → v1}/index.mjs +8 -6
  24. package/dist/v1/index.mjs.map +1 -0
  25. package/dist/{lib/v2 → v2}/index.cjs +82 -20
  26. package/dist/v2/index.cjs.map +1 -0
  27. package/dist/{lib/v2 → v2}/index.d.cts +22 -22
  28. package/dist/v2/index.d.cts.map +1 -0
  29. package/dist/{lib/v2 → v2}/index.d.mts +22 -22
  30. package/dist/v2/index.d.mts.map +1 -0
  31. package/dist/{lib/v2 → v2}/index.mjs +82 -20
  32. package/dist/v2/index.mjs.map +1 -0
  33. package/dist/{wandelscriptUtils-BDdIFHPD.mjs → wandelscriptUtils-CwtdZRDs.mjs} +71 -14
  34. package/dist/wandelscriptUtils-CwtdZRDs.mjs.map +1 -0
  35. package/dist/{wandelscriptUtils-1A9uFPV_.d.cts → wandelscriptUtils-DY3WsiuB.d.cts} +37 -37
  36. package/dist/wandelscriptUtils-DY3WsiuB.d.cts.map +1 -0
  37. package/dist/{wandelscriptUtils-pySXnBlX.d.mts → wandelscriptUtils-YHTxn_p9.d.mts} +37 -37
  38. package/dist/wandelscriptUtils-YHTxn_p9.d.mts.map +1 -0
  39. package/dist/{wandelscriptUtils-BUUwGZNr.cjs → wandelscriptUtils-dUlZrOhy.cjs} +71 -14
  40. package/dist/wandelscriptUtils-dUlZrOhy.cjs.map +1 -0
  41. package/package.json +7 -7
  42. package/src/index.ts +7 -7
  43. package/src/lib/AutoReconnectingWebsocket.ts +8 -3
  44. package/src/lib/{v2/Nova.ts → Nova.ts} +21 -11
  45. package/src/lib/deprecated/v1/ConnectedMotionGroup.ts +42 -16
  46. package/src/lib/deprecated/v1/JoggerConnection.ts +13 -7
  47. package/src/lib/deprecated/v1/MotionStreamConnection.ts +21 -9
  48. package/src/lib/deprecated/v1/NovaCellAPIClient.ts +65 -44
  49. package/src/lib/deprecated/v1/NovaClient.ts +10 -10
  50. package/src/lib/deprecated/v1/ProgramStateConnection.ts +8 -5
  51. package/src/lib/deprecated/v1/getLatestTrajectories.ts +1 -1
  52. package/src/lib/deprecated/v1/mock/MockNovaInstance.ts +1 -1
  53. package/src/lib/deprecated/v2/NovaCellAPIClient.ts +72 -51
  54. package/src/lib/deprecated/v2/NovaClient.ts +8 -8
  55. package/src/lib/errorHandling.ts +1 -1
  56. package/src/lib/{v2/mock → mock}/MockNovaInstance.ts +8 -8
  57. package/src/v1/index.ts +14 -0
  58. package/src/v2/index.ts +7 -0
  59. package/dist/AutoReconnectingWebsocket-DNOF9mpz.d.cts.map +0 -1
  60. package/dist/AutoReconnectingWebsocket-DNOF9mpz.d.mts.map +0 -1
  61. package/dist/context-BQk3xGAI.mjs.map +0 -1
  62. package/dist/context-Dmy8AyY7.cjs.map +0 -1
  63. package/dist/lib/deprecated/v1/index.cjs.map +0 -1
  64. package/dist/lib/deprecated/v1/index.d.cts.map +0 -1
  65. package/dist/lib/deprecated/v1/index.d.mts.map +0 -1
  66. package/dist/lib/deprecated/v1/index.mjs.map +0 -1
  67. package/dist/lib/v2/index.cjs.map +0 -1
  68. package/dist/lib/v2/index.d.cts.map +0 -1
  69. package/dist/lib/v2/index.d.mts.map +0 -1
  70. package/dist/lib/v2/index.mjs.map +0 -1
  71. package/dist/wandelscriptUtils-1A9uFPV_.d.cts.map +0 -1
  72. package/dist/wandelscriptUtils-BDdIFHPD.mjs.map +0 -1
  73. package/dist/wandelscriptUtils-BUUwGZNr.cjs.map +0 -1
  74. package/dist/wandelscriptUtils-pySXnBlX.d.mts.map +0 -1
  75. package/src/lib/deprecated/v1/index.ts +0 -14
  76. package/src/lib/v2/index.ts +0 -7
  77. /package/src/{LoginWithAuth0.ts → lib/LoginWithAuth0.ts} +0 -0
  78. /package/src/lib/{v2/NovaAPIClient.ts → NovaAPIClient.ts} +0 -0
  79. /package/src/lib/{v2/mock → mock}/getCurrentRobotControllerState.ts +0 -0
  80. /package/src/lib/{v2/mock → mock}/getMotionGroupDescription.ts +0 -0
  81. /package/src/lib/{v2/mock → mock}/getMotionGroupKinematicModel.ts +0 -0
  82. /package/src/lib/{v2/mock → mock}/getRobotController.ts +0 -0
  83. /package/src/lib/{v2/mock → mock}/listCoordinateSystems.ts +0 -0
  84. /package/src/lib/{v2/mock → mock}/listRobotControllers.ts +0 -0
@@ -12,10 +12,10 @@ import type {
12
12
  } from "@wandelbots/nova-api/v1"
13
13
  import { makeAutoObservable, runInAction } from "mobx"
14
14
  import * as THREE from "three"
15
- import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
16
- import { tryParseJson } from "../../converters"
17
- import { jointValuesEqual, tcpPoseEqual } from "./motionStateUpdate"
18
- import type { NovaClient } from "./NovaClient"
15
+ import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket.ts"
16
+ import { tryParseJson } from "../../converters.ts"
17
+ import { jointValuesEqual, tcpPoseEqual } from "./motionStateUpdate.ts"
18
+ import type { NovaClient } from "./NovaClient.ts"
19
19
 
20
20
  const MOTION_DELTA_THRESHOLD = 0.0001
21
21
 
@@ -159,20 +159,46 @@ export class ConnectedMotionGroup {
159
159
  activationState: "inactive" | "activating" | "deactivating" | "active" =
160
160
  "inactive"
161
161
 
162
+ readonly nova: NovaClient
163
+ readonly controller: ControllerInstance
164
+ readonly motionGroup: MotionGroupPhysical
165
+ readonly initialMotionState: MotionGroupStateResponse
166
+ readonly motionStateSocket: AutoReconnectingWebsocket
167
+ readonly isVirtual: boolean
168
+ readonly tcps: RobotTcp[]
169
+ readonly motionGroupSpecification: MotionGroupSpecification
170
+ readonly safetySetup: SafetySetup
171
+ readonly mounting: Mounting | null
172
+ readonly initialControllerState: RobotControllerState
173
+ readonly controllerStateSocket: AutoReconnectingWebsocket
174
+
162
175
  constructor(
163
- readonly nova: NovaClient,
164
- readonly controller: ControllerInstance,
165
- readonly motionGroup: MotionGroupPhysical,
166
- readonly initialMotionState: MotionGroupStateResponse,
167
- readonly motionStateSocket: AutoReconnectingWebsocket,
168
- readonly isVirtual: boolean,
169
- readonly tcps: RobotTcp[],
170
- readonly motionGroupSpecification: MotionGroupSpecification,
171
- readonly safetySetup: SafetySetup,
172
- readonly mounting: Mounting | null,
173
- readonly initialControllerState: RobotControllerState,
174
- readonly controllerStateSocket: AutoReconnectingWebsocket,
176
+ nova: NovaClient,
177
+ controller: ControllerInstance,
178
+ motionGroup: MotionGroupPhysical,
179
+ initialMotionState: MotionGroupStateResponse,
180
+ motionStateSocket: AutoReconnectingWebsocket,
181
+ isVirtual: boolean,
182
+ tcps: RobotTcp[],
183
+ motionGroupSpecification: MotionGroupSpecification,
184
+ safetySetup: SafetySetup,
185
+ mounting: Mounting | null,
186
+ initialControllerState: RobotControllerState,
187
+ controllerStateSocket: AutoReconnectingWebsocket,
175
188
  ) {
189
+ this.nova = nova
190
+ this.controller = controller
191
+ this.motionGroup = motionGroup
192
+ this.initialMotionState = initialMotionState
193
+ this.motionStateSocket = motionStateSocket
194
+ this.isVirtual = isVirtual
195
+ this.tcps = tcps
196
+ this.motionGroupSpecification = motionGroupSpecification
197
+ this.safetySetup = safetySetup
198
+ this.mounting = mounting
199
+ this.initialControllerState = initialControllerState
200
+ this.controllerStateSocket = controllerStateSocket
201
+
176
202
  this.rapidlyChangingMotionState = initialMotionState
177
203
  this.controllerState = initialControllerState
178
204
 
@@ -1,9 +1,9 @@
1
1
  import type { Command, Joints, TcpPose } from "@wandelbots/nova-api/v1"
2
2
  import { Vector3 } from "three/src/math/Vector3.js"
3
- import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
4
- import { isSameCoordinateSystem, tryParseJson } from "../../converters"
5
- import type { MotionStreamConnection } from "./MotionStreamConnection"
6
- import type { NovaClient } from "./NovaClient"
3
+ import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket.ts"
4
+ import { isSameCoordinateSystem, tryParseJson } from "../../converters.ts"
5
+ import type { MotionStreamConnection } from "./MotionStreamConnection.ts"
6
+ import type { NovaClient } from "./NovaClient.ts"
7
7
 
8
8
  /** @deprecated */
9
9
  export type JoggerConnectionOpts = {
@@ -36,10 +36,16 @@ export class JoggerConnection {
36
36
  return new JoggerConnection(motionStream, opts)
37
37
  }
38
38
 
39
+ readonly motionStream: MotionStreamConnection
40
+ readonly opts: JoggerConnectionOpts
41
+
39
42
  constructor(
40
- readonly motionStream: MotionStreamConnection,
41
- readonly opts: JoggerConnectionOpts = {},
42
- ) {}
43
+ motionStream: MotionStreamConnection,
44
+ opts: JoggerConnectionOpts = {},
45
+ ) {
46
+ this.motionStream = motionStream
47
+ this.opts = opts
48
+ }
43
49
 
44
50
  get motionGroupId() {
45
51
  return this.motionStream.motionGroupId
@@ -7,10 +7,10 @@ import type {
7
7
  } from "@wandelbots/nova-api/v1"
8
8
  import { makeAutoObservable, runInAction } from "mobx"
9
9
  import { Vector3 } from "three"
10
- import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
11
- import { tryParseJson } from "../../converters"
12
- import { jointValuesEqual, tcpPoseEqual } from "./motionStateUpdate"
13
- import type { NovaClient } from "./NovaClient"
10
+ import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket.ts"
11
+ import { tryParseJson } from "../../converters.ts"
12
+ import { jointValuesEqual, tcpPoseEqual } from "./motionStateUpdate.ts"
13
+ import type { NovaClient } from "./NovaClient.ts"
14
14
 
15
15
  const MOTION_DELTA_THRESHOLD = 0.0001
16
16
 
@@ -109,13 +109,25 @@ export class MotionStreamConnection {
109
109
  // using animation frames
110
110
  rapidlyChangingMotionState: MotionGroupStateResponse
111
111
 
112
+ readonly nova: NovaClient
113
+ readonly controller: ControllerInstance
114
+ readonly motionGroup: MotionGroupPhysical
115
+ readonly initialMotionState: MotionGroupStateResponse
116
+ readonly motionStateSocket: AutoReconnectingWebsocket
117
+
112
118
  constructor(
113
- readonly nova: NovaClient,
114
- readonly controller: ControllerInstance,
115
- readonly motionGroup: MotionGroupPhysical,
116
- readonly initialMotionState: MotionGroupStateResponse,
117
- readonly motionStateSocket: AutoReconnectingWebsocket,
119
+ nova: NovaClient,
120
+ controller: ControllerInstance,
121
+ motionGroup: MotionGroupPhysical,
122
+ initialMotionState: MotionGroupStateResponse,
123
+ motionStateSocket: AutoReconnectingWebsocket,
118
124
  ) {
125
+ this.nova = nova
126
+ this.controller = controller
127
+ this.motionGroup = motionGroup
128
+ this.initialMotionState = initialMotionState
129
+ this.motionStateSocket = motionStateSocket
130
+
119
131
  this.rapidlyChangingMotionState = initialMotionState
120
132
 
121
133
  motionStateSocket.addEventListener("message", (event) => {
@@ -60,13 +60,75 @@ export type WithUnwrappedAxiosResponse<T> = {
60
60
  * @deprecated Use `NovaAPIClient` from `@wandelbots/nova-js/v2` instead.
61
61
  */
62
62
  export class NovaCellAPIClient {
63
+ readonly system: WithUnwrappedAxiosResponse<SystemApi>
64
+ readonly cell: WithUnwrappedAxiosResponse<CellApi>
65
+ readonly deviceConfig: WithCellId<DeviceConfigurationApi>
66
+ readonly motionGroup: WithCellId<MotionGroupApi>
67
+ readonly motionGroupInfos: WithCellId<MotionGroupInfosApi>
68
+ readonly controller: WithCellId<ControllerApi>
69
+ readonly program: WithCellId<ProgramApi>
70
+ readonly programValues: WithCellId<ProgramValuesApi>
71
+ readonly controllerIOs: WithCellId<ControllerIOsApi>
72
+ readonly motionGroupKinematic: WithCellId<MotionGroupKinematicApi>
73
+ readonly motion: WithCellId<MotionApi>
74
+ readonly coordinateSystems: WithCellId<CoordinateSystemsApi>
75
+ readonly application: WithCellId<ApplicationApi>
76
+ readonly applicationGlobal: WithUnwrappedAxiosResponse<ApplicationApi>
77
+ readonly motionGroupJogging: WithCellId<MotionGroupJoggingApi>
78
+ readonly virtualRobot: WithCellId<VirtualRobotApi>
79
+ readonly virtualRobotSetup: WithCellId<VirtualRobotSetupApi>
80
+ readonly virtualRobotMode: WithCellId<VirtualRobotModeApi>
81
+ readonly virtualRobotBehavior: WithCellId<VirtualRobotBehaviorApi>
82
+ readonly libraryProgramMetadata: WithCellId<LibraryProgramMetadataApi>
83
+ readonly libraryProgram: WithCellId<LibraryProgramApi>
84
+ readonly libraryRecipeMetadata: WithCellId<LibraryRecipeMetadataApi>
85
+ readonly libraryRecipe: WithCellId<LibraryRecipeApi>
86
+ readonly storeObject: WithCellId<StoreObjectApi>
87
+ readonly storeCollisionComponents: WithCellId<StoreCollisionComponentsApi>
88
+ readonly storeCollisionScenes: WithCellId<StoreCollisionScenesApi>
89
+
90
+ readonly cellId: string
91
+ readonly opts: BaseConfiguration & {
92
+ axiosInstance?: AxiosInstance
93
+ mock?: boolean
94
+ }
95
+
63
96
  constructor(
64
- readonly cellId: string,
65
- readonly opts: BaseConfiguration & {
97
+ cellId: string,
98
+ opts: BaseConfiguration & {
66
99
  axiosInstance?: AxiosInstance
67
100
  mock?: boolean
68
101
  },
69
- ) {}
102
+ ) {
103
+ this.cellId = cellId
104
+ this.opts = opts
105
+ this.system = this.withUnwrappedResponsesOnly(SystemApi)
106
+ this.cell = this.withUnwrappedResponsesOnly(CellApi)
107
+ this.deviceConfig = this.withCellId(DeviceConfigurationApi)
108
+ this.motionGroup = this.withCellId(MotionGroupApi)
109
+ this.motionGroupInfos = this.withCellId(MotionGroupInfosApi)
110
+ this.controller = this.withCellId(ControllerApi)
111
+ this.program = this.withCellId(ProgramApi)
112
+ this.programValues = this.withCellId(ProgramValuesApi)
113
+ this.controllerIOs = this.withCellId(ControllerIOsApi)
114
+ this.motionGroupKinematic = this.withCellId(MotionGroupKinematicApi)
115
+ this.motion = this.withCellId(MotionApi)
116
+ this.coordinateSystems = this.withCellId(CoordinateSystemsApi)
117
+ this.application = this.withCellId(ApplicationApi)
118
+ this.applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)
119
+ this.motionGroupJogging = this.withCellId(MotionGroupJoggingApi)
120
+ this.virtualRobot = this.withCellId(VirtualRobotApi)
121
+ this.virtualRobotSetup = this.withCellId(VirtualRobotSetupApi)
122
+ this.virtualRobotMode = this.withCellId(VirtualRobotModeApi)
123
+ this.virtualRobotBehavior = this.withCellId(VirtualRobotBehaviorApi)
124
+ this.libraryProgramMetadata = this.withCellId(LibraryProgramMetadataApi)
125
+ this.libraryProgram = this.withCellId(LibraryProgramApi)
126
+ this.libraryRecipeMetadata = this.withCellId(LibraryRecipeMetadataApi)
127
+ this.libraryRecipe = this.withCellId(LibraryRecipeApi)
128
+ this.storeObject = this.withCellId(StoreObjectApi)
129
+ this.storeCollisionComponents = this.withCellId(StoreCollisionComponentsApi)
130
+ this.storeCollisionScenes = this.withCellId(StoreCollisionScenesApi)
131
+ }
70
132
 
71
133
  /**
72
134
  * Some TypeScript sorcery which alters the API class methods so you don't
@@ -143,45 +205,4 @@ export class NovaCellAPIClient {
143
205
 
144
206
  return apiClient as WithUnwrappedAxiosResponse<T>
145
207
  }
146
-
147
- readonly system = this.withUnwrappedResponsesOnly(SystemApi)
148
- readonly cell = this.withUnwrappedResponsesOnly(CellApi)
149
-
150
- readonly deviceConfig = this.withCellId(DeviceConfigurationApi)
151
-
152
- readonly motionGroup = this.withCellId(MotionGroupApi)
153
- readonly motionGroupInfos = this.withCellId(MotionGroupInfosApi)
154
-
155
- readonly controller = this.withCellId(ControllerApi)
156
-
157
- readonly program = this.withCellId(ProgramApi)
158
- readonly programValues = this.withCellId(ProgramValuesApi)
159
-
160
- readonly controllerIOs = this.withCellId(ControllerIOsApi)
161
-
162
- readonly motionGroupKinematic = this.withCellId(MotionGroupKinematicApi)
163
- readonly motion = this.withCellId(MotionApi)
164
-
165
- readonly coordinateSystems = this.withCellId(CoordinateSystemsApi)
166
-
167
- readonly application = this.withCellId(ApplicationApi)
168
- readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)
169
-
170
- readonly motionGroupJogging = this.withCellId(MotionGroupJoggingApi)
171
-
172
- readonly virtualRobot = this.withCellId(VirtualRobotApi)
173
- readonly virtualRobotSetup = this.withCellId(VirtualRobotSetupApi)
174
- readonly virtualRobotMode = this.withCellId(VirtualRobotModeApi)
175
- readonly virtualRobotBehavior = this.withCellId(VirtualRobotBehaviorApi)
176
-
177
- readonly libraryProgramMetadata = this.withCellId(LibraryProgramMetadataApi)
178
- readonly libraryProgram = this.withCellId(LibraryProgramApi)
179
- readonly libraryRecipeMetadata = this.withCellId(LibraryRecipeMetadataApi)
180
- readonly libraryRecipe = this.withCellId(LibraryRecipeApi)
181
-
182
- readonly storeObject = this.withCellId(StoreObjectApi)
183
- readonly storeCollisionComponents = this.withCellId(
184
- StoreCollisionComponentsApi,
185
- )
186
- readonly storeCollisionScenes = this.withCellId(StoreCollisionScenesApi)
187
208
  }
@@ -6,17 +6,17 @@
6
6
  import type { Configuration as BaseConfiguration } from "@wandelbots/nova-api/v1"
7
7
  import type { AxiosRequestConfig } from "axios"
8
8
  import axios, { isAxiosError } from "axios"
9
- import { loginWithAuth0 } from "../../../LoginWithAuth0.js"
10
- import { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket.js"
11
- import { availableStorage } from "../../availableStorage.js"
12
- import { parseNovaInstanceUrl } from "../../converters.js"
9
+ import { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket.ts"
10
+ import { loginWithAuth0 } from "../../LoginWithAuth0.ts"
11
+ import { availableStorage } from "../../availableStorage.ts"
12
+ import { parseNovaInstanceUrl } from "../../converters.ts"
13
13
 
14
- import { isBrowser, isLocalhostDev } from "../../context.js"
15
- import { ConnectedMotionGroup } from "./ConnectedMotionGroup.js"
16
- import { JoggerConnection } from "./JoggerConnection.js"
17
- import { MotionStreamConnection } from "./MotionStreamConnection.js"
18
- import { NovaCellAPIClient } from "./NovaCellAPIClient.js"
19
- import { MockNovaInstance } from "./mock/MockNovaInstance.js"
14
+ import { isBrowser, isLocalhostDev } from "../../context.ts"
15
+ import { ConnectedMotionGroup } from "./ConnectedMotionGroup.ts"
16
+ import { JoggerConnection } from "./JoggerConnection.ts"
17
+ import { MotionStreamConnection } from "./MotionStreamConnection.ts"
18
+ import { NovaCellAPIClient } from "./NovaCellAPIClient.ts"
19
+ import { MockNovaInstance } from "./mock/MockNovaInstance.ts"
20
20
 
21
21
  /** @deprecated Use `NovaConfig` from `@wandelbots/nova-js/v2` instead. */
22
22
  export type NovaClientConfig = {
@@ -2,10 +2,10 @@
2
2
  import type { CollectionValue } from "@wandelbots/nova-api/v1"
3
3
  import { AxiosError } from "axios"
4
4
  import { makeAutoObservable, runInAction } from "mobx"
5
- import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
6
- import { tryParseJson } from "../../converters"
7
- import type { MotionStreamConnection } from "./MotionStreamConnection"
8
- import type { NovaClient } from "./NovaClient"
5
+ import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket.ts"
6
+ import { tryParseJson } from "../../converters.ts"
7
+ import type { MotionStreamConnection } from "./MotionStreamConnection.ts"
8
+ import type { NovaClient } from "./NovaClient.ts"
9
9
 
10
10
  /** @deprecated */
11
11
  export type ProgramRunnerLogEntry = {
@@ -54,7 +54,10 @@ export class ProgramStateConnection {
54
54
 
55
55
  programStateSocket: AutoReconnectingWebsocket
56
56
 
57
- constructor(readonly nova: NovaClient) {
57
+ readonly nova: NovaClient
58
+
59
+ constructor(nova: NovaClient) {
60
+ this.nova = nova
58
61
  makeAutoObservable(this, {}, { autoBind: true })
59
62
 
60
63
  this.programStateSocket = nova.openReconnectingWebsocket(`/programs/state`)
@@ -1,5 +1,5 @@
1
1
  import type { GetTrajectoryResponse } from "@wandelbots/nova-api/v1"
2
- import type { NovaCellAPIClient } from "./NovaCellAPIClient"
2
+ import type { NovaCellAPIClient } from "./NovaCellAPIClient.ts"
3
3
 
4
4
  let lastMotionIds: Set<string> = new Set()
5
5
 
@@ -8,7 +8,7 @@ import type {
8
8
  import type { AxiosResponse, InternalAxiosRequestConfig } from "axios"
9
9
  import { AxiosError } from "axios"
10
10
  import * as pathToRegexp from "path-to-regexp"
11
- import type { AutoReconnectingWebsocket } from "../../../AutoReconnectingWebsocket"
11
+ import type { AutoReconnectingWebsocket } from "../../../AutoReconnectingWebsocket.ts"
12
12
 
13
13
  /**
14
14
  * Ultra-simplified mock Nova server for testing stuff
@@ -60,13 +60,82 @@ export type WithUnwrappedAxiosResponse<T> = {
60
60
  * @deprecated Use `NovaAPIClient` from `@wandelbots/nova-js/v2` instead.
61
61
  */
62
62
  export class NovaCellAPIClient {
63
+ readonly system: WithUnwrappedAxiosResponse<SystemApi>
64
+ readonly cell: WithUnwrappedAxiosResponse<CellApi>
65
+ readonly motionGroup: WithCellId<MotionGroupApi>
66
+ readonly motionGroupModels: WithUnwrappedAxiosResponse<MotionGroupModelsApi>
67
+ readonly controller: WithCellId<ControllerApi>
68
+ readonly controllerIOs: WithCellId<ControllerInputsOutputsApi>
69
+ readonly trajectoryPlanning: WithCellId<TrajectoryPlanningApi>
70
+ readonly trajectoryExecution: WithCellId<TrajectoryExecutionApi>
71
+ readonly trajectoryCaching: WithCellId<TrajectoryCachingApi>
72
+ readonly application: WithCellId<ApplicationApi>
73
+ readonly applicationGlobal: WithUnwrappedAxiosResponse<ApplicationApi>
74
+ readonly jogging: WithCellId<JoggingApi>
75
+ readonly kinematics: WithCellId<KinematicsApi>
76
+ readonly busInputsOutputs: WithCellId<BUSInputsOutputsApi>
77
+ readonly virtualController: WithCellId<VirtualControllerApi>
78
+ readonly virtualControllerBehavior: WithCellId<VirtualControllerBehaviorApi>
79
+ readonly virtualControllerIOs: WithCellId<VirtualControllerInputsOutputsApi>
80
+ readonly storeObject: WithCellId<StoreObjectApi>
81
+ readonly storeCollisionComponents: WithCellId<StoreCollisionComponentsApi>
82
+ readonly storeCollisionSetups: WithCellId<StoreCollisionSetupsApi>
83
+ readonly program: WithCellId<ProgramApi>
84
+ readonly license: WithUnwrappedAxiosResponse<LicenseApi>
85
+ readonly novaCloud: WithUnwrappedAxiosResponse<NOVACloudApi>
86
+ readonly robotConfigurations: WithUnwrappedAxiosResponse<RobotConfigurationsApi>
87
+ readonly version: WithUnwrappedAxiosResponse<VersionApi>
88
+ readonly session: WithUnwrappedAxiosResponse<SessionApi>
89
+
90
+ readonly cellId: string
91
+ readonly opts: BaseConfiguration & {
92
+ axiosInstance?: AxiosInstance
93
+ mock?: boolean
94
+ }
95
+
63
96
  constructor(
64
- readonly cellId: string,
65
- readonly opts: BaseConfiguration & {
97
+ cellId: string,
98
+ opts: BaseConfiguration & {
66
99
  axiosInstance?: AxiosInstance
67
100
  mock?: boolean
68
101
  },
69
- ) {}
102
+ ) {
103
+ this.cellId = cellId
104
+ this.opts = opts
105
+ this.system = this.withUnwrappedResponsesOnly(SystemApi)
106
+ this.cell = this.withUnwrappedResponsesOnly(CellApi)
107
+ this.motionGroup = this.withCellId(MotionGroupApi)
108
+ this.motionGroupModels =
109
+ this.withUnwrappedResponsesOnly(MotionGroupModelsApi)
110
+ this.controller = this.withCellId(ControllerApi)
111
+ this.controllerIOs = this.withCellId(ControllerInputsOutputsApi)
112
+ this.trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)
113
+ this.trajectoryExecution = this.withCellId(TrajectoryExecutionApi)
114
+ this.trajectoryCaching = this.withCellId(TrajectoryCachingApi)
115
+ this.application = this.withCellId(ApplicationApi)
116
+ this.applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)
117
+ this.jogging = this.withCellId(JoggingApi)
118
+ this.kinematics = this.withCellId(KinematicsApi)
119
+ this.busInputsOutputs = this.withCellId(BUSInputsOutputsApi)
120
+ this.virtualController = this.withCellId(VirtualControllerApi)
121
+ this.virtualControllerBehavior = this.withCellId(
122
+ VirtualControllerBehaviorApi,
123
+ )
124
+ this.virtualControllerIOs = this.withCellId(
125
+ VirtualControllerInputsOutputsApi,
126
+ )
127
+ this.storeObject = this.withCellId(StoreObjectApi)
128
+ this.storeCollisionComponents = this.withCellId(StoreCollisionComponentsApi)
129
+ this.storeCollisionSetups = this.withCellId(StoreCollisionSetupsApi)
130
+ this.program = this.withCellId(ProgramApi)
131
+ this.license = this.withUnwrappedResponsesOnly(LicenseApi)
132
+ this.novaCloud = this.withUnwrappedResponsesOnly(NOVACloudApi)
133
+ this.robotConfigurations = this.withUnwrappedResponsesOnly(
134
+ RobotConfigurationsApi,
135
+ )
136
+ this.version = this.withUnwrappedResponsesOnly(VersionApi)
137
+ this.session = this.withUnwrappedResponsesOnly(SessionApi)
138
+ }
70
139
 
71
140
  /**
72
141
  * Some TypeScript sorcery which alters the API class methods so you don't
@@ -143,52 +212,4 @@ export class NovaCellAPIClient {
143
212
 
144
213
  return apiClient as WithUnwrappedAxiosResponse<T>
145
214
  }
146
-
147
- readonly system = this.withUnwrappedResponsesOnly(SystemApi)
148
- readonly cell = this.withUnwrappedResponsesOnly(CellApi)
149
-
150
- readonly motionGroup = this.withCellId(MotionGroupApi)
151
- readonly motionGroupModels =
152
- this.withUnwrappedResponsesOnly(MotionGroupModelsApi)
153
-
154
- readonly controller = this.withCellId(ControllerApi)
155
-
156
- readonly controllerIOs = this.withCellId(ControllerInputsOutputsApi)
157
-
158
- readonly trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)
159
- readonly trajectoryExecution = this.withCellId(TrajectoryExecutionApi)
160
- readonly trajectoryCaching = this.withCellId(TrajectoryCachingApi)
161
-
162
- readonly application = this.withCellId(ApplicationApi)
163
- readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)
164
-
165
- readonly jogging = this.withCellId(JoggingApi)
166
-
167
- readonly kinematics = this.withCellId(KinematicsApi)
168
-
169
- readonly busInputsOutputs = this.withCellId(BUSInputsOutputsApi)
170
-
171
- readonly virtualController = this.withCellId(VirtualControllerApi)
172
- readonly virtualControllerBehavior = this.withCellId(
173
- VirtualControllerBehaviorApi,
174
- )
175
- readonly virtualControllerIOs = this.withCellId(
176
- VirtualControllerInputsOutputsApi,
177
- )
178
-
179
- readonly storeObject = this.withCellId(StoreObjectApi)
180
- readonly storeCollisionComponents = this.withCellId(
181
- StoreCollisionComponentsApi,
182
- )
183
- readonly storeCollisionSetups = this.withCellId(StoreCollisionSetupsApi)
184
-
185
- readonly program = this.withCellId(ProgramApi)
186
-
187
- readonly license = this.withUnwrappedResponsesOnly(LicenseApi)
188
- readonly novaCloud = this.withUnwrappedResponsesOnly(NOVACloudApi)
189
- readonly robotConfigurations = this.withUnwrappedResponsesOnly(
190
- RobotConfigurationsApi,
191
- )
192
- readonly version = this.withUnwrappedResponsesOnly(VersionApi)
193
- readonly session = this.withUnwrappedResponsesOnly(SessionApi)
194
215
  }
@@ -2,14 +2,14 @@
2
2
  import type { Configuration as BaseConfiguration } from "@wandelbots/nova-api/v2"
3
3
  import type { AxiosRequestConfig } from "axios"
4
4
  import axios, { isAxiosError } from "axios"
5
- import { loginWithAuth0 } from "../../../LoginWithAuth0"
6
- import { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
7
- import { availableStorage } from "../../availableStorage"
8
- import { parseNovaInstanceUrl } from "../../converters"
9
-
10
- import { isLocalhostDev } from "../../context"
11
- import { MockNovaInstance } from "../../v2/mock/MockNovaInstance"
12
- import { NovaCellAPIClient } from "./NovaCellAPIClient"
5
+ import { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket.ts"
6
+ import { availableStorage } from "../../availableStorage.ts"
7
+ import { parseNovaInstanceUrl } from "../../converters.ts"
8
+ import { loginWithAuth0 } from "../../LoginWithAuth0.ts"
9
+
10
+ import { isLocalhostDev } from "../../context.ts"
11
+ import { MockNovaInstance } from "../../mock/MockNovaInstance.ts"
12
+ import { NovaCellAPIClient } from "./NovaCellAPIClient.ts"
13
13
 
14
14
  /** @deprecated Use `NovaClientConfig` from `Nova` instead. */
15
15
  export type NovaClientConfig = {
@@ -1,5 +1,5 @@
1
1
  import { isAxiosError } from "axios"
2
- import { tryStringifyJson } from "./converters"
2
+ import { tryStringifyJson } from "./converters.ts"
3
3
 
4
4
  export function delay(ms: number) {
5
5
  return new Promise((resolve) => setTimeout(resolve, ms))
@@ -2,13 +2,13 @@ import type { MotionGroupState } from "@wandelbots/nova-api/v2"
2
2
  import type { AxiosResponse, InternalAxiosRequestConfig } from "axios"
3
3
  import { AxiosError } from "axios"
4
4
  import * as pathToRegexp from "path-to-regexp"
5
- import type { AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket"
6
- import { getCurrentRobotControllerState } from "./getCurrentRobotControllerState"
7
- import { getMotionGroupDescription } from "./getMotionGroupDescription"
8
- import { getMotionGroupKinematicModel } from "./getMotionGroupKinematicModel"
9
- import { getRobotController } from "./getRobotController"
10
- import { listCoordinateSystems } from "./listCoordinateSystems"
11
- import { listRobotControllers } from "./listRobotControllers"
5
+ import type { AutoReconnectingWebsocket } from "../AutoReconnectingWebsocket.ts"
6
+ import { getCurrentRobotControllerState } from "./getCurrentRobotControllerState.ts"
7
+ import { getMotionGroupDescription } from "./getMotionGroupDescription.ts"
8
+ import { getMotionGroupKinematicModel } from "./getMotionGroupKinematicModel.ts"
9
+ import { getRobotController } from "./getRobotController.ts"
10
+ import { listCoordinateSystems } from "./listCoordinateSystems.ts"
11
+ import { listRobotControllers } from "./listRobotControllers.ts"
12
12
 
13
13
  /**
14
14
  * Ultra-simplified mock Nova server for testing stuff
@@ -32,7 +32,7 @@ export class MockNovaInstance {
32
32
  if (!config.url) {
33
33
  throw new Error("No url sent with request")
34
34
  }
35
- const path = config.url.split("?")[0]
35
+ const path = config.url.split("?")[0] ?? config.url
36
36
 
37
37
  for (const handler of apiHandlers) {
38
38
  const match = pathToRegexp.match(handler.path)(path)
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @fileoverview
3
+ * @deprecated The NOVA v1 client is deprecated. Please use the v2 client from `@wandelbots/nova-js/v2` instead.
4
+ */
5
+
6
+ export * from "@wandelbots/nova-api/v1"
7
+ export * from "../lib/deprecated/v1/ConnectedMotionGroup.ts"
8
+ export * from "../lib/deprecated/v1/getLatestTrajectories.ts"
9
+ export * from "../lib/deprecated/v1/JoggerConnection.ts"
10
+ export * from "../lib/deprecated/v1/MotionStreamConnection.ts"
11
+ export * from "../lib/deprecated/v1/NovaCellAPIClient.ts"
12
+ export * from "../lib/deprecated/v1/NovaClient.ts"
13
+ export * from "../lib/deprecated/v1/ProgramStateConnection.ts"
14
+ export * from "../lib/deprecated/v1/wandelscriptUtils.ts"
@@ -0,0 +1,7 @@
1
+ export * from "@wandelbots/nova-api/v2"
2
+ export * from "../lib/deprecated/v2/NovaCellAPIClient.ts"
3
+ export * from "../lib/deprecated/v2/NovaClient.ts"
4
+ export * from "../lib/deprecated/v2/wandelscriptUtils.ts"
5
+ export { Nova } from "../lib/Nova.ts"
6
+ export type { NovaConfig } from "../lib/Nova.ts"
7
+ export { NovaAPIClient } from "../lib/NovaAPIClient.ts"
@@ -1 +0,0 @@
1
- {"version":3,"file":"AutoReconnectingWebsocket-DNOF9mpz.d.cts","names":[],"sources":["../src/lib/deprecated/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"mappings":";;;;;;AAgBA;;cAAa,kBAAA;EAAA,SACF,WAAA,EAAa,yBAAA;EAEhB,gBAAA,CACJ,MAAA,EAAQ,0BAAA,GACP,OAAA,CAAQ,aAAA;EAg8BX,yBAAA,CAA0B,MAAA,EAAQ,yBAAA;EAkOlC,sBAAA,CAAuB,MAAA,EAAQ,yBAAA,EAA2B,OAAA;AAAA;;;;;AAvqC5D;cCDa,gBAAA;EAAA,SACF,WAAA,EAAa,yBAAA;EAEhB,gBAAA,CACJ,MAAA,EAAQ,0BAAA,GACP,OAAA,CAAQ,aAAA;EAyCX,yBAAA,CAA0B,MAAA,EAAQ,yBAAA;EA+BlC,sBAAA,CAAuB,MAAA,EAAQ,yBAAA,EAA2B,OAAA;AAAA;;;cCxF/C,yBAAA,SAAkC,qBAAA;EAAA,SAOlC,IAAA;IACP,IAAA,GAAO,kBAAA,GAAsB,gBAAA;IAC7B,SAAA;EAAA;EARJ,oBAAA,GAAuB,YAAA;EACvB,SAAA;EACA,QAAA;cAGE,SAAA,UACS,IAAA;IACP,IAAA,GAAO,kBAAA,GAAsB,gBAAA;IAC7B,SAAA;EAAA;EA4CJ,SAAA,CAAU,SAAA;EAMV,QAAA,CAAS,IAAA;EF5CH;;;;EEwDN,OAAA;EF04BA;;;EE/3BM,MAAA,IAAM,OAAA;EFimCmB;;;EEnlCzB,MAAA,IAAM,OAAA;EFmlC6D;;;;ACxqC3E;ECqGQ,YAAA,IAAY,OAAA,CAAA,YAAA;;;;;EA4BZ,WAAA,IAAW,OAAA,CAAA,YAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AutoReconnectingWebsocket-DNOF9mpz.d.mts","names":[],"sources":["../src/lib/deprecated/v1/mock/MockNovaInstance.ts","../src/lib/v2/mock/MockNovaInstance.ts","../src/lib/AutoReconnectingWebsocket.ts"],"mappings":";;;;;;AAgBA;;cAAa,kBAAA;EAAA,SACF,WAAA,EAAa,yBAAA;EAEhB,gBAAA,CACJ,MAAA,EAAQ,0BAAA,GACP,OAAA,CAAQ,aAAA;EAg8BX,yBAAA,CAA0B,MAAA,EAAQ,yBAAA;EAkOlC,sBAAA,CAAuB,MAAA,EAAQ,yBAAA,EAA2B,OAAA;AAAA;;;;;AAvqC5D;cCDa,gBAAA;EAAA,SACF,WAAA,EAAa,yBAAA;EAEhB,gBAAA,CACJ,MAAA,EAAQ,0BAAA,GACP,OAAA,CAAQ,aAAA;EAyCX,yBAAA,CAA0B,MAAA,EAAQ,yBAAA;EA+BlC,sBAAA,CAAuB,MAAA,EAAQ,yBAAA,EAA2B,OAAA;AAAA;;;cCxF/C,yBAAA,SAAkC,qBAAA;EAAA,SAOlC,IAAA;IACP,IAAA,GAAO,kBAAA,GAAsB,gBAAA;IAC7B,SAAA;EAAA;EARJ,oBAAA,GAAuB,YAAA;EACvB,SAAA;EACA,QAAA;cAGE,SAAA,UACS,IAAA;IACP,IAAA,GAAO,kBAAA,GAAsB,gBAAA;IAC7B,SAAA;EAAA;EA4CJ,SAAA,CAAU,SAAA;EAMV,QAAA,CAAS,IAAA;EF5CH;;;;EEwDN,OAAA;EF04BA;;;EE/3BM,MAAA,IAAM,OAAA;EFimCmB;;;EEnlCzB,MAAA,IAAM,OAAA;EFmlC6D;;;;ACxqC3E;ECqGQ,YAAA,IAAY,OAAA,CAAA,YAAA;;;;;EA4BZ,WAAA,IAAW,OAAA,CAAA,YAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-BQk3xGAI.mjs","names":[],"sources":["../src/lib/AutoReconnectingWebsocket.ts","../src/lib/availableStorage.ts","../src/lib/converters.ts","../src/LoginWithAuth0.ts","../src/lib/context.ts"],"sourcesContent":["import ReconnectingWebSocket, { type ErrorEvent } from \"reconnecting-websocket\"\nimport type * as v1 from \"./deprecated/v1/mock/MockNovaInstance\"\nimport type * as v2 from \"./v2/mock/MockNovaInstance\"\n\nexport class AutoReconnectingWebsocket extends ReconnectingWebSocket {\n receivedFirstMessage?: MessageEvent\n targetUrl: string\n disposed = false\n\n constructor(\n targetUrl: string,\n readonly opts: {\n mock?: v1.MockNovaInstance | v2.MockNovaInstance\n onDispose?: () => void\n } = {},\n ) {\n console.log(\"Opening websocket to\", targetUrl)\n\n super(() => this.targetUrl || targetUrl, undefined, {\n startClosed: true,\n })\n\n // Reconnecting websocket doesn't set this properly with startClosed\n Object.defineProperty(this, \"url\", {\n get() {\n return this.targetUrl\n },\n })\n\n this.targetUrl = targetUrl\n\n this.addEventListener(\"open\", () => {\n console.log(`Websocket to ${this.url} opened`)\n })\n\n this.addEventListener(\"message\", (ev) => {\n if (!this.receivedFirstMessage) {\n this.receivedFirstMessage = ev\n }\n })\n\n this.addEventListener(\"close\", () => {\n console.log(`Websocket to ${this.url} closed`)\n })\n\n const origReconnect = this.reconnect\n this.reconnect = () => {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketConnection(this)\n } else {\n origReconnect.apply(this)\n }\n }\n\n this.reconnect()\n }\n\n changeUrl(targetUrl: string) {\n this.receivedFirstMessage = undefined\n this.targetUrl = targetUrl\n this.reconnect()\n }\n\n sendJson(data: unknown) {\n if (this.opts.mock) {\n this.opts.mock.handleWebsocketMessage(this, JSON.stringify(data))\n } else {\n this.send(JSON.stringify(data))\n }\n }\n\n /**\n * Permanently close this websocket and indicate that\n * this object should not be used again.\n **/\n dispose() {\n this.close()\n this.disposed = true\n if (this.opts.onDispose) {\n this.opts.onDispose()\n }\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the OPEN state. */\n async opened() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.OPEN) {\n resolve()\n } else {\n this.addEventListener(\"open\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves once the websocket\n * is in the CLOSED state. */\n async closed() {\n return new Promise<void>((resolve, reject) => {\n if (this.readyState === WebSocket.CLOSED) {\n resolve()\n } else {\n this.addEventListener(\"close\", () => resolve())\n this.addEventListener(\"error\", reject)\n }\n })\n }\n\n /**\n * Returns a promise that resolves when the first message\n * is received from the websocket. Resolves immediately if\n * the first message has already been received.\n */\n async firstMessage() {\n if (this.receivedFirstMessage) {\n return this.receivedFirstMessage\n }\n\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.receivedFirstMessage = ev\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n\n /**\n * Returns a promise that resolves when the next message\n * is received from the websocket.\n */\n async nextMessage() {\n return new Promise<MessageEvent>((resolve, reject) => {\n const onMessage = (ev: MessageEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n resolve(ev)\n }\n\n const onError = (ev: ErrorEvent) => {\n this.removeEventListener(\"message\", onMessage)\n this.removeEventListener(\"error\", onError)\n reject(ev)\n }\n\n this.addEventListener(\"message\", onMessage)\n this.addEventListener(\"error\", onError)\n })\n }\n}\n","/**\n * Safety wrapper around browser localStorage providing context availability\n * checks and JSON parsing\n */\nclass AvailableStorage {\n available = typeof window !== \"undefined\" && !!window.localStorage\n\n getJSON<T>(key: string): Partial<T> | null {\n if (!this.available) return null\n\n const result = window.localStorage.getItem(key)\n if (result === null) return null\n\n try {\n return JSON.parse(result)\n } catch (err) {\n return null\n }\n }\n\n setJSON(key: string, obj: unknown) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, JSON.stringify(obj))\n }\n\n delete(key: string) {\n if (!this.available) return null\n\n window.localStorage.removeItem(key)\n }\n\n setString(key: string, value: string) {\n if (!this.available) return null\n\n window.localStorage.setItem(key, value)\n }\n\n getString(key: string): string | null {\n if (!this.available) return null\n\n return window.localStorage.getItem(key)\n }\n}\n\nexport const availableStorage = new AvailableStorage()\n","export type URLParseOptions = {\n /**\n * Ignore any scheme in the input string and force this scheme instead.\n */\n scheme?: \"http\" | \"https\"\n /**\n * If the input string does not include a scheme, use this as the default\n * scheme.\n */\n defaultScheme?: \"http\" | \"https\"\n}\n\n/**\n * Parse a string as a URL, with options to enforce or default the scheme.\n */\nexport function parseUrl(url: string, options: URLParseOptions = {}): URL {\n const { scheme, defaultScheme } = options\n\n const schemeRegex = /^[a-zA-Z]+:\\/\\//\n\n if (scheme) {\n // Force the scheme by removing any existing scheme and prepending the desired one\n url = url.replace(schemeRegex, \"\")\n url = `${scheme}://${url}`\n } else if (defaultScheme && !schemeRegex.test(url)) {\n // No scheme is present, add the default one\n url = `${defaultScheme}://${url}`\n }\n\n return new URL(url)\n}\n\n/**\n * Attempt to parse a string as a URL; return undefined if we can't\n */\nexport function tryParseUrl(\n url: string,\n options: URLParseOptions = {},\n): URL | undefined {\n try {\n return parseUrl(url, options)\n } catch {\n return undefined\n }\n}\n\n/**\n * Permissively parse a NOVA instance URL from a config variable.\n * If scheme is not specified, defaults to https for *.wandelbots.io hosts,\n * and http otherwise.\n * Throws an error if a valid URL could not be determined.\n */\nexport function parseNovaInstanceUrl(url: string): URL {\n const testUrl = tryParseUrl(url, { defaultScheme: \"http\" })\n if (testUrl?.host.endsWith(\".wandelbots.io\")) {\n return parseUrl(url, { defaultScheme: \"https\" })\n } else {\n return parseUrl(url, { defaultScheme: \"http\" })\n }\n}\n\n/** Try to parse something as JSON; return undefined if we can't */\n// biome-ignore lint/suspicious/noExplicitAny: it's json\nexport function tryParseJson(json: unknown): any {\n try {\n return JSON.parse(json as string)\n } catch {\n return undefined\n }\n}\n\n/** Try to turn something into JSON; return undefined if we can't */\nexport function tryStringifyJson(json: unknown): string | undefined {\n try {\n return JSON.stringify(json)\n } catch {\n return undefined\n }\n}\n\n/**\n * Converts object parameters to query string.\n * e.g. { a: \"1\", b: \"2\" } => \"?a=1&b=2\"\n * {} => \"\"\n */\nexport function makeUrlQueryString(obj: Record<string, string>): string {\n const str = new URLSearchParams(obj).toString()\n return str ? `?${str}` : \"\"\n}\n\n/** Convert radians to degrees */\nexport function radiansToDegrees(radians: number): number {\n return radians * (180 / Math.PI)\n}\n\n/** Convert degrees to radians */\nexport function degreesToRadians(degrees: number): number {\n return degrees * (Math.PI / 180)\n}\n\n/**\n * Check for coordinate system id equivalence, accounting for the \"world\" default\n * on empty/undefined values.\n */\nexport function isSameCoordinateSystem(\n firstCoordSystem: string | undefined,\n secondCoordSystem: string | undefined,\n) {\n if (!firstCoordSystem) firstCoordSystem = \"world\"\n if (!secondCoordSystem) secondCoordSystem = \"world\"\n\n return firstCoordSystem === secondCoordSystem\n}\n\n/**\n * Helpful const for converting {x, y, z} to [x, y, z] and vice versa\n */\nexport const XYZ_TO_VECTOR = { x: 0, y: 1, z: 2 }\n","/**\n * Mapping of stages to Auth0 configurations.\n * The client ids are public identifiers for a specific auth0 application\n * and are safe to include in client-side code.\n * https://auth0.com/docs/get-started/applications/application-settings\n */\nconst auth0ConfigMap = {\n dev: {\n domain: `https://auth.portal.dev.wandelbots.io`,\n clientId: \"fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha\",\n },\n stg: {\n domain: `https://auth.portal.stg.wandelbots.io`,\n clientId: \"joVDeD9e786WzFNSGCqoVq7HNkWt5j6s\",\n },\n prod: {\n domain: `https://auth.portal.wandelbots.io`,\n clientId: \"J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2\",\n },\n}\n\n/** Determine which Auth0 configuration to use based on instance URL */\nexport const getAuth0Config = (instanceUrl: URL) => {\n if (instanceUrl.host.endsWith(\".dev.wandelbots.io\")) return auth0ConfigMap.dev\n if (instanceUrl.host.endsWith(\".stg.wandelbots.io\")) return auth0ConfigMap.stg\n if (instanceUrl.host.endsWith(\".wandelbots.io\")) return auth0ConfigMap.prod\n throw new Error(\n `Unable to authenticate with NOVA instance \"${instanceUrl}\". Auth0 login is only supported for cloud instances with hosts of the form \"**.wandelbots.io\".`,\n )\n}\n\n/**\n * Initializes Auth0 login process using redirect if necessary and retrieves an access token.\n * Returns null when an access token should not be needed to authenticate (i.e. cookie auth\n * when deployed on the instance domain)\n */\nexport const loginWithAuth0 = async (\n instanceUrl: URL,\n): Promise<string | null> => {\n if (typeof window === \"undefined\") {\n throw new Error(\n `Access token must be set to use NovaClient when not in a browser environment.`,\n )\n }\n\n if (instanceUrl.origin === window.location.origin) {\n // When deployed on the instance itself, our auth is handled by cookies\n // and no access token is needed-- just need to reload the page and it'll\n // login again / set cookie as needed\n window.location.reload()\n throw new Error(\n \"Failed to reload page to get auth details, please refresh manually\",\n )\n }\n\n // If we're on localhost or another domain, we need to do the full oauth flow\n // Note this will ONLY work for origins which are whitelisted as a redirect_uri\n // in the auth0 config, currently\n const { Auth0Client } = await import(\"@auth0/auth0-spa-js\")\n\n const auth0Config = getAuth0Config(instanceUrl)\n\n const auth0Client = new Auth0Client({\n domain: auth0Config.domain,\n clientId: auth0Config.clientId ?? \"\",\n useRefreshTokens: false,\n authorizationParams: {\n audience: \"nova-api\",\n redirect_uri: window.location.origin,\n },\n })\n\n // If the URL includes a redirect result, handle it\n if (\n window.location.search.includes(\"code=\") &&\n window.location.search.includes(\"state=\")\n ) {\n const { appState } = await auth0Client.handleRedirectCallback()\n // Return to the URL the user was originally on before the redirect\n window.history.replaceState(\n {},\n document.title,\n appState?.returnTo || window.location.pathname,\n )\n } else {\n // Initiate login with redirect\n await auth0Client.loginWithRedirect()\n }\n\n // Once logged in, retrieve the access token silently\n const accessToken = await auth0Client.getTokenSilently()\n return accessToken\n}\n","// Some general checks about the context the nova-js code is running in\n\nexport const isBrowser = typeof window !== \"undefined\"\n\nexport const isLocalhostDev =\n isBrowser &&\n window.location.hostname === \"localhost\" &&\n process.env.NODE_ENV === \"development\"\n"],"mappings":";;AAIA,IAAa,4BAAb,cAA+C,sBAAsB;CAKnE,YACE,WACA,OAGI,CAAC,GACL;EACA,QAAQ,IAAI,wBAAwB,SAAS;EAE7C,YAAY,KAAK,aAAa,WAAW,KAAA,GAAW,EAClD,aAAa,KACf,CAAC;EATQ,KAAA,OAAA;kBAJA;EAgBT,OAAO,eAAe,MAAM,OAAO,EACjC,MAAM;GACJ,OAAO,KAAK;EACd,EACF,CAAC;EAED,KAAK,YAAY;EAEjB,KAAK,iBAAiB,cAAc;GAClC,QAAQ,IAAI,gBAAgB,KAAK,IAAI,QAAQ;EAC/C,CAAC;EAED,KAAK,iBAAiB,YAAY,OAAO;GACvC,IAAI,CAAC,KAAK,sBACR,KAAK,uBAAuB;EAEhC,CAAC;EAED,KAAK,iBAAiB,eAAe;GACnC,QAAQ,IAAI,gBAAgB,KAAK,IAAI,QAAQ;EAC/C,CAAC;EAED,MAAM,gBAAgB,KAAK;EAC3B,KAAK,kBAAkB;GACrB,IAAI,KAAK,KAAK,MACZ,KAAK,KAAK,KAAK,0BAA0B,IAAI;QAE7C,cAAc,MAAM,IAAI;EAE5B;EAEA,KAAK,UAAU;CACjB;CAEA,UAAU,WAAmB;EAC3B,KAAK,uBAAuB,KAAA;EAC5B,KAAK,YAAY;EACjB,KAAK,UAAU;CACjB;CAEA,SAAS,MAAe;EACtB,IAAI,KAAK,KAAK,MACZ,KAAK,KAAK,KAAK,uBAAuB,MAAM,KAAK,UAAU,IAAI,CAAC;OAEhE,KAAK,KAAK,KAAK,UAAU,IAAI,CAAC;CAElC;;;;;CAMA,UAAU;EACR,KAAK,MAAM;EACX,KAAK,WAAW;EAChB,IAAI,KAAK,KAAK,WACZ,KAAK,KAAK,UAAU;CAExB;;;;CAKA,MAAM,SAAS;EACb,OAAO,IAAI,SAAe,SAAS,WAAW;GAC5C,IAAI,KAAK,eAAe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