@holoscript/core 6.1.3 → 8.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.
Files changed (166) hide show
  1. package/dist/{GLTFPipeline-SFIORFJU.js → GLTFPipeline-276GE64O.js} +6 -6
  2. package/dist/{GLTFPipeline-VNNDPONV.cjs → GLTFPipeline-M7WSSJED.cjs} +10 -10
  3. package/dist/HoloScriptRuntime-3URVTKPJ.js +10 -0
  4. package/dist/HoloScriptRuntime-SXEAEU2N.cjs +19 -0
  5. package/dist/{chunk-2B7WVIDZ.js → chunk-23J755AR.js} +4 -4
  6. package/dist/{chunk-HANL7K2Q.cjs → chunk-253GBQZY.cjs} +38 -38
  7. package/dist/{chunk-KQTPCYTG.cjs → chunk-25IQCHTO.cjs} +38 -38
  8. package/dist/{chunk-V73NPPTM.cjs → chunk-3AO425MZ.cjs} +20 -20
  9. package/dist/{chunk-6S6TKNEA.cjs → chunk-3HYYMEXI.cjs} +279 -124
  10. package/dist/{chunk-IHESJZSW.js → chunk-3NFFOWGG.js} +6 -209
  11. package/dist/{chunk-AO4I2Z7M.cjs → chunk-3WZEJHUQ.cjs} +7 -7
  12. package/dist/{chunk-IRWWS72C.cjs → chunk-4V2E7U7Q.cjs} +7 -7
  13. package/dist/{chunk-ER4GATIU.js → chunk-62FBK3B7.js} +6 -6
  14. package/dist/{chunk-L63H3SQ4.cjs → chunk-6DPSFNJB.cjs} +19 -19
  15. package/dist/{chunk-XFXGA5IW.cjs → chunk-73FELZVJ.cjs} +14 -14
  16. package/dist/{chunk-QWNQ523V.cjs → chunk-7CUEMLDZ.cjs} +47 -47
  17. package/dist/{chunk-52ULD552.cjs → chunk-7HIASF7S.cjs} +13 -13
  18. package/dist/{chunk-U4NBQJBY.js → chunk-ANXZFVY2.js} +3 -3
  19. package/dist/{chunk-NHHVLKV3.js → chunk-AYBXB26F.js} +5 -5
  20. package/dist/{chunk-KX76JUQY.js → chunk-B4TFTDG4.js} +3 -3
  21. package/dist/{chunk-OEFY723R.js → chunk-BE4UJCQT.js} +4 -4
  22. package/dist/{chunk-DIL6DDDN.cjs → chunk-C2A5DUMF.cjs} +38 -38
  23. package/dist/{chunk-H3MGK7TX.cjs → chunk-CXFDRBQU.cjs} +10 -10
  24. package/dist/{chunk-4SY77NA4.cjs → chunk-D54CNIAJ.cjs} +2 -2
  25. package/dist/{chunk-22W6NGYN.js → chunk-DAJXW4KX.js} +3 -3
  26. package/dist/{chunk-RUXGBKPS.cjs → chunk-EUDQTK7N.cjs} +15 -222
  27. package/dist/{chunk-SXYLMIGP.js → chunk-F43YAA34.js} +3 -3
  28. package/dist/{chunk-H5DZIHJP.cjs → chunk-FYSPZT4V.cjs} +7 -7
  29. package/dist/{chunk-TK74TR4H.js → chunk-GIOYPNTH.js} +36 -2
  30. package/dist/{chunk-2HLIGOKU.cjs → chunk-GQHQOPXZ.cjs} +36 -2
  31. package/dist/{chunk-BPICAGBV.cjs → chunk-GQT4TYKY.cjs} +35 -35
  32. package/dist/{chunk-QAVXL2IH.js → chunk-GYZE55MO.js} +3 -3
  33. package/dist/{chunk-77V4GTCA.js → chunk-H652NHX5.js} +78 -74
  34. package/dist/{chunk-KHPCJRI3.cjs → chunk-HINXWAOD.cjs} +14 -14
  35. package/dist/{chunk-W6P2GBHH.cjs → chunk-HZSPDCXV.cjs} +3 -3
  36. package/dist/{chunk-EMMC5CSQ.js → chunk-HZTDET3N.js} +4 -4
  37. package/dist/{chunk-5CKA5SXU.js → chunk-IPWSXCCN.js} +4 -4
  38. package/dist/{chunk-GQYKQSTC.cjs → chunk-IUTY5WQ2.cjs} +5 -5
  39. package/dist/{chunk-MSMIFMBL.js → chunk-IVSZDECV.js} +4 -4
  40. package/dist/{chunk-2A7FURVO.js → chunk-IZM5VQZD.js} +4 -4
  41. package/dist/{chunk-33XCOVE3.js → chunk-J6M4FPK5.js} +3 -3
  42. package/dist/{chunk-6KMK2UXT.cjs → chunk-JC5YBPSF.cjs} +5 -5
  43. package/dist/{chunk-W55Z7QIX.js → chunk-JCLBKPMX.js} +3 -3
  44. package/dist/{chunk-MXJ5SS53.cjs → chunk-JJBE3TIH.cjs} +10 -10
  45. package/dist/{chunk-HRODTEEO.js → chunk-JX7YL6ZE.js} +5 -5
  46. package/dist/{chunk-IVIA7K75.cjs → chunk-K4VVR7CN.cjs} +18 -18
  47. package/dist/{chunk-VSK7W3O5.cjs → chunk-KEFNV2WM.cjs} +16 -16
  48. package/dist/{chunk-HZCQO4JM.cjs → chunk-KH4CNH66.cjs} +4 -4
  49. package/dist/{chunk-6FGQNDR4.js → chunk-KJLB4OPV.js} +4 -4
  50. package/dist/{chunk-RMHC2VG7.cjs → chunk-KKP7JKN4.cjs} +6 -2
  51. package/dist/{chunk-OEV5RMZO.cjs → chunk-KQCN6AKJ.cjs} +5 -5
  52. package/dist/{chunk-7AD52FRS.cjs → chunk-KVRSTFNH.cjs} +14 -14
  53. package/dist/{chunk-ZKSS47EV.cjs → chunk-LICPB5HZ.cjs} +13 -13
  54. package/dist/{chunk-S5IFXW6E.js → chunk-MGE5Z4GS.js} +4 -4
  55. package/dist/{chunk-6L4VE27M.js → chunk-NBMHU6SW.js} +4 -4
  56. package/dist/{chunk-QCCBXSCE.js → chunk-NGKREZ36.js} +5 -5
  57. package/dist/{chunk-27MPVJVZ.cjs → chunk-NHWSN2SD.cjs} +21 -21
  58. package/dist/{chunk-XMWZG36H.js → chunk-NV4VMVXU.js} +3 -3
  59. package/dist/{chunk-Y3MWXQSB.cjs → chunk-NXZFOPVD.cjs} +19 -19
  60. package/dist/{chunk-ZUL5AVTX.cjs → chunk-OBIYPYYS.cjs} +5 -5
  61. package/dist/{chunk-ZXBZVXDW.js → chunk-OMXII44L.js} +3 -3
  62. package/dist/{chunk-MJVIRCUV.cjs → chunk-OR4Q2BGL.cjs} +18 -18
  63. package/dist/{chunk-6ASWLXXN.js → chunk-PHVRG4I2.js} +4 -4
  64. package/dist/{chunk-QTPMJRGS.js → chunk-QPSKHBJP.js} +6 -2
  65. package/dist/{chunk-VEXPG4WN.js → chunk-QXH7QDSZ.js} +3 -3
  66. package/dist/chunk-RARB3MBR.js +207 -0
  67. package/dist/{chunk-EOBB6A4B.js → chunk-RVBHAXFG.js} +231 -76
  68. package/dist/{chunk-XXZJEFKW.cjs → chunk-S3MDHNKB.cjs} +5 -5
  69. package/dist/{chunk-4UUKPCY4.js → chunk-S4W6Z2MN.js} +4 -4
  70. package/dist/{chunk-BVLP6D3Q.cjs → chunk-SJBGLS25.cjs} +5 -5
  71. package/dist/chunk-SMIWS6DE.cjs +212 -0
  72. package/dist/{chunk-R3IVNY6P.js → chunk-T2QCTZMO.js} +4 -4
  73. package/dist/{chunk-AIX25INK.cjs → chunk-TVHSPJ4N.cjs} +79 -75
  74. package/dist/{chunk-Z5XMPRNC.cjs → chunk-U44IKGG7.cjs} +30 -30
  75. package/dist/{chunk-OPZ7XDDI.js → chunk-UJXISJBN.js} +3 -3
  76. package/dist/{chunk-FXKTYFYA.js → chunk-UM6C3CGK.js} +4 -4
  77. package/dist/{chunk-LAOCQJ2M.js → chunk-UMABK6SI.js} +4 -4
  78. package/dist/{chunk-GN3KDX4W.js → chunk-V6MKC2FZ.js} +3 -3
  79. package/dist/{chunk-EDPQSGB3.cjs → chunk-W7VDOASB.cjs} +5 -5
  80. package/dist/{chunk-DMXC24WV.js → chunk-WJIHFLMJ.js} +2 -2
  81. package/dist/{chunk-UDMYRFDZ.js → chunk-WRKUDAZJ.js} +3 -3
  82. package/dist/{chunk-GCMWDSBZ.cjs → chunk-XIVIE43A.cjs} +5 -5
  83. package/dist/{chunk-UD3DSHZM.js → chunk-XKTPFXGA.js} +3 -3
  84. package/dist/{chunk-HGVXZDSK.cjs → chunk-XUUVDHIF.cjs} +7 -7
  85. package/dist/{chunk-5N54COB6.cjs → chunk-YN6V7R3L.cjs} +13 -13
  86. package/dist/{chunk-I2O7TW6B.js → chunk-ZBQXLH2L.js} +4 -4
  87. package/dist/{chunk-EOFNVCM6.js → chunk-ZU7NIRT6.js} +11 -11
  88. package/dist/{chunk-P7YIA5LN.js → chunk-ZZEI7MV4.js} +4 -4
  89. package/dist/compiler/agent-inference.cjs +6 -6
  90. package/dist/compiler/agent-inference.js +2 -2
  91. package/dist/compiler/android-xr.cjs +6 -6
  92. package/dist/compiler/android-xr.js +4 -4
  93. package/dist/compiler/android.cjs +5 -5
  94. package/dist/compiler/android.js +3 -3
  95. package/dist/compiler/ar.cjs +5 -5
  96. package/dist/compiler/ar.js +3 -3
  97. package/dist/compiler/babylon.cjs +5 -5
  98. package/dist/compiler/babylon.js +4 -4
  99. package/dist/compiler/business-quest.cjs +9 -9
  100. package/dist/compiler/business-quest.js +1 -1
  101. package/dist/compiler/context.cjs +5 -5
  102. package/dist/compiler/context.js +2 -2
  103. package/dist/compiler/domain-block-utils.cjs +151 -151
  104. package/dist/compiler/domain-block-utils.js +3 -3
  105. package/dist/compiler/dtdl.cjs +6 -6
  106. package/dist/compiler/dtdl.js +3 -3
  107. package/dist/compiler/gltf-pipeline.cjs +8 -8
  108. package/dist/compiler/gltf-pipeline.js +1 -1
  109. package/dist/compiler/godot.cjs +5 -5
  110. package/dist/compiler/godot.js +4 -4
  111. package/dist/compiler/incremental.cjs +7 -7
  112. package/dist/compiler/incremental.js +2 -2
  113. package/dist/compiler/index.cjs +182 -182
  114. package/dist/compiler/index.js +56 -56
  115. package/dist/compiler/ios.cjs +5 -5
  116. package/dist/compiler/ios.js +3 -3
  117. package/dist/compiler/llm-provider-capabilities.cjs +5 -5
  118. package/dist/compiler/llm-provider-capabilities.js +2 -2
  119. package/dist/compiler/multi-layer.cjs +7 -7
  120. package/dist/compiler/multi-layer.js +6 -6
  121. package/dist/compiler/openxr.cjs +5 -5
  122. package/dist/compiler/openxr.js +4 -4
  123. package/dist/compiler/playcanvas.cjs +5 -5
  124. package/dist/compiler/playcanvas.js +4 -4
  125. package/dist/compiler/r3f.cjs +9 -9
  126. package/dist/compiler/r3f.js +4 -4
  127. package/dist/compiler/sdf.cjs +6 -6
  128. package/dist/compiler/sdf.js +4 -4
  129. package/dist/compiler/state.cjs +5 -5
  130. package/dist/compiler/state.js +3 -3
  131. package/dist/compiler/trait-composition.cjs +6 -6
  132. package/dist/compiler/trait-composition.js +2 -2
  133. package/dist/compiler/unity.cjs +5 -5
  134. package/dist/compiler/unity.js +4 -4
  135. package/dist/compiler/unreal.cjs +6 -6
  136. package/dist/compiler/unreal.js +4 -4
  137. package/dist/compiler/urdf.cjs +13 -13
  138. package/dist/compiler/urdf.js +4 -4
  139. package/dist/compiler/usd-physics.cjs +6 -6
  140. package/dist/compiler/usd-physics.js +3 -3
  141. package/dist/compiler/visionos.cjs +5 -5
  142. package/dist/compiler/visionos.js +4 -4
  143. package/dist/compiler/vrchat.cjs +6 -6
  144. package/dist/compiler/vrchat.js +4 -4
  145. package/dist/compiler/vrr.cjs +6 -6
  146. package/dist/compiler/vrr.js +4 -4
  147. package/dist/compiler/wasm.cjs +9 -9
  148. package/dist/compiler/wasm.js +4 -4
  149. package/dist/compiler/webgpu.cjs +5 -5
  150. package/dist/compiler/webgpu.js +4 -4
  151. package/dist/debugger.cjs +7 -6
  152. package/dist/debugger.js +5 -4
  153. package/dist/entries/scripting.cjs +0 -13
  154. package/dist/entries/scripting.js +0 -1
  155. package/dist/index.cjs +1002 -881
  156. package/dist/index.js +506 -87
  157. package/dist/parser.cjs +5 -5
  158. package/dist/parser.js +1 -1
  159. package/dist/reconstruction/index.cjs +31 -31
  160. package/dist/reconstruction/index.js +2 -2
  161. package/dist/runtime.cjs +302 -4
  162. package/dist/runtime.d.ts +61 -0
  163. package/dist/runtime.js +25 -3
  164. package/dist/traits/index.cjs +450 -439
  165. package/dist/traits/index.js +24 -13
  166. package/package.json +20 -20
