@wandelbots/nova-js 3.5.4 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AutoReconnectingWebsocket-By6EZkXv.d.mts → AutoReconnectingWebsocket-BgMrjNxO.d.mts} +1 -2
- package/dist/AutoReconnectingWebsocket-BgMrjNxO.d.mts.map +1 -0
- package/dist/{AutoReconnectingWebsocket-dO-Xkvgo.d.cts → AutoReconnectingWebsocket-COmdtugu.d.cts} +1 -2
- package/dist/AutoReconnectingWebsocket-COmdtugu.d.cts.map +1 -0
- package/dist/{LoginWithAuth0-BAGhME4k.mjs → LoginWithAuth0-CEUVGw1-.mjs} +2 -6
- package/dist/{LoginWithAuth0-BAGhME4k.mjs.map → LoginWithAuth0-CEUVGw1-.mjs.map} +1 -1
- package/dist/{LoginWithAuth0-qpkGkrJo.cjs → LoginWithAuth0-DHgYqs1M.cjs} +84 -93
- package/dist/{LoginWithAuth0-qpkGkrJo.cjs.map → LoginWithAuth0-DHgYqs1M.cjs.map} +1 -1
- package/dist/{NovaClient-CZDpg0Pn.d.cts → NovaClient-36BPI1Yp.d.cts} +4 -7
- package/dist/NovaClient-36BPI1Yp.d.cts.map +1 -0
- package/dist/{NovaClient-D8C3LxqM.d.mts → NovaClient-BabUDOEg.d.mts} +4 -7
- package/dist/NovaClient-BabUDOEg.d.mts.map +1 -0
- package/dist/{NovaClient-DImFdEQS.mjs → NovaClient-D9uLoAgV.mjs} +5 -13
- package/dist/NovaClient-D9uLoAgV.mjs.map +1 -0
- package/dist/{NovaClient-CKpbwv53.cjs → NovaClient-Db0vg1kb.cjs} +35 -43
- package/dist/NovaClient-Db0vg1kb.cjs.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/dist/lib/v1/index.cjs +17 -17
- package/dist/lib/v1/index.cjs.map +1 -1
- package/dist/lib/v1/index.d.cts +3 -3
- package/dist/lib/v1/index.d.cts.map +1 -1
- package/dist/lib/v1/index.d.mts +3 -3
- package/dist/lib/v1/index.d.mts.map +1 -1
- package/dist/lib/v1/index.mjs +11 -14
- package/dist/lib/v1/index.mjs.map +1 -1
- package/dist/lib/v2/index.cjs +13 -20
- package/dist/lib/v2/index.cjs.map +1 -1
- package/dist/lib/v2/index.d.cts +1 -1
- package/dist/lib/v2/index.d.cts.map +1 -1
- package/dist/lib/v2/index.d.mts +1 -1
- package/dist/lib/v2/index.d.mts.map +1 -1
- package/dist/lib/v2/index.mjs +7 -17
- package/dist/lib/v2/index.mjs.map +1 -1
- package/package.json +19 -14
- package/src/lib/v2/mock/MockNovaInstance.ts +1 -0
- package/dist/AutoReconnectingWebsocket-By6EZkXv.d.mts.map +0 -1
- package/dist/AutoReconnectingWebsocket-dO-Xkvgo.d.cts.map +0 -1
- package/dist/NovaClient-CKpbwv53.cjs.map +0 -1
- package/dist/NovaClient-CZDpg0Pn.d.cts.map +0 -1
- package/dist/NovaClient-D8C3LxqM.d.mts.map +0 -1
- package/dist/NovaClient-DImFdEQS.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/lib/v1/getLatestTrajectories.ts","../../../src/lib/v1/ProgramStateConnection.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/lib/v1/getLatestTrajectories.ts","../../../src/lib/v1/ProgramStateConnection.ts"],"mappings":";;;;;;iBAKsB,qBAAA,CACpB,SAAA,EAAW,iBAAA,EACX,UAAA,WACA,yBAAA,YACC,OAAA,CAAQ,qBAAA;;;KCAC,qBAAA;EACV,SAAA;EACA,OAAA;EACA,KAAA;AAAA;AAAA,aAGU,YAAA;EACV,UAAA;EACA,OAAA;EACA,OAAA;EACA,MAAA;EACA,SAAA;AAAA;AAAA,KAGU,cAAA;EACV,EAAA;EACA,YAAA;EACA,KAAA,GAAQ,YAAA;AAAA;AAAA,KAGL,mBAAA;EACH,IAAA;EACA,MAAA;IACE,EAAA;IACA,KAAA,EAAO,YAAA;IACP,UAAA;IACA,cAAA;EAAA;AAAA;;;;;cAQS,sBAAA;EAAA,SASU,IAAA,EAAM,UAAA;EAR3B,cAAA,EAAgB,cAAA;EAChB,IAAA,EAAM,qBAAA;EAEN,cAAA;EACA,iCAAA;EAEA,kBAAA,EAAoB,yBAAA;cAEC,IAAA,EAAM,UAAA;EAhC3B;EAmDM,yBAAA,CAA0B,GAAA,EAAK,mBAAA,GAAmB,OAAA;EAnD/C;EA0IT,aAAA,CAAA;EAOM,cAAA,CACJ,YAAA,UACA,aAAA;IAAA,CAAmB,GAAA,WAAc,eAAA;EAAA,GACjC,WAAA,GAAc,sBAAA,GAAsB,OAAA;EA8DhC,WAAA,CAAA,GAAW,OAAA;EAmBjB,KAAA,CAAA;EAIA,GAAA,CAAI,OAAA;EAQJ,QAAA,CAAS,OAAA;AAAA"}
|
package/dist/lib/v1/index.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { u as tryParseJson } from "../../LoginWithAuth0-
|
|
2
|
-
import { a as ConnectedMotionGroup, i as JoggerConnection, n as NovaCellAPIClient, o as poseToWandelscriptString, r as MotionStreamConnection, t as NovaClient } from "../../NovaClient-
|
|
1
|
+
import { u as tryParseJson } from "../../LoginWithAuth0-CEUVGw1-.mjs";
|
|
2
|
+
import { a as ConnectedMotionGroup, i as JoggerConnection, n as NovaCellAPIClient, o as poseToWandelscriptString, r as MotionStreamConnection, t as NovaClient } from "../../NovaClient-D9uLoAgV.mjs";
|
|
3
3
|
import { AxiosError } from "axios";
|
|
4
4
|
import { makeAutoObservable, runInAction } from "mobx";
|
|
5
|
-
|
|
6
|
-
export * from "@wandelbots/nova-api/v1"
|
|
7
|
-
|
|
5
|
+
export * from "@wandelbots/nova-api/v1";
|
|
8
6
|
//#region src/lib/v1/getLatestTrajectories.ts
|
|
9
7
|
let lastMotionIds = /* @__PURE__ */ new Set();
|
|
10
8
|
async function getLatestTrajectories(apiClient, sampleTime = 50, responsesCoordinateSystem) {
|
|
@@ -23,16 +21,15 @@ async function getLatestTrajectories(apiClient, sampleTime = 50, responsesCoordi
|
|
|
23
21
|
}
|
|
24
22
|
return newTrajectories;
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
//#endregion
|
|
28
25
|
//#region src/lib/v1/ProgramStateConnection.ts
|
|
29
|
-
let ProgramState = /* @__PURE__ */ function(ProgramState
|
|
30
|
-
ProgramState
|
|
31
|
-
ProgramState
|
|
32
|
-
ProgramState
|
|
33
|
-
ProgramState
|
|
34
|
-
ProgramState
|
|
35
|
-
return ProgramState
|
|
26
|
+
let ProgramState = /* @__PURE__ */ function(ProgramState) {
|
|
27
|
+
ProgramState["NotStarted"] = "not started";
|
|
28
|
+
ProgramState["Running"] = "running";
|
|
29
|
+
ProgramState["Stopped"] = "stopped";
|
|
30
|
+
ProgramState["Failed"] = "failed";
|
|
31
|
+
ProgramState["Completed"] = "completed";
|
|
32
|
+
return ProgramState;
|
|
36
33
|
}({});
|
|
37
34
|
/**
|
|
38
35
|
* Interface for running Wandelscript programs on the Nova instance and
|
|
@@ -176,7 +173,7 @@ var ProgramStateConnection = class {
|
|
|
176
173
|
});
|
|
177
174
|
}
|
|
178
175
|
};
|
|
179
|
-
|
|
180
176
|
//#endregion
|
|
181
177
|
export { ConnectedMotionGroup, JoggerConnection, MotionStreamConnection, NovaCellAPIClient, NovaClient, ProgramState, ProgramStateConnection, getLatestTrajectories, poseToWandelscriptString };
|
|
178
|
+
|
|
182
179
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/lib/v1/getLatestTrajectories.ts","../../../src/lib/v1/ProgramStateConnection.ts"],"sourcesContent":["import type { GetTrajectoryResponse } from \"@wandelbots/nova-api/v1\"\nimport type { NovaCellAPIClient } from \"./NovaCellAPIClient\"\n\nlet lastMotionIds: Set<string> = new Set()\n\nexport async function getLatestTrajectories(\n apiClient: NovaCellAPIClient,\n sampleTime: number = 50,\n responsesCoordinateSystem?: string,\n): Promise<GetTrajectoryResponse[]> {\n const newTrajectories: GetTrajectoryResponse[] = []\n\n try {\n const motions = await apiClient.motion.listMotions()\n const currentMotionIds = new Set(motions.motions)\n\n const newMotionIds = Array.from(currentMotionIds).filter(\n (id) => !lastMotionIds.has(id),\n )\n\n for (const motionId of newMotionIds) {\n const trajectory = await apiClient.motion.getMotionTrajectory(\n motionId,\n sampleTime,\n responsesCoordinateSystem,\n )\n newTrajectories.push(trajectory)\n }\n\n lastMotionIds = currentMotionIds\n } catch (error) {\n console.error(\"Failed to get latest trajectories:\", error)\n }\n\n return newTrajectories\n}\n","/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type { CollectionValue } from \"@wandelbots/nova-api/v1\"\nimport { AxiosError } from \"axios\"\nimport { makeAutoObservable, runInAction } from \"mobx\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport type { MotionStreamConnection } from \"./MotionStreamConnection\"\nimport type { NovaClient } from \"./NovaClient\"\n\nexport type ProgramRunnerLogEntry = {\n timestamp: number\n message: string\n level?: \"warn\" | \"error\"\n}\n\nexport enum ProgramState {\n NotStarted = \"not started\",\n Running = \"running\",\n Stopped = \"stopped\",\n Failed = \"failed\",\n Completed = \"completed\",\n}\n\nexport type CurrentProgram = {\n id?: string\n wandelscript?: string\n state?: ProgramState\n}\n\ntype ProgramStateMessage = {\n type: string\n runner: {\n id: string\n state: ProgramState\n start_time?: number | null\n execution_time?: number | null\n }\n}\n\n/**\n * Interface for running Wandelscript programs on the Nova instance and\n * tracking their progress and output\n */\nexport class ProgramStateConnection {\n currentProgram: CurrentProgram = {}\n logs: ProgramRunnerLogEntry[] = []\n\n executionState = \"idle\" as \"idle\" | \"starting\" | \"executing\" | \"stopping\"\n currentlyExecutingProgramRunnerId = null as string | null\n\n programStateSocket: AutoReconnectingWebsocket\n\n constructor(readonly nova: NovaClient) {\n makeAutoObservable(this, {}, { autoBind: true })\n\n this.programStateSocket = nova.openReconnectingWebsocket(`/programs/state`)\n\n this.programStateSocket.addEventListener(\"message\", (ev) => {\n const msg = tryParseJson(ev.data)\n\n if (!msg) {\n console.error(\"Failed to parse program state message\", ev.data)\n return\n }\n if (msg.type === \"update\") {\n this.handleProgramStateMessage(msg)\n }\n })\n }\n\n /** Handle a program state update from the backend */\n async handleProgramStateMessage(msg: ProgramStateMessage) {\n const { runner } = msg\n\n // Ignoring other programs for now\n // TODO - show if execution state is busy from another source\n if (runner.id !== this.currentlyExecutingProgramRunnerId) return\n\n if (runner.state === ProgramState.Failed) {\n try {\n const runnerState = await this.nova.api.program.getProgramRunner(\n runner.id,\n )\n\n // TODO - wandelengine should send print statements in real time over\n // websocket as well, rather than at the end\n const stdout = runnerState.stdout\n if (stdout) {\n this.log(stdout)\n }\n this.logError(\n `Program runner ${runner.id} failed with error: ${runnerState.error}\\n${runnerState.traceback}`,\n )\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.currentProgram.state = ProgramState.Failed\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Stopped) {\n try {\n const runnerState = await this.nova.api.program.getProgramRunner(\n runner.id,\n )\n\n const stdout = runnerState.stdout\n if (stdout) {\n this.log(stdout)\n }\n\n this.currentProgram.state = ProgramState.Stopped\n this.log(`Program runner ${runner.id} stopped`)\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Completed) {\n try {\n const runnerState = await this.nova.api.program.getProgramRunner(\n runner.id,\n )\n\n const stdout = runnerState.stdout\n if (stdout) {\n this.log(stdout)\n }\n this.log(\n `Program runner ${runner.id} finished successfully in ${runner.execution_time?.toFixed(2)} seconds`,\n )\n\n this.currentProgram.state = ProgramState.Completed\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Running) {\n this.currentProgram.state = ProgramState.Running\n this.log(`Program runner ${runner.id} now running`)\n } else if (runner.state !== ProgramState.NotStarted) {\n console.error(runner)\n this.logError(\n `Program runner ${runner.id} entered unexpected state: ${runner.state}`,\n )\n this.currentProgram.state = ProgramState.NotStarted\n this.gotoIdleState()\n }\n }\n\n /** Call when a program is no longer executing */\n gotoIdleState() {\n runInAction(() => {\n this.executionState = \"idle\"\n })\n this.currentlyExecutingProgramRunnerId = null\n }\n\n async executeProgram(\n wandelscript: string,\n initial_state?: { [key: string]: CollectionValue },\n activeRobot?: MotionStreamConnection,\n ) {\n this.currentProgram = {\n wandelscript: wandelscript,\n state: ProgramState.NotStarted,\n }\n\n const { currentProgram: openProgram } = this\n if (!openProgram) return\n runInAction(() => {\n this.executionState = \"starting\"\n })\n\n // Jogging can cause program execution to fail for some time after\n // So we need to explicitly stop jogging before running a program\n if (activeRobot) {\n try {\n await this.nova.api.motionGroupJogging.stopJogging(\n activeRobot.motionGroupId,\n )\n } catch (err) {\n console.error(err)\n }\n }\n\n // WOS-1539: Wandelengine parser currently breaks if there are empty lines with indentation\n const trimmedCode = openProgram.wandelscript!.replaceAll(/^\\s*$/gm, \"\")\n\n try {\n const programRunnerRef = await this.nova.api.program.createProgramRunner(\n {\n code: trimmedCode,\n initial_state: initial_state,\n // @ts-expect-error legacy code - check if param still used\n default_robot: activeRobot?.wandelscriptIdentifier,\n },\n {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n )\n\n this.log(`Created program runner ${programRunnerRef.id}\"`)\n runInAction(() => {\n this.executionState = \"executing\"\n })\n this.currentlyExecutingProgramRunnerId = programRunnerRef.id\n } catch (error) {\n if (error instanceof AxiosError && error.response && error.request) {\n this.logError(\n `${error.response.status} ${error.response.statusText} from ${error.response.config.url} ${JSON.stringify(error.response.data)}`,\n )\n } else {\n this.logError(JSON.stringify(error))\n }\n runInAction(() => {\n this.executionState = \"idle\"\n })\n }\n }\n\n async stopProgram() {\n if (!this.currentlyExecutingProgramRunnerId) return\n runInAction(() => {\n this.executionState = \"stopping\"\n })\n\n try {\n await this.nova.api.program.stopProgramRunner(\n this.currentlyExecutingProgramRunnerId,\n )\n } catch (err) {\n // Reactivate the stop button so user can try again\n runInAction(() => {\n this.executionState = \"executing\"\n })\n throw err\n }\n }\n\n reset() {\n this.currentProgram = {}\n }\n\n log(message: string) {\n console.log(message)\n this.logs.push({\n timestamp: Date.now(),\n message,\n })\n }\n\n logError(message: string) {\n console.log(message)\n this.logs.push({\n timestamp: Date.now(),\n message,\n level: \"error\",\n })\n }\n}\n"],"mappings":";;;;;;;;AAGA,IAAI,gCAA6B,IAAI,KAAK;AAE1C,eAAsB,sBACpB,WACA,aAAqB,IACrB,2BACkC;CAClC,MAAM,kBAA2C,EAAE;AAEnD,KAAI;EACF,MAAM,UAAU,MAAM,UAAU,OAAO,aAAa;EACpD,MAAM,mBAAmB,IAAI,IAAI,QAAQ,QAAQ;EAEjD,MAAM,eAAe,MAAM,KAAK,iBAAiB,CAAC,QAC/C,OAAO,CAAC,cAAc,IAAI,GAAG,CAC/B;AAED,OAAK,MAAM,YAAY,cAAc;GACnC,MAAM,aAAa,MAAM,UAAU,OAAO,oBACxC,UACA,YACA,0BACD;AACD,mBAAgB,KAAK,WAAW;;AAGlC,kBAAgB;UACT,OAAO;AACd,UAAQ,MAAM,sCAAsC,MAAM;;AAG5D,QAAO;;;;;ACnBT,IAAY,wDAAL;AACL;AACA;AACA;AACA;AACA;;;;;;;AAuBF,IAAa,yBAAb,MAAoC;CASlC,YAAY,AAAS,MAAkB;EAAlB;wBARY,EAAE;cACH,EAAE;wBAEjB;2CACmB;AAKlC,qBAAmB,MAAM,EAAE,EAAE,E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SAAS,WAAW,QAAQ,MAAM,SAAS,OAAO,IAAI,GAAG,KAAK,UAAU,MAAM,SAAS,KAAK,GAC/H;OAED,MAAK,SAAS,KAAK,UAAU,MAAM,CAAC;AAEtC,qBAAkB;AAChB,SAAK,iBAAiB;KACtB;;;CAIN,MAAM,cAAc;AAClB,MAAI,CAAC,KAAK,kCAAmC;AAC7C,oBAAkB;AAChB,QAAK,iBAAiB;IACtB;AAEF,MAAI;AACF,SAAM,KAAK,KAAK,IAAI,QAAQ,kBAC1B,KAAK,kCACN;WACM,KAAK;AAEZ,qBAAkB;AAChB,SAAK,iBAAiB;KACtB;AACF,SAAM;;;CAIV,QAAQ;AACN,OAAK,iBAAiB,EAAE;;CAG1B,IAAI,SAAiB;AACnB,UAAQ,IAAI,QAAQ;AACpB,OAAK,KAAK,KAAK;GACb,WAAW,KAAK,KAAK;GACrB;GACD,CAAC;;CAGJ,SAAS,SAAiB;AACxB,UAAQ,IAAI,QAAQ;AACpB,OAAK,KAAK,KAAK;GACb,WAAW,KAAK,KAAK;GACrB;GACA,OAAO;GACR,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/lib/v1/getLatestTrajectories.ts","../../../src/lib/v1/ProgramStateConnection.ts"],"sourcesContent":["import type { GetTrajectoryResponse } from \"@wandelbots/nova-api/v1\"\nimport type { NovaCellAPIClient } from \"./NovaCellAPIClient\"\n\nlet lastMotionIds: Set<string> = new Set()\n\nexport async function getLatestTrajectories(\n apiClient: NovaCellAPIClient,\n sampleTime: number = 50,\n responsesCoordinateSystem?: string,\n): Promise<GetTrajectoryResponse[]> {\n const newTrajectories: GetTrajectoryResponse[] = []\n\n try {\n const motions = await apiClient.motion.listMotions()\n const currentMotionIds = new Set(motions.motions)\n\n const newMotionIds = Array.from(currentMotionIds).filter(\n (id) => !lastMotionIds.has(id),\n )\n\n for (const motionId of newMotionIds) {\n const trajectory = await apiClient.motion.getMotionTrajectory(\n motionId,\n sampleTime,\n responsesCoordinateSystem,\n )\n newTrajectories.push(trajectory)\n }\n\n lastMotionIds = currentMotionIds\n } catch (error) {\n console.error(\"Failed to get latest trajectories:\", error)\n }\n\n return newTrajectories\n}\n","/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type { CollectionValue } from \"@wandelbots/nova-api/v1\"\nimport { AxiosError } from \"axios\"\nimport { makeAutoObservable, runInAction } from \"mobx\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport type { MotionStreamConnection } from \"./MotionStreamConnection\"\nimport type { NovaClient } from \"./NovaClient\"\n\nexport type ProgramRunnerLogEntry = {\n timestamp: number\n message: string\n level?: \"warn\" | \"error\"\n}\n\nexport enum ProgramState {\n NotStarted = \"not started\",\n Running = \"running\",\n Stopped = \"stopped\",\n Failed = \"failed\",\n Completed = \"completed\",\n}\n\nexport type CurrentProgram = {\n id?: string\n wandelscript?: string\n state?: ProgramState\n}\n\ntype ProgramStateMessage = {\n type: string\n runner: {\n id: string\n state: ProgramState\n start_time?: number | null\n execution_time?: number | null\n }\n}\n\n/**\n * Interface for running Wandelscript programs on the Nova instance and\n * tracking their progress and output\n */\nexport class ProgramStateConnection {\n currentProgram: CurrentProgram = {}\n logs: ProgramRunnerLogEntry[] = []\n\n executionState = \"idle\" as \"idle\" | \"starting\" | \"executing\" | \"stopping\"\n currentlyExecutingProgramRunnerId = null as string | null\n\n programStateSocket: AutoReconnectingWebsocket\n\n constructor(readonly nova: NovaClient) {\n makeAutoObservable(this, {}, { autoBind: true })\n\n this.programStateSocket = nova.openReconnectingWebsocket(`/programs/state`)\n\n this.programStateSocket.addEventListener(\"message\", (ev) => {\n const msg = tryParseJson(ev.data)\n\n if (!msg) {\n console.error(\"Failed to parse program state message\", ev.data)\n return\n }\n if (msg.type === \"update\") {\n this.handleProgramStateMessage(msg)\n }\n })\n }\n\n /** Handle a program state update from the backend */\n async handleProgramStateMessage(msg: ProgramStateMessage) {\n const { runner } = msg\n\n // Ignoring other programs for now\n // TODO - show if execution state is busy from another source\n if (runner.id !== this.currentlyExecutingProgramRunnerId) return\n\n if (runner.state === ProgramState.Failed) {\n try {\n const runnerState = await this.nova.api.program.getProgramRunner(\n runner.id,\n )\n\n // TODO - wandelengine should send print statements in real time over\n // websocket as well, rather than at the end\n const stdout = runnerState.stdout\n if (stdout) {\n this.log(stdout)\n }\n this.logError(\n `Program runner ${runner.id} failed with error: ${runnerState.error}\\n${runnerState.traceback}`,\n )\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.currentProgram.state = ProgramState.Failed\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Stopped) {\n try {\n const runnerState = await this.nova.api.program.getProgramRunner(\n runner.id,\n )\n\n const stdout = runnerState.stdout\n if (stdout) {\n this.log(stdout)\n }\n\n this.currentProgram.state = ProgramState.Stopped\n this.log(`Program runner ${runner.id} stopped`)\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Completed) {\n try {\n const runnerState = await this.nova.api.program.getProgramRunner(\n runner.id,\n )\n\n const stdout = runnerState.stdout\n if (stdout) {\n this.log(stdout)\n }\n this.log(\n `Program runner ${runner.id} finished successfully in ${runner.execution_time?.toFixed(2)} seconds`,\n )\n\n this.currentProgram.state = ProgramState.Completed\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Running) {\n this.currentProgram.state = ProgramState.Running\n this.log(`Program runner ${runner.id} now running`)\n } else if (runner.state !== ProgramState.NotStarted) {\n console.error(runner)\n this.logError(\n `Program runner ${runner.id} entered unexpected state: ${runner.state}`,\n )\n this.currentProgram.state = ProgramState.NotStarted\n this.gotoIdleState()\n }\n }\n\n /** Call when a program is no longer executing */\n gotoIdleState() {\n runInAction(() => {\n this.executionState = \"idle\"\n })\n this.currentlyExecutingProgramRunnerId = null\n }\n\n async executeProgram(\n wandelscript: string,\n initial_state?: { [key: string]: CollectionValue },\n activeRobot?: MotionStreamConnection,\n ) {\n this.currentProgram = {\n wandelscript: wandelscript,\n state: ProgramState.NotStarted,\n }\n\n const { currentProgram: openProgram } = this\n if (!openProgram) return\n runInAction(() => {\n this.executionState = \"starting\"\n })\n\n // Jogging can cause program execution to fail for some time after\n // So we need to explicitly stop jogging before running a program\n if (activeRobot) {\n try {\n await this.nova.api.motionGroupJogging.stopJogging(\n activeRobot.motionGroupId,\n )\n } catch (err) {\n console.error(err)\n }\n }\n\n // WOS-1539: Wandelengine parser currently breaks if there are empty lines with indentation\n const trimmedCode = openProgram.wandelscript!.replaceAll(/^\\s*$/gm, \"\")\n\n try {\n const programRunnerRef = await this.nova.api.program.createProgramRunner(\n {\n code: trimmedCode,\n initial_state: initial_state,\n // @ts-expect-error legacy code - check if param still used\n default_robot: activeRobot?.wandelscriptIdentifier,\n },\n {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n )\n\n this.log(`Created program runner ${programRunnerRef.id}\"`)\n runInAction(() => {\n this.executionState = \"executing\"\n })\n this.currentlyExecutingProgramRunnerId = programRunnerRef.id\n } catch (error) {\n if (error instanceof AxiosError && error.response && error.request) {\n this.logError(\n `${error.response.status} ${error.response.statusText} from ${error.response.config.url} ${JSON.stringify(error.response.data)}`,\n )\n } else {\n this.logError(JSON.stringify(error))\n }\n runInAction(() => {\n this.executionState = \"idle\"\n })\n }\n }\n\n async stopProgram() {\n if (!this.currentlyExecutingProgramRunnerId) return\n runInAction(() => {\n this.executionState = \"stopping\"\n })\n\n try {\n await this.nova.api.program.stopProgramRunner(\n this.currentlyExecutingProgramRunnerId,\n )\n } catch (err) {\n // Reactivate the stop button so user can try again\n runInAction(() => {\n this.executionState = \"executing\"\n })\n throw err\n }\n }\n\n reset() {\n this.currentProgram = {}\n }\n\n log(message: string) {\n console.log(message)\n this.logs.push({\n timestamp: Date.now(),\n message,\n })\n }\n\n logError(message: string) {\n console.log(message)\n this.logs.push({\n timestamp: Date.now(),\n message,\n level: \"error\",\n })\n }\n}\n"],"mappings":";;;;;;AAGA,IAAI,gCAA6B,IAAI,KAAK;AAE1C,eAAsB,sBACpB,WACA,aAAqB,IACrB,2BACkC;CAClC,MAAM,kBAA2C,EAAE;AAEnD,KAAI;EACF,MAAM,UAAU,MAAM,UAAU,OAAO,aAAa;EACpD,MAAM,mBAAmB,IAAI,IAAI,QAAQ,QAAQ;EAEjD,MAAM,eAAe,MAAM,KAAK,iBAAiB,CAAC,QAC/C,OAAO,CAAC,cAAc,IAAI,GAAG,CAC/B;AAED,OAAK,MAAM,YAAY,cAAc;GACnC,MAAM,aAAa,MAAM,UAAU,OAAO,oBACxC,UACA,YACA,0BACD;AACD,mBAAgB,KAAK,WAAW;;AAGlC,kBAAgB;UACT,OAAO;AACd,UAAQ,MAAM,sCAAsC,MAAM;;AAG5D,QAAO;;;;ACnBT,IAAY,eAAL,yBAAA,cAAA;AACL,cAAA,gBAAA;AACA,cAAA,aAAA;AACA,cAAA,aAAA;AACA,cAAA,YAAA;AACA,cAAA,eAAA;;KACD;;;;;AAsBD,IAAa,yBAAb,MAAoC;CASlC,YAAY,MAA2B;AAAlB,OAAA,OAAA;wBARY,EAAE;cACH,EAAE;wBAEjB;2CACmB;AAKlC,qBAAmB,MAAM,EAAE,EAAE,EAAE,UAAU,MAAM,CAAC;AAEhD,OAAK,qBAAqB,KAAK,0BAA0B,kBAAkB;AAE3E,OAAK,mBAAmB,iBAAiB,YAAY,OAAO;GAC1D,MAAM,MAAM,aAAa,GAAG,KAAK;AAEjC,OAAI,CAAC,KAAK;AACR,YAAQ,MAAM,yCAAyC,GAAG,KAAK;AAC/D;;AAEF,OAAI,IAAI,SAAS,SACf,MAAK,0BAA0B,IAAI;IAErC;;;CAIJ,MAAM,0BAA0B,KAA0B;EACxD,MAAM,EAAE,WAAW;AAInB,MAAI,OAAO,OAAO,KAAK,k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AChB,SAAK,iBAAiB;KACtB;AACF,SAAM;;;CAIV,QAAQ;AACN,OAAK,iBAAiB,EAAE;;CAG1B,IAAI,SAAiB;AACnB,UAAQ,IAAI,QAAQ;AACpB,OAAK,KAAK,KAAK;GACb,WAAW,KAAK,KAAK;GACrB;GACD,CAAC;;CAGJ,SAAS,SAAiB;AACxB,UAAQ,IAAI,QAAQ;AACpB,OAAK,KAAK,KAAK;GACb,WAAW,KAAK,KAAK;GACrB;GACA,OAAO;GACR,CAAC"}
|
package/dist/lib/v2/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_LoginWithAuth0 = require("../../LoginWithAuth0-DHgYqs1M.cjs");
|
|
2
3
|
let axios = require("axios");
|
|
3
4
|
axios = require_LoginWithAuth0.__toESM(axios);
|
|
4
5
|
let url_join = require("url-join");
|
|
@@ -6,7 +7,6 @@ url_join = require_LoginWithAuth0.__toESM(url_join);
|
|
|
6
7
|
let path_to_regexp = require("path-to-regexp");
|
|
7
8
|
path_to_regexp = require_LoginWithAuth0.__toESM(path_to_regexp);
|
|
8
9
|
let _wandelbots_nova_api_v2 = require("@wandelbots/nova-api/v2");
|
|
9
|
-
|
|
10
10
|
//#region src/lib/v2/NovaCellAPIClient.ts
|
|
11
11
|
/**
|
|
12
12
|
* API client providing type-safe access to all the Nova API REST endpoints
|
|
@@ -76,7 +76,6 @@ var NovaCellAPIClient = class {
|
|
|
76
76
|
return apiClient;
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
|
|
80
79
|
//#endregion
|
|
81
80
|
//#region src/lib/v2/mock/getCurrentRobotControllerState.ts
|
|
82
81
|
const getCurrentRobotControllerState = {
|
|
@@ -154,7 +153,6 @@ const getCurrentRobotControllerState = {
|
|
|
154
153
|
};
|
|
155
154
|
}
|
|
156
155
|
};
|
|
157
|
-
|
|
158
156
|
//#endregion
|
|
159
157
|
//#region src/lib/v2/mock/getMotionGroupDescription.ts
|
|
160
158
|
const getMotionGroupDescription = {
|
|
@@ -466,7 +464,6 @@ const getMotionGroupDescription = {
|
|
|
466
464
|
};
|
|
467
465
|
}
|
|
468
466
|
};
|
|
469
|
-
|
|
470
467
|
//#endregion
|
|
471
468
|
//#region src/lib/v2/mock/getMotionGroupKinematicModel.ts
|
|
472
469
|
const getMotionGroupKinematicModel = {
|
|
@@ -522,7 +519,6 @@ const getMotionGroupKinematicModel = {
|
|
|
522
519
|
};
|
|
523
520
|
}
|
|
524
521
|
};
|
|
525
|
-
|
|
526
522
|
//#endregion
|
|
527
523
|
//#region src/lib/v2/mock/getRobotController.ts
|
|
528
524
|
const getRobotController = {
|
|
@@ -540,7 +536,6 @@ const getRobotController = {
|
|
|
540
536
|
};
|
|
541
537
|
}
|
|
542
538
|
};
|
|
543
|
-
|
|
544
539
|
//#endregion
|
|
545
540
|
//#region src/lib/v2/mock/listCoordinateSystems.ts
|
|
546
541
|
const listCoordinateSystems = {
|
|
@@ -580,7 +575,6 @@ const listCoordinateSystems = {
|
|
|
580
575
|
}];
|
|
581
576
|
}
|
|
582
577
|
};
|
|
583
|
-
|
|
584
578
|
//#endregion
|
|
585
579
|
//#region src/lib/v2/mock/listRobotControllers.ts
|
|
586
580
|
const listRobotControllers = {
|
|
@@ -590,7 +584,6 @@ const listRobotControllers = {
|
|
|
590
584
|
return ["mock-ur5e"];
|
|
591
585
|
}
|
|
592
586
|
};
|
|
593
|
-
|
|
594
587
|
//#endregion
|
|
595
588
|
//#region src/lib/v2/mock/MockNovaInstance.ts
|
|
596
589
|
/**
|
|
@@ -689,9 +682,9 @@ const defaultMotionState = { result: {
|
|
|
689
682
|
-1.7542521568325058,
|
|
690
683
|
.7326972590614671
|
|
691
684
|
]
|
|
692
|
-
}
|
|
685
|
+
},
|
|
686
|
+
description_revision: 0
|
|
693
687
|
} };
|
|
694
|
-
|
|
695
688
|
//#endregion
|
|
696
689
|
//#region src/lib/v2/NovaClient.ts
|
|
697
690
|
/**
|
|
@@ -746,8 +739,8 @@ var NovaClient = class {
|
|
|
746
739
|
return mime === "application/json";
|
|
747
740
|
},
|
|
748
741
|
baseOptions: {
|
|
749
|
-
...this.mock ? { adapter: (config
|
|
750
|
-
return this.mock.handleAPIRequest(config
|
|
742
|
+
...this.mock ? { adapter: (config) => {
|
|
743
|
+
return this.mock.handleAPIRequest(config);
|
|
751
744
|
} } : {},
|
|
752
745
|
...config.baseOptions
|
|
753
746
|
},
|
|
@@ -790,7 +783,6 @@ var NovaClient = class {
|
|
|
790
783
|
return new require_LoginWithAuth0.AutoReconnectingWebsocket(this.makeWebsocketURL(path), { mock: this.mock });
|
|
791
784
|
}
|
|
792
785
|
};
|
|
793
|
-
|
|
794
786
|
//#endregion
|
|
795
787
|
//#region src/lib/v2/wandelscriptUtils.ts
|
|
796
788
|
/**
|
|
@@ -812,16 +804,17 @@ function poseToWandelscriptString(pose) {
|
|
|
812
804
|
const rotationValues = orientation.map((v) => v.toFixed(4));
|
|
813
805
|
return `(${positionValues.concat(rotationValues).join(", ")})`;
|
|
814
806
|
}
|
|
815
|
-
|
|
816
807
|
//#endregion
|
|
817
808
|
exports.NovaCellAPIClient = NovaCellAPIClient;
|
|
818
809
|
exports.NovaClient = NovaClient;
|
|
819
810
|
exports.poseToWandelscriptString = poseToWandelscriptString;
|
|
820
|
-
Object.keys(_wandelbots_nova_api_v2).forEach(function
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
811
|
+
Object.keys(_wandelbots_nova_api_v2).forEach(function(k) {
|
|
812
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
813
|
+
enumerable: true,
|
|
814
|
+
get: function() {
|
|
815
|
+
return _wandelbots_nova_api_v2[k];
|
|
816
|
+
}
|
|
817
|
+
});
|
|
825
818
|
});
|
|
826
819
|
|
|
827
820
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["SystemApi","CellApi","MotionGroupApi","MotionGroupModelsApi","ControllerApi","ControllerInputsOutputsApi","TrajectoryPlanningApi","TrajectoryExecutionApi","TrajectoryCachingApi","ApplicationApi","JoggingApi","KinematicsApi","BUSInputsOutputsApi","VirtualControllerApi","VirtualControllerBehaviorApi","VirtualControllerInputsOutputsApi","StoreObjectApi","StoreCollisionComponentsApi","StoreCollisionSetupsApi","pathToRegexp","AxiosError","availableStorage","parseNovaInstanceUrl","config","loginWithAuth0","AutoReconnectingWebsocket"],"sources":["../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/mock/getCurrentRobotControllerState.ts","../../../src/lib/v2/mock/getMotionGroupDescription.ts","../../../src/lib/v2/mock/getMotionGroupKinematicModel.ts","../../../src/lib/v2/mock/getRobotController.ts","../../../src/lib/v2/mock/listCoordinateSystems.ts","../../../src/lib/v2/mock/listRobotControllers.ts","../../../src/lib/v2/mock/MockNovaInstance.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/wandelscriptUtils.ts"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noExplicitAny: legacy code */\n/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type {\n BaseAPI,\n Configuration as BaseConfiguration,\n} from \"@wandelbots/nova-api/v2\"\nimport {\n ApplicationApi,\n BUSInputsOutputsApi,\n CellApi,\n ControllerApi,\n ControllerInputsOutputsApi,\n JoggingApi,\n KinematicsApi,\n MotionGroupApi,\n MotionGroupModelsApi,\n StoreCollisionComponentsApi,\n StoreCollisionSetupsApi,\n StoreObjectApi,\n SystemApi,\n TrajectoryCachingApi,\n TrajectoryExecutionApi,\n TrajectoryPlanningApi,\n VirtualControllerApi,\n VirtualControllerBehaviorApi,\n VirtualControllerInputsOutputsApi,\n} from \"@wandelbots/nova-api/v2\"\nimport type { AxiosInstance } from \"axios\"\nimport axios from \"axios\"\n\ntype OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R\n ? (...args: P) => R\n : never\n\ntype UnwrapAxiosResponseReturn<T> = T extends (...a: any) => any\n ? (\n ...a: Parameters<T>\n ) => Promise<Awaited<ReturnType<T>> extends { data: infer D } ? D : never>\n : never\n\nexport type WithCellId<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<OmitFirstArg<T[P]>>\n}\n\nexport type WithUnwrappedAxiosResponse<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<T[P]>\n}\n\n/**\n * API client providing type-safe access to all the Nova API REST endpoints\n * associated with a specific cell id.\n */\nexport class NovaCellAPIClient {\n constructor(\n readonly cellId: string,\n readonly opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n },\n ) {}\n\n /**\n * Some TypeScript sorcery which alters the API class methods so you don't\n * have to pass the cell id to every single one, and de-encapsulates the\n * response data\n */\n private withCellId<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, [this.cellId, ...args])\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithCellId<T>\n }\n\n /**\n * As withCellId, but only does the response unwrapping\n */\n private withUnwrappedResponsesOnly<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, args)\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithUnwrappedAxiosResponse<T>\n }\n\n readonly system = this.withUnwrappedResponsesOnly(SystemApi)\n readonly cell = this.withUnwrappedResponsesOnly(CellApi)\n\n readonly motionGroup = this.withCellId(MotionGroupApi)\n readonly motionGroupModels =\n this.withUnwrappedResponsesOnly(MotionGroupModelsApi)\n\n readonly controller = this.withCellId(ControllerApi)\n\n readonly controllerIOs = this.withCellId(ControllerInputsOutputsApi)\n\n readonly trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)\n readonly trajectoryExecution = this.withCellId(TrajectoryExecutionApi)\n readonly trajectoryCaching = this.withCellId(TrajectoryCachingApi)\n\n readonly application = this.withCellId(ApplicationApi)\n readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)\n\n readonly jogging = this.withCellId(JoggingApi)\n\n readonly kinematics = this.withCellId(KinematicsApi)\n\n readonly busInputsOutputs = this.withCellId(BUSInputsOutputsApi)\n\n readonly virtualController = this.withCellId(VirtualControllerApi)\n readonly virtualControllerBehavior = this.withCellId(\n VirtualControllerBehaviorApi,\n )\n readonly virtualControllerIOs = this.withCellId(\n VirtualControllerInputsOutputsApi,\n )\n\n readonly storeObject = this.withCellId(StoreObjectApi)\n readonly storeCollisionComponents = this.withCellId(\n StoreCollisionComponentsApi,\n )\n readonly storeCollisionSetups = this.withCellId(StoreCollisionSetupsApi)\n}\n","export const getCurrentRobotControllerState = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/state\",\n handle() {\n return {\n mode: \"MODE_CONTROL\",\n last_error: [],\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n controller: \"mock-ur5e\",\n operation_mode: \"OPERATION_MODE_AUTO\",\n safety_state: \"SAFETY_STATE_NORMAL\",\n velocity_override: 100,\n motion_groups: [\n {\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n motion_group: \"0@mock-ur5e\",\n controller: \"mock-ur5e\",\n joint_position: [\n 1.487959623336792, -1.8501918315887451, 1.8003005981445312,\n 6.034560203552246, 1.4921919107437134, 1.593459963798523,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n joint_torque: [],\n joint_current: [0, 0, 0, 0, 0, 0],\n flange_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n tcp: \"Flange\",\n tcp_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n payload: \"\",\n coordinate_system: \"\",\n standstill: true,\n },\n ],\n }\n },\n}\n","export const getMotionGroupDescription = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/motion-groups/:motionGroupId/description\",\n handle() {\n return {\n motion_group_model: \"UniversalRobots_UR5e\",\n mounting: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n tcps: {\n Flange: {\n name: \"Default-Flange\",\n pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n },\n },\n payloads: {\n \"FPay-0\": {\n name: \"FPay-0\",\n payload: 0,\n center_of_mass: [0, 0, 0],\n moment_of_inertia: [0, 0, 0],\n },\n },\n cycle_time: 8,\n dh_parameters: [\n {\n alpha: 1.5707963267948966,\n d: 162.25,\n },\n {\n a: -425,\n },\n {\n a: -392.2,\n },\n {\n alpha: 1.5707963267948966,\n d: 133.3,\n },\n {\n alpha: -1.5707963267948966,\n d: 99.7,\n },\n {\n d: 99.6,\n },\n ],\n operation_limits: {\n auto_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n elbow: {\n velocity: 5000,\n },\n flange: {\n velocity: 5000,\n },\n },\n manual_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t1_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t2_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n },\n serial_number: \"WBVirtualRobot\",\n }\n },\n}\n","export const getMotionGroupKinematicModel = {\n method: \"GET\",\n path: \"/motion-group-models/:motionGroupModel/kinematic\",\n handle() {\n return {\n dh_parameters: [\n {\n alpha: 1.5707963267948966,\n theta: 0.0,\n a: 0.0,\n d: 162.25,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0.0,\n theta: 0.0,\n a: -425.0,\n d: 0.0,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0.0,\n theta: 0.0,\n a: -392.2,\n d: 0.0,\n reverse_rotation_direction: false,\n },\n {\n alpha: 1.5707963267948966,\n theta: 0.0,\n a: 0.0,\n d: 133.3,\n reverse_rotation_direction: false,\n },\n {\n alpha: -1.5707963267948966,\n theta: 0.0,\n a: 0.0,\n d: 99.7,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0.0,\n theta: 0.0,\n a: 0.0,\n d: 99.6,\n reverse_rotation_direction: false,\n },\n ],\n inverse_solver: \"Universalrobots\",\n }\n },\n}\n","import type { RobotController } from \"@wandelbots/nova-api/v2\"\n\nexport const getRobotController = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId\",\n handle() {\n return {\n configuration: {\n initial_joint_position: \"[0,-1.571,-1.571,-1.571,1.571,-1.571,0]\",\n kind: \"VirtualController\",\n manufacturer: \"universalrobots\",\n type: \"universalrobots-ur5e\",\n },\n name: \"mock-ur5\",\n } satisfies RobotController\n },\n}\n","export const listCoordinateSystems = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/coordinate-systems\",\n handle() {\n return [\n {\n coordinate_system: \"\",\n name: \"world\",\n reference_coordinate_system: \"\",\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n orientation_type: \"ROTATION_VECTOR\",\n },\n {\n coordinate_system: \"CS-0\",\n name: \"Default-CS\",\n reference_coordinate_system: \"\",\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n orientation_type: \"ROTATION_VECTOR\",\n },\n ]\n },\n}\n","export const listRobotControllers = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return [\"mock-ur5e\"]\n },\n}\n","import type { MotionGroupState } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosResponse, InternalAxiosRequestConfig } from \"axios\"\nimport { AxiosError } from \"axios\"\nimport * as pathToRegexp from \"path-to-regexp\"\nimport type { AutoReconnectingWebsocket } from \"../../AutoReconnectingWebsocket\"\nimport { getCurrentRobotControllerState } from \"./getCurrentRobotControllerState\"\nimport { getMotionGroupDescription } from \"./getMotionGroupDescription\"\nimport { getMotionGroupKinematicModel } from \"./getMotionGroupKinematicModel\"\nimport { getRobotController } from \"./getRobotController\"\nimport { listCoordinateSystems } from \"./listCoordinateSystems\"\nimport { listRobotControllers } from \"./listRobotControllers\"\n\n/**\n * Ultra-simplified mock Nova server for testing stuff\n */\nexport class MockNovaInstance {\n readonly connections: AutoReconnectingWebsocket[] = []\n\n async handleAPIRequest(\n config: InternalAxiosRequestConfig,\n ): Promise<AxiosResponse> {\n const apiHandlers = [\n listRobotControllers,\n getRobotController,\n getMotionGroupDescription,\n getCurrentRobotControllerState,\n listCoordinateSystems,\n getMotionGroupKinematicModel,\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n if (!config.url) {\n throw new Error(\"No url sent with request\")\n }\n const path = config.url.split(\"?\")[0]\n\n for (const handler of apiHandlers) {\n const match = pathToRegexp.match(handler.path)(path)\n if (method === handler.method && match) {\n const json = handler.handle()\n return {\n status: 200,\n statusText: \"Success\",\n data: JSON.stringify(json),\n headers: {},\n config,\n request: {\n responseURL: config.url,\n },\n }\n }\n }\n\n throw new AxiosError(\n `No mock handler matched this request: ${method} ${path}`,\n \"404\",\n config,\n )\n }\n\n // Please note: Only very basic websocket mocking is done here, needs to be extended as needed\n handleWebsocketConnection(socket: AutoReconnectingWebsocket) {\n this.connections.push(socket)\n\n setTimeout(() => {\n socket.dispatchEvent(new Event(\"open\"))\n\n console.log(\"Websocket connection opened from\", socket.url)\n\n if (socket.url.includes(\"/state-stream\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify(defaultMotionState),\n }),\n )\n }\n\n if (socket.url.includes(\"/execution/jogging\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify({\n result: {\n message: \"string\",\n kind: \"INITIALIZE_RECEIVED\",\n },\n }),\n }),\n )\n }\n }, 10)\n }\n\n handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string) {\n console.log(`Received message on ${socket.url}`, message)\n }\n}\n\nconst defaultMotionState = {\n result: {\n motion_group: \"0@universalrobots-ur5e\",\n controller: \"universalrobots-ur5e\",\n timestamp: new Date().toISOString(),\n sequence_number: 1,\n joint_position: [\n 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,\n 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n standstill: false,\n flange_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n tcp_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n } satisfies MotionGroupState,\n}\n","/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type { Configuration as BaseConfiguration } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosRequestConfig } from \"axios\"\nimport axios, { isAxiosError } from \"axios\"\nimport urlJoin from \"url-join\"\nimport { loginWithAuth0 } from \"../../LoginWithAuth0\"\nimport { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { availableStorage } from \"../availableStorage\"\nimport { parseNovaInstanceUrl } from \"../converters\"\nimport { MockNovaInstance } from \"./mock/MockNovaInstance\"\nimport { NovaCellAPIClient } from \"./NovaCellAPIClient\"\n\nexport type NovaClientConfig = {\n /**\n * Url of the deployed Nova instance to connect to\n * e.g. https://saeattii.instance.wandelbots.io\n */\n instanceUrl: string | \"https://mock.example.com\"\n\n /**\n * Identifier of the cell on the Nova instance to connect this client to.\n * If omitted, the default identifier \"cell\" is used.\n **/\n cellId?: string\n\n /**\n * Username for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n username?: string\n\n /**\n * Password for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n password?: string\n\n /**\n * Access token for Bearer authentication.\n */\n accessToken?: string\n} & Omit<BaseConfiguration, \"isJsonMime\" | \"basePath\">\n\ntype NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string }\n\n/**\n *\n * Client for connecting to a Nova instance and controlling robots.\n */\nexport class NovaClient {\n readonly api: NovaCellAPIClient\n readonly config: NovaClientConfigWithDefaults\n readonly mock?: MockNovaInstance\n readonly instanceUrl: URL\n authPromise: Promise<string | null> | null = null\n accessToken: string | null = null\n\n constructor(config: NovaClientConfig) {\n const cellId = config.cellId ?? \"cell\"\n this.config = {\n cellId,\n ...config,\n }\n this.accessToken =\n config.accessToken ||\n availableStorage.getString(\"wbjs.access_token\") ||\n null\n\n if (this.config.instanceUrl === \"https://mock.example.com\") {\n this.mock = new MockNovaInstance()\n }\n this.instanceUrl = parseNovaInstanceUrl(this.config.instanceUrl)\n\n // Set up Axios instance with interceptor for token fetching\n const axiosInstance = axios.create({\n baseURL: urlJoin(this.instanceUrl.href, \"/api/v2\"),\n // TODO - backend needs to set proper CORS headers for this\n headers:\n typeof window !== \"undefined\" &&\n window.location.origin.includes(\"localhost\")\n ? {}\n : {\n // Identify the client to the backend for logging purposes\n \"X-Wandelbots-Client\": \"Wandelbots-Nova-JS-SDK\",\n },\n })\n\n axiosInstance.interceptors.request.use(async (request) => {\n if (!request.headers.Authorization) {\n if (this.accessToken) {\n request.headers.Authorization = `Bearer ${this.accessToken}`\n } else if (this.config.username && this.config.password) {\n request.headers.Authorization = `Basic ${btoa(`${config.username}:${config.password}`)}`\n }\n }\n return request\n })\n\n if (typeof window !== \"undefined\") {\n axiosInstance.interceptors.response.use(\n (r) => r,\n async (error) => {\n if (isAxiosError(error)) {\n if (error.response?.status === 401) {\n // If we hit a 401, attempt to login the user and retry with\n // a new access token\n try {\n await this.renewAuthentication()\n\n if (error.config) {\n if (this.accessToken) {\n error.config.headers.Authorization = `Bearer ${this.accessToken}`\n } else {\n delete error.config.headers.Authorization\n }\n return axiosInstance.request(error.config)\n }\n } catch (err) {\n return Promise.reject(err)\n }\n } else if (error.response?.status === 503) {\n // Check if the server as a whole is down\n const res = await fetch(window.location.href)\n if (res.status === 503) {\n // Go to 503 page\n window.location.reload()\n }\n }\n }\n\n return Promise.reject(error)\n },\n )\n }\n\n this.api = new NovaCellAPIClient(cellId, {\n ...config,\n basePath: urlJoin(this.instanceUrl.href, \"/api/v2\"),\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n baseOptions: {\n ...(this.mock\n ? ({\n adapter: (config) => {\n return this.mock!.handleAPIRequest(config)\n },\n } satisfies AxiosRequestConfig)\n : {}),\n ...config.baseOptions,\n },\n axiosInstance,\n })\n }\n\n async renewAuthentication(): Promise<void> {\n if (this.authPromise) {\n // Don't double up\n return\n }\n\n const storedToken = availableStorage.getString(\"wbjs.access_token\")\n if (storedToken && this.accessToken !== storedToken) {\n // Might be newer than the one we have\n this.accessToken = storedToken\n return\n }\n\n // Otherwise, perform login flow\n this.authPromise = loginWithAuth0(this.instanceUrl)\n try {\n this.accessToken = await this.authPromise\n if (this.accessToken) {\n // Cache access token so we don't need to log in every refresh\n availableStorage.setString(\"wbjs.access_token\", this.accessToken)\n } else {\n availableStorage.delete(\"wbjs.access_token\")\n }\n } finally {\n this.authPromise = null\n }\n }\n\n makeWebsocketURL(path: string): string {\n const url = new URL(\n urlJoin(\n this.instanceUrl.href,\n `/api/v2/cells/${this.config.cellId}`,\n path,\n ),\n )\n url.protocol = url.protocol.replace(\"http\", \"ws\")\n url.protocol = url.protocol.replace(\"https\", \"wss\")\n\n // If provided, add basic auth credentials to the URL\n // NOTE - basic auth is deprecated on websockets and doesn't work in Safari\n // use tokens instead\n if (this.accessToken) {\n url.searchParams.append(\"token\", this.accessToken)\n } else if (this.config.username && this.config.password) {\n url.username = this.config.username\n url.password = this.config.password\n }\n\n return url.toString()\n }\n\n /**\n * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.\n * If you explicitly want to reconnect an existing websocket, call `reconnect`\n * on the returned object.\n */\n openReconnectingWebsocket(path: string) {\n return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {\n mock: this.mock,\n })\n }\n}\n","import type { Pose } from \"@wandelbots/nova-api/v2\"\n\n/**\n * Convert a Pose object representing a motion group position\n * into a string which represents that pose in Wandelscript.\n */\nexport function poseToWandelscriptString(\n pose: Pick<Pose, \"position\" | \"orientation\">,\n) {\n const position = [\n pose.position?.[0] ?? 0,\n pose.position?.[1] ?? 0,\n pose.position?.[2] ?? 0,\n ]\n\n const orientation = [\n pose.orientation?.[0] ?? 0,\n pose.orientation?.[1] ?? 0,\n pose.orientation?.[2] ?? 0,\n ]\n\n const positionValues = position.map((v) => v.toFixed(1))\n // Rotation needs more precision since it's in radians\n const rotationValues = orientation.map((v) => v.toFixed(4))\n\n return `(${positionValues.concat(rotationValues).join(\", \")})`\n}\n"],"mappings":";;;;;;;;;;;;;;AAoDA,IAAa,oBAAb,MAA+B;CAC7B,YACE,AAAS,QACT,AAAS,MAIT;EALS;EACA;gBAkFO,KAAK,2BAA2BA,kCAAU;cAC5C,KAAK,2BAA2BC,gCAAQ;qBAEjC,KAAK,WAAWC,uCAAe;2BAEpD,KAAK,2BAA2BC,6CAAqB;oBAEjC,KAAK,WAAWC,sCAAc;uBAE3B,KAAK,WAAWC,mDAA2B;4B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;GACD,YAAY;GACZ,eAAe;IACb;KACE,OAAO;KACP,GAAG;KACJ;IACD,EACE,GAAG,MACJ;IACD,EACE,GAAG,QACJ;IACD;KACE,OAAO;KACP,GAAG;KACJ;IACD;KACE,OAAO;KACP,GAAG;KACJ;IACD,EACE,GAAG,MACJ;IACF;GACD,kBAAkB;IAChB,aAAa;KACX,QAAQ;MACN;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACF;KACD,KAAK,EACH,UAAU,KACX;KACD,OAAO,EACL,UAAU,KACX;KACD,QAAQ,EACN,UAAU,KACX;KACF;IACD,eAAe;KACb,QAAQ;MACN;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACF;KACD,KAAK,EACH,UAAU,KACX;KACF;IACD,kBAAkB;KAChB,QAAQ;MACN;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACF;KACD,KAAK,EACH,UAAU,KACX;KACF;IACD,kBAAkB;KAChB,QAAQ;MACN;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACF;KACD,KAAK,EACH,UAAU,KACX;KACF;IACF;GACD,eAAe;GAChB;;CAE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KAAK,OAAO,YAAY,KAAK,OAAO,UAAU;AACvD,OAAI,WAAW,KAAK,OAAO;AAC3B,OAAI,WAAW,KAAK,OAAO;;AAG7B,SAAO,IAAI,UAAU;;;;;;;CAQvB,0BAA0B,MAAc;AACtC,SAAO,IAAIC,iDAA0B,KAAK,iBAAiB,KAAK,EAAE,EAChE,MAAM,KAAK,MACZ,CAAC;;;;;;;;;;ACjNN,SAAgB,yBACd,MACA;CACA,MAAM,WAAW;EACf,KAAK,WAAW,MAAM;EACtB,KAAK,WAAW,MAAM;EACtB,KAAK,WAAW,MAAM;EACvB;CAED,MAAM,cAAc;EAClB,KAAK,cAAc,MAAM;EACzB,KAAK,cAAc,MAAM;EACzB,KAAK,cAAc,MAAM;EAC1B;CAED,MAAM,iBAAiB,SAAS,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;CAExD,MAAM,iBAAiB,YAAY,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;AAE3D,QAAO,IAAI,eAAe,OAAO,eAAe,CAAC,KAAK,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["SystemApi","CellApi","MotionGroupApi","MotionGroupModelsApi","ControllerApi","ControllerInputsOutputsApi","TrajectoryPlanningApi","TrajectoryExecutionApi","TrajectoryCachingApi","ApplicationApi","JoggingApi","KinematicsApi","BUSInputsOutputsApi","VirtualControllerApi","VirtualControllerBehaviorApi","VirtualControllerInputsOutputsApi","StoreObjectApi","StoreCollisionComponentsApi","StoreCollisionSetupsApi","pathToRegexp","AxiosError","availableStorage","parseNovaInstanceUrl","loginWithAuth0","AutoReconnectingWebsocket"],"sources":["../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/mock/getCurrentRobotControllerState.ts","../../../src/lib/v2/mock/getMotionGroupDescription.ts","../../../src/lib/v2/mock/getMotionGroupKinematicModel.ts","../../../src/lib/v2/mock/getRobotController.ts","../../../src/lib/v2/mock/listCoordinateSystems.ts","../../../src/lib/v2/mock/listRobotControllers.ts","../../../src/lib/v2/mock/MockNovaInstance.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/wandelscriptUtils.ts"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noExplicitAny: legacy code */\n/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type {\n BaseAPI,\n Configuration as BaseConfiguration,\n} from \"@wandelbots/nova-api/v2\"\nimport {\n ApplicationApi,\n BUSInputsOutputsApi,\n CellApi,\n ControllerApi,\n ControllerInputsOutputsApi,\n JoggingApi,\n KinematicsApi,\n MotionGroupApi,\n MotionGroupModelsApi,\n StoreCollisionComponentsApi,\n StoreCollisionSetupsApi,\n StoreObjectApi,\n SystemApi,\n TrajectoryCachingApi,\n TrajectoryExecutionApi,\n TrajectoryPlanningApi,\n VirtualControllerApi,\n VirtualControllerBehaviorApi,\n VirtualControllerInputsOutputsApi,\n} from \"@wandelbots/nova-api/v2\"\nimport type { AxiosInstance } from \"axios\"\nimport axios from \"axios\"\n\ntype OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R\n ? (...args: P) => R\n : never\n\ntype UnwrapAxiosResponseReturn<T> = T extends (...a: any) => any\n ? (\n ...a: Parameters<T>\n ) => Promise<Awaited<ReturnType<T>> extends { data: infer D } ? D : never>\n : never\n\nexport type WithCellId<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<OmitFirstArg<T[P]>>\n}\n\nexport type WithUnwrappedAxiosResponse<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<T[P]>\n}\n\n/**\n * API client providing type-safe access to all the Nova API REST endpoints\n * associated with a specific cell id.\n */\nexport class NovaCellAPIClient {\n constructor(\n readonly cellId: string,\n readonly opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n },\n ) {}\n\n /**\n * Some TypeScript sorcery which alters the API class methods so you don't\n * have to pass the cell id to every single one, and de-encapsulates the\n * response data\n */\n private withCellId<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, [this.cellId, ...args])\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithCellId<T>\n }\n\n /**\n * As withCellId, but only does the response unwrapping\n */\n private withUnwrappedResponsesOnly<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, args)\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithUnwrappedAxiosResponse<T>\n }\n\n readonly system = this.withUnwrappedResponsesOnly(SystemApi)\n readonly cell = this.withUnwrappedResponsesOnly(CellApi)\n\n readonly motionGroup = this.withCellId(MotionGroupApi)\n readonly motionGroupModels =\n this.withUnwrappedResponsesOnly(MotionGroupModelsApi)\n\n readonly controller = this.withCellId(ControllerApi)\n\n readonly controllerIOs = this.withCellId(ControllerInputsOutputsApi)\n\n readonly trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)\n readonly trajectoryExecution = this.withCellId(TrajectoryExecutionApi)\n readonly trajectoryCaching = this.withCellId(TrajectoryCachingApi)\n\n readonly application = this.withCellId(ApplicationApi)\n readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)\n\n readonly jogging = this.withCellId(JoggingApi)\n\n readonly kinematics = this.withCellId(KinematicsApi)\n\n readonly busInputsOutputs = this.withCellId(BUSInputsOutputsApi)\n\n readonly virtualController = this.withCellId(VirtualControllerApi)\n readonly virtualControllerBehavior = this.withCellId(\n VirtualControllerBehaviorApi,\n )\n readonly virtualControllerIOs = this.withCellId(\n VirtualControllerInputsOutputsApi,\n )\n\n readonly storeObject = this.withCellId(StoreObjectApi)\n readonly storeCollisionComponents = this.withCellId(\n StoreCollisionComponentsApi,\n )\n readonly storeCollisionSetups = this.withCellId(StoreCollisionSetupsApi)\n}\n","export const getCurrentRobotControllerState = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/state\",\n handle() {\n return {\n mode: \"MODE_CONTROL\",\n last_error: [],\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n controller: \"mock-ur5e\",\n operation_mode: \"OPERATION_MODE_AUTO\",\n safety_state: \"SAFETY_STATE_NORMAL\",\n velocity_override: 100,\n motion_groups: [\n {\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n motion_group: \"0@mock-ur5e\",\n controller: \"mock-ur5e\",\n joint_position: [\n 1.487959623336792, -1.8501918315887451, 1.8003005981445312,\n 6.034560203552246, 1.4921919107437134, 1.593459963798523,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n joint_torque: [],\n joint_current: [0, 0, 0, 0, 0, 0],\n flange_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n tcp: \"Flange\",\n tcp_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n payload: \"\",\n coordinate_system: \"\",\n standstill: true,\n },\n ],\n }\n },\n}\n","export const getMotionGroupDescription = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/motion-groups/:motionGroupId/description\",\n handle() {\n return {\n motion_group_model: \"UniversalRobots_UR5e\",\n mounting: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n tcps: {\n Flange: {\n name: \"Default-Flange\",\n pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n },\n },\n payloads: {\n \"FPay-0\": {\n name: \"FPay-0\",\n payload: 0,\n center_of_mass: [0, 0, 0],\n moment_of_inertia: [0, 0, 0],\n },\n },\n cycle_time: 8,\n dh_parameters: [\n {\n alpha: 1.5707963267948966,\n d: 162.25,\n },\n {\n a: -425,\n },\n {\n a: -392.2,\n },\n {\n alpha: 1.5707963267948966,\n d: 133.3,\n },\n {\n alpha: -1.5707963267948966,\n d: 99.7,\n },\n {\n d: 99.6,\n },\n ],\n operation_limits: {\n auto_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n elbow: {\n velocity: 5000,\n },\n flange: {\n velocity: 5000,\n },\n },\n manual_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t1_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t2_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n },\n serial_number: \"WBVirtualRobot\",\n }\n },\n}\n","export const getMotionGroupKinematicModel = {\n method: \"GET\",\n path: \"/motion-group-models/:motionGroupModel/kinematic\",\n handle() {\n return {\n dh_parameters: [\n {\n alpha: 1.5707963267948966,\n theta: 0.0,\n a: 0.0,\n d: 162.25,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0.0,\n theta: 0.0,\n a: -425.0,\n d: 0.0,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0.0,\n theta: 0.0,\n a: -392.2,\n d: 0.0,\n reverse_rotation_direction: false,\n },\n {\n alpha: 1.5707963267948966,\n theta: 0.0,\n a: 0.0,\n d: 133.3,\n reverse_rotation_direction: false,\n },\n {\n alpha: -1.5707963267948966,\n theta: 0.0,\n a: 0.0,\n d: 99.7,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0.0,\n theta: 0.0,\n a: 0.0,\n d: 99.6,\n reverse_rotation_direction: false,\n },\n ],\n inverse_solver: \"Universalrobots\",\n }\n },\n}\n","import type { RobotController } from \"@wandelbots/nova-api/v2\"\n\nexport const getRobotController = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId\",\n handle() {\n return {\n configuration: {\n initial_joint_position: \"[0,-1.571,-1.571,-1.571,1.571,-1.571,0]\",\n kind: \"VirtualController\",\n manufacturer: \"universalrobots\",\n type: \"universalrobots-ur5e\",\n },\n name: \"mock-ur5\",\n } satisfies RobotController\n },\n}\n","export const listCoordinateSystems = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/coordinate-systems\",\n handle() {\n return [\n {\n coordinate_system: \"\",\n name: \"world\",\n reference_coordinate_system: \"\",\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n orientation_type: \"ROTATION_VECTOR\",\n },\n {\n coordinate_system: \"CS-0\",\n name: \"Default-CS\",\n reference_coordinate_system: \"\",\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n orientation_type: \"ROTATION_VECTOR\",\n },\n ]\n },\n}\n","export const listRobotControllers = {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return [\"mock-ur5e\"]\n },\n}\n","import type { MotionGroupState } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosResponse, InternalAxiosRequestConfig } from \"axios\"\nimport { AxiosError } from \"axios\"\nimport * as pathToRegexp from \"path-to-regexp\"\nimport type { AutoReconnectingWebsocket } from \"../../AutoReconnectingWebsocket\"\nimport { getCurrentRobotControllerState } from \"./getCurrentRobotControllerState\"\nimport { getMotionGroupDescription } from \"./getMotionGroupDescription\"\nimport { getMotionGroupKinematicModel } from \"./getMotionGroupKinematicModel\"\nimport { getRobotController } from \"./getRobotController\"\nimport { listCoordinateSystems } from \"./listCoordinateSystems\"\nimport { listRobotControllers } from \"./listRobotControllers\"\n\n/**\n * Ultra-simplified mock Nova server for testing stuff\n */\nexport class MockNovaInstance {\n readonly connections: AutoReconnectingWebsocket[] = []\n\n async handleAPIRequest(\n config: InternalAxiosRequestConfig,\n ): Promise<AxiosResponse> {\n const apiHandlers = [\n listRobotControllers,\n getRobotController,\n getMotionGroupDescription,\n getCurrentRobotControllerState,\n listCoordinateSystems,\n getMotionGroupKinematicModel,\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n if (!config.url) {\n throw new Error(\"No url sent with request\")\n }\n const path = config.url.split(\"?\")[0]\n\n for (const handler of apiHandlers) {\n const match = pathToRegexp.match(handler.path)(path)\n if (method === handler.method && match) {\n const json = handler.handle()\n return {\n status: 200,\n statusText: \"Success\",\n data: JSON.stringify(json),\n headers: {},\n config,\n request: {\n responseURL: config.url,\n },\n }\n }\n }\n\n throw new AxiosError(\n `No mock handler matched this request: ${method} ${path}`,\n \"404\",\n config,\n )\n }\n\n // Please note: Only very basic websocket mocking is done here, needs to be extended as needed\n handleWebsocketConnection(socket: AutoReconnectingWebsocket) {\n this.connections.push(socket)\n\n setTimeout(() => {\n socket.dispatchEvent(new Event(\"open\"))\n\n console.log(\"Websocket connection opened from\", socket.url)\n\n if (socket.url.includes(\"/state-stream\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify(defaultMotionState),\n }),\n )\n }\n\n if (socket.url.includes(\"/execution/jogging\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify({\n result: {\n message: \"string\",\n kind: \"INITIALIZE_RECEIVED\",\n },\n }),\n }),\n )\n }\n }, 10)\n }\n\n handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string) {\n console.log(`Received message on ${socket.url}`, message)\n }\n}\n\nconst defaultMotionState = {\n result: {\n motion_group: \"0@universalrobots-ur5e\",\n controller: \"universalrobots-ur5e\",\n timestamp: new Date().toISOString(),\n sequence_number: 1,\n joint_position: [\n 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,\n 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n standstill: false,\n flange_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n tcp_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n description_revision: 0,\n } satisfies MotionGroupState,\n}\n","/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type { Configuration as BaseConfiguration } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosRequestConfig } from \"axios\"\nimport axios, { isAxiosError } from \"axios\"\nimport urlJoin from \"url-join\"\nimport { loginWithAuth0 } from \"../../LoginWithAuth0\"\nimport { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { availableStorage } from \"../availableStorage\"\nimport { parseNovaInstanceUrl } from \"../converters\"\nimport { MockNovaInstance } from \"./mock/MockNovaInstance\"\nimport { NovaCellAPIClient } from \"./NovaCellAPIClient\"\n\nexport type NovaClientConfig = {\n /**\n * Url of the deployed Nova instance to connect to\n * e.g. https://saeattii.instance.wandelbots.io\n */\n instanceUrl: string | \"https://mock.example.com\"\n\n /**\n * Identifier of the cell on the Nova instance to connect this client to.\n * If omitted, the default identifier \"cell\" is used.\n **/\n cellId?: string\n\n /**\n * Username for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n username?: string\n\n /**\n * Password for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n password?: string\n\n /**\n * Access token for Bearer authentication.\n */\n accessToken?: string\n} & Omit<BaseConfiguration, \"isJsonMime\" | \"basePath\">\n\ntype NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string }\n\n/**\n *\n * Client for connecting to a Nova instance and controlling robots.\n */\nexport class NovaClient {\n readonly api: NovaCellAPIClient\n readonly config: NovaClientConfigWithDefaults\n readonly mock?: MockNovaInstance\n readonly instanceUrl: URL\n authPromise: Promise<string | null> | null = null\n accessToken: string | null = null\n\n constructor(config: NovaClientConfig) {\n const cellId = config.cellId ?? \"cell\"\n this.config = {\n cellId,\n ...config,\n }\n this.accessToken =\n config.accessToken ||\n availableStorage.getString(\"wbjs.access_token\") ||\n null\n\n if (this.config.instanceUrl === \"https://mock.example.com\") {\n this.mock = new MockNovaInstance()\n }\n this.instanceUrl = parseNovaInstanceUrl(this.config.instanceUrl)\n\n // Set up Axios instance with interceptor for token fetching\n const axiosInstance = axios.create({\n baseURL: urlJoin(this.instanceUrl.href, \"/api/v2\"),\n // TODO - backend needs to set proper CORS headers for this\n headers:\n typeof window !== \"undefined\" &&\n window.location.origin.includes(\"localhost\")\n ? {}\n : {\n // Identify the client to the backend for logging purposes\n \"X-Wandelbots-Client\": \"Wandelbots-Nova-JS-SDK\",\n },\n })\n\n axiosInstance.interceptors.request.use(async (request) => {\n if (!request.headers.Authorization) {\n if (this.accessToken) {\n request.headers.Authorization = `Bearer ${this.accessToken}`\n } else if (this.config.username && this.config.password) {\n request.headers.Authorization = `Basic ${btoa(`${config.username}:${config.password}`)}`\n }\n }\n return request\n })\n\n if (typeof window !== \"undefined\") {\n axiosInstance.interceptors.response.use(\n (r) => r,\n async (error) => {\n if (isAxiosError(error)) {\n if (error.response?.status === 401) {\n // If we hit a 401, attempt to login the user and retry with\n // a new access token\n try {\n await this.renewAuthentication()\n\n if (error.config) {\n if (this.accessToken) {\n error.config.headers.Authorization = `Bearer ${this.accessToken}`\n } else {\n delete error.config.headers.Authorization\n }\n return axiosInstance.request(error.config)\n }\n } catch (err) {\n return Promise.reject(err)\n }\n } else if (error.response?.status === 503) {\n // Check if the server as a whole is down\n const res = await fetch(window.location.href)\n if (res.status === 503) {\n // Go to 503 page\n window.location.reload()\n }\n }\n }\n\n return Promise.reject(error)\n },\n )\n }\n\n this.api = new NovaCellAPIClient(cellId, {\n ...config,\n basePath: urlJoin(this.instanceUrl.href, \"/api/v2\"),\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n baseOptions: {\n ...(this.mock\n ? ({\n adapter: (config) => {\n return this.mock!.handleAPIRequest(config)\n },\n } satisfies AxiosRequestConfig)\n : {}),\n ...config.baseOptions,\n },\n axiosInstance,\n })\n }\n\n async renewAuthentication(): Promise<void> {\n if (this.authPromise) {\n // Don't double up\n return\n }\n\n const storedToken = availableStorage.getString(\"wbjs.access_token\")\n if (storedToken && this.accessToken !== storedToken) {\n // Might be newer than the one we have\n this.accessToken = storedToken\n return\n }\n\n // Otherwise, perform login flow\n this.authPromise = loginWithAuth0(this.instanceUrl)\n try {\n this.accessToken = await this.authPromise\n if (this.accessToken) {\n // Cache access token so we don't need to log in every refresh\n availableStorage.setString(\"wbjs.access_token\", this.accessToken)\n } else {\n availableStorage.delete(\"wbjs.access_token\")\n }\n } finally {\n this.authPromise = null\n }\n }\n\n makeWebsocketURL(path: string): string {\n const url = new URL(\n urlJoin(\n this.instanceUrl.href,\n `/api/v2/cells/${this.config.cellId}`,\n path,\n ),\n )\n url.protocol = url.protocol.replace(\"http\", \"ws\")\n url.protocol = url.protocol.replace(\"https\", \"wss\")\n\n // If provided, add basic auth credentials to the URL\n // NOTE - basic auth is deprecated on websockets and doesn't work in Safari\n // use tokens instead\n if (this.accessToken) {\n url.searchParams.append(\"token\", this.accessToken)\n } else if (this.config.username && this.config.password) {\n url.username = this.config.username\n url.password = this.config.password\n }\n\n return url.toString()\n }\n\n /**\n * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.\n * If you explicitly want to reconnect an existing websocket, call `reconnect`\n * on the returned object.\n */\n openReconnectingWebsocket(path: string) {\n return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {\n mock: this.mock,\n })\n }\n}\n","import type { Pose } from \"@wandelbots/nova-api/v2\"\n\n/**\n * Convert a Pose object representing a motion group position\n * into a string which represents that pose in Wandelscript.\n */\nexport function poseToWandelscriptString(\n pose: Pick<Pose, \"position\" | \"orientation\">,\n) {\n const position = [\n pose.position?.[0] ?? 0,\n pose.position?.[1] ?? 0,\n pose.position?.[2] ?? 0,\n ]\n\n const orientation = [\n pose.orientation?.[0] ?? 0,\n pose.orientation?.[1] ?? 0,\n pose.orientation?.[2] ?? 0,\n ]\n\n const positionValues = position.map((v) => v.toFixed(1))\n // Rotation needs more precision since it's in radians\n const rotationValues = orientation.map((v) => v.toFixed(4))\n\n return `(${positionValues.concat(rotationValues).join(\", \")})`\n}\n"],"mappings":";;;;;;;;;;;;;;AAoDA,IAAa,oBAAb,MAA+B;CAC7B,YACE,QACA,MAIA;AALS,OAAA,SAAA;AACA,OAAA,OAAA;gBAkFO,KAAK,2BAA2BA,wBAAAA,UAAU;cAC5C,KAAK,2BAA2BC,wBAAAA,QAAQ;qBAEjC,KAAK,WAAWC,wBAAAA,eAAe;2BAEpD,KAAK,2BAA2BC,wBAAAA,qBAAqB;oBAEjC,KAAK,WAAWC,wBAAAA,cAAc;uBAE3B,KAAK,WAAWC,wBAAAA,2BAA2B;4BAEtC,KAAK,WAAWC,wBAAAA,sBAAsB;6BACrC,KAAK,WAAWC,wBAAAA,uBAAuB;2BACzC,KAAK,WAAWC,wBAAAA,qBAAqB;qBAE3C,KAAK,WAAWC,wBAAAA,eAAe;2BACzB,KAAK,2BAA2BA,wBAAAA,eAAe;iBAEzD,KAAK,WAAWC,wBAAAA,WAAW;oBAExB,KAAK,WAAWC,wBAAAA,cAAc;0BAExB,KAAK,WAAWC,wBAAAA,oBAAoB;2BAEnC,KAAK,WAAWC,wBAAAA,qBAAqB;mCAC7B,KAAK,WACxCC,wBAAAA,6BACD;8BAC+B,KAAK,WACnCC,wBAAAA,kCACD;qBAEsB,KAAK,WAAWC,wBAAAA,eAAe;kCAClB,KAAK,WACvCC,wBAAAA,4BACD;8BAC+B,KAAK,WAAWC,wBAAAA,wBAAwB;;;;;;;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Aa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACF;KACD,KAAK,EACH,UAAU,KACX;KACD,OAAO,EACL,UAAU,KACX;KACD,QAAQ,EACN,UAAU,KACX;KACF;IACD,eAAe;KACb,QAAQ;MACN;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACF;KACD,KAAK,EACH,UAAU,KACX;KACF;IACD,kBAAkB;KAChB,QAAQ;MACN;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACF;KACD,KAAK,EACH,UAAU,KACX;KACF;IACD,kBAAkB;KAChB,QAAQ;MACN;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACD;OACE,UAAU;QACR,aAAa;QACb,aAAa;QACd;OACD,UAAU;OACV,cAAc;OACd,QAAQ;OACT;MACF;KACD,KAAK,EACH,UAAU,KACX;KACF;IACF;GACD,eAAe;GAChB;;CAEJ;;;AClTD,MAAa,+BAA+B;CAC1C,QAAQ;CACR,MAAM;CACN,SAAS;AACP,SAAO;GACL,eAAe;IACb;KACE,OAAO;KACP,OAAO;KACP,GAAG;KACH,GAAG;KACH,4BAA4B;KAC7B;IACD;KACE,OAAO;KACP,OAAO;KACP,GAAG;KACH,GAAG;KACH,4BAA4B;KAC7B;IACD;KACE,OAAO;KACP,OAAO;KACP,GAAG;KACH,GAAG;KACH,4BAA4B;KAC7B;IACD;KACE,OAAO;KACP,OAAO;KACP,GAAG;KACH,GAAG;KACH,4BAA4B;KAC7B;IACD;KACE,OAAO;KACP,OAAO;KACP,GAAG;KACH,GAAG;KACH,4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f,KAAK,WAAW,MAAM;EACtB,KAAK,WAAW,MAAM;EACtB,KAAK,WAAW,MAAM;EACvB;CAED,MAAM,cAAc;EAClB,KAAK,cAAc,MAAM;EACzB,KAAK,cAAc,MAAM;EACzB,KAAK,cAAc,MAAM;EAC1B;CAED,MAAM,iBAAiB,SAAS,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;CAExD,MAAM,iBAAiB,YAAY,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;AAE3D,QAAO,IAAI,eAAe,OAAO,eAAe,CAAC,KAAK,KAAK,CAAC"}
|
package/dist/lib/v2/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as MockNovaInstance, t as AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket-
|
|
1
|
+
import { n as MockNovaInstance, t as AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket-COmdtugu.cjs";
|
|
2
2
|
import { AxiosInstance } from "axios";
|
|
3
3
|
import { ApplicationApi, BUSInputsOutputsApi, CellApi, Configuration, ControllerApi, ControllerInputsOutputsApi, JoggingApi, KinematicsApi, MotionGroupApi, MotionGroupModelsApi, Pose, StoreCollisionComponentsApi, StoreCollisionSetupsApi, StoreObjectApi, SystemApi, TrajectoryCachingApi, TrajectoryExecutionApi, TrajectoryPlanningApi, VirtualControllerApi, VirtualControllerBehaviorApi, VirtualControllerInputsOutputsApi } from "@wandelbots/nova-api/v2";
|
|
4
4
|
export * from "@wandelbots/nova-api/v2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/wandelscriptUtils.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/wandelscriptUtils.ts"],"mappings":";;;;;;KA8BK,Y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AAA,EAAgB,UAAA,CAAA,mBAAA;EAAA,SAEhB,iBAAA,EAAiB,UAAA,CAAA,oBAAA;EAAA,SACjB,yBAAA,EAAyB,UAAA,CAAA,4BAAA;EAAA,SAGzB,oBAAA,EAAoB,UAAA,CAAA,iCAAA;EAAA,SAIpB,WAAA,EAAW,UAAA,CAAA,cAAA;EAAA,SACX,wBAAA,EAAwB,UAAA,CAAA,2BAAA;EAAA,SAGxB,oBAAA,EAAoB,UAAA,CAAA,uBAAA;AAAA;;;KCjKnB,gBAAA;;ADe8B;;;ECVxC,WAAA;EDcY;;;;ECRZ,MAAA;EDOqB;;;;ECDrB,QAAA;EDEM;;;;ECIN,QAAA;EDDG;;;ECMH,WAAA;AAAA,IACE,IAAA,CAAK,aAAA;AAAA,KAEJ,4BAAA,GAA+B,gBAAA;EAAqB,MAAA;AAAA;;;;;cAM5C,UAAA;EAAA,SACF,GAAA,EAAK,iBAAA;EAAA,SACL,MAAA,EAAQ,4BAAA;EAAA,SACR,IAAA,GAAO,gBAAA;EAAA,SACP,WAAA,EAAa,GAAA;EACtB,WAAA,EAAa,OAAA;EACb,WAAA;cAEY,MAAA,EAAQ,gBAAA;EAkGd,mBAAA,CAAA,GAAuB,OAAA;EA4B7B,gBAAA,CAAiB,IAAA;EDlJ+B;;;;;EC+KhD,yBAAA,CAA0B,IAAA,WAAY,yBAAA;AAAA;;;;;;;iBC9MxB,wBAAA,CACd,IAAA,EAAM,IAAA,CAAK,IAAA"}
|
package/dist/lib/v2/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as MockNovaInstance, t as AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket-
|
|
1
|
+
import { n as MockNovaInstance, t as AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket-BgMrjNxO.mjs";
|
|
2
2
|
import { AxiosInstance } from "axios";
|
|
3
3
|
import { ApplicationApi, BUSInputsOutputsApi, CellApi, Configuration, ControllerApi, ControllerInputsOutputsApi, JoggingApi, KinematicsApi, MotionGroupApi, MotionGroupModelsApi, Pose, StoreCollisionComponentsApi, StoreCollisionSetupsApi, StoreObjectApi, SystemApi, TrajectoryCachingApi, TrajectoryExecutionApi, TrajectoryPlanningApi, VirtualControllerApi, VirtualControllerBehaviorApi, VirtualControllerInputsOutputsApi } from "@wandelbots/nova-api/v2";
|
|
4
4
|
export * from "@wandelbots/nova-api/v2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/wandelscriptUtils.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/wandelscriptUtils.ts"],"mappings":";;;;;;KA8BK,YAAA,MAAkB,CAAA,WAAW,CAAA,UAAW,IAAA,6BACrC,IAAA,EAAM,CAAA,KAAM,CAAA;AAAA,KAGf,yBAAA,MAA+B,CAAA,cAAc,CAAA,qBAEzC,CAAA,EAAG,UAAA,CAAW,CAAA,MACd,OAAA,CAAQ,OAAA,CAAQ,UAAA,CAAW,CAAA;EAAc,IAAA;AAAA,IAAkB,CAAA;AAAA,KAGxD,UAAA,oBACE,CAAA,GAAI,yBAAA,CAA0B,YAAA,CAAa,CAAA,CAAE,CAAA;AAAA,KAG/C,0BAAA,oBACE,CAAA,GAAI,yBAAA,CAA0B,CAAA,CAAE,CAAA;;;;;cAOjC,iBAAA;EAAA,SAEA,MAAA;EAAA,SACA,IAAA,EAAM,aAAA;IACb,aAAA,GAAgB,aAAA;IAChB,IAAA;EAAA;cAHO,MAAA,UACA,IAAA,EAAM,aAAA;IACb,aAAA,GAAgB,aAAA;IAChB,IAAA;EAAA;EAvB8B;;;;;EAAA,QAgC1B,UAAA;EA7BD;;;EAAA,QAkEC,0BAAA;EAAA,SAkCC,MAAA,EAAM,0BAAA,C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Aa,OAAA;EACb,WAAA;cAEY,MAAA,EAAQ,gBAAA;EAkGd,mBAAA,CAAA,GAAuB,OAAA;EA4B7B,gBAAA,CAAiB,IAAA;EDlJ+B;;;;;EC+KhD,yBAAA,CAA0B,IAAA,WAAY,yBAAA;AAAA;;;;;;;iBC9MxB,wBAAA,CACd,IAAA,EAAM,IAAA,CAAK,IAAA"}
|
package/dist/lib/v2/index.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { m as AutoReconnectingWebsocket, n as loginWithAuth0, p as availableStorage, s as parseNovaInstanceUrl } from "../../LoginWithAuth0-
|
|
1
|
+
import { m as AutoReconnectingWebsocket, n as loginWithAuth0, p as availableStorage, s as parseNovaInstanceUrl } from "../../LoginWithAuth0-CEUVGw1-.mjs";
|
|
2
2
|
import axios, { AxiosError, isAxiosError } from "axios";
|
|
3
3
|
import urlJoin from "url-join";
|
|
4
4
|
import * as pathToRegexp from "path-to-regexp";
|
|
5
5
|
import { ApplicationApi, BUSInputsOutputsApi, CellApi, ControllerApi, ControllerInputsOutputsApi, JoggingApi, KinematicsApi, MotionGroupApi, MotionGroupModelsApi, StoreCollisionComponentsApi, StoreCollisionSetupsApi, StoreObjectApi, SystemApi, TrajectoryCachingApi, TrajectoryExecutionApi, TrajectoryPlanningApi, VirtualControllerApi, VirtualControllerBehaviorApi, VirtualControllerInputsOutputsApi } from "@wandelbots/nova-api/v2";
|
|
6
|
-
|
|
7
|
-
export * from "@wandelbots/nova-api/v2"
|
|
8
|
-
|
|
6
|
+
export * from "@wandelbots/nova-api/v2";
|
|
9
7
|
//#region src/lib/v2/NovaCellAPIClient.ts
|
|
10
8
|
/**
|
|
11
9
|
* API client providing type-safe access to all the Nova API REST endpoints
|
|
@@ -75,7 +73,6 @@ var NovaCellAPIClient = class {
|
|
|
75
73
|
return apiClient;
|
|
76
74
|
}
|
|
77
75
|
};
|
|
78
|
-
|
|
79
76
|
//#endregion
|
|
80
77
|
//#region src/lib/v2/mock/getCurrentRobotControllerState.ts
|
|
81
78
|
const getCurrentRobotControllerState = {
|
|
@@ -153,7 +150,6 @@ const getCurrentRobotControllerState = {
|
|
|
153
150
|
};
|
|
154
151
|
}
|
|
155
152
|
};
|
|
156
|
-
|
|
157
153
|
//#endregion
|
|
158
154
|
//#region src/lib/v2/mock/getMotionGroupDescription.ts
|
|
159
155
|
const getMotionGroupDescription = {
|
|
@@ -465,7 +461,6 @@ const getMotionGroupDescription = {
|
|
|
465
461
|
};
|
|
466
462
|
}
|
|
467
463
|
};
|
|
468
|
-
|
|
469
464
|
//#endregion
|
|
470
465
|
//#region src/lib/v2/mock/getMotionGroupKinematicModel.ts
|
|
471
466
|
const getMotionGroupKinematicModel = {
|
|
@@ -521,7 +516,6 @@ const getMotionGroupKinematicModel = {
|
|
|
521
516
|
};
|
|
522
517
|
}
|
|
523
518
|
};
|
|
524
|
-
|
|
525
519
|
//#endregion
|
|
526
520
|
//#region src/lib/v2/mock/getRobotController.ts
|
|
527
521
|
const getRobotController = {
|
|
@@ -539,7 +533,6 @@ const getRobotController = {
|
|
|
539
533
|
};
|
|
540
534
|
}
|
|
541
535
|
};
|
|
542
|
-
|
|
543
536
|
//#endregion
|
|
544
537
|
//#region src/lib/v2/mock/listCoordinateSystems.ts
|
|
545
538
|
const listCoordinateSystems = {
|
|
@@ -579,7 +572,6 @@ const listCoordinateSystems = {
|
|
|
579
572
|
}];
|
|
580
573
|
}
|
|
581
574
|
};
|
|
582
|
-
|
|
583
575
|
//#endregion
|
|
584
576
|
//#region src/lib/v2/mock/listRobotControllers.ts
|
|
585
577
|
const listRobotControllers = {
|
|
@@ -589,7 +581,6 @@ const listRobotControllers = {
|
|
|
589
581
|
return ["mock-ur5e"];
|
|
590
582
|
}
|
|
591
583
|
};
|
|
592
|
-
|
|
593
584
|
//#endregion
|
|
594
585
|
//#region src/lib/v2/mock/MockNovaInstance.ts
|
|
595
586
|
/**
|
|
@@ -688,9 +679,9 @@ const defaultMotionState = { result: {
|
|
|
688
679
|
-1.7542521568325058,
|
|
689
680
|
.7326972590614671
|
|
690
681
|
]
|
|
691
|
-
}
|
|
682
|
+
},
|
|
683
|
+
description_revision: 0
|
|
692
684
|
} };
|
|
693
|
-
|
|
694
685
|
//#endregion
|
|
695
686
|
//#region src/lib/v2/NovaClient.ts
|
|
696
687
|
/**
|
|
@@ -745,8 +736,8 @@ var NovaClient = class {
|
|
|
745
736
|
return mime === "application/json";
|
|
746
737
|
},
|
|
747
738
|
baseOptions: {
|
|
748
|
-
...this.mock ? { adapter: (config
|
|
749
|
-
return this.mock.handleAPIRequest(config
|
|
739
|
+
...this.mock ? { adapter: (config) => {
|
|
740
|
+
return this.mock.handleAPIRequest(config);
|
|
750
741
|
} } : {},
|
|
751
742
|
...config.baseOptions
|
|
752
743
|
},
|
|
@@ -789,7 +780,6 @@ var NovaClient = class {
|
|
|
789
780
|
return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), { mock: this.mock });
|
|
790
781
|
}
|
|
791
782
|
};
|
|
792
|
-
|
|
793
783
|
//#endregion
|
|
794
784
|
//#region src/lib/v2/wandelscriptUtils.ts
|
|
795
785
|
/**
|
|
@@ -811,7 +801,7 @@ function poseToWandelscriptString(pose) {
|
|
|
811
801
|
const rotationValues = orientation.map((v) => v.toFixed(4));
|
|
812
802
|
return `(${positionValues.concat(rotationValues).join(", ")})`;
|
|
813
803
|
}
|
|
814
|
-
|
|
815
804
|
//#endregion
|
|
816
805
|
export { NovaCellAPIClient, NovaClient, poseToWandelscriptString };
|
|
806
|
+
|
|
817
807
|
//# sourceMappingURL=index.mjs.map
|