mujoco-react 9.5.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/spark.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _sparkjsdev_spark from '@sparkjsdev/spark';
3
- import { n as SplatEnvironmentProps, q as PairedSplatEnvironmentConfig, S as SceneConfig, t as SplatEnvironmentReadiness, o as VisualScenarioConfig } from './types-BDB9QT6Z.js';
3
+ import { n as SplatEnvironmentProps, q as PairedSplatEnvironmentConfig, S as SceneConfig, t as SplatEnvironmentReadiness, o as VisualScenarioConfig } from './types-BaSMqJHT.js';
4
4
  import 'react';
5
5
  import '@react-three/fiber';
6
6
  import 'three';
package/dist/spark.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useSplatSceneConfig, useSplatEnvironment, SplatEnvironment, CAMERA_FRAME_CAPTURE_RENDER_USER_DATA_KEY } from './chunk-6MOK6ZWB.js';
1
+ import { useSplatSceneConfig, useSplatEnvironment, SplatEnvironment, CAMERA_FRAME_CAPTURE_RENDER_USER_DATA_KEY } from './chunk-QTCAVQS6.js';
2
2
  import { useThree } from '@react-three/fiber';
3
3
  import { useMemo, useState, useEffect, useCallback, useRef } from 'react';
4
4
  import * as THREE from 'three';