@@ -6,33 +6,15 @@ var chunkWDT3JTGM_cjs = require('./chunk-WDT3JTGM.cjs');
6
6
  var chunk4PDEPEQW_cjs = require('./chunk-4PDEPEQW.cjs');
7
7
  var chunkXJAN7CZG_cjs = require('./chunk-XJAN7CZG.cjs');
8
8
  var chunkXHIV6326_cjs = require('./chunk-XHIV6326.cjs');
9
- var chunkAIX25INK_cjs = require('./chunk-AIX25INK.cjs');
9
+ var chunkTVHSPJ4N_cjs = require('./chunk-TVHSPJ4N.cjs');
10
10
  var chunkILRBGFVD_cjs = require('./chunk-ILRBGFVD.cjs');
11
11
  var chunkE7JP3BS3_cjs = require('./chunk-E7JP3BS3.cjs');
12
12
  var chunkHCCQLAA4_cjs = require('./chunk-HCCQLAA4.cjs');
13
- var NavigationEngine = require('@holoscript/engine/runtime/NavigationEngine');
14
- var VoiceSynthesizer = require('@holoscript/engine/runtime/VoiceSynthesizer');
15
- var EmotionDetector = require('@holoscript/engine/runtime/EmotionDetector');
16
- var PhysicsEngine = require('@holoscript/engine/runtime/PhysicsEngine');
17
- var IslandDetector = require('@holoscript/engine/physics/IslandDetector');
18
- var SoftBodyAdapter = require('@holoscript/engine/physics/SoftBodyAdapter');
19
- var MLSMPMFluid = require('@holoscript/engine/physics/MLSMPMFluid');
20
- var WeatherBlackboard = require('@holoscript/engine/environment/WeatherBlackboard');
21
- var SoftBodySolver = require('@holoscript/engine/physics/SoftBodySolver');
22
- var choreography = require('@holoscript/engine/choreography');
23
- var negotiation = require('@holoscript/framework/negotiation');
24
- var mesh = require('@holoscript/mesh');
25
- var agents = require('@holoscript/framework/agents');
26
- var MQTTClient = require('@holoscript/engine/runtime/protocols/MQTTClient');
27
- var BoneSystem = require('@holoscript/engine/animation/BoneSystem');
28
- var IKSolver = require('@holoscript/engine/animation/IKSolver');
29
- var AvatarController = require('@holoscript/engine/animation/AvatarController');
30
- var ai = require('@holoscript/framework/ai');
31
- var SpringAnimator = require('@holoscript/engine/animation/SpringAnimator');
32
13
  var events = require('events');
33
- var spatial = require('@holoscript/engine/spatial');
34
14
  var jose = require('jose');
35
15
 
