@holoscript/core 6.0.2 → 6.0.4

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 (229) hide show
  1. package/README.md +38 -38
  2. package/dist/GLTFPipeline-DEN36VNK.js +12 -0
  3. package/dist/GLTFPipeline-YPCAK236.cjs +33 -0
  4. package/dist/{HoloScriptPlusParser-BZR5DELQ.js → HoloScriptPlusParser-BN6KVRCM.js} +5 -5
  5. package/dist/{HoloScriptPlusParser-SBMYDNXO.cjs → HoloScriptPlusParser-NC5FE6AL.cjs} +16 -16
  6. package/dist/{USDZExporter-YA55ZS35.js → USDZExporter-NTMBNTDB.js} +3 -3
  7. package/dist/{USDZExporter-MHEHXZB4.cjs → USDZExporter-UWGWNMMD.cjs} +3 -3
  8. package/dist/{chunk-32TWR3HE.js → chunk-2CWOLHTE.js} +3 -4
  9. package/dist/{chunk-2UX5LRAP.cjs → chunk-33LSUQDD.cjs} +33 -31
  10. package/dist/{chunk-LBPEZQAF.js → chunk-3FJCK5XA.js} +7 -7
  11. package/dist/{chunk-EGIZHYJP.cjs → chunk-3SAK5KFL.cjs} +2 -4
  12. package/dist/{chunk-PJMOXFPR.cjs → chunk-4XSNJCLC.cjs} +25 -27
  13. package/dist/{chunk-HKCVM6OK.cjs → chunk-5BGSECRJ.cjs} +21 -21
  14. package/dist/{chunk-EMO7HAKJ.cjs → chunk-5O6TQC6M.cjs} +26 -30
  15. package/dist/{chunk-XSUZMPVQ.cjs → chunk-5OEOHAAW.cjs} +26 -26
  16. package/dist/{chunk-EJA7G2C4.cjs → chunk-5WUNN6ZN.cjs} +2 -2
  17. package/dist/{chunk-CQDOF3G7.cjs → chunk-6TZPZCOJ.cjs} +18 -18
  18. package/dist/{chunk-NRUB55IT.cjs → chunk-6UEHYZ7V.cjs} +18 -16
  19. package/dist/{chunk-V42NTCFH.js → chunk-6XSERL6L.js} +4230 -2197
  20. package/dist/{chunk-X4YVN7H3.cjs → chunk-72EQECGT.cjs} +37 -17
  21. package/dist/{chunk-4KJ2R7VP.cjs → chunk-7AGYRWKW.cjs} +19 -19
  22. package/dist/{chunk-UQW6SLM5.js → chunk-A7PIMZGU.js} +110 -19
  23. package/dist/{chunk-RT7LJRSF.cjs → chunk-ATSKSYVE.cjs} +1013 -6708
  24. package/dist/{chunk-WN3YF33G.cjs → chunk-B5TCIAPQ.cjs} +9 -10
  25. package/dist/{chunk-AIUXRS74.cjs → chunk-BF2235SI.cjs} +4275 -2242
  26. package/dist/{chunk-DIEDKX5B.cjs → chunk-BND3ST2K.cjs} +18 -16
  27. package/dist/{chunk-EPWRXL6S.js → chunk-BU7VWW2K.js} +29 -29
  28. package/dist/{chunk-6OQBLABR.js → chunk-BWFJEM5A.js} +368 -189
  29. package/dist/{chunk-ARNKA274.cjs → chunk-CAUCGUEA.cjs} +6 -6
  30. package/dist/{chunk-YCMQQQ5U.cjs → chunk-CBJSLA2E.cjs} +398 -219
  31. package/dist/{chunk-BU5ZAFMC.js → chunk-CDPGV4DN.js} +6 -7
  32. package/dist/{chunk-CO2VM2DK.js → chunk-CS2EMTGF.js} +10 -9
  33. package/dist/{chunk-AW7WAELW.js → chunk-DMG7C4H2.js} +4 -4
  34. package/dist/{chunk-XSF76QRU.js → chunk-DXJQDCFL.js} +3 -3
  35. package/dist/{chunk-4FCZDTD5.js → chunk-E3FWRT3Z.js} +7 -9
  36. package/dist/{chunk-KYM4XRFG.js → chunk-E3UALNFA.js} +4 -4
  37. package/dist/{chunk-GC3YU46J.js → chunk-EONILVMF.js} +2 -2
  38. package/dist/{chunk-VJVCD5T5.cjs → chunk-EQV4R3EV.cjs} +22 -22
  39. package/dist/{chunk-FEFHPUEM.cjs → chunk-F3HH56EB.cjs} +74 -658
  40. package/dist/{chunk-WYH4GVZ5.js → chunk-F4IULT7N.js} +2 -2
  41. package/dist/{chunk-XDXZM3ZP.cjs → chunk-FFKU7BTK.cjs} +19 -19
  42. package/dist/{chunk-NKRKT6V2.js → chunk-FHQVYCH2.js} +11 -10
  43. package/dist/{chunk-7H5UNJZD.cjs → chunk-FSF7EQVA.cjs} +11 -10
  44. package/dist/{chunk-KUJRR4FJ.js → chunk-G4VZTCIB.js} +9 -7
  45. package/dist/{chunk-A6GO3DPZ.cjs → chunk-G7CT3EMP.cjs} +4 -4
  46. package/dist/{chunk-EUFLX2PI.js → chunk-GGHSW2NN.js} +989 -6611
  47. package/dist/chunk-GVUR45UF.cjs +777 -0
  48. package/dist/{chunk-ODGMVILH.js → chunk-H5Z7NASB.js} +3 -3
  49. package/dist/{chunk-7KPI4EKH.cjs → chunk-HE7ULERA.cjs} +45 -49
  50. package/dist/{chunk-26TLYBFD.js → chunk-HPS76H7Q.js} +3 -3
  51. package/dist/{chunk-RE3OKSYF.cjs → chunk-HQUEA5R6.cjs} +6 -6
  52. package/dist/{chunk-ZGTGVSTZ.js → chunk-HYNTS5CP.js} +2 -2
  53. package/dist/{chunk-PBA6NXCT.cjs → chunk-IBDG74G2.cjs} +6 -3
  54. package/dist/chunk-IFNQFCTM.js +3098 -0
  55. package/dist/{chunk-ZL6VJ6SN.js → chunk-IWI6J7FX.js} +5 -5
  56. package/dist/{chunk-3KEU5QYY.cjs → chunk-K3JDKWGI.cjs} +118 -23
  57. package/dist/{chunk-NLPSZT4C.js → chunk-K6EKD26I.js} +6 -6
  58. package/dist/chunk-KCQ5NDYC.cjs +3172 -0
  59. package/dist/{chunk-ELLQPFAF.js → chunk-KED34ILP.js} +11 -9
  60. package/dist/{chunk-BY3B7ZYV.cjs → chunk-KSGXLT74.cjs} +3 -3
  61. package/dist/{chunk-65RFOWZI.js → chunk-L4G4RLXX.js} +9 -7
  62. package/dist/{chunk-4SMUJFHL.js → chunk-LDP5OK6G.js} +6 -3
  63. package/dist/{chunk-VZNKJZTT.cjs → chunk-LGGRPKTV.cjs} +82 -96
  64. package/dist/{chunk-C2QHVHZF.js → chunk-LSW7P7ML.js} +23 -414
  65. package/dist/{chunk-HHS6FMOU.cjs → chunk-LXJ4667L.cjs} +83 -22
  66. package/dist/{chunk-H6WMMLQK.cjs → chunk-LZ266PCM.cjs} +20 -13
  67. package/dist/{chunk-V2ILLPHK.cjs → chunk-MD6KDHVE.cjs} +10 -10
  68. package/dist/{chunk-6WNCRE6F.js → chunk-MEASWI2Y.js} +5 -5
  69. package/dist/chunk-MPXBVFHQ.js +768 -0
  70. package/dist/{chunk-WUXIRGZP.cjs → chunk-NCUKG4SK.cjs} +304 -144
  71. package/dist/chunk-NDQNIJEH.js +1715 -0
  72. package/dist/{chunk-Y5MUAYTO.js → chunk-NOZZ46QU.js} +9 -8
  73. package/dist/{chunk-F5LVGHNT.js → chunk-OFKWH2IP.js} +3 -3
  74. package/dist/{chunk-SPDELRRV.cjs → chunk-PMGODDJA.cjs} +12 -12
  75. package/dist/{chunk-I3XGTIHM.cjs → chunk-Q4QX3AET.cjs} +2 -2
  76. package/dist/{chunk-Y7VK5TH3.cjs → chunk-Q5JT3YML.cjs} +10 -10
  77. package/dist/{chunk-TSWTWZ42.cjs → chunk-Q5SJOGHQ.cjs} +247 -205
  78. package/dist/{chunk-M6FU6S22.js → chunk-QGKNANZ3.js} +251 -91
  79. package/dist/{chunk-WFJIDI2N.cjs → chunk-QLEAOI3Q.cjs} +10 -10
  80. package/dist/{chunk-VK5AXKO3.js → chunk-R7MA7QWV.js} +70 -84
  81. package/dist/{chunk-W76ETJTI.js → chunk-RVYPEYPX.js} +6 -6
  82. package/dist/{chunk-MWEFR6YQ.js → chunk-S2N5TNMA.js} +7 -9
  83. package/dist/{chunk-NCUHGRTZ.js → chunk-S565K7NK.js} +7 -7
  84. package/dist/{chunk-AC4BSHFV.js → chunk-SDAMZIRE.js} +5 -5
  85. package/dist/{chunk-HBZYCASG.js → chunk-T36DDXSF.js} +75 -33
  86. package/dist/{chunk-BO2OKHIY.js → chunk-T4NKMBDL.js} +30 -611
  87. package/dist/{chunk-7X2IEJIE.cjs → chunk-T7LEXZUZ.cjs} +29 -29
  88. package/dist/{chunk-HUFNKFA6.js → chunk-TEWCN33Y.js} +8 -12
  89. package/dist/{chunk-L3Z2HIWJ.cjs → chunk-TQSZUOW5.cjs} +2 -2
  90. package/dist/chunk-TSH3MSQU.cjs +129 -0
  91. package/dist/{chunk-PLMYCCA4.js → chunk-UERJ3YJV.js} +6 -6
  92. package/dist/{chunk-7N3JIJMT.js → chunk-UPJBDCVF.js} +6 -6
  93. package/dist/{chunk-CMYAWUX3.js → chunk-V3NN3HPP.js} +12 -5
  94. package/dist/{chunk-SUCBB66F.js → chunk-WB4Z63GG.js} +3 -3
  95. package/dist/{chunk-PPULB4GG.cjs → chunk-WDW67DZB.cjs} +68 -68
  96. package/dist/chunk-WGMEAYBG.js +126 -0
  97. package/dist/{chunk-VSXOIUCF.cjs → chunk-X4ZF6CNE.cjs} +7 -7
  98. package/dist/{chunk-HF4OFY25.cjs → chunk-X6SEAXAX.cjs} +29 -445
  99. package/dist/{chunk-C7BNX4XJ.js → chunk-XCWFGZAA.js} +6 -6
  100. package/dist/{chunk-CNVM7J3M.js → chunk-XD6IYDUX.js} +34 -14
  101. package/dist/chunk-XG23EUQX.cjs +1717 -0
  102. package/dist/{chunk-DN7UFU63.cjs → chunk-XRKWN5PL.cjs} +12 -11
  103. package/dist/{chunk-XNMEH2BI.js → chunk-XUTX5CBW.js} +3 -3
  104. package/dist/{chunk-PQLGZKMC.cjs → chunk-XWPNTWDN.cjs} +26 -26
  105. package/dist/{chunk-NTMZSDXM.cjs → chunk-XXINBTZK.cjs} +43 -43
  106. package/dist/{chunk-74YCHHTE.js → chunk-YCXFCXDS.js} +8 -12
  107. package/dist/{chunk-KDB6BUMB.js → chunk-YQK5JNFK.js} +77 -18
  108. package/dist/{chunk-DH5G2JUA.cjs → chunk-Z34RLXRA.cjs} +44 -46
  109. package/dist/{chunk-XH7SE4HH.cjs → chunk-ZP4D3CSX.cjs} +19 -19
  110. package/dist/cli/holoscript-runner.cjs +33 -32
  111. package/dist/cli/holoscript-runner.js +13 -12
  112. package/dist/codebase/index.cjs +1 -1
  113. package/dist/codebase/index.d.ts +25 -0
  114. package/dist/codebase/index.js +1 -1
  115. package/dist/compiler/agent-inference.cjs +7 -8
  116. package/dist/compiler/agent-inference.js +3 -4
  117. package/dist/compiler/android-xr.cjs +7 -8
  118. package/dist/compiler/android-xr.js +5 -6
  119. package/dist/compiler/android.cjs +8 -9
  120. package/dist/compiler/android.js +6 -7
  121. package/dist/compiler/ar.cjs +6 -7
  122. package/dist/compiler/ar.js +4 -5
  123. package/dist/compiler/babylon.cjs +8 -9
  124. package/dist/compiler/babylon.js +7 -8
  125. package/dist/compiler/coco.cjs +1 -1
  126. package/dist/compiler/coco.js +1 -1
  127. package/dist/compiler/domain-block-utils.cjs +158 -151
  128. package/dist/compiler/domain-block-utils.js +4 -5
  129. package/dist/compiler/dtdl.cjs +7 -8
  130. package/dist/compiler/dtdl.js +4 -5
  131. package/dist/compiler/gltf-pipeline.cjs +9 -9
  132. package/dist/compiler/gltf-pipeline.js +2 -2
  133. package/dist/compiler/godot.cjs +6 -7
  134. package/dist/compiler/godot.js +5 -6
  135. package/dist/compiler/incremental.cjs +7 -8
  136. package/dist/compiler/incremental.js +2 -3
  137. package/dist/compiler/index.cjs +1934 -878
  138. package/dist/compiler/index.js +1904 -842
  139. package/dist/compiler/ios.cjs +8 -9
  140. package/dist/compiler/ios.js +6 -7
  141. package/dist/compiler/multi-layer.cjs +10 -17
  142. package/dist/compiler/multi-layer.js +9 -10
  143. package/dist/compiler/nodetoy.cjs +1 -1
  144. package/dist/compiler/nodetoy.js +1 -1
  145. package/dist/compiler/openxr.cjs +6 -7
  146. package/dist/compiler/openxr.js +5 -6
  147. package/dist/compiler/playcanvas.cjs +7 -8
  148. package/dist/compiler/playcanvas.js +6 -7
  149. package/dist/compiler/r3f.cjs +13 -14
  150. package/dist/compiler/r3f.js +8 -9
  151. package/dist/compiler/remotion.cjs +1 -1
  152. package/dist/compiler/remotion.js +1 -1
  153. package/dist/compiler/reproducibility.cjs +1 -1
  154. package/dist/compiler/reproducibility.js +1 -1
  155. package/dist/compiler/sdf.cjs +7 -8
  156. package/dist/compiler/sdf.js +5 -6
  157. package/dist/compiler/semantic-scene.cjs +7 -7
  158. package/dist/compiler/semantic-scene.js +2 -2
  159. package/dist/compiler/state.cjs +5 -6
  160. package/dist/compiler/state.js +3 -4
  161. package/dist/compiler/trait-composition.cjs +7 -8
  162. package/dist/compiler/trait-composition.js +3 -4
  163. package/dist/compiler/unity.cjs +6 -7
  164. package/dist/compiler/unity.js +5 -6
  165. package/dist/compiler/unreal.cjs +7 -8
  166. package/dist/compiler/unreal.js +5 -6
  167. package/dist/compiler/urdf.cjs +13 -14
  168. package/dist/compiler/urdf.js +5 -6
  169. package/dist/compiler/usd-physics.cjs +7 -8
  170. package/dist/compiler/usd-physics.js +4 -5
  171. package/dist/compiler/visionos.cjs +6 -7
  172. package/dist/compiler/visionos.js +5 -6
  173. package/dist/compiler/vrchat.cjs +7 -8
  174. package/dist/compiler/vrchat.js +5 -6
  175. package/dist/compiler/vrr.cjs +7 -8
  176. package/dist/compiler/vrr.js +5 -6
  177. package/dist/compiler/wasm.cjs +10 -11
  178. package/dist/compiler/wasm.js +5 -6
  179. package/dist/compiler/webgpu.cjs +6 -7
  180. package/dist/compiler/webgpu.js +5 -6
  181. package/dist/constants.d.ts +3 -0
  182. package/dist/debugger.cjs +7 -7
  183. package/dist/debugger.js +5 -5
  184. package/dist/entries/interop.cjs +1 -1
  185. package/dist/entries/interop.d.ts +9 -0
  186. package/dist/entries/interop.js +1 -1
  187. package/dist/entries/scripting.cjs +18 -17
  188. package/dist/entries/scripting.d.ts +7 -0
  189. package/dist/entries/scripting.js +8 -7
  190. package/dist/index.cjs +6773 -27555
  191. package/dist/index.d.ts +19 -0
  192. package/dist/index.js +5212 -26101
  193. package/dist/math/vec3.cjs +1 -1
  194. package/dist/math/vec3.js +1 -1
  195. package/dist/ml-dsa-PHCWUBPX.cjs +1178 -0
  196. package/dist/ml-dsa-WYLJHJO6.js +1178 -0
  197. package/dist/parser.cjs +11 -10
  198. package/dist/parser.js +8 -7
  199. package/dist/{playwright-BIZXMLD2.js → playwright-5OSAPTNH.js} +3 -3
  200. package/dist/{playwright-7DTEQCBD.cjs → playwright-RL6GY4F7.cjs} +1985 -1985
  201. package/dist/runtime.cjs +5 -5
  202. package/dist/runtime.js +4 -4
  203. package/dist/self-improvement/index.d.ts +0 -48
  204. package/dist/storage/index.cjs +1 -1
  205. package/dist/storage/index.d.ts +24 -0
  206. package/dist/storage/index.js +1 -1
  207. package/dist/tools/index.d.ts +12 -0
  208. package/dist/traits/index.cjs +925 -607
  209. package/dist/traits/index.js +137 -20
  210. package/dist/type-checker.cjs +4 -4
  211. package/dist/type-checker.js +2 -2
  212. package/package.json +54 -19
  213. package/LICENSE +0 -21
  214. package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
  215. package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
  216. package/dist/chunk-CN4NOESF.cjs +0 -416
  217. package/dist/chunk-DXVCEFZB.js +0 -2027
  218. package/dist/chunk-ENV7K6XA.js +0 -282
  219. package/dist/chunk-H7XMORZI.js +0 -2731
  220. package/dist/chunk-HAN4V3PF.cjs +0 -2037
  221. package/dist/chunk-LER4WXW5.cjs +0 -286
  222. package/dist/chunk-QHVVVN47.cjs +0 -2033
  223. package/dist/chunk-QWKUKVRE.js +0 -2026
  224. package/dist/chunk-UITWA6DV.cjs +0 -2829
  225. package/dist/chunk-X67XRI2T.js +0 -410
  226. package/dist/post-quantum-JTTAAGO3.cjs +0 -6
  227. package/dist/post-quantum-RVPVDEPI.js +0 -4
  228. package/dist/wot/index.cjs +0 -29
  229. package/dist/wot/index.js +0 -4
