@wandelbots/nova-js 3.7.0-pr.267.ffc5d9d → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,196 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_LoginWithAuth0 = require("../../LoginWithAuth0-oZFpwe7m.cjs");
3
+ const require_NovaClient = require("../../NovaClient-B-QdK0HR.cjs");
4
+ let axios = require("axios");
5
+ let mobx = require("mobx");
6
+ //#region src/lib/v1/getLatestTrajectories.ts
7
+ let lastMotionIds = /* @__PURE__ */ new Set();
8
+ async function getLatestTrajectories(apiClient, sampleTime = 50, responsesCoordinateSystem) {
9
+ const newTrajectories = [];
10
+ try {
11
+ const motions = await apiClient.motion.listMotions();
12
+ const currentMotionIds = new Set(motions.motions);
13
+ const newMotionIds = Array.from(currentMotionIds).filter((id) => !lastMotionIds.has(id));
14
+ for (const motionId of newMotionIds) {
15
+ const trajectory = await apiClient.motion.getMotionTrajectory(motionId, sampleTime, responsesCoordinateSystem);
16
+ newTrajectories.push(trajectory);
17
+ }
18
+ lastMotionIds = currentMotionIds;
19
+ } catch (error) {
20
+ console.error("Failed to get latest trajectories:", error);
21
+ }
22
+ return newTrajectories;
23
+ }
24
+ //#endregion
25
+ //#region src/lib/v1/ProgramStateConnection.ts
26
+ let ProgramState = /* @__PURE__ */ function(ProgramState) {
27
+ ProgramState["NotStarted"] = "not started";
28
+ ProgramState["Running"] = "running";
29
+ ProgramState["Stopped"] = "stopped";
30
+ ProgramState["Failed"] = "failed";
31
+ ProgramState["Completed"] = "completed";
32
+ return ProgramState;
33
+ }({});
34
+ /**
35
+ * Interface for running Wandelscript programs on the Nova instance and
36
+ * tracking their progress and output
37
+ */
38
+ var ProgramStateConnection = class {
39
+ constructor(nova) {
40
+ this.nova = nova;
41
+ this.currentProgram = {};
42
+ this.logs = [];
43
+ this.executionState = "idle";
44
+ this.currentlyExecutingProgramRunnerId = null;
45
+ (0, mobx.makeAutoObservable)(this, {}, { autoBind: true });
46
+ this.programStateSocket = nova.openReconnectingWebsocket(`/programs/state`);
47
+ this.programStateSocket.addEventListener("message", (ev) => {
48
+ const msg = require_LoginWithAuth0.tryParseJson(ev.data);
49
+ if (!msg) {
50
+ console.error("Failed to parse program state message", ev.data);
51
+ return;
52
+ }
53
+ if (msg.type === "update") this.handleProgramStateMessage(msg);
54
+ });
55
+ }
56
+ /** Handle a program state update from the backend */
57
+ async handleProgramStateMessage(msg) {
58
+ const { runner } = msg;
59
+ if (runner.id !== this.currentlyExecutingProgramRunnerId) return;
60
+ if (runner.state === "failed") {
61
+ try {
62
+ const runnerState = await this.nova.api.program.getProgramRunner(runner.id);
63
+ const stdout = runnerState.stdout;
64
+ if (stdout) this.log(stdout);
65
+ this.logError(`Program runner ${runner.id} failed with error: ${runnerState.error}\n${runnerState.traceback}`);
66
+ } catch (err) {
67
+ this.logError(`Failed to retrieve results for program ${runner.id}: ${err}`);
68
+ }
69
+ this.currentProgram.state = "failed";
70
+ this.gotoIdleState();
71
+ } else if (runner.state === "stopped") {
72
+ try {
73
+ const stdout = (await this.nova.api.program.getProgramRunner(runner.id)).stdout;
74
+ if (stdout) this.log(stdout);
75
+ this.currentProgram.state = "stopped";
76
+ this.log(`Program runner ${runner.id} stopped`);
77
+ } catch (err) {
78
+ this.logError(`Failed to retrieve results for program ${runner.id}: ${err}`);
79
+ }
80
+ this.gotoIdleState();
81
+ } else if (runner.state === "completed") {
82
+ try {
83
+ const stdout = (await this.nova.api.program.getProgramRunner(runner.id)).stdout;
84
+ if (stdout) this.log(stdout);
85
+ this.log(`Program runner ${runner.id} finished successfully in ${runner.execution_time?.toFixed(2)} seconds`);
86
+ this.currentProgram.state = "completed";
87
+ } catch (err) {
88
+ this.logError(`Failed to retrieve results for program ${runner.id}: ${err}`);
89
+ }
90
+ this.gotoIdleState();
91
+ } else if (runner.state === "running") {
92
+ this.currentProgram.state = "running";
93
+ this.log(`Program runner ${runner.id} now running`);
94
+ } else if (runner.state !== "not started") {
95
+ console.error(runner);
96
+ this.logError(`Program runner ${runner.id} entered unexpected state: ${runner.state}`);
97
+ this.currentProgram.state = "not started";
98
+ this.gotoIdleState();
99
+ }
100
+ }
101
+ /** Call when a program is no longer executing */
102
+ gotoIdleState() {
103
+ (0, mobx.runInAction)(() => {
104
+ this.executionState = "idle";
105
+ });
106
+ this.currentlyExecutingProgramRunnerId = null;
107
+ }
108
+ async executeProgram(wandelscript, initial_state, activeRobot) {
109
+ this.currentProgram = {
110
+ wandelscript,
111
+ state: "not started"
112
+ };
113
+ const { currentProgram: openProgram } = this;
114
+ if (!openProgram) return;
115
+ (0, mobx.runInAction)(() => {
116
+ this.executionState = "starting";
117
+ });
118
+ if (activeRobot) try {
119
+ await this.nova.api.motionGroupJogging.stopJogging(activeRobot.motionGroupId);
120
+ } catch (err) {
121
+ console.error(err);
122
+ }
123
+ const trimmedCode = openProgram.wandelscript.replaceAll(/^\s*$/gm, "");
124
+ try {
125
+ const programRunnerRef = await this.nova.api.program.createProgramRunner({
126
+ code: trimmedCode,
127
+ initial_state,
128
+ default_robot: activeRobot?.wandelscriptIdentifier
129
+ }, { headers: { "Content-Type": "application/json" } });
130
+ this.log(`Created program runner ${programRunnerRef.id}"`);
131
+ (0, mobx.runInAction)(() => {
132
+ this.executionState = "executing";
133
+ });
134
+ this.currentlyExecutingProgramRunnerId = programRunnerRef.id;
135
+ } catch (error) {
136
+ if (error instanceof axios.AxiosError && error.response && error.request) this.logError(`${error.response.status} ${error.response.statusText} from ${error.response.config.url} ${JSON.stringify(error.response.data)}`);
137
+ else this.logError(JSON.stringify(error));
138
+ (0, mobx.runInAction)(() => {
139
+ this.executionState = "idle";
140
+ });
141
+ }
142
+ }
143
+ async stopProgram() {
144
+ if (!this.currentlyExecutingProgramRunnerId) return;
145
+ (0, mobx.runInAction)(() => {
146
+ this.executionState = "stopping";
147
+ });
148
+ try {
149
+ await this.nova.api.program.stopProgramRunner(this.currentlyExecutingProgramRunnerId);
150
+ } catch (err) {
151
+ (0, mobx.runInAction)(() => {
152
+ this.executionState = "executing";
153
+ });
154
+ throw err;
155
+ }
156
+ }
157
+ reset() {
158
+ this.currentProgram = {};
159
+ }
160
+ log(message) {
161
+ console.log(message);
162
+ this.logs.push({
163
+ timestamp: Date.now(),
164
+ message
165
+ });
166
+ }
167
+ logError(message) {
168
+ console.log(message);
169
+ this.logs.push({
170
+ timestamp: Date.now(),
171
+ message,
172
+ level: "error"
173
+ });
174
+ }
175
+ };
176
+ //#endregion
177
+ exports.ConnectedMotionGroup = require_NovaClient.ConnectedMotionGroup;
178
+ exports.JoggerConnection = require_NovaClient.JoggerConnection;
179
+ exports.MotionStreamConnection = require_NovaClient.MotionStreamConnection;
180
+ exports.NovaCellAPIClient = require_NovaClient.NovaCellAPIClient;
181
+ exports.NovaClient = require_NovaClient.NovaClient;
182
+ exports.ProgramState = ProgramState;
183
+ exports.ProgramStateConnection = ProgramStateConnection;
184
+ exports.getLatestTrajectories = getLatestTrajectories;
185
+ exports.poseToWandelscriptString = require_NovaClient.poseToWandelscriptString;
186
+ var _wandelbots_nova_api_v1 = require("@wandelbots/nova-api/v1");
187
+ Object.keys(_wandelbots_nova_api_v1).forEach(function(k) {
188
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
189
+ enumerable: true,
190
+ get: function() {
191
+ return _wandelbots_nova_api_v1[k];
192
+ }
193
+ });
194
+ });
195
+
196
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
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,IAAI;AAEzC,eAAsB,sBACpB,WACA,aAAqB,IACrB,2BACkC;CAClC,MAAM,kBAA2C,CAAC;CAElD,IAAI;EACF,MAAM,UAAU,MAAM,UAAU,OAAO,YAAY;EACnD,MAAM,mBAAmB,IAAI,IAAI,QAAQ,OAAO;EAEhD,MAAM,eAAe,MAAM,KAAK,gBAAgB,EAAE,QAC/C,OAAO,CAAC,cAAc,IAAI,EAAE,CAC/B;EAEA,KAAK,MAAM,YAAY,cAAc;GACnC,MAAM,aAAa,MAAM,UAAU,OAAO,oBACxC,UACA,YACA,yBACF;GACA,gBAAgB,KAAK,UAAU;EACjC;EAEA,gBAAgB;CAClB,SAAS,OAAO;EACd,QAAQ,MAAM,sCAAsC,KAAK;CAC3D;CAEA,OAAO;AACT;;;ACpBA,IAAY,eAAL,yBAAA,cAAA;CACL,aAAA,gBAAA;CACA,aAAA,aAAA;CACA,aAAA,aAAA;CACA,aAAA,YAAA;CACA,aAAA,eAAA;;AACF,EAAA,CAAA,CAAA;;;;;AAsBA,IAAa,yBAAb,MAAoC;CASlC,YAAY,MAA2B;EAAlB,KAAA,OAAA;wBARY,CAAC;cACF,CAAC;wBAEhB;2CACmB;EAKlC,CAAA,GAAA,KAAA,oBAAmB,MAAM,CAAC,GAAG,EAAE,UA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K,oCAAoC,iBAAiB;EAC5D,SAAS,OAAO;GACd,IAAI,iBAAiBC,MAAAA,cAAc,MAAM,YAAY,MAAM,SACzD,KAAK,SACH,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM,SAAS,WAAW,QAAQ,MAAM,SAAS,OAAO,IAAI,GAAG,KAAK,UAAU,MAAM,SAAS,IAAI,GAC/H;QAEA,KAAK,SAAS,KAAK,UAAU,KAAK,CAAC;GAErC,CAAA,GAAA,KAAA,mBAAkB;IAChB,KAAK,iBAAiB;GACxB,CAAC;EACH;CACF;CAEA,MAAM,cAAc;EAClB,IAAI,CAAC,KAAK,mCAAmC;EAC7C,CAAA,GAAA,KAAA,mBAAkB;GAChB,KAAK,iBAAiB;EACxB,CAAC;EAED,IAAI;GACF,MAAM,KAAK,KAAK,IAAI,QAAQ,kBAC1B,KAAK,iCACP;EACF,SAAS,KAAK;GAEZ,CAAA,GAAA,KAAA,mBAAkB;IAChB,KAAK,iBAAiB;GACxB,CAAC;GACD,MAAM;EACR;CACF;CAEA,QAAQ;EACN,KAAK,iBAAiB,CAAC;CACzB;CAEA,IAAI,SAAiB;EACnB,QAAQ,IAAI,OAAO;EACnB,KAAK,KAAK,KAAK;GACb,WAAW,KAAK,IAAI;GACpB;EACF,CAAC;CACH;CAEA,SAAS,SAAiB;EACxB,QAAQ,IAAI,OAAO;EACnB,KAAK,KAAK,KAAK;GACb,WAAW,KAAK,IAAI;GACpB;GACA,OAAO;EACT,CAAC;CACH;AACF"}
@@ -0,0 +1,62 @@
1
+ import { t as AutoReconnectingWebsocket } from "../../AutoReconnectingWebsocket-9Of5_BJe.cjs";
2
+ import { a as WithUnwrappedAxiosResponse, c as MotionStreamConnection, d as poseToWandelscriptString, i as WithCellId, l as ConnectedMotionGroup, n as NovaClientConfig, o as JoggerConnection, r as NovaCellAPIClient, s as JoggerConnectionOpts, t as NovaClient, u as MotionGroupOption } from "../../NovaClient-4PG1cMau.cjs";
3
+ import { CollectionValue, GetTrajectoryResponse } from "@wandelbots/nova-api/v1";
4
+ export * from "@wandelbots/nova-api/v1";
5
+
6
+ //#region src/lib/v1/getLatestTrajectories.d.ts
7
+ declare function getLatestTrajectories(apiClient: NovaCellAPIClient, sampleTime?: number, responsesCoordinateSystem?: string): Promise<GetTrajectoryResponse[]>;
8
+ //#endregion
9
+ //#region src/lib/v1/ProgramStateConnection.d.ts
10
+ type ProgramRunnerLogEntry = {
11
+ timestamp: number;
12
+ message: string;
13
+ level?: "warn" | "error";
14
+ };
15
+ declare enum ProgramState {
16
+ NotStarted = "not started",
17
+ Running = "running",
18
+ Stopped = "stopped",
19
+ Failed = "failed",
20
+ Completed = "completed"
21
+ }
22
+ type CurrentProgram = {
23
+ id?: string;
24
+ wandelscript?: string;
25
+ state?: ProgramState;
26
+ };
27
+ type ProgramStateMessage = {
28
+ type: string;
29
+ runner: {
30
+ id: string;
31
+ state: ProgramState;
32
+ start_time?: number | null;
33
+ execution_time?: number | null;
34
+ };
35
+ };
36
+ /**
37
+ * Interface for running Wandelscript programs on the Nova instance and
38
+ * tracking their progress and output
39
+ */
40
+ declare class ProgramStateConnection {
41
+ readonly nova: NovaClient;
42
+ currentProgram: CurrentProgram;
43
+ logs: ProgramRunnerLogEntry[];
44
+ executionState: "idle" | "starting" | "executing" | "stopping";
45
+ currentlyExecutingProgramRunnerId: string | null;
46
+ programStateSocket: AutoReconnectingWebsocket;
47
+ constructor(nova: NovaClient);
48
+ /** Handle a program state update from the backend */
49
+ handleProgramStateMessage(msg: ProgramStateMessage): Promise<void>;
50
+ /** Call when a program is no longer executing */
51
+ gotoIdleState(): void;
52
+ executeProgram(wandelscript: string, initial_state?: {
53
+ [key: string]: CollectionValue;
54
+ }, activeRobot?: MotionStreamConnection): Promise<void>;
55
+ stopProgram(): Promise<void>;
56
+ reset(): void;
57
+ log(message: string): void;
58
+ logError(message: string): void;
59
+ }
60
+ //#endregion
61
+ export { ConnectedMotionGroup, CurrentProgram, JoggerConnection, JoggerConnectionOpts, MotionGroupOption, MotionStreamConnection, NovaCellAPIClient, NovaClient, NovaClientConfig, ProgramRunnerLogEntry, ProgramState, ProgramStateConnection, WithCellId, WithUnwrappedAxiosResponse, getLatestTrajectories, poseToWandelscriptString };
62
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/lib/v1/getLatestTrajectories.ts","../../../src/lib/v1/ProgramStateConnection.ts"],"mappings":";;;;;;iBAKsB,qBAAA,CACpB,SAAA,EAAW,iBAAA,EACX,UAAA,WACA,yBAAA,YACC,OAAA,CAAQ,qBAAA;;;KCAC,qBAAA;EACV,SAAA;EACA,OAAA;EACA,KAAA;AAAA;AAAA,aAGU,YAAA;EACV,UAAA;EACA,OAAA;EACA,OAAA;EACA,MAAA;EACA,SAAA;AAAA;AAAA,KAGU,cAAA;EACV,EAAA;EACA,YAAA;EACA,KAAA,GAAQ,YAAY;AAAA;AAAA,KAGjB,mBAAA;EACH,IAAA;EACA,MAAA;IACE,EAAA;IACA,KAAA,EAAO,YAAY;IACnB,UAAA;IACA,cAAA;EAAA;AAAA;;;;AAvBG;cA+BM,sBAAA;EAAA,SASU,IAAA,EAAM,UAAA;EAR3B,cAAA,EAAgB,cAAA;EAChB,IAAA,EAAM,qBAAA;EAEN,cAAA;EACA,iCAAA;EAEA,kBAAA,EAAoB,yBAAA;cAEC,IAAA,EAAM,UAAA;EAhC3B;EAmDM,yBAAA,CAA0B,GAAA,EAAK,mBAAA,GAAmB,OAAA;EAnD/C;EA0IT,aAAA,CAAA;EAOM,cAAA,CACJ,YAAA,UACA,aAAA;IAAA,CAAmB,GAAA,WAAc,eAAA;EAAA,GACjC,WAAA,GAAc,sBAAA,GAAsB,OAAA;EA8DhC,WAAA,CAAA,GAAW,OAAA;EAmBjB,KAAA,CAAA;EAIA,GAAA,CAAI,OAAA;EAQJ,QAAA,CAAS,OAAA;AAAA"}