@holoscript/core 6.0.3 → 7.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 (244) hide show
  1. package/README.md +40 -40
  2. package/dist/codebase/index.d.ts +25 -0
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +4 -0
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/entries/interop.d.ts +9 -0
  7. package/dist/entries/scripting.d.ts +7 -0
  8. package/dist/index.d.ts +520 -19
  9. package/dist/paper-0c-spike/index.d.ts +29 -0
  10. package/dist/reconstruction/index.d.ts +78 -0
  11. package/dist/self-improvement/index.d.ts +0 -48
  12. package/dist/storage/index.d.ts +24 -0
  13. package/dist/tools/index.d.ts +33 -0
  14. package/dist/traitDocs/traitDocs.d.ts +69 -0
  15. package/dist/traits/index.d.ts +61 -0
  16. package/package.json +102 -19
  17. package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
  18. package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
  19. package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
  20. package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
  21. package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
  22. package/dist/USDZExporter-YA55ZS35.js +0 -707
  23. package/dist/chunk-26TLYBFD.js +0 -309
  24. package/dist/chunk-27LWW5FU.cjs +0 -410
  25. package/dist/chunk-2UX5LRAP.cjs +0 -833
  26. package/dist/chunk-32TWR3HE.js +0 -70
  27. package/dist/chunk-3FXV5S25.cjs +0 -633
  28. package/dist/chunk-3FYZOR7S.cjs +0 -69
  29. package/dist/chunk-3KEU5QYY.cjs +0 -175
  30. package/dist/chunk-4FCZDTD5.js +0 -610
  31. package/dist/chunk-4KJ2R7VP.cjs +0 -507
  32. package/dist/chunk-4SMUJFHL.js +0 -1213
  33. package/dist/chunk-54FHG2MX.js +0 -655
  34. package/dist/chunk-56IF4NTA.js +0 -56
  35. package/dist/chunk-5GLCTO44.js +0 -161
  36. package/dist/chunk-5TOFIR6L.js +0 -407
  37. package/dist/chunk-65RFOWZI.js +0 -765
  38. package/dist/chunk-6OQBLABR.js +0 -5240
  39. package/dist/chunk-6WNCRE6F.js +0 -126
  40. package/dist/chunk-74YCHHTE.js +0 -1872
  41. package/dist/chunk-7H5UNJZD.cjs +0 -1973
  42. package/dist/chunk-7KPI4EKH.cjs +0 -701
  43. package/dist/chunk-7LCYLPW2.cjs +0 -663
  44. package/dist/chunk-7N3JIJMT.js +0 -1395
  45. package/dist/chunk-7X2IEJIE.cjs +0 -2526
  46. package/dist/chunk-A6GO3DPZ.cjs +0 -1002
  47. package/dist/chunk-AC4BSHFV.js +0 -765
  48. package/dist/chunk-AIUXRS74.cjs +0 -3681
  49. package/dist/chunk-ARNKA274.cjs +0 -130
  50. package/dist/chunk-AW7WAELW.js +0 -975
  51. package/dist/chunk-BKIGPPVM.js +0 -629
  52. package/dist/chunk-BO2OKHIY.js +0 -6055
  53. package/dist/chunk-BU5ZAFMC.js +0 -115
  54. package/dist/chunk-BY3B7ZYV.cjs +0 -457
  55. package/dist/chunk-C2QHVHZF.js +0 -4066
  56. package/dist/chunk-C7BNX4XJ.js +0 -1043
  57. package/dist/chunk-CLYEIWA5.cjs +0 -408
  58. package/dist/chunk-CMYAWUX3.js +0 -4455
  59. package/dist/chunk-CN4NOESF.cjs +0 -416
  60. package/dist/chunk-CNVM7J3M.js +0 -883
  61. package/dist/chunk-CO2VM2DK.js +0 -1965
  62. package/dist/chunk-CQDOF3G7.cjs +0 -1404
  63. package/dist/chunk-DH5G2JUA.cjs +0 -614
  64. package/dist/chunk-DIEDKX5B.cjs +0 -660
  65. package/dist/chunk-DN7UFU63.cjs +0 -172
  66. package/dist/chunk-DXVCEFZB.js +0 -2027
  67. package/dist/chunk-EGIZHYJP.cjs +0 -85
  68. package/dist/chunk-EJA7G2C4.cjs +0 -428
  69. package/dist/chunk-ELLQPFAF.js +0 -830
  70. package/dist/chunk-EMO7HAKJ.cjs +0 -1875
  71. package/dist/chunk-ENV7K6XA.js +0 -282
  72. package/dist/chunk-EPWRXL6S.js +0 -2522
  73. package/dist/chunk-EUFLX2PI.js +0 -56956
  74. package/dist/chunk-F5LVGHNT.js +0 -449
  75. package/dist/chunk-FEFHPUEM.cjs +0 -6122
  76. package/dist/chunk-FF3Q7ADR.js +0 -380
  77. package/dist/chunk-GC3YU46J.js +0 -762
  78. package/dist/chunk-H6WMMLQK.cjs +0 -4492
  79. package/dist/chunk-H7XMORZI.js +0 -2731
  80. package/dist/chunk-HAN4V3PF.cjs +0 -2037
  81. package/dist/chunk-HBZYCASG.js +0 -4208
  82. package/dist/chunk-HF4OFY25.cjs +0 -4097
  83. package/dist/chunk-HHS6FMOU.cjs +0 -3813
  84. package/dist/chunk-HJJLD366.js +0 -1169
  85. package/dist/chunk-HKCVM6OK.cjs +0 -2237
  86. package/dist/chunk-HUFNKFA6.js +0 -698
  87. package/dist/chunk-I3XGTIHM.cjs +0 -1505
  88. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  89. package/dist/chunk-IHOUYQIA.js +0 -406
  90. package/dist/chunk-ILRBGFVD.cjs +0 -72
  91. package/dist/chunk-KDB6BUMB.js +0 -3666
  92. package/dist/chunk-KUJRR4FJ.js +0 -657
  93. package/dist/chunk-KYM4XRFG.js +0 -421
  94. package/dist/chunk-L3Z2HIWJ.cjs +0 -793
  95. package/dist/chunk-LBPEZQAF.js +0 -2232
  96. package/dist/chunk-LER4WXW5.cjs +0 -286
  97. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  98. package/dist/chunk-M6FU6S22.js +0 -2911
  99. package/dist/chunk-MWEFR6YQ.js +0 -1857
  100. package/dist/chunk-N5FTS757.cjs +0 -415
  101. package/dist/chunk-NCUHGRTZ.js +0 -752
  102. package/dist/chunk-NKRKT6V2.js +0 -69
  103. package/dist/chunk-NLPSZT4C.js +0 -630
  104. package/dist/chunk-NRUB55IT.cjs +0 -771
  105. package/dist/chunk-NTMZSDXM.cjs +0 -633
  106. package/dist/chunk-ODGMVILH.js +0 -9662
  107. package/dist/chunk-PBA6NXCT.cjs +0 -1216
  108. package/dist/chunk-PHENW4MQ.js +0 -65
  109. package/dist/chunk-PJMOXFPR.cjs +0 -1861
  110. package/dist/chunk-PLMYCCA4.js +0 -504
  111. package/dist/chunk-PPULB4GG.cjs +0 -9728
  112. package/dist/chunk-PQLGZKMC.cjs +0 -755
  113. package/dist/chunk-Q56TT7IL.js +0 -483
  114. package/dist/chunk-QHVVVN47.cjs +0 -2033
  115. package/dist/chunk-QWKUKVRE.js +0 -2026
  116. package/dist/chunk-RE3OKSYF.cjs +0 -424
  117. package/dist/chunk-RT7LJRSF.cjs +0 -57378
  118. package/dist/chunk-SPDELRRV.cjs +0 -319
  119. package/dist/chunk-SUCBB66F.js +0 -229
  120. package/dist/chunk-TSWTWZ42.cjs +0 -4214
  121. package/dist/chunk-UITWA6DV.cjs +0 -2829
  122. package/dist/chunk-UQW6SLM5.js +0 -172
  123. package/dist/chunk-V2ILLPHK.cjs +0 -237
  124. package/dist/chunk-V42NTCFH.js +0 -3645
  125. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  126. package/dist/chunk-VJVCD5T5.cjs +0 -769
  127. package/dist/chunk-VK5AXKO3.js +0 -746
  128. package/dist/chunk-VSXOIUCF.cjs +0 -473
  129. package/dist/chunk-VZNKJZTT.cjs +0 -749
  130. package/dist/chunk-W76ETJTI.js +0 -678
  131. package/dist/chunk-WFJIDI2N.cjs +0 -424
  132. package/dist/chunk-WN3YF33G.cjs +0 -118
  133. package/dist/chunk-WUXIRGZP.cjs +0 -2915
  134. package/dist/chunk-WYH4GVZ5.js +0 -1488
  135. package/dist/chunk-X4YVN7H3.cjs +0 -888
  136. package/dist/chunk-X67XRI2T.js +0 -410
  137. package/dist/chunk-XDXZM3ZP.cjs +0 -1046
  138. package/dist/chunk-XH7SE4HH.cjs +0 -72
  139. package/dist/chunk-XNMEH2BI.js +0 -126
  140. package/dist/chunk-XSF76QRU.js +0 -468
  141. package/dist/chunk-XSUZMPVQ.cjs +0 -682
  142. package/dist/chunk-XUILI4KB.cjs +0 -430
  143. package/dist/chunk-Y5MUAYTO.js +0 -167
  144. package/dist/chunk-Y7VK5TH3.cjs +0 -129
  145. package/dist/chunk-YCMQQQ5U.cjs +0 -5244
  146. package/dist/chunk-YYXH45E2.js +0 -426
  147. package/dist/chunk-ZGTGVSTZ.js +0 -422
  148. package/dist/chunk-ZL6VJ6SN.js +0 -421
  149. package/dist/cli/holoscript-runner.cjs +0 -2258
  150. package/dist/cli/holoscript-runner.js +0 -2233
  151. package/dist/codebase/index.cjs +0 -336
  152. package/dist/codebase/index.js +0 -331
  153. package/dist/compiler/agent-inference.cjs +0 -29
  154. package/dist/compiler/agent-inference.js +0 -6
  155. package/dist/compiler/android-xr.cjs +0 -20
  156. package/dist/compiler/android-xr.js +0 -10
  157. package/dist/compiler/android.cjs +0 -21
  158. package/dist/compiler/android.js +0 -11
  159. package/dist/compiler/ar.cjs +0 -21
  160. package/dist/compiler/ar.js +0 -9
  161. package/dist/compiler/babylon.cjs +0 -18
  162. package/dist/compiler/babylon.js +0 -12
  163. package/dist/compiler/coco.cjs +0 -27
  164. package/dist/compiler/coco.js +0 -4
  165. package/dist/compiler/domain-block-utils.cjs +0 -595
  166. package/dist/compiler/domain-block-utils.js +0 -9
  167. package/dist/compiler/dtdl.cjs +0 -25
  168. package/dist/compiler/dtdl.js +0 -9
  169. package/dist/compiler/gltf-pipeline.cjs +0 -39
  170. package/dist/compiler/gltf-pipeline.js +0 -4
  171. package/dist/compiler/godot.cjs +0 -16
  172. package/dist/compiler/godot.js +0 -10
  173. package/dist/compiler/incremental.cjs +0 -30
  174. package/dist/compiler/incremental.js +0 -5
  175. package/dist/compiler/index.cjs +0 -1522
  176. package/dist/compiler/index.js +0 -1321
  177. package/dist/compiler/ios.cjs +0 -21
  178. package/dist/compiler/ios.js +0 -11
  179. package/dist/compiler/multi-layer.cjs +0 -27
  180. package/dist/compiler/multi-layer.js +0 -12
  181. package/dist/compiler/nodetoy.cjs +0 -23
  182. package/dist/compiler/nodetoy.js +0 -4
  183. package/dist/compiler/openxr.cjs +0 -16
  184. package/dist/compiler/openxr.js +0 -10
  185. package/dist/compiler/playcanvas.cjs +0 -17
  186. package/dist/compiler/playcanvas.js +0 -11
  187. package/dist/compiler/r3f.cjs +0 -35
  188. package/dist/compiler/r3f.js +0 -13
  189. package/dist/compiler/remotion.cjs +0 -23
  190. package/dist/compiler/remotion.js +0 -4
  191. package/dist/compiler/reproducibility.cjs +0 -39
  192. package/dist/compiler/reproducibility.js +0 -4
  193. package/dist/compiler/sdf.cjs +0 -22
  194. package/dist/compiler/sdf.js +0 -10
  195. package/dist/compiler/semantic-scene.cjs +0 -31
  196. package/dist/compiler/semantic-scene.js +0 -4
  197. package/dist/compiler/state.cjs +0 -18
  198. package/dist/compiler/state.js +0 -8
  199. package/dist/compiler/trait-composition.cjs +0 -27
  200. package/dist/compiler/trait-composition.js +0 -6
  201. package/dist/compiler/unity.cjs +0 -16
  202. package/dist/compiler/unity.js +0 -10
  203. package/dist/compiler/unreal.cjs +0 -20
  204. package/dist/compiler/unreal.js +0 -10
  205. package/dist/compiler/urdf.cjs +0 -46
  206. package/dist/compiler/urdf.js +0 -10
  207. package/dist/compiler/usd-physics.cjs +0 -24
  208. package/dist/compiler/usd-physics.js +0 -7
  209. package/dist/compiler/visionos.cjs +0 -16
  210. package/dist/compiler/visionos.js +0 -10
  211. package/dist/compiler/vrchat.cjs +0 -20
  212. package/dist/compiler/vrchat.js +0 -10
  213. package/dist/compiler/vrr.cjs +0 -22
  214. package/dist/compiler/vrr.js +0 -10
  215. package/dist/compiler/wasm.cjs +0 -34
  216. package/dist/compiler/wasm.js +0 -10
  217. package/dist/compiler/webgpu.cjs +0 -16
  218. package/dist/compiler/webgpu.js +0 -10
  219. package/dist/debugger.cjs +0 -21
  220. package/dist/debugger.js +0 -8
  221. package/dist/entries/interop.cjs +0 -62
  222. package/dist/entries/interop.js +0 -5
  223. package/dist/entries/scripting.cjs +0 -67
  224. package/dist/entries/scripting.js +0 -10
  225. package/dist/index.cjs +0 -61703
  226. package/dist/index.js +0 -58652
  227. package/dist/math/vec3.cjs +0 -57
  228. package/dist/math/vec3.js +0 -4
  229. package/dist/parser.cjs +0 -26
  230. package/dist/parser.js +0 -9
  231. package/dist/playwright-7DTEQCBD.cjs +0 -98673
  232. package/dist/playwright-BIZXMLD2.js +0 -98660
  233. package/dist/post-quantum-JTTAAGO3.cjs +0 -6
  234. package/dist/post-quantum-RVPVDEPI.js +0 -4
  235. package/dist/runtime.cjs +0 -16
  236. package/dist/runtime.js +0 -7
  237. package/dist/storage/index.cjs +0 -37
  238. package/dist/storage/index.js +0 -4
  239. package/dist/traits/index.cjs +0 -14331
  240. package/dist/traits/index.js +0 -12126
  241. package/dist/type-checker.cjs +0 -18
  242. package/dist/type-checker.js +0 -5
  243. package/dist/wot/index.cjs +0 -29
  244. package/dist/wot/index.js +0 -4
