@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,692 +0,0 @@
1
- import { MaterialTrait, LIGHTING_PRESETS, LightingTrait, RenderingTrait, SHADER_PRESETS, ShaderTrait } from './chunk-WYH4GVZ5.js';
2
- import { HoloScriptCodeParser } from './chunk-EPWRXL6S.js';
3
- import './chunk-PHENW4MQ.js';
4
- import './chunk-32TWR3HE.js';
5
-
6
- // src/HoloScriptPlusParser.ts
7
- var HoloScriptPlusParser = class {
8
- constructor() {
9
- this.baseParser = new HoloScriptCodeParser();
10
- }
11
- /**
12
- * Parse HoloScript+ code with trait annotations
13
- */
14
- parse(code) {
15
- const baseResult = this.baseParser.parse(code);
16
- const ast = baseResult.ast;
17
- return this.enhanceWithTraits(ast, code);
18
- }
19
- /**
20
- * Enhance AST nodes with trait annotations
21
- */
22
- enhanceWithTraits(ast, code) {
23
- return ast.map((node) => {
24
- if (node.type === "orb") {
25
- return this.enhanceOrbNodeWithTraits(node, code);
26
- }
27
- return node;
28
- });
29
- }
30
- /**
31
- * Enhance OrbNode with trait annotations
32
- */
33
- enhanceOrbNodeWithTraits(node, code) {
34
- const orbNode = node;
35
- const enhanced = {
36
- ...orbNode,
37
- traits: [],
38
- graphics: {}
39
- };
40
- const traits = this.extractTraitAnnotations(code, node.line);
41
- enhanced.traits = traits;
42
- if (traits.length > 0) {
43
- enhanced.graphics = this.buildGraphicsConfig(traits);
44
- }
45
- return enhanced;
46
- }
47
- /**
48
- * Extract trait annotations from code
49
- */
50
- extractTraitAnnotations(code, _orbLine) {
51
- const traits = [];
52
- const traitRegex = /@(material|lighting|rendering|shader|networked|rpc|joint|ik)\s*\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/g;
53
- let match;
54
- while ((match = traitRegex.exec(code)) !== null) {
55
- const type = match[1];
56
- const configStr = match[2];
57
- try {
58
- const config = this.parseTraitConfig(configStr, type);
59
- switch (type) {
60
- case "material":
61
- traits.push({
62
- type: "material",
63
- config
64
- });
65
- break;
66
- case "lighting":
67
- traits.push({
68
- type: "lighting",
69
- config
70
- });
71
- break;
72
- case "rendering":
73
- traits.push({
74
- type: "rendering",
75
- config
76
- });
77
- break;
78
- case "shader":
79
- traits.push({
80
- type: "shader",
81
- config
82
- });
83
- break;
84
- case "networked":
85
- traits.push({
86
- type: "networked",
87
- config
88
- });
89
- break;
90
- case "rpc":
91
- traits.push({
92
- type: "rpc",
93
- config
94
- });
95
- break;
96
- case "joint":
97
- traits.push({
98
- type: "joint",
99
- config
100
- });
101
- break;
102
- case "ik":
103
- traits.push({
104
- type: "ik",
105
- config
106
- });
107
- break;
108
- }
109
- } catch (e) {
110
- console.warn(`Failed to parse ${type} trait annotation:`, e);
111
- }
112
- }
113
- return traits;
114
- }
115
- /**
116
- * Parse trait configuration with support for inline code (backticks)
117
- */
118
- parseTraitConfig(str, traitType) {
119
- if (traitType === "shader") {
120
- return this.parseShaderConfig(str);
121
- }
122
- return this.parseObjectLiteral(str);
123
- }
124
- /**
125
- * Parse shader configuration with inline GLSL support
126
- */
127
- parseShaderConfig(str) {
128
- const config = {};
129
- const backtickStrings = [];
130
- const processedStr = str.replace(/`([^`]*)`/g, (_, content) => {
131
- backtickStrings.push(content);
132
- return `__BACKTICK_${backtickStrings.length - 1}__`;
133
- });
134
- const parsed = this.parseObjectLiteral(processedStr);
135
- for (const [key, value] of Object.entries(parsed)) {
136
- if (typeof value === "string" && value.startsWith("__BACKTICK_")) {
137
- const index = parseInt(value.replace("__BACKTICK_", "").replace("__", ""));
138
- config[key] = backtickStrings[index];
139
- } else {
140
- config[key] = value;
141
- }
142
- }
143
- return config;
144
- }
145
- /**
146
- * Parse object literal from string
147
- * Supports nested objects and arrays
148
- */
149
- parseObjectLiteral(str) {
150
- const config = {};
151
- let depth = 0;
152
- let current = "";
153
- const pairs = [];
154
- for (let i = 0; i < str.length; i++) {
155
- const char = str[i];
156
- if (char === "{" || char === "[") {
157
- depth++;
158
- } else if (char === "}" || char === "]") {
159
- depth--;
160
- } else if (char === "," && depth === 0) {
161
- pairs.push(current.trim());
162
- current = "";
163
- continue;
164
- }
165
- current += char;
166
- }
167
- if (current.trim()) {
168
- pairs.push(current.trim());
169
- }
170
- for (const pair of pairs) {
171
- const colonIndex = pair.indexOf(":");
172
- if (colonIndex === -1) continue;
173
- const key = pair.substring(0, colonIndex).trim();
174
- const value = pair.substring(colonIndex + 1).trim();
175
- config[key] = this.parseValue(value);
176
- }
177
- return config;
178
- }
179
- /**
180
- * Parse individual values
181
- */
182
- parseValue(str) {
183
- str = str.trim();
184
- if (str === "true") return true;
185
- if (str === "false") return false;
186
- if (/^-?\d+(\.\d+)?$/.test(str)) return parseFloat(str);
187
- if (str.startsWith('"') && str.endsWith('"') || str.startsWith("'") && str.endsWith("'")) {
188
- return str.slice(1, -1);
189
- }
190
- if (str.startsWith("{") && str.endsWith("}")) {
191
- return this.parseObjectLiteral(str.slice(1, -1));
192
- }
193
- if (str.startsWith("[") && str.endsWith("]")) {
194
- const items = str.slice(1, -1).split(",");
195
- return items.map((item) => this.parseValue(item));
196
- }
197
- return str;
198
- }
199
- /**
200
- * Build GraphicsConfiguration from trait annotations
201
- */
202
- buildGraphicsConfig(traits) {
203
- const config = {};
204
- for (const trait of traits) {
205
- switch (trait.type) {
206
- case "material":
207
- config.material = trait.config;
208
- break;
209
- case "lighting":
210
- config.lighting = trait.config;
211
- break;
212
- case "rendering":
213
- config.rendering = trait.config;
214
- break;
215
- case "shader":
216
- config.shader = trait.config;
217
- break;
218
- case "networked":
219
- config.networked = trait.config;
220
- break;
221
- case "rpc":
222
- config.rpc = trait.config;
223
- break;
224
- case "joint":
225
- config.joint = trait.config;
226
- break;
227
- case "ik":
228
- config.ik = trait.config;
229
- break;
230
- }
231
- }
232
- return config;
233
- }
234
- /**
235
- * Validate trait annotation configuration
236
- */
237
- validateTraitAnnotation(trait) {
238
- const errors = [];
239
- switch (trait.type) {
240
- case "material":
241
- errors.push(...this.validateMaterialTrait(trait));
242
- break;
243
- case "lighting":
244
- errors.push(...this.validateLightingTrait(trait));
245
- break;
246
- case "rendering":
247
- errors.push(...this.validateRenderingTrait(trait));
248
- break;
249
- case "shader":
250
- errors.push(...this.validateShaderTrait(trait));
251
- break;
252
- case "networked":
253
- errors.push(...this.validateNetworkedTrait(trait));
254
- break;
255
- case "joint":
256
- errors.push(...this.validateJointTrait(trait));
257
- break;
258
- case "ik":
259
- errors.push(...this.validateIKTrait(trait));
260
- break;
261
- }
262
- return {
263
- valid: errors.length === 0,
264
- errors
265
- };
266
- }
267
- /**
268
- * Validate material trait configuration
269
- */
270
- validateMaterialTrait(trait) {
271
- const errors = [];
272
- const { config } = trait;
273
- if (config.pbr) {
274
- if (config.pbr.metallic !== void 0 && (config.pbr.metallic < 0 || config.pbr.metallic > 1)) {
275
- errors.push("material.pbr.metallic must be between 0 and 1");
276
- }
277
- if (config.pbr.roughness !== void 0 && (config.pbr.roughness < 0 || config.pbr.roughness > 1)) {
278
- errors.push("material.pbr.roughness must be between 0 and 1");
279
- }
280
- }
281
- if (config.compression && !["none", "dxt", "astc", "basis"].includes(config.compression)) {
282
- errors.push(`material.compression must be one of: none, dxt, astc, basis`);
283
- }
284
- return errors;
285
- }
286
- /**
287
- * Validate lighting trait configuration
288
- */
289
- validateLightingTrait(trait) {
290
- const errors = [];
291
- const { config } = trait;
292
- if (config.preset && !["studio", "outdoor", "interior", "night", "sunset"].includes(config.preset)) {
293
- errors.push("lighting.preset must be one of: studio, outdoor, interior, night, sunset");
294
- }
295
- if (config.lights) {
296
- config.lights.forEach((light, index) => {
297
- if (!["directional", "point", "spot", "area", "ambient"].includes(light.type)) {
298
- errors.push(`lighting.lights[${index}].type must be a valid light type`);
299
- }
300
- if (light.intensity !== void 0 && light.intensity < 0) {
301
- errors.push(`lighting.lights[${index}].intensity must be >= 0`);
302
- }
303
- });
304
- }
305
- return errors;
306
- }
307
- /**
308
- * Validate rendering trait configuration
309
- */
310
- validateRenderingTrait(trait) {
311
- const errors = [];
312
- const { config } = trait;
313
- if (config.quality && !["low", "medium", "high", "ultra"].includes(config.quality)) {
314
- errors.push("rendering.quality must be one of: low, medium, high, ultra");
315
- }
316
- if (config.platform && !["mobile", "vr", "desktop"].includes(config.platform)) {
317
- errors.push("rendering.platform must be one of: mobile, vr, desktop");
318
- }
319
- if (config.compression && !["none", "dxt", "astc", "basis"].includes(config.compression)) {
320
- errors.push("rendering.compression must be one of: none, dxt, astc, basis");
321
- }
322
- if (config.maxTextureResolution && config.maxTextureResolution < 128) {
323
- errors.push("rendering.maxTextureResolution must be >= 128");
324
- }
325
- if (config.targetFPS && (config.targetFPS < 24 || config.targetFPS > 240)) {
326
- errors.push("rendering.targetFPS must be between 24 and 240");
327
- }
328
- return errors;
329
- }
330
- /**
331
- * Get trait annotations as graphics traits
332
- */
333
- createGraphicsTraits(config) {
334
- return {
335
- material: config.material ? this.createMaterialTrait(config.material) : null,
336
- lighting: config.lighting ? this.createLightingTrait(config.lighting) : null,
337
- rendering: config.rendering ? this.createRenderingTrait(config.rendering) : null,
338
- shader: config.shader ? this.createShaderTrait(config.shader) : null
339
- };
340
- }
341
- /**
342
- * Create MaterialTrait from config
343
- */
344
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic material config from parsed AST
345
- createMaterialTrait(config) {
346
- const material = new MaterialTrait({
347
- type: config.type || "pbr",
348
- pbr: config.pbr
349
- });
350
- if (config.compression) {
351
- material.setCompression(config.compression);
352
- }
353
- if (config.instancing) {
354
- material.setInstanced(true);
355
- }
356
- if (config.streaming) {
357
- material.setTextureStreaming(true);
358
- }
359
- if (config.textures) {
360
- config.textures.forEach((tex) => {
361
- material.addTexture(tex);
362
- });
363
- }
364
- return material;
365
- }
366
- /**
367
- * Create LightingTrait from config
368
- */
369
- createLightingTrait(config) {
370
- let lighting;
371
- if (config.preset) {
372
- const presetFactory = LIGHTING_PRESETS[config.preset];
373
- const presetConfig = presetFactory ? presetFactory() : void 0;
374
- lighting = new LightingTrait(presetConfig);
375
- } else {
376
- lighting = new LightingTrait();
377
- }
378
- if (config.globalIllumination) {
379
- lighting.setGlobalIllumination(config.globalIllumination);
380
- }
381
- if (config.lights) {
382
- config.lights.forEach((light) => {
383
- lighting.addLight(light);
384
- });
385
- }
386
- return lighting;
387
- }
388
- /**
389
- * Create RenderingTrait from config
390
- */
391
- createRenderingTrait(config) {
392
- const rendering = new RenderingTrait();
393
- if (config.quality) {
394
- rendering.applyQualityPreset(config.quality);
395
- }
396
- if (config.platform) {
397
- switch (config.platform) {
398
- case "mobile":
399
- rendering.optimizeForMobile();
400
- break;
401
- case "vr":
402
- rendering.optimizeForVRAR(config.targetFPS || 90);
403
- break;
404
- case "desktop":
405
- rendering.optimizeForDesktop();
406
- break;
407
- }
408
- }
409
- if (config.lod !== false) {
410
- rendering.setupLODLevels("automatic");
411
- }
412
- if (config.culling !== false) {
413
- rendering.setFrustumCulling(true);
414
- }
415
- if (config.compression) {
416
- rendering.setTextureCompression(config.compression);
417
- }
418
- if (config.maxTextureResolution) {
419
- rendering.setMaxTextureResolution(config.maxTextureResolution);
420
- }
421
- return rendering;
422
- }
423
- /**
424
- * Create ShaderTrait from config
425
- */
426
- createShaderTrait(config) {
427
- if (config.preset && SHADER_PRESETS[config.preset]) {
428
- const preset = SHADER_PRESETS[config.preset];
429
- return new ShaderTrait(preset);
430
- }
431
- const shaderConfig = {
432
- source: {
433
- language: config.language || "glsl",
434
- vertex: config.vertex,
435
- fragment: config.fragment
436
- },
437
- uniforms: config.uniforms,
438
- includes: config.includes?.map((path) => ({ path })),
439
- blendMode: config.blendMode,
440
- depthTest: config.depthTest,
441
- depthWrite: config.depthWrite,
442
- cullFace: config.cullFace
443
- };
444
- return new ShaderTrait(shaderConfig);
445
- }
446
- /**
447
- * Validate shader trait configuration
448
- */
449
- validateShaderTrait(trait) {
450
- const errors = [];
451
- const { config } = trait;
452
- if (!config.preset && !config.vertex && !config.fragment) {
453
- errors.push("shader must have either preset or vertex/fragment code");
454
- }
455
- if (config.preset && !SHADER_PRESETS[config.preset]) {
456
- errors.push(
457
- `shader.preset "${config.preset}" is not a valid preset. Available: hologram, forceField, dissolve`
458
- );
459
- }
460
- if (config.language && !["glsl", "hlsl", "wgsl"].includes(config.language)) {
461
- errors.push("shader.language must be one of: glsl, hlsl, wgsl");
462
- }
463
- if (config.blendMode && !["opaque", "blend", "additive", "multiply"].includes(config.blendMode)) {
464
- errors.push("shader.blendMode must be one of: opaque, blend, additive, multiply");
465
- }
466
- if (config.cullFace && !["none", "front", "back"].includes(config.cullFace)) {
467
- errors.push("shader.cullFace must be one of: none, front, back");
468
- }
469
- return errors;
470
- }
471
- /**
472
- * Validate networked trait configuration
473
- */
474
- validateNetworkedTrait(trait) {
475
- const errors = [];
476
- const { config } = trait;
477
- if (config.mode && !["owner", "shared", "server"].includes(config.mode)) {
478
- errors.push("networked.mode must be one of: owner, shared, server");
479
- }
480
- if (config.syncRate !== void 0 && (config.syncRate < 1 || config.syncRate > 60)) {
481
- errors.push("networked.syncRate must be between 1 and 60 Hz");
482
- }
483
- return errors;
484
- }
485
- /**
486
- * Validate joint trait configuration
487
- */
488
- validateJointTrait(trait) {
489
- const errors = [];
490
- const { config } = trait;
491
- if (!config.jointType) {
492
- errors.push("joint.jointType is required");
493
- } else if (!["fixed", "hinge", "ball", "slider", "spring"].includes(config.jointType)) {
494
- errors.push("joint.jointType must be one of: fixed, hinge, ball, slider, spring");
495
- }
496
- if (config.breakForce !== void 0 && config.breakForce < 0) {
497
- errors.push("joint.breakForce must be >= 0");
498
- }
499
- return errors;
500
- }
501
- /**
502
- * Validate IK trait configuration
503
- */
504
- validateIKTrait(trait) {
505
- const errors = [];
506
- const { config } = trait;
507
- if (!config.chain) {
508
- errors.push("ik.chain is required");
509
- }
510
- if (config.chainLength !== void 0 && config.chainLength < 1) {
511
- errors.push("ik.chainLength must be >= 1");
512
- }
513
- if (config.iterations !== void 0 && config.iterations < 1) {
514
- errors.push("ik.iterations must be >= 1");
515
- }
516
- if (config.weight !== void 0 && (config.weight < 0 || config.weight > 1)) {
517
- errors.push("ik.weight must be between 0 and 1");
518
- }
519
- return errors;
520
- }
521
- // ==========================================================================
522
- // Module System — @import / @export
523
- // ==========================================================================
524
- /**
525
- * Parse HoloScript+ code and also extract module-level @import / @export
526
- * declarations from the source header.
527
- *
528
- * Returns both the enhanced AST and a structured module header so callers
529
- * (e.g. ModuleResolver, SceneRunner) can understand the file's dependencies
530
- * without running a separate pass.
531
- */
532
- parseWithModules(code, fromFile = "<inline>") {
533
- const ast = this.parse(code);
534
- const { imports, exports: exports$1 } = this.parseModuleHeader(code, fromFile);
535
- return { ast, imports, exports: exports$1 };
536
- }
537
- /**
538
- * Scan the top of a source string and return all @import / @export
539
- * declarations before the first non-directive, non-comment line.
540
- */
541
- parseModuleHeader(code, _fromFile = "<inline>") {
542
- const imports = [];
543
- const exports$1 = [];
544
- for (const rawLine of code.split("\n")) {
545
- const line = rawLine.trim();
546
- if (!line || line.startsWith("//") || line.startsWith("#")) continue;
547
- const imp = this.parseImportDirective(line);
548
- if (imp) {
549
- imports.push(imp);
550
- continue;
551
- }
552
- const exp = this.parseExportDirective(line);
553
- if (exp) {
554
- exports$1.push(...exp);
555
- continue;
556
- }
557
- break;
558
- }
559
- return { imports, exports: exports$1 };
560
- }
561
- /**
562
- * Parse a single @import directive line.
563
- *
564
- * Accepted forms:
565
- * @import @physics, @ai_npc from "./physics.hs"
566
- * @import * from "./shared.hs"
567
- * @import @physics as @p from "./physics.hs"
568
- *
569
- * Returns null if the line is not an @import.
570
- */
571
- parseImportDirective(line) {
572
- const m = line.match(/^@import\s+([\w@*,\s]+?)(?:\s+as\s+(@\w+))?\s+from\s+["']([^"']+)["']/);
573
- if (!m) return null;
574
- const specifiersPart = m[1].trim();
575
- const alias = m[2]?.replace("@", "");
576
- const source = m[3];
577
- const specifiers = specifiersPart === "*" ? ["*"] : specifiersPart.split(",").map((s) => s.trim().replace("@", "")).filter(Boolean);
578
- return { specifiers, source, ...alias ? { alias } : {} };
579
- }
580
- /**
581
- * Parse a single @export directive line.
582
- *
583
- * @export @turret, @enemy
584
- *
585
- * Returns null if the line is not an @export.
586
- */
587
- parseExportDirective(line) {
588
- const m = line.match(/^@export\s+([\w@,\s]+)/);
589
- if (!m) return null;
590
- return m[1].split(",").map((s) => s.trim().replace("@", "")).filter(Boolean);
591
- }
592
- /**
593
- * Parse a single trait composition assignment line.
594
- *
595
- * @turret = @physics + @ai_npc + @targeting
596
- *
597
- * This can appear anywhere in a HoloScript+ file body.
598
- * Returns null if the line is not a composition assignment.
599
- *
600
- * The returned AST node type is `'trait_composition'` and can be
601
- * emitted by callers into the broader AST to register composed traits.
602
- */
603
- parseCompositionDirective(line) {
604
- const m = line.trim().match(/^@(\w+)\s*=\s*((?:@\w+\s*\+\s*)*@\w+)/);
605
- if (!m) return null;
606
- const name = m[1];
607
- const sources = m[2].split("+").map((s) => s.trim().replace("@", "")).filter(Boolean);
608
- return { type: "trait_composition", name, sources };
609
- }
610
- /**
611
- * Scan an entire source string for trait composition assignments and return
612
- * all found definitions in document order.
613
- *
614
- * @param code Full HoloScript+ source
615
- * @returns Array of composition definitions ready for TraitBinder registration
616
- */
617
- parseCompositionBlock(code) {
618
- const results = [];
619
- for (const rawLine of code.split("\n")) {
620
- const node = this.parseCompositionDirective(rawLine.trim());
621
- if (node) results.push(node);
622
- }
623
- return results;
624
- }
625
- // ==========================================================================
626
- // Reactive State — state { } / on event { } (Sprint 3)
627
- // ==========================================================================
628
- /**
629
- * Parse a `state { ... }` block from HoloScript+ source.
630
- *
631
- * Accepted syntax:
632
- * state {
633
- * hp = 100
634
- * speed = 5.5
635
- * alive = true
636
- * name = "hero"
637
- * }
638
- *
639
- * The block may appear inline or multi-line. Values are coerced to their
640
- * inferred JS types (number, boolean, string). The returned list is ordered
641
- * by declaration order and is suitable for `new ReactiveState(entries)`.
642
- *
643
- * Returns null if no `state {` opener is found in the source.
644
- */
645
- parseStateBlock(code) {
646
- const m = code.match(/\bstate\s*\{([^}]*)\}/s);
647
- if (!m) return null;
648
- const body = m[1];
649
- const vars = [];
650
- for (const rawLine of body.split("\n")) {
651
- const line = rawLine.trim();
652
- if (!line || line.startsWith("//")) continue;
653
- const pair = line.match(/^(\w+)\s*=\s*(.+?)[\s;,]*$/);
654
- if (!pair) continue;
655
- const [, varName, rawVal] = pair;
656
- let value = rawVal.trim();
657
- if (rawVal === "true") value = true;
658
- else if (rawVal === "false") value = false;
659
- else if (!isNaN(Number(rawVal))) value = Number(rawVal);
660
- else if (/^["'](.*)["']$/.test(rawVal)) value = rawVal.slice(1, -1);
661
- vars.push({ name: varName, value });
662
- }
663
- return vars;
664
- }
665
- /**
666
- * Parse all `on <event> { ... }` handler blocks from HoloScript+ source.
667
- *
668
- * Accepted syntax:
669
- * on collide { hp = hp - 10 }
670
- * on death { alive = false }
671
- *
672
- * Returns an array of `{ event, body }` records ordered by appearance.
673
- * The `body` string is the raw block content suitable for ExpressionEvaluator.
674
- * Returns an empty array if no `on` blocks are found.
675
- */
676
- parseOnBlock(code) {
677
- const results = [];
678
- const pattern = /\bon\s+(\w+)\s*\{([^}]*)\}/gs;
679
- let m;
680
- while ((m = pattern.exec(code)) !== null) {
681
- const event = m[1];
682
- const body = m[2].trim();
683
- results.push({ event, body });
684
- }
685
- return results;
686
- }
687
- };
688
- var HoloScriptPlusParser_default = HoloScriptPlusParser;
689
-
690
- export { HoloScriptPlusParser, HoloScriptPlusParser_default as default };
691
- //# sourceMappingURL=HoloScriptPlusParser-BZR5DELQ.js.map
692
- //# sourceMappingURL=HoloScriptPlusParser-BZR5DELQ.js.map