@wandelbots/nova-js 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["lastMotionIds: Set<string>","newTrajectories: GetTrajectoryResponse[]","nova: NovaClient","tryParseJson","AxiosError"],"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,IAAIA,gCAA6B,IAAI,KAAK;AAE1C,eAAsB,sBACpB,WACA,aAAqB,IACrB,2BACkC;CAClC,MAAMC,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,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E,MAAM;IACS;IAEf,eAAe,aAAa;IAC7B,EACD,EACE,SAAS,EACP,gBAAgB,oBACjB,EACF,CACF;AAED,QAAK,IAAI,0BAA0B,iBAAiB,GAAG,GAAG;AAC1D,+BAAkB;AAChB,SAAK,iBAAiB;KACtB;AACF,QAAK,oCAAoC,iBAAiB;WACnD,OAAO;AACd,OAAI,iBAAiBC,oBAAc,MAAM,YAAY,MAAM,QACzD,MAAK,SACH,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM,SAAS,WAAW,QAAQ,MAAM,SAAS,OAAO,IAAI,GAAG,KAAK,UAAU,MAAM,SAAS,KAAK,GAC/H;OAED,MAAK,SAAS,KAAK,UAAU,MAAM,CAAC;AAEtC,+BAAkB;AAChB,SAAK,iBAAiB;KACtB;;;CAIN,MAAM,cAAc;AAClB,MAAI,CAAC,KAAK,kCAAmC;AAC7C,8BAAkB;AAChB,QAAK,iBAAiB;IACtB;AAEF,MAAI;AACF,SAAM,KAAK,KAAK,IAAI,QAAQ,kBAC1B,KAAK,kCACN;WACM,KAAK;AAEZ,+BAAkB;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.cjs","names":["tryParseJson","AxiosError"],"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,+BAAmB,MAAM,EAAE,EAAE,EAAE,UAAU,MAAM,CAAC;AAEhD,OAAK,qBAAqB,KAAK,0BAA0B,kBAAkB;AAE3E,OAAK,mBAAmB,iBAAiB,YAAY,OAAO;GAC1D,MAAM,M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M,CAAC;AAEtC,+BAAkB;AAChB,SAAK,iBAAiB;KACtB;;;CAIN,MAAM,cAAc;AAClB,MAAI,CAAC,KAAK,kCAAmC;AAC7C,8BAAkB;AAChB,QAAK,iBAAiB;IACtB;AAEF,MAAI;AACF,SAAM,KAAK,KAAK,IAAI,QAAQ,kBAC1B,KAAK,kCACN;WACM,KAAK;AAEZ,+BAAkB;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 +1 @@
1
- {"version":3,"file":"index.mjs","names":["lastMotionIds: Set<string>","newTrajectories: GetTrajectoryResponse[]","nova: NovaClient"],"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 timestam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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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Ae,aAAa;IAC7B,EACD,EACE,SAAS,EACP,gBAAgB,oBACjB,EACF,CACF;AAED,QAAK,IAAI,0BAA0B,iBAAiB,GAAG,GAAG;AAC1D,qBAAkB;AAChB,SAAK,iBAAiB;KACtB;AACF,QAAK,oCAAoC,iBAAiB;WACnD,OAAO;AACd,OAAI,iBAAiB,cAAc,MAAM,YAAY,MAAM,QACzD,MAAK,SACH,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM,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 +1 @@
1
- {"version":3,"file":"index.cjs","names":["cellId: string","opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n }","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/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 = this.withCellId(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","/** biome-ignore-all lint/suspicious/noApproximativeNumericConstant: mock data contains approximative pi values from robot description */\nimport type { MotionGroupState, RobotController } 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\"\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 {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return [\"mock-ur5e\"]\n },\n },\n {\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 {\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 {\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 {\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 ] //satisfies CoordinateSystems\n },\n },\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n const path = `/cells${config.url?.split(\"/cells\")[1]?.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 // return {\n // status: 404,\n // statusText: \"Not Found\",\n // data: \"\",\n // headers: {},\n // config,\n // request: {\n // responseURL: config.url,\n // },\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,AAASA,QACT,AAASC,MAIT;EALS;EACA;gBAkFO,KAAK,2BAA2BC,kCAAU;cAC5C,KAAK,2BAA2BC,gCAAQ;qBAEjC,KAAK,WAAWC,uCAAe;2BACzB,KAAK,WAAWC,6CAAqB;oBAE5C,KAAK,WAAWC,sCAAc;uBAE3B,KAAK,WAAWC,mDAA2B;4BAEtC,KAAK,WAAWC,8CAAsB;6BACrC,KA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M;QACJ,UAAU;SAAC;SAAG;SAAG;SAAE;QACnB,aAAa;SAAC;SAAG;SAAG;SAAE;QACvB;OACF,EACF;MACD,UAAU,EACR,UAAU;OACR,MAAM;OACN,SAAS;OACT,gBAAgB;QAAC;QAAG;QAAG;QAAE;OACzB,mBAAmB;QAAC;QAAG;QAAG;QAAE;OAC7B,EACF;MACD,YAAY;MACZ,eAAe;OACb;QACE,OAAO;QACP,GAAG;QACJ;OACD,EACE,GAAG,MACJ;OACD,EACE,GAAG,QACJ;OACD;QACE,OAAO;QACP,GAAG;QACJ;OACD;QACE,OAAO;QACP,GAAG;QACJ;OACD,EACE,GAAG,MACJ;OACF;MACD,kBAAkB;OAChB,aAAa;QACX,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACD,OAAO,EACL,UAAU,KACX;QACD,QAAQ,EACN,UAAU,KACX;QACF;OACD,eAAe;QACb,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD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Api","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/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 = this.withCellId(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","/** biome-ignore-all lint/suspicious/noApproximativeNumericConstant: mock data contains approximative pi values from robot description */\nimport type { MotionGroupState, RobotController } 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\"\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 {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return [\"mock-ur5e\"]\n },\n },\n {\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 {\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 {\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 {\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 ] //satisfies CoordinateSystems\n },\n },\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n const path = `/cells${config.url?.split(\"/cells\")[1]?.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 // return {\n // status: 404,\n // statusText: \"Not Found\",\n // data: \"\",\n // headers: {},\n // config,\n // request: {\n // responseURL: config.url,\n // },\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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U;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WAC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AE,CAAC;AAE3D,QAAO,IAAI,eAAe,OAAO,eAAe,CAAC,KAAK,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["cellId: string","opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n }","config"],"sources":["../../../src/lib/v2/NovaCellAPIClient.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 = this.withCellId(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","/** biome-ignore-all lint/suspicious/noApproximativeNumericConstant: mock data contains approximative pi values from robot description */\nimport type { MotionGroupState, RobotController } 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\"\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 {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return [\"mock-ur5e\"]\n },\n },\n {\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 {\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 {\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 {\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 ] //satisfies CoordinateSystems\n },\n },\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n const path = `/cells${config.url?.split(\"/cells\")[1]?.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 // return {\n // status: 404,\n // statusText: \"Not Found\",\n // data: \"\",\n // headers: {},\n // config,\n // request: {\n // responseURL: config.url,\n // },\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,AAASA,QACT,AAASC,MAIT;EALS;EACA;gBAkFO,KAAK,2BAA2B,UAAU;cAC5C,KAAK,2BAA2B,QAAQ;qBAEjC,KAAK,WAAW,eAAe;2BACzB,KAAK,WAAW,qBAAqB;oBAE5C,KAAK,WAAW,cAAc;uBAE3B,KAAK,WAAW,2BAA2B;4BAEtC,KAAK,WAAW,sBA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,UAAU;SAAC;SAAG;SAAG;SAAE;QACnB,aAAa;SAAC;SAAG;SAAG;SAAE;QACvB;OACF,EACF;MACD,UAAU,EACR,UAAU;OACR,MAAM;OACN,SAAS;OACT,gBAAgB;QAAC;QAAG;QAAG;QAAE;OACzB,mBAAmB;QAAC;QAAG;QAAG;QAAE;OAC7B,EACF;MACD,YAAY;MACZ,eAAe;OACb;QACE,OAAO;QACP,GAAG;QACJ;OACD,EACE,GAAG,MACJ;OACD,EACE,GAAG,QACJ;OACD;QACE,OAAO;QACP,GAAG;QACJ;OACD;QACE,OAAO;QACP,GAAG;QACJ;OACD,EACE,GAAG,MACJ;OACF;MACD,kBAAkB;OAChB,aAAa;QACX,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACD,OAAO,EACL,UAAU,KACX;QACD,QAAQ,EACN,UAAU,KACX;QACF;OACD,eAAe;QACb,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,U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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 = this.withCellId(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","/** biome-ignore-all lint/suspicious/noApproximativeNumericConstant: mock data contains approximative pi values from robot description */\nimport type { MotionGroupState, RobotController } 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\"\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 {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return [\"mock-ur5e\"]\n },\n },\n {\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 {\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 {\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 {\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 ] //satisfies CoordinateSystems\n },\n },\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n const path = `/cells${config.url?.split(\"/cells\")[1]?.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 // return {\n // status: 404,\n // statusText: \"Not Found\",\n // data: \"\",\n // headers: {},\n // config,\n // request: {\n // responseURL: config.url,\n // },\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,2BAA2B,UAAU;cAC5C,KAAK,2BAA2B,QAAQ;qBAEjC,KAAK,WAAW,eAAe;2BACzB,KAAK,WAAW,qBAAqB;oBAE5C,KAAK,WAAW,cAAc;uBAE3B,KAAK,WAAW,2BAA2B;4BAEtC,KAAK,WAAW,sBAAsB;6BACrC,KAAK,WAAW,uBAAuB;2BACzC,KAAK,WAAW,qBAAqB;qBAE3C,KAAK,WAAW,eAAe;2BACzB,KAAK,2BAA2B,eAAe;iBAEzD,KAAK,WAAW,WAAW;oBAExB,KAAK,WAAW,cAAc;0BAExB,KAAK,WAAW,oBAAoB;2BAEnC,KAAK,WA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ACF;MACD,YAAY;MACZ,eAAe;OACb;QACE,OAAO;QACP,GAAG;QACJ;OACD,EACE,GAAG,MACJ;OACD,EACE,GAAG,QACJ;OACD;QACE,OAAO;QACP,GAAG;QACJ;OACD;QACE,OAAO;QACP,GAAG;QACJ;OACD,EACE,GAAG,MACJ;OACF;MACD,kBAAkB;OAChB,aAAa;QACX,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACD,OAAO,EACL,UAAU,KACX;QACD,QAAQ,EACN,UAAU,KACX;QACF;OACD,eAAe;QACb,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACF;MACD,eAAe;MAChB;;I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;YAEtC;AACR,QAAK,cAAc;;;CAIvB,iBAAiB,MAAsB;EACrC,MAAM,MAAM,IAAI,IACd,QACE,KAAK,YAAY,MACjB,iBAAiB,KAAK,OAAO,UAC7B,KACD,CACF;AACD,MAAI,WAAW,IAAI,SAAS,QAAQ,QAAQ,KAAK;AACjD,MAAI,WAAW,IAAI,SAAS,QAAQ,SAAS,MAAM;AAKnD,MAAI,KAAK,YACP,KAAI,aAAa,OAAO,SAAS,KAAK,YAAY;WACzC,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,IAAI,0BAA0B,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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wandelbots/nova-js",
3
3
  "type": "module",
4
- "version": "3.4.0",
4
+ "version": "3.4.1",
5
5
  "description": "Official JS client for the Wandelbots API",
6
6
  "sideEffects": false,
7
7
  "packageManager": "pnpm@10.19.0",
@@ -50,16 +50,16 @@
50
50
  "@biomejs/biome": "^2.3.11",
51
51
  "@types/lodash-es": "^4.17.12",
52
52
  "knip": "^5.76.3",
53
- "lodash-es": "^4.17.21",
54
- "nodemon": "^3.1.9",
53
+ "lodash-es": "^4.17.22",
54
+ "nodemon": "^3.1.11",
55
55
  "semantic-release": "^25.0.2",
56
- "tsdown": "^0.18.2",
56
+ "tsdown": "^0.19.0",
57
57
  "typescript": "^5.9.3",
58
- "vitest": "^4.0.8",
59
- "ws": "^8.18.1"
58
+ "vitest": "^4.0.17",
59
+ "ws": "^8.19.0"
60
60
  },
61
61
  "dependencies": {
62
- "@auth0/auth0-spa-js": "^2.11.0",
62
+ "@auth0/auth0-spa-js": "^2.11.2",
63
63
  "@types/three": "^0.182.0",
64
64
  "@wandelbots/nova-api": "^25.10.0",
65
65
  "axios": "^1.13.2",