16
+ // src/traits/FlowFieldTrait.ts
17
+ var _navigationEngine = null;
36
18
  function toTuple(v) {
37
19
  if (Array.isArray(v)) return v;
38
20
  return [v[0] ?? 0, v[1] ?? 0, v[2] ?? 0];
@@ -55,10 +37,12 @@ var flowFieldHandler = {
55
37
  onDetach(node) {
56
38
  delete node.__flowFieldState;
57
39
  },
58
- onUpdate(node, config, context, delta) {
40
+ async onUpdate(node, config, context, delta) {
59
41
  const state = node.__flowFieldState;
60
42
  if (!state || !config.destinationId) return;
61
- const navEngine = NavigationEngine.getNavigationEngine("gpu_flowfield") || NavigationEngine.getNavigationEngine("default");
43
+ _navigationEngine ?? (_navigationEngine = await import('@holoscript/engine/runtime/NavigationEngine'));
44
+ const { getNavigationEngine } = _navigationEngine;
45
+ const navEngine = getNavigationEngine("gpu_flowfield") || getNavigationEngine("default");
62
46
  if (!navEngine) return;
63
47
  const currentPos = toTuple(node.properties?.position || [0, 0, 0]);
64
48
  const flowDir = toTuple(navEngine.sampleDirection(config.destinationId, currentPos));
@@ -966,6 +950,9 @@ var rbacHandler = {
966
950
  }
967
951
  }
968
952
  };
953
+
954
+ // src/traits/EmotionalVoiceTrait.ts
955
+ var _voiceSynthesizer = null;
969
956
  var emotionalVoiceHandler = {
970
957
  name: "emotional_voice",
971
958
  defaultConfig: {
@@ -1003,7 +990,9 @@ var emotionalVoiceHandler = {
1003
990
  }
1004
991
  };
1005
992
  emotionalVoiceHandler.handleSpeak = async function(node, config, state, request) {
1006
- const synthesizer = VoiceSynthesizer.getVoiceSynthesizer("default") || Array.from(VoiceSynthesizer.voiceSynthesizerRegistry.values())[0];
993
+ _voiceSynthesizer ?? (_voiceSynthesizer = await import('@holoscript/engine/runtime/VoiceSynthesizer'));
994
+ const { getVoiceSynthesizer, voiceSynthesizerRegistry } = _voiceSynthesizer;
995
+ const synthesizer = getVoiceSynthesizer("default") || Array.from(voiceSynthesizerRegistry.values())[0];
1007
996
  if (!synthesizer) {
1008
997
  console.warn("No VoiceSynthesizer registered. Skipping speech for", node.name);
1009
998
  return;
@@ -1033,9 +1022,14 @@ emotionalVoiceHandler.handleSpeak = async function(node, config, state, request)
1033
1022
  request
1034
1023
  });
1035
1024
  };
1025
+
1026
+ // src/traits/UserMonitorTrait.ts
1027
+ var _emotionDetector = null;
1036
1028
  var traitState = /* @__PURE__ */ new WeakMap();
1037
- function performInference(node, config, _context, state) {
1038
- const detector = EmotionDetector.getEmotionDetector("default") || EmotionDetector.getEmotionDetector("lite");
1029
+ async function performInference(node, config, _context, state) {
1030
+ _emotionDetector ?? (_emotionDetector = await import('@holoscript/engine/runtime/EmotionDetector'));
1031
+ const { getEmotionDetector } = _emotionDetector;
1032
+ const detector = getEmotionDetector("default") || getEmotionDetector("lite");
1039
1033
  if (!detector) return;
1040
1034
  const headStability = calculateStability(state.headPositions);
1041
1035
  const handStability = calculateStability(state.handPositions);
@@ -1079,7 +1073,7 @@ var userMonitorHandler = {
1079
1073
  traitState.delete(node);
1080
1074
  delete node.__userMonitorState;
1081
1075
  },
1082
- onUpdate(node, config, context, delta) {
1076
+ async onUpdate(node, config, context, delta) {
1083
1077
  const state = traitState.get(node);
1084
1078
  if (!state) return;
1085
1079
  const headPos = context.vr.headset.position;
@@ -1100,7 +1094,7 @@ var userMonitorHandler = {
1100
1094
  state.lastInferenceTime += delta;
1101
1095
  if (state.lastInferenceTime >= (config.updateRate ?? 0.2)) {
1102
1096
  state.lastInferenceTime = 0;
1103
- performInference(node, config, context, state);
1097
+ await performInference(node, config, context, state);
1104
1098
  }
1105
1099
  },
1106
1100
  onEvent(node, config, context, event) {
@@ -7057,6 +7051,11 @@ var gpuParticleHandler = {
7057
7051
  }
7058
7052
  }
7059
7053
  };
7054
+
7055
+ // src/traits/GPUPhysicsTrait.ts
7056
+ var _physicsEngineModule = null;
7057
+ var _islandDetectorModule = null;
7058
+ var _softBodyAdapterModule = null;
7060
7059
  function extractPosition(node) {
7061
7060
  const pos = node?.properties?.position ?? node?.position;
7062
7061
  if (Array.isArray(pos) && pos.length >= 3) {
@@ -7081,19 +7080,25 @@ var gpuPhysicsHandler = {
7081
7080
  restitution: 0.3,
7082
7081
  isStatic: false
7083
7082
  },
7084
- onAttach(node, config, _context) {
7083
+ async onAttach(node, config, _context) {
7084
+ _islandDetectorModule ?? (_islandDetectorModule = await import('@holoscript/engine/physics/IslandDetector'));
7085
+ const { IslandDetector } = _islandDetectorModule;
7085
7086
  if (config.sim_type === "soft_body") {
7086
- const softBody = new SoftBodyAdapter.SoftBodyAdapter(node, config);
7087
+ _softBodyAdapterModule ?? (_softBodyAdapterModule = await import('@holoscript/engine/physics/SoftBodyAdapter'));
7088
+ const { SoftBodyAdapter } = _softBodyAdapterModule;
7089
+ const softBody = new SoftBodyAdapter(node, config);
7087
7090
  node.__gpuPhysicsState = {
7088
7091
  engineId: "soft_body_solver",
7089
7092
  isSimulating: true,
7090
7093
  lastPosition: extractPosition(node),
7091
- islandDetector: new IslandDetector.IslandDetector(),
7094
+ islandDetector: new IslandDetector(),
7092
7095
  softBody
7093
7096
  };
7094
7097
  return;
7095
7098
  }
7096
- const engine = PhysicsEngine.getPhysicsEngine("webgpu") || PhysicsEngine.getPhysicsEngine("default");
7099
+ _physicsEngineModule ?? (_physicsEngineModule = await import('@holoscript/engine/runtime/PhysicsEngine'));
7100
+ const { getPhysicsEngine } = _physicsEngineModule;
7101
+ const engine = getPhysicsEngine("webgpu") || getPhysicsEngine("default");
7097
7102
  if (!engine) {
7098
7103
  console.warn("No GPU PhysicsEngine found. Physics will be disabled for", node.name);
7099
7104
  return;
@@ -7103,7 +7108,7 @@ var gpuPhysicsHandler = {
7103
7108
  // Fallback or from config
7104
7109
  isSimulating: true,
7105
7110
  lastPosition: [0, 0, 0],
7106
- islandDetector: new IslandDetector.IslandDetector()
7111
+ islandDetector: new IslandDetector()
7107
7112
  };
7108
7113
  node.__gpuPhysicsState = state;
7109
7114
  engine?.addBody(node.name || "", {
@@ -7117,24 +7122,28 @@ var gpuPhysicsHandler = {
7117
7122
  restitution: config.restitution
7118
7123
  });
7119
7124
  },
7120
- onDetach(node) {
7125
+ async onDetach(node) {
7121
7126
  const state = node.__gpuPhysicsState;
7122
7127
  if (state) {
7123
7128
  if (state.softBody) ; else {
7124
- const engine = PhysicsEngine.getPhysicsEngine(state.engineId);
7129
+ _physicsEngineModule ?? (_physicsEngineModule = await import('@holoscript/engine/runtime/PhysicsEngine'));
7130
+ const { getPhysicsEngine } = _physicsEngineModule;
7131
+ const engine = getPhysicsEngine(state.engineId);
7125
7132
  engine?.removeBody(node.name || "");
7126
7133
  }
7127
7134
  delete node.__gpuPhysicsState;
7128
7135
  }
7129
7136
  },
7130
- onUpdate(node, _config, _context, _delta) {
7137
+ async onUpdate(node, _config, _context, _delta) {
7131
7138
  const state = node.__gpuPhysicsState;
7132
7139
  if (!state || !state.isSimulating) return;
7133
7140
  if (state.softBody) {
7134
7141
  state.softBody.update(_delta);
7135
7142
  return;
7136
7143
  }
7137
- const engine = PhysicsEngine.getPhysicsEngine(state.engineId);
7144
+ _physicsEngineModule ?? (_physicsEngineModule = await import('@holoscript/engine/runtime/PhysicsEngine'));
7145
+ const { getPhysicsEngine } = _physicsEngineModule;
7146
+ const engine = getPhysicsEngine(state.engineId);
7138
7147
  if (!engine) return;
7139
7148
  const states = engine.getStates();
7140
7149
  const bodyState = states[node.name || ""];
@@ -7143,13 +7152,15 @@ var gpuPhysicsHandler = {
7143
7152
  node.rotation = bodyState.rotation;
7144
7153
  }
7145
7154
  },
7146
- onEvent(node, config, context, event) {
7155
+ async onEvent(node, config, context, event) {
7147
7156
  const state = node.__gpuPhysicsState;
7148
7157
  if (!state) return;
7149
7158
  const eventType = typeof event === "string" ? event : event.type;
7150
7159
  if (eventType === "apply-force") {
7151
7160
  if (state.softBody) ; else {
7152
- const engine = PhysicsEngine.getPhysicsEngine(state.engineId || "webgpu");
7161
+ _physicsEngineModule ?? (_physicsEngineModule = await import('@holoscript/engine/runtime/PhysicsEngine'));
7162
+ const { getPhysicsEngine } = _physicsEngineModule;
7163
+ const engine = getPhysicsEngine(state.engineId || "webgpu");
7153
7164
  engine?.applyForce(
7154
7165
  node.name || "",
7155
7166
  event.data?.force,
@@ -16773,6 +16784,10 @@ function initializeClothMesh(state, config) {
16773
16784
  }
16774
16785
  }
16775
16786
  }
16787
+
16788
+ // src/traits/FluidTrait.ts
16789
+ var _mlsMpmModule = null;
16790
+ var _weatherModule = null;
16776
16791
  var fluidHandler = {
16777
16792
  name: "fluid",
16778
16793
  defaultConfig: {
@@ -16795,7 +16810,7 @@ var fluidHandler = {
16795
16810
  absorption_color: [0.4, 0.04, 0],
16796
16811
  absorption_strength: 2
16797
16812
  },
16798
- onAttach(node, config, context) {
16813
+ async onAttach(node, config, context) {
16799
16814
  const state = {
16800
16815
  isSimulating: false,
16801
16816
  particleCount: 0,
@@ -16811,7 +16826,9 @@ var fluidHandler = {
16811
16826
  };
16812
16827
  node.__fluidState = state;
16813
16828
  if (config.method === "mls_mpm" && context.gpuDevice) {
16814
- const sim = new MLSMPMFluid.MLSMPMFluid({
16829
+ _mlsMpmModule ?? (_mlsMpmModule = await import('@holoscript/engine/physics/MLSMPMFluid'));
16830
+ const { MLSMPMFluid } = _mlsMpmModule;
16831
+ const sim = new MLSMPMFluid({
16815
16832
  type: "liquid",
16816
16833
  particleCount: config.particle_count,
16817
16834
  viscosity: config.viscosity,
@@ -16859,15 +16876,17 @@ var fluidHandler = {
16859
16876
  }
16860
16877
  delete node.__fluidState;
16861
16878
  },
16862
- onUpdate(node, config, context, delta) {
16879
+ async onUpdate(node, config, context, delta) {
16863
16880
  const state = node.__fluidState;
16864
16881
  if (!state || !state.isSimulating) return;
16865
16882
  if (state.mlsMpm && state.gpuReady) {
16866
- if (config.wind_sensitivity > 0 && WeatherBlackboard.weatherBlackboard.wind_speed > 0) {
16883
+ _weatherModule ?? (_weatherModule = await import('@holoscript/engine/environment/WeatherBlackboard'));
16884
+ const { weatherBlackboard } = _weatherModule;
16885
+ if (config.wind_sensitivity > 0 && weatherBlackboard.wind_speed > 0) {
16867
16886
  const s = config.wind_sensitivity;
16868
- const wv = WeatherBlackboard.weatherBlackboard.wind_vector;
16887
+ const wv = weatherBlackboard.wind_vector;
16869
16888
  const windDir = wv ? [wv[0], wv[1], wv[2]] : [0, 0, 0];
16870
- const windSpeed = WeatherBlackboard.weatherBlackboard.wind_speed;
16889
+ const windSpeed = weatherBlackboard.wind_speed;
16871
16890
  state.mlsMpm.setExternalForce(
16872
16891
  windDir[0] * windSpeed * s,
16873
16892
  windDir[1] * windSpeed * s,
@@ -16980,6 +16999,9 @@ var fluidHandler = {
16980
16999
  }
16981
17000
  }
16982
17001
  };
17002
+
17003
+ // src/traits/SoftBodyTrait.ts
17004
+ var _softBodySolverModule = null;
16983
17005
  function autoPopulateFromMesh(node, config) {
16984
17006
  const meshData = node.properties?.meshData;
16985
17007
  if (!meshData || !meshData.positions || !meshData.indices) {
@@ -17041,7 +17063,7 @@ var softBodyHandler = {
17041
17063
  surface_stiffness: 0.5,
17042
17064
  bending_stiffness: 0.3
17043
17065
  },
17044
- onAttach(node, config, context) {
17066
+ async onAttach(node, config, context) {
17045
17067
  const state = {
17046
17068
  isSimulating: false,
17047
17069
  isDeformed: false,
@@ -17053,8 +17075,10 @@ var softBodyHandler = {
17053
17075
  solver: null
17054
17076
  };
17055
17077
  node.__softBodyState = state;
17078
+ _softBodySolverModule ?? (_softBodySolverModule = await import('@holoscript/engine/physics/SoftBodySolver'));
17079
+ const { SoftBodySolver } = _softBodySolverModule;
17056
17080
  const { particles, constraints } = autoPopulateFromMesh(node, config);
17057
- state.solver = new SoftBodySolver.SoftBodySolver(particles, constraints);
17081
+ state.solver = new SoftBodySolver(particles, constraints);
17058
17082
  state.isSimulating = true;
17059
17083
  state.restVolume = node.properties?.meshData?.volume || 1;
17060
17084
  },
@@ -18634,6 +18658,9 @@ var layerAwareHandler = {
18634
18658
  onUpdate(node, config, context, _delta) {
18635
18659
  }
18636
18660
  };
18661
+
18662
+ // src/traits/ChoreographyTrait.ts
18663
+ var _choreography = null;
18637
18664
  var DEFAULT_CHOREOGRAPHY_CONFIG = {
18638
18665
  mode: "participant",
18639
18666
  auto_start: true,
@@ -18672,14 +18699,16 @@ function addEvent(state, type, planId, config, stepId) {
18672
18699
  var choreographyHandler = {
18673
18700
  name: "choreography",
18674
18701
  defaultConfig: DEFAULT_CHOREOGRAPHY_CONFIG,
18675
- onAttach(node, config, _context) {
18702
+ async onAttach(node, config, _context) {
18703
+ _choreography ?? (_choreography = await import('@holoscript/engine/choreography'));
18704
+ const { ChoreographyEngine, ChoreographyPlanner } = _choreography;
18676
18705
  const cfg = { ...DEFAULT_CHOREOGRAPHY_CONFIG, ...config };
18677
18706
  const state = createDefaultState();
18678
18707
  state.mode = cfg.mode;
18679
18708
  node.__choreography_state = state;
18680
- state.planner = new choreography.ChoreographyPlanner();
18709
+ state.planner = new ChoreographyPlanner();
18681
18710
  if (cfg.mode === "orchestrator" || cfg.mode === "hybrid") {
18682
- state.engine = new choreography.ChoreographyEngine({
18711
+ state.engine = new ChoreographyEngine({
18683
18712
  maxConcurrency: cfg.max_concurrent_plans,
18684
18713
  defaultTimeout: cfg.default_step_timeout,
18685
18714
  executeFallback: cfg.execute_fallback,
@@ -18731,6 +18760,9 @@ var choreographyHandler = {
18731
18760
  delete n.__choreography_state;
18732
18761
  }
18733
18762
  };
18763
+
18764
+ // src/traits/NegotiationTrait.ts
18765
+ var _negotiationMod = null;
18734
18766
  var DEFAULT_NEGOTIATION_CONFIG = {
18735
18767
  role: "participant",
18736
18768
  default_mechanism: "majority",
@@ -18803,10 +18835,12 @@ async function autoVoteInternal(node, sessionId, config) {
18803
18835
  default:
18804
18836
  return null;
18805
18837
  }
18838
+ _negotiationMod ?? (_negotiationMod = await import('@holoscript/framework/negotiation'));
18839
+ const { getTrustWeight } = _negotiationMod;
18806
18840
  const voteResult = await state.protocol.vote(sessionId, {
18807
18841
  agentId: state.agentId,
18808
18842
  ranking,
18809
- weight: negotiation.getTrustWeight("local"),
18843
+ weight: getTrustWeight("local"),
18810
18844
  justification: `Auto-voted: ${config.auto_vote_strategy}`,
18811
18845
  approvals: void 0,
18812
18846
  abstain: false
@@ -18820,13 +18854,15 @@ async function autoVoteInternal(node, sessionId, config) {
18820
18854
  var negotiationHandler = {
18821
18855
  name: "negotiation",
18822
18856
  defaultConfig: DEFAULT_NEGOTIATION_CONFIG,
18823
- onAttach(node, config, _context) {
18857
+ async onAttach(node, config, _context) {
18824
18858
  const cfg = { ...DEFAULT_NEGOTIATION_CONFIG, ...config };
18825
18859
  const state = createDefaultState2();
18826
18860
  state.role = cfg.role;
18827
18861
  state.agentId = cfg.agent_id || node.id || `agent-${Date.now()}`;
18828
18862
  node.__negotiation_state = state;
18829
- state.protocol = negotiation.getNegotiationProtocol();
18863
+ _negotiationMod ?? (_negotiationMod = await import('@holoscript/framework/negotiation'));
18864
+ const { getNegotiationProtocol } = _negotiationMod;
18865
+ state.protocol = getNegotiationProtocol();
18830
18866
  const unsub1 = state.protocol.on("sessionStarted", ({ session }) => {
18831
18867
  if (session.participants.includes(state.agentId)) {
18832
18868
  state.activeSessions.set(session.id, session);
@@ -18913,10 +18949,12 @@ async function vote(node, sessionId, ranking, options) {
18913
18949
  if (state.role === "observer") {
18914
18950
  throw new Error("Observers cannot vote");
18915
18951
  }
18952
+ _negotiationMod ?? (_negotiationMod = await import('@holoscript/framework/negotiation'));
18953
+ const { getTrustWeight } = _negotiationMod;
18916
18954
  const voteResult = await state.protocol.vote(sessionId, {
18917
18955
  agentId: state.agentId,
18918
18956
  ranking,
18919
- weight: options?.weight ?? negotiation.getTrustWeight("local"),
18957
+ weight: options?.weight ?? getTrustWeight("local"),
18920
18958
  justification: options?.justification,
18921
18959
  approvals: options?.approvals,
18922
18960
  abstain: options?.abstain
@@ -19035,12 +19073,17 @@ function getNegotiationMethods(node) {
19035
19073
  leave: (sessionId) => leave(node, sessionId)
19036
19074
  };
19037
19075
  }
19076
+
19077
+ // src/traits/NetworkedTrait.ts
19038
19078
  chunkE7JP3BS3_cjs.init_safeJsonParse();
19079
+ var _mesh = null;
19039
19080
  var syncProtocolPool = /* @__PURE__ */ new Map();
19040
- function getOrCreateSyncProtocol(roomId, transport = "local", serverUrl) {
19081
+ async function getOrCreateSyncProtocol(roomId, transport = "local", serverUrl) {
19082
+ _mesh ?? (_mesh = await import('@holoscript/mesh'));
19083
+ const { SyncProtocol } = _mesh;
19041
19084
  const isTestEnv = process.env.NODE_ENV === "test" || !!process.env.VITEST;
19042
19085
  if (isTestEnv) {
19043
- return new mesh.SyncProtocol({
19086
+ return new SyncProtocol({
19044
19087
  roomId,
19045
19088
  transport,
19046
19089
  serverUrl,
@@ -19050,7 +19093,7 @@ function getOrCreateSyncProtocol(roomId, transport = "local", serverUrl) {
19050
19093
  }
19051
19094
  const key = `${transport}:${roomId}`;
19052
19095
  if (!syncProtocolPool.has(key)) {
19053
- const protocol = new mesh.SyncProtocol({
19096
+ const protocol = new SyncProtocol({
19054
19097
  roomId,
19055
19098
  transport,
19056
19099
  serverUrl,
@@ -19107,9 +19150,11 @@ var NetworkedTrait = class {
19107
19150
  */
19108
19151
  async connect(transport = "local", serverUrl) {
19109
19152
  const roomId = this.config.room || "default-room";
19153
+ _mesh ?? (_mesh = await import('@holoscript/mesh'));
19154
+ const { WebRTCTransport, WebSocketTransport } = _mesh;
19110
19155
  if (transport === "auto" && serverUrl) {
19111
19156
  try {
19112
- this.rtcTransport = new mesh.WebRTCTransport(serverUrl);
19157
+ this.rtcTransport = new WebRTCTransport(serverUrl);
19113
19158
  await this.rtcTransport.connect();
19114
19159
  this.rtcTransport.onMessage((msg) => {
19115
19160
  const networkMsg = msg;
@@ -19125,7 +19170,7 @@ var NetworkedTrait = class {
19125
19170
  this.rtcTransport = null;
19126
19171
  }
19127
19172
  try {
19128
- this.wsTransport = new mesh.WebSocketTransport(serverUrl);
19173
+ this.wsTransport = new WebSocketTransport(serverUrl);
19129
19174
  await this.wsTransport.connect();
19130
19175
  this.wsTransport.onMessage((msg) => {
19131
19176
  this.handleNetworkMessage(msg);
@@ -19142,7 +19187,7 @@ var NetworkedTrait = class {
19142
19187
  }
19143
19188
  if (serverUrl && transport === "websocket") {
19144
19189
  try {
19145
- this.wsTransport = new mesh.WebSocketTransport(serverUrl);
19190
+ this.wsTransport = new WebSocketTransport(serverUrl);
19146
19191
  await this.wsTransport.connect();
19147
19192
  this.wsTransport.onMessage((msg) => {
19148
19193
  this.handleNetworkMessage(msg);
@@ -19158,7 +19203,7 @@ var NetworkedTrait = class {
19158
19203
  }
19159
19204
  if (serverUrl && transport === "webrtc") {
19160
19205
  try {
19161
- this.rtcTransport = new mesh.WebRTCTransport(serverUrl);
19206
+ this.rtcTransport = new WebRTCTransport(serverUrl);
19162
19207
  await this.rtcTransport.connect();
19163
19208
  this.rtcTransport.onMessage((msg) => {
19164
19209
  const networkMsg = msg;
@@ -19173,7 +19218,7 @@ var NetworkedTrait = class {
19173
19218
  chunkILRBGFVD_cjs.logger.warn(`[NetworkedTrait] WebRTC connection failed, using local sync: ${error}`);
19174
19219
  }
19175
19220
  }
19176
- this.syncProtocol = getOrCreateSyncProtocol(roomId, "local", serverUrl);
19221
+ this.syncProtocol = await getOrCreateSyncProtocol(roomId, "local", serverUrl);
19177
19222
  this.syncProtocol.on("state-updated", (event) => {
19178
19223
  const data = event.data;
19179
19224
  if (data.entityId === this.entityId && !this.isOwner) {
@@ -19726,6 +19771,9 @@ function createNetworkedTrait(config) {
19726
19771
  ...config
19727
19772
  });
19728
19773
  }
19774
+
19775
+ // src/traits/NetworkedTraitHandler.ts
19776
+ var _mesh2 = null;
19729
19777
  var handlerStates = /* @__PURE__ */ new Map();
19730
19778
  function getNodeKey(node) {
19731
19779
  return node.id || `__anon_${Math.random().toString(36).slice(2, 8)}`;
@@ -19835,12 +19883,14 @@ var networkedHandler = {
19835
19883
  // ===========================================================================
19836
19884
  // onUpdate — per-frame sync
19837
19885
  // ===========================================================================
19838
- onUpdate(node, config, context, delta) {
19886
+ async onUpdate(node, config, context, delta) {
19839
19887
  const key = getNodeKey(node);
19840
19888
  const state = handlerStates.get(key);
19841
19889
  if (!state || !state.registered) return;
19842
19890
  const trait = state.trait;
19843
- const baseSyncRate = mesh.SYNC_TIER_RATES[config.syncTier] ?? config.syncRate;
19891
+ _mesh2 ?? (_mesh2 = await import('@holoscript/mesh'));
19892
+ const { SYNC_TIER_RATES } = _mesh2;
19893
+ const baseSyncRate = SYNC_TIER_RATES[config.syncTier] ?? config.syncRate;
19844
19894
  const effectiveRate = baseSyncRate * state.priorityWeight;
19845
19895
  const syncIntervalMs = effectiveRate > 0 ? 1e3 / effectiveRate : Infinity;
19846
19896
  if (trait.isLocalOwner()) {
@@ -24821,6 +24871,9 @@ function average(values) {
24821
24871
  function round(value) {
24822
24872
  return Math.round(value * 1e6) / 1e6;
24823
24873
  }
24874
+
24875
+ // src/traits/AgentDiscoveryTrait.ts
24876
+ var _frameworkAgents = null;
24824
24877
  function generateAgentId() {
24825
24878
  return `agent_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
24826
24879
  }
@@ -24868,7 +24921,9 @@ var agentDiscoveryHandler = {
24868
24921
  registry_config: null,
24869
24922
  tags: []
24870
24923
  },
24871
- onAttach(node, config, context) {
24924
+ async onAttach(node, config, context) {
24925
+ _frameworkAgents ?? (_frameworkAgents = await import('@holoscript/framework/agents'));
24926
+ const { getDefaultRegistry } = _frameworkAgents;
24872
24927
  const state = {
24873
24928
  registrationStatus: "unregistered",
24874
24929
  manifest: null,
@@ -24880,7 +24935,7 @@ var agentDiscoveryHandler = {
24880
24935
  registry: null
24881
24936
  };
24882
24937
  node.__agentDiscoveryState = state;
24883
- state.registry = agents.getDefaultRegistry(config.registry_config || void 0);
24938
+ state.registry = getDefaultRegistry(config.registry_config || void 0);
24884
24939
  const nodeId = node.id || "unknown";
24885
24940
  state.manifest = createManifest(nodeId, config);
24886
24941
  if (config.auto_register) {
@@ -29578,6 +29633,9 @@ var messagingHandler = {
29578
29633
  });
29579
29634
  }
29580
29635
  };
29636
+
29637
+ // src/traits/MQTTSinkTrait.ts
29638
+ var _mqttClientMod = null;
29581
29639
  var defaultConfig = {
29582
29640
  broker: "mqtt://localhost:1883",
29583
29641
  topic: "holoscript/{nodeId}/state",
@@ -29591,7 +29649,7 @@ var defaultConfig = {
29591
29649
  var mqttSinkHandler = {
29592
29650
  name: "mqtt_sink",
29593
29651
  defaultConfig,
29594
- onAttach(node, config, context) {
29652
+ async onAttach(node, config, context) {
29595
29653
  const state = {
29596
29654
  connected: false,
29597
29655
  publishCount: 0,
@@ -29601,16 +29659,18 @@ var mqttSinkHandler = {
29601
29659
  lastStateHash: null
29602
29660
  };
29603
29661
  node.__mqttSinkState = state;
29662
+ _mqttClientMod ?? (_mqttClientMod = await import('@holoscript/engine/runtime/protocols/MQTTClient'));
29663
+ const { createMQTTClient, getMQTTClient, registerMQTTClient } = _mqttClientMod;
29604
29664
  const clientKey = `${config.broker}_${config.clientId || "default"}`;
29605
- let client = MQTTClient.getMQTTClient(clientKey);
29665
+ let client = getMQTTClient(clientKey);
29606
29666
  if (!client) {
29607
- client = MQTTClient.createMQTTClient({
29667
+ client = createMQTTClient({
29608
29668
  broker: config.broker,
29609
29669
  clientId: config.clientId,
29610
29670
  username: config.username,
29611
29671
  password: config.password
29612
29672
  });
29613
- MQTTClient.registerMQTTClient(clientKey, client);
29673
+ registerMQTTClient(clientKey, client);
29614
29674
  }
29615
29675
  state.client = client;
29616
29676
  client.on("connect", () => {
@@ -29756,6 +29816,9 @@ function publishToMQTTSink(node, payload, topic) {
29756
29816
  }
29757
29817
  );
29758
29818
  }
29819
+
29820
+ // src/traits/MQTTSourceTrait.ts
29821
+ var _mqttClientMod2 = null;
29759
29822
  var defaultConfig2 = {
29760
29823
  broker: "mqtt://localhost:1883",
29761
29824
  topic: "#",
@@ -29767,7 +29830,7 @@ var defaultConfig2 = {
29767
29830
  var mqttSourceHandler = {
29768
29831
  name: "mqtt_source",
29769
29832
  defaultConfig: defaultConfig2,
29770
- onAttach(node, config, context) {
29833
+ async onAttach(node, config, context) {
29771
29834
  const state = {
29772
29835
  connected: false,
29773
29836
  lastMessage: null,
@@ -29777,16 +29840,18 @@ var mqttSourceHandler = {
29777
29840
  client: null
29778
29841
  };
29779
29842
  node.__mqttSourceState = state;
29843
+ _mqttClientMod2 ?? (_mqttClientMod2 = await import('@holoscript/engine/runtime/protocols/MQTTClient'));
29844
+ const { createMQTTClient, getMQTTClient, registerMQTTClient } = _mqttClientMod2;
29780
29845
  const clientKey = `${config.broker}_${config.clientId || "default"}`;
29781
- let client = MQTTClient.getMQTTClient(clientKey);
29846
+ let client = getMQTTClient(clientKey);
29782
29847
  if (!client) {
29783
- client = MQTTClient.createMQTTClient({
29848
+ client = createMQTTClient({
29784
29849
  broker: config.broker,
29785
29850
  clientId: config.clientId,
29786
29851
  username: config.username,
29787
29852
  password: config.password
29788
29853
  });
29789
- MQTTClient.registerMQTTClient(clientKey, client);
29854
+ registerMQTTClient(clientKey, client);
29790
29855
  }
29791
29856
  state.client = client;
29792
29857
  client.on("connect", () => {
@@ -29818,8 +29883,8 @@ var mqttSourceHandler = {
29818
29883
  };
29819
29884
  client.subscribe({ topic: config.topic, qos: config.qos }, (message) => {
29820
29885
  let value = message.payload;
29821
- if (config.parseJson) {
29822
- value = MQTTClient.MQTTClient.parsePayload(message);
29886
+ if (config.parseJson && _mqttClientMod2) {
29887
+ value = _mqttClientMod2.MQTTClient.parsePayload(message);
29823
29888
  }
29824
29889
  if (config.debounce && config.debounce > 0) {
29825
29890
  pendingMessage = value;
@@ -30281,16 +30346,27 @@ var multiAgentHandler = {
30281
30346
  }
30282
30347
  }
30283
30348
  };
30349
+
30350
+ // src/traits/NetworkedAvatarTrait.ts
30351
+ var _boneSystemMod = null;
30352
+ var _ikSolverMod = null;
30353
+ var _avatarControllerMod = null;
30284
30354
  var networkedAvatarHandler = {
30285
30355
  name: "networked_avatar",
30286
30356
  defaultConfig: {
30287
30357
  isLocal: false,
30288
30358
  updateRate: 30
30289
30359
  },
30290
- onAttach(node, config, context) {
30291
- const bones = new BoneSystem.BoneSystem();
30292
- const solver = new IKSolver.IKSolver();
30293
- const controller = new AvatarController.AvatarController(solver, bones);
30360
+ async onAttach(node, config, context) {
30361
+ _boneSystemMod ?? (_boneSystemMod = await import('@holoscript/engine/animation/BoneSystem'));
30362
+ _ikSolverMod ?? (_ikSolverMod = await import('@holoscript/engine/animation/IKSolver'));
30363
+ _avatarControllerMod ?? (_avatarControllerMod = await import('@holoscript/engine/animation/AvatarController'));
30364
+ const { BoneSystem } = _boneSystemMod;
30365
+ const { IKSolver } = _ikSolverMod;
30366
+ const { AvatarController } = _avatarControllerMod;
30367
+ const bones = new BoneSystem();
30368
+ const solver = new IKSolver();
30369
+ const controller = new AvatarController(solver, bones);
30294
30370
  bones.addBone("Hips", "Hips", null, { ty: 1 });
30295
30371
  bones.addBone("Spine", "Spine", "Hips", { ty: 0.2 });
30296
30372
  bones.addBone("Head", "Head", "Spine", { ty: 0.3 });
@@ -30701,6 +30777,9 @@ var neuralForgeHandler = {
30701
30777
  }
30702
30778
  }
30703
30779
  };
30780
+
30781
+ // src/traits/NPCAITrait.ts
30782
+ var _frameworkAI = null;
30704
30783
  var npcAIHandler = {
30705
30784
  name: "npc_ai",
30706
30785
  defaultConfig: {
@@ -30729,7 +30808,7 @@ var npcAIHandler = {
30729
30808
  const state = node.__npcAIState;
30730
30809
  if (!state || state.isThinking) return;
30731
30810
  },
30732
- onEvent(node, config, context, event) {
30811
+ async onEvent(node, config, context, event) {
30733
30812
  const state = node.__npcAIState;
30734
30813
  if (!state) return;
30735
30814
  if (event.type === "npc_ai_prompt") {
@@ -30737,7 +30816,9 @@ var npcAIHandler = {
30737
30816
  state.isThinking = true;
30738
30817
  state.conversationHistory.push({ role: "user", content: prompt });
30739
30818
  context.emit?.("npc_ai_think_begin", { node, prompt });
30740
- const adapter = ai.getDefaultAIAdapter();
30819
+ _frameworkAI ?? (_frameworkAI = await import('@holoscript/framework/ai'));
30820
+ const { getDefaultAIAdapter } = _frameworkAI;
30821
+ const adapter = getDefaultAIAdapter();
30741
30822
  if (adapter && adapter.chat) {
30742
30823
  adapter.chat(prompt, void 0, state.conversationHistory.slice(0, -1)).then((response) => {
30743
30824
  context.emit?.("npc_ai_response", { node, text: response });
@@ -36259,6 +36340,9 @@ var lotusGenesisTriggerHandler = {
36259
36340
  });
36260
36341
  }
36261
36342
  };
36343
+
36344
+ // src/traits/HandMenuTrait.ts
36345
+ var _springAnimatorModule = null;
36262
36346
  var getCoord = (v, idx, key) => (Array.isArray(v) ? v[idx] : v[key]) ?? 0;
36263
36347
  var add2 = (v1, v2) => [
36264
36348
  getCoord(v1, 0, "x") + getCoord(v2, 0, "x"),
@@ -36274,8 +36358,10 @@ var handMenuHandler = {
36274
36358
  offset: [0, 0.2, 0],
36275
36359
  scale: 1
36276
36360
  },
36277
- onAttach(node, config, context) {
36278
- const spring = new SpringAnimator.SpringAnimator(0, SpringAnimator.SpringPresets.gentle);
36361
+ async onAttach(node, config, context) {
36362
+ _springAnimatorModule ?? (_springAnimatorModule = await import('@holoscript/engine/animation/SpringAnimator'));
36363
+ const { SpringAnimator, SpringPresets } = _springAnimatorModule;
36364
+ const spring = new SpringAnimator(0, SpringPresets.gentle);
36279
36365
  menuSprings.set(node.id, spring);
36280
36366
  if (node.properties) {
36281
36367
  node.properties.scale = [0, 0, 0];
@@ -36319,6 +36405,9 @@ var handMenuHandler = {
36319
36405
  }
36320
36406
  }
36321
36407
  };
36408
+
36409
+ // src/traits/ScrollableTrait.ts
36410
+ var _springAnimatorModule2 = null;
36322
36411
  var scrollStates = /* @__PURE__ */ new Map();
36323
36412
  var scrollableHandler = {
36324
36413
  name: "scrollable",
@@ -36329,8 +36418,10 @@ var scrollableHandler = {
36329
36418
  elasticity: 0.1,
36330
36419
  useSpringBounce: true
36331
36420
  },
36332
- onAttach(node, config, context) {
36333
- const spring = config.useSpringBounce ? new SpringAnimator.SpringAnimator(0, { ...SpringAnimator.SpringPresets.gentle, precision: 5e-3 }) : null;
36421
+ async onAttach(node, config, context) {
36422
+ _springAnimatorModule2 ?? (_springAnimatorModule2 = await import('@holoscript/engine/animation/SpringAnimator'));
36423
+ const { SpringAnimator, SpringPresets } = _springAnimatorModule2;
36424
+ const spring = config.useSpringBounce ? new SpringAnimator(0, { ...SpringPresets.gentle, precision: 5e-3 }) : null;
36334
36425
  scrollStates.set(node.id, {
36335
36426
  offset: 0,
36336
36427
  velocity: 0,
@@ -38410,6 +38501,7 @@ var characterHandler = {
38410
38501
  if (typeof instance.onUpdate === "function") instance.onUpdate(node, ctx, dt);
38411
38502
  }
38412
38503
  };
38504
+ var _mesh3 = null;
38413
38505
  var DEFAULT_TRAIT_CONFIG = {
38414
38506
  mechanism: "simple_majority",
38415
38507
  timeout: 5e3
@@ -38430,12 +38522,14 @@ var ConsensusTrait = class extends events.EventEmitter {
38430
38522
  /**
38431
38523
  * Start the consensus trait
38432
38524
  */
38433
- start() {
38525
+ async start() {
38434
38526
  if (this.isStarted) return;
38527
+ _mesh3 ?? (_mesh3 = await import('@holoscript/mesh'));
38528
+ const { RaftConsensus, ConsensusManager } = _mesh3;
38435
38529
  const nodeId = this.config.nodeId || this.entityId;
38436
38530
  const mechanism = this.config.mechanism || "simple_majority";
38437
38531
  if (mechanism === "raft") {
38438
- this.raft = new mesh.RaftConsensus(nodeId, this.config);
38532
+ this.raft = new RaftConsensus(nodeId, this.config);
38439
38533
  if (this.config.messageSender) {
38440
38534
  this.raft.setMessageSender(this.config.messageSender);
38441
38535
  }
@@ -38458,7 +38552,7 @@ var ConsensusTrait = class extends events.EventEmitter {
38458
38552
  }
38459
38553
  this.raft.start();
38460
38554
  } else {
38461
- this.manager = new mesh.ConsensusManager(nodeId, this.config);
38555
+ this.manager = new ConsensusManager(nodeId, this.config);
38462
38556
  this.manager.on("proposal:accepted", (result) => {
38463
38557
  this.emit("proposal:accepted", result);
38464
38558
  });
@@ -44591,15 +44685,26 @@ var slidableHandler = {
44591
44685
  if (typeof instance.onUpdate === "function") instance.onUpdate(node, ctx, dt);
44592
44686
  }
44593
44687
  };
44688
+ var _spatial = null;
44594
44689
  var DEFAULT_TRAIT_CONFIG2 = {
44595
- ...spatial.DEFAULT_SPATIAL_CONFIG,
44596
44690
  initialPosition: [0, 0, 0],
44597
44691
  autoStart: true
44598
44692
  };
44599
44693
  var SpatialAwarenessTrait = class extends events.EventEmitter {
44600
44694
  constructor(id, config = {}) {
44601
44695
  super();
44696
+ /**
44697
+ * The underlying spatial provider. `null` until `ensureInitialized()` has run
44698
+ * (it lazy-imports the optional engine peer to construct it). All sync methods
44699
+ * that touch `this.provider` null-guard and no-op until initialization, since
44700
+ * the trait is not "active" until `start()` / `ensureInitialized()` completes.
44701
+ */
44702
+ this.provider = null;
44602
44703
  this.ownsProvider = false;
44704
+ /** True once `ensureInitialized()` has constructed the provider + wired events. */
44705
+ this.initialized = false;
44706
+ /** In-flight initialization promise so concurrent `ensureInitialized()` calls share one import. */
44707
+ this.initPromise = null;
44603
44708
  this.velocity = [0, 0, 0];
44604
44709
  this.isActive = false;
44605
44710
  this.lastContext = null;
@@ -44608,26 +44713,53 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44608
44713
  this.id = id;
44609
44714
  this.config = { ...DEFAULT_TRAIT_CONFIG2, ...config };
44610
44715
  this.position = this.config.initialPosition || [0, 0, 0];
44611
- if (this.config.sharedProvider) {
44612
- this.provider = this.config.sharedProvider;
44613
- this.ownsProvider = false;
44614
- } else {
44615
- this.provider = new spatial.SpatialContextProvider();
44616
- this.ownsProvider = true;
44617
- }
44618
- this.setupEventHandlers();
44716
+ this.ownsProvider = !this.config.sharedProvider;
44619
44717
  if (this.config.autoStart) {
44620
- this.start();
44718
+ void this.start().catch(() => {
44719
+ });
44621
44720
  }
44622
44721
  }
44623
44722
  // ===========================================================================
44624
44723
  // LIFECYCLE
44625
44724
  // ===========================================================================
44626
44725
  /**
44627
- * Start spatial awareness
44726
+ * Lazily load the optional `@holoscript/engine/spatial` peer, construct the
44727
+ * provider, merge in the spatial defaults, and wire event forwarding.
44728
+ *
44729
+ * This is the single place the optional engine module is dynamically imported,
44730
+ * so a cold `import '@holoscript/core'` never touches it. Safe to call multiple
44731
+ * times — the import + construction happen exactly once (guarded by `initPromise`
44732
+ * and `this.initialized`).
44733
+ *
44734
+ * @throws if `@holoscript/engine/spatial` is not installed (the optional peer).
44735
+ */
44736
+ async ensureInitialized() {
44737
+ if (this.initialized) return;
44738
+ if (this.initPromise) return this.initPromise;
44739
+ this.initPromise = (async () => {
44740
+ _spatial ?? (_spatial = await import('@holoscript/engine/spatial'));
44741
+ this.config = { ..._spatial.DEFAULT_SPATIAL_CONFIG, ...this.config };
44742
+ this.provider = this.config.sharedProvider ?? new _spatial.SpatialContextProvider();
44743
+ this.setupEventHandlers();
44744
+ this.initialized = true;
44745
+ })();
44746
+ try {
44747
+ await this.initPromise;
44748
+ } finally {
44749
+ this.initPromise = null;
44750
+ }
44751
+ }
44752
+ /**
44753
+ * Start spatial awareness.
44754
+ *
44755
+ * Now async: it first awaits `ensureInitialized()` (which lazy-imports the
44756
+ * optional engine peer and constructs the provider), then registers the agent.
44628
44757
  */
44629
- start() {
44758
+ async start() {
44630
44759
  if (this.isActive) return;
44760
+ await this.ensureInitialized();
44761
+ if (this.isActive) return;
44762
+ if (!this.provider) return;
44631
44763
  this.provider.registerAgent(this.id, this.position, this.config);
44632
44764
  if (this.ownsProvider) {
44633
44765
  this.provider.start();
@@ -44639,6 +44771,10 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44639
44771
  */
44640
44772
  stop() {
44641
44773
  if (!this.isActive) return;
44774
+ if (!this.provider) {
44775
+ this.isActive = false;
44776
+ return;
44777
+ }
44642
44778
  this.provider.unregisterAgent(this.id);
44643
44779
  if (this.ownsProvider) {
44644
44780
  this.provider.stop();
@@ -44666,7 +44802,7 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44666
44802
  */
44667
44803
  setPosition(position) {
44668
44804
  this.position = position;
44669
- if (this.isActive) {
44805
+ if (this.isActive && this.provider) {
44670
44806
  this.provider.updateAgentPosition(this.id, position, this.velocity);
44671
44807
  }
44672
44808
  }
@@ -44681,7 +44817,7 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44681
44817
  */
44682
44818
  setVelocity(velocity) {
44683
44819
  this.velocity = velocity;
44684
- if (this.isActive) {
44820
+ if (this.isActive && this.provider) {
44685
44821
  this.provider.updateAgentPosition(this.id, this.position, velocity);
44686
44822
  }
44687
44823
  }
@@ -44698,7 +44834,9 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44698
44834
  * Get current spatial context
44699
44835
  */
44700
44836
  getContext() {
44701
- return this.lastContext || this.provider.getContext(this.id);
44837
+ if (this.lastContext) return this.lastContext;
44838
+ if (!this.provider) return null;
44839
+ return this.provider.getContext(this.id);
44702
44840
  }
44703
44841
  /**
44704
44842
  * Get nearby entities
@@ -44728,6 +44866,7 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44728
44866
  * Find nearest entity
44729
44867
  */
44730
44868
  findNearest(typeFilter) {
44869
+ if (!this.provider) return null;
44731
44870
  const results = this.provider.findNearest(this.position, 1, typeFilter);
44732
44871
  return results[0] || null;
44733
44872
  }
@@ -44735,12 +44874,14 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44735
44874
  * Find all entities within radius
44736
44875
  */
44737
44876
  findWithin(radius, typeFilter) {
44877
+ if (!this.provider) return [];
44738
44878
  return this.provider.findWithin(this.position, radius, typeFilter);
44739
44879
  }
44740
44880
  /**
44741
44881
  * Find visible entities
44742
44882
  */
44743
44883
  findVisible(direction, fov, maxDistance) {
44884
+ if (!this.provider) return [];
44744
44885
  return this.provider.findVisible(this.position, direction, fov, maxDistance);
44745
44886
  }
44746
44887
  /**
@@ -44768,18 +44909,21 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44768
44909
  * Register an entity for tracking
44769
44910
  */
44770
44911
  registerEntity(entity) {
44912
+ if (!this.provider) return;
44771
44913
  this.provider.setEntity(entity);
44772
44914
  }
44773
44915
  /**
44774
44916
  * Unregister an entity
44775
44917
  */
44776
44918
  unregisterEntity(entityId) {
44919
+ if (!this.provider) return;
44777
44920
  this.provider.removeEntity(entityId);
44778
44921
  }
44779
44922
  /**
44780
44923
  * Batch register entities
44781
44924
  */
44782
44925
  registerEntities(entities) {
44926
+ if (!this.provider) return;
44783
44927
  this.provider.setEntities(entities);
44784
44928
  }
44785
44929
  // ===========================================================================
@@ -44789,24 +44933,28 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44789
44933
  * Register a region
44790
44934
  */
44791
44935
  registerRegion(region) {
44936
+ if (!this.provider) return;
44792
44937
  this.provider.setRegion(region);
44793
44938
  }
44794
44939
  /**
44795
44940
  * Unregister a region
44796
44941
  */
44797
44942
  unregisterRegion(regionId) {
44943
+ if (!this.provider) return;
44798
44944
  this.provider.removeRegion(regionId);
44799
44945
  }
44800
44946
  /**
44801
44947
  * Subscribe to region events
44802
44948
  */
44803
44949
  watchRegion(regionId, callback) {
44950
+ if (!this.provider) return;
44804
44951
  this.provider.subscribeToRegion(this.id, regionId, callback);
44805
44952
  }
44806
44953
  /**
44807
44954
  * Unsubscribe from region events
44808
44955
  */
44809
44956
  unwatchRegion(regionId) {
44957
+ if (!this.provider) return;
44810
44958
  this.provider.unsubscribeFromRegion(this.id, regionId);
44811
44959
  }
44812
44960
  // ===========================================================================
@@ -44817,23 +44965,26 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44817
44965
  */
44818
44966
  setPerceptionRadius(radius) {
44819
44967
  this.config.perceptionRadius = radius;
44820
- if (this.isActive) {
44968
+ if (this.isActive && this.provider) {
44821
44969
  this.provider.unregisterAgent(this.id);
44822
44970
  this.provider.registerAgent(this.id, this.position, this.config);
44823
44971
  }
44824
44972
  }
44825
44973
  /**
44826
44974
  * Get perception radius
44975
+ *
44976
+ * Returns 0 if the spatial defaults have not yet been merged (i.e. before
44977
+ * `ensureInitialized()` ran and no explicit value was supplied in config).
44827
44978
  */
44828
44979
  getPerceptionRadius() {
44829
- return this.config.perceptionRadius;
44980
+ return this.config.perceptionRadius ?? 0;
44830
44981
  }
44831
44982
  /**
44832
44983
  * Set entity type filter
44833
44984
  */
44834
44985
  setEntityTypeFilter(types) {
44835
44986
  this.config.entityTypeFilter = types;
44836
- if (this.isActive) {
44987
+ if (this.isActive && this.provider) {
44837
44988
  this.provider.unregisterAgent(this.id);
44838
44989
  this.provider.registerAgent(this.id, this.position, this.config);
44839
44990
  }
@@ -44845,38 +44996,40 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44845
44996
  * Setup event handlers from provider
44846
44997
  */
44847
44998
  setupEventHandlers() {
44848
- this.provider.on("entity:entered", (agentId, event) => {
44999
+ const provider = this.provider;
45000
+ if (!provider) return;
45001
+ provider.on("entity:entered", (agentId, event) => {
44849
45002
  if (agentId !== this.id) return;
44850
45003
  if (event.type === "entity_entered") {
44851
45004
  this.emit("entity:entered", event.entity, event.distance);
44852
45005
  }
44853
45006
  });
44854
- this.provider.on("entity:exited", (agentId, event) => {
45007
+ provider.on("entity:exited", (agentId, event) => {
44855
45008
  if (agentId !== this.id) return;
44856
45009
  if (event.type === "entity_exited") {
44857
45010
  this.emit("entity:exited", event.entity);
44858
45011
  }
44859
45012
  });
44860
- this.provider.on("region:entered", (agentId, event) => {
45013
+ provider.on("region:entered", (agentId, event) => {
44861
45014
  if (agentId !== this.id) return;
44862
45015
  if (event.type === "region_entered") {
44863
45016
  this.emit("region:entered", event.region, event.previousRegion);
44864
45017
  }
44865
45018
  });
44866
- this.provider.on("region:exited", (agentId, event) => {
45019
+ provider.on("region:exited", (agentId, event) => {
44867
45020
  if (agentId !== this.id) return;
44868
45021
  if (event.type === "region_exited") {
44869
45022
  this.emit("region:exited", event.region);
44870
45023
  }
44871
45024
  });
44872
- this.provider.on("visibility:changed", (agentId, event) => {
45025
+ provider.on("visibility:changed", (agentId, event) => {
44873
45026
  if (agentId !== this.id) return;
44874
45027
  if (event.type === "visibility_changed") {
44875
45028
  this.visibleEntities.set(event.entityId, event.visible);
44876
45029
  this.emit("visibility:changed", event.entityId, event.visible);
44877
45030
  }
44878
45031
  });
44879
- this.provider.on("context:updated", (agentId, context) => {
45032
+ provider.on("context:updated", (agentId, context) => {
44880
45033
  if (agentId !== this.id) return;
44881
45034
  this.lastContext = context;
44882
45035
  this.emit("context:updated", context);
@@ -44886,15 +45039,17 @@ var SpatialAwarenessTrait = class extends events.EventEmitter {
44886
45039
  function createSpatialAwarenessTrait(id, config) {
44887
45040
  return new SpatialAwarenessTrait(id, config);
44888
45041
  }
44889
- function createSharedSpatialProvider() {
44890
- return new spatial.SpatialContextProvider();
45042
+ async function createSharedSpatialProvider() {
45043
+ _spatial ?? (_spatial = await import('@holoscript/engine/spatial'));
45044
+ return new _spatial.SpatialContextProvider();
44891
45045
  }
44892
45046
  var spatialAwarenessHandler = {
44893
45047
  name: "spatial_awareness",
44894
45048
  defaultConfig: {},
44895
- onAttach(node, config, ctx) {
45049
+ async onAttach(node, config, ctx) {
44896
45050
  const instance = new SpatialAwarenessTrait(node.id || "spatial_awareness", config);
44897
45051
  node.__spatial_awareness_instance = instance;
45052
+ await instance.start();
44898
45053
  ctx.emit("spatial_awareness_attached", { node, config });
44899
45054
  },
44900
45055
  onDetach(node, _config, ctx) {
@@ -55553,7 +55708,7 @@ var VRTraitRegistry = class {
55553
55708
  this.register(hapticHandler);
55554
55709
  this.register(eyeTrackedHandler);
55555
55710
  this.register(roadmapNodeHandler);
55556
- this.register(chunkAIX25INK_cjs.mitosisHandler);
55711
+ this.register(chunkTVHSPJ4N_cjs.mitosisHandler);
55557
55712
  this.register(planeDetectionHandler);
55558
55713
  this.register(meshDetectionHandler);
55559
55714
  this.register(roomMeshHandler);
@@ -55718,8 +55873,8 @@ var VRTraitRegistry = class {
55718
55873
  this.register(sseHandler);
55719
55874
  this.register(modelLoadHandler);
55720
55875
  this.register(inferenceHandler);
55721
- this.register(chunkAIX25INK_cjs.embeddingHandler);
55722
- this.register(chunkAIX25INK_cjs.jepObjectiveHandler);
55876
+ this.register(chunkTVHSPJ4N_cjs.embeddingHandler);
55877
+ this.register(chunkTVHSPJ4N_cjs.jepObjectiveHandler);
55723
55878
  this.register(fineTuneHandler);
55724
55879
  this.register(vectorSearchHandler);
55725
55880
  this.register(promptTemplateHandler);
@@ -55801,8 +55956,8 @@ var VRTraitRegistry = class {
55801
55956
  this.register(trainingLoopHandler);
55802
55957
  this.register(modelLoadHandler);
55803
55958
  this.register(inferenceHandler);
55804
- this.register(chunkAIX25INK_cjs.embeddingHandler);
55805
- this.register(chunkAIX25INK_cjs.jepObjectiveHandler);
55959
+ this.register(chunkTVHSPJ4N_cjs.embeddingHandler);
55960
+ this.register(chunkTVHSPJ4N_cjs.jepObjectiveHandler);
55806
55961
  this.register(sqlQueryHandler);
55807
55962
  this.register(ormEntityHandler);
55808
55963
  this.register(offlineSyncHandler);
@@ -55852,7 +56007,7 @@ var VRTraitRegistry = class {
55852
56007
  this.register(npcAIHandler);
55853
56008
  this.register(objectTrackingHandler);
55854
56009
  this.register(openXRHALHandler);
55855
- this.register(chunkAIX25INK_cjs.orbitalHandler);
56010
+ this.register(chunkTVHSPJ4N_cjs.orbitalHandler);
55856
56011
  this.register(partnerSDKHandler);
55857
56012
  this.register(poseEstimationHandler);
55858
56013
  this.register(ragKnowledgeHandler);
@@ -56419,5 +56574,5 @@ exports.windHandler = windHandler;
56419
56574
  exports.withNegotiation = withNegotiation;
56420
56575
  exports.wotThingHandler = wotThingHandler;
56421
56576
  exports.zkPrivateHandler = zkPrivateHandler;
56422
- //# sourceMappingURL=chunk-6S6TKNEA.cjs.map
56423
- //# sourceMappingURL=chunk-6S6TKNEA.cjs.map
56577
+ //# sourceMappingURL=chunk-3HYYMEXI.cjs.map
56578
+ //# sourceMappingURL=chunk-3HYYMEXI.cjs.map