@wandelbots/nova-js 3.1.0 → 3.2.0-pr.ci-simplify-build.137.87eeb8d

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 (79) hide show
  1. package/dist/AutoReconnectingWebsocket-BI1ckzP8.d.ts +71 -0
  2. package/dist/AutoReconnectingWebsocket-BI1ckzP8.d.ts.map +1 -0
  3. package/dist/AutoReconnectingWebsocket-Cr7f9016.d.cts +71 -0
  4. package/dist/AutoReconnectingWebsocket-Cr7f9016.d.cts.map +1 -0
  5. package/dist/LoginWithAuth0-0g0wWRUC.js +217 -0
  6. package/dist/LoginWithAuth0-0g0wWRUC.js.map +1 -0
  7. package/dist/LoginWithAuth0-C82OCyDy.cjs +264 -0
  8. package/dist/LoginWithAuth0-C82OCyDy.cjs.map +1 -0
  9. package/dist/converters-DP2EIVv6.cjs +108 -0
  10. package/dist/converters-DP2EIVv6.cjs.map +1 -0
  11. package/dist/converters-DY6Lf7mb.js +66 -0
  12. package/dist/converters-DY6Lf7mb.js.map +1 -0
  13. package/dist/index.cjs +41 -386
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +70 -0
  16. package/dist/index.d.cts.map +1 -0
  17. package/dist/index.d.ts +69 -5
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +28 -52
  20. package/dist/index.js.map +1 -1
  21. package/dist/lib/v1/index.cjs +2146 -2917
  22. package/dist/lib/v1/index.cjs.map +1 -1
  23. package/dist/lib/v1/index.d.cts +397 -0
  24. package/dist/lib/v1/index.d.cts.map +1 -0
  25. package/dist/lib/v1/index.d.ts +395 -7
  26. package/dist/lib/v1/index.d.ts.map +1 -1
  27. package/dist/lib/v1/index.js +2127 -2623
  28. package/dist/lib/v1/index.js.map +1 -1
  29. package/dist/lib/v2/index.cjs +1356 -1472
  30. package/dist/lib/v2/index.cjs.map +1 -1
  31. package/dist/lib/v2/index.d.cts +115 -0
  32. package/dist/lib/v2/index.d.cts.map +1 -0
  33. package/dist/lib/v2/index.d.ts +113 -2
  34. package/dist/lib/v2/index.d.ts.map +1 -1
  35. package/dist/lib/v2/index.js +1346 -1189
  36. package/dist/lib/v2/index.js.map +1 -1
  37. package/package.json +14 -16
  38. package/src/LoginWithAuth0.ts +9 -9
  39. package/src/lib/v1/NovaCellAPIClient.ts +4 -2
  40. package/src/lib/v2/NovaCellAPIClient.ts +4 -2
  41. package/src/lib/v2/mock/MockNovaInstance.ts +9 -13
  42. package/dist/LoginWithAuth0.d.ts +0 -7
  43. package/dist/LoginWithAuth0.d.ts.map +0 -1
  44. package/dist/chunk-B2C22PTK.js +0 -53
  45. package/dist/chunk-B2C22PTK.js.map +0 -1
  46. package/dist/chunk-I3PUV6ZD.js +0 -286
  47. package/dist/chunk-I3PUV6ZD.js.map +0 -1
  48. package/dist/lib/AutoReconnectingWebsocket.d.ts +0 -43
  49. package/dist/lib/AutoReconnectingWebsocket.d.ts.map +0 -1
  50. package/dist/lib/availableStorage.d.ts +0 -15
  51. package/dist/lib/availableStorage.d.ts.map +0 -1
  52. package/dist/lib/converters.d.ts +0 -26
  53. package/dist/lib/converters.d.ts.map +0 -1
  54. package/dist/lib/errorHandling.d.ts +0 -15
  55. package/dist/lib/errorHandling.d.ts.map +0 -1
  56. package/dist/lib/v1/ConnectedMotionGroup.d.ts +0 -77
  57. package/dist/lib/v1/ConnectedMotionGroup.d.ts.map +0 -1
  58. package/dist/lib/v1/JoggerConnection.d.ts +0 -94
  59. package/dist/lib/v1/JoggerConnection.d.ts.map +0 -1
  60. package/dist/lib/v1/MotionStreamConnection.d.ts +0 -26
  61. package/dist/lib/v1/MotionStreamConnection.d.ts.map +0 -1
  62. package/dist/lib/v1/NovaCellAPIClient.d.ts +0 -68
  63. package/dist/lib/v1/NovaCellAPIClient.d.ts.map +0 -1
  64. package/dist/lib/v1/NovaClient.d.ts +0 -67
  65. package/dist/lib/v1/NovaClient.d.ts.map +0 -1
  66. package/dist/lib/v1/ProgramStateConnection.d.ts +0 -57
  67. package/dist/lib/v1/ProgramStateConnection.d.ts.map +0 -1
  68. package/dist/lib/v1/getLatestTrajectories.d.ts +0 -4
  69. package/dist/lib/v1/getLatestTrajectories.d.ts.map +0 -1
  70. package/dist/lib/v1/mock/MockNovaInstance.d.ts +0 -13
  71. package/dist/lib/v1/mock/MockNovaInstance.d.ts.map +0 -1
  72. package/dist/lib/v1/motionStateUpdate.d.ts +0 -4
  73. package/dist/lib/v1/motionStateUpdate.d.ts.map +0 -1
  74. package/dist/lib/v2/NovaCellAPIClient.d.ts +0 -62
  75. package/dist/lib/v2/NovaCellAPIClient.d.ts.map +0 -1
  76. package/dist/lib/v2/NovaClient.d.ts +0 -60
  77. package/dist/lib/v2/NovaClient.d.ts.map +0 -1
  78. package/dist/lib/v2/mock/MockNovaInstance.d.ts +0 -13
  79. package/dist/lib/v2/mock/MockNovaInstance.d.ts.map +0 -1
@@ -1,1483 +1,1367 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- var __export = (target, all) => {
26
- for (var name in all)
27
- __defProp(target, name, { get: all[name], enumerable: true });
28
- };
29
- var __copyProps = (to, from, except, desc) => {
30
- if (from && typeof from === "object" || typeof from === "function") {
31
- for (let key of __getOwnPropNames(from))
32
- if (!__hasOwnProp.call(to, key) && key !== except)
33
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
- }
35
- return to;
36
- };
37
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
38
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
39
- // If the importer is in node compatibility mode or this is not an ESM
40
- // file that has been converted to a CommonJS file using a Babel-
41
- // compatible transform (i.e. "__esModule" has not been set), then set
42
- // "default" to the CommonJS "module.exports" for node compatibility.
43
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
44
- mod
45
- ));
46
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
47
- var __async = (__this, __arguments, generator) => {
48
- return new Promise((resolve, reject) => {
49
- var fulfilled = (value) => {
50
- try {
51
- step(generator.next(value));
52
- } catch (e) {
53
- reject(e);
54
- }
55
- };
56
- var rejected = (value) => {
57
- try {
58
- step(generator.throw(value));
59
- } catch (e) {
60
- reject(e);
61
- }
62
- };
63
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
64
- step((generator = generator.apply(__this, __arguments)).next());
65
- });
66
- };
1
+ const require_LoginWithAuth0 = require('../../LoginWithAuth0-C82OCyDy.cjs');
2
+ let axios = require("axios");
3
+ axios = require_LoginWithAuth0.__toESM(axios);
4
+ let url_join = require("url-join");
5
+ url_join = require_LoginWithAuth0.__toESM(url_join);
6
+ let path_to_regexp = require("path-to-regexp");
7
+ path_to_regexp = require_LoginWithAuth0.__toESM(path_to_regexp);
8
+ let __wandelbots_nova_api_v2 = require("@wandelbots/nova-api/v2");
9
+ __wandelbots_nova_api_v2 = require_LoginWithAuth0.__toESM(__wandelbots_nova_api_v2);
67
10
 