@@ -1,7 +1,8 @@
1
- import { init_CompilerBase, init_ANSNamespace, CompilerBase, ANSCapabilityPath } from './chunk-QWKUKVRE.js';
2
- import { init_roomplan, init_lidar_scanner, init_face_tracking, init_ios_object_capture, init_shareplay, init_uwb_positioning, init_airpods_spatial_audio, ROOMPLAN_TRAITS, LIDAR_SCANNER_TRAITS, IOS_OBJECT_CAPTURE_TRAITS, SHAREPLAY_TRAITS, FACE_TRACKING_TRAITS, UWB_POSITIONING_TRAITS, AIRPODS_SPATIAL_AUDIO_TRAITS } from './chunk-SUCBB66F.js';
3
- import { init_npu_scene, init_portal_ar, init_camera_hand_tracking, NPU_SCENE_TRAITS, NPU_SCENE_DEFAULTS, PORTAL_AR_TRAITS, CAMERA_HAND_TRACKING_TRAITS } from './chunk-XNMEH2BI.js';
4
- import { __export, __esm } from './chunk-32TWR3HE.js';
1
+ import { init_roomplan, init_lidar_scanner, init_face_tracking, init_ios_object_capture, init_shareplay, init_uwb_positioning, init_airpods_spatial_audio, ROOMPLAN_TRAITS, LIDAR_SCANNER_TRAITS, IOS_OBJECT_CAPTURE_TRAITS, SHAREPLAY_TRAITS, FACE_TRACKING_TRAITS, UWB_POSITIONING_TRAITS, AIRPODS_SPATIAL_AUDIO_TRAITS } from './chunk-WB4Z63GG.js';
2
+ import { init_npu_scene, init_portal_ar, init_camera_hand_tracking, NPU_SCENE_TRAITS, NPU_SCENE_DEFAULTS, PORTAL_AR_TRAITS, CAMERA_HAND_TRACKING_TRAITS } from './chunk-XUTX5CBW.js';
3
+ import { init_CompilerBase, CompilerBase } from './chunk-6XSERL6L.js';
4
+ import { __export, __esm } from './chunk-2CWOLHTE.js';
5
+ import { ANSCapabilityPath } from '@holoscript/platform';
5
6
 
6
7
  // src/compiler/IOSCompiler.ts
7
8
  var IOSCompiler_exports = {};
