@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,424 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkQHVVVN47_cjs = require('./chunk-QHVVVN47.cjs');
4
- var chunkEGIZHYJP_cjs = require('./chunk-EGIZHYJP.cjs');
5
-
6
- // src/compiler/DTDLCompiler.ts
7
- var DTDLCompiler_exports = {};
8
- chunkEGIZHYJP_cjs.__export(DTDLCompiler_exports, {
9
- DTDLCompiler: () => exports.DTDLCompiler,
10
- DTDL_TRAIT_COMPONENTS: () => exports.DTDL_TRAIT_COMPONENTS,
11
- default: () => exports.DTDLCompiler_default
12
- });
13
- exports.DTDLCompiler = void 0; exports.DTDL_TRAIT_COMPONENTS = void 0; exports.DTDLCompiler_default = void 0;
14
- var init_DTDLCompiler = chunkEGIZHYJP_cjs.__esm({
15
- "src/compiler/DTDLCompiler.ts"() {
16
- chunkQHVVVN47_cjs.init_CompilerBase();
17
- chunkQHVVVN47_cjs.init_ANSNamespace();
18
- exports.DTDLCompiler = class extends chunkQHVVVN47_cjs.CompilerBase {
19
- constructor(options = {}) {
20
- super();
21
- this.compilerName = "DTDLCompiler";
22
- this.generatedInterfaces = [];
23
- this.options = {
24
- dtdlVersion: options.dtdlVersion ?? 3,
25
- namespace: options.namespace || "dtmi:holoscript",
26
- modelVersion: options.modelVersion ?? 1,
27
- includeDescriptions: options.includeDescriptions ?? true,
28
- includeTraitComponents: options.includeTraitComponents ?? true
29
- };
30
- }
31
- getRequiredCapability() {
32
- return chunkQHVVVN47_cjs.ANSCapabilityPath.DTDL;
33
- }
34
- /**
35
- * Get trait name from either string or { name: string } format
36
- */
37
- getTraitName(trait) {
38
- return typeof trait === "string" ? trait : trait.name;
39
- }
40
- /**
41
- * Check if traits include a specific trait name
42
- */
43
- hasTrait(traits, targetTrait) {
44
- return traits?.some((t) => this.getTraitName(t) === targetTrait) ?? false;
45
- }
46
- compile(composition, agentToken, outputPath) {
47
- this.validateCompilerAccess(agentToken, outputPath);
48
- this.generatedInterfaces = [];
49
- if (composition.templates) {
50
- for (const template of composition.templates) {
51
- this.generatedInterfaces.push(this.compileTemplate(template));
52
- }
53
- }
54
- const mainInterface = this.compileComposition(composition);
55
- this.generatedInterfaces.push(mainInterface);
56
- if (composition.objects) {
57
- for (const obj of composition.objects) {
58
- if (this.objectNeedsInterface(obj)) {
59
- this.generatedInterfaces.push(this.compileObject(obj));
60
- }
61
- }
62
- }
63
- return JSON.stringify(this.generatedInterfaces, null, 2);
64
- }
65
- compileComposition(composition) {
66
- const modelId = this.generateModelId(composition.name);
67
- const contents = [];
68
- if (composition.environment) {
69
- contents.push(...this.compileEnvironmentProperties(composition.environment));
70
- }
71
- if (composition.state) {
72
- contents.push(...this.compileStateProperties(composition.state));
73
- }
74
- if (composition.logic) {
75
- contents.push(...this.compileLogicCommands(composition.logic));
76
- }
77
- if (composition.objects) {
78
- for (const obj of composition.objects) {
79
- contents.push(this.createObjectRelationship(obj));
80
- }
81
- }
82
- if (composition.spatialGroups) {
83
- for (const group of composition.spatialGroups) {
84
- contents.push({
85
- "@type": "Relationship",
86
- name: this.sanitizeName(group.name),
87
- displayName: group.name,
88
- description: `Spatial group containing ${group.objects?.length || 0} objects`
89
- });
90
- }
91
- }
92
- const iface = {
93
- "@context": this.getDtdlContext(),
94
- "@type": "Interface",
95
- "@id": modelId,
96
- displayName: composition.name,
97
- contents
98
- };
99
- if (this.options.includeDescriptions) {
100
- iface.description = `Generated from HoloScript composition "${this.escapeStringValue(composition.name, "TypeScript")}"`;
101
- }
102
- return iface;
103
- }
104
- compileTemplate(template) {
105
- const modelId = this.generateModelId(template.name);
106
- const contents = [];
107
- if (template.state) {
108
- contents.push(...this.compileStateProperties(template.state));
109
- }
110
- if (template.actions) {
111
- for (const action of template.actions) {
112
- contents.push({
113
- "@type": "Command",
114
- name: action.name,
115
- displayName: action.name,
116
- description: `Action defined in template ${this.escapeStringValue(template.name, "TypeScript")}`
117
- });
118
- }
119
- }
120
- if (template.traits && this.options.includeTraitComponents) {
121
- for (const trait of template.traits) {
122
- const traitName = typeof trait === "string" ? trait : trait.name;
123
- const component = this.traitToComponent(traitName);
124
- if (component) {
125
- contents.push(component);
126
- }
127
- }
128
- }
129
- const iface = {
130
- "@context": this.getDtdlContext(),
131
- "@type": "Interface",
132
- "@id": modelId,
133
- displayName: template.name,
134
- contents
135
- };
136
- const templateExt = template;
137
- if (templateExt.extends) {
138
- iface.extends = [this.generateModelId(templateExt.extends)];
139
- }
140
- return iface;
141
- }
142
- compileObject(obj) {
143
- const modelId = this.generateModelId(obj.name);
144
- const contents = [];
145
- const posProp = obj.properties.find((p) => p.key === "position");
146
- if (posProp) {
147
- contents.push({
148
- "@type": ["Property", "Location"],
149
- name: "position",
150
- schema: {
151
- "@type": "Object",
152
- fields: [
153
- { name: "x", schema: "double" },
154
- { name: "y", schema: "double" },
155
- { name: "z", schema: "double" }
156
- ]
157
- },
158
- writable: true
159
- });
160
- }
161
- for (const prop of obj.properties) {
162
- if (prop.key !== "position" && prop.key !== "geometry") {
163
- contents.push(this.propertyToContent(prop.key, prop.value));
164
- }
165
- }
166
- if (this.hasTrait(obj.traits, "sensor") || this.hasTrait(obj.traits, "observable")) {
167
- contents.push({
168
- "@type": "Telemetry",
169
- name: "sensorReading",
170
- schema: "double",
171
- description: "Sensor telemetry data"
172
- });
173
- }
174
- if (obj.traits && this.options.includeTraitComponents) {
175
- for (const trait of obj.traits) {
176
- const traitName = this.getTraitName(trait);
177
- const component = this.traitToComponent(traitName);
178
- if (component) {
179
- contents.push(component);
180
- }
181
- }
182
- }
183
- const iface = {
184
- "@context": this.getDtdlContext(),
185
- "@type": "Interface",
186
- "@id": modelId,
187
- displayName: obj.name,
188
- contents
189
- };
190
- if (obj.template) {
191
- iface.extends = this.generateModelId(obj.template);
192
- }
193
- return iface;
194
- }
195
- compileEnvironmentProperties(env) {
196
- const props = [];
197
- const envExt = env;
198
- if (Array.isArray(envExt.properties)) {
199
- for (const prop of envExt.properties) {
200
- this.addEnvironmentProperty(props, prop.key, prop.value);
201
- }
202
- } else {
203
- for (const key of Object.keys(envExt)) {
204
- if (key !== "type") {
205
- this.addEnvironmentProperty(props, key, envExt[key]);
206
- }
207
- }
208
- }
209
- return props;
210
- }
211
- addEnvironmentProperty(props, key, _value) {
212
- if (key === "skybox") {
213
- props.push({
214
- "@type": "Property",
215
- name: "skybox",
216
- schema: "string",
217
- displayName: "Skybox",
218
- description: "Environment skybox setting"
219
- });
220
- } else if (key === "ambient_light") {
221
- props.push({
222
- "@type": "Property",
223
- name: "ambientLight",
224
- schema: "double",
225
- displayName: "Ambient Light",
226
- description: "Ambient light level"
227
- });
228
- } else if (key === "fog") {
229
- props.push({
230
- "@type": "Property",
231
- name: "fogEnabled",
232
- schema: "boolean",
233
- displayName: "Fog Enabled"
234
- });
235
- }
236
- }
237
- compileStateProperties(state) {
238
- const props = [];
239
- for (const prop of state.properties) {
240
- props.push(this.propertyToContent(prop.key, prop.value));
241
- }
242
- return props;
243
- }
244
- compileLogicCommands(logic) {
245
- const commands = [];
246
- const logicExt = logic;
247
- const items = logicExt.handlers || logicExt.rules || [];
248
- for (const item of items) {
249
- const event = item.event;
250
- if (event?.startsWith("on_")) {
251
- commands.push({
252
- "@type": "Command",
253
- name: event.replace("on_", ""),
254
- displayName: this.formatEventName(event),
255
- description: `Event handler for ${event}`
256
- });
257
- }
258
- }
259
- return commands;
260
- }
261
- propertyToContent(key, value) {
262
- return {
263
- "@type": "Property",
264
- name: this.sanitizeName(key),
265
- schema: this.inferSchema(value),
266
- displayName: this.formatDisplayName(key),
267
- writable: true
268
- };
269
- }
270
- createObjectRelationship(obj) {
271
- return {
272
- "@type": "Relationship",
273
- name: `has${this.pascalCase(obj.name)}`,
274
- displayName: obj.name,
275
- target: this.objectNeedsInterface(obj) ? this.generateModelId(obj.name) : void 0,
276
- maxMultiplicity: 1
277
- };
278
- }
279
- traitToComponent(trait) {
280
- const traitComponents = {
281
- grabbable: {
282
- schema: `${this.options.namespace}:component:Grabbable;${this.options.modelVersion}`,
283
- description: "Allows object to be grabbed/manipulated"
284
- },
285
- networked: {
286
- schema: `${this.options.namespace}:component:Networked;${this.options.modelVersion}`,
287
- description: "Enables network synchronization"
288
- },
289
- physics: {
290
- schema: `${this.options.namespace}:component:Physics;${this.options.modelVersion}`,
291
- description: "Enables physics simulation"
292
- },
293
- collidable: {
294
- schema: `${this.options.namespace}:component:Collidable;${this.options.modelVersion}`,
295
- description: "Enables collision detection"
296
- },
297
- sensor: {
298
- schema: `${this.options.namespace}:component:Sensor;${this.options.modelVersion}`,
299
- description: "IoT sensor capabilities"
300
- },
301
- observable: {
302
- schema: `${this.options.namespace}:component:Observable;${this.options.modelVersion}`,
303
- description: "State observation capabilities"
304
- }
305
- };
306
- const config = traitComponents[trait];
307
- if (!config) return null;
308
- return {
309
- "@type": "Component",
310
- name: trait,
311
- schema: config.schema,
312
- description: config.description
313
- };
314
- }
315
- inferSchema(value) {
316
- if (typeof value === "boolean") return "boolean";
317
- if (typeof value === "number") {
318
- return Number.isInteger(value) ? "integer" : "double";
319
- }
320
- if (typeof value === "string") return "string";
321
- if (Array.isArray(value)) {
322
- if (value.length > 0) {
323
- return {
324
- "@type": "Array",
325
- elementSchema: this.inferSchema(value[0])
326
- };
327
- }
328
- return { "@type": "Array", elementSchema: "double" };
329
- }
330
- if (typeof value === "object" && value !== null) {
331
- const fields = Object.entries(value).map(([k, v]) => ({
332
- name: k,
333
- schema: this.inferSchema(v)
334
- }));
335
- return { "@type": "Object", fields };
336
- }
337
- return "string";
338
- }
339
- getDtdlContext() {
340
- return this.options.dtdlVersion === 3 ? "dtmi:dtdl:context;3" : "dtmi:dtdl:context;2";
341
- }
342
- generateModelId(name) {
343
- const sanitized = this.sanitizeName(name);
344
- return `${this.options.namespace}:${sanitized};${this.options.modelVersion}`;
345
- }
346
- objectNeedsInterface(obj) {
347
- const hasState = obj.properties.some((p) => p.key === "state" || typeof p.value === "object");
348
- const complexTraitList = ["networked", "sensor", "observable", "state"];
349
- const hasComplexTraits = obj.traits?.some(
350
- (t) => complexTraitList.includes(this.getTraitName(t))
351
- );
352
- return hasState || hasComplexTraits || false;
353
- }
354
- sanitizeName(name) {
355
- return name.replace(/[^a-zA-Z0-9_]/g, "_").replace(/^_+|_+$/g, "").replace(/_+/g, "_");
356
- }
357
- formatDisplayName(name) {
358
- return name.replace(/_/g, " ").replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).trim();
359
- }
360
- formatEventName(event) {
361
- return event.replace(/^on_/, "").replace(/_/g, " ").replace(/^./, (s) => s.toUpperCase());
362
- }
363
- pascalCase(name) {
364
- return name.replace(/[^a-zA-Z0-9]/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join("");
365
- }
366
- };
367
- exports.DTDL_TRAIT_COMPONENTS = [
368
- {
369
- "@context": "dtmi:dtdl:context;3",
370
- "@type": "Interface",
371
- "@id": "dtmi:holoscript:component:Grabbable;1",
372
- displayName: "Grabbable",
373
- description: "Component for objects that can be grabbed in VR/AR",
374
- contents: [
375
- { "@type": "Property", name: "isGrabbed", schema: "boolean", writable: false },
376
- { "@type": "Property", name: "grabDistance", schema: "double", writable: true }
377
- ]
378
- },
379
- {
380
- "@context": "dtmi:dtdl:context;3",
381
- "@type": "Interface",
382
- "@id": "dtmi:holoscript:component:Networked;1",
383
- displayName: "Networked",
384
- description: "Component for network-synchronized objects",
385
- contents: [
386
- { "@type": "Property", name: "networkId", schema: "string", writable: false },
387
- { "@type": "Property", name: "syncRate", schema: "integer", writable: true },
388
- { "@type": "Property", name: "ownerId", schema: "string", writable: false }
389
- ]
390
- },
391
- {
392
- "@context": "dtmi:dtdl:context;3",
393
- "@type": "Interface",
394
- "@id": "dtmi:holoscript:component:Physics;1",
395
- displayName: "Physics",
396
- description: "Component for physics-enabled objects",
397
- contents: [
398
- { "@type": "Property", name: "mass", schema: "double", writable: true },
399
- { "@type": "Property", name: "friction", schema: "double", writable: true },
400
- { "@type": "Property", name: "restitution", schema: "double", writable: true },
401
- { "@type": "Property", name: "isKinematic", schema: "boolean", writable: true }
402
- ]
403
- },
404
- {
405
- "@context": "dtmi:dtdl:context;3",
406
- "@type": "Interface",
407
- "@id": "dtmi:holoscript:component:Sensor;1",
408
- displayName: "Sensor",
409
- description: "Component for IoT sensor capabilities",
410
- contents: [
411
- { "@type": "Property", name: "sensorType", schema: "string", writable: false },
412
- { "@type": "Telemetry", name: "value", schema: "double" },
413
- { "@type": "Telemetry", name: "timestamp", schema: "dateTime" }
414
- ]
415
- }
416
- ];
417
- exports.DTDLCompiler_default = exports.DTDLCompiler;
418
- }
419
- });
420
-
421
- exports.DTDLCompiler_exports = DTDLCompiler_exports;
422
- exports.init_DTDLCompiler = init_DTDLCompiler;
423
- //# sourceMappingURL=chunk-WFJIDI2N.cjs.map
424
- //# sourceMappingURL=chunk-WFJIDI2N.cjs.map
@@ -1,118 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkAIUXRS74_cjs = require('./chunk-AIUXRS74.cjs');
4
- var chunkEGIZHYJP_cjs = require('./chunk-EGIZHYJP.cjs');
5
-
6
- // src/compiler/StateCompiler.ts
7
- var StateCompiler_exports = {};
8
- chunkEGIZHYJP_cjs.__export(StateCompiler_exports, {
9
- StateCompiler: () => exports.StateCompiler,
10
- UnauthorizedStateCompilerAccessError: () => exports.UnauthorizedStateCompilerAccessError
11
- });
12
- exports.StateCompiler = void 0; exports.UnauthorizedStateCompilerAccessError = void 0;
13
- var init_StateCompiler = chunkEGIZHYJP_cjs.__esm({
14
- "src/compiler/StateCompiler.ts"() {
15
- chunkAIUXRS74_cjs.init_AgentRBAC();
16
- exports.StateCompiler = class {
17
- /**
18
- * Walk an entire HSPlusAST and extract all per-node stateBlocks.
19
- *
20
- * @param ast - The parse result returned by HoloScriptPlusParser.
21
- * @param agentToken - JWT token proving agent identity (optional for backwards compatibility).
22
- * @returns A StateShapeMap keyed by node.name (or a generated id).
23
- * @throws UnauthorizedStateCompilerAccessError if token is provided but invalid.
24
- */
25
- compile(ast, agentToken) {
26
- this.validateAccess(agentToken);
27
- const shapes = /* @__PURE__ */ new Map();
28
- this.walkNode(ast.root, shapes);
29
- return shapes;
30
- }
31
- // ---------------------------------------------------------------------------
32
- // RBAC enforcement
33
- // ---------------------------------------------------------------------------
34
- /**
35
- * Validate agent has permission to compile state blocks.
36
- * Skips validation when no token is provided (backwards compatibility / testing).
37
- */
38
- validateAccess(agentToken) {
39
- if (!agentToken) return;
40
- const rbac = chunkAIUXRS74_cjs.getRBAC();
41
- const decision = rbac.checkAccess({
42
- token: agentToken,
43
- resourceType: "ast" /* AST */,
44
- operation: "read",
45
- expectedWorkflowStep: "generate_assembly" /* GENERATE_ASSEMBLY */
46
- });
47
- if (!decision.allowed) {
48
- throw new exports.UnauthorizedStateCompilerAccessError(decision, "StateCompiler");
49
- }
50
- }
51
- /**
52
- * Compile a single HSPlusNode subtree.
53
- * Useful when only a portion of the AST is being (re-)compiled.
54
- */
55
- compileNode(node) {
56
- if (!node.stateBlock || Object.keys(node.stateBlock).length === 0) {
57
- return null;
58
- }
59
- return this.buildShape(node);
60
- }
61
- // ---------------------------------------------------------------------------
62
- // Private helpers
63
- // ---------------------------------------------------------------------------
64
- walkNode(node, out) {
65
- if (!node) return;
66
- if (node.stateBlock && Object.keys(node.stateBlock).length > 0) {
67
- const shape = this.buildShape(node);
68
- out.set(shape.nodeId, shape);
69
- }
70
- if (Array.isArray(node.children)) {
71
- for (const child of node.children) {
72
- this.walkNode(child, out);
73
- }
74
- }
75
- if (node.body && typeof node.body === "object" && !Array.isArray(node.body)) {
76
- if (node.body.type) {
77
- this.walkNode(node.body, out);
78
- }
79
- }
80
- }
81
- buildShape(node) {
82
- const nodeId = this.resolveNodeId(node);
83
- const stateBlock = node.stateBlock ?? {};
84
- const vars = [];
85
- const initialState = {};
86
- for (const [key, value] of Object.entries(stateBlock)) {
87
- if (key.startsWith("__spread_")) continue;
88
- vars.push({ name: key, initialValue: value });
89
- initialState[key] = value;
90
- }
91
- return { nodeId, initialState, vars };
92
- }
93
- resolveNodeId(node) {
94
- if (node.name) return node.name;
95
- const loc = node.loc;
96
- if (loc) return `${node.type}@${loc.start.line}:${loc.start.column}`;
97
- return `${node.type}_${Math.random().toString(36).slice(2, 7)}`;
98
- }
99
- };
100
- exports.UnauthorizedStateCompilerAccessError = class extends Error {
101
- constructor(decision, compilerName) {
102
- super(
103
- `[${compilerName}] Unauthorized access: ${decision.reason || "Access denied"}
104
- Agent Role: ${decision.agentRole || "unknown"}
105
- Required Permission: ${decision.requiredPermission || "unknown"}`
106
- );
107
- this.decision = decision;
108
- this.compilerName = compilerName;
109
- this.name = "UnauthorizedStateCompilerAccessError";
110
- }
111
- };
112
- }
113
- });
114
-
115
- exports.StateCompiler_exports = StateCompiler_exports;
116
- exports.init_StateCompiler = init_StateCompiler;
117
- //# sourceMappingURL=chunk-WN3YF33G.cjs.map
118
- //# sourceMappingURL=chunk-WN3YF33G.cjs.map