@@ -1,1321 +0,0 @@
1
- export { NodeToyMapper, mapNodeToyToShader } from '../chunk-IHOUYQIA.js';
2
- export { createReproducibilityContext, parseReproducibilityFlags } from '../chunk-5GLCTO44.js';
3
- export { GLTF_PIPELINE_TOOLS, registerGLTFTools } from '../chunk-F5LVGHNT.js';
4
- import { init_Native2DCompiler, init_A2AAgentCardCompiler, A2AAgentCardCompiler_exports, init_NIRCompiler, NIRCompiler_exports, Native2DCompiler_exports } from '../chunk-BO2OKHIY.js';
5
- export { CompilerBridge, Native2DCompiler, NextJSCompiler, USDZPipeline, bestCategoryForTraits, compilePipelineSource, compilePipelineSourceToNode, compilePipelineSourceToPython, compilePipelineToNode, compilePipelineToPython, quickSafetyCheck, runSafetyPass, selectModality, selectModalityForAll } from '../chunk-BO2OKHIY.js';
6
- export { generateHullGeometry, generateMembraneGeometry, generateSplineGeometry } from '../chunk-HJJLD366.js';
7
- export { RemotionBridgeImpl as RemotionBridge } from '../chunk-YYXH45E2.js';
8
- export { SemanticSceneGraph } from '../chunk-ZGTGVSTZ.js';
9
- import '../chunk-CNVM7J3M.js';
10
- export { COCOExporterImpl as COCOExporter } from '../chunk-Q56TT7IL.js';
11
- import { init_WebGPUCompiler, WebGPUCompiler_exports } from '../chunk-KUJRR4FJ.js';
12
- export { WebGPUCompiler } from '../chunk-KUJRR4FJ.js';
13
- import { init_DTDLCompiler, DTDLCompiler_exports } from '../chunk-ZL6VJ6SN.js';
14
- export { DTDLCompiler } from '../chunk-ZL6VJ6SN.js';
15
- import { init_URDFCompiler, URDFCompiler_exports } from '../chunk-7N3JIJMT.js';
16
- export { URDFCompiler } from '../chunk-7N3JIJMT.js';
17
- export { USDPhysicsCompiler } from '../chunk-AC4BSHFV.js';
18
- import { init_SDFCompiler, SDFCompiler_exports } from '../chunk-PLMYCCA4.js';
19
- export { SDFCompiler } from '../chunk-PLMYCCA4.js';
20
- import { init_StateCompiler, StateCompiler_exports } from '../chunk-BU5ZAFMC.js';
21
- export { StateCompiler } from '../chunk-BU5ZAFMC.js';
22
- export { TraitCompositionCompiler } from '../chunk-Y5MUAYTO.js';
23
- export { IncrementalCompiler } from '../chunk-CO2VM2DK.js';
24
- import { init_GodotCompiler, GodotCompiler_exports } from '../chunk-NLPSZT4C.js';
25
- export { GodotCompiler } from '../chunk-NLPSZT4C.js';
26
- import { init_R3FCompiler, R3FCompiler_exports } from '../chunk-HBZYCASG.js';
27
- export { ENVIRONMENT_PRESETS, R3FCompiler } from '../chunk-HBZYCASG.js';
28
- import '../chunk-ODGMVILH.js';
29
- import { init_PlayCanvasCompiler, PlayCanvasCompiler_exports } from '../chunk-NCUHGRTZ.js';
30
- export { PlayCanvasCompiler } from '../chunk-NCUHGRTZ.js';
31
- import { init_AndroidCompiler, AndroidCompiler_exports } from '../chunk-M6FU6S22.js';
32
- export { AndroidCompiler } from '../chunk-M6FU6S22.js';
33
- import { init_AndroidXRCompiler, AndroidXRCompiler_exports } from '../chunk-MWEFR6YQ.js';
34
- export { AndroidXRCompiler } from '../chunk-MWEFR6YQ.js';
35
- import { init_IOSCompiler, IOSCompiler_exports } from '../chunk-6OQBLABR.js';
36
- export { IOSCompiler } from '../chunk-6OQBLABR.js';
37
- import { init_VisionOSCompiler, VisionOSCompiler_exports } from '../chunk-74YCHHTE.js';
38
- export { VisionOSCompiler } from '../chunk-74YCHHTE.js';
39
- import { init_WASMCompiler, WASMCompiler_exports } from '../chunk-65RFOWZI.js';
40
- export { WASMCompiler } from '../chunk-65RFOWZI.js';
41
- export { MultiLayerCompiler } from '../chunk-NKRKT6V2.js';
42
- import { init_VRRCompiler, VRRCompiler_exports } from '../chunk-VK5AXKO3.js';
43
- import { init_ARCompiler, ARCompiler_exports } from '../chunk-6WNCRE6F.js';
44
- export { ARCompiler } from '../chunk-6WNCRE6F.js';
45
- import { init_OpenXRCompiler, OpenXRCompiler_exports } from '../chunk-C7BNX4XJ.js';
46
- export { OpenXRCompiler } from '../chunk-C7BNX4XJ.js';
47
- import { init_VRChatCompiler, VRChatCompiler_exports } from '../chunk-4FCZDTD5.js';
48
- export { VRChatCompiler } from '../chunk-4FCZDTD5.js';
49
- import { init_BabylonCompiler, BabylonCompiler_exports } from '../chunk-ELLQPFAF.js';
50
- export { BabylonCompiler } from '../chunk-ELLQPFAF.js';
51
- import '../chunk-UQW6SLM5.js';
52
- import '../chunk-XSF76QRU.js';
53
- import { init_UnityCompiler, UnityCompiler_exports } from '../chunk-HUFNKFA6.js';
54
- export { UnityCompiler } from '../chunk-HUFNKFA6.js';
55
- import { init_UnrealCompiler, UnrealCompiler_exports } from '../chunk-W76ETJTI.js';
56
- import '../chunk-KDB6BUMB.js';
57
- import { init_CompilerBase, init_ANSNamespace, CompilerBase, ANSCapabilityPath, init_CompilerDocumentationGenerator } from '../chunk-QWKUKVRE.js';
58
- export { CompilerBase, CompilerDocumentationGenerator, UnauthorizedCompilerAccessError, createTestCompilerToken, isCapabilityTokenCredential } from '../chunk-QWKUKVRE.js';
59
- import '../chunk-V42NTCFH.js';
60
- import '../chunk-56IF4NTA.js';
61
- import '../chunk-26TLYBFD.js';
62
- import '../chunk-SUCBB66F.js';
63
- import '../chunk-XNMEH2BI.js';
64
- import { __export, __esm, __toCommonJS } from '../chunk-32TWR3HE.js';
65
-
66
- // src/compiler/NextJSAPICompiler.ts
67
- var NextJSAPICompiler_exports = {};
68
- __export(NextJSAPICompiler_exports, {
69
- compileAllToNextJSAPI: () => compileAllToNextJSAPI,
70
- compileToNextJSAPI: () => compileToNextJSAPI
71
- });
72
- function toScalar(val) {
73
- if (val === null || val === void 0) return void 0;
74
- if (typeof val === "string" || typeof val === "number") return val;
75
- if (typeof val === "object" && !Array.isArray(val) && "value" in val) {
76
- return toScalar(val.value);
77
- }
78
- return void 0;
79
- }
80
- function findRootTrait(composition, traitName) {
81
- if (!composition.traits) return null;
82
- const found = composition.traits.find((t) => t.name === traitName);
83
- return found ? found.config : null;
84
- }
85
- function buildPropMap(obj) {
86
- const map = /* @__PURE__ */ new Map();
87
- for (const prop of obj.properties) {
88
- const scalar = toScalar(prop.value);
89
- if (scalar !== void 0) map.set(prop.key, scalar);
90
- }
91
- return map;
92
- }
93
- function toApiRouteSegment(name, override) {
94
- if (override) {
95
- return override.replace(/^\/+api\/+/, "").replace(/^\/+/, "").replace(/\/+$/, "");
96
- }
97
- return name.replace(/API$/, "").replace(/Api$/, "").replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]{2,})([A-Z][a-z])/g, "$1-$2").toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "") || "api";
98
- }
99
- function parseMethod(raw) {
100
- if (raw === void 0) return void 0;
101
- const upper = String(raw).trim().toUpperCase();
102
- return VALID_METHODS.has(upper) ? upper : void 0;
103
- }
104
- function extractHandlers(composition) {
105
- const byMethod = /* @__PURE__ */ new Map();
106
- const rootHttp = findRootTrait(composition, "http");
107
- if (rootHttp) {
108
- const method = parseMethod(toScalar(rootHttp["method"]));
109
- if (method) {
110
- byMethod.set(method, {
111
- method,
112
- statusCode: Number(toScalar(rootHttp["statusCode"]) ?? toScalar(rootHttp["status"]) ?? 200),
113
- description: String(toScalar(rootHttp["description"]) ?? "")
114
- });
115
- }
116
- }
117
- for (const obj of composition.objects) {
118
- const hasHttpTrait = obj.traits.some((t) => t.name === "http");
119
- if (!hasHttpTrait) continue;
120
- const traitConfig = obj.traits.find((t) => t.name === "http")?.config ?? {};
121
- const props = buildPropMap(obj);
122
- const rawMethod = toScalar(traitConfig["method"]) ?? props.get("method");
123
- const method = parseMethod(rawMethod);
124
- if (!method) continue;
125
- const traitStatus = toScalar(
126
- traitConfig["statusCode"] ?? traitConfig["status"]
127
- );
128
- const propStatus = props.get("statusCode") ?? props.get("status");
129
- byMethod.set(method, {
130
- method,
131
- statusCode: Number(traitStatus ?? propStatus ?? 200),
132
- description: String(
133
- props.get("description") ?? toScalar(traitConfig["description"]) ?? obj.name ?? ""
134
- )
135
- });
136
- }
137
- return [...byMethod.values()];
138
- }
139
- function emitHandler(handler) {
140
- const { method, statusCode, description } = handler;
141
- const lines = [];
142
- const hasBody = BODY_METHODS.has(method);
143
- const isPassthrough = PASSTHROUGH_METHODS.has(method);
144
- if (description) {
145
- lines.push(`/** ${description} */`);
146
- }
147
- const param = isPassthrough ? "_request: Request" : "_request: NextRequest";
148
- lines.push(`export async function ${method}(${param}): Promise<NextResponse> {`);
149
- if (method === "HEAD") {
150
- lines.push(` return new NextResponse(null, { status: 200 });`);
151
- } else if (method === "DELETE") {
152
- const code = statusCode === 200 ? 204 : statusCode;
153
- lines.push(` return new NextResponse(null, { status: ${code} });`);
154
- } else if (hasBody) {
155
- lines.push(` let body: unknown;`);
156
- lines.push(` try {`);
157
- lines.push(` body = await _request.json();`);
158
- lines.push(` } catch {`);
159
- lines.push(` return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 });`);
160
- lines.push(` }`);
161
- lines.push(``);
162
- lines.push(` void body; // TODO: validate and process body`);
163
- lines.push(``);
164
- lines.push(` return NextResponse.json(`);
165
- lines.push(` { /* TODO: return response data */ },`);
166
- lines.push(` { status: ${statusCode} }`);
167
- lines.push(` );`);
168
- } else {
169
- lines.push(` return NextResponse.json(`);
170
- lines.push(` { /* TODO: return response data */ },`);
171
- lines.push(` { status: ${statusCode} }`);
172
- lines.push(` );`);
173
- }
174
- lines.push(`}`);
175
- return lines;
176
- }
177
- function compileToNextJSAPI(composition, options = {}) {
178
- let handlers = extractHandlers(composition);
179
- if (handlers.length === 0) {
180
- handlers = [
181
- {
182
- method: "GET",
183
- statusCode: 200,
184
- description: `${composition.name} API endpoint`
185
- }
186
- ];
187
- }
188
- const routeSegment = toApiRouteSegment(composition.name, options.apiRoute);
189
- const outputBase = options.outputDir ? options.outputDir.replace(/\/$/, "") : "api";
190
- const filePath = `${outputBase}/${routeSegment}/route.ts`;
191
- const lines = [];
192
- if (options.includeJsDoc !== false) {
193
- lines.push(`// @generated by HoloScript NextJSAPICompiler \u2014 DO NOT EDIT`);
194
- lines.push(`// Source composition: "${composition.name}"`);
195
- lines.push(`// Route: /${outputBase}/${routeSegment}`);
196
- lines.push(``);
197
- }
198
- const needsNextRequest = handlers.some((h) => !PASSTHROUGH_METHODS.has(h.method));
199
- if (needsNextRequest) {
200
- lines.push(`import { NextRequest, NextResponse } from 'next/server';`);
201
- } else {
202
- lines.push(`import { NextResponse } from 'next/server';`);
203
- }
204
- lines.push(``);
205
- for (let i = 0; i < handlers.length; i++) {
206
- lines.push(...emitHandler(handlers[i]));
207
- if (i < handlers.length - 1) {
208
- lines.push(``);
209
- }
210
- }
211
- return {
212
- path: filePath,
213
- code: lines.join("\n").trimEnd() + "\n"
214
- };
215
- }
216
- function compileAllToNextJSAPI(compositions, options = {}) {
217
- return compositions.map(({ composition }) => compileToNextJSAPI(composition, options));
218
- }
219
- var VALID_METHODS, BODY_METHODS, PASSTHROUGH_METHODS;
220
- var init_NextJSAPICompiler = __esm({
221
- "src/compiler/NextJSAPICompiler.ts"() {
222
- VALID_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
223
- BODY_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH"]);
224
- PASSTHROUGH_METHODS = /* @__PURE__ */ new Set(["HEAD", "DELETE"]);
225
- }
226
- });
227
-
228
- // src/compiler/registerBuiltinDialects.ts
229
- var registerBuiltinDialects_exports = {};
230
- __export(registerBuiltinDialects_exports, {
231
- registerBuiltinDialects: () => registerBuiltinDialects
232
- });
233
- function registerBuiltinDialects() {
234
- if (_registered) return;
235
- _registered = true;
236
- const descriptors = [
237
- // ── Game Engines ──────────────────────────────────────────────────────
238
- {
239
- name: "unity",
240
- domain: "gamedev",
241
- description: "Compiles to Unity C# MonoBehaviours",
242
- supportedTraits: [
243
- "physics",
244
- "collidable",
245
- "grabbable",
246
- "throwable",
247
- "audio",
248
- "spatial_audio",
249
- "animation",
250
- "particles",
251
- "material",
252
- "ui",
253
- "networked",
254
- "behavior_tree",
255
- "navmesh",
256
- "lod"
257
- ],
258
- riskTier: "standard",
259
- factory: (opts) => {
260
- const { UnityCompiler: UnityCompiler2 } = (init_UnityCompiler(), __toCommonJS(UnityCompiler_exports));
261
- return new UnityCompiler2(opts);
262
- },
263
- outputExtensions: [".cs"]
264
- },
265
- {
266
- name: "unreal",
267
- domain: "gamedev",
268
- description: "Compiles to Unreal Engine C++ actors",
269
- supportedTraits: [
270
- "physics",
271
- "collidable",
272
- "grabbable",
273
- "audio",
274
- "animation",
275
- "particles",
276
- "material",
277
- "niagara",
278
- "landscape",
279
- "behavior_tree",
280
- "navmesh",
281
- "lod"
282
- ],
283
- riskTier: "standard",
284
- factory: (opts) => {
285
- const { UnrealCompiler } = (init_UnrealCompiler(), __toCommonJS(UnrealCompiler_exports));
286
- return new UnrealCompiler(opts);
287
- },
288
- outputExtensions: [".cpp", ".h"]
289
- },
290
- {
291
- name: "godot",
292
- domain: "gamedev",
293
- description: "Compiles to Godot GDScript nodes",
294
- supportedTraits: [
295
- "physics",
296
- "collidable",
297
- "grabbable",
298
- "audio",
299
- "animation",
300
- "particles",
301
- "material",
302
- "behavior_tree",
303
- "navmesh"
304
- ],
305
- riskTier: "standard",
306
- factory: (opts) => {
307
- const { GodotCompiler: GodotCompiler2 } = (init_GodotCompiler(), __toCommonJS(GodotCompiler_exports));
308
- return new GodotCompiler2(opts);
309
- },
310
- outputExtensions: [".gd", ".tscn"]
311
- },
312
- // ── Web 3D ────────────────────────────────────────────────────────────
313
- {
314
- name: "r3f",
315
- domain: "web3d",
316
- description: "Compiles to React Three Fiber JSX components",
317
- supportedTraits: [
318
- "physics",
319
- "collidable",
320
- "grabbable",
321
- "audio",
322
- "spatial_audio",
323
- "animation",
324
- "particles",
325
- "material",
326
- "ui",
327
- "behavior_tree",
328
- "lod",
329
- "vr_only",
330
- "ar_only"
331
- ],
332
- riskTier: "standard",
333
- factory: (opts) => {
334
- const { R3FCompiler: R3FCompiler2 } = (init_R3FCompiler(), __toCommonJS(R3FCompiler_exports));
335
- return new R3FCompiler2(opts);
336
- },
337
- outputExtensions: [".tsx", ".jsx"]
338
- },
339
- {
340
- name: "babylon",
341
- domain: "web3d",
342
- description: "Compiles to Babylon.js scene code",
343
- supportedTraits: [
344
- "physics",
345
- "collidable",
346
- "audio",
347
- "animation",
348
- "particles",
349
- "material",
350
- "behavior_tree"
351
- ],
352
- riskTier: "standard",
353
- factory: (opts) => {
354
- const { BabylonCompiler: BabylonCompiler2 } = (init_BabylonCompiler(), __toCommonJS(BabylonCompiler_exports));
355
- return new BabylonCompiler2(opts);
356
- },
357
- outputExtensions: [".ts", ".js"]
358
- },
359
- {
360
- name: "playcanvas",
361
- domain: "web3d",
362
- description: "Compiles to PlayCanvas engine scripts",
363
- supportedTraits: ["physics", "collidable", "audio", "animation", "material"],
364
- riskTier: "standard",
365
- factory: (opts) => {
366
- const { PlayCanvasCompiler: PlayCanvasCompiler2 } = (init_PlayCanvasCompiler(), __toCommonJS(PlayCanvasCompiler_exports));
367
- return new PlayCanvasCompiler2(opts);
368
- },
369
- outputExtensions: [".js"]
370
- },
371
- // ── VR/XR ─────────────────────────────────────────────────────────────
372
- {
373
- name: "openxr",
374
- domain: "xr",
375
- description: "Compiles to OpenXR C++ application layer",
376
- supportedTraits: [
377
- "physics",
378
- "hand_tracking",
379
- "spatial_anchor",
380
- "input",
381
- "collidable",
382
- "grabbable"
383
- ],
384
- riskTier: "standard",
385
- factory: (opts) => {
386
- const { OpenXRCompiler: OpenXRCompiler2 } = (init_OpenXRCompiler(), __toCommonJS(OpenXRCompiler_exports));
387
- return new OpenXRCompiler2(opts);
388
- },
389
- outputExtensions: [".cpp", ".h"]
390
- },
391
- {
392
- name: "vrchat",
393
- domain: "social-vr",
394
- description: "Compiles to VRChat UdonSharp scripts",
395
- supportedTraits: [
396
- "physics",
397
- "collidable",
398
- "grabbable",
399
- "audio",
400
- "animation",
401
- "networked",
402
- "ui",
403
- "interaction"
404
- ],
405
- riskTier: "standard",
406
- factory: (opts) => {
407
- const { VRChatCompiler: VRChatCompiler2 } = (init_VRChatCompiler(), __toCommonJS(VRChatCompiler_exports));
408
- return new VRChatCompiler2(opts);
409
- },
410
- outputExtensions: [".cs"]
411
- },
412
- {
413
- name: "visionos",
414
- domain: "xr",
415
- description: "Compiles to visionOS RealityKit Swift",
416
- supportedTraits: [
417
- "physics",
418
- "hand_tracking",
419
- "spatial_anchor",
420
- "animation",
421
- "material",
422
- "collidable"
423
- ],
424
- riskTier: "standard",
425
- factory: (opts) => {
426
- const { VisionOSCompiler: VisionOSCompiler2 } = (init_VisionOSCompiler(), __toCommonJS(VisionOSCompiler_exports));
427
- return new VisionOSCompiler2(opts);
428
- },
429
- outputExtensions: [".swift"]
430
- },
431
- {
432
- name: "android-xr",
433
- domain: "xr",
434
- description: "Compiles to Android XR OpenXR Kotlin",
435
- supportedTraits: ["physics", "hand_tracking", "spatial_anchor", "input", "collidable"],
436
- riskTier: "standard",
437
- factory: (opts) => {
438
- const { AndroidXRCompiler: AndroidXRCompiler2 } = (init_AndroidXRCompiler(), __toCommonJS(AndroidXRCompiler_exports));
439
- return new AndroidXRCompiler2(opts);
440
- },
441
- outputExtensions: [".kt"]
442
- },
443
- // ── Mobile ────────────────────────────────────────────────────────────
444
- {
445
- name: "ios",
446
- domain: "mobile",
447
- description: "Compiles to iOS ARKit Swift",
448
- supportedTraits: ["physics", "ar_anchor", "animation", "material", "collidable"],
449
- riskTier: "standard",
450
- factory: (opts) => {
451
- const { IOSCompiler: IOSCompiler2 } = (init_IOSCompiler(), __toCommonJS(IOSCompiler_exports));
452
- return new IOSCompiler2(opts);
453
- },
454
- outputExtensions: [".swift"]
455
- },
456
- {
457
- name: "android",
458
- domain: "mobile",
459
- description: "Compiles to Android ARCore Kotlin",
460
- supportedTraits: ["physics", "ar_anchor", "animation", "material", "collidable"],
461
- riskTier: "standard",
462
- factory: (opts) => {
463
- const { AndroidCompiler: AndroidCompiler2 } = (init_AndroidCompiler(), __toCommonJS(AndroidCompiler_exports));
464
- return new AndroidCompiler2(opts);
465
- },
466
- outputExtensions: [".kt"]
467
- },
468
- {
469
- name: "ar",
470
- domain: "mobile",
471
- description: "Compiles to generic AR platform code",
472
- supportedTraits: ["physics", "ar_anchor", "spatial_anchor", "collidable", "material"],
473
- riskTier: "standard",
474
- factory: (opts) => {
475
- const { ARCompiler: ARCompiler2 } = (init_ARCompiler(), __toCommonJS(ARCompiler_exports));
476
- return new ARCompiler2(opts);
477
- },
478
- outputExtensions: [".ts"]
479
- },
480
- // ── Low-level ─────────────────────────────────────────────────────────
481
- {
482
- name: "wasm",
483
- domain: "runtime",
484
- description: "Compiles to WebAssembly modules",
485
- supportedTraits: ["physics", "animation", "audio"],
486
- riskTier: "high",
487
- factory: (opts) => {
488
- const { WASMCompiler: WASMCompiler2 } = (init_WASMCompiler(), __toCommonJS(WASMCompiler_exports));
489
- return new WASMCompiler2(opts);
490
- },
491
- outputExtensions: [".wasm", ".js"]
492
- },
493
- {
494
- name: "webgpu",
495
- domain: "shader",
496
- description: "Compiles to WebGPU compute shaders (WGSL)",
497
- supportedTraits: ["physics", "particles", "fluid", "material", "compute"],
498
- riskTier: "standard",
499
- factory: (opts) => {
500
- const { WebGPUCompiler: WebGPUCompiler2 } = (init_WebGPUCompiler(), __toCommonJS(WebGPUCompiler_exports));
501
- return new WebGPUCompiler2(opts);
502
- },
503
- outputExtensions: [".wgsl", ".ts"]
504
- },
505
- // ── Robotics & IoT ───────────────────────────────────────────────────
506
- {
507
- name: "urdf",
508
- domain: "robotics",
509
- description: "Compiles to URDF robot descriptions",
510
- supportedTraits: ["joint", "actuator", "sensor", "collider", "end_effector"],
511
- riskTier: "standard",
512
- factory: (opts) => {
513
- const { URDFCompiler: URDFCompiler2 } = (init_URDFCompiler(), __toCommonJS(URDFCompiler_exports));
514
- return new URDFCompiler2(opts);
515
- },
516
- outputExtensions: [".urdf"]
517
- },
518
- {
519
- name: "sdf",
520
- domain: "robotics",
521
- description: "Compiles to SDF simulation descriptions (Gazebo)",
522
- supportedTraits: ["joint", "actuator", "sensor", "collider", "physics", "environment"],
523
- riskTier: "standard",
524
- factory: (opts) => {
525
- const { SDFCompiler: SDFCompiler2 } = (init_SDFCompiler(), __toCommonJS(SDFCompiler_exports));
526
- return new SDFCompiler2(opts);
527
- },
528
- outputExtensions: [".sdf"]
529
- },
530
- {
531
- name: "dtdl",
532
- domain: "iot",
533
- description: "Compiles to DTDL digital twin definitions",
534
- supportedTraits: ["sensor", "telemetry", "property", "command", "relationship"],
535
- riskTier: "standard",
536
- factory: (opts) => {
537
- const { DTDLCompiler: DTDLCompiler2 } = (init_DTDLCompiler(), __toCommonJS(DTDLCompiler_exports));
538
- return new DTDLCompiler2(opts);
539
- },
540
- outputExtensions: [".json"]
541
- },
542
- // ── Specialized ───────────────────────────────────────────────────────
543
- {
544
- name: "state",
545
- domain: "meta",
546
- description: "Extracts reactive state descriptors from compositions",
547
- supportedTraits: ["state", "bind", "reactive"],
548
- riskTier: "standard",
549
- factory: (opts) => {
550
- const { StateCompiler: StateCompiler2 } = (init_StateCompiler(), __toCommonJS(StateCompiler_exports));
551
- return new StateCompiler2(opts);
552
- },
553
- outputExtensions: [".json"]
554
- },
555
- {
556
- name: "a2a-agent-card",
557
- domain: "ai",
558
- description: "Generates A2A Agent Card from composition metadata",
559
- supportedTraits: ["agent", "skill", "capability"],
560
- riskTier: "standard",
561
- factory: (opts) => {
562
- const { A2AAgentCardCompiler } = (init_A2AAgentCardCompiler(), __toCommonJS(A2AAgentCardCompiler_exports));
563
- return new A2AAgentCardCompiler(opts);
564
- },
565
- outputExtensions: [".json"]
566
- },
567
- {
568
- name: "nir",
569
- domain: "neuromorphic",
570
- description: "Compiles to Neuromorphic Intermediate Representation",
571
- supportedTraits: ["snn", "neuron", "synapse", "spike_train"],
572
- riskTier: "high",
573
- factory: (opts) => {
574
- const { NIRCompiler } = (init_NIRCompiler(), __toCommonJS(NIRCompiler_exports));
575
- return new NIRCompiler(opts);
576
- },
577
- outputExtensions: [".json"]
578
- },
579
- {
580
- name: "vrr",
581
- domain: "xr",
582
- description: "Compiles with Variable Rate Rendering optimizations",
583
- supportedTraits: ["physics", "material", "lod", "rendering"],
584
- riskTier: "standard",
585
- factory: (opts) => {
586
- const { VRRCompiler } = (init_VRRCompiler(), __toCommonJS(VRRCompiler_exports));
587
- return new VRRCompiler(opts);
588
- },
589
- outputExtensions: [".ts"]
590
- },
591
- {
592
- name: "native-2d",
593
- domain: "web3d",
594
- description: "Compiles to native 2D HTML/CSS/Canvas applications",
595
- supportedTraits: ["layout", "style", "animation", "interaction"],
596
- riskTier: "standard",
597
- factory: (opts) => {
598
- const { Native2DCompiler: Native2DCompiler2 } = (init_Native2DCompiler(), __toCommonJS(Native2DCompiler_exports));
599
- return new Native2DCompiler2(opts);
600
- },
601
- outputExtensions: [".tsx", ".html"]
602
- },
603
- // ── Next.js API Routes ────────────────────────────────────────────────
604
- {
605
- name: "nextjs-api",
606
- domain: "web",
607
- description: "Compiles @http traits to Next.js App Router API route handlers (route.ts)",
608
- supportedTraits: ["http", "handler", "middleware", "auth", "rate_limit", "cors"],
609
- riskTier: "standard",
610
- factory: () => {
611
- const { compileToNextJSAPI: compileToNextJSAPI2 } = (init_NextJSAPICompiler(), __toCommonJS(NextJSAPICompiler_exports));
612
- return {
613
- compile: (composition, _token) => compileToNextJSAPI2(composition)
614
- };
615
- },
616
- outputExtensions: [".ts"],
617
- experimental: true
618
- },
619
- // ── v6 Universal Service ──────────────────────────────────────────────
620
- {
621
- name: "node-service",
622
- domain: "service",
623
- description: "Compiles @service traits to Express/Fastify applications",
624
- supportedTraits: [
625
- "service",
626
- "endpoint",
627
- "route",
628
- "handler",
629
- "middleware",
630
- "cors_policy",
631
- "rate_limiter",
632
- "health_endpoint"
633
- ],
634
- riskTier: "standard",
635
- factory: (opts) => {
636
- const { NodeServiceCompiler: NodeServiceCompiler2 } = (init_NodeServiceCompiler(), __toCommonJS(NodeServiceCompiler_exports));
637
- return new NodeServiceCompiler2(opts);
638
- },
639
- outputExtensions: [".ts", ".js"],
640
- experimental: true
641
- }
642
- ];
643
- for (const desc of descriptors) {
644
- if (!DialectRegistry.has(desc.name)) {
645
- DialectRegistry.register(desc);
646
- }
647
- }
648
- }
649
- var _registered;
650
- var init_registerBuiltinDialects = __esm({
651
- "src/compiler/registerBuiltinDialects.ts"() {
652
- init_DialectRegistry();
653
- _registered = false;
654
- }
655
- });
656
-
657
- // src/compiler/DialectRegistry.ts
658
- function ensureDialectsBooted() {
659
- if (_autoBooted) return;
660
- _autoBooted = true;
661
- try {
662
- const { registerBuiltinDialects: registerBuiltinDialects2 } = (init_registerBuiltinDialects(), __toCommonJS(registerBuiltinDialects_exports));
663
- registerBuiltinDialects2();
664
- } catch {
665
- }
666
- }
667
- var DialectRegistryImpl, DialectRegistry, _autoBooted;
668
- var init_DialectRegistry = __esm({
669
- "src/compiler/DialectRegistry.ts"() {
670
- DialectRegistryImpl = class {
671
- constructor() {
672
- this.dialects = /* @__PURE__ */ new Map();
673
- }
674
- /**
675
- * Register a new compiler dialect.
676
- * @throws Error if a dialect with the same name already exists
677
- */
678
- register(descriptor) {
679
- if (this.dialects.has(descriptor.name)) {
680
- throw new Error(
681
- `Dialect "${descriptor.name}" is already registered. Use DialectRegistry.override() to replace an existing dialect.`
682
- );
683
- }
684
- if (!descriptor.ansPath) {
685
- descriptor.ansPath = `/compile/${descriptor.domain}/${descriptor.name}`;
686
- }
687
- this.dialects.set(descriptor.name, descriptor);
688
- }
689
- /**
690
- * Override an existing dialect registration.
691
- */
692
- override(descriptor) {
693
- if (!descriptor.ansPath) {
694
- descriptor.ansPath = `/compile/${descriptor.domain}/${descriptor.name}`;
695
- }
696
- this.dialects.set(descriptor.name, descriptor);
697
- }
698
- /**
699
- * Unregister a dialect.
700
- */
701
- unregister(name) {
702
- return this.dialects.delete(name);
703
- }
704
- /**
705
- * Check if a dialect is registered.
706
- */
707
- has(name) {
708
- return this.dialects.has(name);
709
- }
710
- /**
711
- * Get dialect info (without factory, safe for discovery).
712
- */
713
- get(name) {
714
- const desc = this.dialects.get(name);
715
- if (!desc) return void 0;
716
- return {
717
- name: desc.name,
718
- domain: desc.domain,
719
- description: desc.description,
720
- supportedTraits: desc.supportedTraits,
721
- riskTier: desc.riskTier,
722
- ansPath: desc.ansPath || `/compile/${desc.domain}/${desc.name}`,
723
- outputExtensions: desc.outputExtensions || [],
724
- experimental: desc.experimental ?? false
725
- };
726
- }
727
- /**
728
- * Create a compiler instance from a registered dialect.
729
- * @throws Error if dialect not found
730
- */
731
- create(name, options) {
732
- const desc = this.dialects.get(name);
733
- if (!desc) {
734
- const available = [...this.dialects.keys()].join(", ");
735
- throw new Error(`Unknown dialect "${name}". Available: ${available}`);
736
- }
737
- return desc.factory(options);
738
- }
739
- /**
740
- * List all registered dialects.
741
- */
742
- list() {
743
- return [...this.dialects.values()].map((desc) => ({
744
- name: desc.name,
745
- domain: desc.domain,
746
- description: desc.description,
747
- supportedTraits: desc.supportedTraits,
748
- riskTier: desc.riskTier,
749
- ansPath: desc.ansPath || `/compile/${desc.domain}/${desc.name}`,
750
- outputExtensions: desc.outputExtensions || [],
751
- experimental: desc.experimental ?? false
752
- }));
753
- }
754
- /**
755
- * List dialects filtered by domain.
756
- */
757
- listByDomain(domain) {
758
- return this.list().filter((d) => d.domain === domain);
759
- }
760
- /**
761
- * Find dialects that support a specific trait.
762
- */
763
- findByTrait(traitName) {
764
- return this.list().filter((d) => d.supportedTraits.includes(traitName));
765
- }
766
- /**
767
- * Get all registered dialect names.
768
- */
769
- names() {
770
- return [...this.dialects.keys()];
771
- }
772
- /**
773
- * Get count of registered dialects.
774
- */
775
- get size() {
776
- return this.dialects.size;
777
- }
778
- /**
779
- * Execute a progressive lowering pipeline for a dialect.
780
- * Runs all registered lowering passes in priority order.
781
- */
782
- executeLoweringPipeline(dialectName, composition, options = {}) {
783
- const desc = this.dialects.get(dialectName);
784
- if (!desc) {
785
- throw new Error(`Unknown dialect "${dialectName}"`);
786
- }
787
- const passes = [...desc.loweringPasses || []].sort((a, b) => a.priority - b.priority);
788
- if (passes.length === 0) {
789
- throw new Error(
790
- `Dialect "${dialectName}" has no lowering passes. Use create() for direct compilation.`
791
- );
792
- }
793
- const context = {
794
- target: dialectName,
795
- options,
796
- previousPasses: /* @__PURE__ */ new Map(),
797
- diagnostics: []
798
- };
799
- let lastResult = { output: "" };
800
- for (const pass of passes) {
801
- lastResult = pass.lower(composition, context);
802
- context.previousPasses.set(pass.name, lastResult);
803
- if (lastResult.diagnostics) {
804
- context.diagnostics.push(...lastResult.diagnostics);
805
- }
806
- const hasError = lastResult.diagnostics?.some((d) => d.level === "error");
807
- if (hasError) break;
808
- }
809
- lastResult.diagnostics = context.diagnostics;
810
- return lastResult;
811
- }
812
- };
813
- DialectRegistry = new DialectRegistryImpl();
814
- _autoBooted = false;
815
- }
816
- });
817
-
818
- // src/compiler/NodeServiceCompiler.ts
819
- var NodeServiceCompiler_exports = {};
820
- __export(NodeServiceCompiler_exports, {
821
- NodeServiceCompiler: () => NodeServiceCompiler
822
- });
823
- var NodeServiceCompiler;
824
- var init_NodeServiceCompiler = __esm({
825
- "src/compiler/NodeServiceCompiler.ts"() {
826
- init_CompilerBase();
827
- init_ANSNamespace();
828
- init_DialectRegistry();
829
- NodeServiceCompiler = class extends CompilerBase {
830
- constructor(options = {}) {
831
- super();
832
- this.compilerName = "NodeServiceCompiler";
833
- this.services = [];
834
- this.options = {
835
- framework: options.framework ?? "express",
836
- port: options.port ?? 3e3,
837
- apiPrefix: options.apiPrefix ?? "/api",
838
- typescript: options.typescript ?? true,
839
- nodeVersion: options.nodeVersion ?? "20",
840
- includeDocker: options.includeDocker ?? false
841
- };
842
- }
843
- getRequiredCapability() {
844
- return ANSCapabilityPath.NODE_SERVICE;
845
- }
846
- compile(composition, agentToken, outputPath) {
847
- this.validateCompilerAccess(agentToken, outputPath);
848
- this.services = [];
849
- this.extractServices(composition);
850
- const output = {};
851
- output[this.ext("index")] = this.emitEntryPoint();
852
- for (const service of this.services) {
853
- output[this.ext(`routes/${this.toFileName(service.name)}`)] = this.emitRouteModule(service);
854
- }
855
- const allMiddleware = this.collectMiddleware();
856
- if (allMiddleware.length > 0) {
857
- output[this.ext("middleware/index")] = this.emitMiddlewareIndex(allMiddleware);
858
- }
859
- output["package.json"] = this.emitPackageJson(composition.name);
860
- if (this.options.typescript) {
861
- output["tsconfig.json"] = this.emitTsConfig();
862
- }
863
- if (this.options.includeDocker) {
864
- output["Dockerfile"] = this.emitDockerfile();
865
- }
866
- return output;
867
- }
868
- // ── Extraction ─────────────────────────────────────────────────────────
869
- extractServices(composition) {
870
- if (composition.domainBlocks) {
871
- for (const block of composition.domainBlocks) {
872
- if (this.isServiceBlock(block)) {
873
- this.services.push(this.parseServiceBlock(block));
874
- }
875
- }
876
- }
877
- for (const obj of composition.objects) {
878
- if (this.hasServiceTraits(obj)) {
879
- this.services.push(this.parseServiceObject(obj));
880
- }
881
- }
882
- if (this.services.length === 0) {
883
- this.services.push({
884
- name: composition.name || "App",
885
- routes: [],
886
- middleware: [],
887
- port: this.options.port
888
- });
889
- }
890
- }
891
- isServiceBlock(block) {
892
- return block.keyword === "service" || block.keyword === "endpoint" || block.keyword === "gateway" || block.keyword === "handler";
893
- }
894
- hasServiceTraits(obj) {
895
- if (!obj.traits) return false;
896
- const serviceTraits = ["service", "endpoint", "http", "handler", "route"];
897
- return obj.traits.some((t) => serviceTraits.includes(t.name));
898
- }
899
- parseServiceBlock(block) {
900
- const service = {
901
- name: block.name,
902
- routes: [],
903
- middleware: [],
904
- port: this.resolveNumber(block.properties["port"]) ?? this.options.port
905
- };
906
- if (block.traits) {
907
- service.middleware = this.extractMiddlewareFromTraits(block.traits);
908
- }
909
- if (block.children) {
910
- for (const child of block.children) {
911
- const route = this.extractRoute(child, block.name);
912
- if (route) service.routes.push(route);
913
- }
914
- }
915
- const inlineRoute = this.extractInlineRoute(block);
916
- if (inlineRoute) service.routes.push(inlineRoute);
917
- return service;
918
- }
919
- parseServiceObject(obj) {
920
- const service = {
921
- name: obj.name,
922
- routes: [],
923
- middleware: [],
924
- port: this.options.port
925
- };
926
- if (obj.traits) {
927
- service.middleware = this.extractMiddlewareFromTraits(obj.traits.map((t) => t.name));
928
- }
929
- const route = this.extractRoute(obj, obj.name);
930
- if (route) service.routes.push(route);
931
- return service;
932
- }
933
- extractRoute(obj, serviceName) {
934
- const propMap = this.objectPropsToMap(obj.properties);
935
- const traits = (obj.traits || []).map((t) => t.name);
936
- const method = this.resolveString(propMap.get("method"))?.toUpperCase() || "GET";
937
- const path = this.resolveString(propMap.get("path")) || `/${this.toKebab(obj.name)}`;
938
- const handlerName = this.resolveString(propMap.get("handler")) || this.toCamelCase(obj.name);
939
- const hasHttpInfo = propMap.has("method") || propMap.has("path") || traits.includes("http") || traits.includes("route");
940
- if (!hasHttpInfo) return null;
941
- return {
942
- method,
943
- path,
944
- handlerName,
945
- middleware: this.extractMiddlewareFromTraits(traits),
946
- serviceName
947
- };
948
- }
949
- extractInlineRoute(block) {
950
- const props = block.properties;
951
- if (!props["method"] && !props["path"]) return null;
952
- return {
953
- method: this.resolveString(props["method"])?.toUpperCase() || "GET",
954
- path: this.resolveString(props["path"]) || `/${this.toKebab(block.name)}`,
955
- handlerName: this.resolveString(props["handler"]) || this.toCamelCase(block.name),
956
- middleware: [],
957
- serviceName: block.name
958
- };
959
- }
960
- extractMiddlewareFromTraits(traits) {
961
- const mw = [];
962
- for (const t of traits) {
963
- if (t === "middleware" || t === "auth" || t === "rate_limit" || t === "cors" || t === "validation") {
964
- mw.push(t);
965
- }
966
- }
967
- return mw;
968
- }
969
- collectMiddleware() {
970
- const set = /* @__PURE__ */ new Set();
971
- for (const service of this.services) {
972
- for (const mw of service.middleware) set.add(mw);
973
- for (const route of service.routes) {
974
- for (const mw of route.middleware) set.add(mw);
975
- }
976
- }
977
- return [...set];
978
- }
979
- // ── Code Emission ──────────────────────────────────────────────────────
980
- emitEntryPoint() {
981
- const isExpress = this.options.framework === "express";
982
- const lines = [];
983
- lines.push(`/**`);
984
- lines.push(` * Auto-generated by HoloScript NodeServiceCompiler v0.1.0`);
985
- lines.push(` * Framework: ${this.options.framework}`);
986
- lines.push(` */`);
987
- lines.push("");
988
- if (isExpress) {
989
- lines.push(`import express from 'express';`);
990
- for (const service of this.services) {
991
- const importName = `${this.toCamelCase(service.name)}Routes`;
992
- lines.push(`import { ${importName} } from './routes/${this.toFileName(service.name)}';`);
993
- }
994
- lines.push("");
995
- lines.push(`const app = express();`);
996
- lines.push(`app.use(express.json());`);
997
- lines.push(`app.use(express.urlencoded({ extended: true }));`);
998
- lines.push("");
999
- for (const service of this.services) {
1000
- const importName = `${this.toCamelCase(service.name)}Routes`;
1001
- lines.push(
1002
- `app.use('${this.escapeStringValue(this.options.apiPrefix, "TypeScript")}', ${importName});`
1003
- );
1004
- }
1005
- lines.push("");
1006
- lines.push(`const PORT = process.env['PORT'] || ${this.options.port};`);
1007
- lines.push(`app.listen(PORT, () => {`);
1008
- lines.push(` console.log(\`Server running on port \${PORT}\`);`);
1009
- lines.push(`});`);
1010
- lines.push("");
1011
- lines.push(`export { app };`);
1012
- } else {
1013
- lines.push(`import Fastify from 'fastify';`);
1014
- for (const service of this.services) {
1015
- const importName = `${this.toCamelCase(service.name)}Routes`;
1016
- lines.push(`import { ${importName} } from './routes/${this.toFileName(service.name)}';`);
1017
- }
1018
- lines.push("");
1019
- lines.push(`const app = Fastify({ logger: true });`);
1020
- lines.push("");
1021
- for (const service of this.services) {
1022
- const importName = `${this.toCamelCase(service.name)}Routes`;
1023
- lines.push(
1024
- `app.register(${importName}, { prefix: '${this.escapeStringValue(this.options.apiPrefix, "TypeScript")}' });`
1025
- );
1026
- }
1027
- lines.push("");
1028
- lines.push(`const PORT = Number(process.env['PORT']) || ${this.options.port};`);
1029
- lines.push(`app.listen({ port: PORT, host: '0.0.0.0' }).then((address) => {`);
1030
- lines.push(` console.log(\`Server running at \${address}\`);`);
1031
- lines.push(`});`);
1032
- lines.push("");
1033
- lines.push(`export { app };`);
1034
- }
1035
- return lines.join("\n");
1036
- }
1037
- emitRouteModule(service) {
1038
- const isExpress = this.options.framework === "express";
1039
- const lines = [];
1040
- const routerName = `${this.toCamelCase(service.name)}Routes`;
1041
- lines.push(`/**`);
1042
- lines.push(` * Routes for ${service.name}`);
1043
- lines.push(` * Auto-generated by HoloScript NodeServiceCompiler`);
1044
- lines.push(` */`);
1045
- lines.push("");
1046
- if (isExpress) {
1047
- lines.push(`import { Router } from 'express';`);
1048
- if (this.options.typescript) {
1049
- lines.push(`import type { Request, Response } from 'express';`);
1050
- }
1051
- lines.push("");
1052
- lines.push(`const router = Router();`);
1053
- lines.push("");
1054
- for (const route of service.routes) {
1055
- const methodLower = route.method.toLowerCase();
1056
- const mwArgs = route.middleware.length > 0 ? route.middleware.map((mw) => `/* ${mw} */`).join(", ") + ", " : "";
1057
- lines.push(`// ${route.method} ${route.path}`);
1058
- if (this.options.typescript) {
1059
- lines.push(
1060
- `router.${methodLower}('${this.escapeStringValue(route.path, "TypeScript")}', ${mwArgs}(req: Request, res: Response) => {`
1061
- );
1062
- } else {
1063
- lines.push(
1064
- `router.${methodLower}('${this.escapeStringValue(route.path, "TypeScript")}', ${mwArgs}(req, res) => {`
1065
- );
1066
- }
1067
- lines.push(` // TODO: Implement ${route.handlerName}`);
1068
- lines.push(
1069
- ` res.json({ message: '${this.escapeStringValue(route.handlerName, "TypeScript")} not implemented' });`
1070
- );
1071
- lines.push(`});`);
1072
- lines.push("");
1073
- }
1074
- if (service.routes.length === 0) {
1075
- lines.push(`// Default health check`);
1076
- if (this.options.typescript) {
1077
- lines.push(`router.get('/health', (_req: Request, res: Response) => {`);
1078
- } else {
1079
- lines.push(`router.get('/health', (_req, res) => {`);
1080
- }
1081
- lines.push(
1082
- ` res.json({ status: 'ok', service: '${this.escapeStringValue(service.name, "TypeScript")}' });`
1083
- );
1084
- lines.push(`});`);
1085
- lines.push("");
1086
- }
1087
- lines.push(`export { router as ${routerName} };`);
1088
- } else {
1089
- lines.push(`import type { FastifyInstance } from 'fastify';`);
1090
- lines.push("");
1091
- lines.push(`export async function ${routerName}(app: FastifyInstance) {`);
1092
- for (const route of service.routes) {
1093
- const methodLower = route.method.toLowerCase();
1094
- lines.push(` // ${route.method} ${route.path}`);
1095
- lines.push(
1096
- ` app.${methodLower}('${this.escapeStringValue(route.path, "TypeScript")}', async (request, reply) => {`
1097
- );
1098
- lines.push(` // TODO: Implement ${route.handlerName}`);
1099
- lines.push(
1100
- ` return { message: '${this.escapeStringValue(route.handlerName, "TypeScript")} not implemented' };`
1101
- );
1102
- lines.push(` });`);
1103
- lines.push("");
1104
- }
1105
- if (service.routes.length === 0) {
1106
- lines.push(` // Default health check`);
1107
- lines.push(` app.get('/health', async () => {`);
1108
- lines.push(
1109
- ` return { status: 'ok', service: '${this.escapeStringValue(service.name, "TypeScript")}' };`
1110
- );
1111
- lines.push(` });`);
1112
- lines.push("");
1113
- }
1114
- lines.push(`}`);
1115
- }
1116
- return lines.join("\n");
1117
- }
1118
- emitMiddlewareIndex(middleware) {
1119
- const lines = [];
1120
- lines.push(`/**`);
1121
- lines.push(` * Middleware stubs`);
1122
- lines.push(` * Auto-generated by HoloScript NodeServiceCompiler`);
1123
- lines.push(` */`);
1124
- lines.push("");
1125
- if (this.options.framework === "express") {
1126
- lines.push(`import type { Request, Response, NextFunction } from 'express';`);
1127
- lines.push("");
1128
- for (const mw of middleware) {
1129
- const fnName = this.toCamelCase(mw) + "Middleware";
1130
- lines.push(`export function ${fnName}(req: Request, _res: Response, next: NextFunction) {`);
1131
- lines.push(` // TODO: Implement ${mw} middleware`);
1132
- lines.push(` next();`);
1133
- lines.push(`}`);
1134
- lines.push("");
1135
- }
1136
- } else {
1137
- lines.push(
1138
- `import type { FastifyRequest, FastifyReply, HookHandlerDoneFunction } from 'fastify';`
1139
- );
1140
- lines.push("");
1141
- for (const mw of middleware) {
1142
- const fnName = this.toCamelCase(mw) + "Middleware";
1143
- lines.push(
1144
- `export function ${fnName}(request: FastifyRequest, _reply: FastifyReply, done: HookHandlerDoneFunction) {`
1145
- );
1146
- lines.push(` // TODO: Implement ${mw} middleware`);
1147
- lines.push(` done();`);
1148
- lines.push(`}`);
1149
- lines.push("");
1150
- }
1151
- }
1152
- return lines.join("\n");
1153
- }
1154
- emitPackageJson(projectName) {
1155
- const name = this.toKebab(projectName || "holoscript-service");
1156
- const isExpress = this.options.framework === "express";
1157
- const pkg = {
1158
- name,
1159
- version: "0.1.0",
1160
- description: `Generated by HoloScript NodeServiceCompiler`,
1161
- main: this.options.typescript ? "dist/index.js" : "index.js",
1162
- scripts: {
1163
- ...this.options.typescript ? {
1164
- build: "tsc",
1165
- start: "node dist/index.js",
1166
- dev: "tsx watch index.ts"
1167
- } : {
1168
- start: "node index.js",
1169
- dev: "node --watch index.js"
1170
- }
1171
- },
1172
- dependencies: isExpress ? { express: "^4.21.0" } : { fastify: "^5.0.0" },
1173
- ...this.options.typescript && {
1174
- devDependencies: {
1175
- typescript: "^5.5.0",
1176
- tsx: "^4.0.0",
1177
- ...isExpress ? { "@types/express": "^4.17.21", "@types/node": "^20.0.0" } : { "@types/node": "^20.0.0" }
1178
- }
1179
- }
1180
- };
1181
- return JSON.stringify(pkg, null, 2);
1182
- }
1183
- emitTsConfig() {
1184
- const config = {
1185
- compilerOptions: {
1186
- target: "ES2022",
1187
- module: "NodeNext",
1188
- moduleResolution: "NodeNext",
1189
- outDir: "./dist",
1190
- rootDir: "./",
1191
- strict: true,
1192
- esModuleInterop: true,
1193
- skipLibCheck: true,
1194
- declaration: true
1195
- },
1196
- include: ["./**/*.ts"],
1197
- exclude: ["node_modules", "dist"]
1198
- };
1199
- return JSON.stringify(config, null, 2);
1200
- }
1201
- emitDockerfile() {
1202
- const nodeVer = this.options.nodeVersion;
1203
- return [
1204
- `FROM node:${nodeVer}-alpine AS builder`,
1205
- `WORKDIR /app`,
1206
- `COPY package*.json ./`,
1207
- `RUN npm ci`,
1208
- `COPY . .`,
1209
- ...this.options.typescript ? [`RUN npm run build`] : [],
1210
- ``,
1211
- `FROM node:${nodeVer}-alpine`,
1212
- `WORKDIR /app`,
1213
- `COPY --from=builder /app/package*.json ./`,
1214
- `RUN npm ci --omit=dev`,
1215
- ...this.options.typescript ? [`COPY --from=builder /app/dist ./dist`] : [`COPY --from=builder /app/*.js ./`],
1216
- `EXPOSE ${this.options.port}`,
1217
- `CMD ["npm", "start"]`,
1218
- ``
1219
- ].join("\n");
1220
- }
1221
- // ── Utilities ──────────────────────────────────────────────────────────
1222
- /** Convert HoloObjectProperty[] to a Map for key-based lookup */
1223
- objectPropsToMap(props) {
1224
- const map = /* @__PURE__ */ new Map();
1225
- if (!props) return map;
1226
- for (const prop of props) {
1227
- map.set(prop.key, prop.value);
1228
- }
1229
- return map;
1230
- }
1231
- ext(name) {
1232
- return this.options.typescript ? `${name}.ts` : `${name}.js`;
1233
- }
1234
- toFileName(name) {
1235
- return name.replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-");
1236
- }
1237
- toKebab(name) {
1238
- return name.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").toLowerCase();
1239
- }
1240
- toCamelCase(name) {
1241
- const parts = name.replace(/[^a-zA-Z0-9]/g, " ").split(/\s+/).filter(Boolean);
1242
- if (parts.length === 0) return "unnamed";
1243
- return parts[0].toLowerCase() + parts.slice(1).map((p) => p.charAt(0).toUpperCase() + p.slice(1).toLowerCase()).join("");
1244
- }
1245
- resolveString(val) {
1246
- if (val === void 0 || val === null) return void 0;
1247
- if (typeof val === "string") return val;
1248
- if (typeof val === "object" && "value" in val) return String(val.value);
1249
- return String(val);
1250
- }
1251
- resolveNumber(val) {
1252
- if (val === void 0 || val === null) return void 0;
1253
- if (typeof val === "number") return val;
1254
- if (typeof val === "string") {
1255
- const n = Number(val);
1256
- return isNaN(n) ? void 0 : n;
1257
- }
1258
- if (typeof val === "object" && "value" in val) {
1259
- const n = Number(val.value);
1260
- return isNaN(n) ? void 0 : n;
1261
- }
1262
- return void 0;
1263
- }
1264
- };
1265
- DialectRegistry.register({
1266
- name: "node-service",
1267
- domain: "service",
1268
- description: "Compiles @service traits to Express/Fastify Node.js applications",
1269
- supportedTraits: [
1270
- "service",
1271
- "endpoint",
1272
- "route",
1273
- "handler",
1274
- "middleware",
1275
- "http",
1276
- "gateway",
1277
- "proxy",
1278
- "load_balancer",
1279
- "auth",
1280
- "cors",
1281
- "rate_limit",
1282
- "validation"
1283
- ],
1284
- riskTier: "standard",
1285
- factory: (options) => new NodeServiceCompiler(options),
1286
- outputExtensions: [".ts", ".js", ".json"],
1287
- experimental: true
1288
- });
1289
- }
1290
- });
1291
-
1292
- // src/compiler/index.ts
1293
- init_CompilerBase();
1294
- init_CompilerDocumentationGenerator();
1295
- init_R3FCompiler();
1296
- init_UnityCompiler();
1297
- init_GodotCompiler();
1298
- init_BabylonCompiler();
1299
- init_PlayCanvasCompiler();
1300
- init_ARCompiler();
1301
- init_OpenXRCompiler();
1302
- init_VRChatCompiler();
1303
- init_VisionOSCompiler();
1304
- init_AndroidCompiler();
1305
- init_AndroidXRCompiler();
1306
- init_IOSCompiler();
1307
- init_WASMCompiler();
1308
- init_WebGPUCompiler();
1309
- init_SDFCompiler();
1310
- init_DTDLCompiler();
1311
- init_URDFCompiler();
1312
- init_StateCompiler();
1313
- init_NextJSAPICompiler();
1314
- init_Native2DCompiler();
1315
- init_NodeServiceCompiler();
1316
- init_DialectRegistry();
1317
- init_registerBuiltinDialects();
1318
-
1319
- export { DialectRegistry, NodeServiceCompiler, compileAllToNextJSAPI, compileToNextJSAPI, ensureDialectsBooted, registerBuiltinDialects };
1320
- //# sourceMappingURL=index.js.map
1321
- //# sourceMappingURL=index.js.map