@@ -17,7 +18,6 @@ var IOSCompiler;
17
18
  var init_IOSCompiler = __esm({
18
19
  "src/compiler/IOSCompiler.ts"() {
19
20
  init_CompilerBase();
20
- init_ANSNamespace();
21
21
  init_roomplan();
22
22
  init_lidar_scanner();
23
23
  init_npu_scene();
@@ -667,9 +667,7 @@ var init_IOSCompiler = __esm({
667
667
  const name = this.sanitizeName(action.name);
668
668
  this.emit(`func ${name}() {`);
669
669
  this.indentLevel++;
670
- this.emit(
671
- `print("[HoloScript] Action: ${this.escapeStringValue(action.name, "Swift")}")`
672
- );
670
+ this.emit(`print("[HoloScript] Action: ${this.escapeStringValue(action.name, "Swift")}")`);
673
671
  this.emit("// Action implementation");
674
672
  this.indentLevel--;
675
673
  this.emit("}");
@@ -730,7 +728,9 @@ var init_IOSCompiler = __esm({
730
728
  this.indentLevel--;
731
729
  this.emit("} else {");
732
730
  this.indentLevel++;
733
- this.emit('print("[HoloScript] ARGeoTracking not available: \\(error?.localizedDescription ?? \\"unknown\\")")');
731
+ this.emit(
732
+ 'print("[HoloScript] ARGeoTracking not available: \\(error?.localizedDescription ?? \\"unknown\\")")'
733
+ );
734
734
  this.indentLevel--;
735
735
  this.emit("}");
736
736
  this.indentLevel--;
@@ -765,9 +765,13 @@ var init_IOSCompiler = __esm({
765
765
  const heading = headingConfig.degrees ?? 0;
766
766
  this.emit(`// Geo-anchor: ${this.escapeStringValue(obj.name, "Swift")}`);
767
767
  if (usesARGeoAnchor) {
768
- this.emit(`createGeoAnchor(name: "${this.escapeStringValue(obj.name, "Swift")}", latitude: ${lat}, longitude: ${lng}, altitude: ${alt}, heading: ${heading})`);
768
+ this.emit(
769
+ `createGeoAnchor(name: "${this.escapeStringValue(obj.name, "Swift")}", latitude: ${lat}, longitude: ${lng}, altitude: ${alt}, heading: ${heading})`
770
+ );
769
771
  } else {
770
- this.emit(`createLocationAnchor(name: "${this.escapeStringValue(obj.name, "Swift")}", latitude: ${lat}, longitude: ${lng}, altitude: ${alt})`);
772
+ this.emit(
773
+ `createLocationAnchor(name: "${this.escapeStringValue(obj.name, "Swift")}", latitude: ${lat}, longitude: ${lng}, altitude: ${alt})`
774
+ );
771
775
  }
772
776
  }
773
777
  const usesPersist = this.compositionHasTrait(composition, "geo_persist");
@@ -780,20 +784,28 @@ var init_IOSCompiler = __esm({
780
784
  this.emit("}");
781
785
  this.emit("");
782
786
  if (usesARGeoAnchor) {
783
- this.emit("func createGeoAnchor(name: String, latitude: Double, longitude: Double, altitude: Double, heading: Double) {");
787
+ this.emit(
788
+ "func createGeoAnchor(name: String, latitude: Double, longitude: Double, altitude: Double, heading: Double) {"
789
+ );
784
790
  this.indentLevel++;
785
791
  this.emit("guard let arView = arView else { return }");
786
- this.emit("let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)");
792
+ this.emit(
793
+ "let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)"
794
+ );
787
795
  this.emit("let geoAnchor = ARGeoAnchor(coordinate: coordinate, altitude: altitude)");
788
796
  this.emit("geoAnchor.name = name");
789
797
  this.emit("arView.session.add(anchor: geoAnchor)");
790
798
  this.emit("geoAnchors[name] = geoAnchor");
791
- this.emit('print("[HoloScript] Geo-anchored: \\(name) at (\\(latitude), \\(longitude), \\(altitude))")');
799
+ this.emit(
800
+ 'print("[HoloScript] Geo-anchored: \\(name) at (\\(latitude), \\(longitude), \\(altitude))")'
801
+ );
792
802
  this.indentLevel--;
793
803
  this.emit("}");
794
804
  this.emit("");
795
805
  }
796
- this.emit("func createLocationAnchor(name: String, latitude: Double, longitude: Double, altitude: Double) {");
806
+ this.emit(
807
+ "func createLocationAnchor(name: String, latitude: Double, longitude: Double, altitude: Double) {"
808
+ );
797
809
  this.indentLevel++;
798
810
  this.emit("guard let arView = arView else { return }");
799
811
  this.emit("let _ = CLLocation(latitude: latitude, longitude: longitude)");
@@ -818,14 +830,18 @@ var init_IOSCompiler = __esm({
818
830
  this.indentLevel++;
819
831
  this.emit("guard let map = worldMap else {");
820
832
  this.indentLevel++;
821
- this.emit('print("[HoloScript] Failed to get world map: \\(error?.localizedDescription ?? \\"unknown\\")")');
833
+ this.emit(
834
+ 'print("[HoloScript] Failed to get world map: \\(error?.localizedDescription ?? \\"unknown\\")")'
835
+ );
822
836
  this.emit("return");
823
837
  this.indentLevel--;
824
838
  this.emit("}");
825
839
  this.emit("");
826
840
  this.emit("do {");
827
841
  this.indentLevel++;
828
- this.emit("let data = try NSKeyedArchiver.archivedData(withRootObject: map, requiringSecureCoding: true)");
842
+ this.emit(
843
+ "let data = try NSKeyedArchiver.archivedData(withRootObject: map, requiringSecureCoding: true)"
844
+ );
829
845
  this.emit("let url = self.worldMapURL()");
830
846
  this.emit("try data.write(to: url)");
831
847
  this.emit('print("[HoloScript] World map saved to \\(url)")');
@@ -844,7 +860,9 @@ var init_IOSCompiler = __esm({
844
860
  this.indentLevel++;
845
861
  this.emit("let url = worldMapURL()");
846
862
  this.emit("guard let data = try? Data(contentsOf: url),");
847
- this.emit(" let worldMap = try? NSKeyedUnarchiver.unarchivedObject(ofClass: ARWorldMap.self, from: data) else {");
863
+ this.emit(
864
+ " let worldMap = try? NSKeyedUnarchiver.unarchivedObject(ofClass: ARWorldMap.self, from: data) else {"
865
+ );
848
866
  this.indentLevel++;
849
867
  this.emit('print("[HoloScript] No saved world map found")');
850
868
  this.emit("return");
@@ -855,14 +873,18 @@ var init_IOSCompiler = __esm({
855
873
  this.emit("let configuration = ARWorldTrackingConfiguration()");
856
874
  this.emit("configuration.planeDetection = [.horizontal, .vertical]");
857
875
  this.emit("configuration.initialWorldMap = worldMap");
858
- this.emit("arView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])");
876
+ this.emit(
877
+ "arView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])"
878
+ );
859
879
  this.emit('print("[HoloScript] World map restored with \\(worldMap.anchors.count) anchors")');
860
880
  this.indentLevel--;
861
881
  this.emit("}");
862
882
  this.emit("");
863
883
  this.emit("private func worldMapURL() -> URL {");
864
884
  this.indentLevel++;
865
- this.emit("let documentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!");
885
+ this.emit(
886
+ "let documentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!"
887
+ );
866
888
  this.emit('return documentsPath.appendingPathComponent("holoscript_worldmap.arworldmap")');
867
889
  this.indentLevel--;
868
890
  this.emit("}");
@@ -909,9 +931,7 @@ var init_IOSCompiler = __esm({
909
931
  this.emit("import SceneKit");
910
932
  this.emit("import SwiftUI");
911
933
  this.emit("");
912
- this.emit(
913
- "/// A single entity in the HoloScript scene graph produced from a RoomPlan scan."
914
- );
934
+ this.emit("/// A single entity in the HoloScript scene graph produced from a RoomPlan scan.");
915
935
  this.emit("struct HoloEntity: Identifiable {");
916
936
  this.indentLevel++;
917
937
  this.emit("let id: UUID");
@@ -970,9 +990,7 @@ var init_IOSCompiler = __esm({
970
990
  this.emit("");
971
991
  this.emit("// MARK: - Surface mapping");
972
992
  this.emit("");
973
- this.emit(
974
- "private func mapSurface(_ surface: CapturedRoom.Surface) -> HoloEntity {"
975
- );
993
+ this.emit("private func mapSurface(_ surface: CapturedRoom.Surface) -> HoloEntity {");
976
994
  this.indentLevel++;
977
995
  this.emit("let (label, category, traits) = surfaceMeta(surface)");
978
996
  this.emit("return HoloEntity(");
@@ -1028,9 +1046,7 @@ var init_IOSCompiler = __esm({
1028
1046
  this.emit("");
1029
1047
  this.emit("// MARK: - Object mapping");
1030
1048
  this.emit("");
1031
- this.emit(
1032
- "private func mapObject(_ object: CapturedRoom.Object) -> HoloEntity {"
1033
- );
1049
+ this.emit("private func mapObject(_ object: CapturedRoom.Object) -> HoloEntity {");
1034
1050
  this.indentLevel++;
1035
1051
  this.emit("let (label, traits) = objectMeta(object)");
1036
1052
  this.emit("return HoloEntity(");
@@ -1047,9 +1063,7 @@ var init_IOSCompiler = __esm({
1047
1063
  this.indentLevel--;
1048
1064
  this.emit("}");
1049
1065
  this.emit("");
1050
- this.emit(
1051
- "private func objectMeta(_ o: CapturedRoom.Object) -> (String, [String]) {"
1052
- );
1066
+ this.emit("private func objectMeta(_ o: CapturedRoom.Object) -> (String, [String]) {");
1053
1067
  this.indentLevel++;
1054
1068
  this.emit("switch o.category {");
1055
1069
  this.emit("case .table:");
@@ -1103,9 +1117,7 @@ var init_IOSCompiler = __esm({
1103
1117
  this.emit("self.capturedRoom = room");
1104
1118
  this.emit("var result: [HoloEntity] = []");
1105
1119
  this.emit("");
1106
- this.emit(
1107
- "for surface in room.walls + room.doors + room.windows + room.openings {"
1108
- );
1120
+ this.emit("for surface in room.walls + room.doors + room.windows + room.openings {");
1109
1121
  this.indentLevel++;
1110
1122
  this.emit("result.append(mapSurface(surface))");
1111
1123
  this.indentLevel--;
@@ -1124,35 +1136,27 @@ var init_IOSCompiler = __esm({
1124
1136
  this.emit("}");
1125
1137
  this.emit("");
1126
1138
  this.emit("self.entities = result");
1127
- this.emit(
1128
- 'print("[HoloScript] Processed \\(result.count) entities from RoomPlan scan")'
1129
- );
1139
+ this.emit('print("[HoloScript] Processed \\(result.count) entities from RoomPlan scan")');
1130
1140
  this.indentLevel--;
1131
1141
  this.emit("}");
1132
1142
  this.emit("");
1133
1143
  this.emit("// MARK: - .holo export");
1134
1144
  this.emit("");
1135
- this.emit(
1136
- "/// Serialize captured entities to a HoloScript .holo scene string."
1137
- );
1145
+ this.emit("/// Serialize captured entities to a HoloScript .holo scene string.");
1138
1146
  this.emit("func exportToHolo() -> String {");
1139
1147
  this.indentLevel++;
1140
1148
  this.emit("var lines: [String] = []");
1141
1149
  this.emit('lines.append("composition RoomScan {")');
1142
1150
  this.emit("for entity in entities {");
1143
1151
  this.indentLevel++;
1144
- this.emit(
1145
- 'lines.append(" object \\(entity.label)_\\(entity.id.uuidString.prefix(8)) {")'
1146
- );
1152
+ this.emit('lines.append(" object \\(entity.label)_\\(entity.id.uuidString.prefix(8)) {")');
1147
1153
  this.emit(
1148
1154
  'lines.append(" position: [\\(entity.position.x), \\(entity.position.y), \\(entity.position.z)]")'
1149
1155
  );
1150
1156
  this.emit(
1151
1157
  'lines.append(" dimensions: [\\(entity.dimensions.x), \\(entity.dimensions.y), \\(entity.dimensions.z)]")'
1152
1158
  );
1153
- this.emit(
1154
- 'lines.append(" category: \\"\\(entity.category)\\"")'
1155
- );
1159
+ this.emit('lines.append(" category: \\"\\(entity.category)\\"")');
1156
1160
  this.emit("for trait in entity.traits {");
1157
1161
  this.indentLevel++;
1158
1162
  this.emit('lines.append(" trait \\(trait)")');
@@ -1168,13 +1172,9 @@ var init_IOSCompiler = __esm({
1168
1172
  this.indentLevel--;
1169
1173
  this.emit("}");
1170
1174
  this.emit("");
1171
- this.emit(
1172
- `extension ${cls}RoomPlanManager: RoomCaptureSessionDelegate {`
1173
- );
1175
+ this.emit(`extension ${cls}RoomPlanManager: RoomCaptureSessionDelegate {`);
1174
1176
  this.indentLevel++;
1175
- this.emit(
1176
- "func captureSession(_ session: RoomCaptureSession, didUpdate room: CapturedRoom) {"
1177
- );
1177
+ this.emit("func captureSession(_ session: RoomCaptureSession, didUpdate room: CapturedRoom) {");
1178
1178
  this.indentLevel++;
1179
1179
  this.emit("DispatchQueue.main.async { [weak self] in");
1180
1180
  this.indentLevel++;
@@ -1193,9 +1193,7 @@ var init_IOSCompiler = __esm({
1193
1193
  this.emit("self?.isScanning = false");
1194
1194
  this.emit("if let error = error {");
1195
1195
  this.indentLevel++;
1196
- this.emit(
1197
- 'print("[HoloScript] RoomPlan error: \\(error.localizedDescription)")'
1198
- );
1196
+ this.emit('print("[HoloScript] RoomPlan error: \\(error.localizedDescription)")');
1199
1197
  this.emit("return");
1200
1198
  this.indentLevel--;
1201
1199
  this.emit("}");
@@ -1211,9 +1209,7 @@ var init_IOSCompiler = __esm({
1211
1209
  this.emit("");
1212
1210
  this.emit(`struct ${cls}RoomPlanView: View {`);
1213
1211
  this.indentLevel++;
1214
- this.emit(
1215
- `@StateObject private var manager = ${cls}RoomPlanManager()`
1216
- );
1212
+ this.emit(`@StateObject private var manager = ${cls}RoomPlanManager()`);
1217
1213
  this.emit("");
1218
1214
  this.emit("var body: some View {");
1219
1215
  this.indentLevel++;
@@ -1243,12 +1239,8 @@ var init_IOSCompiler = __esm({
1243
1239
  this.emit("VStack(alignment: .leading) {");
1244
1240
  this.indentLevel++;
1245
1241
  this.emit("Text(entity.label).font(.headline)");
1246
- this.emit(
1247
- "Text(entity.category).font(.caption).foregroundColor(.secondary)"
1248
- );
1249
- this.emit(
1250
- 'Text(entity.traits.joined(separator: ", ")).font(.caption2)'
1251
- );
1242
+ this.emit("Text(entity.category).font(.caption).foregroundColor(.secondary)");
1243
+ this.emit('Text(entity.traits.joined(separator: ", ")).font(.caption2)');
1252
1244
  this.indentLevel--;
1253
1245
  this.emit("}");
1254
1246
  this.indentLevel--;
@@ -1296,7 +1288,9 @@ var init_IOSCompiler = __esm({
1296
1288
  const cls = this.options.className;
1297
1289
  const traits = this.collectLiDARTraits(composition);
1298
1290
  this.emit("// Auto-generated by HoloScript IOSCompiler \u2014 LiDAR Scanner integration");
1299
- this.emit(`// Source: composition "${this.escapeStringValue(composition.name, "Swift")}"`);
1291
+ this.emit(
1292
+ `// Source: composition "${this.escapeStringValue(composition.name, "Swift")}"`
1293
+ );
1300
1294
  this.emit("// Requires iOS 15.0+, device with LiDAR sensor");
1301
1295
  this.emit("// Do not edit manually \u2014 regenerate from .holo source");
1302
1296
  this.emit("");
@@ -1352,7 +1346,8 @@ var init_IOSCompiler = __esm({
1352
1346
  this.emit("@Published var meshAnchors: [ARMeshAnchor] = []");
1353
1347
  if (traits.has("lidar_point_cloud")) this.emit("@Published var pointCloud: [simd_float3] = []");
1354
1348
  if (traits.has("lidar_depth_map")) this.emit("@Published var depthMap: CVPixelBuffer?");
1355
- if (traits.has("lidar_depth_confidence")) this.emit("@Published var confidenceMap: CVPixelBuffer?");
1349
+ if (traits.has("lidar_depth_confidence"))
1350
+ this.emit("@Published var confidenceMap: CVPixelBuffer?");
1356
1351
  this.emit("");
1357
1352
  this.emit("private var arSession: ARSession?");
1358
1353
  this.emit("");
@@ -1365,7 +1360,9 @@ var init_IOSCompiler = __esm({
1365
1360
  this.emit("/// Begin a LiDAR scanning session.");
1366
1361
  this.emit("func startScan() {");
1367
1362
  this.indentLevel++;
1368
- this.emit("guard ARWorldTrackingConfiguration.supportsSceneReconstruction(.meshWithClassification) else {");
1363
+ this.emit(
1364
+ "guard ARWorldTrackingConfiguration.supportsSceneReconstruction(.meshWithClassification) else {"
1365
+ );
1369
1366
  this.indentLevel++;
1370
1367
  this.emit('print("[HoloScript] LiDAR scene reconstruction is not supported on this device")');
1371
1368
  this.emit("return");
@@ -1400,7 +1397,9 @@ var init_IOSCompiler = __esm({
1400
1397
  this.emit("// MARK: - Mesh extraction");
1401
1398
  this.emit("");
1402
1399
  this.emit("/// Extract vertices, normals, and faces from an ARMeshGeometry.");
1403
- this.emit("func extractGeometry(_ meshGeometry: ARMeshGeometry) -> (vertices: [simd_float3], normals: [simd_float3], faces: [[UInt32]]) {");
1400
+ this.emit(
1401
+ "func extractGeometry(_ meshGeometry: ARMeshGeometry) -> (vertices: [simd_float3], normals: [simd_float3], faces: [[UInt32]]) {"
1402
+ );
1404
1403
  this.indentLevel++;
1405
1404
  this.emit("var vertices: [simd_float3] = []");
1406
1405
  this.emit("var normals: [simd_float3] = []");
@@ -1409,7 +1408,9 @@ var init_IOSCompiler = __esm({
1409
1408
  this.emit("let vertexBuffer = meshGeometry.vertices");
1410
1409
  this.emit("for i in 0..<vertexBuffer.count {");
1411
1410
  this.indentLevel++;
1412
- this.emit("let ptr = vertexBuffer.buffer.contents().advanced(by: vertexBuffer.offset + vertexBuffer.stride * i)");
1411
+ this.emit(
1412
+ "let ptr = vertexBuffer.buffer.contents().advanced(by: vertexBuffer.offset + vertexBuffer.stride * i)"
1413
+ );
1413
1414
  this.emit("let vertex = ptr.assumingMemoryBound(to: simd_float3.self).pointee");
1414
1415
  this.emit("vertices.append(vertex)");
1415
1416
  this.indentLevel--;
@@ -1418,7 +1419,9 @@ var init_IOSCompiler = __esm({
1418
1419
  this.emit("let normalBuffer = meshGeometry.normals");
1419
1420
  this.emit("for i in 0..<normalBuffer.count {");
1420
1421
  this.indentLevel++;
1421
- this.emit("let ptr = normalBuffer.buffer.contents().advanced(by: normalBuffer.offset + normalBuffer.stride * i)");
1422
+ this.emit(
1423
+ "let ptr = normalBuffer.buffer.contents().advanced(by: normalBuffer.offset + normalBuffer.stride * i)"
1424
+ );
1422
1425
  this.emit("let normal = ptr.assumingMemoryBound(to: simd_float3.self).pointee");
1423
1426
  this.emit("normals.append(normal)");
1424
1427
  this.indentLevel--;
@@ -1430,7 +1433,9 @@ var init_IOSCompiler = __esm({
1430
1433
  this.emit("var indices: [UInt32] = []");
1431
1434
  this.emit("for j in 0..<faceBuffer.indexCountPerPrimitive {");
1432
1435
  this.indentLevel++;
1433
- this.emit("let ptr = faceBuffer.buffer.contents().advanced(by: faceBuffer.offset + (i * faceBuffer.indexCountPerPrimitive + j) * faceBuffer.bytesPerIndex)");
1436
+ this.emit(
1437
+ "let ptr = faceBuffer.buffer.contents().advanced(by: faceBuffer.offset + (i * faceBuffer.indexCountPerPrimitive + j) * faceBuffer.bytesPerIndex)"
1438
+ );
1434
1439
  this.emit("let index = ptr.assumingMemoryBound(to: UInt32.self).pointee");
1435
1440
  this.emit("indices.append(index)");
1436
1441
  this.indentLevel--;
@@ -1453,7 +1458,9 @@ var init_IOSCompiler = __esm({
1453
1458
  this.emit("var classifications: [ARMeshClassification] = []");
1454
1459
  this.emit("for i in 0..<classBuffer.count {");
1455
1460
  this.indentLevel++;
1456
- this.emit("let ptr = classBuffer.buffer.contents().advanced(by: classBuffer.offset + classBuffer.stride * i)");
1461
+ this.emit(
1462
+ "let ptr = classBuffer.buffer.contents().advanced(by: classBuffer.offset + classBuffer.stride * i)"
1463
+ );
1457
1464
  this.emit("let raw = ptr.assumingMemoryBound(to: UInt8.self).pointee");
1458
1465
  this.emit("let classification = ARMeshClassification(rawValue: Int(raw)) ?? .none");
1459
1466
  this.emit("classifications.append(classification)");
@@ -1473,7 +1480,9 @@ var init_IOSCompiler = __esm({
1473
1480
  if (traits.has("lidar_mesh_classification") || traits.has("lidar_mesh_to_holo")) {
1474
1481
  this.emit("let classifications = extractClassifications(anchor)");
1475
1482
  this.emit("");
1476
- this.emit("var grouped: [ARMeshClassification: (verts: [simd_float3], norms: [simd_float3], faces: [[UInt32]])] = [:]");
1483
+ this.emit(
1484
+ "var grouped: [ARMeshClassification: (verts: [simd_float3], norms: [simd_float3], faces: [[UInt32]])] = [:]"
1485
+ );
1477
1486
  this.emit("for (i, face) in faces.enumerated() {");
1478
1487
  this.indentLevel++;
1479
1488
  this.emit("let cls = i < classifications.count ? classifications[i] : .none");
@@ -1501,7 +1510,9 @@ var init_IOSCompiler = __esm({
1501
1510
  this.emit("normals: data.norms,");
1502
1511
  this.emit("faces: data.faces,");
1503
1512
  this.emit("transform: anchor.transform,");
1504
- this.emit('traits: ["lidar_mesh_classification", "lidar_\\(holoLabel(for: classification))"]');
1513
+ this.emit(
1514
+ 'traits: ["lidar_mesh_classification", "lidar_\\(holoLabel(for: classification))"]'
1515
+ );
1505
1516
  this.indentLevel--;
1506
1517
  this.emit("))");
1507
1518
  this.indentLevel--;
@@ -1562,7 +1573,9 @@ var init_IOSCompiler = __esm({
1562
1573
  this.emit("let asset = MDLAsset(bufferAllocator: allocator)");
1563
1574
  this.emit("for anchor in meshAnchors {");
1564
1575
  this.indentLevel++;
1565
- this.emit("let mdlMesh = anchor.geometry.toMDLMesh(device: MTLCreateSystemDefaultDevice()!, allocator: allocator)");
1576
+ this.emit(
1577
+ "let mdlMesh = anchor.geometry.toMDLMesh(device: MTLCreateSystemDefaultDevice()!, allocator: allocator)"
1578
+ );
1566
1579
  this.emit("asset.add(mdlMesh)");
1567
1580
  this.indentLevel--;
1568
1581
  this.emit("}");
@@ -1604,7 +1617,9 @@ var init_IOSCompiler = __esm({
1604
1617
  this.indentLevel++;
1605
1618
  this.emit("let device = MTLCreateSystemDefaultDevice()!");
1606
1619
  this.emit("let allocator = MTKMeshBufferAllocator(device: device)");
1607
- this.emit("let simplified = MDLMesh(meshBySubdividing: mdlMesh, submeshIndex: 0, subdivisionLevels: 0, allocator: allocator)");
1620
+ this.emit(
1621
+ "let simplified = MDLMesh(meshBySubdividing: mdlMesh, submeshIndex: 0, subdivisionLevels: 0, allocator: allocator)"
1622
+ );
1608
1623
  this.emit('print("[HoloScript] Mesh simplified to target face count: \\(targetFaceCount)")');
1609
1624
  this.emit("return simplified");
1610
1625
  this.indentLevel--;
@@ -1669,7 +1684,9 @@ var init_IOSCompiler = __esm({
1669
1684
  this.emit("self?.entities.append(contentsOf: newEntities)");
1670
1685
  this.indentLevel--;
1671
1686
  this.emit("}");
1672
- this.emit('print("[HoloScript] LiDAR mesh updated: \\(self?.meshAnchors.count ?? 0) anchors, \\(self?.entities.count ?? 0) entities")');
1687
+ this.emit(
1688
+ 'print("[HoloScript] LiDAR mesh updated: \\(self?.meshAnchors.count ?? 0) anchors, \\(self?.entities.count ?? 0) entities")'
1689
+ );
1673
1690
  this.indentLevel--;
1674
1691
  this.emit("}");
1675
1692
  this.indentLevel--;
@@ -1821,7 +1838,9 @@ var init_IOSCompiler = __esm({
1821
1838
  this.emit("let request = VNClassifyImageRequest { [weak self] request, error in");
1822
1839
  this.indentLevel++;
1823
1840
  this.emit("guard let self = self, error == nil else { return }");
1824
- this.emit("guard let results = request.results as? [VNClassificationObservation] else { return }");
1841
+ this.emit(
1842
+ "guard let results = request.results as? [VNClassificationObservation] else { return }"
1843
+ );
1825
1844
  this.emit("let filtered = results.filter { $0.confidence >= self.confidenceThreshold }");
1826
1845
  this.emit(" .prefix(self.maxDetections)");
1827
1846
  this.emit("DispatchQueue.main.async {");
@@ -1829,7 +1848,9 @@ var init_IOSCompiler = __esm({
1829
1848
  this.emit("self.detections = filtered.map { obs in");
1830
1849
  this.indentLevel++;
1831
1850
  this.emit("NPUDetection(label: obs.identifier, confidence: obs.confidence,");
1832
- this.emit(" boundingBox: nil, position: nil, segmentationMask: nil, depthValue: nil)");
1851
+ this.emit(
1852
+ " boundingBox: nil, position: nil, segmentationMask: nil, depthValue: nil)"
1853
+ );
1833
1854
  this.indentLevel--;
1834
1855
  this.emit("}");
1835
1856
  this.emit("self.inferenceCount += 1");
@@ -1873,7 +1894,9 @@ var init_IOSCompiler = __esm({
1873
1894
  this.emit("");
1874
1895
  this.emit("private func handleDetectionResults(_ results: [VNObservation]?) {");
1875
1896
  this.indentLevel++;
1876
- this.emit("guard let observations = results as? [VNRecognizedObjectObservation] else { return }");
1897
+ this.emit(
1898
+ "guard let observations = results as? [VNRecognizedObjectObservation] else { return }"
1899
+ );
1877
1900
  this.emit("let filtered = observations.filter { $0.confidence >= confidenceThreshold }");
1878
1901
  this.emit(" .prefix(maxDetections)");
1879
1902
  this.emit("DispatchQueue.main.async { [weak self] in");
@@ -1943,7 +1966,9 @@ var init_IOSCompiler = __esm({
1943
1966
  this.emit("if #available(iOS 18.0, *) {");
1944
1967
  this.indentLevel++;
1945
1968
  this.emit("let request = VNGenerateDepthRequest()");
1946
- this.emit("let handler = VNImageRequestHandler(cvPixelBuffer: frame.capturedImage, options: [:])");
1969
+ this.emit(
1970
+ "let handler = VNImageRequestHandler(cvPixelBuffer: frame.capturedImage, options: [:])"
1971
+ );
1947
1972
  this.emit("try? handler.perform([request])");
1948
1973
  this.emit("if let result = request.results?.first {");
1949
1974
  this.indentLevel++;
@@ -1968,14 +1993,18 @@ var init_IOSCompiler = __esm({
1968
1993
  if (usedTraits.has("npu_entity_pipe")) {
1969
1994
  this.emit("// MARK: - Entity Pipeline (npu_entity_pipe)");
1970
1995
  this.emit("");
1971
- this.emit("func mapDetectionsToEntities(_ detections: [NPUDetection], in sceneView: ARSCNView) -> [SCNNode] {");
1996
+ this.emit(
1997
+ "func mapDetectionsToEntities(_ detections: [NPUDetection], in sceneView: ARSCNView) -> [SCNNode] {"
1998
+ );
1972
1999
  this.indentLevel++;
1973
2000
  this.emit("var nodes: [SCNNode] = []");
1974
2001
  this.emit("for detection in detections {");
1975
2002
  this.indentLevel++;
1976
2003
  this.emit("guard let bbox = detection.boundingBox else { continue }");
1977
2004
  this.emit("let center = CGPoint(x: bbox.midX, y: bbox.midY)");
1978
- this.emit("guard let query = sceneView.raycastQuery(from: center, allowing: .estimatedPlane, alignment: .any),");
2005
+ this.emit(
2006
+ "guard let query = sceneView.raycastQuery(from: center, allowing: .estimatedPlane, alignment: .any),"
2007
+ );
1979
2008
  this.emit(" let result = sceneView.session.raycast(query).first else { continue }");
1980
2009
  this.emit("let anchor = ARAnchor(name: detection.label, transform: result.worldTransform)");
1981
2010
  this.emit("sceneView.session.add(anchor: anchor)");
@@ -1983,7 +2012,9 @@ var init_IOSCompiler = __esm({
1983
2012
  this.emit("node.name = detection.label");
1984
2013
  this.emit(`node.simdWorldPosition = simd_make_float3(result.worldTransform.columns.3)`);
1985
2014
  this.emit(`let sphere = SCNSphere(radius: CGFloat(entityScale))`);
1986
- this.emit("sphere.firstMaterial?.diffuse.contents = UIColor.systemBlue.withAlphaComponent(0.6)");
2015
+ this.emit(
2016
+ "sphere.firstMaterial?.diffuse.contents = UIColor.systemBlue.withAlphaComponent(0.6)"
2017
+ );
1987
2018
  this.emit("node.geometry = sphere");
1988
2019
  this.emit("nodes.append(node)");
1989
2020
  this.indentLevel--;
@@ -2035,9 +2066,13 @@ var init_IOSCompiler = __esm({
2035
2066
  this.emit("");
2036
2067
  this.emit("func loadCustomModel(named name: String) throws {");
2037
2068
  this.indentLevel++;
2038
- this.emit('guard let url = Bundle.main.url(forResource: name, withExtension: "mlmodelc") else {');
2069
+ this.emit(
2070
+ 'guard let url = Bundle.main.url(forResource: name, withExtension: "mlmodelc") else {'
2071
+ );
2039
2072
  this.indentLevel++;
2040
- this.emit('throw NSError(domain: "HoloScript", code: -1, userInfo: [NSLocalizedDescriptionKey: "Model \\(name) not found"])');
2073
+ this.emit(
2074
+ 'throw NSError(domain: "HoloScript", code: -1, userInfo: [NSLocalizedDescriptionKey: "Model \\(name) not found"])'
2075
+ );
2041
2076
  this.indentLevel--;
2042
2077
  this.emit("}");
2043
2078
  this.emit("try loadCustomModel(at: url)");
@@ -2050,7 +2085,9 @@ var init_IOSCompiler = __esm({
2050
2085
  this.emit("");
2051
2086
  this.emit("func createLabelNode(for detection: NPUDetection) -> SCNNode {");
2052
2087
  this.indentLevel++;
2053
- this.emit('let text = SCNText(string: "\\(detection.label) (\\(String(format: "%.0f%%", detection.confidence * 100)))", extrusionDepth: 0.5)');
2088
+ this.emit(
2089
+ 'let text = SCNText(string: "\\(detection.label) (\\(String(format: "%.0f%%", detection.confidence * 100)))", extrusionDepth: 0.5)'
2090
+ );
2054
2091
  this.emit("text.font = UIFont.systemFont(ofSize: 4, weight: .bold)");
2055
2092
  this.emit("text.firstMaterial?.diffuse.contents = UIColor.white");
2056
2093
  this.emit("text.firstMaterial?.isDoubleSided = true");
@@ -2282,7 +2319,9 @@ var init_IOSCompiler = __esm({
2282
2319
  if (this.compositionHasTrait(composition, "portal_people_occlusion")) {
2283
2320
  this.emit("");
2284
2321
  this.emit("// People occlusion via ARKit person segmentation");
2285
- this.emit("if ARWorldTrackingConfiguration.supportsFrameSemantics(.personSegmentationWithDepth) {");
2322
+ this.emit(
2323
+ "if ARWorldTrackingConfiguration.supportsFrameSemantics(.personSegmentationWithDepth) {"
2324
+ );
2286
2325
  this.indentLevel++;
2287
2326
  this.emit("config.frameSemantics.insert(.personSegmentationWithDepth)");
2288
2327
  this.indentLevel--;
@@ -2315,14 +2354,20 @@ var init_IOSCompiler = __esm({
2315
2354
  this.emit("// Apply depth-based occlusion to holographic layer");
2316
2355
  this.emit("for child in holographicLayer.childNodes {");
2317
2356
  this.indentLevel++;
2318
- this.emit("let screenPoint = frame.camera.projectPoint(child.worldPosition, orientation: .portrait, viewportSize: CGSize(width: 1, height: 1))");
2319
- this.emit("child.isHidden = isOccluded(at: screenPoint, depthMap: depthMap, nodeDepth: child.worldPosition.z)");
2357
+ this.emit(
2358
+ "let screenPoint = frame.camera.projectPoint(child.worldPosition, orientation: .portrait, viewportSize: CGSize(width: 1, height: 1))"
2359
+ );
2360
+ this.emit(
2361
+ "child.isHidden = isOccluded(at: screenPoint, depthMap: depthMap, nodeDepth: child.worldPosition.z)"
2362
+ );
2320
2363
  this.indentLevel--;
2321
2364
  this.emit("}");
2322
2365
  this.indentLevel--;
2323
2366
  this.emit("}");
2324
2367
  this.emit("");
2325
- this.emit("private func isOccluded(at point: CGPoint, depthMap: CVPixelBuffer, nodeDepth: Float) -> Bool {");
2368
+ this.emit(
2369
+ "private func isOccluded(at point: CGPoint, depthMap: CVPixelBuffer, nodeDepth: Float) -> Bool {"
2370
+ );
2326
2371
  this.indentLevel++;
2327
2372
  this.emit("CVPixelBufferLockBaseAddress(depthMap, .readOnly)");
2328
2373
  this.emit("defer { CVPixelBufferUnlockBaseAddress(depthMap, .readOnly) }");
@@ -2346,8 +2391,12 @@ var init_IOSCompiler = __esm({
2346
2391
  this.emit("guard let segmentation = frame.segmentationBuffer else { return }");
2347
2392
  this.emit("guard let estimatedDepth = frame.estimatedDepthData else { return }");
2348
2393
  this.emit("// Use matteGenerator for alpha matte of people");
2349
- this.emit("let matteGenerator = ARMatteGenerator(device: MTLCreateSystemDefaultDevice()!, matteResolution: .half)");
2350
- this.emit("let matte = matteGenerator.generateMatte(from: frame, commandBuffer: MTLCreateSystemDefaultDevice()!.makeCommandQueue()!.makeCommandBuffer()!)");
2394
+ this.emit(
2395
+ "let matteGenerator = ARMatteGenerator(device: MTLCreateSystemDefaultDevice()!, matteResolution: .half)"
2396
+ );
2397
+ this.emit(
2398
+ "let matte = matteGenerator.generateMatte(from: frame, commandBuffer: MTLCreateSystemDefaultDevice()!.makeCommandQueue()!.makeCommandBuffer()!)"
2399
+ );
2351
2400
  this.emit("// Apply people matte to holographic layer rendering");
2352
2401
  this.emit('portalScene.rootNode.setValue(matte, forKey: "peopleOcclusionMatte")');
2353
2402
  this.indentLevel--;
@@ -2359,14 +2408,20 @@ var init_IOSCompiler = __esm({
2359
2408
  this.emit("func applyParallaxCorrection(frame: ARFrame) {");
2360
2409
  this.indentLevel++;
2361
2410
  this.emit("let cameraTransform = frame.camera.transform");
2362
- this.emit("let cameraPosition = SIMD3<Float>(cameraTransform.columns.3.x, cameraTransform.columns.3.y, cameraTransform.columns.3.z)");
2411
+ this.emit(
2412
+ "let cameraPosition = SIMD3<Float>(cameraTransform.columns.3.x, cameraTransform.columns.3.y, cameraTransform.columns.3.z)"
2413
+ );
2363
2414
  this.emit("// Offset holographic layer based on camera movement for parallax");
2364
2415
  this.emit("for child in holographicLayer.childNodes {");
2365
2416
  this.indentLevel++;
2366
2417
  this.emit("let depth = child.worldPosition.z");
2367
2418
  this.emit("let parallaxFactor: Float = 1.0 - (depth / 10.0)");
2368
- this.emit("child.position.x += (cameraPosition.x - child.position.x) * parallaxFactor * 0.01");
2369
- this.emit("child.position.y += (cameraPosition.y - child.position.y) * parallaxFactor * 0.01");
2419
+ this.emit(
2420
+ "child.position.x += (cameraPosition.x - child.position.x) * parallaxFactor * 0.01"
2421
+ );
2422
+ this.emit(
2423
+ "child.position.y += (cameraPosition.y - child.position.y) * parallaxFactor * 0.01"
2424
+ );
2370
2425
  this.indentLevel--;
2371
2426
  this.emit("}");
2372
2427
  this.indentLevel--;
@@ -2378,15 +2433,21 @@ var init_IOSCompiler = __esm({
2378
2433
  this.emit("func applyDepthFade(frame: ARFrame) {");
2379
2434
  this.indentLevel++;
2380
2435
  this.emit("let cameraTransform = frame.camera.transform");
2381
- this.emit("let cameraPos = SIMD3<Float>(cameraTransform.columns.3.x, cameraTransform.columns.3.y, cameraTransform.columns.3.z)");
2436
+ this.emit(
2437
+ "let cameraPos = SIMD3<Float>(cameraTransform.columns.3.x, cameraTransform.columns.3.y, cameraTransform.columns.3.z)"
2438
+ );
2382
2439
  this.emit("let nearPlane: Float = 0.1");
2383
2440
  this.emit("let farPlane: Float = 10.0");
2384
2441
  this.emit("");
2385
2442
  this.emit("for child in holographicLayer.childNodes {");
2386
2443
  this.indentLevel++;
2387
- this.emit("let nodePos = SIMD3<Float>(child.worldPosition.x, child.worldPosition.y, child.worldPosition.z)");
2444
+ this.emit(
2445
+ "let nodePos = SIMD3<Float>(child.worldPosition.x, child.worldPosition.y, child.worldPosition.z)"
2446
+ );
2388
2447
  this.emit("let distance = simd_distance(cameraPos, nodePos)");
2389
- this.emit("let alpha = max(0, min(1, 1.0 - (distance - nearPlane) / (farPlane - nearPlane)))");
2448
+ this.emit(
2449
+ "let alpha = max(0, min(1, 1.0 - (distance - nearPlane) / (farPlane - nearPlane)))"
2450
+ );
2390
2451
  this.emit("child.opacity = CGFloat(alpha)");
2391
2452
  this.indentLevel--;
2392
2453
  this.emit("}");
@@ -2395,7 +2456,9 @@ var init_IOSCompiler = __esm({
2395
2456
  this.emit("");
2396
2457
  }
2397
2458
  if (this.compositionHasTrait(composition, "portal_lighting_match")) {
2398
- this.emit("// Portal lighting match: match hologram lighting to real environment via ARKit environment probe");
2459
+ this.emit(
2460
+ "// Portal lighting match: match hologram lighting to real environment via ARKit environment probe"
2461
+ );
2399
2462
  this.emit("func updateLightingMatch(frame: ARFrame) {");
2400
2463
  this.indentLevel++;
2401
2464
  this.emit("guard let lightEstimate = frame.lightEstimate else { return }");
@@ -2403,7 +2466,9 @@ var init_IOSCompiler = __esm({
2403
2466
  this.emit("let temperature = lightEstimate.ambientColorTemperature");
2404
2467
  this.emit("");
2405
2468
  this.emit("// Update holographic scene lighting");
2406
- this.emit('if let light = holographicLayer.childNode(withName: "portalAmbientLight", recursively: true)?.light {');
2469
+ this.emit(
2470
+ 'if let light = holographicLayer.childNode(withName: "portalAmbientLight", recursively: true)?.light {'
2471
+ );
2407
2472
  this.indentLevel++;
2408
2473
  this.emit("light.intensity = intensity");
2409
2474
  this.emit("light.temperature = temperature");
@@ -2425,7 +2490,9 @@ var init_IOSCompiler = __esm({
2425
2490
  }
2426
2491
  if (this.compositionHasTrait(composition, "portal_boundary")) {
2427
2492
  this.emit("// Portal boundary: define portal edges with configurable shape");
2428
- this.emit('func createPortalBoundary(shape: String = "circle", radius: Float = 1.5) -> SCNNode {');
2493
+ this.emit(
2494
+ 'func createPortalBoundary(shape: String = "circle", radius: Float = 1.5) -> SCNNode {'
2495
+ );
2429
2496
  this.indentLevel++;
2430
2497
  this.emit("let boundaryNode = SCNNode()");
2431
2498
  this.emit('boundaryNode.name = "portalBoundary"');
@@ -2439,7 +2506,9 @@ var init_IOSCompiler = __esm({
2439
2506
  this.indentLevel--;
2440
2507
  this.emit('case "rect":');
2441
2508
  this.indentLevel++;
2442
- this.emit("let box = SCNBox(width: CGFloat(radius * 2), height: CGFloat(radius * 2), length: 0.02, chamferRadius: 0.01)");
2509
+ this.emit(
2510
+ "let box = SCNBox(width: CGFloat(radius * 2), height: CGFloat(radius * 2), length: 0.02, chamferRadius: 0.01)"
2511
+ );
2443
2512
  this.emit("box.firstMaterial?.diffuse.contents = UIColor.cyan.withAlphaComponent(0.8)");
2444
2513
  this.emit("boundaryNode.geometry = box");
2445
2514
  this.indentLevel--;
@@ -2463,8 +2532,12 @@ var init_IOSCompiler = __esm({
2463
2532
  this.emit(" float glowIntensity;");
2464
2533
  this.emit(" float time;");
2465
2534
  this.emit(" #pragma body");
2466
- this.emit(" float edgeFactor = 1.0 - abs(dot(normalize(_surface.normal), normalize(_surface.view)));");
2467
- this.emit(" float glow = pow(edgeFactor, 3.0) * glowIntensity * (0.8 + 0.2 * sin(time * 2.0));");
2535
+ this.emit(
2536
+ " float edgeFactor = 1.0 - abs(dot(normalize(_surface.normal), normalize(_surface.view)));"
2537
+ );
2538
+ this.emit(
2539
+ " float glow = pow(edgeFactor, 3.0) * glowIntensity * (0.8 + 0.2 * sin(time * 2.0));"
2540
+ );
2468
2541
  this.emit(" _output.color.rgb += vec3(0.0, glow * 0.8, glow);");
2469
2542
  this.emit('"""');
2470
2543
  this.emit("");
@@ -2473,7 +2546,9 @@ var init_IOSCompiler = __esm({
2473
2546
  this.emit(".fragment: glowShader");
2474
2547
  this.indentLevel--;
2475
2548
  this.emit("]");
2476
- this.emit('boundaryNode.geometry?.firstMaterial?.setValue(Float(1.5), forKey: "glowIntensity")');
2549
+ this.emit(
2550
+ 'boundaryNode.geometry?.firstMaterial?.setValue(Float(1.5), forKey: "glowIntensity")'
2551
+ );
2477
2552
  this.indentLevel--;
2478
2553
  this.emit("}");
2479
2554
  this.emit("");
@@ -2484,7 +2559,9 @@ var init_IOSCompiler = __esm({
2484
2559
  this.indentLevel++;
2485
2560
  this.emit("let cameraTransform = frame.camera.transform");
2486
2561
  this.emit("// Calculate tilt angle from camera orientation");
2487
- this.emit("let forward = SIMD3<Float>(cameraTransform.columns.2.x, cameraTransform.columns.2.y, cameraTransform.columns.2.z)");
2562
+ this.emit(
2563
+ "let forward = SIMD3<Float>(cameraTransform.columns.2.x, cameraTransform.columns.2.y, cameraTransform.columns.2.z)"
2564
+ );
2488
2565
  this.emit("let tiltAngle = abs(asin(forward.y)) * 180.0 / .pi");
2489
2566
  this.emit("let tiltThreshold: Float = 30.0");
2490
2567
  this.emit("portalEnabled = tiltAngle > tiltThreshold");
@@ -2546,7 +2623,9 @@ var init_IOSCompiler = __esm({
2546
2623
  const hasSkeleton = this.compositionHasTrait(composition, "camera_hand_skeleton");
2547
2624
  const hasToSpatial = this.compositionHasTrait(composition, "camera_hand_to_spatial");
2548
2625
  this.emit("// Auto-generated by HoloScript IOSCompiler \u2014 Hand Tracking integration");
2549
- this.emit(`// Source: composition "${this.escapeStringValue(composition.name, "Swift")}"`);
2626
+ this.emit(
2627
+ `// Source: composition "${this.escapeStringValue(composition.name, "Swift")}"`
2628
+ );
2550
2629
  this.emit("// Requires iOS 14.0+, Vision framework");
2551
2630
  this.emit("// Do not edit manually \u2014 regenerate from .holo source");
2552
2631
  this.emit("");
@@ -2571,7 +2650,9 @@ var init_IOSCompiler = __esm({
2571
2650
  this.emit("@Published var currentGesture: HandGesture = .none");
2572
2651
  this.emit("@Published var handCount: Int = 0");
2573
2652
  if (hasSkeleton) {
2574
- this.emit("@Published var jointPositions: [[VNHumanHandPoseObservation.JointName: VNRecognizedPoint]] = []");
2653
+ this.emit(
2654
+ "@Published var jointPositions: [[VNHumanHandPoseObservation.JointName: VNRecognizedPoint]] = []"
2655
+ );
2575
2656
  }
2576
2657
  this.emit("");
2577
2658
  this.emit("private var captureSession: AVCaptureSession?");
@@ -2595,7 +2676,9 @@ var init_IOSCompiler = __esm({
2595
2676
  this.emit("let session = AVCaptureSession()");
2596
2677
  this.emit("session.sessionPreset = .high");
2597
2678
  this.emit("");
2598
- this.emit("guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front),");
2679
+ this.emit(
2680
+ "guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front),"
2681
+ );
2599
2682
  this.emit(" let input = try? AVCaptureDeviceInput(device: device) else {");
2600
2683
  this.indentLevel++;
2601
2684
  this.emit('print("[HoloScript] Failed to access front camera")');
@@ -2642,7 +2725,9 @@ var init_IOSCompiler = __esm({
2642
2725
  this.emit("");
2643
2726
  if (hasConfidence) {
2644
2727
  this.emit("// Filter low-confidence joints");
2645
- this.emit("guard thumbTip.confidence > minConfidence && indexTip.confidence > minConfidence else { return }");
2728
+ this.emit(
2729
+ "guard thumbTip.confidence > minConfidence && indexTip.confidence > minConfidence else { return }"
2730
+ );
2646
2731
  this.emit("");
2647
2732
  }
2648
2733
  if (hasSkeleton) {
@@ -2670,7 +2755,9 @@ var init_IOSCompiler = __esm({
2670
2755
  }
2671
2756
  if (hasPinch) {
2672
2757
  this.emit("// Pinch gesture: thumb tip close to index tip");
2673
- this.emit("let pinchDist = hypot(thumbTip.location.x - indexTip.location.x, thumbTip.location.y - indexTip.location.y)");
2758
+ this.emit(
2759
+ "let pinchDist = hypot(thumbTip.location.x - indexTip.location.x, thumbTip.location.y - indexTip.location.y)"
2760
+ );
2674
2761
  this.emit("if pinchDist < 0.05 {");
2675
2762
  this.indentLevel++;
2676
2763
  this.emit("DispatchQueue.main.async { self.currentGesture = .pinch }");
@@ -2756,13 +2843,19 @@ var init_IOSCompiler = __esm({
2756
2843
  this.indentLevel--;
2757
2844
  this.emit("}");
2758
2845
  this.emit("");
2759
- this.emit(`extension ${cls}HandTrackingManager: AVCaptureVideoDataOutputSampleBufferDelegate {`);
2846
+ this.emit(
2847
+ `extension ${cls}HandTrackingManager: AVCaptureVideoDataOutputSampleBufferDelegate {`
2848
+ );
2760
2849
  this.indentLevel++;
2761
- this.emit("func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {");
2850
+ this.emit(
2851
+ "func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {"
2852
+ );
2762
2853
  this.indentLevel++;
2763
2854
  this.emit("guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }");
2764
2855
  this.emit("");
2765
- this.emit("let handler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: .up, options: [:])");
2856
+ this.emit(
2857
+ "let handler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: .up, options: [:])"
2858
+ );
2766
2859
  this.emit("do {");
2767
2860
  this.indentLevel++;
2768
2861
  this.emit("try handler.perform([handPoseRequest])");
@@ -2894,7 +2987,9 @@ var init_IOSCompiler = __esm({
2894
2987
  this.emit(`class ${cls}ObjectCaptureManager: ObservableObject {`);
2895
2988
  this.indentLevel++;
2896
2989
  this.emit("");
2897
- this.emit('private let logger = Logger(subsystem: "net.holoscript", category: "ObjectCapture")');
2990
+ this.emit(
2991
+ 'private let logger = Logger(subsystem: "net.holoscript", category: "ObjectCapture")'
2992
+ );
2898
2993
  this.emit("");
2899
2994
  this.emit("enum CaptureState: Equatable {");
2900
2995
  this.indentLevel++;
@@ -2928,9 +3023,15 @@ var init_IOSCompiler = __esm({
2928
3023
  this.emit("");
2929
3024
  this.emit("init() {");
2930
3025
  this.indentLevel++;
2931
- this.emit("let docs = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!");
2932
- this.emit('self.outputDirectory = docs.appendingPathComponent("HoloCaptures", isDirectory: true)');
2933
- this.emit("try? FileManager.default.createDirectory(at: outputDirectory, withIntermediateDirectories: true)");
3026
+ this.emit(
3027
+ "let docs = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!"
3028
+ );
3029
+ this.emit(
3030
+ 'self.outputDirectory = docs.appendingPathComponent("HoloCaptures", isDirectory: true)'
3031
+ );
3032
+ this.emit(
3033
+ "try? FileManager.default.createDirectory(at: outputDirectory, withIntermediateDirectories: true)"
3034
+ );
2934
3035
  this.indentLevel--;
2935
3036
  this.emit("}");
2936
3037
  this.emit("");
@@ -2953,7 +3054,9 @@ var init_IOSCompiler = __esm({
2953
3054
  this.emit("self.captureSession = session");
2954
3055
  this.emit("");
2955
3056
  this.emit("var configuration = ObjectCaptureSession.Configuration()");
2956
- this.emit('configuration.checkpointDirectory = outputDirectory.appendingPathComponent("Checkpoints")');
3057
+ this.emit(
3058
+ 'configuration.checkpointDirectory = outputDirectory.appendingPathComponent("Checkpoints")'
3059
+ );
2957
3060
  this.emit("configuration.isOverCaptureEnabled = true");
2958
3061
  this.emit('session.start(imagesDirectory: outputDirectory.appendingPathComponent("Images"),');
2959
3062
  this.emit(" configuration: configuration)");
@@ -3068,7 +3171,9 @@ var init_IOSCompiler = __esm({
3068
3171
  this.emit("private func makePhotogrammetryRequest() -> PhotogrammetrySession.Request {");
3069
3172
  this.indentLevel++;
3070
3173
  this.emit('let outputURL = outputDirectory.appendingPathComponent("model.usdz")');
3071
- this.emit("// .full detail level captures PBR maps (diffuse, normal, roughness, metallic, AO)");
3174
+ this.emit(
3175
+ "// .full detail level captures PBR maps (diffuse, normal, roughness, metallic, AO)"
3176
+ );
3072
3177
  this.emit("return .modelFile(url: outputURL, detail: .full)");
3073
3178
  this.indentLevel--;
3074
3179
  this.emit("}");
@@ -3081,7 +3186,9 @@ var init_IOSCompiler = __esm({
3081
3186
  this.emit("");
3082
3187
  this.emit("for level in HoloCapturedEntity.DetailLevel.allCases {");
3083
3188
  this.indentLevel++;
3084
- this.emit('let url = outputDirectory.appendingPathComponent("model_\\(level.rawValue).usdz")');
3189
+ this.emit(
3190
+ 'let url = outputDirectory.appendingPathComponent("model_\\(level.rawValue).usdz")'
3191
+ );
3085
3192
  this.emit("let detail: PhotogrammetrySession.Request.Detail");
3086
3193
  this.emit("switch level {");
3087
3194
  this.emit("case .preview: detail = .preview");
@@ -3105,7 +3212,9 @@ var init_IOSCompiler = __esm({
3105
3212
  this.emit("");
3106
3213
  }
3107
3214
  if (traits.has("pbr_texture_extract") || traits.has("object_capture")) {
3108
- this.emit("private func extractPBRMaterials(from modelURL: URL) -> HoloCapturedEntity.PBRMaterialSet? {");
3215
+ this.emit(
3216
+ "private func extractPBRMaterials(from modelURL: URL) -> HoloCapturedEntity.PBRMaterialSet? {"
3217
+ );
3109
3218
  this.indentLevel++;
3110
3219
  this.emit("let baseDir = modelURL.deletingLastPathComponent()");
3111
3220
  this.emit('let diffuse = baseDir.appendingPathComponent("diffuse.png")');
@@ -3115,10 +3224,18 @@ var init_IOSCompiler = __esm({
3115
3224
  this.emit('let ao = baseDir.appendingPathComponent("ao.png")');
3116
3225
  this.emit("");
3117
3226
  this.emit("return HoloCapturedEntity.PBRMaterialSet(");
3118
- this.emit(" diffuseMap: FileManager.default.fileExists(atPath: diffuse.path) ? diffuse : nil,");
3119
- this.emit(" normalMap: FileManager.default.fileExists(atPath: normal.path) ? normal : nil,");
3120
- this.emit(" roughnessMap: FileManager.default.fileExists(atPath: roughness.path) ? roughness : nil,");
3121
- this.emit(" metallicMap: FileManager.default.fileExists(atPath: metallic.path) ? metallic : nil,");
3227
+ this.emit(
3228
+ " diffuseMap: FileManager.default.fileExists(atPath: diffuse.path) ? diffuse : nil,"
3229
+ );
3230
+ this.emit(
3231
+ " normalMap: FileManager.default.fileExists(atPath: normal.path) ? normal : nil,"
3232
+ );
3233
+ this.emit(
3234
+ " roughnessMap: FileManager.default.fileExists(atPath: roughness.path) ? roughness : nil,"
3235
+ );
3236
+ this.emit(
3237
+ " metallicMap: FileManager.default.fileExists(atPath: metallic.path) ? metallic : nil,"
3238
+ );
3122
3239
  this.emit(" aoMap: FileManager.default.fileExists(atPath: ao.path) ? ao : nil");
3123
3240
  this.emit(")");
3124
3241
  this.indentLevel--;
@@ -3183,16 +3300,24 @@ var init_IOSCompiler = __esm({
3183
3300
  this.emit('var holo = "scene CapturedObject {\\n"');
3184
3301
  this.emit('holo += " object \\(entity.name) {\\n"');
3185
3302
  this.emit('holo += " model: \\"\\(entity.modelURL.lastPathComponent)\\"\\n"');
3186
- this.emit('holo += " position: [\\(entity.boundingBox.center.x), \\(entity.boundingBox.center.y), \\(entity.boundingBox.center.z)]\\n"');
3187
- this.emit('holo += " scale: [\\(entity.boundingBox.extents.x), \\(entity.boundingBox.extents.y), \\(entity.boundingBox.extents.z)]\\n"');
3303
+ this.emit(
3304
+ 'holo += " position: [\\(entity.boundingBox.center.x), \\(entity.boundingBox.center.y), \\(entity.boundingBox.center.z)]\\n"'
3305
+ );
3306
+ this.emit(
3307
+ 'holo += " scale: [\\(entity.boundingBox.extents.x), \\(entity.boundingBox.extents.y), \\(entity.boundingBox.extents.z)]\\n"'
3308
+ );
3188
3309
  this.emit('holo += " traits: [object_capture, photogrammetry_scan]\\n"');
3189
3310
  if (traits.has("pbr_texture_extract")) {
3190
3311
  this.emit("if let pbr = entity.pbrMaterials {");
3191
3312
  this.indentLevel++;
3192
3313
  this.emit('if pbr.diffuseMap != nil { holo += " diffuse_map: \\"diffuse.png\\"\\n" }');
3193
3314
  this.emit('if pbr.normalMap != nil { holo += " normal_map: \\"normal.png\\"\\n" }');
3194
- this.emit('if pbr.roughnessMap != nil { holo += " roughness_map: \\"roughness.png\\"\\n" }');
3195
- this.emit('if pbr.metallicMap != nil { holo += " metallic_map: \\"metallic.png\\"\\n" }');
3315
+ this.emit(
3316
+ 'if pbr.roughnessMap != nil { holo += " roughness_map: \\"roughness.png\\"\\n" }'
3317
+ );
3318
+ this.emit(
3319
+ 'if pbr.metallicMap != nil { holo += " metallic_map: \\"metallic.png\\"\\n" }'
3320
+ );
3196
3321
  this.emit('if pbr.aoMap != nil { holo += " ao_map: \\"ao.png\\"\\n" }');
3197
3322
  this.indentLevel--;
3198
3323
  this.emit("}");
@@ -3435,7 +3560,9 @@ var init_IOSCompiler = __esm({
3435
3560
  this.emit("");
3436
3561
  }
3437
3562
  if (this.compositionHasTrait(composition, "shareplay_anchor_local")) {
3438
- this.emit("// Local AR anchor mapping \u2014 each participant maps shared positions to local space");
3563
+ this.emit(
3564
+ "// Local AR anchor mapping \u2014 each participant maps shared positions to local space"
3565
+ );
3439
3566
  this.emit("private var localWorldTransform: simd_float4x4 = matrix_identity_float4x4");
3440
3567
  this.emit("private var sharedToLocalOffset: simd_float3 = .zero");
3441
3568
  this.emit("");
@@ -3526,9 +3653,7 @@ var init_IOSCompiler = __esm({
3526
3653
  this.emit("func becomeHost() {");
3527
3654
  this.indentLevel++;
3528
3655
  this.emit("isHost = true");
3529
- this.emit(
3530
- "broadcastSceneState() // Host pushes authoritative state to all participants"
3531
- );
3656
+ this.emit("broadcastSceneState() // Host pushes authoritative state to all participants");
3532
3657
  this.indentLevel--;
3533
3658
  this.emit("}");
3534
3659
  this.emit("");
@@ -3774,9 +3899,7 @@ var init_IOSCompiler = __esm({
3774
3899
  if (this.compositionHasTrait(composition, "shareplay_anchor_local")) {
3775
3900
  this.emit("// MARK: - Local Anchor Mapping");
3776
3901
  this.emit("");
3777
- this.emit(
3778
- "func calibrateLocalAnchor(arFrame: ARFrame, sharedReferencePoint: simd_float3) {"
3779
- );
3902
+ this.emit("func calibrateLocalAnchor(arFrame: ARFrame, sharedReferencePoint: simd_float3) {");
3780
3903
  this.indentLevel++;
3781
3904
  this.emit("// Each participant creates a local ARKit anchor and maps shared positions");
3782
3905
  this.emit("let cameraPos = arFrame.camera.transform.columns.3");
@@ -3805,9 +3928,7 @@ var init_IOSCompiler = __esm({
3805
3928
  this.emit("");
3806
3929
  this.emit("func configureSpatialAudio() {");
3807
3930
  this.indentLevel++;
3808
- this.emit(
3809
- "// SpatialAudioExperience.custom(fixedToScene: true) for participant voices"
3810
- );
3931
+ this.emit("// SpatialAudioExperience.custom(fixedToScene: true) for participant voices");
3811
3932
  this.emit("guard let session = groupSession else { return }");
3812
3933
  this.emit("session.spatialAudioExperience = .custom(fixedToScene: true)");
3813
3934
  this.indentLevel--;
@@ -3817,9 +3938,7 @@ var init_IOSCompiler = __esm({
3817
3938
  if (this.compositionHasTrait(composition, "shareplay_mute_zone")) {
3818
3939
  this.emit("// MARK: - Mute Zones");
3819
3940
  this.emit("");
3820
- this.emit(
3821
- "func addMuteZone(center: simd_float3, radius: Float, attenuation: Float = 0.0) {"
3822
- );
3941
+ this.emit("func addMuteZone(center: simd_float3, radius: Float, attenuation: Float = 0.0) {");
3823
3942
  this.indentLevel++;
3824
3943
  this.emit(
3825
3944
  "muteZones.append(MuteZone(center: center, radius: radius, attenuation: attenuation))"
@@ -3836,9 +3955,7 @@ var init_IOSCompiler = __esm({
3836
3955
  this.emit("if distance < zone.radius {");
3837
3956
  this.indentLevel++;
3838
3957
  this.emit("let factor = distance / zone.radius");
3839
- this.emit(
3840
- "let zoneAttenuation = zone.attenuation + (1.0 - zone.attenuation) * factor"
3841
- );
3958
+ this.emit("let zoneAttenuation = zone.attenuation + (1.0 - zone.attenuation) * factor");
3842
3959
  this.emit("minAttenuation = min(minAttenuation, zoneAttenuation)");
3843
3960
  this.indentLevel--;
3844
3961
  this.emit("}");
@@ -3878,12 +3995,8 @@ var init_IOSCompiler = __esm({
3878
3995
  this.emit("// Session status");
3879
3996
  this.emit("HStack {");
3880
3997
  this.indentLevel++;
3881
- this.emit(
3882
- 'Image(systemName: manager.isSessionActive ? "person.2.fill" : "person.2")'
3883
- );
3884
- this.emit(
3885
- 'Text(manager.isSessionActive ? "SharePlay Active" : "SharePlay Inactive")'
3886
- );
3998
+ this.emit('Image(systemName: manager.isSessionActive ? "person.2.fill" : "person.2")');
3999
+ this.emit('Text(manager.isSessionActive ? "SharePlay Active" : "SharePlay Inactive")');
3887
4000
  this.indentLevel--;
3888
4001
  this.emit("}");
3889
4002
  this.emit(".padding()");
@@ -3950,7 +4063,9 @@ var init_IOSCompiler = __esm({
3950
4063
  const hasGaze = this.compositionHasTrait(composition, "face_gaze_direction");
3951
4064
  const hasTongue = this.compositionHasTrait(composition, "face_tongue_detect");
3952
4065
  this.emit("// Auto-generated by HoloScript IOSCompiler \u2014 TrueDepth Face Tracking");
3953
- this.emit(`// Source: composition "${this.escapeStringValue(composition.name, "Swift")}"`);
4066
+ this.emit(
4067
+ `// Source: composition "${this.escapeStringValue(composition.name, "Swift")}"`
4068
+ );
3954
4069
  this.emit("// Requires iOS 11.0+, ARKit, TrueDepth camera");
3955
4070
  this.emit("// Do not edit manually \u2014 regenerate from .holo source");
3956
4071
  this.emit("");
@@ -3996,7 +4111,9 @@ var init_IOSCompiler = __esm({
3996
4111
  }
3997
4112
  if (hasRetarget) {
3998
4113
  this.emit("@Published var retargetedBlendShapes: [String: Float] = [:]");
3999
- this.emit("var retargetMap: [ARFaceAnchor.BlendShapeLocation: (target: String, scale: Float)] = [:]");
4114
+ this.emit(
4115
+ "var retargetMap: [ARFaceAnchor.BlendShapeLocation: (target: String, scale: Float)] = [:]"
4116
+ );
4000
4117
  }
4001
4118
  this.emit("");
4002
4119
  this.emit("private var arSession: ARSession?");
@@ -4052,7 +4169,9 @@ var init_IOSCompiler = __esm({
4052
4169
  this.emit("");
4053
4170
  this.emit("func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {");
4054
4171
  this.indentLevel++;
4055
- this.emit("guard let faceAnchor = anchors.compactMap({ $0 as? ARFaceAnchor }).first else { return }");
4172
+ this.emit(
4173
+ "guard let faceAnchor = anchors.compactMap({ $0 as? ARFaceAnchor }).first else { return }"
4174
+ );
4056
4175
  this.emit("");
4057
4176
  if (hasBlendshapes || hasAvatarDrive || hasMirror || hasPuppet) {
4058
4177
  this.emit("let shapes = faceAnchor.blendShapes");
@@ -4149,7 +4268,9 @@ var init_IOSCompiler = __esm({
4149
4268
  this.emit("// MARK: - Puppet Mode");
4150
4269
  this.emit("");
4151
4270
  this.emit("/// Puppet mode: avatar responds exclusively to face input.");
4152
- this.emit("/// Returns a complete morph target dictionary derived solely from face tracking.");
4271
+ this.emit(
4272
+ "/// Returns a complete morph target dictionary derived solely from face tracking."
4273
+ );
4153
4274
  this.emit("func getPuppetMorphTargets() -> [String: Float] {");
4154
4275
  this.indentLevel++;
4155
4276
  this.emit("var targets: [String: Float] = [:]");
@@ -4166,8 +4287,12 @@ var init_IOSCompiler = __esm({
4166
4287
  if (hasRetarget) {
4167
4288
  this.emit("// MARK: - Retargeting");
4168
4289
  this.emit("");
4169
- this.emit("/// Applies retarget map to remap/scale blendshapes for non-human avatar topologies.");
4170
- this.emit("private func applyRetargeting(from shapes: [ARFaceAnchor.BlendShapeLocation: NSNumber]) {");
4290
+ this.emit(
4291
+ "/// Applies retarget map to remap/scale blendshapes for non-human avatar topologies."
4292
+ );
4293
+ this.emit(
4294
+ "private func applyRetargeting(from shapes: [ARFaceAnchor.BlendShapeLocation: NSNumber]) {"
4295
+ );
4171
4296
  this.indentLevel++;
4172
4297
  this.emit("var result: [String: Float] = [:]");
4173
4298
  this.emit("for (arkitShape, value) in shapes {");
@@ -4196,7 +4321,9 @@ var init_IOSCompiler = __esm({
4196
4321
  this.emit("// MARK: - Emotion Detection");
4197
4322
  this.emit("");
4198
4323
  this.emit("/// Derives emotion from blendshape combinations.");
4199
- this.emit("private func detectEmotion(from shapes: [ARFaceAnchor.BlendShapeLocation: NSNumber]) {");
4324
+ this.emit(
4325
+ "private func detectEmotion(from shapes: [ARFaceAnchor.BlendShapeLocation: NSNumber]) {"
4326
+ );
4200
4327
  this.indentLevel++;
4201
4328
  this.emit("let mouthSmileL = shapes[.mouthSmileLeft]?.floatValue ?? 0.0");
4202
4329
  this.emit("let mouthSmileR = shapes[.mouthSmileRight]?.floatValue ?? 0.0");
@@ -4228,7 +4355,9 @@ var init_IOSCompiler = __esm({
4228
4355
  this.emit("emotion = .surprised");
4229
4356
  this.indentLevel--;
4230
4357
  this.emit("// Angry: browDown + mouthPress");
4231
- this.emit("} else if ((browDownL + browDownR) / 2.0 > 0.4) && ((mouthPressL + mouthPressR) / 2.0 > 0.3) {");
4358
+ this.emit(
4359
+ "} else if ((browDownL + browDownR) / 2.0 > 0.4) && ((mouthPressL + mouthPressR) / 2.0 > 0.3) {"
4360
+ );
4232
4361
  this.indentLevel++;
4233
4362
  this.emit("emotion = .angry");
4234
4363
  this.indentLevel--;
@@ -4267,7 +4396,9 @@ var init_IOSCompiler = __esm({
4267
4396
  this.emit('Text("Blendshapes (\\(manager.blendShapes.count))").font(.subheadline)');
4268
4397
  this.emit("ScrollView {");
4269
4398
  this.indentLevel++;
4270
- this.emit("ForEach(Array(manager.blendShapes.keys).sorted(by: { $0.rawValue < $1.rawValue }), id: \\.rawValue) { key in");
4399
+ this.emit(
4400
+ "ForEach(Array(manager.blendShapes.keys).sorted(by: { $0.rawValue < $1.rawValue }), id: \\.rawValue) { key in"
4401
+ );
4271
4402
  this.indentLevel++;
4272
4403
  this.emit("HStack {");
4273
4404
  this.indentLevel++;
@@ -4284,7 +4415,9 @@ var init_IOSCompiler = __esm({
4284
4415
  this.emit('Text("Emotion: \\(manager.currentEmotion.rawValue)").font(.subheadline)');
4285
4416
  }
4286
4417
  if (hasGaze) {
4287
- this.emit('Text("Gaze: \\(manager.gazeDirection.x, specifier: "%.2f"), \\(manager.gazeDirection.y, specifier: "%.2f"), \\(manager.gazeDirection.z, specifier: "%.2f")").font(.caption)');
4418
+ this.emit(
4419
+ 'Text("Gaze: \\(manager.gazeDirection.x, specifier: "%.2f"), \\(manager.gazeDirection.y, specifier: "%.2f"), \\(manager.gazeDirection.z, specifier: "%.2f")").font(.caption)'
4420
+ );
4288
4421
  }
4289
4422
  if (hasTongue) {
4290
4423
  this.emit('Text("Tongue Out: \\(manager.isTongueOut ? "Yes" : "No")").font(.caption)');
@@ -4416,11 +4549,15 @@ var init_IOSCompiler = __esm({
4416
4549
  this.indentLevel++;
4417
4550
  this.emit("guard !isScanning else { return }");
4418
4551
  this.emit("");
4419
- this.emit("let session = MCSession(peer: localPeerId, securityIdentity: nil, encryptionPreference: .required)");
4552
+ this.emit(
4553
+ "let session = MCSession(peer: localPeerId, securityIdentity: nil, encryptionPreference: .required)"
4554
+ );
4420
4555
  this.emit("session.delegate = self");
4421
4556
  this.emit("mcSession = session");
4422
4557
  this.emit("");
4423
- this.emit("mcAdvertiser = MCNearbyServiceAdvertiser(peer: localPeerId, discoveryInfo: nil, serviceType: serviceType)");
4558
+ this.emit(
4559
+ "mcAdvertiser = MCNearbyServiceAdvertiser(peer: localPeerId, discoveryInfo: nil, serviceType: serviceType)"
4560
+ );
4424
4561
  this.emit("mcAdvertiser?.delegate = self");
4425
4562
  this.emit("mcAdvertiser?.startAdvertisingPeer()");
4426
4563
  this.emit("");
@@ -4506,9 +4643,13 @@ var init_IOSCompiler = __esm({
4506
4643
  this.indentLevel--;
4507
4644
  this.emit("]");
4508
4645
  this.emit("");
4509
- this.emit("guard let data = try? JSONSerialization.data(withJSONObject: payload) else { return }");
4646
+ this.emit(
4647
+ "guard let data = try? JSONSerialization.data(withJSONObject: payload) else { return }"
4648
+ );
4510
4649
  this.emit("");
4511
- this.emit("if let mcPeer = session.connectedPeers.first(where: { $0.displayName == peerId }) {");
4650
+ this.emit(
4651
+ "if let mcPeer = session.connectedPeers.first(where: { $0.displayName == peerId }) {"
4652
+ );
4512
4653
  this.indentLevel++;
4513
4654
  this.emit("try? session.send(data, toPeers: [mcPeer], with: .reliable)");
4514
4655
  this.emit('print("[UWB] Handoff entity \\(entityId) to \\(peerId)")');
@@ -4569,7 +4710,9 @@ var init_IOSCompiler = __esm({
4569
4710
  this.emit("private func shareDiscoveryToken(with mcPeer: MCPeerID) {");
4570
4711
  this.indentLevel++;
4571
4712
  this.emit("guard let token = niSession?.discoveryToken,");
4572
- this.emit(" let data = try? NSKeyedArchiver.archivedData(withRootObject: token, requiringSecureCoding: true) else { return }");
4713
+ this.emit(
4714
+ " let data = try? NSKeyedArchiver.archivedData(withRootObject: token, requiringSecureCoding: true) else { return }"
4715
+ );
4573
4716
  this.emit("try? mcSession?.send(data, toPeers: [mcPeer], with: .reliable)");
4574
4717
  this.indentLevel--;
4575
4718
  this.emit("}");
@@ -4605,7 +4748,9 @@ var init_IOSCompiler = __esm({
4605
4748
  this.emit("for obj in nearbyObjects {");
4606
4749
  this.indentLevel++;
4607
4750
  this.emit("guard let peerId = peerTokenMap[obj.discoveryToken] else { continue }");
4608
- this.emit("var peer = peers[peerId] ?? UWBPeer(id: peerId, discoveryToken: obj.discoveryToken)");
4751
+ this.emit(
4752
+ "var peer = peers[peerId] ?? UWBPeer(id: peerId, discoveryToken: obj.discoveryToken)"
4753
+ );
4609
4754
  this.emit("peer.distance = obj.distance");
4610
4755
  this.emit("peer.direction = obj.direction");
4611
4756
  this.emit("peer.lastSeen = Date()");
@@ -4616,7 +4761,9 @@ var init_IOSCompiler = __esm({
4616
4761
  this.indentLevel--;
4617
4762
  this.emit("}");
4618
4763
  this.emit("");
4619
- this.emit("func session(_ session: NISession, didRemove nearbyObjects: [NINearbyObject], reason: NINearbyObject.RemovalReason) {");
4764
+ this.emit(
4765
+ "func session(_ session: NISession, didRemove nearbyObjects: [NINearbyObject], reason: NINearbyObject.RemovalReason) {"
4766
+ );
4620
4767
  this.indentLevel++;
4621
4768
  this.emit("for obj in nearbyObjects {");
4622
4769
  this.indentLevel++;
@@ -4661,7 +4808,9 @@ var init_IOSCompiler = __esm({
4661
4808
  this.emit(`extension ${cls}UWBManager: MCSessionDelegate {`);
4662
4809
  this.indentLevel++;
4663
4810
  this.emit("");
4664
- this.emit("func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {");
4811
+ this.emit(
4812
+ "func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {"
4813
+ );
4665
4814
  this.indentLevel++;
4666
4815
  this.emit("switch state {");
4667
4816
  this.emit("case .connected:");
@@ -4687,10 +4836,14 @@ var init_IOSCompiler = __esm({
4687
4836
  this.indentLevel--;
4688
4837
  this.emit("}");
4689
4838
  this.emit("");
4690
- this.emit("func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) {");
4839
+ this.emit(
4840
+ "func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) {"
4841
+ );
4691
4842
  this.indentLevel++;
4692
4843
  this.emit("// Try to decode as NI discovery token");
4693
- this.emit("if let token = try? NSKeyedUnarchiver.unarchivedObject(ofClass: NIDiscoveryToken.self, from: data) {");
4844
+ this.emit(
4845
+ "if let token = try? NSKeyedUnarchiver.unarchivedObject(ofClass: NIDiscoveryToken.self, from: data) {"
4846
+ );
4694
4847
  this.indentLevel++;
4695
4848
  this.emit("peerTokenMap[token] = peerID.displayName");
4696
4849
  this.emit("let peer = UWBPeer(id: peerID.displayName, discoveryToken: token)");
@@ -4703,7 +4856,9 @@ var init_IOSCompiler = __esm({
4703
4856
  if (this.compositionHasTrait(composition, "uwb_handoff")) {
4704
4857
  this.emit("");
4705
4858
  this.emit("// Try to decode as handoff payload");
4706
- this.emit("if let json = try? JSONSerialization.jsonObject(with: data) as? [String: String],");
4859
+ this.emit(
4860
+ "if let json = try? JSONSerialization.jsonObject(with: data) as? [String: String],"
4861
+ );
4707
4862
  this.emit(' json["type"] == "uwb_handoff",');
4708
4863
  this.emit(' let entityId = json["entityId"],');
4709
4864
  this.emit(" let peer = peers[peerID.displayName] {");
@@ -4715,9 +4870,15 @@ var init_IOSCompiler = __esm({
4715
4870
  this.indentLevel--;
4716
4871
  this.emit("}");
4717
4872
  this.emit("");
4718
- this.emit("func session(_ session: MCSession, didReceive stream: InputStream, withName streamName: String, fromPeer peerID: MCPeerID) {}");
4719
- this.emit("func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress) {}");
4720
- this.emit("func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL?, withError error: Error?) {}");
4873
+ this.emit(
4874
+ "func session(_ session: MCSession, didReceive stream: InputStream, withName streamName: String, fromPeer peerID: MCPeerID) {}"
4875
+ );
4876
+ this.emit(
4877
+ "func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress) {}"
4878
+ );
4879
+ this.emit(
4880
+ "func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL?, withError error: Error?) {}"
4881
+ );
4721
4882
  this.indentLevel--;
4722
4883
  this.emit("}");
4723
4884
  this.emit("");
@@ -4726,7 +4887,9 @@ var init_IOSCompiler = __esm({
4726
4887
  this.emit(`extension ${cls}UWBManager: MCNearbyServiceAdvertiserDelegate {`);
4727
4888
  this.indentLevel++;
4728
4889
  this.emit("");
4729
- this.emit("func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: Data?, invitationHandler: @escaping (Bool, MCSession?) -> Void) {");
4890
+ this.emit(
4891
+ "func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: Data?, invitationHandler: @escaping (Bool, MCSession?) -> Void) {"
4892
+ );
4730
4893
  this.indentLevel++;
4731
4894
  this.emit("invitationHandler(true, mcSession)");
4732
4895
  this.indentLevel--;
@@ -4739,7 +4902,9 @@ var init_IOSCompiler = __esm({
4739
4902
  this.emit(`extension ${cls}UWBManager: MCNearbyServiceBrowserDelegate {`);
4740
4903
  this.indentLevel++;
4741
4904
  this.emit("");
4742
- this.emit("func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String: String]?) {");
4905
+ this.emit(
4906
+ "func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String: String]?) {"
4907
+ );
4743
4908
  this.indentLevel++;
4744
4909
  this.emit("guard let session = mcSession else { return }");
4745
4910
  this.emit("browser.invitePeer(peerID, to: session, withContext: nil, timeout: 10)");
@@ -4930,7 +5095,9 @@ var init_IOSCompiler = __esm({
4930
5095
  this.indentLevel--;
4931
5096
  this.emit("}");
4932
5097
  this.emit("");
4933
- this.emit("headphoneMotionManager.startDeviceMotionUpdates(to: .main) { [weak self] motion, error in");
5098
+ this.emit(
5099
+ "headphoneMotionManager.startDeviceMotionUpdates(to: .main) { [weak self] motion, error in"
5100
+ );
4934
5101
  this.indentLevel++;
4935
5102
  this.emit("guard let self = self, let motion = motion else { return }");
4936
5103
  this.emit("self.headTrackingActive = true");
@@ -4978,7 +5145,9 @@ var init_IOSCompiler = __esm({
4978
5145
  this.emit("sources[source.id] = phaseSource");
4979
5146
  this.emit("audioSources.append(source)");
4980
5147
  this.emit("");
4981
- this.emit("loadAndPlayAudio(sourceId: source.id, audioFile: source.audioFile, gain: source.gain)");
5148
+ this.emit(
5149
+ "loadAndPlayAudio(sourceId: source.id, audioFile: source.audioFile, gain: source.gain)"
5150
+ );
4982
5151
  this.indentLevel--;
4983
5152
  this.emit("}");
4984
5153
  this.emit("");
@@ -5040,7 +5209,9 @@ var init_IOSCompiler = __esm({
5040
5209
  this.indentLevel--;
5041
5210
  this.emit(")");
5042
5211
  this.emit("samplerNodeDef.playbackMode = .looping");
5043
- this.emit("samplerNodeDef.setCalibrationMode(calibrationMode: .relativeSpl, level: Double(gain * 20))");
5212
+ this.emit(
5213
+ "samplerNodeDef.setCalibrationMode(calibrationMode: .relativeSpl, level: Double(gain * 20))"
5214
+ );
5044
5215
  this.emit("");
5045
5216
  if (traits.has("audio_falloff")) {
5046
5217
  this.emit("// Distance-based falloff (audio_falloff)");
@@ -5053,7 +5224,9 @@ var init_IOSCompiler = __esm({
5053
5224
  this.emit("distanceModelParameters.rolloffFactor = 1.0");
5054
5225
  this.emit("");
5055
5226
  this.emit("let spatialPipelineDef = PHASESpatialPipeline(flags: [.directPathTransmission])!");
5056
- this.emit("spatialPipelineDef.entries[PHASESpatialCategory.directPath]!.sendLevel = Double(gain)");
5227
+ this.emit(
5228
+ "spatialPipelineDef.entries[PHASESpatialCategory.directPath]!.sendLevel = Double(gain)"
5229
+ );
5057
5230
  this.emit("");
5058
5231
  this.emit("let spatialMixerDef = PHASESpatialMixerDefinition(");
5059
5232
  this.indentLevel++;
@@ -5063,7 +5236,9 @@ var init_IOSCompiler = __esm({
5063
5236
  this.emit("spatialMixerDef.distanceModelParameters = distanceModelParameters");
5064
5237
  } else {
5065
5238
  this.emit("let spatialPipelineDef = PHASESpatialPipeline(flags: [.directPathTransmission])!");
5066
- this.emit("spatialPipelineDef.entries[PHASESpatialCategory.directPath]!.sendLevel = Double(gain)");
5239
+ this.emit(
5240
+ "spatialPipelineDef.entries[PHASESpatialCategory.directPath]!.sendLevel = Double(gain)"
5241
+ );
5067
5242
  this.emit("");
5068
5243
  this.emit("let spatialMixerDef = PHASESpatialMixerDefinition(");
5069
5244
  this.indentLevel++;
@@ -5137,7 +5312,9 @@ var init_IOSCompiler = __esm({
5137
5312
  if (traits.has("audio_occlusion")) {
5138
5313
  this.emit("// MARK: - Audio Occlusion (audio_occlusion)");
5139
5314
  this.emit("");
5140
- this.emit("func updateOcclusionForSource(id: String, occluded: Bool, attenuationDb: Float = -12.0) {");
5315
+ this.emit(
5316
+ "func updateOcclusionForSource(id: String, occluded: Bool, attenuationDb: Float = -12.0) {"
5317
+ );
5141
5318
  this.indentLevel++;
5142
5319
  this.emit("guard let event = soundEvents[id] else { return }");
5143
5320
  this.emit("if occluded {");
@@ -5211,7 +5388,9 @@ var init_IOSCompiler = __esm({
5211
5388
  this.emit('Image(systemName: "speaker.wave.3")');
5212
5389
  this.emit("Text(source.id)");
5213
5390
  this.emit("Spacer()");
5214
- this.emit('Text(String(format: "(%.1f, %.1f, %.1f)", source.position.x, source.position.y, source.position.z))');
5391
+ this.emit(
5392
+ 'Text(String(format: "(%.1f, %.1f, %.1f)", source.position.x, source.position.y, source.position.z))'
5393
+ );
5215
5394
  this.indentLevel--;
5216
5395
  this.emit("}");
5217
5396
  this.indentLevel--;
@@ -5236,5 +5415,5 @@ var init_IOSCompiler = __esm({
5236
5415
  });
5237
5416
 
5238
5417
  export { IOSCompiler, IOSCompiler_exports, compileToIOS, init_IOSCompiler };
5239
- //# sourceMappingURL=chunk-6OQBLABR.js.map
5240
- //# sourceMappingURL=chunk-6OQBLABR.js.map
5418
+ //# sourceMappingURL=chunk-BWFJEM5A.js.map
5419
+ //# sourceMappingURL=chunk-BWFJEM5A.js.map