68
- // src/lib/v2/index.ts
69
- var v2_exports = {};
70
- __export(v2_exports, {
71
- NovaCellAPIClient: () => NovaCellAPIClient,
72
- NovaClient: () => NovaClient
73
- });
74
- module.exports = __toCommonJS(v2_exports);
75
- __reExport(v2_exports, require("@wandelbots/nova-api/v2"), module.exports);
76
-
77
- // src/lib/v2/NovaCellAPIClient.ts
78
- var import_v2 = require("@wandelbots/nova-api/v2");
79
- var import_axios = __toESM(require("axios"), 1);
11
+ //#region src/lib/v2/NovaCellAPIClient.ts
12
+ /**
13
+ * API client providing type-safe access to all the Nova API REST endpoints
14
+ * associated with a specific cell id.
15
+ */
80
16
  var NovaCellAPIClient = class {
81
- constructor(cellId, opts) {
82
- this.cellId = cellId;
83
- this.opts = opts;
84
- this.system = this.withUnwrappedResponsesOnly(import_v2.SystemApi);
85
- this.cell = this.withUnwrappedResponsesOnly(import_v2.CellApi);
86
- this.motionGroup = this.withCellId(import_v2.MotionGroupApi);
87
- this.motionGroupModels = this.withCellId(import_v2.MotionGroupModelsApi);
88
- this.controller = this.withCellId(import_v2.ControllerApi);
89
- this.controllerIOs = this.withCellId(import_v2.ControllerInputsOutputsApi);
90
- this.trajectoryPlanning = this.withCellId(import_v2.TrajectoryPlanningApi);
91
- this.trajectoryExecution = this.withCellId(import_v2.TrajectoryExecutionApi);
92
- this.trajectoryCaching = this.withCellId(import_v2.TrajectoryCachingApi);
93
- this.application = this.withCellId(import_v2.ApplicationApi);
94
- this.applicationGlobal = this.withUnwrappedResponsesOnly(import_v2.ApplicationApi);
95
- this.jogging = this.withCellId(import_v2.JoggingApi);
96
- this.kinematics = this.withCellId(import_v2.KinematicsApi);
97
- this.busInputsOutputs = this.withCellId(import_v2.BUSInputsOutputsApi);
98
- this.virtualController = this.withCellId(import_v2.VirtualControllerApi);
99
- this.virtualControllerBehavior = this.withCellId(
100
- import_v2.VirtualControllerBehaviorApi
101
- );
102
- this.virtualControllerIOs = this.withCellId(
103
- import_v2.VirtualControllerInputsOutputsApi
104
- );
105
- this.storeObject = this.withCellId(import_v2.StoreObjectApi);
106
- this.storeCollisionComponents = this.withCellId(
107
- import_v2.StoreCollisionComponentsApi
108
- );
109
- this.storeCollisionSetups = this.withCellId(import_v2.StoreCollisionSetupsApi);
110
- }
111
- /**
112
- * Some TypeScript sorcery which alters the API class methods so you don't
113
- * have to pass the cell id to every single one, and de-encapsulates the
114
- * response data
115
- */
116
- withCellId(ApiConstructor) {
117
- var _a, _b;
118
- const apiClient = new ApiConstructor(
119
- __spreadProps(__spreadValues({}, this.opts), {
120
- isJsonMime: (mime) => {
121
- return mime === "application/json";
122
- }
123
- }),
124
- (_a = this.opts.basePath) != null ? _a : "",
125
- (_b = this.opts.axiosInstance) != null ? _b : import_axios.default.create()
126
- );
127
- for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) {
128
- if (key !== "constructor" && typeof apiClient[key] === "function") {
129
- const originalFunction = apiClient[key];
130
- apiClient[key] = (...args) => {
131
- return originalFunction.apply(apiClient, [this.cellId, ...args]).then((res) => res.data);
132
- };
133
- }
134
- }
135
- return apiClient;
136
- }
137
- /**
138
- * As withCellId, but only does the response unwrapping
139
- */
140
- withUnwrappedResponsesOnly(ApiConstructor) {
141
- var _a, _b;
142
- const apiClient = new ApiConstructor(
143
- __spreadProps(__spreadValues({}, this.opts), {
144
- isJsonMime: (mime) => {
145
- return mime === "application/json";
146
- }
147
- }),
148
- (_a = this.opts.basePath) != null ? _a : "",
149
- (_b = this.opts.axiosInstance) != null ? _b : import_axios.default.create()
150
- );
151
- for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) {
152
- if (key !== "constructor" && typeof apiClient[key] === "function") {
153
- const originalFunction = apiClient[key];
154
- apiClient[key] = (...args) => {
155
- return originalFunction.apply(apiClient, args).then((res) => res.data);
156
- };
157
- }
158
- }
159
- return apiClient;
160
- }
17
+ constructor(cellId, opts) {
18
+ this.cellId = cellId;
19
+ this.opts = opts;
20
+ this.system = this.withUnwrappedResponsesOnly(__wandelbots_nova_api_v2.SystemApi);
21
+ this.cell = this.withUnwrappedResponsesOnly(__wandelbots_nova_api_v2.CellApi);
22
+ this.motionGroup = this.withCellId(__wandelbots_nova_api_v2.MotionGroupApi);
23
+ this.motionGroupModels = this.withCellId(__wandelbots_nova_api_v2.MotionGroupModelsApi);
24
+ this.controller = this.withCellId(__wandelbots_nova_api_v2.ControllerApi);
25
+ this.controllerIOs = this.withCellId(__wandelbots_nova_api_v2.ControllerInputsOutputsApi);
26
+ this.trajectoryPlanning = this.withCellId(__wandelbots_nova_api_v2.TrajectoryPlanningApi);
27
+ this.trajectoryExecution = this.withCellId(__wandelbots_nova_api_v2.TrajectoryExecutionApi);
28
+ this.trajectoryCaching = this.withCellId(__wandelbots_nova_api_v2.TrajectoryCachingApi);
29
+ this.application = this.withCellId(__wandelbots_nova_api_v2.ApplicationApi);
30
+ this.applicationGlobal = this.withUnwrappedResponsesOnly(__wandelbots_nova_api_v2.ApplicationApi);
31
+ this.jogging = this.withCellId(__wandelbots_nova_api_v2.JoggingApi);
32
+ this.kinematics = this.withCellId(__wandelbots_nova_api_v2.KinematicsApi);
33
+ this.busInputsOutputs = this.withCellId(__wandelbots_nova_api_v2.BUSInputsOutputsApi);
34
+ this.virtualController = this.withCellId(__wandelbots_nova_api_v2.VirtualControllerApi);
35
+ this.virtualControllerBehavior = this.withCellId(__wandelbots_nova_api_v2.VirtualControllerBehaviorApi);
36
+ this.virtualControllerIOs = this.withCellId(__wandelbots_nova_api_v2.VirtualControllerInputsOutputsApi);
37
+ this.storeObject = this.withCellId(__wandelbots_nova_api_v2.StoreObjectApi);
38
+ this.storeCollisionComponents = this.withCellId(__wandelbots_nova_api_v2.StoreCollisionComponentsApi);
39
+ this.storeCollisionSetups = this.withCellId(__wandelbots_nova_api_v2.StoreCollisionSetupsApi);
40
+ }
41
+ /**
42
+ * Some TypeScript sorcery which alters the API class methods so you don't
43
+ * have to pass the cell id to every single one, and de-encapsulates the
44
+ * response data
45
+ */
46
+ withCellId(ApiConstructor) {
47
+ const apiClient = new ApiConstructor({
48
+ ...this.opts,
49
+ isJsonMime: (mime) => {
50
+ return mime === "application/json";
51
+ }
52
+ }, this.opts.basePath ?? "", this.opts.axiosInstance ?? axios.default.create());
53
+ for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) if (key !== "constructor" && typeof apiClient[key] === "function") {
54
+ const originalFunction = apiClient[key];
55
+ apiClient[key] = (...args) => {
56
+ return originalFunction.apply(apiClient, [this.cellId, ...args]).then((res) => res.data);
57
+ };
58
+ }
59
+ return apiClient;
60
+ }
61
+ /**
62
+ * As withCellId, but only does the response unwrapping
63
+ */
64
+ withUnwrappedResponsesOnly(ApiConstructor) {
65
+ const apiClient = new ApiConstructor({
66
+ ...this.opts,
67
+ isJsonMime: (mime) => {
68
+ return mime === "application/json";
69
+ }
70
+ }, this.opts.basePath ?? "", this.opts.axiosInstance ?? axios.default.create());
71
+ for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient))) if (key !== "constructor" && typeof apiClient[key] === "function") {
72
+ const originalFunction = apiClient[key];
73
+ apiClient[key] = (...args) => {
74
+ return originalFunction.apply(apiClient, args).then((res) => res.data);
75
+ };
76
+ }
77
+ return apiClient;
78
+ }
161
79
  };
162
80
 