@@ -14,7 +14,7 @@ import * as THREE from 'three';
14
14
  * ```ts
15
15
  * declare module 'mujoco-react' {
16
16
  * interface Register {
17
- * robots: {
17
+ * models: {
18
18
  * panda: {
19
19
  * actuators: 'joint1' | 'joint2' | 'gripper';
20
20
  * sensors: 'force_sensor' | 'torque_sensor';
@@ -32,44 +32,44 @@ import * as THREE from 'three';
32
32
  */
33
33
  interface Register {
34
34
  }
35
- type RegisteredRobotMap = Register extends {
36
- robots: infer T extends Record<string, Record<string, string>>;
35
+ type RegisteredModelMap = Register extends {
36
+ models: infer T extends Record<string, Record<string, string>>;
37
37
  } ? T : never;
38
- type Robots = [RegisteredRobotMap] extends [never] ? string : Extract<keyof RegisteredRobotMap, string>;
39
- type RobotResource<TRobot extends string, TKey extends string> = [
40
- RegisteredRobotMap
41
- ] extends [never] ? string : TRobot extends keyof RegisteredRobotMap ? TKey extends keyof RegisteredRobotMap[TRobot] ? RegisteredRobotMap[TRobot][TKey] : string : never;
38
+ type Models = [RegisteredModelMap] extends [never] ? string : Extract<keyof RegisteredModelMap, string>;
39
+ type ModelResource<TModel extends string, TKey extends string> = [
40
+ RegisteredModelMap
41
+ ] extends [never] ? string : TModel extends keyof RegisteredModelMap ? TKey extends keyof RegisteredModelMap[TModel] ? RegisteredModelMap[TModel][TKey] : string : never;
42
42
  type RegisterResourceKey = 'actuators' | 'sensors' | 'bodies' | 'joints' | 'sites' | 'geoms' | 'keyframes' | 'cameras';
43
- type RobotResourceObject<TRobot extends string, TKey extends RegisterResourceKey> = string extends RobotResource<TRobot, TKey> ? Record<string, string> : {
44
- readonly [K in RobotResource<TRobot, TKey>]: K;
43
+ type ModelResourceObject<TModel extends string, TKey extends RegisterResourceKey> = string extends ModelResource<TModel, TKey> ? Record<string, string> : {
44
+ readonly [K in ModelResource<TModel, TKey>]: K;
45
45
  };
46
- type RobotResourceCategory<TKey extends RegisterResourceKey> = string extends Robots ? Record<string, Record<string, string>> : {
47
- readonly [TRobot in Robots]: RobotResourceObject<TRobot, TKey>;
46
+ type ModelResourceCategory<TKey extends RegisterResourceKey> = string extends Models ? Record<string, Record<string, string>> : {
47
+ readonly [TModel in Models]: ModelResourceObject<TModel, TKey>;
48
48
  };
49
- type RobotResourceRegistry = string extends Robots ? Record<string, Record<RegisterResourceKey, Record<string, string>>> : {
50
- readonly [TRobot in Robots]: {
51
- readonly [TKey in RegisterResourceKey]: RobotResourceObject<TRobot, TKey>;
49
+ type ModelResourceRegistry = string extends Models ? Record<string, Record<RegisterResourceKey, Record<string, string>>> : {
50
+ readonly [TModel in Models]: {
51
+ readonly [TKey in RegisterResourceKey]: ModelResourceObject<TModel, TKey>;
52
52
  };
53
53
  };
54
- type RuntimeRobotResourceRegistration = Readonly<Record<string, Readonly<Record<RegisterResourceKey, Readonly<Record<string, string>>>>>>;
55
- declare function registerRobotResources(resources: RuntimeRobotResourceRegistration): void;
56
- declare const RobotResources: RobotResourceRegistry;
57
- type RobotActuators<TRobot extends string> = RobotResource<TRobot, 'actuators'>;
58
- declare const RobotActuators: RobotResourceCategory<'actuators'>;
59
- type RobotSensors<TRobot extends string> = RobotResource<TRobot, 'sensors'>;
60
- declare const RobotSensors: RobotResourceCategory<'sensors'>;
61
- type RobotBodies<TRobot extends string> = RobotResource<TRobot, 'bodies'>;
62
- declare const RobotBodies: RobotResourceCategory<'bodies'>;
63
- type RobotJoints<TRobot extends string> = RobotResource<TRobot, 'joints'>;
64
- declare const RobotJoints: RobotResourceCategory<'joints'>;
65
- type RobotSites<TRobot extends string> = RobotResource<TRobot, 'sites'>;
66
- declare const RobotSites: RobotResourceCategory<'sites'>;
67
- type RobotGeoms<TRobot extends string> = RobotResource<TRobot, 'geoms'>;
68
- declare const RobotGeoms: RobotResourceCategory<'geoms'>;
69
- type RobotKeyframes<TRobot extends string> = RobotResource<TRobot, 'keyframes'>;
70
- declare const RobotKeyframes: RobotResourceCategory<'keyframes'>;
71
- type RobotCameras<TRobot extends string> = RobotResource<TRobot, 'cameras'>;
72
- declare const RobotCameras: RobotResourceCategory<'cameras'>;
54
+ type RuntimeModelResourceRegistration = Readonly<Record<string, Readonly<Record<RegisterResourceKey, Readonly<Record<string, string>>>>>>;
55
+ declare function registerModelResources(resources: RuntimeModelResourceRegistration): void;
56
+ declare const ModelResources: ModelResourceRegistry;
57
+ type ModelActuators<TModel extends string> = ModelResource<TModel, 'actuators'>;
58
+ declare const ModelActuators: ModelResourceCategory<'actuators'>;
59
+ type ModelSensors<TModel extends string> = ModelResource<TModel, 'sensors'>;
60
+ declare const ModelSensors: ModelResourceCategory<'sensors'>;
61
+ type ModelBodies<TModel extends string> = ModelResource<TModel, 'bodies'>;
62
+ declare const ModelBodies: ModelResourceCategory<'bodies'>;
63
+ type ModelJoints<TModel extends string> = ModelResource<TModel, 'joints'>;
64
+ declare const ModelJoints: ModelResourceCategory<'joints'>;
65
+ type ModelSites<TModel extends string> = ModelResource<TModel, 'sites'>;
66
+ declare const ModelSites: ModelResourceCategory<'sites'>;
67
+ type ModelGeoms<TModel extends string> = ModelResource<TModel, 'geoms'>;
68
+ declare const ModelGeoms: ModelResourceCategory<'geoms'>;
69
+ type ModelKeyframes<TModel extends string> = ModelResource<TModel, 'keyframes'>;
70
+ declare const ModelKeyframes: ModelResourceCategory<'keyframes'>;
71
+ type ModelCameras<TModel extends string> = ModelResource<TModel, 'cameras'>;
72
+ declare const ModelCameras: ModelResourceCategory<'cameras'>;
73
73
  type Actuators = Register extends {
74
74
  actuators: infer T extends string;
75
75
  } ? T : string;
@@ -383,6 +383,14 @@ interface IkConfig {
383
383
  ikSolveFn?: IKSolveFn;
384
384
  /** DLS damping. Default: 0.01. */
385
385
  damping?: number;
386
+ /** Position error weight for the built-in DLS solver. Default: 1. */
387
+ posWeight?: number;
388
+ /** Orientation error weight for the built-in DLS solver. Default: 0.3. */
389
+ rotWeight?: number;
390
+ /** Solver convergence tolerance. Default: 1e-3. */
391
+ tolerance?: number;
392
+ /** Finite-difference step used by the built-in DLS solver. Default: 1e-6. */
393
+ epsilon?: number;
386
394
  /** Max solver iterations. Default: 50. */
387
395
  maxIterations?: number;
388
396
  }
@@ -659,6 +667,33 @@ interface IkGizmoDragInput {
659
667
  position: THREE.Vector3;
660
668
  quaternion: THREE.Quaternion;
661
669
  }
670
+ type KeyboardIkTargetAction = 'x+' | 'x-' | 'y+' | 'y-' | 'z+' | 'z-' | 'pitch+' | 'pitch-' | 'yaw+' | 'yaw-' | 'roll+' | 'roll-';
671
+ interface KeyboardIkTargetBinding {
672
+ /** KeyboardEvent.code, e.g. `KeyW`, `ArrowUp`, `Space`. */
673
+ code: string;
674
+ action: KeyboardIkTargetAction;
675
+ /** Override translation speed in meters/second for this binding. */
676
+ translateSpeed?: number;
677
+ /** Override rotation speed in radians/second for this binding. */
678
+ rotateSpeed?: number;
679
+ }
680
+ interface KeyboardIkTargetConfig {
681
+ controller: IkContextValue | null;
682
+ bindings: KeyboardIkTargetBinding[];
683
+ enabled?: boolean;
684
+ /** Default translation speed in meters/second. Default: 0.25. */
685
+ translateSpeed?: number;
686
+ /** Default rotation speed in radians/second. Default: 1.0. */
687
+ rotateSpeed?: number;
688
+ /** Apply translation and rotation axes in world or current target space. Default: `world`. */
689
+ frame?: 'world' | 'target';
690
+ /** Enable IK while keys are active. Default: true. */
691
+ autoEnableIk?: boolean;
692
+ /** Sync target to current site when keyboard control starts. Default: true. */
693
+ syncOnStart?: boolean;
694
+ /** Prevent browser default behavior for bound keys. Default: true. */
695
+ preventDefault?: boolean;
696
+ }
662
697
  interface DragInteractionProps {
663
698
  stiffness?: number;
664
699
  showArrow?: boolean;
@@ -1160,9 +1195,28 @@ interface BodyStateResult {
1160
1195
  linearVelocity: React__default.RefObject<THREE.Vector3>;
1161
1196
  angularVelocity: React__default.RefObject<THREE.Vector3>;
1162
1197
  }
1198
+ type JointStateKind = 'auto' | 'scalar' | 'array';
1199
+ interface JointStateOptions {
1200
+ /**
1201
+ * Expected joint value shape.
1202
+ *
1203
+ * - `auto`: scalar joints return numbers, ball/free joints return Float64Array.
1204
+ * - `scalar`: return numeric refs for hinge/slide joints.
1205
+ * - `array`: return Float64Array refs for ball/free joints.
1206
+ */
1207
+ kind?: JointStateKind;
1208
+ }
1163
1209
  interface JointStateResult {
1164
1210
  position: React__default.RefObject<number | Float64Array>;
1165
1211
  velocity: React__default.RefObject<number | Float64Array>;
1166
1212
  }
1213
+ interface ScalarJointStateResult {
1214
+ position: React__default.RefObject<number>;
1215
+ velocity: React__default.RefObject<number>;
1216
+ }
1217
+ interface ArrayJointStateResult {
1218
+ position: React__default.RefObject<Float64Array>;
1219
+ velocity: React__default.RefObject<Float64Array>;
1220
+ }
1167
1221
 
1168
- export { type Bodies as $, type ActuatedJointInfo as A, type BodyProps as B, type ControlGroupInfo as C, type DragInteractionProps as D, type ScenarioLightingPreset as E, type SplatEnvironmentMetadataInput as F, type SplatEnvironmentMetadata as G, type SplatSceneInput as H, type IkConfig as I, type DebugProps as J, type GeomInfo as K, type ContactListenerProps as L, type MujocoContextValue as M, type ActuatorInfo as N, type ObservationConfig as O, type PhysicsStepCallback as P, type Sites as Q, type ReadyCallbackInput as R, type SceneConfig as S, type TrajectoryPlayerProps as T, type SitePositionResult as U, type VisualScenarioEffectsProps as V, type Sensors as W, type SensorHandle as X, type SensorInfo as Y, type Joints as Z, type JointStateResult as _, type MujocoCanvasProps as a, RobotActuators as a$, type BodyStateResult as a0, type Actuators as a1, type CtrlHandle as a2, type ContactInfo as a3, type KeyboardTeleopConfig as a4, type PolicyConfig as a5, type PolicyVector as a6, type ObservationHandle as a7, type TrajectoryInput as a8, type TrajectoryStateChangeInput as a9, type FrameCaptureTarget as aA, type FrameCaptureTargetRef as aB, type Geoms as aC, type IKSolveFn as aD, type IkGizmoDragInput as aE, type IkSolveInput as aF, type JointInfo as aG, type KeyBinding as aH, type Keyframes as aI, type ModelOptions as aJ, type MujocoContact as aK, type MujocoContactArray as aL, type MujocoFrameCaptureOptions as aM, type ObservationLayoutItem as aN, type ObservationOutput as aO, type PhysicsConfig as aP, type PhysicsStepInput as aQ, type PolicyActionInput as aR, type PolicyInferenceInput as aS, type PolicyObservationInput as aT, type RayHit as aU, type Register as aV, type RegisteredRobotMap as aW, type ResetCallbackInput as aX, type ResolvedScenarioCameraConfig as aY, type ResolvedScenarioMaterialConfig as aZ, type ResourceSelector as a_, type PlaybackState as aa, type TrajectoryFrame as ab, type FrameCaptureOptions as ac, type FrameCaptureResult as ad, type FrameCaptureBlobResult as ae, type FrameCaptureAPI as af, type CameraFrameCaptureOptions as ag, type CameraFrameCaptureAPI as ah, type CameraFrameSequenceRecorderAPI as ai, type Cameras as aj, type CameraFrameSequenceCamera as ak, type CameraFrameCaptureSource as al, type CameraFrameSequenceOptions as am, type CameraFrameSequenceResult as an, type CameraFrameCaptureResult as ao, type CameraFrameCaptureBlobResult as ap, type BodyInfo as aq, type CameraFrameCaptureQuaternion as ar, type CameraFrameCaptureVector3 as as, type CameraFrameSequenceCameraSummary as at, type CameraFrameSequenceFrame as au, type CameraFrameSequenceSampleInput as av, type CameraFrameSequenceStepInput as aw, type CameraInfo as ax, type ControlJointInfo as ay, type FrameCaptureStatus as az, type MujocoSimAPI as b, RobotBodies as b0, RobotCameras as b1, RobotGeoms as b2, RobotJoints as b3, RobotKeyframes as b4, type RobotResource as b5, RobotResources as b6, RobotSensors as b7, RobotSites as b8, type Robots as b9, type ScenarioCameraConfig as ba, type ScenarioMaterialConfig as bb, type SceneMarker as bc, type SceneObject as bd, type SensorResult as be, type SiteInfo as bf, type SplatAssetConfig as bg, type SplatScenarioConfig as bh, type StateSnapshot as bi, type TrajectoryData as bj, type TrajectoryFrameCallbackInput as bk, type VisualScenarioMaterialFilterInput as bl, type XmlPatch as bm, getContact as bn, registerRobotResources as bo, type StepCallbackInput as c, type SelectionCallbackInput as d, type MujocoModule as e, type MujocoModel as f, type MujocoData as g, type ControlGroupSelector as h, type ObservationResult as i, type IkContextValue as j, type IkGizmoProps as k, type SceneLightsProps as l, type ScenarioLightingProps as m, type SplatEnvironmentProps as n, type VisualScenarioConfig as o, type SplatRendererKind as p, type PairedSplatEnvironmentConfig as q, type SplatFormat as r, type SplatCollisionProxyConfig as s, type SplatEnvironmentReadiness as t, type SplatCollisionPrimitive as u, SplatEnvironmentReadinessStatus as v, type SplatSceneConfigInput as w, type SplatSceneConfigState as x, type VisualScenarioExecutionContextInput as y, type VisualScenarioExecutionContext as z };
1222
+ export { type ArrayJointStateResult as $, type ActuatedJointInfo as A, type BodyProps as B, type ControlGroupInfo as C, type DragInteractionProps as D, type ScenarioLightingPreset as E, type SplatEnvironmentMetadataInput as F, type SplatEnvironmentMetadata as G, type SplatSceneInput as H, type IkConfig as I, type DebugProps as J, type GeomInfo as K, type ContactListenerProps as L, type MujocoContextValue as M, type ActuatorInfo as N, type ObservationConfig as O, type PhysicsStepCallback as P, type Sites as Q, type ReadyCallbackInput as R, type SceneConfig as S, type TrajectoryPlayerProps as T, type SitePositionResult as U, type VisualScenarioEffectsProps as V, type Sensors as W, type SensorHandle as X, type SensorInfo as Y, type Joints as Z, type ScalarJointStateResult as _, type MujocoCanvasProps as a, type Models as a$, type JointStateOptions as a0, type JointStateResult as a1, type Bodies as a2, type BodyStateResult as a3, type Actuators as a4, type CtrlHandle as a5, type ContactInfo as a6, type KeyboardTeleopConfig as a7, type KeyboardIkTargetConfig as a8, type PolicyConfig as a9, type CameraFrameSequenceStepInput as aA, type CameraInfo as aB, type ControlJointInfo as aC, type FrameCaptureStatus as aD, type FrameCaptureTarget as aE, type FrameCaptureTargetRef as aF, type Geoms as aG, type IKSolveFn as aH, type IkGizmoDragInput as aI, type IkSolveInput as aJ, type JointInfo as aK, type JointStateKind as aL, type KeyBinding as aM, type KeyboardIkTargetAction as aN, type KeyboardIkTargetBinding as aO, type Keyframes as aP, ModelActuators as aQ, ModelBodies as aR, ModelCameras as aS, ModelGeoms as aT, ModelJoints as aU, ModelKeyframes as aV, type ModelOptions as aW, type ModelResource as aX, ModelResources as aY, ModelSensors as aZ, ModelSites as a_, type PolicyVector as aa, type ObservationHandle as ab, type TrajectoryInput as ac, type TrajectoryStateChangeInput as ad, type PlaybackState as ae, type TrajectoryFrame as af, type FrameCaptureOptions as ag, type FrameCaptureResult as ah, type FrameCaptureBlobResult as ai, type FrameCaptureAPI as aj, type CameraFrameCaptureOptions as ak, type CameraFrameCaptureAPI as al, type CameraFrameSequenceRecorderAPI as am, type Cameras as an, type CameraFrameSequenceCamera as ao, type CameraFrameCaptureSource as ap, type CameraFrameSequenceOptions as aq, type CameraFrameSequenceResult as ar, type CameraFrameCaptureResult as as, type CameraFrameCaptureBlobResult as at, type BodyInfo as au, type CameraFrameCaptureQuaternion as av, type CameraFrameCaptureVector3 as aw, type CameraFrameSequenceCameraSummary as ax, type CameraFrameSequenceFrame as ay, type CameraFrameSequenceSampleInput as az, type MujocoSimAPI as b, type MujocoContact as b0, type MujocoContactArray as b1, type MujocoFrameCaptureOptions as b2, type ObservationLayoutItem as b3, type ObservationOutput as b4, type PhysicsConfig as b5, type PhysicsStepInput as b6, type PolicyActionInput as b7, type PolicyInferenceInput as b8, type PolicyObservationInput as b9, type RayHit as ba, type Register as bb, type RegisteredModelMap as bc, type ResetCallbackInput as bd, type ResolvedScenarioCameraConfig as be, type ResolvedScenarioMaterialConfig as bf, type ResourceSelector as bg, type ScenarioCameraConfig as bh, type ScenarioMaterialConfig as bi, type SceneMarker as bj, type SceneObject as bk, type SensorResult as bl, type SiteInfo as bm, type SplatAssetConfig as bn, type SplatScenarioConfig as bo, type StateSnapshot as bp, type TrajectoryData as bq, type TrajectoryFrameCallbackInput as br, type VisualScenarioMaterialFilterInput as bs, type XmlPatch as bt, getContact as bu, registerModelResources as bv, type StepCallbackInput as c, type SelectionCallbackInput as d, type MujocoModule as e, type MujocoModel as f, type MujocoData as g, type ControlGroupSelector as h, type ObservationResult as i, type IkContextValue as j, type IkGizmoProps as k, type SceneLightsProps as l, type ScenarioLightingProps as m, type SplatEnvironmentProps as n, type VisualScenarioConfig as o, type SplatRendererKind as p, type PairedSplatEnvironmentConfig as q, type SplatFormat as r, type SplatCollisionProxyConfig as s, type SplatEnvironmentReadiness as t, type SplatCollisionPrimitive as u, SplatEnvironmentReadinessStatus as v, type SplatSceneConfigInput as w, type SplatSceneConfigState as x, type VisualScenarioExecutionContextInput as y, type VisualScenarioExecutionContext as z };
package/dist/vite.js CHANGED
@@ -141,28 +141,28 @@ function readAttr(attrs, attr) {
141
141
  }
142
142
  function renderRegister(moduleName, names, models, declarationsOnly) {
143
143
  const fields = REGISTER_KEYS.filter((key) => names[key].size > 0).map((key) => ` ${key}: ${renderUnion(names[key])};`);
144
- const robots = models.map((model) => ` ${quoteProperty(model.id)}: {
145
- ${renderRobotFields(model.names)}
144
+ const modelFields = models.map((model) => ` ${quoteProperty(model.id)}: {
145
+ ${renderModelFields(model.names)}
146
146
  };`);
147
147
  const namespaceAliases = renderNamespaceAliases(models);
148
- const registerImport = declarationsOnly ? "" : `import { registerRobotResources } from '${moduleName}';
148
+ const registerImport = declarationsOnly ? "" : `import { registerModelResources } from '${moduleName}';
149
149
  `;
150
150
  const resources = declarationsOnly ? "" : `${renderResourceTypes(models)}
151
151
 
152
152
  ${renderResourceConstants(models)}
153
153
 
154
- registerRobotResources(generatedRobotResources);
154
+ registerModelResources(generatedModelResources);
155
155
 
156
156
  `;
157
157
  return `// Auto-generated by mujoco-react. Do not edit.
158
158
  // Regenerate by running Vite with the mujocoReact() plugin or \`mujoco-react codegen\`.
159
159
 
160
- ${registerImport}import type { RobotResource } from '${moduleName}';
160
+ ${registerImport}import type { ModelResource } from '${moduleName}';
161
161
 
162
162
  ${resources}declare module '${moduleName}' {
163
163
  interface Register {
164
- robots: {
165
- ${robots.join("\n")}
164
+ models: {
165
+ ${modelFields.join("\n")}
166
166
  };
167
167
  ${fields.join("\n")}
168
168
  }
@@ -175,7 +175,7 @@ function renderResourceTypes(models) {
175
175
  const modelTypes = models.map((model) => ` readonly ${quoteProperty(model.id)}: {
176
176
  ${renderResourceTypeFields(model.names)}
177
177
  };`).join("\n");
178
- return `type GeneratedRobotResources = {
178
+ return `type GeneratedModelResources = {
179
179
  ${modelTypes}
180
180
  };`;
181
181
  }
@@ -192,7 +192,7 @@ function renderResourceConstants(models) {
192
192
  const entries = models.map((model) => ` ${quoteProperty(model.id)}: {
193
193
  ${renderResourceConstantFields(model.names)}
194
194
  },`).join("\n");
195
- return `const generatedRobotResources: GeneratedRobotResources = {
195
+ return `const generatedModelResources: GeneratedModelResources = {
196
196
  ${entries}
197
197
  };`;
198
198
  }
@@ -205,7 +205,7 @@ function renderResourceObject(values) {
205
205
  ${entries.join("\n")}
206
206
  }` : "{}";
207
207
  }
208
- function renderRobotFields(names) {
208
+ function renderModelFields(names) {
209
209
  return REGISTER_KEYS.map((key) => ` ${key}: ${names[key].size > 0 ? renderUnion(names[key]) : "never"};`).join("\n");
210
210
  }
211
211
  function renderUnion(values) {
@@ -213,20 +213,20 @@ function renderUnion(values) {
213
213
  }
214
214
  function renderNamespaceAliases(models) {
215
215
  const namespaces = {
216
- actuators: "RobotActuators",
217
- sensors: "RobotSensors",
218
- bodies: "RobotBodies",
219
- joints: "RobotJoints",
220
- sites: "RobotSites",
221
- geoms: "RobotGeoms",
222
- keyframes: "RobotKeyframes",
223
- cameras: "RobotCameras"
216
+ actuators: "ModelActuators",
217
+ sensors: "ModelSensors",
218
+ bodies: "ModelBodies",
219
+ joints: "ModelJoints",
220
+ sites: "ModelSites",
221
+ geoms: "ModelGeoms",
222
+ keyframes: "ModelKeyframes",
223
+ cameras: "ModelCameras"
224
224
  };
225
225
  const blocks = REGISTER_KEYS.map((key) => {
226
- const aliases = models.filter((model) => isIdentifier(model.id)).map((model) => ` export type ${model.id} = RobotResource<'${escapeTs(model.id)}', '${key}'>;`);
227
- if (aliases.length === 0) return "";
226
+ const modelAliases = models.filter((model) => isIdentifier(model.id)).map((model) => ` export type ${model.id} = ModelResource<'${escapeTs(model.id)}', '${key}'>;`);
227
+ if (modelAliases.length === 0) return "";
228
228
  return ` export namespace ${namespaces[key]} {
229
- ${aliases.join("\n")}
229
+ ${modelAliases.join("\n")}
230
230
  }`;
231
231
  }).filter(Boolean).join("\n\n");
232
232
  return blocks ? `${blocks}
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite.ts"],"names":[],"mappings":";;;;AAiDA,IAAM,aAAA,GAA+B,CAAC,WAAA,EAAa,SAAA,EAAW,UAAU,QAAA,EAAU,OAAA,EAAS,OAAA,EAAS,WAAA,EAAa,SAAS,CAAA;AAC1H,IAAM,mCAAmB,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAA,EAAS,OAAO,CAAC,CAAA;AAE3D,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} from 'node:fs/promises';\nimport path from 'node:path';\n\ntype ViteConfig = { root: string };\ntype ViteServer = {\n watcher: {\n add(paths: string | string[]): void;\n on(event: 'add' | 'change' | 'unlink', listener: (file: string) => void): void;\n };\n};\n\nexport interface MujocoReactPluginOptions {\n /** Entry MJCF/URDF files to scan. Prefer a record for stable per-robot type names. */\n models: ModelInput;\n /** Generated resource module. Defaults to `src/mujoco-register.gen.ts`. */\n generatedRegister?: string;\n /** Module name to augment. Defaults to `mujoco-react`. */\n moduleName?: string;\n /** Disable console output. */\n disableLogging?: boolean;\n}\n\nexport interface MujocoRegisterCodegenOptions {\n models: ModelInput;\n out: string;\n moduleName?: string;\n root?: string;\n}\n\nexport interface MujocoRegisterCodegenResult {\n out: string;\n files: string[];\n counts: Record<RegisterKey, number>;\n}\n\ntype RegisterKey = 'actuators' | 'sensors' | 'bodies' | 'joints' | 'sites' | 'geoms' | 'keyframes' | 'cameras';\nexport type ModelInput = string | readonly string[] | Record<string, string>;\n\ninterface ModelEntry {\n id: string;\n file: string;\n names: Record<RegisterKey, Set<string>>;\n}\n\nconst REGISTER_KEYS: RegisterKey[] = ['actuators', 'sensors', 'bodies', 'joints', 'sites', 'geoms', 'keyframes', 'cameras'];\nconst MODEL_EXTENSIONS = new Set(['.xml', '.mjcf', '.urdf']);\n\nfunction createEmptyNames(): Record<RegisterKey, Set<string>> {\n return {\n actuators: new Set(),\n sensors: new Set(),\n bodies: new Set(),\n joints: new Set(),\n sites: new Set(),\n geoms: new Set(),\n keyframes: new Set(),\n cameras: new Set(),\n };\n}\n\nexport function mujocoReact(options: MujocoReactPluginOptions) {\n const models = normalizeModels(options.models);\n let root = process.cwd();\n let generatedRegister = options.generatedRegister ?? 'src/mujoco-register.gen.ts';\n let watchedFiles: string[] = [];\n\n async function generate() {\n const result = await generateMujocoRegister({\n models: options.models,\n out: generatedRegister,\n moduleName: options.moduleName,\n root,\n });\n watchedFiles = result.files;\n if (!options.disableLogging) {\n const total = Object.values(result.counts).reduce((sum, count) => sum + count, 0);\n console.log(`[mujoco-react] generated ${path.relative(root, result.out)} (${total} names)`);\n }\n return result;\n }\n\n return {\n name: 'mujoco-react',\n enforce: 'pre' as const,\n config(userConfig: { build?: { chunkSizeWarningLimit?: number } }) {\n // three + drei + MuJoCo WASM glue are inherently large; the large-chunk\n // warning is expected, not a failure. Raise the limit so consumers don't\n // see it. Vite merges plugin config on top of user config, so only set a\n // default when the consumer hasn't specified their own limit.\n if (userConfig.build?.chunkSizeWarningLimit !== undefined) return;\n return { build: { chunkSizeWarningLimit: 4000 } };\n },\n configResolved(config: ViteConfig) {\n root = config.root;\n generatedRegister = path.resolve(root, generatedRegister);\n },\n transform(code: string, id: string) {\n if (!shouldInjectRegisterImport(id, root, generatedRegister)) return;\n return `${renderGeneratedImport(id, generatedRegister)}\\n${code}`;\n },\n async buildStart(this: { addWatchFile?: (file: string) => void }) {\n const result = await generate();\n for (const file of result.files) this.addWatchFile?.(file);\n },\n configureServer(server: ViteServer) {\n generate().then((result) => server.watcher.add(result.files)).catch((error: unknown) => {\n console.error('[mujoco-react] register generation failed', error);\n });\n\n server.watcher.on('add', regenerateIfModelFile);\n server.watcher.on('change', regenerateIfModelFile);\n server.watcher.on('unlink', regenerateIfModelFile);\n\n function regenerateIfModelFile(file: string) {\n if (!shouldRegenerate(file, watchedFiles, models, root)) return;\n generate().then((result) => server.watcher.add(result.files)).catch((error: unknown) => {\n console.error('[mujoco-react] register generation failed', error);\n });\n }\n },\n };\n}\n\nexport async function generateMujocoRegister(\n options: MujocoRegisterCodegenOptions\n): Promise<MujocoRegisterCodegenResult> {\n const root = path.resolve(options.root ?? process.cwd());\n const out = path.resolve(root, options.out);\n const moduleName = options.moduleName ?? 'mujoco-react';\n const models = normalizeModels(options.models);\n const names = createEmptyNames();\n const seen = new Set<string>();\n const declarationsOnly = out.endsWith('.d.ts');\n\n for (const model of models) {\n await scanModel(path.resolve(root, model.file), root, seen, model.names);\n mergeNames(names, model.names);\n }\n\n await mkdir(path.dirname(out), { recursive: true });\n await writeFile(out, renderRegister(moduleName, names, models, declarationsOnly), 'utf8');\n\n return {\n out,\n files: [...seen].sort((a, b) => a.localeCompare(b)),\n counts: Object.fromEntries(REGISTER_KEYS.map((key) => [key, names[key].size])) as Record<RegisterKey, number>,\n };\n}\n\nasync function scanModel(\n filePath: string,\n root: string,\n seen: Set<string>,\n names: Record<RegisterKey, Set<string>>\n) {\n const normalized = path.resolve(filePath);\n if (seen.has(normalized)) return;\n seen.add(normalized);\n\n const xml = await readFile(normalized, 'utf8');\n collectSimpleTagNames(xml, 'body', names.bodies);\n collectSimpleTagNames(xml, 'joint', names.joints);\n collectSimpleTagNames(xml, 'site', names.sites);\n collectSimpleTagNames(xml, 'geom', names.geoms);\n collectSimpleTagNames(xml, 'camera', names.cameras);\n collectSimpleTagNames(xml, 'key', names.keyframes);\n collectSectionNames(xml, 'actuator', names.actuators);\n collectSectionNames(xml, 'sensor', names.sensors);\n\n for (const includePath of collectIncludePaths(xml)) {\n const next = path.resolve(path.dirname(normalized), includePath);\n if (isPathInsideRoot(next, root)) await scanModel(next, root, seen, names);\n }\n}\n\nfunction collectSimpleTagNames(xml: string, tag: string, target: Set<string>) {\n const pattern = new RegExp(`<\\\\s*${tag}\\\\b([^>]*)>`, 'gi');\n for (const match of xml.matchAll(pattern)) {\n const name = readAttr(match[1], 'name');\n if (name) target.add(name);\n }\n}\n\nfunction collectSectionNames(xml: string, section: string, target: Set<string>) {\n const sectionPattern = new RegExp(`<\\\\s*${section}\\\\b[^>]*>([\\\\s\\\\S]*?)<\\\\s*/\\\\s*${section}\\\\s*>`, 'gi');\n for (const sectionMatch of xml.matchAll(sectionPattern)) {\n const tagPattern = /<\\s*[a-zA-Z0-9_:-]+\\b([^>]*)>/g;\n for (const tagMatch of sectionMatch[1].matchAll(tagPattern)) {\n const name = readAttr(tagMatch[1], 'name');\n if (name) target.add(name);\n }\n }\n}\n\nfunction collectIncludePaths(xml: string): string[] {\n const result: string[] = [];\n const pattern = /<\\s*include\\b([^>]*)>/gi;\n for (const match of xml.matchAll(pattern)) {\n const file = readAttr(match[1], 'file');\n if (file && !file.includes('://') && !file.startsWith('/')) result.push(file);\n }\n return result;\n}\n\nfunction readAttr(attrs: string, attr: string): string | undefined {\n const pattern = new RegExp(`\\\\b${attr}\\\\s*=\\\\s*(['\"])(.*?)\\\\1`, 'i');\n return attrs.match(pattern)?.[2];\n}\n\nfunction renderRegister(\n moduleName: string,\n names: Record<RegisterKey, Set<string>>,\n models: readonly ModelEntry[],\n declarationsOnly: boolean\n): string {\n const fields = REGISTER_KEYS\n .filter((key) => names[key].size > 0)\n .map((key) => ` ${key}: ${renderUnion(names[key])};`);\n const robots = models\n .map((model) => ` ${quoteProperty(model.id)}: {\\n${renderRobotFields(model.names)}\\n };`);\n const namespaceAliases = renderNamespaceAliases(models);\n const registerImport = declarationsOnly ? '' : `import { registerRobotResources } from '${moduleName}';\\n`;\n const resources = declarationsOnly ? '' : `${renderResourceTypes(models)}\\n\\n${renderResourceConstants(models)}\\n\\nregisterRobotResources(generatedRobotResources);\\n\\n`;\n\n return `// Auto-generated by mujoco-react. Do not edit.\n// Regenerate by running Vite with the mujocoReact() plugin or \\`mujoco-react codegen\\`.\n\n${registerImport}import type { RobotResource } from '${moduleName}';\n\n${resources}declare module '${moduleName}' {\n interface Register {\n robots: {\n${robots.join('\\n')}\n };\n${fields.join('\\n')}\n }\n\n${namespaceAliases}\n}\n`;\n}\n\nfunction renderResourceTypes(models: readonly ModelEntry[]): string {\n const modelTypes = models\n .map((model) => ` readonly ${quoteProperty(model.id)}: {\\n${renderResourceTypeFields(model.names)}\\n };`)\n .join('\\n');\n return `type GeneratedRobotResources = {\\n${modelTypes}\\n};`;\n}\n\nfunction renderResourceTypeFields(names: Record<RegisterKey, Set<string>>): string {\n return REGISTER_KEYS\n .map((key) => ` readonly ${key}: ${renderResourceObjectType(names[key])};`)\n .join('\\n');\n}\n\nfunction renderResourceObjectType(values: Set<string>): string {\n const entries = sortedValues(values)\n .map((value) => ` readonly ${quoteProperty(value)}: '${escapeTs(value)}';`);\n return entries.length > 0 ? `{\\n${entries.join('\\n')}\\n }` : '{}';\n}\n\nfunction renderResourceConstants(models: readonly ModelEntry[]): string {\n const entries = models\n .map((model) => ` ${quoteProperty(model.id)}: {\\n${renderResourceConstantFields(model.names)}\\n },`)\n .join('\\n');\n return `const generatedRobotResources: GeneratedRobotResources = {\\n${entries}\\n};`;\n}\n\nfunction renderResourceConstantFields(names: Record<RegisterKey, Set<string>>): string {\n return REGISTER_KEYS\n .map((key) => ` ${key}: ${renderResourceObject(names[key])},`)\n .join('\\n');\n}\n\nfunction renderResourceObject(values: Set<string>): string {\n const entries = sortedValues(values)\n .map((value) => ` ${quoteProperty(value)}: '${escapeTs(value)}',`);\n return entries.length > 0 ? `{\\n${entries.join('\\n')}\\n }` : '{}';\n}\n\nfunction renderRobotFields(names: Record<RegisterKey, Set<string>>): string {\n return REGISTER_KEYS\n .map((key) => ` ${key}: ${names[key].size > 0 ? renderUnion(names[key]) : 'never'};`)\n .join('\\n');\n}\n\nfunction renderUnion(values: Set<string>): string {\n return sortedValues(values).map((value) => `'${escapeTs(value)}'`).join(' | ');\n}\n\nfunction renderNamespaceAliases(models: readonly ModelEntry[]): string {\n const namespaces: Record<RegisterKey, string> = {\n actuators: 'RobotActuators',\n sensors: 'RobotSensors',\n bodies: 'RobotBodies',\n joints: 'RobotJoints',\n sites: 'RobotSites',\n geoms: 'RobotGeoms',\n keyframes: 'RobotKeyframes',\n cameras: 'RobotCameras',\n };\n\n const blocks = REGISTER_KEYS\n .map((key) => {\n const aliases = models\n .filter((model) => isIdentifier(model.id))\n .map((model) => ` export type ${model.id} = RobotResource<'${escapeTs(model.id)}', '${key}'>;`);\n if (aliases.length === 0) return '';\n return ` export namespace ${namespaces[key]} {\\n${aliases.join('\\n')}\\n }`;\n })\n .filter(Boolean)\n .join('\\n\\n');\n\n return blocks ? `${blocks}\\n` : '';\n}\n\nfunction escapeTs(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\nfunction sortedValues(values: Set<string>): string[] {\n return [...values].sort((a, b) => a.localeCompare(b));\n}\n\nfunction quoteProperty(value: string): string {\n return isIdentifier(value) ? value : `'${escapeTs(value)}'`;\n}\n\nfunction isIdentifier(value: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value);\n}\n\nfunction toPosixPath(value: string): string {\n return value.split(path.sep).join('/');\n}\n\nfunction shouldInjectRegisterImport(id: string, root: string, generatedRegister: string): boolean {\n if (generatedRegister.endsWith('.d.ts')) return false;\n const file = stripQuery(id);\n if (!/\\.[cm]?[jt]sx?$/.test(file)) return false;\n if (file.includes(`${path.sep}node_modules${path.sep}`)) return false;\n const absolute = path.resolve(file);\n if (absolute === generatedRegister) return false;\n return isPathInsideRoot(absolute, root);\n}\n\nfunction renderGeneratedImport(id: string, generatedRegister: string): string {\n const fromDir = path.dirname(stripQuery(id));\n let relative = toPosixPath(path.relative(fromDir, generatedRegister));\n if (!relative.startsWith('.')) relative = `./${relative}`;\n return `import '${relative}';`;\n}\n\nfunction stripQuery(id: string): string {\n return id.split('?')[0];\n}\n\nfunction normalizeModels(input: ModelInput): ModelEntry[] {\n if (typeof input === 'string') return [createModelEntry(deriveModelId(input), input)];\n if (Array.isArray(input)) return input.map((file) => createModelEntry(deriveModelId(file), file));\n return Object.entries(input).map(([id, file]) => createModelEntry(sanitizeModelId(id), file));\n}\n\nfunction createModelEntry(id: string, file: string): ModelEntry {\n return { id, file, names: createEmptyNames() };\n}\n\nfunction deriveModelId(file: string): string {\n const normalized = file.replace(/\\\\/g, '/');\n const parts = normalized.split('/').filter(Boolean);\n const filename = parts.at(-1) ?? 'model';\n const parent = parts.length > 1 ? parts.at(-2) : undefined;\n const base = filename.replace(/\\.(xml|mjcf|urdf)$/i, '');\n return sanitizeModelId(parent && ['scene', 'model', 'robot'].includes(base.toLowerCase()) ? parent : base);\n}\n\nfunction sanitizeModelId(value: string): string {\n const sanitized = value.replace(/[^A-Za-z0-9_$]/g, '_').replace(/^[^A-Za-z_$]+/, '');\n return sanitized || 'model';\n}\n\nfunction mergeNames(target: Record<RegisterKey, Set<string>>, source: Record<RegisterKey, Set<string>>) {\n for (const key of REGISTER_KEYS) {\n for (const value of source[key]) target[key].add(value);\n }\n}\n\nfunction shouldRegenerate(file: string, watchedFiles: string[], models: readonly ModelEntry[], root: string): boolean {\n const absolute = path.resolve(file);\n if (watchedFiles.includes(absolute)) return true;\n if (!MODEL_EXTENSIONS.has(path.extname(absolute).toLowerCase())) return false;\n const modelDirs = models.map((model) => path.dirname(path.resolve(root, model.file)));\n return modelDirs.some((dir) => isPathInsideRoot(absolute, dir));\n}\n\nfunction isPathInsideRoot(filePath: string, root: string): boolean {\n const relative = path.relative(path.resolve(root), path.resolve(filePath));\n return relative === '' || (relative !== '' && !relative.startsWith('..') && !path.isAbsolute(relative));\n}\n"]}
1
+ {"version":3,"sources":["../src/vite.ts"],"names":[],"mappings":";;;;AAiDA,IAAM,aAAA,GAA+B,CAAC,WAAA,EAAa,SAAA,EAAW,UAAU,QAAA,EAAU,OAAA,EAAS,OAAA,EAAS,WAAA,EAAa,SAAS,CAAA;AAC1H,IAAM,mCAAmB,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAA,EAAS,OAAO,CAAC,CAAA;AAE3D,SAAS,gBAAA,GAAqD;AAC5D,EAAA,OAAO;AAAA,IACL,SAAA,sBAAe,GAAA,EAAI;AAAA,IACnB,OAAA,sBAAa,GAAA,EAAI;AAAA,IACjB,MAAA,sBAAY,GAAA,EAAI;AAAA,IAChB,MAAA,sBAAY,GAAA,EAAI;AAAA,IAChB,KAAA,sBAAW,GAAA,EAAI;AAAA,IACf,KAAA,sBAAW,GAAA,EAAI;AAAA,IACf,SAAA,sBAAe,GAAA,EAAI;AAAA,IACnB,OAAA,sBAAa,GAAA;AAAI,GACnB;AACF;AAEO,SAAS,YAAY,OAAA,EAAmC;AAC7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,OAAO,IAAA;AAC5C,EAAA,IAAI,CAAC,gBAAA,CAAiB,GAAA,CAAI,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA,CAAE,WAAA,EAAa,CAAA,EAAG,OAAO,KAAA;AACxE,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK,OAAA,CAAQ,IAAA,EAAM,KAAA,CAAM,IAAI,CAAC,CAAC,CAAA;AACpF,EAAA,OAAO,UAAU,IAAA,CAAK,CAAC,QAAQ,gBAAA,CAAiB,QAAA,EAAU,GAAG,CAAC,CAAA;AAChE;AAEA,SAAS,gBAAA,CAAiB,UAAkB,IAAA,EAAuB;AACjE,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA,EAAG,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAC,CAAA;AACzE,EAAA,OAAO,QAAA,KAAa,EAAA,IAAO,QAAA,KAAa,EAAA,IAAM,CAAC,QAAA,CAAS,UAAA,CAAW,IAAI,CAAA,IAAK,CAAC,IAAA,CAAK,UAAA,CAAW,QAAQ,CAAA;AACvG","file":"vite.js","sourcesContent":["/**\n * @license\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\n\ntype ViteConfig = { root: string };\ntype ViteServer = {\n watcher: {\n add(paths: string | string[]): void;\n on(event: 'add' | 'change' | 'unlink', listener: (file: string) => void): void;\n };\n};\n\nexport interface MujocoReactPluginOptions {\n /** Entry MJCF/URDF files to scan. Prefer a record for stable per-robot type names. */\n models: ModelInput;\n /** Generated resource module. Defaults to `src/mujoco-register.gen.ts`. */\n generatedRegister?: string;\n /** Module name to augment. Defaults to `mujoco-react`. */\n moduleName?: string;\n /** Disable console output. */\n disableLogging?: boolean;\n}\n\nexport interface MujocoRegisterCodegenOptions {\n models: ModelInput;\n out: string;\n moduleName?: string;\n root?: string;\n}\n\nexport interface MujocoRegisterCodegenResult {\n out: string;\n files: string[];\n counts: Record<RegisterKey, number>;\n}\n\ntype RegisterKey = 'actuators' | 'sensors' | 'bodies' | 'joints' | 'sites' | 'geoms' | 'keyframes' | 'cameras';\nexport type ModelInput = string | readonly string[] | Record<string, string>;\n\ninterface ModelEntry {\n id: string;\n file: string;\n names: Record<RegisterKey, Set<string>>;\n}\n\nconst REGISTER_KEYS: RegisterKey[] = ['actuators', 'sensors', 'bodies', 'joints', 'sites', 'geoms', 'keyframes', 'cameras'];\nconst MODEL_EXTENSIONS = new Set(['.xml', '.mjcf', '.urdf']);\n\nfunction createEmptyNames(): Record<RegisterKey, Set<string>> {\n return {\n actuators: new Set(),\n sensors: new Set(),\n bodies: new Set(),\n joints: new Set(),\n sites: new Set(),\n geoms: new Set(),\n keyframes: new Set(),\n cameras: new Set(),\n };\n}\n\nexport function mujocoReact(options: MujocoReactPluginOptions) {\n const models = normalizeModels(options.models);\n let root = process.cwd();\n let generatedRegister = options.generatedRegister ?? 'src/mujoco-register.gen.ts';\n let watchedFiles: string[] = [];\n\n async function generate() {\n const result = await generateMujocoRegister({\n models: options.models,\n out: generatedRegister,\n moduleName: options.moduleName,\n root,\n });\n watchedFiles = result.files;\n if (!options.disableLogging) {\n const total = Object.values(result.counts).reduce((sum, count) => sum + count, 0);\n console.log(`[mujoco-react] generated ${path.relative(root, result.out)} (${total} names)`);\n }\n return result;\n }\n\n return {\n name: 'mujoco-react',\n enforce: 'pre' as const,\n config(userConfig: { build?: { chunkSizeWarningLimit?: number } }) {\n // three + drei + MuJoCo WASM glue are inherently large; the large-chunk\n // warning is expected, not a failure. Raise the limit so consumers don't\n // see it. Vite merges plugin config on top of user config, so only set a\n // default when the consumer hasn't specified their own limit.\n if (userConfig.build?.chunkSizeWarningLimit !== undefined) return;\n return { build: { chunkSizeWarningLimit: 4000 } };\n },\n configResolved(config: ViteConfig) {\n root = config.root;\n generatedRegister = path.resolve(root, generatedRegister);\n },\n transform(code: string, id: string) {\n if (!shouldInjectRegisterImport(id, root, generatedRegister)) return;\n return `${renderGeneratedImport(id, generatedRegister)}\\n${code}`;\n },\n async buildStart(this: { addWatchFile?: (file: string) => void }) {\n const result = await generate();\n for (const file of result.files) this.addWatchFile?.(file);\n },\n configureServer(server: ViteServer) {\n generate().then((result) => server.watcher.add(result.files)).catch((error: unknown) => {\n console.error('[mujoco-react] register generation failed', error);\n });\n\n server.watcher.on('add', regenerateIfModelFile);\n server.watcher.on('change', regenerateIfModelFile);\n server.watcher.on('unlink', regenerateIfModelFile);\n\n function regenerateIfModelFile(file: string) {\n if (!shouldRegenerate(file, watchedFiles, models, root)) return;\n generate().then((result) => server.watcher.add(result.files)).catch((error: unknown) => {\n console.error('[mujoco-react] register generation failed', error);\n });\n }\n },\n };\n}\n\nexport async function generateMujocoRegister(\n options: MujocoRegisterCodegenOptions\n): Promise<MujocoRegisterCodegenResult> {\n const root = path.resolve(options.root ?? process.cwd());\n const out = path.resolve(root, options.out);\n const moduleName = options.moduleName ?? 'mujoco-react';\n const models = normalizeModels(options.models);\n const names = createEmptyNames();\n const seen = new Set<string>();\n const declarationsOnly = out.endsWith('.d.ts');\n\n for (const model of models) {\n await scanModel(path.resolve(root, model.file), root, seen, model.names);\n mergeNames(names, model.names);\n }\n\n await mkdir(path.dirname(out), { recursive: true });\n await writeFile(out, renderRegister(moduleName, names, models, declarationsOnly), 'utf8');\n\n return {\n out,\n files: [...seen].sort((a, b) => a.localeCompare(b)),\n counts: Object.fromEntries(REGISTER_KEYS.map((key) => [key, names[key].size])) as Record<RegisterKey, number>,\n };\n}\n\nasync function scanModel(\n filePath: string,\n root: string,\n seen: Set<string>,\n names: Record<RegisterKey, Set<string>>\n) {\n const normalized = path.resolve(filePath);\n if (seen.has(normalized)) return;\n seen.add(normalized);\n\n const xml = await readFile(normalized, 'utf8');\n collectSimpleTagNames(xml, 'body', names.bodies);\n collectSimpleTagNames(xml, 'joint', names.joints);\n collectSimpleTagNames(xml, 'site', names.sites);\n collectSimpleTagNames(xml, 'geom', names.geoms);\n collectSimpleTagNames(xml, 'camera', names.cameras);\n collectSimpleTagNames(xml, 'key', names.keyframes);\n collectSectionNames(xml, 'actuator', names.actuators);\n collectSectionNames(xml, 'sensor', names.sensors);\n\n for (const includePath of collectIncludePaths(xml)) {\n const next = path.resolve(path.dirname(normalized), includePath);\n if (isPathInsideRoot(next, root)) await scanModel(next, root, seen, names);\n }\n}\n\nfunction collectSimpleTagNames(xml: string, tag: string, target: Set<string>) {\n const pattern = new RegExp(`<\\\\s*${tag}\\\\b([^>]*)>`, 'gi');\n for (const match of xml.matchAll(pattern)) {\n const name = readAttr(match[1], 'name');\n if (name) target.add(name);\n }\n}\n\nfunction collectSectionNames(xml: string, section: string, target: Set<string>) {\n const sectionPattern = new RegExp(`<\\\\s*${section}\\\\b[^>]*>([\\\\s\\\\S]*?)<\\\\s*/\\\\s*${section}\\\\s*>`, 'gi');\n for (const sectionMatch of xml.matchAll(sectionPattern)) {\n const tagPattern = /<\\s*[a-zA-Z0-9_:-]+\\b([^>]*)>/g;\n for (const tagMatch of sectionMatch[1].matchAll(tagPattern)) {\n const name = readAttr(tagMatch[1], 'name');\n if (name) target.add(name);\n }\n }\n}\n\nfunction collectIncludePaths(xml: string): string[] {\n const result: string[] = [];\n const pattern = /<\\s*include\\b([^>]*)>/gi;\n for (const match of xml.matchAll(pattern)) {\n const file = readAttr(match[1], 'file');\n if (file && !file.includes('://') && !file.startsWith('/')) result.push(file);\n }\n return result;\n}\n\nfunction readAttr(attrs: string, attr: string): string | undefined {\n const pattern = new RegExp(`\\\\b${attr}\\\\s*=\\\\s*(['\"])(.*?)\\\\1`, 'i');\n return attrs.match(pattern)?.[2];\n}\n\nfunction renderRegister(\n moduleName: string,\n names: Record<RegisterKey, Set<string>>,\n models: readonly ModelEntry[],\n declarationsOnly: boolean\n): string {\n const fields = REGISTER_KEYS\n .filter((key) => names[key].size > 0)\n .map((key) => ` ${key}: ${renderUnion(names[key])};`);\n const modelFields = models\n .map((model) => ` ${quoteProperty(model.id)}: {\\n${renderModelFields(model.names)}\\n };`);\n const namespaceAliases = renderNamespaceAliases(models);\n const registerImport = declarationsOnly ? '' : `import { registerModelResources } from '${moduleName}';\\n`;\n const resources = declarationsOnly ? '' : `${renderResourceTypes(models)}\\n\\n${renderResourceConstants(models)}\\n\\nregisterModelResources(generatedModelResources);\\n\\n`;\n\n return `// Auto-generated by mujoco-react. Do not edit.\n// Regenerate by running Vite with the mujocoReact() plugin or \\`mujoco-react codegen\\`.\n\n${registerImport}import type { ModelResource } from '${moduleName}';\n\n${resources}declare module '${moduleName}' {\n interface Register {\n models: {\n${modelFields.join('\\n')}\n };\n${fields.join('\\n')}\n }\n\n${namespaceAliases}\n}\n`;\n}\n\nfunction renderResourceTypes(models: readonly ModelEntry[]): string {\n const modelTypes = models\n .map((model) => ` readonly ${quoteProperty(model.id)}: {\\n${renderResourceTypeFields(model.names)}\\n };`)\n .join('\\n');\n return `type GeneratedModelResources = {\\n${modelTypes}\\n};`;\n}\n\nfunction renderResourceTypeFields(names: Record<RegisterKey, Set<string>>): string {\n return REGISTER_KEYS\n .map((key) => ` readonly ${key}: ${renderResourceObjectType(names[key])};`)\n .join('\\n');\n}\n\nfunction renderResourceObjectType(values: Set<string>): string {\n const entries = sortedValues(values)\n .map((value) => ` readonly ${quoteProperty(value)}: '${escapeTs(value)}';`);\n return entries.length > 0 ? `{\\n${entries.join('\\n')}\\n }` : '{}';\n}\n\nfunction renderResourceConstants(models: readonly ModelEntry[]): string {\n const entries = models\n .map((model) => ` ${quoteProperty(model.id)}: {\\n${renderResourceConstantFields(model.names)}\\n },`)\n .join('\\n');\n return `const generatedModelResources: GeneratedModelResources = {\\n${entries}\\n};`;\n}\n\nfunction renderResourceConstantFields(names: Record<RegisterKey, Set<string>>): string {\n return REGISTER_KEYS\n .map((key) => ` ${key}: ${renderResourceObject(names[key])},`)\n .join('\\n');\n}\n\nfunction renderResourceObject(values: Set<string>): string {\n const entries = sortedValues(values)\n .map((value) => ` ${quoteProperty(value)}: '${escapeTs(value)}',`);\n return entries.length > 0 ? `{\\n${entries.join('\\n')}\\n }` : '{}';\n}\n\nfunction renderModelFields(names: Record<RegisterKey, Set<string>>): string {\n return REGISTER_KEYS\n .map((key) => ` ${key}: ${names[key].size > 0 ? renderUnion(names[key]) : 'never'};`)\n .join('\\n');\n}\n\nfunction renderUnion(values: Set<string>): string {\n return sortedValues(values).map((value) => `'${escapeTs(value)}'`).join(' | ');\n}\n\nfunction renderNamespaceAliases(models: readonly ModelEntry[]): string {\n const namespaces: Record<RegisterKey, string> = {\n actuators: 'ModelActuators',\n sensors: 'ModelSensors',\n bodies: 'ModelBodies',\n joints: 'ModelJoints',\n sites: 'ModelSites',\n geoms: 'ModelGeoms',\n keyframes: 'ModelKeyframes',\n cameras: 'ModelCameras',\n };\n\n const blocks = REGISTER_KEYS\n .map((key) => {\n const modelAliases = models\n .filter((model) => isIdentifier(model.id))\n .map((model) => ` export type ${model.id} = ModelResource<'${escapeTs(model.id)}', '${key}'>;`);\n if (modelAliases.length === 0) return '';\n return ` export namespace ${namespaces[key]} {\\n${modelAliases.join('\\n')}\\n }`;\n })\n .filter(Boolean)\n .join('\\n\\n');\n\n return blocks ? `${blocks}\\n` : '';\n}\n\nfunction escapeTs(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\nfunction sortedValues(values: Set<string>): string[] {\n return [...values].sort((a, b) => a.localeCompare(b));\n}\n\nfunction quoteProperty(value: string): string {\n return isIdentifier(value) ? value : `'${escapeTs(value)}'`;\n}\n\nfunction isIdentifier(value: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value);\n}\n\nfunction toPosixPath(value: string): string {\n return value.split(path.sep).join('/');\n}\n\nfunction shouldInjectRegisterImport(id: string, root: string, generatedRegister: string): boolean {\n if (generatedRegister.endsWith('.d.ts')) return false;\n const file = stripQuery(id);\n if (!/\\.[cm]?[jt]sx?$/.test(file)) return false;\n if (file.includes(`${path.sep}node_modules${path.sep}`)) return false;\n const absolute = path.resolve(file);\n if (absolute === generatedRegister) return false;\n return isPathInsideRoot(absolute, root);\n}\n\nfunction renderGeneratedImport(id: string, generatedRegister: string): string {\n const fromDir = path.dirname(stripQuery(id));\n let relative = toPosixPath(path.relative(fromDir, generatedRegister));\n if (!relative.startsWith('.')) relative = `./${relative}`;\n return `import '${relative}';`;\n}\n\nfunction stripQuery(id: string): string {\n return id.split('?')[0];\n}\n\nfunction normalizeModels(input: ModelInput): ModelEntry[] {\n if (typeof input === 'string') return [createModelEntry(deriveModelId(input), input)];\n if (Array.isArray(input)) return input.map((file) => createModelEntry(deriveModelId(file), file));\n return Object.entries(input).map(([id, file]) => createModelEntry(sanitizeModelId(id), file));\n}\n\nfunction createModelEntry(id: string, file: string): ModelEntry {\n return { id, file, names: createEmptyNames() };\n}\n\nfunction deriveModelId(file: string): string {\n const normalized = file.replace(/\\\\/g, '/');\n const parts = normalized.split('/').filter(Boolean);\n const filename = parts.at(-1) ?? 'model';\n const parent = parts.length > 1 ? parts.at(-2) : undefined;\n const base = filename.replace(/\\.(xml|mjcf|urdf)$/i, '');\n return sanitizeModelId(parent && ['scene', 'model', 'robot'].includes(base.toLowerCase()) ? parent : base);\n}\n\nfunction sanitizeModelId(value: string): string {\n const sanitized = value.replace(/[^A-Za-z0-9_$]/g, '_').replace(/^[^A-Za-z_$]+/, '');\n return sanitized || 'model';\n}\n\nfunction mergeNames(target: Record<RegisterKey, Set<string>>, source: Record<RegisterKey, Set<string>>) {\n for (const key of REGISTER_KEYS) {\n for (const value of source[key]) target[key].add(value);\n }\n}\n\nfunction shouldRegenerate(file: string, watchedFiles: string[], models: readonly ModelEntry[], root: string): boolean {\n const absolute = path.resolve(file);\n if (watchedFiles.includes(absolute)) return true;\n if (!MODEL_EXTENSIONS.has(path.extname(absolute).toLowerCase())) return false;\n const modelDirs = models.map((model) => path.dirname(path.resolve(root, model.file)));\n return modelDirs.some((dir) => isPathInsideRoot(absolute, dir));\n}\n\nfunction isPathInsideRoot(filePath: string, root: string): boolean {\n const relative = path.relative(path.resolve(root), path.resolve(filePath));\n return relative === '' || (relative !== '' && !relative.startsWith('..') && !path.isAbsolute(relative));\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mujoco-react",
3
- "version": "9.5.0",
3
+ "version": "10.0.0",
4
4
  "description": "Composable React Three Fiber building blocks for MuJoCo WASM simulations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -849,7 +849,7 @@ function applyInitialPose(mjModel: MujocoModel, mjData: MujocoData, config: Scen
849
849
  }
850
850
 
851
851
  /**
852
- * Config-driven scene loader — replaces the old RobotLoader + patchSingleRobot approach.
852
+ * Config-driven scene loader — replaces the old single-model patching approach.
853
853
  */
854
854
  export async function loadScene(
855
855
  mujoco: MujocoModule,
@@ -43,7 +43,7 @@ export type ControllerComponent<TConfig> = React.FC<{
43
43
  * const MyController = createController<{ speed: number }>(
44
44
  * { name: 'my-controller', defaultConfig: { speed: 1.0 } },
45
45
  * function MyControllerImpl({ config }) {
46
- * const wheel = useCtrl(RobotActuators.mobile.leftWheel);
46
+ * const wheel = useCtrl(ModelActuators.mobile.leftWheel);
47
47
  *
48
48
  * useBeforePhysicsStep(({ data }) => {
49
49
  * wheel.write(config.speed);
@@ -102,7 +102,7 @@ export function createController<TConfig>(
102
102
  * { name: 'useMyController', defaultConfig: { gain: 1.0 } },
103
103
  * function useMyControllerImpl(config) {
104
104
  * // config is MyConfig | null — hooks must be called unconditionally
105
- * const joint = useCtrl(config?.actuator ?? RobotActuators.franka.actuator1);
105
+ * const joint = useCtrl(config?.actuator ?? ModelActuators.franka.actuator1);
106
106
  *
107
107
  * useBeforePhysicsStep(({ data }) => {
108
108
  * if (!config) return;
@@ -94,7 +94,14 @@ export const useIkController = createControllerHook<IkConfig, IkContextValue>(
94
94
  return genericIkRef.current.solve(
95
95
  model, data, siteIdRef.current, controlGroup.qposAdr,
96
96
  position, quaternion, currentQ,
97
- { damping: config.damping, maxIterations: config.maxIterations },
97
+ {
98
+ damping: config.damping,
99
+ epsilon: config.epsilon,
100
+ maxIterations: config.maxIterations,
101
+ posWeight: config.posWeight,
102
+ rotWeight: config.rotWeight,
103
+ tolerance: config.tolerance,
104
+ },
98
105
  );
99
106
  },
100
107
  [config, mjModelRef, mjDataRef],
@@ -8,23 +8,34 @@
8
8
  import { useEffect, useRef } from 'react';
9
9
  import { useMujocoContext, useAfterPhysicsStep } from '../core/MujocoSimProvider';
10
10
  import { getName } from '../core/SceneLoader';
11
- import type { Joints, JointStateResult } from '../types';
11
+ import type {
12
+ ArrayJointStateResult,
13
+ Joints,
14
+ JointStateOptions,
15
+ JointStateResult,
16
+ ScalarJointStateResult,
17
+ } from '../types';
12
18
 
13
19
  /**
14
20
  * Track a MuJoCo joint's position and velocity by name.
15
21
  * Values are updated every physics frame via refs (no re-renders).
16
22
  *
17
- * For hinge/slide joints, position/velocity are scalar (stored as Float64Array of length 1).
23
+ * For hinge/slide joints, position/velocity are scalar numbers.
18
24
  * For ball joints, position is quat (4), velocity is angular vel (3).
19
25
  * For free joints, position is pos+quat (7), velocity is lin+ang vel (6).
20
26
  */
21
- export function useJointState(name: Joints): JointStateResult {
27
+ export function useJointState(name: Joints, options: { kind: 'scalar' }): ScalarJointStateResult;
28
+ export function useJointState(name: Joints, options: { kind: 'array' }): ArrayJointStateResult;
29
+ export function useJointState(name: Joints, options?: JointStateOptions): JointStateResult;
30
+ export function useJointState(name: Joints, options: JointStateOptions = {}): JointStateResult {
22
31
  const { mjModelRef, mjDataRef, status } = useMujocoContext();
23
32
  const jointIdRef = useRef(-1);
24
33
  const qposAdrRef = useRef(0);
25
34
  const dofAdrRef = useRef(0);
26
35
  const qposDimRef = useRef(1);
27
36
  const dofDimRef = useRef(1);
37
+ const kindRef = useRef(options.kind ?? 'auto');
38
+ kindRef.current = options.kind ?? 'auto';
28
39
  const positionRef = useRef<number | Float64Array>(0);
29
40
  const velocityRef = useRef<number | Float64Array>(0);
30
41
  // Preallocated typed arrays for multi-DOF joints
@@ -45,8 +56,8 @@ export function useJointState(name: Joints): JointStateResult {
45
56
  else if (type === 1) { qposDimRef.current = 4; dofDimRef.current = 3; }
46
57
  else { qposDimRef.current = 1; dofDimRef.current = 1; }
47
58
 
48
- // Preallocate buffers for multi-DOF joints
49
- if (qposDimRef.current > 1) {
59
+ // Preallocate buffers when callers request array output, or for multi-DOF joints.
60
+ if (kindRef.current === 'array' || qposDimRef.current > 1) {
50
61
  posBufferRef.current = new Float64Array(qposDimRef.current);
51
62
  velBufferRef.current = new Float64Array(dofDimRef.current);
52
63
  } else {
@@ -57,13 +68,13 @@ export function useJointState(name: Joints): JointStateResult {
57
68
  }
58
69
  }
59
70
  jointIdRef.current = -1;
60
- }, [name, status, mjModelRef]);
71
+ }, [name, options.kind, status, mjModelRef]);
61
72
 
62
73
  useAfterPhysicsStep(({ data }) => {
63
74
  if (jointIdRef.current < 0) return;
64
75
  const qa = qposAdrRef.current;
65
76
  const da = dofAdrRef.current;
66
- if (qposDimRef.current === 1) {
77
+ if (kindRef.current === 'scalar' || (kindRef.current === 'auto' && qposDimRef.current === 1)) {
67
78
  positionRef.current = data.qpos[qa];
68
79
  velocityRef.current = data.qvel[da];
69
80
  } else {