@holoscript/core 6.0.4 → 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 (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,697 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var chunkQ4QX3AET_cjs = require('./chunk-Q4QX3AET.cjs');
6
- var chunkT7LEXZUZ_cjs = require('./chunk-T7LEXZUZ.cjs');
7
- require('./chunk-ILRBGFVD.cjs');
8
- require('./chunk-3SAK5KFL.cjs');
9
-
10
- // src/HoloScriptPlusParser.ts
11
- var HoloScriptPlusParser = class {
12
- constructor() {
13
- this.baseParser = new chunkT7LEXZUZ_cjs.HoloScriptCodeParser();
14
- }
15
- /**
16
- * Parse HoloScript+ code with trait annotations
17
- */
18
- parse(code) {
19
- const baseResult = this.baseParser.parse(code);
20
- const ast = baseResult.ast;
21
- return this.enhanceWithTraits(ast, code);
22
- }
23
- /**
24
- * Enhance AST nodes with trait annotations
25
- */
26
- enhanceWithTraits(ast, code) {
27
- return ast.map((node) => {
28
- if (node.type === "orb") {
29
- return this.enhanceOrbNodeWithTraits(node, code);
30
- }
31
- return node;
32
- });
33
- }
34
- /**
35
- * Enhance OrbNode with trait annotations
36
- */
37
- enhanceOrbNodeWithTraits(node, code) {
38
- const orbNode = node;
39
- const enhanced = {
40
- ...orbNode,
41
- traits: [],
42
- graphics: {}
43
- };
44
- const traits = this.extractTraitAnnotations(code, node.line);
45
- enhanced.traits = traits;
46
- if (traits.length > 0) {
47
- enhanced.graphics = this.buildGraphicsConfig(traits);
48
- }
49
- return enhanced;
50
- }
51
- /**
52
- * Extract trait annotations from code
53
- */
54
- extractTraitAnnotations(code, _orbLine) {
55
- const traits = [];
56
- const traitRegex = /@(material|lighting|rendering|shader|networked|rpc|joint|ik)\s*\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/g;
57
- let match;
58
- while ((match = traitRegex.exec(code)) !== null) {
59
- const type = match[1];
60
- const configStr = match[2];
61
- try {
62
- const config = this.parseTraitConfig(configStr, type);
63
- switch (type) {
64
- case "material":
65
- traits.push({
66
- type: "material",
67
- config
68
- });
69
- break;
70
- case "lighting":
71
- traits.push({
72
- type: "lighting",
73
- config
74
- });
75
- break;
76
- case "rendering":
77
- traits.push({
78
- type: "rendering",
79
- config
80
- });
81
- break;
82
- case "shader":
83
- traits.push({
84
- type: "shader",
85
- config
86
- });
87
- break;
88
- case "networked":
89
- traits.push({
90
- type: "networked",
91
- config
92
- });
93
- break;
94
- case "rpc":
95
- traits.push({
96
- type: "rpc",
97
- config
98
- });
99
- break;
100
- case "joint":
101
- traits.push({
102
- type: "joint",
103
- config
104
- });
105
- break;
106
- case "ik":
107
- traits.push({
108
- type: "ik",
109
- config
110
- });
111
- break;
112
- }
113
- } catch (e) {
114
- console.warn(`Failed to parse ${type} trait annotation:`, e);
115
- }
116
- }
117
- return traits;
118
- }
119
- /**
120
- * Parse trait configuration with support for inline code (backticks)
121
- */
122
- parseTraitConfig(str, traitType) {
123
- if (traitType === "shader") {
124
- return this.parseShaderConfig(str);
125
- }
126
- return this.parseObjectLiteral(str);
127
- }
128
- /**
129
- * Parse shader configuration with inline GLSL support
130
- */
131
- parseShaderConfig(str) {
132
- const config = {};
133
- const backtickStrings = [];
134
- const processedStr = str.replace(/`([^`]*)`/g, (_, content) => {
135
- backtickStrings.push(content);
136
- return `__BACKTICK_${backtickStrings.length - 1}__`;
137
- });
138
- const parsed = this.parseObjectLiteral(processedStr);
139
- for (const [key, value] of Object.entries(parsed)) {
140
- if (typeof value === "string" && value.startsWith("__BACKTICK_")) {
141
- const index = parseInt(value.replace("__BACKTICK_", "").replace("__", ""));
142
- config[key] = backtickStrings[index];
143
- } else {
144
- config[key] = value;
145
- }
146
- }
147
- return config;
148
- }
149
- /**
150
- * Parse object literal from string
151
- * Supports nested objects and arrays
152
- */
153
- parseObjectLiteral(str) {
154
- const config = {};
155
- let depth = 0;
156
- let current = "";
157
- const pairs = [];
158
- for (let i = 0; i < str.length; i++) {
159
- const char = str[i];
160
- if (char === "{" || char === "[") {
161
- depth++;
162
- } else if (char === "}" || char === "]") {
163
- depth--;
164
- } else if (char === "," && depth === 0) {
165
- pairs.push(current.trim());
166
- current = "";
167
- continue;
168
- }
169
- current += char;
170
- }
171
- if (current.trim()) {
172
- pairs.push(current.trim());
173
- }
174
- for (const pair of pairs) {
175
- const colonIndex = pair.indexOf(":");
176
- if (colonIndex === -1) continue;
177
- const key = pair.substring(0, colonIndex).trim();
178
- const value = pair.substring(colonIndex + 1).trim();
179
- config[key] = this.parseValue(value);
180
- }
181
- return config;
182
- }
183
- /**
184
- * Parse individual values
185
- */
186
- parseValue(str) {
187
- str = str.trim();
188
- if (str === "true") return true;
189
- if (str === "false") return false;
190
- if (/^-?\d+(\.\d+)?$/.test(str)) return parseFloat(str);
191
- if (str.startsWith('"') && str.endsWith('"') || str.startsWith("'") && str.endsWith("'")) {
192
- return str.slice(1, -1);
193
- }
194
- if (str.startsWith("{") && str.endsWith("}")) {
195
- return this.parseObjectLiteral(str.slice(1, -1));
196
- }
197
- if (str.startsWith("[") && str.endsWith("]")) {
198
- const items = str.slice(1, -1).split(",");
199
- return items.map((item) => this.parseValue(item));
200
- }
201
- return str;
202
- }
203
- /**
204
- * Build GraphicsConfiguration from trait annotations
205
- */
206
- buildGraphicsConfig(traits) {
207
- const config = {};
208
- for (const trait of traits) {
209
- switch (trait.type) {
210
- case "material":
211
- config.material = trait.config;
212
- break;
213
- case "lighting":
214
- config.lighting = trait.config;
215
- break;
216
- case "rendering":
217
- config.rendering = trait.config;
218
- break;
219
- case "shader":
220
- config.shader = trait.config;
221
- break;
222
- case "networked":
223
- config.networked = trait.config;
224
- break;
225
- case "rpc":
226
- config.rpc = trait.config;
227
- break;
228
- case "joint":
229
- config.joint = trait.config;
230
- break;
231
- case "ik":
232
- config.ik = trait.config;
233
- break;
234
- }
235
- }
236
- return config;
237
- }
238
- /**
239
- * Validate trait annotation configuration
240
- */
241
- validateTraitAnnotation(trait) {
242
- const errors = [];
243
- switch (trait.type) {
244
- case "material":
245
- errors.push(...this.validateMaterialTrait(trait));
246
- break;
247
- case "lighting":
248
- errors.push(...this.validateLightingTrait(trait));
249
- break;
250
- case "rendering":
251
- errors.push(...this.validateRenderingTrait(trait));
252
- break;
253
- case "shader":
254
- errors.push(...this.validateShaderTrait(trait));
255
- break;
256
- case "networked":
257
- errors.push(...this.validateNetworkedTrait(trait));
258
- break;
259
- case "joint":
260
- errors.push(...this.validateJointTrait(trait));
261
- break;
262
- case "ik":
263
- errors.push(...this.validateIKTrait(trait));
264
- break;
265
- }
266
- return {
267
- valid: errors.length === 0,
268
- errors
269
- };
270
- }
271
- /**
272
- * Validate material trait configuration
273
- */
274
- validateMaterialTrait(trait) {
275
- const errors = [];
276
- const { config } = trait;
277
- if (config.pbr) {
278
- if (config.pbr.metallic !== void 0 && (config.pbr.metallic < 0 || config.pbr.metallic > 1)) {
279
- errors.push("material.pbr.metallic must be between 0 and 1");
280
- }
281
- if (config.pbr.roughness !== void 0 && (config.pbr.roughness < 0 || config.pbr.roughness > 1)) {
282
- errors.push("material.pbr.roughness must be between 0 and 1");
283
- }
284
- }
285
- if (config.compression && !["none", "dxt", "astc", "basis"].includes(config.compression)) {
286
- errors.push(`material.compression must be one of: none, dxt, astc, basis`);
287
- }
288
- return errors;
289
- }
290
- /**
291
- * Validate lighting trait configuration
292
- */
293
- validateLightingTrait(trait) {
294
- const errors = [];
295
- const { config } = trait;
296
- if (config.preset && !["studio", "outdoor", "interior", "night", "sunset"].includes(config.preset)) {
297
- errors.push("lighting.preset must be one of: studio, outdoor, interior, night, sunset");
298
- }
299
- if (config.lights) {
300
- config.lights.forEach((light, index) => {
301
- if (!["directional", "point", "spot", "area", "ambient"].includes(light.type)) {
302
- errors.push(`lighting.lights[${index}].type must be a valid light type`);
303
- }
304
- if (light.intensity !== void 0 && light.intensity < 0) {
305
- errors.push(`lighting.lights[${index}].intensity must be >= 0`);
306
- }
307
- });
308
- }
309
- return errors;
310
- }
311
- /**
312
- * Validate rendering trait configuration
313
- */
314
- validateRenderingTrait(trait) {
315
- const errors = [];
316
- const { config } = trait;
317
- if (config.quality && !["low", "medium", "high", "ultra"].includes(config.quality)) {
318
- errors.push("rendering.quality must be one of: low, medium, high, ultra");
319
- }
320
- if (config.platform && !["mobile", "vr", "desktop"].includes(config.platform)) {
321
- errors.push("rendering.platform must be one of: mobile, vr, desktop");
322
- }
323
- if (config.compression && !["none", "dxt", "astc", "basis"].includes(config.compression)) {
324
- errors.push("rendering.compression must be one of: none, dxt, astc, basis");
325
- }
326
- if (config.maxTextureResolution && config.maxTextureResolution < 128) {
327
- errors.push("rendering.maxTextureResolution must be >= 128");
328
- }
329
- if (config.targetFPS && (config.targetFPS < 24 || config.targetFPS > 240)) {
330
- errors.push("rendering.targetFPS must be between 24 and 240");
331
- }
332
- return errors;
333
- }
334
- /**
335
- * Get trait annotations as graphics traits
336
- */
337
- createGraphicsTraits(config) {
338
- return {
339
- material: config.material ? this.createMaterialTrait(config.material) : null,
340
- lighting: config.lighting ? this.createLightingTrait(config.lighting) : null,
341
- rendering: config.rendering ? this.createRenderingTrait(config.rendering) : null,
342
- shader: config.shader ? this.createShaderTrait(config.shader) : null
343
- };
344
- }
345
- /**
346
- * Create MaterialTrait from config
347
- */
348
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic material config from parsed AST
349
- createMaterialTrait(config) {
350
- const material = new chunkQ4QX3AET_cjs.MaterialTrait({
351
- type: config.type || "pbr",
352
- pbr: config.pbr
353
- });
354
- if (config.compression) {
355
- material.setCompression(config.compression);
356
- }
357
- if (config.instancing) {
358
- material.setInstanced(true);
359
- }
360
- if (config.streaming) {
361
- material.setTextureStreaming(true);
362
- }
363
- if (config.textures) {
364
- config.textures.forEach((tex) => {
365
- material.addTexture(tex);
366
- });
367
- }
368
- return material;
369
- }
370
- /**
371
- * Create LightingTrait from config
372
- */
373
- createLightingTrait(config) {
374
- let lighting;
375
- if (config.preset) {
376
- const presetFactory = chunkQ4QX3AET_cjs.LIGHTING_PRESETS[config.preset];
377
- const presetConfig = presetFactory ? presetFactory() : void 0;
378
- lighting = new chunkQ4QX3AET_cjs.LightingTrait(presetConfig);
379
- } else {
380
- lighting = new chunkQ4QX3AET_cjs.LightingTrait();
381
- }
382
- if (config.globalIllumination) {
383
- lighting.setGlobalIllumination(config.globalIllumination);
384
- }
385
- if (config.lights) {
386
- config.lights.forEach((light) => {
387
- lighting.addLight(light);
388
- });
389
- }
390
- return lighting;
391
- }
392
- /**
393
- * Create RenderingTrait from config
394
- */
395
- createRenderingTrait(config) {
396
- const rendering = new chunkQ4QX3AET_cjs.RenderingTrait();
397
- if (config.quality) {
398
- rendering.applyQualityPreset(config.quality);
399
- }
400
- if (config.platform) {
401
- switch (config.platform) {
402
- case "mobile":
403
- rendering.optimizeForMobile();
404
- break;
405
- case "vr":
406
- rendering.optimizeForVRAR(config.targetFPS || 90);
407
- break;
408
- case "desktop":
409
- rendering.optimizeForDesktop();
410
- break;
411
- }
412
- }
413
- if (config.lod !== false) {
414
- rendering.setupLODLevels("automatic");
415
- }
416
- if (config.culling !== false) {
417
- rendering.setFrustumCulling(true);
418
- }
419
- if (config.compression) {
420
- rendering.setTextureCompression(config.compression);
421
- }
422
- if (config.maxTextureResolution) {
423
- rendering.setMaxTextureResolution(config.maxTextureResolution);
424
- }
425
- return rendering;
426
- }
427
- /**
428
- * Create ShaderTrait from config
429
- */
430
- createShaderTrait(config) {
431
- if (config.preset && chunkQ4QX3AET_cjs.SHADER_PRESETS[config.preset]) {
432
- const preset = chunkQ4QX3AET_cjs.SHADER_PRESETS[config.preset];
433
- return new chunkQ4QX3AET_cjs.ShaderTrait(preset);
434
- }
435
- const shaderConfig = {
436
- source: {
437
- language: config.language || "glsl",
438
- vertex: config.vertex,
439
- fragment: config.fragment
440
- },
441
- uniforms: config.uniforms,
442
- includes: config.includes?.map((path) => ({ path })),
443
- blendMode: config.blendMode,
444
- depthTest: config.depthTest,
445
- depthWrite: config.depthWrite,
446
- cullFace: config.cullFace
447
- };
448
- return new chunkQ4QX3AET_cjs.ShaderTrait(shaderConfig);
449
- }
450
- /**
451
- * Validate shader trait configuration
452
- */
453
- validateShaderTrait(trait) {
454
- const errors = [];
455
- const { config } = trait;
456
- if (!config.preset && !config.vertex && !config.fragment) {
457
- errors.push("shader must have either preset or vertex/fragment code");
458
- }
459
- if (config.preset && !chunkQ4QX3AET_cjs.SHADER_PRESETS[config.preset]) {
460
- errors.push(
461
- `shader.preset "${config.preset}" is not a valid preset. Available: hologram, forceField, dissolve`
462
- );
463
- }
464
- if (config.language && !["glsl", "hlsl", "wgsl"].includes(config.language)) {
465
- errors.push("shader.language must be one of: glsl, hlsl, wgsl");
466
- }
467
- if (config.blendMode && !["opaque", "blend", "additive", "multiply"].includes(config.blendMode)) {
468
- errors.push("shader.blendMode must be one of: opaque, blend, additive, multiply");
469
- }
470
- if (config.cullFace && !["none", "front", "back"].includes(config.cullFace)) {
471
- errors.push("shader.cullFace must be one of: none, front, back");
472
- }
473
- return errors;
474
- }
475
- /**
476
- * Validate networked trait configuration
477
- */
478
- validateNetworkedTrait(trait) {
479
- const errors = [];
480
- const { config } = trait;
481
- if (config.mode && !["owner", "shared", "server"].includes(config.mode)) {
482
- errors.push("networked.mode must be one of: owner, shared, server");
483
- }
484
- if (config.syncRate !== void 0 && (config.syncRate < 1 || config.syncRate > 60)) {
485
- errors.push("networked.syncRate must be between 1 and 60 Hz");
486
- }
487
- return errors;
488
- }
489
- /**
490
- * Validate joint trait configuration
491
- */
492
- validateJointTrait(trait) {
493
- const errors = [];
494
- const { config } = trait;
495
- if (!config.jointType) {
496
- errors.push("joint.jointType is required");
497
- } else if (!["fixed", "hinge", "ball", "slider", "spring"].includes(config.jointType)) {
498
- errors.push("joint.jointType must be one of: fixed, hinge, ball, slider, spring");
499
- }
500
- if (config.breakForce !== void 0 && config.breakForce < 0) {
501
- errors.push("joint.breakForce must be >= 0");
502
- }
503
- return errors;
504
- }
505
- /**
506
- * Validate IK trait configuration
507
- */
508
- validateIKTrait(trait) {
509
- const errors = [];
510
- const { config } = trait;
511
- if (!config.chain) {
512
- errors.push("ik.chain is required");
513
- }
514
- if (config.chainLength !== void 0 && config.chainLength < 1) {
515
- errors.push("ik.chainLength must be >= 1");
516
- }
517
- if (config.iterations !== void 0 && config.iterations < 1) {
518
- errors.push("ik.iterations must be >= 1");
519
- }
520
- if (config.weight !== void 0 && (config.weight < 0 || config.weight > 1)) {
521
- errors.push("ik.weight must be between 0 and 1");
522
- }
523
- return errors;
524
- }
525
- // ==========================================================================
526
- // Module System — @import / @export
527
- // ==========================================================================
528
- /**
529
- * Parse HoloScript+ code and also extract module-level @import / @export
530
- * declarations from the source header.
531
- *
532
- * Returns both the enhanced AST and a structured module header so callers
533
- * (e.g. ModuleResolver, SceneRunner) can understand the file's dependencies
534
- * without running a separate pass.
535
- */
536
- parseWithModules(code, fromFile = "<inline>") {
537
- const ast = this.parse(code);
538
- const { imports, exports: exports$1 } = this.parseModuleHeader(code, fromFile);
539
- return { ast, imports, exports: exports$1 };
540
- }
541
- /**
542
- * Scan the top of a source string and return all @import / @export
543
- * declarations before the first non-directive, non-comment line.
544
- */
545
- parseModuleHeader(code, _fromFile = "<inline>") {
546
- const imports = [];
547
- const exports$1 = [];
548
- for (const rawLine of code.split("\n")) {
549
- const line = rawLine.trim();
550
- if (!line || line.startsWith("//") || line.startsWith("#")) continue;
551
- const imp = this.parseImportDirective(line);
552
- if (imp) {
553
- imports.push(imp);
554
- continue;
555
- }
556
- const exp = this.parseExportDirective(line);
557
- if (exp) {
558
- exports$1.push(...exp);
559
- continue;
560
- }
561
- break;
562
- }
563
- return { imports, exports: exports$1 };
564
- }
565
- /**
566
- * Parse a single @import directive line.
567
- *
568
- * Accepted forms:
569
- * @import @physics, @ai_npc from "./physics.hs"
570
- * @import * from "./shared.hs"
571
- * @import @physics as @p from "./physics.hs"
572
- *
573
- * Returns null if the line is not an @import.
574
- */
575
- parseImportDirective(line) {
576
- const m = line.match(/^@import\s+([\w@*,\s]+?)(?:\s+as\s+(@\w+))?\s+from\s+["']([^"']+)["']/);
577
- if (!m) return null;
578
- const specifiersPart = m[1].trim();
579
- const alias = m[2]?.replace("@", "");
580
- const source = m[3];
581
- const specifiers = specifiersPart === "*" ? ["*"] : specifiersPart.split(",").map((s) => s.trim().replace("@", "")).filter(Boolean);
582
- return { specifiers, source, ...alias ? { alias } : {} };
583
- }
584
- /**
585
- * Parse a single @export directive line.
586
- *
587
- * @export @turret, @enemy
588
- *
589
- * Returns null if the line is not an @export.
590
- */
591
- parseExportDirective(line) {
592
- const m = line.match(/^@export\s+([\w@,\s]+)/);
593
- if (!m) return null;
594
- return m[1].split(",").map((s) => s.trim().replace("@", "")).filter(Boolean);
595
- }
596
- /**
597
- * Parse a single trait composition assignment line.
598
- *
599
- * @turret = @physics + @ai_npc + @targeting
600
- *
601
- * This can appear anywhere in a HoloScript+ file body.
602
- * Returns null if the line is not a composition assignment.
603
- *
604
- * The returned AST node type is `'trait_composition'` and can be
605
- * emitted by callers into the broader AST to register composed traits.
606
- */
607
- parseCompositionDirective(line) {
608
- const m = line.trim().match(/^@(\w+)\s*=\s*((?:@\w+\s*\+\s*)*@\w+)/);
609
- if (!m) return null;
610
- const name = m[1];
611
- const sources = m[2].split("+").map((s) => s.trim().replace("@", "")).filter(Boolean);
612
- return { type: "trait_composition", name, sources };
613
- }
614
- /**
615
- * Scan an entire source string for trait composition assignments and return
616
- * all found definitions in document order.
617
- *
618
- * @param code Full HoloScript+ source
619
- * @returns Array of composition definitions ready for TraitBinder registration
620
- */
621
- parseCompositionBlock(code) {
622
- const results = [];
623
- for (const rawLine of code.split("\n")) {
624
- const node = this.parseCompositionDirective(rawLine.trim());
625
- if (node) results.push(node);
626
- }
627
- return results;
628
- }
629
- // ==========================================================================
630
- // Reactive State — state { } / on event { } (Sprint 3)
631
- // ==========================================================================
632
- /**
633
- * Parse a `state { ... }` block from HoloScript+ source.
634
- *
635
- * Accepted syntax:
636
- * state {
637
- * hp = 100
638
- * speed = 5.5
639
- * alive = true
640
- * name = "hero"
641
- * }
642
- *
643
- * The block may appear inline or multi-line. Values are coerced to their
644
- * inferred JS types (number, boolean, string). The returned list is ordered
645
- * by declaration order and is suitable for `new ReactiveState(entries)`.
646
- *
647
- * Returns null if no `state {` opener is found in the source.
648
- */
649
- parseStateBlock(code) {
650
- const m = code.match(/\bstate\s*\{([^}]*)\}/s);
651
- if (!m) return null;
652
- const body = m[1];
653
- const vars = [];
654
- for (const rawLine of body.split("\n")) {
655
- const line = rawLine.trim();
656
- if (!line || line.startsWith("//")) continue;
657
- const pair = line.match(/^(\w+)\s*=\s*(.+?)[\s;,]*$/);
658
- if (!pair) continue;
659
- const [, varName, rawVal] = pair;
660
- let value = rawVal.trim();
661
- if (rawVal === "true") value = true;
662
- else if (rawVal === "false") value = false;
663
- else if (!isNaN(Number(rawVal))) value = Number(rawVal);
664
- else if (/^["'](.*)["']$/.test(rawVal)) value = rawVal.slice(1, -1);
665
- vars.push({ name: varName, value });
666
- }
667
- return vars;
668
- }
669
- /**
670
- * Parse all `on <event> { ... }` handler blocks from HoloScript+ source.
671
- *
672
- * Accepted syntax:
673
- * on collide { hp = hp - 10 }
674
- * on death { alive = false }
675
- *
676
- * Returns an array of `{ event, body }` records ordered by appearance.
677
- * The `body` string is the raw block content suitable for ExpressionEvaluator.
678
- * Returns an empty array if no `on` blocks are found.
679
- */
680
- parseOnBlock(code) {
681
- const results = [];
682
- const pattern = /\bon\s+(\w+)\s*\{([^}]*)\}/gs;
683
- let m;
684
- while ((m = pattern.exec(code)) !== null) {
685
- const event = m[1];
686
- const body = m[2].trim();
687
- results.push({ event, body });
688
- }
689
- return results;
690
- }
691
- };
692
- var HoloScriptPlusParser_default = HoloScriptPlusParser;
693
-
694
- exports.HoloScriptPlusParser = HoloScriptPlusParser;
695
- exports.default = HoloScriptPlusParser_default;
696
- //# sourceMappingURL=HoloScriptPlusParser-NC5FE6AL.cjs.map
697
- //# sourceMappingURL=HoloScriptPlusParser-NC5FE6AL.cjs.map