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