163
- // src/lib/v2/NovaClient.ts
164
- var import_axios3 = __toESM(require("axios"), 1);
165
- var import_url_join = __toESM(require("url-join"), 1);
166
-
167
- // src/LoginWithAuth0.ts
168
- var DOMAIN_SUFFIX = "wandelbots.io";
169
- var auth0ConfigMap = {
170
- dev: {
171
- domain: `https://auth.portal.dev.${DOMAIN_SUFFIX}`,
172
- clientId: "fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha"
173
- },
174
- stg: {
175
- domain: `https://auth.portal.stg.${DOMAIN_SUFFIX}`,
176
- clientId: "joVDeD9e786WzFNSGCqoVq7HNkWt5j6s"
177
- },
178
- prod: {
179
- domain: `https://auth.portal.${DOMAIN_SUFFIX}`,
180
- clientId: "J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2"
181
- }
182
- };
183
- var getAuth0Config = (instanceUrl) => {
184
- if (instanceUrl.includes(`dev.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.dev;
185
- if (instanceUrl.includes(`stg.${DOMAIN_SUFFIX}`)) return auth0ConfigMap.stg;
186
- if (instanceUrl.includes(DOMAIN_SUFFIX)) return auth0ConfigMap.prod;
187
- throw new Error(
188
- "Unsupported instance URL. Cannot determine Auth0 configuration."
189
- );
190
- };
191
- var loginWithAuth0 = (instanceUrl) => __async(null, null, function* () {
192
- var _a;
193
- if (typeof window === "undefined") {
194
- throw new Error(
195
- `Access token must be set to use NovaClient when not in a browser environment.`
196
- );
197
- }
198
- const auth0Config = getAuth0Config(instanceUrl);
199
- if (new URL(instanceUrl).origin === window.location.origin) {
200
- window.location.reload();
201
- throw new Error(
202
- "Failed to reload page to get auth details, please refresh manually"
203
- );
204
- }
205
- const { Auth0Client } = yield import("@auth0/auth0-spa-js");
206
- const auth0Client = new Auth0Client({
207
- domain: auth0Config.domain,
208
- clientId: (_a = auth0Config.clientId) != null ? _a : "",
209
- useRefreshTokens: false,
210
- authorizationParams: {
211
- audience: "nova-api",
212
- redirect_uri: window.location.origin
213
- }
214
- });
215
- if (window.location.search.includes("code=") && window.location.search.includes("state=")) {
216
- const { appState } = yield auth0Client.handleRedirectCallback();
217
- window.history.replaceState(
218
- {},
219
- document.title,
220
- (appState == null ? void 0 : appState.returnTo) || window.location.pathname
221
- );
222
- } else {
223
- yield auth0Client.loginWithRedirect();
224
- }
225
- const accessToken = yield auth0Client.getTokenSilently();
226
- return accessToken;
227
- });
228
-
229
- // src/lib/AutoReconnectingWebsocket.ts
230
- var import_reconnecting_websocket = __toESM(require("reconnecting-websocket"), 1);
231
- var AutoReconnectingWebsocket = class extends import_reconnecting_websocket.default {
232
- constructor(targetUrl, opts = {}) {
233
- console.log("Opening websocket to", targetUrl);
234
- super(() => this.targetUrl || targetUrl, void 0, {
235
- startClosed: true
236
- });
237
- this.opts = opts;
238
- this.disposed = false;
239
- Object.defineProperty(this, "url", {
240
- get() {
241
- return this.targetUrl;
242
- }
243
- });
244
- this.targetUrl = targetUrl;
245
- this.addEventListener("open", () => {
246
- console.log(`Websocket to ${this.url} opened`);
247
- });
248
- this.addEventListener("message", (ev) => {
249
- if (!this.receivedFirstMessage) {
250
- this.receivedFirstMessage = ev;
251
- }
252
- });
253
- this.addEventListener("close", () => {
254
- console.log(`Websocket to ${this.url} closed`);
255
- });
256
- const origReconnect = this.reconnect;
257
- this.reconnect = () => {
258
- if (this.opts.mock) {
259
- this.opts.mock.handleWebsocketConnection(this);
260
- } else {
261
- origReconnect.apply(this);
262
- }
263
- };
264
- this.reconnect();
265
- }
266
- changeUrl(targetUrl) {
267
- this.receivedFirstMessage = void 0;
268
- this.targetUrl = targetUrl;
269
- this.reconnect();
270
- }
271
- sendJson(data) {
272
- if (this.opts.mock) {
273
- this.opts.mock.handleWebsocketMessage(this, JSON.stringify(data));
274
- } else {
275
- this.send(JSON.stringify(data));
276
- }
277
- }
278
- /**
279
- * Permanently close this websocket and indicate that
280
- * this object should not be used again.
281
- **/
282
- dispose() {
283
- this.close();
284
- this.disposed = true;
285
- if (this.opts.onDispose) {
286
- this.opts.onDispose();
287
- }
288
- }
289
- /**
290
- * Returns a promise that resolves once the websocket
291
- * is in the OPEN state. */
292
- opened() {
293
- return __async(this, null, function* () {
294
- return new Promise((resolve, reject) => {
295
- if (this.readyState === WebSocket.OPEN) {
296
- resolve();
297
- } else {
298
- this.addEventListener("open", () => resolve());
299
- this.addEventListener("error", reject);
300
- }
301
- });
302
- });
303
- }
304
- /**
305
- * Returns a promise that resolves once the websocket
306
- * is in the CLOSED state. */
307
- closed() {
308
- return __async(this, null, function* () {
309
- return new Promise((resolve, reject) => {
310
- if (this.readyState === WebSocket.CLOSED) {
311
- resolve();
312
- } else {
313
- this.addEventListener("close", () => resolve());
314
- this.addEventListener("error", reject);
315
- }
316
- });
317
- });
318
- }
319
- /**
320
- * Returns a promise that resolves when the first message
321
- * is received from the websocket. Resolves immediately if
322
- * the first message has already been received.
323
- */
324
- firstMessage() {
325
- return __async(this, null, function* () {
326
- if (this.receivedFirstMessage) {
327
- return this.receivedFirstMessage;
328
- }
329
- return new Promise((resolve, reject) => {
330
- const onMessage = (ev) => {
331
- this.receivedFirstMessage = ev;
332
- this.removeEventListener("message", onMessage);
333
- this.removeEventListener("error", onError);
334
- resolve(ev);
335
- };
336
- const onError = (ev) => {
337
- this.removeEventListener("message", onMessage);
338
- this.removeEventListener("error", onError);
339
- reject(ev);
340
- };
341
- this.addEventListener("message", onMessage);
342
- this.addEventListener("error", onError);
343
- });
344
- });
345
- }
346
- /**
347
- * Returns a promise that resolves when the next message
348
- * is received from the websocket.
349
- */
350
- nextMessage() {
351
- return __async(this, null, function* () {
352
- return new Promise((resolve, reject) => {
353
- const onMessage = (ev) => {
354
- this.removeEventListener("message", onMessage);
355
- this.removeEventListener("error", onError);
356
- resolve(ev);
357
- };
358
- const onError = (ev) => {
359
- this.removeEventListener("message", onMessage);
360
- this.removeEventListener("error", onError);
361
- reject(ev);
362
- };
363
- this.addEventListener("message", onMessage);
364
- this.addEventListener("error", onError);
365
- });
366
- });
367
- }
368
- };
369
-
370
- // src/lib/availableStorage.ts
371
- var AvailableStorage = class {
372
- constructor() {
373
- this.available = typeof window !== "undefined" && !!window.localStorage;
374
- }
375
- getJSON(key) {
376
- if (!this.available) return null;
377
- const result = window.localStorage.getItem(key);
378
- if (result === null) return null;
379
- try {
380
- return JSON.parse(result);
381
- } catch (err) {
382
- return null;
383
- }
384
- }
385
- setJSON(key, obj) {
386
- if (!this.available) return null;
387
- window.localStorage.setItem(key, JSON.stringify(obj));
388
- }
389
- delete(key) {
390
- if (!this.available) return null;
391
- window.localStorage.removeItem(key);
392
- }
393
- setString(key, value) {
394
- if (!this.available) return null;
395
- window.localStorage.setItem(key, value);
396
- }
397
- getString(key) {
398
- if (!this.available) return null;
399
- return window.localStorage.getItem(key);
400
- }
401
- };
402
- var availableStorage = new AvailableStorage();
403
-
404
- // src/lib/v2/mock/MockNovaInstance.ts
405
- var import_axios2 = require("axios");
406
- var pathToRegexp = __toESM(require("path-to-regexp"), 1);
81
+ //#endregion
82
+ //#region src/lib/v2/mock/MockNovaInstance.ts
83
+ /**
84
+ * EXPERIMENTAL
85
+ * Ultra-simplified mock Nova server for testing stuff
86
+ */
407
87
  var MockNovaInstance = class {
408
- constructor() {
409
- this.connections = [];
410
- }
411
- handleAPIRequest(config) {
412
- return __async(this, null, function* () {
413
- var _a, _b, _c;
414
- const apiHandlers = [
415
- {
416
- method: "GET",
417
- path: "/cells/:cellId/controllers",
418
- handle() {
419
- return {
420
- controllers: [
421
- {
422
- controller: "mock-ur5e",
423
- model_name: "UniversalRobots::Controller",
424
- host: "mock-ur5e",
425
- allow_software_install_on_controller: true,
426
- motion_groups: [
427
- {
428
- motion_group: "0@mock-ur5e",
429
- name_from_controller: "UR5e",
430
- active: false,
431
- model_from_controller: "UniversalRobots_UR5e"
432
- }
433
- ],
434
- has_error: false,
435
- error_details: ""
436
- }
437
- ]
438
- };
439
- }
440
- },
441
- {
442
- method: "GET",
443
- path: "/cells/:cellId/controllers/:controllerId",
444
- handle() {
445
- return {
446
- configuration: {
447
- kind: "VirtualController",
448
- manufacturer: "universalrobots",
449
- type: "universalrobots-ur5e"
450
- },
451
- name: "mock-ur5"
452
- };
453
- }
454
- },
455
- {
456
- method: "GET",
457
- path: "/cells/:cellId/motion-groups/:motionGroupId/specification",
458
- handle() {
459
- return {
460
- dh_parameters: [
461
- {
462
- alpha: 1.5707963267948966,
463
- theta: 0,
464
- a: 0,
465
- d: 162.25,
466
- reverse_rotation_direction: false
467
- },
468
- {
469
- alpha: 0,
470
- theta: 0,
471
- a: -425,
472
- d: 0,
473
- reverse_rotation_direction: false
474
- },
475
- {
476
- alpha: 0,
477
- theta: 0,
478
- a: -392.2,
479
- d: 0,
480
- reverse_rotation_direction: false
481
- },
482
- {
483
- alpha: 1.5707963267948966,
484
- theta: 0,
485
- a: 0,
486
- d: 133.3,
487
- reverse_rotation_direction: false
488
- },
489
- {
490
- alpha: -1.5707963267948966,
491
- theta: 0,
492
- a: 0,
493
- d: 99.7,
494
- reverse_rotation_direction: false
495
- },
496
- {
497
- alpha: 0,
498
- theta: 0,
499
- a: 0,
500
- d: 99.6,
501
- reverse_rotation_direction: false
502
- }
503
- ],
504
- mechanical_joint_limits: [
505
- {
506
- joint: "JOINTNAME_AXIS_1",
507
- lower_limit: -6.335545063018799,
508
- upper_limit: 6.335545063018799,
509
- unlimited: false
510
- },
511
- {
512
- joint: "JOINTNAME_AXIS_2",
513
- lower_limit: -6.335545063018799,
514
- upper_limit: 6.335545063018799,
515
- unlimited: false
516
- },
517
- {
518
- joint: "JOINTNAME_AXIS_3",
519
- lower_limit: -6.335545063018799,
520
- upper_limit: 6.335545063018799,
521
- unlimited: false
522
- },
523
- {
524
- joint: "JOINTNAME_AXIS_4",
525
- lower_limit: -6.335545063018799,
526
- upper_limit: 6.335545063018799,
527
- unlimited: false
528
- },
529
- {
530
- joint: "JOINTNAME_AXIS_5",
531
- lower_limit: -6.335545063018799,
532
- upper_limit: 6.335545063018799,
533
- unlimited: false
534
- },
535
- {
536
- joint: "JOINTNAME_AXIS_6",
537
- lower_limit: -6.335545063018799,
538
- upper_limit: 6.335545063018799,
539
- unlimited: false
540
- }
541
- ]
542
- };
543
- }
544
- },
545
- {
546
- method: "GET",
547
- path: "/cells/:cellId/motion-groups/:motionGroupId/safety-setup",
548
- handle() {
549
- return {
550
- safety_settings: [
551
- {
552
- safety_state: "SAFETY_NORMAL",
553
- settings: {
554
- joint_position_limits: [
555
- {
556
- joint: "JOINTNAME_AXIS_1",
557
- lower_limit: -2.96705961227417,
558
- upper_limit: 2.96705961227417,
559
- unlimited: false
560
- },
561
- {
562
- joint: "JOINTNAME_AXIS_2",
563
- lower_limit: -1.7453292608261108,
564
- upper_limit: 2.7925267219543457,
565
- unlimited: false
566
- },
567
- {
568
- joint: "JOINTNAME_AXIS_3",
569
- lower_limit: -3.3161256313323975,
570
- upper_limit: 0.40142571926116943,
571
- unlimited: false
572
- },
573
- {
574
- joint: "JOINTNAME_AXIS_4",
575
- lower_limit: -3.4906585216522217,
576
- upper_limit: 3.4906585216522217,
577
- unlimited: false
578
- },
579
- {
580
- joint: "JOINTNAME_AXIS_5",
581
- lower_limit: -2.4434609413146973,
582
- upper_limit: 2.4434609413146973,
583
- unlimited: false
584
- },
585
- {
586
- joint: "JOINTNAME_AXIS_6",
587
- lower_limit: -4.71238899230957,
588
- upper_limit: 4.71238899230957,
589
- unlimited: false
590
- }
591
- ],
592
- joint_velocity_limits: [
593
- {
594
- joint: "JOINTNAME_AXIS_1",
595
- limit: 3.1415927410125732
596
- },
597
- {
598
- joint: "JOINTNAME_AXIS_2",
599
- limit: 3.1415927410125732
600
- },
601
- {
602
- joint: "JOINTNAME_AXIS_3",
603
- limit: 3.4906585216522217
604
- },
605
- {
606
- joint: "JOINTNAME_AXIS_4",
607
- limit: 6.108652591705322
608
- },
609
- {
610
- joint: "JOINTNAME_AXIS_5",
611
- limit: 6.108652591705322
612
- },
613
- {
614
- joint: "JOINTNAME_AXIS_6",
615
- limit: 6.981317043304443
616
- }
617
- ],
618
- joint_acceleration_limits: [],
619
- joint_torque_limits: [],
620
- tcp_velocity_limit: 1800
621
- }
622
- }
623
- ],
624
- safety_zones: [
625
- {
626
- id: 1,
627
- priority: 0,
628
- geometry: {
629
- compound: {
630
- child_geometries: [
631
- {
632
- convex_hull: {
633
- vertices: [
634
- { vertex: [-800, -1330, -1820] },
635
- { vertex: [1650, -1330, -1820] },
636
- { vertex: [1650, 1330, -1820] },
637
- { vertex: [-800, 1330, -1820] }
638
- ]
639
- },
640
- init_pose: {
641
- position: [0, 0, 0],
642
- orientation: [0, 0, 0, 1]
643
- },
644
- id: "box"
645
- },
646
- {
647
- convex_hull: {
648
- vertices: [
649
- {
650
- vertex: [-800, -1330, -1820]
651
- },
652
- {
653
- vertex: [1650, -1330, -1820]
654
- },
655
- {
656
- vertex: [1650, -1330, 1500]
657
- },
658
- {
659
- vertex: [-800, -1330, 1500]
660
- }
661
- ]
662
- },
663
- init_pose: {
664
- position: [0, 0, 0],
665
- orientation: [0, 0, 0, 1]
666
- },
667
- id: "box"
668
- },
669
- {
670
- convex_hull: {
671
- vertices: [
672
- {
673
- vertex: [-800, -1330, -1820]
674
- },
675
- {
676
- vertex: [-800, 1330, -1820]
677
- },
678
- {
679
- vertex: [-800, 1330, 1500]
680
- },
681
- {
682
- vertex: [-800, -1330, 1500]
683
- }
684
- ]
685
- },
686
- init_pose: {
687
- position: [0, 0, 0],
688
- orientation: [0, 0, 0, 1]
689
- },
690
- id: "box"
691
- },
692
- {
693
- convex_hull: {
694
- vertices: [
695
- {
696
- vertex: [1650, 1330, 1500]
697
- },
698
- {
699
- vertex: [-800, 1330, 1500]
700
- },
701
- {
702
- vertex: [-800, -1330, 1500]
703
- },
704
- {
705
- vertex: [1650, -1330, 1500]
706
- }
707
- ]
708
- },
709
- init_pose: {
710
- position: [0, 0, 0],
711
- orientation: [0, 0, 0, 1]
712
- },
713
- id: "box"
714
- },
715
- {
716
- convex_hull: {
717
- vertices: [
718
- {
719
- vertex: [1650, 1330, 1500]
720
- },
721
- {
722
- vertex: [-800, 1330, 1500]
723
- },
724
- {
725
- vertex: [-800, 1330, -1820]
726
- },
727
- {
728
- vertex: [1650, 1330, -1820]
729
- }
730
- ]
731
- },
732
- init_pose: {
733
- position: [0, 0, 0],
734
- orientation: [0, 0, 0, 1]
735
- },
736
- id: "box"
737
- },
738
- {
739
- convex_hull: {
740
- vertices: [
741
- {
742
- vertex: [1650, 1330, 1500]
743
- },
744
- {
745
- vertex: [1650, -1330, 1500]
746
- },
747
- {
748
- vertex: [1650, -1330, -1820]
749
- },
750
- {
751
- vertex: [1650, 1330, -1820]
752
- }
753
- ]
754
- },
755
- init_pose: {
756
- position: [0, 0, 0],
757
- orientation: [0, 0, 0, 1]
758
- },
759
- id: "box"
760
- }
761
- ]
762
- },
763
- init_pose: {
764
- position: [0, 0, 0],
765
- orientation: [0, 0, 0, 1]
766
- },
767
- id: "Cell workzone"
768
- },
769
- motion_group_uid: 1
770
- },
771
- {
772
- id: 2,
773
- priority: 0,
774
- geometry: {
775
- convex_hull: {
776
- vertices: [
777
- {
778
- vertex: [1650, 1330, -1850]
779
- },
780
- {
781
- vertex: [865, 1330, -1850]
782
- },
783
- {
784
- vertex: [865, -720, -1850]
785
- },
786
- {
787
- vertex: [1650, -720, -1850]
788
- },
789
- {
790
- vertex: [1650, 1330, -920]
791
- },
792
- {
793
- vertex: [865, 1330, -920]
794
- },
795
- {
796
- vertex: [865, -720, -920]
797
- },
798
- {
799
- vertex: [1650, -720, -920]
800
- }
801
- ]
802
- },
803
- init_pose: {
804
- position: [0, 0, 0],
805
- orientation: [0, 0, 0, 1]
806
- },
807
- id: "Transport"
808
- },
809
- motion_group_uid: 1
810
- },
811
- {
812
- id: 3,
813
- priority: 0,
814
- geometry: {
815
- convex_hull: {
816
- vertices: [
817
- {
818
- vertex: [1650, 1330, -600]
819
- },
820
- {
821
- vertex: [865, 1330, -600]
822
- },
823
- {
824
- vertex: [865, 430, -600]
825
- },
826
- {
827
- vertex: [1650, 430, -600]
828
- },
829
- {
830
- vertex: [1650, 1330, -1250]
831
- },
832
- {
833
- vertex: [865, 1330, -1250]
834
- },
835
- {
836
- vertex: [865, 430, -1250]
837
- },
838
- {
839
- vertex: [1650, 430, -1250]
840
- }
841
- ]
842
- },
843
- init_pose: {
844
- position: [0, 0, 0],
845
- orientation: [0, 0, 0, 1]
846
- },
847
- id: "Tunel"
848
- },
849
- motion_group_uid: 1
850
- },
851
- {
852
- id: 4,
853
- priority: 0,
854
- geometry: {
855
- convex_hull: {
856
- vertices: [
857
- {
858
- vertex: [1650, -760, -440]
859
- },
860
- {
861
- vertex: [900, -760, -440]
862
- },
863
- {
864
- vertex: [900, -1330, -440]
865
- },
866
- {
867
- vertex: [1650, -1330, -440]
868
- },
869
- {
870
- vertex: [1650, -760, -1800]
871
- },
872
- {
873
- vertex: [900, -760, -1800]
874
- },
875
- {
876
- vertex: [900, -1330, -1800]
877
- },
878
- {
879
- vertex: [1650, -1330, -1800]
880
- }
881
- ]
882
- },
883
- init_pose: {
884
- position: [0, 0, 0],
885
- orientation: [0, 0, 0, 1]
886
- },
887
- id: "Fanuc controller"
888
- },
889
- motion_group_uid: 1
890
- },
891
- {
892
- id: 6,
893
- priority: 0,
894
- geometry: {
895
- convex_hull: {
896
- vertices: [
897
- {
898
- vertex: [-200, -200, -1900]
899
- },
900
- {
901
- vertex: [200, -200, -1900]
902
- },
903
- {
904
- vertex: [200, 200, -1900]
905
- },
906
- {
907
- vertex: [-200, 200, -1900]
908
- },
909
- {
910
- vertex: [-200, -200, -350]
911
- },
912
- {
913
- vertex: [200, -200, -350]
914
- },
915
- {
916
- vertex: [200, 200, -350]
917
- },
918
- {
919
- vertex: [-200, 200, -350]
920
- }
921
- ]
922
- },
923
- init_pose: {
924
- position: [0, 0, 0],
925
- orientation: [0, 0, 0, 1]
926
- },
927
- id: "Robot base"
928
- },
929
- motion_group_uid: 1
930
- }
931
- ],
932
- robot_model_geometries: [
933
- {
934
- link_index: 1,
935
- geometry: {
936
- sphere: {
937
- radius: 270
938
- },
939
- init_pose: {
940
- position: [-70, -70, -50],
941
- orientation: [0, 0, 0, 1]
942
- },
943
- id: "link1_sphere"
944
- }
945
- },
946
- {
947
- link_index: 2,
948
- geometry: {
949
- capsule: {
950
- radius: 160,
951
- cylinder_height: 800
952
- },
953
- init_pose: {
954
- position: [-450, 40, 170],
955
- orientation: [0, -Math.SQRT1_2, 0, Math.SQRT1_2]
956
- },
957
- id: "link2_capsule"
958
- }
959
- },
960
- {
961
- link_index: 3,
962
- geometry: {
963
- sphere: {
964
- radius: 270
965
- },
966
- init_pose: {
967
- position: [-110, 10, -100],
968
- orientation: [0, 0, 0, 1]
969
- },
970
- id: "link3_sphere"
971
- }
972
- },
973
- {
974
- link_index: 4,
975
- geometry: {
976
- capsule: {
977
- radius: 110,
978
- cylinder_height: 600
979
- },
980
- init_pose: {
981
- position: [0, 300, 40],
982
- orientation: [-Math.SQRT1_2, 0, 0, Math.SQRT1_2]
983
- },
984
- id: "link4_capsule"
985
- }
986
- },
987
- {
988
- link_index: 5,
989
- geometry: {
990
- sphere: {
991
- radius: 75
992
- },
993
- init_pose: {
994
- position: [0, 0, -50],
995
- orientation: [0, 0, 0, 1]
996
- },
997
- id: "link5_sphere"
998
- }
999
- }
1000
- ],
1001
- tool_geometries: []
1002
- };
1003
- }
1004
- },
1005
- {
1006
- method: "GET",
1007
- path: "/cells/:cellId/coordinate-systems",
1008
- handle() {
1009
- return {
1010
- coordinatesystems: [
1011
- {
1012
- coordinate_system: "",
1013
- name: "world",
1014
- reference_uid: "",
1015
- position: [0, 0, 0],
1016
- rotation: {
1017
- angles: [0, 0, 0],
1018
- type: "ROTATION_VECTOR"
1019
- }
1020
- }
1021
- ]
1022
- };
1023
- }
1024
- },
1025
- {
1026
- method: "GET",
1027
- path: "/cells/:cellId/motion-groups/:motionGroupId/tcps",
1028
- handle() {
1029
- return {
1030
- tcps: [
1031
- {
1032
- id: "Flange",
1033
- readable_name: "Default-Flange",
1034
- position: [0, 0, 0],
1035
- rotation: {
1036
- angles: [0, 0, 0, 0],
1037
- type: "ROTATION_VECTOR"
1038
- }
1039
- },
1040
- {
1041
- id: "complex-tcp-position",
1042
- readable_name: "Complex TCP Position",
1043
- position: [-200, 300, 150],
1044
- rotation: {
1045
- angles: [
1046
- -0.12139440409113832,
1047
- -0.06356210998212003,
1048
- -0.2023240068185639,
1049
- 0
1050
- ],
1051
- type: "ROTATION_VECTOR"
1052
- }
1053
- }
1054
- ]
1055
- };
1056
- }
1057
- }
1058
- ];
1059
- const method = ((_a = config.method) == null ? void 0 : _a.toUpperCase()) || "GET";
1060
- const path = `/cells${(_c = (_b = config.url) == null ? void 0 : _b.split("/cells")[1]) == null ? void 0 : _c.split("?")[0]}`;
1061
- for (const handler of apiHandlers) {
1062
- const match2 = pathToRegexp.match(handler.path)(path || "");
1063
- if (method === handler.method && match2) {
1064
- const json = handler.handle();
1065
- return {
1066
- status: 200,
1067
- statusText: "Success",
1068
- data: JSON.stringify(json),
1069
- headers: {},
1070
- config,
1071
- request: {
1072
- responseURL: config.url
1073
- }
1074
- };
1075
- }
1076
- }
1077
- throw new import_axios2.AxiosError(
1078
- `No mock handler matched this request: ${method} ${path}`,
1079
- "404",
1080
- config
1081
- );
1082
- });
1083
- }
1084
- handleWebsocketConnection(socket) {
1085
- this.connections.push(socket);
1086
- setTimeout(() => {
1087
- socket.dispatchEvent(new Event("open"));
1088
- console.log("Websocket connection opened from", socket.url);
1089
- if (socket.url.includes("/state-stream")) {
1090
- socket.dispatchEvent(
1091
- new MessageEvent("message", {
1092
- data: JSON.stringify(defaultMotionState)
1093
- })
1094
- );
1095
- }
1096
- if (socket.url.includes("/move-joint")) {
1097
- socket.dispatchEvent(
1098
- new MessageEvent("message", {
1099
- data: JSON.stringify({
1100
- result: {
1101
- motion_group: "0@ur",
1102
- state: {
1103
- controller: "ur",
1104
- operation_mode: "OPERATION_MODE_AUTO",
1105
- safety_state: "SAFETY_STATE_NORMAL",
1106
- timestamp: "2024-09-18T12:48:26.096266444Z",
1107
- velocity_override: 100,
1108
- motion_groups: [
1109
- {
1110
- motion_group: "0@ur",
1111
- controller: "ur",
1112
- joint_position: {
1113
- joints: [
1114
- 1.3492152690887451,
1115
- -1.5659207105636597,
1116
- 1.6653711795806885,
1117
- -1.0991662740707397,
1118
- -1.829018235206604,
1119
- 1.264623761177063
1120
- ]
1121
- },
1122
- joint_velocity: {
1123
- joints: [0, 0, 0, 0, 0, 0]
1124
- },
1125
- flange_pose: {
1126
- position: [
1127
- 6.437331889439328,
1128
- -628.4123774830913,
1129
- 577.0569957147832
1130
- ],
1131
- orientation: {
1132
- x: -1.683333649797158,
1133
- y: -1.9783363827298732,
1134
- z: -0.4928031860165713
1135
- },
1136
- coordinate_system: ""
1137
- },
1138
- tcp_pose: {
1139
- position: [
1140
- 6.437331889439328,
1141
- -628.4123774830913,
1142
- 577.0569957147832
1143
- ],
1144
- orientation: {
1145
- x: -1.683333649797158,
1146
- y: -1.9783363827298732,
1147
- z: -0.4928031860165713
1148
- },
1149
- coordinate_system: "",
1150
- tcp: "Flange"
1151
- },
1152
- velocity: {
1153
- linear: {
1154
- x: 0,
1155
- y: 0,
1156
- z: 0
1157
- },
1158
- angular: {
1159
- x: -0,
1160
- y: 0,
1161
- z: 0
1162
- },
1163
- coordinate_system: ""
1164
- },
1165
- force: {
1166
- force: {
1167
- x: 0,
1168
- y: 0,
1169
- z: 0
1170
- },
1171
- moment: {
1172
- x: 0,
1173
- y: 0,
1174
- z: 0
1175
- },
1176
- coordinate_system: ""
1177
- },
1178
- joint_limit_reached: {
1179
- limit_reached: [
1180
- false,
1181
- false,
1182
- false,
1183
- false,
1184
- false,
1185
- false
1186
- ]
1187
- },
1188
- joint_current: {
1189
- joints: [0, 0, 0, 0, 0, 0]
1190
- },
1191
- sequence_number: "671259"
1192
- }
1193
- ],
1194
- sequence_number: "671259"
1195
- },
1196
- movement_state: "MOVEMENT_STATE_MOVING"
1197
- }
1198
- })
1199
- })
1200
- );
1201
- }
1202
- if (socket.url.includes("/move-tcp")) {
1203
- socket.dispatchEvent(
1204
- new MessageEvent("message", {
1205
- data: JSON.stringify({
1206
- result: {
1207
- motion_group: "0@ur",
1208
- state: {
1209
- controller: "ur",
1210
- operation_mode: "OPERATION_MODE_AUTO",
1211
- safety_state: "SAFETY_STATE_NORMAL",
1212
- timestamp: "2024-09-18T12:43:12.188335774Z",
1213
- velocity_override: 100,
1214
- motion_groups: [
1215
- {
1216
- motion_group: "0@ur",
1217
- controller: "ur",
1218
- joint_position: {
1219
- joints: [
1220
- 1.3352527618408203,
1221
- -1.5659207105636597,
1222
- 1.6653711795806885,
1223
- -1.110615611076355,
1224
- -1.829018235206604,
1225
- 1.264623761177063
1226
- ]
1227
- },
1228
- joint_velocity: {
1229
- joints: [0, 0, 0, 0, 0, 0]
1230
- },
1231
- flange_pose: {
1232
- position: [
1233
- -2.763015284002938,
1234
- -630.2151479701106,
1235
- 577.524509114342
1236
- ],
1237
- orientation: {
1238
- x: -1.704794877102097,
1239
- y: -1.9722372952861567,
1240
- z: -0.4852079204210754
1241
- },
1242
- coordinate_system: ""
1243
- },
1244
- tcp_pose: {
1245
- position: [
1246
- -2.763015284002938,
1247
- -630.2151479701106,
1248
- 577.524509114342
1249
- ],
1250
- orientation: {
1251
- x: -1.704794877102097,
1252
- y: -1.9722372952861567,
1253
- z: -0.4852079204210754
1254
- },
1255
- coordinate_system: "",
1256
- tcp: "Flange"
1257
- },
1258
- velocity: {
1259
- linear: {
1260
- x: 0,
1261
- y: 0,
1262
- z: 0
1263
- },
1264
- angular: {
1265
- x: -0,
1266
- y: 0,
1267
- z: 0
1268
- },
1269
- coordinate_system: ""
1270
- },
1271
- force: {
1272
- force: {
1273
- x: 0,
1274
- y: 0,
1275
- z: 0
1276
- },
1277
- moment: {
1278
- x: 0,
1279
- y: 0,
1280
- z: 0
1281
- },
1282
- coordinate_system: ""
1283
- },
1284
- joint_limit_reached: {
1285
- limit_reached: [
1286
- false,
1287
- false,
1288
- false,
1289
- false,
1290
- false,
1291
- false
1292
- ]
1293
- },
1294
- joint_current: {
1295
- joints: [0, 0, 0, 0, 0, 0]
1296
- },
1297
- sequence_number: "627897"
1298
- }
1299
- ],
1300
- sequence_number: "627897"
1301
- },
1302
- movement_state: "MOVEMENT_STATE_MOVING"
1303
- }
1304
- })
1305
- })
1306
- );
1307
- }
1308
- }, 10);
1309
- }
1310
- handleWebsocketMessage(socket, message) {
1311
- console.log(`Received message on ${socket.url}`, message);
1312
- }
1313
- };
1314
- var defaultMotionState = {
1315
- result: {
1316
- motion_group: "0@universalrobots-ur5e",
1317
- controller: "universalrobots-ur5e",
1318
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1319
- sequence_number: 1,
1320
- joint_position: {
1321
- joints: [
1322
- 1.1699999570846558,
1323
- -1.5700000524520874,
1324
- 1.3600000143051147,
1325
- 1.0299999713897705,
1326
- 1.2899999618530273,
1327
- 1.2799999713897705
1328
- ]
1329
- },
1330
- joint_limit_reached: {
1331
- limit_reached: [false, false, false, false, false, false]
1332
- },
1333
- standstill: false,
1334
- flange_pose: {
1335
- position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],
1336
- orientation: [
1337
- 1.7564919306270736,
1338
- -1.7542521568325058,
1339
- 0.7326972590614671
1340
- ]
1341
- },
1342
- tcp_pose: {
1343
- position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],
1344
- orientation: [
1345
- 1.7564919306270736,
1346
- -1.7542521568325058,
1347
- 0.7326972590614671
1348
- ]
1349
- }
1350
- }
88
+ constructor() {
89
+ this.connections = [];
90
+ }
91
+ async handleAPIRequest(config) {
92
+ const apiHandlers = [
93
+ {
94
+ method: "GET",
95
+ path: "/cells/:cellId/controllers",
96
+ handle() {
97
+ return { controllers: [{
98
+ controller: "mock-ur5e",
99
+ model_name: "UniversalRobots::Controller",
100
+ host: "mock-ur5e",
101
+ allow_software_install_on_controller: true,
102
+ motion_groups: [{
103
+ motion_group: "0@mock-ur5e",
104
+ name_from_controller: "UR5e",
105
+ active: false,
106
+ model_from_controller: "UniversalRobots_UR5e"
107
+ }],
108
+ has_error: false,
109
+ error_details: ""
110
+ }] };
111
+ }
112
+ },
113
+ {
114
+ method: "GET",
115
+ path: "/cells/:cellId/controllers/:controllerId",
116
+ handle() {
117
+ return {
118
+ configuration: {
119
+ kind: "VirtualController",
120
+ manufacturer: "universalrobots",
121
+ type: "universalrobots-ur5e"
122
+ },
123
+ name: "mock-ur5"
124
+ };
125
+ }
126
+ },
127
+ {
128
+ method: "GET",
129
+ path: "/cells/:cellId/motion-groups/:motionGroupId/specification",
130
+ handle() {
131
+ return {
132
+ dh_parameters: [
133
+ {
134
+ alpha: 1.5707963267948966,
135
+ theta: 0,
136
+ a: 0,
137
+ d: 162.25,
138
+ reverse_rotation_direction: false
139
+ },
140
+ {
141
+ alpha: 0,
142
+ theta: 0,
143
+ a: -425,
144
+ d: 0,
145
+ reverse_rotation_direction: false
146
+ },
147
+ {
148
+ alpha: 0,
149
+ theta: 0,
150
+ a: -392.2,
151
+ d: 0,
152
+ reverse_rotation_direction: false
153
+ },
154
+ {
155
+ alpha: 1.5707963267948966,
156
+ theta: 0,
157
+ a: 0,
158
+ d: 133.3,
159
+ reverse_rotation_direction: false
160
+ },
161
+ {
162
+ alpha: -1.5707963267948966,
163
+ theta: 0,
164
+ a: 0,
165
+ d: 99.7,
166
+ reverse_rotation_direction: false
167
+ },
168
+ {
169
+ alpha: 0,
170
+ theta: 0,
171
+ a: 0,
172
+ d: 99.6,
173
+ reverse_rotation_direction: false
174
+ }
175
+ ],
176
+ mechanical_joint_limits: [
177
+ {
178
+ joint: "JOINTNAME_AXIS_1",
179
+ lower_limit: -6.335545063018799,
180
+ upper_limit: 6.335545063018799,
181
+ unlimited: false
182
+ },
183
+ {
184
+ joint: "JOINTNAME_AXIS_2",
185
+ lower_limit: -6.335545063018799,
186
+ upper_limit: 6.335545063018799,
187
+ unlimited: false
188
+ },
189
+ {
190
+ joint: "JOINTNAME_AXIS_3",
191
+ lower_limit: -6.335545063018799,
192
+ upper_limit: 6.335545063018799,
193
+ unlimited: false
194
+ },
195
+ {
196
+ joint: "JOINTNAME_AXIS_4",
197
+ lower_limit: -6.335545063018799,
198
+ upper_limit: 6.335545063018799,
199
+ unlimited: false
200
+ },
201
+ {
202
+ joint: "JOINTNAME_AXIS_5",
203
+ lower_limit: -6.335545063018799,
204
+ upper_limit: 6.335545063018799,
205
+ unlimited: false
206
+ },
207
+ {
208
+ joint: "JOINTNAME_AXIS_6",
209
+ lower_limit: -6.335545063018799,
210
+ upper_limit: 6.335545063018799,
211
+ unlimited: false
212
+ }
213
+ ]
214
+ };
215
+ }
216
+ },
217
+ {
218
+ method: "GET",
219
+ path: "/cells/:cellId/motion-groups/:motionGroupId/safety-setup",
220
+ handle() {
221
+ return {
222
+ safety_settings: [{
223
+ safety_state: "SAFETY_NORMAL",
224
+ settings: {
225
+ joint_position_limits: [
226
+ {
227
+ joint: "JOINTNAME_AXIS_1",
228
+ lower_limit: -2.96705961227417,
229
+ upper_limit: 2.96705961227417,
230
+ unlimited: false
231
+ },
232
+ {
233
+ joint: "JOINTNAME_AXIS_2",
234
+ lower_limit: -1.7453292608261108,
235
+ upper_limit: 2.7925267219543457,
236
+ unlimited: false
237
+ },
238
+ {
239
+ joint: "JOINTNAME_AXIS_3",
240
+ lower_limit: -3.3161256313323975,
241
+ upper_limit: .40142571926116943,
242
+ unlimited: false
243
+ },
244
+ {
245
+ joint: "JOINTNAME_AXIS_4",
246
+ lower_limit: -3.4906585216522217,
247
+ upper_limit: 3.4906585216522217,
248
+ unlimited: false
249
+ },
250
+ {
251
+ joint: "JOINTNAME_AXIS_5",
252
+ lower_limit: -2.4434609413146973,
253
+ upper_limit: 2.4434609413146973,
254
+ unlimited: false
255
+ },
256
+ {
257
+ joint: "JOINTNAME_AXIS_6",
258
+ lower_limit: -4.71238899230957,
259
+ upper_limit: 4.71238899230957,
260
+ unlimited: false
261
+ }
262
+ ],
263
+ joint_velocity_limits: [
264
+ {
265
+ joint: "JOINTNAME_AXIS_1",
266
+ limit: 3.1415927410125732
267
+ },
268
+ {
269
+ joint: "JOINTNAME_AXIS_2",
270
+ limit: 3.1415927410125732
271
+ },
272
+ {
273
+ joint: "JOINTNAME_AXIS_3",
274
+ limit: 3.4906585216522217
275
+ },
276
+ {
277
+ joint: "JOINTNAME_AXIS_4",
278
+ limit: 6.108652591705322
279
+ },
280
+ {
281
+ joint: "JOINTNAME_AXIS_5",
282
+ limit: 6.108652591705322
283
+ },
284
+ {
285
+ joint: "JOINTNAME_AXIS_6",
286
+ limit: 6.981317043304443
287
+ }
288
+ ],
289
+ joint_acceleration_limits: [],
290
+ joint_torque_limits: [],
291
+ tcp_velocity_limit: 1800
292
+ }
293
+ }],
294
+ safety_zones: [
295
+ {
296
+ id: 1,
297
+ priority: 0,
298
+ geometry: {
299
+ compound: { child_geometries: [
300
+ {
301
+ convex_hull: { vertices: [
302
+ { vertex: [
303
+ -800,
304
+ -1330,
305
+ -1820
306
+ ] },
307
+ { vertex: [
308
+ 1650,
309
+ -1330,
310
+ -1820
311
+ ] },
312
+ { vertex: [
313
+ 1650,
314
+ 1330,
315
+ -1820
316
+ ] },
317
+ { vertex: [
318
+ -800,
319
+ 1330,
320
+ -1820
321
+ ] }
322
+ ] },
323
+ init_pose: {
324
+ position: [
325
+ 0,
326
+ 0,
327
+ 0
328
+ ],
329
+ orientation: [
330
+ 0,
331
+ 0,
332
+ 0,
333
+ 1
334
+ ]
335
+ },
336
+ id: "box"
337
+ },
338
+ {
339
+ convex_hull: { vertices: [
340
+ { vertex: [
341
+ -800,
342
+ -1330,
343
+ -1820
344
+ ] },
345
+ { vertex: [
346
+ 1650,
347
+ -1330,
348
+ -1820
349
+ ] },
350
+ { vertex: [
351
+ 1650,
352
+ -1330,
353
+ 1500
354
+ ] },
355
+ { vertex: [
356
+ -800,
357
+ -1330,
358
+ 1500
359
+ ] }
360
+ ] },
361
+ init_pose: {
362
+ position: [
363
+ 0,
364
+ 0,
365
+ 0
366
+ ],
367
+ orientation: [
368
+ 0,
369
+ 0,
370
+ 0,
371
+ 1
372
+ ]
373
+ },
374
+ id: "box"
375
+ },
376
+ {
377
+ convex_hull: { vertices: [
378
+ { vertex: [
379
+ -800,
380
+ -1330,
381
+ -1820
382
+ ] },
383
+ { vertex: [
384
+ -800,
385
+ 1330,
386
+ -1820
387
+ ] },
388
+ { vertex: [
389
+ -800,
390
+ 1330,
391
+ 1500
392
+ ] },
393
+ { vertex: [
394
+ -800,
395
+ -1330,
396
+ 1500
397
+ ] }
398
+ ] },
399
+ init_pose: {
400
+ position: [
401
+ 0,
402
+ 0,
403
+ 0
404
+ ],
405
+ orientation: [
406
+ 0,
407
+ 0,
408
+ 0,
409
+ 1
410
+ ]
411
+ },
412
+ id: "box"
413
+ },
414
+ {
415
+ convex_hull: { vertices: [
416
+ { vertex: [
417
+ 1650,
418
+ 1330,
419
+ 1500
420
+ ] },
421
+ { vertex: [
422
+ -800,
423
+ 1330,
424
+ 1500
425
+ ] },
426
+ { vertex: [
427
+ -800,
428
+ -1330,
429
+ 1500
430
+ ] },
431
+ { vertex: [
432
+ 1650,
433
+ -1330,
434
+ 1500
435
+ ] }
436
+ ] },
437
+ init_pose: {
438
+ position: [
439
+ 0,
440
+ 0,
441
+ 0
442
+ ],
443
+ orientation: [
444
+ 0,
445
+ 0,
446
+ 0,
447
+ 1
448
+ ]
449
+ },
450
+ id: "box"
451
+ },
452
+ {
453
+ convex_hull: { vertices: [
454
+ { vertex: [
455
+ 1650,
456
+ 1330,
457
+ 1500
458
+ ] },
459
+ { vertex: [
460
+ -800,
461
+ 1330,
462
+ 1500
463
+ ] },
464
+ { vertex: [
465
+ -800,
466
+ 1330,
467
+ -1820
468
+ ] },
469
+ { vertex: [
470
+ 1650,
471
+ 1330,
472
+ -1820
473
+ ] }
474
+ ] },
475
+ init_pose: {
476
+ position: [
477
+ 0,
478
+ 0,
479
+ 0
480
+ ],
481
+ orientation: [
482
+ 0,
483
+ 0,
484
+ 0,
485
+ 1
486
+ ]
487
+ },
488
+ id: "box"
489
+ },
490
+ {
491
+ convex_hull: { vertices: [
492
+ { vertex: [
493
+ 1650,
494
+ 1330,
495
+ 1500
496
+ ] },
497
+ { vertex: [
498
+ 1650,
499
+ -1330,
500
+ 1500
501
+ ] },
502
+ { vertex: [
503
+ 1650,
504
+ -1330,
505
+ -1820
506
+ ] },
507
+ { vertex: [
508
+ 1650,
509
+ 1330,
510
+ -1820
511
+ ] }
512
+ ] },
513
+ init_pose: {
514
+ position: [
515
+ 0,
516
+ 0,
517
+ 0
518
+ ],
519
+ orientation: [
520
+ 0,
521
+ 0,
522
+ 0,
523
+ 1
524
+ ]
525
+ },
526
+ id: "box"
527
+ }
528
+ ] },
529
+ init_pose: {
530
+ position: [
531
+ 0,
532
+ 0,
533
+ 0
534
+ ],
535
+ orientation: [
536
+ 0,
537
+ 0,
538
+ 0,
539
+ 1
540
+ ]
541
+ },
542
+ id: "Cell workzone"
543
+ },
544
+ motion_group_uid: 1
545
+ },
546
+ {
547
+ id: 2,
548
+ priority: 0,
549
+ geometry: {
550
+ convex_hull: { vertices: [
551
+ { vertex: [
552
+ 1650,
553
+ 1330,
554
+ -1850
555
+ ] },
556
+ { vertex: [
557
+ 865,
558
+ 1330,
559
+ -1850
560
+ ] },
561
+ { vertex: [
562
+ 865,
563
+ -720,
564
+ -1850
565
+ ] },
566
+ { vertex: [
567
+ 1650,
568
+ -720,
569
+ -1850
570
+ ] },
571
+ { vertex: [
572
+ 1650,
573
+ 1330,
574
+ -920
575
+ ] },
576
+ { vertex: [
577
+ 865,
578
+ 1330,
579
+ -920
580
+ ] },
581
+ { vertex: [
582
+ 865,
583
+ -720,
584
+ -920
585
+ ] },
586
+ { vertex: [
587
+ 1650,
588
+ -720,
589
+ -920
590
+ ] }
591
+ ] },
592
+ init_pose: {
593
+ position: [
594
+ 0,
595
+ 0,
596
+ 0
597
+ ],
598
+ orientation: [
599
+ 0,
600
+ 0,
601
+ 0,
602
+ 1
603
+ ]
604
+ },
605
+ id: "Transport"
606
+ },
607
+ motion_group_uid: 1
608
+ },
609
+ {
610
+ id: 3,
611
+ priority: 0,
612
+ geometry: {
613
+ convex_hull: { vertices: [
614
+ { vertex: [
615
+ 1650,
616
+ 1330,
617
+ -600
618
+ ] },
619
+ { vertex: [
620
+ 865,
621
+ 1330,
622
+ -600
623
+ ] },
624
+ { vertex: [
625
+ 865,
626
+ 430,
627
+ -600
628
+ ] },
629
+ { vertex: [
630
+ 1650,
631
+ 430,
632
+ -600
633
+ ] },
634
+ { vertex: [
635
+ 1650,
636
+ 1330,
637
+ -1250
638
+ ] },
639
+ { vertex: [
640
+ 865,
641
+ 1330,
642
+ -1250
643
+ ] },
644
+ { vertex: [
645
+ 865,
646
+ 430,
647
+ -1250
648
+ ] },
649
+ { vertex: [
650
+ 1650,
651
+ 430,
652
+ -1250
653
+ ] }
654
+ ] },
655
+ init_pose: {
656
+ position: [
657
+ 0,
658
+ 0,
659
+ 0
660
+ ],
661
+ orientation: [
662
+ 0,
663
+ 0,
664
+ 0,
665
+ 1
666
+ ]
667
+ },
668
+ id: "Tunel"
669
+ },
670
+ motion_group_uid: 1
671
+ },
672
+ {
673
+ id: 4,
674
+ priority: 0,
675
+ geometry: {
676
+ convex_hull: { vertices: [
677
+ { vertex: [
678
+ 1650,
679
+ -760,
680
+ -440
681
+ ] },
682
+ { vertex: [
683
+ 900,
684
+ -760,
685
+ -440
686
+ ] },
687
+ { vertex: [
688
+ 900,
689
+ -1330,
690
+ -440
691
+ ] },
692
+ { vertex: [
693
+ 1650,
694
+ -1330,
695
+ -440
696
+ ] },
697
+ { vertex: [
698
+ 1650,
699
+ -760,
700
+ -1800
701
+ ] },
702
+ { vertex: [
703
+ 900,
704
+ -760,
705
+ -1800
706
+ ] },
707
+ { vertex: [
708
+ 900,
709
+ -1330,
710
+ -1800
711
+ ] },
712
+ { vertex: [
713
+ 1650,
714
+ -1330,
715
+ -1800
716
+ ] }
717
+ ] },
718
+ init_pose: {
719
+ position: [
720
+ 0,
721
+ 0,
722
+ 0
723
+ ],
724
+ orientation: [
725
+ 0,
726
+ 0,
727
+ 0,
728
+ 1
729
+ ]
730
+ },
731
+ id: "Fanuc controller"
732
+ },
733
+ motion_group_uid: 1
734
+ },
735
+ {
736
+ id: 6,
737
+ priority: 0,
738
+ geometry: {
739
+ convex_hull: { vertices: [
740
+ { vertex: [
741
+ -200,
742
+ -200,
743
+ -1900
744
+ ] },
745
+ { vertex: [
746
+ 200,
747
+ -200,
748
+ -1900
749
+ ] },
750
+ { vertex: [
751
+ 200,
752
+ 200,
753
+ -1900
754
+ ] },
755
+ { vertex: [
756
+ -200,
757
+ 200,
758
+ -1900
759
+ ] },
760
+ { vertex: [
761
+ -200,
762
+ -200,
763
+ -350
764
+ ] },
765
+ { vertex: [
766
+ 200,
767
+ -200,
768
+ -350
769
+ ] },
770
+ { vertex: [
771
+ 200,
772
+ 200,
773
+ -350
774
+ ] },
775
+ { vertex: [
776
+ -200,
777
+ 200,
778
+ -350
779
+ ] }
780
+ ] },
781
+ init_pose: {
782
+ position: [
783
+ 0,
784
+ 0,
785
+ 0
786
+ ],
787
+ orientation: [
788
+ 0,
789
+ 0,
790
+ 0,
791
+ 1
792
+ ]
793
+ },
794
+ id: "Robot base"
795
+ },
796
+ motion_group_uid: 1
797
+ }
798
+ ],
799
+ robot_model_geometries: [
800
+ {
801
+ link_index: 1,
802
+ geometry: {
803
+ sphere: { radius: 270 },
804
+ init_pose: {
805
+ position: [
806
+ -70,
807
+ -70,
808
+ -50
809
+ ],
810
+ orientation: [
811
+ 0,
812
+ 0,
813
+ 0,
814
+ 1
815
+ ]
816
+ },
817
+ id: "link1_sphere"
818
+ }
819
+ },
820
+ {
821
+ link_index: 2,
822
+ geometry: {
823
+ capsule: {
824
+ radius: 160,
825
+ cylinder_height: 800
826
+ },
827
+ init_pose: {
828
+ position: [
829
+ -450,
830
+ 40,
831
+ 170
832
+ ],
833
+ orientation: [
834
+ 0,
835
+ -Math.SQRT1_2,
836
+ 0,
837
+ Math.SQRT1_2
838
+ ]
839
+ },
840
+ id: "link2_capsule"
841
+ }
842
+ },
843
+ {
844
+ link_index: 3,
845
+ geometry: {
846
+ sphere: { radius: 270 },
847
+ init_pose: {
848
+ position: [
849
+ -110,
850
+ 10,
851
+ -100
852
+ ],
853
+ orientation: [
854
+ 0,
855
+ 0,
856
+ 0,
857
+ 1
858
+ ]
859
+ },
860
+ id: "link3_sphere"
861
+ }
862
+ },
863
+ {
864
+ link_index: 4,
865
+ geometry: {
866
+ capsule: {
867
+ radius: 110,
868
+ cylinder_height: 600
869
+ },
870
+ init_pose: {
871
+ position: [
872
+ 0,
873
+ 300,
874
+ 40
875
+ ],
876
+ orientation: [
877
+ -Math.SQRT1_2,
878
+ 0,
879
+ 0,
880
+ Math.SQRT1_2
881
+ ]
882
+ },
883
+ id: "link4_capsule"
884
+ }
885
+ },
886
+ {
887
+ link_index: 5,
888
+ geometry: {
889
+ sphere: { radius: 75 },
890
+ init_pose: {
891
+ position: [
892
+ 0,
893
+ 0,
894
+ -50
895
+ ],
896
+ orientation: [
897
+ 0,
898
+ 0,
899
+ 0,
900
+ 1
901
+ ]
902
+ },
903
+ id: "link5_sphere"
904
+ }
905
+ }
906
+ ],
907
+ tool_geometries: []
908
+ };
909
+ }
910
+ },
911
+ {
912
+ method: "GET",
913
+ path: "/cells/:cellId/coordinate-systems",
914
+ handle() {
915
+ return { coordinatesystems: [{
916
+ coordinate_system: "",
917
+ name: "world",
918
+ reference_uid: "",
919
+ position: [
920
+ 0,
921
+ 0,
922
+ 0
923
+ ],
924
+ rotation: {
925
+ angles: [
926
+ 0,
927
+ 0,
928
+ 0
929
+ ],
930
+ type: "ROTATION_VECTOR"
931
+ }
932
+ }] };
933
+ }
934
+ },
935
+ {
936
+ method: "GET",
937
+ path: "/cells/:cellId/motion-groups/:motionGroupId/tcps",
938
+ handle() {
939
+ return { tcps: [{
940
+ id: "Flange",
941
+ readable_name: "Default-Flange",
942
+ position: [
943
+ 0,
944
+ 0,
945
+ 0
946
+ ],
947
+ rotation: {
948
+ angles: [
949
+ 0,
950
+ 0,
951
+ 0,
952
+ 0
953
+ ],
954
+ type: "ROTATION_VECTOR"
955
+ }
956
+ }, {
957
+ id: "complex-tcp-position",
958
+ readable_name: "Complex TCP Position",
959
+ position: [
960
+ -200,
961
+ 300,
962
+ 150
963
+ ],
964
+ rotation: {
965
+ angles: [
966
+ -.12139440409113832,
967
+ -.06356210998212003,
968
+ -.2023240068185639,
969
+ 0
970
+ ],
971
+ type: "ROTATION_VECTOR"
972
+ }
973
+ }] };
974
+ }
975
+ }
976
+ ];
977
+ const method = config.method?.toUpperCase() || "GET";
978
+ const path = `/cells${config.url?.split("/cells")[1]?.split("?")[0]}`;
979
+ for (const handler of apiHandlers) {
980
+ const match = path_to_regexp.match(handler.path)(path || "");
981
+ if (method === handler.method && match) {
982
+ const json = handler.handle();
983
+ return {
984
+ status: 200,
985
+ statusText: "Success",
986
+ data: JSON.stringify(json),
987
+ headers: {},
988
+ config,
989
+ request: { responseURL: config.url }
990
+ };
991
+ }
992
+ }
993
+ throw new axios.AxiosError(`No mock handler matched this request: ${method} ${path}`, "404", config);
994
+ }
995
+ handleWebsocketConnection(socket) {
996
+ this.connections.push(socket);
997
+ setTimeout(() => {
998
+ socket.dispatchEvent(new Event("open"));
999
+ console.log("Websocket connection opened from", socket.url);
1000
+ if (socket.url.includes("/state-stream")) socket.dispatchEvent(new MessageEvent("message", { data: JSON.stringify(defaultMotionState) }));
1001
+ if (socket.url.includes("/move-joint")) socket.dispatchEvent(new MessageEvent("message", { data: JSON.stringify({ result: {
1002
+ motion_group: "0@ur",
1003
+ state: {
1004
+ controller: "ur",
1005
+ operation_mode: "OPERATION_MODE_AUTO",
1006
+ safety_state: "SAFETY_STATE_NORMAL",
1007
+ timestamp: "2024-09-18T12:48:26.096266444Z",
1008
+ velocity_override: 100,
1009
+ motion_groups: [{
1010
+ motion_group: "0@ur",
1011
+ controller: "ur",
1012
+ joint_position: [
1013
+ 1.3492152690887451,
1014
+ -1.5659207105636597,
1015
+ 1.6653711795806885,
1016
+ -1.0991662740707397,
1017
+ -1.829018235206604,
1018
+ 1.264623761177063
1019
+ ],
1020
+ joint_velocity: { joints: [
1021
+ 0,
1022
+ 0,
1023
+ 0,
1024
+ 0,
1025
+ 0,
1026
+ 0
1027
+ ] },
1028
+ flange_pose: {
1029
+ position: [
1030
+ 6.437331889439328,
1031
+ -628.4123774830913,
1032
+ 577.0569957147832
1033
+ ],
1034
+ orientation: {
1035
+ x: -1.683333649797158,
1036
+ y: -1.9783363827298732,
1037
+ z: -.4928031860165713
1038
+ },
1039
+ coordinate_system: ""
1040
+ },
1041
+ tcp_pose: {
1042
+ position: [
1043
+ 6.437331889439328,
1044
+ -628.4123774830913,
1045
+ 577.0569957147832
1046
+ ],
1047
+ orientation: {
1048
+ x: -1.683333649797158,
1049
+ y: -1.9783363827298732,
1050
+ z: -.4928031860165713
1051
+ },
1052
+ coordinate_system: "",
1053
+ tcp: "Flange"
1054
+ },
1055
+ velocity: {
1056
+ linear: {
1057
+ x: 0,
1058
+ y: 0,
1059
+ z: 0
1060
+ },
1061
+ angular: {
1062
+ x: -0,
1063
+ y: 0,
1064
+ z: 0
1065
+ },
1066
+ coordinate_system: ""
1067
+ },
1068
+ force: {
1069
+ force: {
1070
+ x: 0,
1071
+ y: 0,
1072
+ z: 0
1073
+ },
1074
+ moment: {
1075
+ x: 0,
1076
+ y: 0,
1077
+ z: 0
1078
+ },
1079
+ coordinate_system: ""
1080
+ },
1081
+ joint_limit_reached: { limit_reached: [
1082
+ false,
1083
+ false,
1084
+ false,
1085
+ false,
1086
+ false,
1087
+ false
1088
+ ] },
1089
+ joint_current: { joints: [
1090
+ 0,
1091
+ 0,
1092
+ 0,
1093
+ 0,
1094
+ 0,
1095
+ 0
1096
+ ] },
1097
+ sequence_number: "671259"
1098
+ }],
1099
+ sequence_number: "671259"
1100
+ },
1101
+ movement_state: "MOVEMENT_STATE_MOVING"
1102
+ } }) }));
1103
+ if (socket.url.includes("/move-tcp")) socket.dispatchEvent(new MessageEvent("message", { data: JSON.stringify({ result: {
1104
+ motion_group: "0@ur",
1105
+ state: {
1106
+ controller: "ur",
1107
+ operation_mode: "OPERATION_MODE_AUTO",
1108
+ safety_state: "SAFETY_STATE_NORMAL",
1109
+ timestamp: "2024-09-18T12:43:12.188335774Z",
1110
+ velocity_override: 100,
1111
+ motion_groups: [{
1112
+ motion_group: "0@ur",
1113
+ controller: "ur",
1114
+ joint_position: { joints: [
1115
+ 1.3352527618408203,
1116
+ -1.5659207105636597,
1117
+ 1.6653711795806885,
1118
+ -1.110615611076355,
1119
+ -1.829018235206604,
1120
+ 1.264623761177063
1121
+ ] },
1122
+ joint_velocity: { joints: [
1123
+ 0,
1124
+ 0,
1125
+ 0,
1126
+ 0,
1127
+ 0,
1128
+ 0
1129
+ ] },
1130
+ flange_pose: {
1131
+ position: [
1132
+ -2.763015284002938,
1133
+ -630.2151479701106,
1134
+ 577.524509114342
1135
+ ],
1136
+ orientation: {
1137
+ x: -1.704794877102097,
1138
+ y: -1.9722372952861567,
1139
+ z: -.4852079204210754
1140
+ },
1141
+ coordinate_system: ""
1142
+ },
1143
+ tcp_pose: {
1144
+ position: [
1145
+ -2.763015284002938,
1146
+ -630.2151479701106,
1147
+ 577.524509114342
1148
+ ],
1149
+ orientation: {
1150
+ x: -1.704794877102097,
1151
+ y: -1.9722372952861567,
1152
+ z: -.4852079204210754
1153
+ },
1154
+ coordinate_system: "",
1155
+ tcp: "Flange"
1156
+ },
1157
+ velocity: {
1158
+ linear: {
1159
+ x: 0,
1160
+ y: 0,
1161
+ z: 0
1162
+ },
1163
+ angular: {
1164
+ x: -0,
1165
+ y: 0,
1166
+ z: 0
1167
+ },
1168
+ coordinate_system: ""
1169
+ },
1170
+ force: {
1171
+ force: {
1172
+ x: 0,
1173
+ y: 0,
1174
+ z: 0
1175
+ },
1176
+ moment: {
1177
+ x: 0,
1178
+ y: 0,
1179
+ z: 0
1180
+ },
1181
+ coordinate_system: ""
1182
+ },
1183
+ joint_limit_reached: { limit_reached: [
1184
+ false,
1185
+ false,
1186
+ false,
1187
+ false,
1188
+ false,
1189
+ false
1190
+ ] },
1191
+ joint_current: { joints: [
1192
+ 0,
1193
+ 0,
1194
+ 0,
1195
+ 0,
1196
+ 0,
1197
+ 0
1198
+ ] },
1199
+ sequence_number: "627897"
1200
+ }],
1201
+ sequence_number: "627897"
1202
+ },
1203
+ movement_state: "MOVEMENT_STATE_MOVING"
1204
+ } }) }));
1205
+ }, 10);
1206
+ }
1207
+ handleWebsocketMessage(socket, message) {
1208
+ console.log(`Received message on ${socket.url}`, message);
1209
+ }
1351
1210
  };
1211
+ const defaultMotionState = { result: {
1212
+ motion_group: "0@universalrobots-ur5e",
1213
+ controller: "universalrobots-ur5e",
1214
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1215
+ sequence_number: 1,
1216
+ joint_position: [
1217
+ 1.1699999570846558,
1218
+ -1.5700000524520874,
1219
+ 1.3600000143051147,
1220
+ 1.0299999713897705,
1221
+ 1.2899999618530273,
1222
+ 1.2799999713897705
1223
+ ],
1224
+ joint_limit_reached: { limit_reached: [
1225
+ false,
1226
+ false,
1227
+ false,
1228
+ false,
1229
+ false,
1230
+ false
1231
+ ] },
1232
+ standstill: false,
1233
+ flange_pose: {
1234
+ position: [
1235
+ 1.3300010259703043,
1236
+ -409.2680714682808,
1237
+ 531.0203477065281
1238
+ ],
1239
+ orientation: [
1240
+ 1.7564919306270736,
1241
+ -1.7542521568325058,
1242
+ .7326972590614671
1243
+ ]
1244
+ },
1245
+ tcp_pose: {
1246
+ position: [
1247
+ 1.3300010259703043,
1248
+ -409.2680714682808,
1249
+ 531.0203477065281
1250
+ ],
1251
+ orientation: [
1252
+ 1.7564919306270736,
1253
+ -1.7542521568325058,
1254
+ .7326972590614671
1255
+ ]
1256
+ }
1257
+ } };
1352
1258
 
1353
- // src/lib/v2/NovaClient.ts
1259
+ //#endregion
1260
+ //#region src/lib/v2/NovaClient.ts
1261
+ /**
1262
+ * EXPERIMENTAL
1263
+ *
1264
+ * This client provides a starting point to migrate NOVA api v2.
1265
+ * As v2 is still in development, this client has to be considered unstable
1266
+ *
1267
+ * Client for connecting to a Nova instance and controlling robots.
1268
+ */
1354
1269
  var NovaClient = class {
1355
- constructor(config) {
1356
- this.authPromise = null;
1357
- this.accessToken = null;
1358
- var _a;
1359
- console.warn("Using experimental NOVA v2 client");
1360
- const cellId = (_a = config.cellId) != null ? _a : "cell";
1361
- this.config = __spreadValues({
1362
- cellId
1363
- }, config);
1364
- this.accessToken = config.accessToken || availableStorage.getString("wbjs.access_token") || null;
1365
- if (this.config.instanceUrl === "https://mock.example.com") {
1366
- this.mock = new MockNovaInstance();
1367
- }
1368
- const axiosInstance = import_axios3.default.create({
1369
- baseURL: (0, import_url_join.default)(this.config.instanceUrl, "/api/v2"),
1370
- // TODO - backend needs to set proper CORS headers for this
1371
- headers: typeof window !== "undefined" && window.location.origin.includes("localhost") ? {} : {
1372
- // Identify the client to the backend for logging purposes
1373
- "X-Wandelbots-Client": "Wandelbots-Nova-JS-SDK"
1374
- }
1375
- });
1376
- axiosInstance.interceptors.request.use((request) => __async(this, null, function* () {
1377
- if (!request.headers.Authorization) {
1378
- if (this.accessToken) {
1379
- request.headers.Authorization = `Bearer ${this.accessToken}`;
1380
- } else if (this.config.username && this.config.password) {
1381
- request.headers.Authorization = `Basic ${btoa(`${config.username}:${config.password}`)}`;
1382
- }
1383
- }
1384
- return request;
1385
- }));
1386
- if (typeof window !== "undefined") {
1387
- axiosInstance.interceptors.response.use(
1388
- (r) => r,
1389
- (error) => __async(this, null, function* () {
1390
- var _a2, _b;
1391
- if ((0, import_axios3.isAxiosError)(error)) {
1392
- if (((_a2 = error.response) == null ? void 0 : _a2.status) === 401) {
1393
- try {
1394
- yield this.renewAuthentication();
1395
- if (error.config) {
1396
- if (this.accessToken) {
1397
- error.config.headers.Authorization = `Bearer ${this.accessToken}`;
1398
- } else {
1399
- delete error.config.headers.Authorization;
1400
- }
1401
- return axiosInstance.request(error.config);
1402
- }
1403
- } catch (err) {
1404
- return Promise.reject(err);
1405
- }
1406
- } else if (((_b = error.response) == null ? void 0 : _b.status) === 503) {
1407
- const res = yield fetch(window.location.href);
1408
- if (res.status === 503) {
1409
- window.location.reload();
1410
- }
1411
- }
1412
- }
1413
- return Promise.reject(error);
1414
- })
1415
- );
1416
- }
1417
- this.api = new NovaCellAPIClient(cellId, __spreadProps(__spreadValues({}, config), {
1418
- basePath: (0, import_url_join.default)(this.config.instanceUrl, "/api/v1"),
1419
- isJsonMime: (mime) => {
1420
- return mime === "application/json";
1421
- },
1422
- baseOptions: __spreadValues(__spreadValues({}, this.mock ? {
1423
- adapter: (config2) => {
1424
- return this.mock.handleAPIRequest(config2);
1425
- }
1426
- } : {}), config.baseOptions),
1427
- axiosInstance
1428
- }));
1429
- }
1430
- renewAuthentication() {
1431
- return __async(this, null, function* () {
1432
- if (this.authPromise) {
1433
- return;
1434
- }
1435
- this.authPromise = loginWithAuth0(this.config.instanceUrl);
1436
- try {
1437
- this.accessToken = yield this.authPromise;
1438
- if (this.accessToken) {
1439
- availableStorage.setString("wbjs.access_token", this.accessToken);
1440
- } else {
1441
- availableStorage.delete("wbjs.access_token");
1442
- }
1443
- } finally {
1444
- this.authPromise = null;
1445
- }
1446
- });
1447
- }
1448
- makeWebsocketURL(path) {
1449
- const url = new URL(
1450
- (0, import_url_join.default)(
1451
- this.config.instanceUrl,
1452
- `/api/v1/cells/${this.config.cellId}`,
1453
- path
1454
- )
1455
- );
1456
- url.protocol = url.protocol.replace("http", "ws");
1457
- url.protocol = url.protocol.replace("https", "wss");
1458
- if (this.accessToken) {
1459
- url.searchParams.append("token", this.accessToken);
1460
- } else if (this.config.username && this.config.password) {
1461
- url.username = this.config.username;
1462
- url.password = this.config.password;
1463
- }
1464
- return url.toString();
1465
- }
1466
- /**
1467
- * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.
1468
- * If you explicitly want to reconnect an existing websocket, call `reconnect`
1469
- * on the returned object.
1470
- */
1471
- openReconnectingWebsocket(path) {
1472
- return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {
1473
- mock: this.mock
1474
- });
1475
- }
1270
+ constructor(config) {
1271
+ this.authPromise = null;
1272
+ this.accessToken = null;
1273
+ console.warn("Using experimental NOVA v2 client");
1274
+ const cellId = config.cellId ?? "cell";
1275
+ this.config = {
1276
+ cellId,
1277
+ ...config
1278
+ };
1279
+ this.accessToken = config.accessToken || require_LoginWithAuth0.availableStorage.getString("wbjs.access_token") || null;
1280
+ if (this.config.instanceUrl === "https://mock.example.com") this.mock = new MockNovaInstance();
1281
+ const axiosInstance = axios.default.create({
1282
+ baseURL: (0, url_join.default)(this.config.instanceUrl, "/api/v2"),
1283
+ headers: typeof window !== "undefined" && window.location.origin.includes("localhost") ? {} : { "X-Wandelbots-Client": "Wandelbots-Nova-JS-SDK" }
1284
+ });
1285
+ axiosInstance.interceptors.request.use(async (request) => {
1286
+ if (!request.headers.Authorization) {
1287
+ if (this.accessToken) request.headers.Authorization = `Bearer ${this.accessToken}`;
1288
+ else if (this.config.username && this.config.password) request.headers.Authorization = `Basic ${btoa(`${config.username}:${config.password}`)}`;
1289
+ }
1290
+ return request;
1291
+ });
1292
+ if (typeof window !== "undefined") axiosInstance.interceptors.response.use((r) => r, async (error) => {
1293
+ if ((0, axios.isAxiosError)(error)) {
1294
+ if (error.response?.status === 401) try {
1295
+ await this.renewAuthentication();
1296
+ if (error.config) {
1297
+ if (this.accessToken) error.config.headers.Authorization = `Bearer ${this.accessToken}`;
1298
+ else delete error.config.headers.Authorization;
1299
+ return axiosInstance.request(error.config);
1300
+ }
1301
+ } catch (err) {
1302
+ return Promise.reject(err);
1303
+ }
1304
+ else if (error.response?.status === 503) {
1305
+ if ((await fetch(window.location.href)).status === 503) window.location.reload();
1306
+ }
1307
+ }
1308
+ return Promise.reject(error);
1309
+ });
1310
+ this.api = new NovaCellAPIClient(cellId, {
1311
+ ...config,
1312
+ basePath: (0, url_join.default)(this.config.instanceUrl, "/api/v1"),
1313
+ isJsonMime: (mime) => {
1314
+ return mime === "application/json";
1315
+ },
1316
+ baseOptions: {
1317
+ ...this.mock ? { adapter: (config$1) => {
1318
+ return this.mock.handleAPIRequest(config$1);
1319
+ } } : {},
1320
+ ...config.baseOptions
1321
+ },
1322
+ axiosInstance
1323
+ });
1324
+ }
1325
+ async renewAuthentication() {
1326
+ if (this.authPromise) return;
1327
+ this.authPromise = require_LoginWithAuth0.loginWithAuth0(this.config.instanceUrl);
1328
+ try {
1329
+ this.accessToken = await this.authPromise;
1330
+ if (this.accessToken) require_LoginWithAuth0.availableStorage.setString("wbjs.access_token", this.accessToken);
1331
+ else require_LoginWithAuth0.availableStorage.delete("wbjs.access_token");
1332
+ } finally {
1333
+ this.authPromise = null;
1334
+ }
1335
+ }
1336
+ makeWebsocketURL(path) {
1337
+ const url = new URL((0, url_join.default)(this.config.instanceUrl, `/api/v1/cells/${this.config.cellId}`, path));
1338
+ url.protocol = url.protocol.replace("http", "ws");
1339
+ url.protocol = url.protocol.replace("https", "wss");
1340
+ if (this.accessToken) url.searchParams.append("token", this.accessToken);
1341
+ else if (this.config.username && this.config.password) {
1342
+ url.username = this.config.username;
1343
+ url.password = this.config.password;
1344
+ }
1345
+ return url.toString();
1346
+ }
1347
+ /**
1348
+ * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.
1349
+ * If you explicitly want to reconnect an existing websocket, call `reconnect`
1350
+ * on the returned object.
1351
+ */
1352
+ openReconnectingWebsocket(path) {
1353
+ return new require_LoginWithAuth0.AutoReconnectingWebsocket(this.makeWebsocketURL(path), { mock: this.mock });
1354
+ }
1476
1355
  };
1477
- // Annotate the CommonJS export names for ESM import in node:
1478
- 0 && (module.exports = {
1479
- NovaCellAPIClient,
1480
- NovaClient,
1481
- ...require("@wandelbots/nova-api/v2")
1356
+
1357
+ //#endregion
1358
+ exports.NovaCellAPIClient = NovaCellAPIClient;
1359
+ exports.NovaClient = NovaClient;
1360
+ Object.keys(__wandelbots_nova_api_v2).forEach(function (k) {
1361
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1362
+ enumerable: true,
1363
+ get: function () { return __wandelbots_nova_api_v2[k]; }
1364
+ });
1482
1365
  });
1366
+
1483
1367
  //# sourceMappingURL=index.cjs.map