@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,749 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkHHS6FMOU_cjs = require('./chunk-HHS6FMOU.cjs');
4
- var chunkQHVVVN47_cjs = require('./chunk-QHVVVN47.cjs');
5
- var chunkEGIZHYJP_cjs = require('./chunk-EGIZHYJP.cjs');
6
-
7
- // src/compiler/VRRCompiler.ts
8
- var VRRCompiler_exports = {};
9
- chunkEGIZHYJP_cjs.__export(VRRCompiler_exports, {
10
- VRRCompiler: () => exports.VRRCompiler,
11
- default: () => exports.VRRCompiler_default
12
- });
13
- var VRRTraitDefs; exports.VRRCompiler = void 0; exports.VRRCompiler_default = void 0;
14
- var init_VRRCompiler = chunkEGIZHYJP_cjs.__esm({
15
- "src/compiler/VRRCompiler.ts"() {
16
- chunkQHVVVN47_cjs.init_CompilerBase();
17
- chunkQHVVVN47_cjs.init_ANSNamespace();
18
- chunkHHS6FMOU_cjs.init_DomainBlockCompilerMixin();
19
- VRRTraitDefs = {
20
- vrr_twin: { validator: (p) => !!p.mirror },
21
- reality_mirror: { validator: (p) => Array.isArray(p.sync) && p.sync.length > 0 },
22
- geo_anchor: {
23
- validator: (p) => typeof p.lat === "number" && typeof p.lng === "number" && p.lat >= -90 && p.lat <= 90 && p.lng >= -180 && p.lng <= 180
24
- },
25
- weather_sync: { validator: (p) => ["weather.gov", "openweathermap"].includes(String(p.provider)) },
26
- event_sync: { validator: (p) => ["eventbrite", "ticketmaster"].includes(String(p.provider)) },
27
- inventory_sync: { validator: (p) => ["square_pos", "shopify", "woocommerce"].includes(String(p.provider)) },
28
- quest_hub: { validator: (p) => Array.isArray(p.quests) && p.quests.length > 0 },
29
- layer_shift: {
30
- validator: (p) => {
31
- const valid = ["ar", "vrr", "vr"];
32
- return valid.includes(String(p.from)) && valid.includes(String(p.to));
33
- }
34
- },
35
- x402_paywall: {
36
- validator: (p) => Number(p.price) > 0 && ["USDC", "ETH", "SOL"].includes(String(p.asset || "USDC")) && ["base", "ethereum", "solana"].includes(String(p.network || "base"))
37
- },
38
- geo_sync: { validator: (p) => !!p.center && Number(p.radius || 0) >= 0 }
39
- };
40
- exports.VRRCompiler = class extends chunkQHVVVN47_cjs.CompilerBase {
41
- constructor(options) {
42
- super();
43
- this.compilerName = "VRRCompiler";
44
- this.errors = [];
45
- this.warnings = [];
46
- this.generatedCode = [];
47
- this.options = options;
48
- }
49
- getRequiredCapability() {
50
- return chunkQHVVVN47_cjs.ANSCapabilityPath.VRR;
51
- }
52
- // ─── 1. parseVRRComposition ───────────────────────────────────────────
53
- /**
54
- * Parse a HoloScript AST and extract VRR-specific traits.
55
- * Walks AST nodes, collects trait annotations, validates params against VRRTraits definitions.
56
- */
57
- parseVRRComposition(composition) {
58
- const data = {
59
- twinNodes: [],
60
- weatherNodes: [],
61
- eventNodes: [],
62
- inventoryNodes: [],
63
- questNodes: [],
64
- layerShiftNodes: [],
65
- paywallNodes: [],
66
- geoAnchorNodes: []
67
- };
68
- const traitToField = {
69
- vrr_twin: "twinNodes",
70
- weather_sync: "weatherNodes",
71
- event_sync: "eventNodes",
72
- inventory_sync: "inventoryNodes",
73
- quest_hub: "questNodes",
74
- layer_shift: "layerShiftNodes",
75
- x402_paywall: "paywallNodes",
76
- geo_anchor: "geoAnchorNodes"
77
- };
78
- const traverse = (node) => {
79
- if (!node || typeof node !== "object") return;
80
- const n = node;
81
- if (n.traits && Array.isArray(n.traits)) {
82
- for (const trait of n.traits) {
83
- const field = traitToField[trait.name];
84
- if (field) {
85
- const traitDef = VRRTraitDefs[trait.name];
86
- if (traitDef?.validator && !traitDef.validator(trait.params)) {
87
- this.warnings.push(
88
- `@${trait.name} on "${n.name || "unnamed"}" has invalid params`
89
- );
90
- }
91
- data[field].push(n);
92
- }
93
- }
94
- }
95
- for (const key of Object.keys(n)) {
96
- const val = n[key];
97
- if (val && typeof val === "object") {
98
- if (Array.isArray(val)) {
99
- for (const item of val) {
100
- traverse(item);
101
- }
102
- } else {
103
- traverse(val);
104
- }
105
- }
106
- }
107
- };
108
- traverse(composition);
109
- return data;
110
- }
111
- // ─── 2. compileToThreeJS ──────────────────────────────────────────────
112
- /**
113
- * Generate a complete Three.js scene from VRR composition data.
114
- * Places objects using geo_anchor coordinates, sets up materials/lighting/camera.
115
- */
116
- compileToThreeJS(compositionData) {
117
- this.generatedCode.push(`
118
- // === Three.js Scene Generation ===`);
119
- this.generatedCode.push(`const ambientLight = new THREE.AmbientLight(0x404040, 0.6);`);
120
- this.generatedCode.push(`scene.add(ambientLight);`);
121
- this.generatedCode.push(
122
- `const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);`
123
- );
124
- this.generatedCode.push(`directionalLight.position.set(50, 200, 100);`);
125
- this.generatedCode.push(`directionalLight.castShadow = true;`);
126
- this.generatedCode.push(`scene.add(directionalLight);`);
127
- this.generatedCode.push(
128
- `const groundGeo = new THREE.PlaneGeometry(10000, 10000);`
129
- );
130
- this.generatedCode.push(
131
- `const groundMat = new THREE.MeshStandardMaterial({ color: 0x3a7d3a, roughness: 0.9 });`
132
- );
133
- this.generatedCode.push(
134
- `const ground = new THREE.Mesh(groundGeo, groundMat);`
135
- );
136
- this.generatedCode.push(`ground.rotation.x = -Math.PI / 2;`);
137
- this.generatedCode.push(`ground.receiveShadow = true;`);
138
- this.generatedCode.push(`scene.add(ground);`);
139
- this.generatedCode.push(`camera.position.set(0, 50, 100);`);
140
- this.generatedCode.push(`camera.lookAt(0, 0, 0);`);
141
- for (const node of compositionData.geoAnchorNodes) {
142
- const geoTrait = this.findTrait(node, "geo_anchor");
143
- if (!geoTrait) continue;
144
- const lat = Number(geoTrait.params.lat) || 0;
145
- const lng = Number(geoTrait.params.lng) || 0;
146
- const safeName = this.escapeStringValue(String(node.name || "geo_object"), "TypeScript");
147
- this.generatedCode.push(`
148
- // Geo-anchored: ${safeName} (${lat}, ${lng})`);
149
- this.generatedCode.push(
150
- `const marker_${safeName} = new THREE.Group();`
151
- );
152
- this.generatedCode.push(
153
- `marker_${safeName}.position.copy(vrr.geoToSceneCoords(${lat}, ${lng}));`
154
- );
155
- this.generatedCode.push(
156
- `marker_${safeName}.userData.geo = { lat: ${lat}, lng: ${lng} };`
157
- );
158
- this.generatedCode.push(`phoenix_downtown.add(marker_${safeName});`);
159
- }
160
- this.generatedCode.push(`
161
- // Skybox`);
162
- this.generatedCode.push(
163
- `scene.background = new THREE.Color(0x87ceeb);`
164
- );
165
- this.generatedCode.push(`
166
- // Render loop`);
167
- this.generatedCode.push(`renderer.shadowMap.enabled = true;`);
168
- this.generatedCode.push(
169
- `renderer.shadowMap.type = THREE.PCFSoftShadowMap;`
170
- );
171
- this.generatedCode.push(`function animate() {`);
172
- this.generatedCode.push(` requestAnimationFrame(animate);`);
173
- this.generatedCode.push(` vrr.tick();`);
174
- this.generatedCode.push(` renderer.render(scene, camera);`);
175
- this.generatedCode.push(`}`);
176
- this.generatedCode.push(`animate();`);
177
- }
178
- // ─── 3. generateWeatherSync ───────────────────────────────────────────
179
- /**
180
- * Generate code that connects to weather API and updates scene
181
- * lighting/particles/skybox based on real-time weather data.
182
- */
183
- generateWeatherSync(nodes) {
184
- if (nodes.length === 0) return;
185
- this.generatedCode.push(`
186
- // === @weather_sync \u2014 Real-Time Weather Integration ===`);
187
- for (const node of nodes) {
188
- const trait = this.findTrait(node, "weather_sync");
189
- if (!trait) continue;
190
- const provider = String(trait.params.provider || "weather.gov");
191
- const refresh = String(trait.params.refresh || "5_minutes");
192
- const safeName = this.escapeStringValue(String(node.name || "zone"), "TypeScript");
193
- this.generatedCode.push(`// Weather sync for "${safeName}" via ${provider}`);
194
- this.generatedCode.push(`const weatherSync_${safeName} = vrr.createWeatherSync({`);
195
- this.generatedCode.push(` provider: '${provider}',`);
196
- this.generatedCode.push(` refresh: '${refresh}',`);
197
- this.generatedCode.push(` location: vrr.getGeoCenter(),`);
198
- this.generatedCode.push(`});`);
199
- this.generatedCode.push(`const rainGeometry = new THREE.BufferGeometry();`);
200
- this.generatedCode.push(
201
- `const rainPositions = new Float32Array(3000 * 3);`
202
- );
203
- this.generatedCode.push(`for (let i = 0; i < 3000; i++) {`);
204
- this.generatedCode.push(
205
- ` rainPositions[i * 3] = (Math.random() - 0.5) * 500;`
206
- );
207
- this.generatedCode.push(
208
- ` rainPositions[i * 3 + 1] = Math.random() * 200;`
209
- );
210
- this.generatedCode.push(
211
- ` rainPositions[i * 3 + 2] = (Math.random() - 0.5) * 500;`
212
- );
213
- this.generatedCode.push(`}`);
214
- this.generatedCode.push(
215
- `rainGeometry.setAttribute('position', new THREE.BufferAttribute(rainPositions, 3));`
216
- );
217
- this.generatedCode.push(
218
- `const rainMaterial = new THREE.PointsMaterial({ color: 0xaaaaaa, size: 0.1, transparent: true });`
219
- );
220
- this.generatedCode.push(
221
- `const rainSystem = new THREE.Points(rainGeometry, rainMaterial);`
222
- );
223
- this.generatedCode.push(`rainSystem.visible = false;`);
224
- this.generatedCode.push(`scene.add(rainSystem);`);
225
- this.generatedCode.push(`weatherSync_${safeName}.onUpdate((weather) => {`);
226
- this.generatedCode.push(
227
- ` // Update fog based on visibility`
228
- );
229
- this.generatedCode.push(
230
- ` scene.fog = new THREE.Fog(0xcccccc, 10, Math.max(weather.visibility, 50));`
231
- );
232
- this.generatedCode.push(` // Toggle rain particles`);
233
- this.generatedCode.push(
234
- ` rainSystem.visible = weather.precipitation > 0;`
235
- );
236
- this.generatedCode.push(` // Adjust sun intensity based on cloud cover`);
237
- this.generatedCode.push(
238
- ` directionalLight.intensity = Math.max(0.2, 1.0 - (weather.cloud_cover || 0) / 100);`
239
- );
240
- this.generatedCode.push(` // Update skybox color`);
241
- this.generatedCode.push(
242
- ` const skyHue = weather.precipitation > 50 ? 0x666680 : 0x87ceeb;`
243
- );
244
- this.generatedCode.push(
245
- ` scene.background = new THREE.Color(skyHue);`
246
- );
247
- this.generatedCode.push(` // Temperature-based ambient tint`);
248
- this.generatedCode.push(
249
- ` const tempNorm = Math.max(0, Math.min(1, (weather.temperature_f || 70) / 120));`
250
- );
251
- this.generatedCode.push(
252
- ` ambientLight.color.setHSL(0.6 - tempNorm * 0.4, 0.3, 0.4);`
253
- );
254
- this.generatedCode.push(`});`);
255
- }
256
- }
257
- // ─── 4. generateEventSync ─────────────────────────────────────────────
258
- /**
259
- * Generate code that fetches events from providers (Eventbrite/Ticketmaster)
260
- * and creates event markers + UI overlays in the scene.
261
- */
262
- generateEventSync(nodes) {
263
- if (nodes.length === 0) return;
264
- this.generatedCode.push(`
265
- // === @event_sync \u2014 Real-Time Event Integration ===`);
266
- for (const node of nodes) {
267
- const trait = this.findTrait(node, "event_sync");
268
- if (!trait) continue;
269
- const provider = String(trait.params.provider || "eventbrite");
270
- const refresh = String(trait.params.refresh || "5_minutes");
271
- const safeName = this.escapeStringValue(String(node.name || "zone"), "TypeScript");
272
- this.generatedCode.push(`// Event sync for "${safeName}" via ${provider}`);
273
- this.generatedCode.push(`const eventSync_${safeName} = vrr.createEventSync({`);
274
- this.generatedCode.push(` provider: '${provider}',`);
275
- this.generatedCode.push(` refresh: '${refresh}',`);
276
- this.generatedCode.push(` location: vrr.getGeoCenter(),`);
277
- this.generatedCode.push(`});`);
278
- this.generatedCode.push(`const eventMarkers_${safeName} = new THREE.Group();`);
279
- this.generatedCode.push(`scene.add(eventMarkers_${safeName});`);
280
- this.generatedCode.push(`eventSync_${safeName}.onUpdate((events) => {`);
281
- this.generatedCode.push(` // Clear previous markers`);
282
- this.generatedCode.push(` while (eventMarkers_${safeName}.children.length > 0) {`);
283
- this.generatedCode.push(` eventMarkers_${safeName}.remove(eventMarkers_${safeName}.children[0]);`);
284
- this.generatedCode.push(` }`);
285
- this.generatedCode.push(` for (const evt of events) {`);
286
- this.generatedCode.push(` // Create event marker billboard`);
287
- this.generatedCode.push(` const markerGeo = new THREE.CylinderGeometry(0.5, 0.5, 8, 8);`);
288
- this.generatedCode.push(
289
- ` const markerMat = new THREE.MeshStandardMaterial({ color: 0xff4444, emissive: 0x331111 });`
290
- );
291
- this.generatedCode.push(` const marker = new THREE.Mesh(markerGeo, markerMat);`);
292
- this.generatedCode.push(` if (evt.geo) {`);
293
- this.generatedCode.push(` marker.position.copy(vrr.geoToSceneCoords(evt.geo.lat, evt.geo.lng));`);
294
- this.generatedCode.push(` }`);
295
- this.generatedCode.push(` marker.userData.event = { name: evt.name, date: evt.date, url: evt.url };`);
296
- this.generatedCode.push(` eventMarkers_${safeName}.add(marker);`);
297
- this.generatedCode.push(` // Spawn NPC crowds for active events`);
298
- this.generatedCode.push(` if (evt.status === 'active') {`);
299
- this.generatedCode.push(` vrr.spawnNPCCrowd(marker.position, evt.expected_attendance || 20);`);
300
- this.generatedCode.push(` }`);
301
- this.generatedCode.push(` }`);
302
- this.generatedCode.push(`});`);
303
- }
304
- }
305
- // ─── 5. generateInventorySync ─────────────────────────────────────────
306
- /**
307
- * Generate code for real-time inventory display:
308
- * product counts, availability badges, stock-level indicators.
309
- */
310
- generateInventorySync(nodes) {
311
- if (nodes.length === 0) return;
312
- this.generatedCode.push(`
313
- // === @inventory_sync \u2014 Real-Time Inventory Display ===`);
314
- for (const node of nodes) {
315
- const trait = this.findTrait(node, "inventory_sync");
316
- if (!trait) continue;
317
- const provider = String(trait.params.provider || "square_pos");
318
- const refresh = String(trait.params.refresh || "1_minute");
319
- const useWebSocket = Boolean(trait.params.websocket);
320
- const safeName = this.escapeStringValue(String(node.name || "shop"), "TypeScript");
321
- this.generatedCode.push(`// Inventory sync for "${safeName}" via ${provider}`);
322
- this.generatedCode.push(`const inventorySync_${safeName} = vrr.createInventorySync({`);
323
- this.generatedCode.push(` provider: '${provider}',`);
324
- this.generatedCode.push(` refresh: '${refresh}',`);
325
- this.generatedCode.push(` websocket: ${useWebSocket},`);
326
- this.generatedCode.push(` business_id: '${safeName}',`);
327
- this.generatedCode.push(`});`);
328
- this.generatedCode.push(`const inventoryUI_${safeName} = new THREE.Group();`);
329
- this.generatedCode.push(`phoenix_downtown.add(inventoryUI_${safeName});`);
330
- this.generatedCode.push(`inventorySync_${safeName}.onUpdate((inventory) => {`);
331
- this.generatedCode.push(` // Clear previous inventory display`);
332
- this.generatedCode.push(` while (inventoryUI_${safeName}.children.length > 0) {`);
333
- this.generatedCode.push(` inventoryUI_${safeName}.remove(inventoryUI_${safeName}.children[0]);`);
334
- this.generatedCode.push(` }`);
335
- this.generatedCode.push(` for (const item of inventory.items) {`);
336
- this.generatedCode.push(` // Availability badge color: green=in-stock, yellow=low, red=out`);
337
- this.generatedCode.push(` const badgeColor = item.quantity > 10 ? 0x00ff00 : item.quantity > 0 ? 0xffaa00 : 0xff0000;`);
338
- this.generatedCode.push(` const badgeGeo = new THREE.SphereGeometry(0.3, 8, 8);`);
339
- this.generatedCode.push(` const badgeMat = new THREE.MeshStandardMaterial({ color: badgeColor, emissive: badgeColor, emissiveIntensity: 0.5 });`);
340
- this.generatedCode.push(` const badge = new THREE.Mesh(badgeGeo, badgeMat);`);
341
- this.generatedCode.push(` badge.userData.product = { name: item.name, quantity: item.quantity, price: item.price };`);
342
- this.generatedCode.push(` inventoryUI_${safeName}.add(badge);`);
343
- this.generatedCode.push(` }`);
344
- this.generatedCode.push(`});`);
345
- }
346
- }
347
- // ─── 6. generateQuestLogic ────────────────────────────────────────────
348
- /**
349
- * Generate quest/gamification code: visit locations, collect items,
350
- * earn rewards, track progress across AR/VRR/VR layers.
351
- */
352
- generateQuestLogic(nodes) {
353
- if (nodes.length === 0) return;
354
- this.generatedCode.push(`
355
- // === @quest_hub \u2014 Business Quest Mechanics ===`);
356
- for (const node of nodes) {
357
- const trait = this.findTrait(node, "quest_hub");
358
- if (!trait) continue;
359
- const quests = Array.isArray(trait.params.quests) ? trait.params.quests : [];
360
- const safeName = this.escapeStringValue(String(node.name || "business"), "TypeScript");
361
- this.generatedCode.push(`// Quest hub: "${safeName}" with ${quests.length} quest(s)`);
362
- this.generatedCode.push(`const questHub_${safeName} = vrr.createQuestHub({`);
363
- this.generatedCode.push(` business_id: '${safeName}',`);
364
- this.generatedCode.push(` quests: ${JSON.stringify(quests)},`);
365
- this.generatedCode.push(`});`);
366
- this.generatedCode.push(`// Quest NPC beacon`);
367
- this.generatedCode.push(
368
- `const questBeacon_${safeName} = new THREE.PointLight(0xffdd00, 2, 30);`
369
- );
370
- this.generatedCode.push(
371
- `questBeacon_${safeName}.position.set(0, 5, 0);`
372
- );
373
- this.generatedCode.push(
374
- `if (marker_${safeName}) marker_${safeName}.add(questBeacon_${safeName});`
375
- );
376
- this.generatedCode.push(`questHub_${safeName}.onQuestStart((quest) => {`);
377
- this.generatedCode.push(` vrr.persistState('quest_progress_' + quest.id, {`);
378
- this.generatedCode.push(` started_at: Date.now(),`);
379
- this.generatedCode.push(` current_step: 0,`);
380
- this.generatedCode.push(` steps_completed: [],`);
381
- this.generatedCode.push(` });`);
382
- this.generatedCode.push(`});`);
383
- this.generatedCode.push(`questHub_${safeName}.onStepComplete((quest, stepIndex) => {`);
384
- this.generatedCode.push(` const state = vrr.getState('quest_progress_' + quest.id);`);
385
- this.generatedCode.push(` if (state) {`);
386
- this.generatedCode.push(` state.steps_completed.push(stepIndex);`);
387
- this.generatedCode.push(` state.current_step = stepIndex + 1;`);
388
- this.generatedCode.push(` vrr.persistState('quest_progress_' + quest.id, state);`);
389
- this.generatedCode.push(` }`);
390
- this.generatedCode.push(`});`);
391
- this.generatedCode.push(`questHub_${safeName}.onQuestComplete((quest, reward) => {`);
392
- this.generatedCode.push(` vrr.persistState('quest_progress_' + quest.id, {`);
393
- this.generatedCode.push(` completed_at: Date.now(),`);
394
- this.generatedCode.push(` reward_claimed: false,`);
395
- this.generatedCode.push(` });`);
396
- this.generatedCode.push(` // Grant reward (coupon, NFT, etc.)`);
397
- this.generatedCode.push(` vrr.grantReward(quest.id, reward);`);
398
- this.generatedCode.push(` // Visual celebration`);
399
- this.generatedCode.push(
400
- ` questBeacon_${safeName}.color.setHex(0x00ff00);`
401
- );
402
- this.generatedCode.push(`});`);
403
- }
404
- }
405
- // ─── 7. generateLayerShift ────────────────────────────────────────────
406
- /**
407
- * Generate AR/VRR/VR transition handlers with state persistence.
408
- * Preserves quest progress, inventory state, and player position across layers.
409
- */
410
- generateLayerShift(nodes) {
411
- if (nodes.length === 0) return;
412
- this.generatedCode.push(`
413
- // === @layer_shift \u2014 AR/VRR/VR Transition Handlers ===`);
414
- this.generatedCode.push(`const layerState = {`);
415
- this.generatedCode.push(` current: 'vrr',`);
416
- this.generatedCode.push(` persist: async (data) => {`);
417
- this.generatedCode.push(` // IndexedDB for client-side persistence`);
418
- this.generatedCode.push(` const db = await vrr.getIndexedDB('hololand_layers');`);
419
- this.generatedCode.push(` await db.put('layer_state', data);`);
420
- this.generatedCode.push(` // Server-side sync`);
421
- this.generatedCode.push(` await vrr.syncToServer('layer_state', data);`);
422
- this.generatedCode.push(` },`);
423
- this.generatedCode.push(` restore: async () => {`);
424
- this.generatedCode.push(` const db = await vrr.getIndexedDB('hololand_layers');`);
425
- this.generatedCode.push(` return await db.get('layer_state');`);
426
- this.generatedCode.push(` },`);
427
- this.generatedCode.push(`};`);
428
- for (const node of nodes) {
429
- const trait = this.findTrait(node, "layer_shift");
430
- if (!trait) continue;
431
- const from = String(trait.params.from || "ar");
432
- const to = String(trait.params.to || "vrr");
433
- const price = Number(trait.params.price) || 0;
434
- const persistState = trait.params.persist_state !== false;
435
- const safeName = this.escapeStringValue(String(node.name || "portal"), "TypeScript");
436
- this.generatedCode.push(`
437
- // Layer shift: ${from} -> ${to} (${safeName})`);
438
- this.generatedCode.push(`vrr.registerLayerShift({`);
439
- this.generatedCode.push(` id: '${safeName}',`);
440
- this.generatedCode.push(` from: '${from}',`);
441
- this.generatedCode.push(` to: '${to}',`);
442
- this.generatedCode.push(` price: ${price},`);
443
- this.generatedCode.push(` persist_state: ${persistState},`);
444
- this.generatedCode.push(` onTransition: async (player) => {`);
445
- if (persistState) {
446
- this.generatedCode.push(` // Save current state before transition`);
447
- this.generatedCode.push(` await layerState.persist({`);
448
- this.generatedCode.push(` player_position: player.position,`);
449
- this.generatedCode.push(` quest_progress: vrr.getAllQuestProgress(),`);
450
- this.generatedCode.push(` inventory: vrr.getPlayerInventory(),`);
451
- this.generatedCode.push(` layer_from: '${from}',`);
452
- this.generatedCode.push(` timestamp: Date.now(),`);
453
- this.generatedCode.push(` });`);
454
- }
455
- if (price > 0) {
456
- this.generatedCode.push(` // Require payment before transition`);
457
- this.generatedCode.push(
458
- ` const paid = await vrr.requirePayment({ price: ${price}, asset: 'USDC', network: 'base' });`
459
- );
460
- this.generatedCode.push(` if (!paid) return false;`);
461
- }
462
- this.generatedCode.push(` // Execute layer transition`);
463
- this.generatedCode.push(` layerState.current = '${to}';`);
464
- this.generatedCode.push(` vrr.transitionToLayer('${to}');`);
465
- this.generatedCode.push(` return true;`);
466
- this.generatedCode.push(` },`);
467
- this.generatedCode.push(` onArrive: async (player) => {`);
468
- if (persistState) {
469
- this.generatedCode.push(` // Restore state after transition`);
470
- this.generatedCode.push(` const saved = await layerState.restore();`);
471
- this.generatedCode.push(` if (saved) {`);
472
- this.generatedCode.push(` vrr.restoreQuestProgress(saved.quest_progress);`);
473
- this.generatedCode.push(` vrr.restorePlayerInventory(saved.inventory);`);
474
- this.generatedCode.push(` }`);
475
- }
476
- this.generatedCode.push(` },`);
477
- this.generatedCode.push(`});`);
478
- }
479
- }
480
- // ─── 8. generateX402Paywall ───────────────────────────────────────────
481
- /**
482
- * Generate payment requirement checks using x402 protocol.
483
- * Blocks content access until on-chain payment is verified.
484
- */
485
- generateX402Paywall(nodes) {
486
- if (nodes.length === 0) return;
487
- this.generatedCode.push(`
488
- // === @x402_paywall \u2014 Payment Requirement Checks ===`);
489
- for (const node of nodes) {
490
- const trait = this.findTrait(node, "x402_paywall");
491
- if (!trait) continue;
492
- const price = Number(trait.params.price) || 0;
493
- const asset = String(trait.params.asset || "USDC");
494
- const network = String(trait.params.network || "base");
495
- const safeName = this.escapeStringValue(String(node.name || "content"), "TypeScript");
496
- this.generatedCode.push(`// x402 paywall: "${safeName}" \u2014 ${price} ${asset} on ${network}`);
497
- this.generatedCode.push(`const paywall_${safeName} = vrr.createPaywall({`);
498
- this.generatedCode.push(` content_id: '${safeName}',`);
499
- this.generatedCode.push(` price: ${price},`);
500
- this.generatedCode.push(` asset: '${asset}',`);
501
- this.generatedCode.push(` network: '${network}',`);
502
- this.generatedCode.push(` on402: async (req) => {`);
503
- this.generatedCode.push(` // Return 402 Payment Required with payment details`);
504
- this.generatedCode.push(` return {`);
505
- this.generatedCode.push(` status: 402,`);
506
- this.generatedCode.push(` headers: {`);
507
- this.generatedCode.push(` 'X-Payment-Required': 'true',`);
508
- this.generatedCode.push(` 'X-Payment-Amount': '${price}',`);
509
- this.generatedCode.push(` 'X-Payment-Asset': '${asset}',`);
510
- this.generatedCode.push(` 'X-Payment-Network': '${network}',`);
511
- this.generatedCode.push(
512
- ` 'X-Payment-Address': vrr.getPaymentAddress('${safeName}'),`
513
- );
514
- this.generatedCode.push(` },`);
515
- this.generatedCode.push(` };`);
516
- this.generatedCode.push(` },`);
517
- this.generatedCode.push(` onPaymentVerified: (receipt) => {`);
518
- this.generatedCode.push(` vrr.persistState('paywall_${safeName}', {`);
519
- this.generatedCode.push(` paid: true,`);
520
- this.generatedCode.push(` tx_hash: receipt.tx_hash,`);
521
- this.generatedCode.push(` timestamp: Date.now(),`);
522
- this.generatedCode.push(` });`);
523
- this.generatedCode.push(` // Unlock content in scene`);
524
- this.generatedCode.push(` vrr.unlockContent('${safeName}');`);
525
- this.generatedCode.push(` },`);
526
- this.generatedCode.push(` onPaymentFailed: (error) => {`);
527
- this.generatedCode.push(` console.warn('Payment failed for ${safeName}:', error.message);`);
528
- this.generatedCode.push(` vrr.showPaywallUI('${safeName}', { price: ${price}, asset: '${asset}', network: '${network}' });`);
529
- this.generatedCode.push(` },`);
530
- this.generatedCode.push(`});`);
531
- }
532
- }
533
- // ─── Utility: find trait on node ──────────────────────────────────────
534
- findTrait(node, traitName) {
535
- if (!node.traits) return void 0;
536
- return node.traits.find((t) => t.name === traitName);
537
- }
538
- // ─── Main compile() ──────────────────────────────────────────────────
539
- compile(composition, agentToken, outputPath) {
540
- this.validateCompilerAccess(agentToken, outputPath);
541
- this.errors = [];
542
- this.warnings = [];
543
- this.generatedCode = [];
544
- if (!composition || composition.type !== "Composition") {
545
- this.errors.push("Invalid composition tree");
546
- return this.buildResult();
547
- }
548
- const compositionData = this.parseVRRComposition(composition);
549
- const twinNodes = compositionData.twinNodes;
550
- if (twinNodes.length === 0) {
551
- this.warnings.push(
552
- "No @vrr_twin traits found. Compiling as standard 3D instead of reality mirror."
553
- );
554
- }
555
- this.generateImports();
556
- this.generateSceneSetup();
557
- this.generateAPIHooks(twinNodes);
558
- this.compileToThreeJS(compositionData);
559
- this.generateWeatherSync(compositionData.weatherNodes);
560
- this.generateEventSync(compositionData.eventNodes);
561
- this.generateInventorySync(compositionData.inventoryNodes);
562
- this.generateQuestLogic(compositionData.questNodes);
563
- this.generateLayerShift(compositionData.layerShiftNodes);
564
- this.generateX402Paywall(compositionData.paywallNodes);
565
- const comp = composition;
566
- const domainBlocks = Array.isArray(comp.domainBlocks) ? comp.domainBlocks : [];
567
- if (domainBlocks.length > 0) {
568
- this.generatedCode.push("\n// === v4.2 Domain Blocks ===");
569
- const compiled = chunkHHS6FMOU_cjs.compileDomainBlocks(
570
- // @ts-expect-error During migration
571
- domainBlocks,
572
- {
573
- material: (block) => {
574
- const m = chunkHHS6FMOU_cjs.compileMaterialBlock(block);
575
- return `// VRR Material: "${this.escapeStringValue(m.name, "TypeScript")}" type=${m.type} baseColor=${m.baseColor || "none"}`;
576
- },
577
- physics: (block) => {
578
- const p = chunkHHS6FMOU_cjs.compilePhysicsBlock(block);
579
- return `// VRR Physics: ${p.keyword} "${p.name || ""}" colliders=${p.colliders?.length || 0}`;
580
- },
581
- vfx: (block) => {
582
- const ps = chunkHHS6FMOU_cjs.compileParticleBlock(block);
583
- return `// VRR Particles: "${this.escapeStringValue(ps.name, "TypeScript")}" rate=${ps.properties.rate || "default"}`;
584
- },
585
- audio: (block) => {
586
- const a = chunkHHS6FMOU_cjs.compileAudioSourceBlock(block);
587
- return `// VRR Audio: "${this.escapeStringValue(a.name, "TypeScript")}" clip=${a.properties.clip || "none"}`;
588
- },
589
- weather: (block) => {
590
- const w = chunkHHS6FMOU_cjs.compileWeatherBlock(block);
591
- return `// VRR Weather: ${w.keyword} layers=[${w.layers.map((l) => l.type).join(", ")}]`;
592
- }
593
- },
594
- (block) => `// Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "TypeScript")}"`
595
- );
596
- for (const line of compiled) {
597
- this.generatedCode.push(line);
598
- }
599
- }
600
- this.generatedCode.push(`
601
- // --- End of VRR Bindings --- //
602
- `);
603
- this.generatedCode.push(`scene.add(phoenix_downtown);`);
604
- return this.buildResult();
605
- }
606
- extractNodesWithTrait(astNode, traitName) {
607
- const matched = [];
608
- const cleanTraitName = traitName.startsWith("@") ? traitName.slice(1) : traitName;
609
- const traverse = (node) => {
610
- if (!node || typeof node !== "object") return;
611
- const n = node;
612
- if (n.traits && Array.isArray(n.traits) && n.traits.some((t) => t.name === cleanTraitName)) {
613
- matched.push(n);
614
- }
615
- for (const key of Object.keys(n)) {
616
- const val = n[key];
617
- if (typeof val === "object" && val !== null) {
618
- traverse(val);
619
- }
620
- }
621
- };
622
- traverse(astNode);
623
- return matched;
624
- }
625
- generateImports() {
626
- this.generatedCode.push(`import * as THREE from 'three';`);
627
- this.generatedCode.push(`import { VRRRuntime } from '@holoscript/runtime';`);
628
- }
629
- generateSceneSetup() {
630
- this.generatedCode.push(`
631
- // Initialize Scene`);
632
- this.generatedCode.push(`const scene = new THREE.Scene();`);
633
- this.generatedCode.push(
634
- `const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);`
635
- );
636
- this.generatedCode.push(`const renderer = new THREE.WebGLRenderer({ antialias: true });`);
637
- this.generatedCode.push(`renderer.setSize(window.innerWidth, window.innerHeight);`);
638
- this.generatedCode.push(`document.body.appendChild(renderer.domElement);`);
639
- }
640
- generateAPIHooks(twinNodes) {
641
- this.generatedCode.push(`
642
- // Engine Initialization via @vrr_twin`);
643
- let geoCenter = { lat: 0, lng: 0 };
644
- let twinId = `auto_gen_twin`;
645
- let weatherProvider = "";
646
- let eventProvider = "";
647
- let inventoryProvider = "";
648
- for (const rawNode of twinNodes) {
649
- const node = rawNode;
650
- if (node.traits) {
651
- for (const trait of node.traits) {
652
- if (trait.name === "geo_anchor")
653
- geoCenter = { lat: Number(trait.params.lat), lng: Number(trait.params.lng) };
654
- else if (trait.name === "vrr_twin" && trait.params.mirror) twinId = String(trait.params.mirror);
655
- else if (trait.name === "weather_sync") weatherProvider = String(trait.params.provider);
656
- else if (trait.name === "event_sync") eventProvider = String(trait.params.provider);
657
- else if (trait.name === "inventory_sync") inventoryProvider = String(trait.params.provider);
658
- }
659
- }
660
- }
661
- const apiConfig = JSON.parse(JSON.stringify(this.options.api_integrations || {}));
662
- if (weatherProvider && !apiConfig.weather) apiConfig.weather = { provider: weatherProvider };
663
- if (eventProvider && !apiConfig.events) apiConfig.events = { provider: eventProvider };
664
- if (inventoryProvider && !apiConfig.inventory)
665
- apiConfig.inventory = { provider: inventoryProvider };
666
- this.generatedCode.push(`const vrr = new VRRRuntime({`);
667
- this.generatedCode.push(` twin_id: '${twinId}',`);
668
- this.generatedCode.push(` geo_center: { lat: ${geoCenter.lat}, lng: ${geoCenter.lng} },`);
669
- this.generatedCode.push(` apis: ${JSON.stringify(apiConfig, null, 2)},`);
670
- this.generatedCode.push(` multiplayer: { enabled: true, max_players: 1000, tick_rate: 20 },`);
671
- this.generatedCode.push(
672
- ` state_persistence: { client: 'indexeddb', server: 'https://supabase.hololand.io' }`
673
- );
674
- this.generatedCode.push(`});`);
675
- this.generatedCode.push(`
676
- const phoenix_downtown = new THREE.Group();`);
677
- if (weatherProvider) {
678
- this.generatedCode.push(`
679
- // Extracted @weather_sync hook`);
680
- this.generatedCode.push(`vrr.syncWeather((weather) => {`);
681
- this.generatedCode.push(` scene.fog = new THREE.Fog(0xcccccc, 10, weather.visibility);`);
682
- this.generatedCode.push(
683
- ` if (weather.precipitation > 50) console.log("Heavy Rain Detected in Twin");`
684
- );
685
- this.generatedCode.push(`});`);
686
- }
687
- if (eventProvider) {
688
- this.generatedCode.push(`
689
- // Extracted @event_sync hook`);
690
- this.generatedCode.push(`vrr.syncEvents((events) => {`);
691
- this.generatedCode.push(
692
- ` events.forEach(evt => console.log('Spawning event NPCs for:', evt.name));`
693
- );
694
- this.generatedCode.push(`});`);
695
- }
696
- const questHubs = this.extractNodesWithTrait(twinNodes[0] || {}, "@quest_hub");
697
- for (const hub of questHubs) {
698
- const questTrait = hub.traits?.find((t) => t.name === "quest_hub");
699
- const quests = questTrait ? Array.isArray(questTrait.params.quests) ? questTrait.params.quests : [] : [];
700
- this.generatedCode.push(`
701
- // Configured @quest_hub for ${hub.name || "Business"}`);
702
- this.generatedCode.push(`const hub_${Math.random().toString(36).substring(7)} = {`);
703
- this.generatedCode.push(` quests: ${JSON.stringify(quests)}`);
704
- this.generatedCode.push(`};`);
705
- const inventory = hub.traits?.find((t) => t.name === "inventory_sync");
706
- if (inventory) {
707
- this.generatedCode.push(`vrr.syncInventory('${hub.name || "shop"}', (inv) => {`);
708
- this.generatedCode.push(` console.log('Stock updated:', inv);`);
709
- this.generatedCode.push(`});`);
710
- }
711
- }
712
- const paywalls = this.extractNodesWithTrait(twinNodes[0] || {}, "@x402_paywall");
713
- for (const pw of paywalls) {
714
- const trait = pw.traits?.find((t) => t.name === "x402_paywall");
715
- if (!trait) continue;
716
- this.generatedCode.push(
717
- `
718
- // @x402_paywall requirement for ${this.escapeStringValue(String(pw.name || ""), "TypeScript")}`
719
- );
720
- this.generatedCode.push(
721
- `vrr.persistState('paywall_${this.escapeStringValue(String(pw.name || ""), "TypeScript")}', ${JSON.stringify(trait.params)});`
722
- );
723
- }
724
- this.generatedCode.push(`
725
- // Extracted Multiplayer logic`);
726
- this.generatedCode.push(`vrr.syncPlayers((players) => {`);
727
- this.generatedCode.push(` // Render avatars in scene mapped to players.position`);
728
- this.generatedCode.push(`});`);
729
- }
730
- buildResult() {
731
- return {
732
- success: this.errors.length === 0,
733
- target: this.options.target,
734
- code: this.generatedCode.join("\n"),
735
- assets: [],
736
- api_endpoints: [],
737
- warnings: this.warnings,
738
- errors: this.errors
739
- };
740
- }
741
- };
742
- exports.VRRCompiler_default = exports.VRRCompiler;
743
- }
744
- });
745
-
746
- exports.VRRCompiler_exports = VRRCompiler_exports;
747
- exports.init_VRRCompiler = init_VRRCompiler;
748
- //# sourceMappingURL=chunk-VZNKJZTT.cjs.map
749
- //# sourceMappingURL=chunk-VZNKJZTT.cjs.map