@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,426 +0,0 @@
1
- // src/compiler/RemotionBridge.ts
2
- function bridgeToRemotion(composition, options = {}) {
3
- const bridge = new RemotionBridgeImpl(options);
4
- return bridge.convert(composition);
5
- }
6
- var RemotionBridgeImpl = class {
7
- constructor(options = {}) {
8
- this.width = options.width ?? 1920;
9
- this.height = options.height ?? 1080;
10
- this.fps = options.fps ?? 30;
11
- this.defaultDurationSeconds = options.defaultDurationSeconds ?? 10;
12
- this.include3DCanvas = options.include3DCanvas ?? true;
13
- this.multiPass = options.multiPass ?? false;
14
- this.componentImportPath = options.componentImportPath ?? "./components";
15
- this.isTypeScript = (options.outputFormat ?? "typescript") === "typescript";
16
- }
17
- convert(composition) {
18
- const durationInFrames = this.calculateDuration(composition);
19
- const compositionConfig = {
20
- id: this.sanitizeId(composition.name),
21
- width: this.width,
22
- height: this.height,
23
- fps: this.fps,
24
- durationInFrames
25
- };
26
- const sequences = this.extractSequences(composition);
27
- const audioClips = this.extractAudioClips(composition);
28
- const interpolationTracks = this.extractInterpolationTracks(composition);
29
- const renderPasses = this.buildRenderPasses();
30
- const componentSource = this.generateComponentSource(
31
- composition,
32
- sequences,
33
- interpolationTracks
34
- );
35
- const rootSource = this.generateRootSource(compositionConfig, audioClips);
36
- return {
37
- composition: compositionConfig,
38
- sequences,
39
- audioClips,
40
- componentSource,
41
- rootSource,
42
- interpolationTracks,
43
- renderPasses
44
- };
45
- }
46
- // ---------------------------------------------------------------------------
47
- // Duration calculation
48
- // ---------------------------------------------------------------------------
49
- calculateDuration(composition) {
50
- let maxTimeSeconds = this.defaultDurationSeconds;
51
- for (const timeline of composition.timelines ?? []) {
52
- for (const entry of timeline.entries ?? []) {
53
- maxTimeSeconds = Math.max(maxTimeSeconds, entry.time + 1);
54
- }
55
- }
56
- return Math.ceil(maxTimeSeconds * this.fps);
57
- }
58
- // ---------------------------------------------------------------------------
59
- // Sequence extraction
60
- // ---------------------------------------------------------------------------
61
- extractSequences(composition) {
62
- const sequences = [];
63
- for (const timeline of composition.timelines ?? []) {
64
- const entries = [...timeline.entries ?? []].sort((a, b) => a.time - b.time);
65
- for (let i = 0; i < entries.length; i++) {
66
- const entry = entries[i];
67
- const nextEntry = entries[i + 1];
68
- const startFrame = Math.round(entry.time * this.fps);
69
- const endFrame = nextEntry ? Math.round(nextEntry.time * this.fps) : Math.round((entry.time + 1) * this.fps);
70
- const sequence = {
71
- name: `${timeline.name}_${i}`,
72
- from: startFrame,
73
- durationInFrames: Math.max(1, endFrame - startFrame),
74
- component: this.actionToComponent(entry.action),
75
- props: this.actionToProps(entry)
76
- };
77
- sequences.push(sequence);
78
- }
79
- }
80
- return sequences;
81
- }
82
- actionToComponent(action) {
83
- switch (action.kind) {
84
- case "animate":
85
- return "AnimateObject";
86
- case "emit":
87
- return "EmitEvent";
88
- case "call":
89
- return "CallMethod";
90
- default:
91
- return "Noop";
92
- }
93
- }
94
- actionToProps(entry) {
95
- const action = entry.action;
96
- const props = { time: entry.time };
97
- if (action.kind === "animate") {
98
- props.target = action.target;
99
- props.properties = action.properties;
100
- } else if (action.kind === "emit") {
101
- props.event = action.event;
102
- props.data = action.data;
103
- } else if (action.kind === "call") {
104
- props.method = action.method;
105
- props.args = action.args;
106
- }
107
- return props;
108
- }
109
- // ---------------------------------------------------------------------------
110
- // Audio extraction
111
- // ---------------------------------------------------------------------------
112
- extractAudioClips(composition) {
113
- const clips = [];
114
- for (const audio of composition.audio ?? []) {
115
- const clip = {
116
- src: this.extractAudioSrc(audio)
117
- };
118
- for (const prop of audio.properties) {
119
- if (prop.key === "volume" && typeof prop.value === "number") {
120
- clip.volume = prop.value;
121
- }
122
- if (prop.key === "playbackRate" && typeof prop.value === "number") {
123
- clip.playbackRate = prop.value;
124
- }
125
- if (prop.key === "spatial" && typeof prop.value === "boolean") {
126
- clip.spatial = prop.value;
127
- }
128
- if (prop.key === "startTime" && typeof prop.value === "number") {
129
- clip.startFrom = Math.round(prop.value * this.fps);
130
- }
131
- }
132
- clips.push(clip);
133
- }
134
- return clips;
135
- }
136
- extractAudioSrc(audio) {
137
- for (const prop of audio.properties) {
138
- if (prop.key === "src" && typeof prop.value === "string") return prop.value;
139
- if (prop.key === "source" && typeof prop.value === "string") return prop.value;
140
- if (prop.key === "url" && typeof prop.value === "string") return prop.value;
141
- }
142
- return `./audio/${audio.name}.mp3`;
143
- }
144
- // ---------------------------------------------------------------------------
145
- // Interpolation tracks
146
- // ---------------------------------------------------------------------------
147
- extractInterpolationTracks(composition) {
148
- const trackMap = /* @__PURE__ */ new Map();
149
- for (const timeline of composition.timelines ?? []) {
150
- for (const entry of timeline.entries ?? []) {
151
- if (entry.action.kind !== "animate") continue;
152
- const target = entry.action.target;
153
- const properties = entry.action.properties;
154
- for (const [prop, value] of Object.entries(properties)) {
155
- if (typeof value !== "number") continue;
156
- const trackKey = `${target}.${prop}`;
157
- if (!trackMap.has(trackKey)) {
158
- trackMap.set(trackKey, {
159
- target,
160
- property: prop,
161
- keyframes: []
162
- });
163
- }
164
- const track = trackMap.get(trackKey);
165
- track.keyframes.push({
166
- frame: Math.round(entry.time * this.fps),
167
- value
168
- });
169
- }
170
- }
171
- }
172
- for (const track of trackMap.values()) {
173
- track.keyframes.sort((a, b) => a.frame - b.frame);
174
- }
175
- return Array.from(trackMap.values());
176
- }
177
- // ---------------------------------------------------------------------------
178
- // Render passes
179
- // ---------------------------------------------------------------------------
180
- buildRenderPasses() {
181
- const passes = [
182
- { name: "Beauty", type: "beauty", outputSuffix: "", enabled: true }
183
- ];
184
- if (this.multiPass) {
185
- passes.push(
186
- { name: "Depth", type: "depth", outputSuffix: "_depth", enabled: true },
187
- { name: "Normal", type: "normal", outputSuffix: "_normal", enabled: true },
188
- { name: "ID Mask", type: "id", outputSuffix: "_id", enabled: true },
189
- { name: "Wireframe", type: "wireframe", outputSuffix: "_wire", enabled: false }
190
- );
191
- }
192
- return passes;
193
- }
194
- // ---------------------------------------------------------------------------
195
- // Code generation: Scene component
196
- // ---------------------------------------------------------------------------
197
- generateComponentSource(composition, sequences, tracks) {
198
- this.isTypeScript ? "tsx" : "jsx";
199
- const typeAnnotation = this.isTypeScript ? ": React.FC" : "";
200
- const lines = [];
201
- lines.push(`// Auto-generated by HoloScript RemotionBridge`);
202
- lines.push(`// Source composition: "${composition.name}"`);
203
- lines.push(``);
204
- lines.push(`import React from 'react';`);
205
- lines.push(
206
- `import { useCurrentFrame, useVideoConfig, interpolate, Sequence } from 'remotion';`
207
- );
208
- if (this.include3DCanvas) {
209
- lines.push(`import { Canvas } from '@react-three/fiber';`);
210
- lines.push(`import { OrbitControls, Environment } from '@react-three/drei';`);
211
- }
212
- lines.push(``);
213
- if (tracks.length > 0) {
214
- lines.push(`// --- Interpolation Tracks ---`);
215
- lines.push(``);
216
- for (const track of tracks) {
217
- const fnName = `get_${this.sanitizeId(track.target)}_${track.property}`;
218
- const inputRange = track.keyframes.map((k) => k.frame);
219
- const outputRange = track.keyframes.map((k) => k.value);
220
- lines.push(`function ${fnName}(frame${this.isTypeScript ? ": number" : ""}) {`);
221
- lines.push(
222
- ` return interpolate(frame, ${JSON.stringify(inputRange)}, ${JSON.stringify(outputRange)}, {`
223
- );
224
- lines.push(` extrapolateLeft: 'clamp',`);
225
- lines.push(` extrapolateRight: 'clamp',`);
226
- lines.push(` });`);
227
- lines.push(`}`);
228
- lines.push(``);
229
- }
230
- }
231
- if (this.include3DCanvas) {
232
- lines.push(`function SceneObjects() {`);
233
- lines.push(` const frame = useCurrentFrame();`);
234
- lines.push(``);
235
- lines.push(` return (`);
236
- lines.push(` <>`);
237
- for (const light of composition.lights ?? []) {
238
- lines.push(` ${this.lightToJSX(light)}`);
239
- }
240
- for (const obj of composition.objects ?? []) {
241
- lines.push(` ${this.objectToJSX(obj, tracks)}`);
242
- }
243
- for (const group of composition.spatialGroups ?? []) {
244
- lines.push(` ${this.groupToJSX(group, tracks)}`);
245
- }
246
- lines.push(` </>`);
247
- lines.push(` );`);
248
- lines.push(`}`);
249
- lines.push(``);
250
- }
251
- const componentName = this.sanitizeId(composition.name) + "Scene";
252
- lines.push(`export const ${componentName}${typeAnnotation} = () => {`);
253
- lines.push(` const frame = useCurrentFrame();`);
254
- lines.push(` const { durationInFrames } = useVideoConfig();`);
255
- lines.push(``);
256
- lines.push(` return (`);
257
- lines.push(` <div style={{ width: '100%', height: '100%', background: '#000' }}>`);
258
- for (const seq of sequences) {
259
- lines.push(
260
- ` <Sequence from={${seq.from}} durationInFrames={${seq.durationInFrames}} name="${seq.name}">`
261
- );
262
- lines.push(` {/* ${seq.component}: ${JSON.stringify(seq.props)} */}`);
263
- lines.push(` </Sequence>`);
264
- }
265
- if (this.include3DCanvas) {
266
- lines.push(` <Canvas camera={{ position: [0, 1.6, 5], fov: 60 }}>`);
267
- lines.push(` <SceneObjects />`);
268
- lines.push(` <OrbitControls />`);
269
- lines.push(` <Environment preset="apartment" />`);
270
- lines.push(` </Canvas>`);
271
- }
272
- lines.push(` </div>`);
273
- lines.push(` );`);
274
- lines.push(`};`);
275
- lines.push(``);
276
- lines.push(`export default ${componentName};`);
277
- return lines.join("\n");
278
- }
279
- // ---------------------------------------------------------------------------
280
- // Code generation: Remotion Root
281
- // ---------------------------------------------------------------------------
282
- generateRootSource(config, audioClips) {
283
- const lines = [];
284
- const componentName = config.id + "Scene";
285
- lines.push(`// Auto-generated Remotion Root by HoloScript RemotionBridge`);
286
- lines.push(``);
287
- lines.push(`import { Composition } from 'remotion';`);
288
- lines.push(`import { ${componentName} } from '${this.componentImportPath}/${componentName}';`);
289
- if (audioClips.length > 0) {
290
- lines.push(`import { Audio } from 'remotion';`);
291
- }
292
- lines.push(``);
293
- lines.push(`export const RemotionRoot = () => {`);
294
- lines.push(` return (`);
295
- lines.push(` <>`);
296
- lines.push(` <Composition`);
297
- lines.push(` id="${config.id}"`);
298
- lines.push(` component={${componentName}}`);
299
- lines.push(` durationInFrames={${config.durationInFrames}}`);
300
- lines.push(` fps={${config.fps}}`);
301
- lines.push(` width={${config.width}}`);
302
- lines.push(` height={${config.height}}`);
303
- lines.push(` />`);
304
- lines.push(` </>`);
305
- lines.push(` );`);
306
- lines.push(`};`);
307
- return lines.join("\n");
308
- }
309
- // ---------------------------------------------------------------------------
310
- // JSX generation helpers
311
- // ---------------------------------------------------------------------------
312
- lightToJSX(light) {
313
- const props = this.propsToJSXAttrs(light.properties);
314
- switch (light.lightType) {
315
- case "directional":
316
- return `<directionalLight ${props} />`;
317
- case "point":
318
- return `<pointLight ${props} />`;
319
- case "spot":
320
- return `<spotLight ${props} />`;
321
- case "hemisphere":
322
- return `<hemisphereLight ${props} />`;
323
- case "ambient":
324
- return `<ambientLight ${props} />`;
325
- default:
326
- return `<pointLight ${props} />`;
327
- }
328
- }
329
- objectToJSX(obj, tracks) {
330
- const geometry = this.inferGeometry(obj);
331
- const position = this.extractVec3(obj.properties, "position", [0, 0, 0]);
332
- const scale = this.extractVec3(obj.properties, "scale", [1, 1, 1]);
333
- const color = this.extractColor(obj);
334
- const hasAnimation = tracks.some((t) => t.target === obj.name);
335
- const positionExpr = hasAnimation ? `[get_${this.sanitizeId(obj.name)}_x?.(frame) ?? ${position[0]}, get_${this.sanitizeId(obj.name)}_y?.(frame) ?? ${position[1]}, get_${this.sanitizeId(obj.name)}_z?.(frame) ?? ${position[2]}]` : `[${position.join(", ")}]`;
336
- return [
337
- `<mesh position={${positionExpr}} scale={[${scale.join(", ")}]} name="${obj.name}">`,
338
- ` <${geometry}Geometry />`,
339
- ` <meshStandardMaterial color="${color}" />`,
340
- ` </mesh>`
341
- ].join("\n ");
342
- }
343
- groupToJSX(group, tracks) {
344
- const position = this.extractGroupVec3(group, "position", [0, 0, 0]);
345
- const children = (group.objects ?? []).map((o) => ` ${this.objectToJSX(o, tracks)}`).join("\n");
346
- return [
347
- `<group position={[${position.join(", ")}]} name="${group.name}">`,
348
- children,
349
- ` </group>`
350
- ].join("\n ");
351
- }
352
- // ---------------------------------------------------------------------------
353
- // Property extraction
354
- // ---------------------------------------------------------------------------
355
- extractVec3(properties, key, defaultVal) {
356
- for (const prop of properties) {
357
- if (prop.key === key && Array.isArray(prop.value)) {
358
- const arr = prop.value;
359
- return [arr[0] ?? defaultVal[0], arr[1] ?? defaultVal[1], arr[2] ?? defaultVal[2]];
360
- }
361
- }
362
- return defaultVal;
363
- }
364
- extractGroupVec3(group, key, defaultVal) {
365
- for (const prop of group.properties) {
366
- if (prop.key === key && Array.isArray(prop.value)) {
367
- const arr = prop.value;
368
- return [arr[0] ?? defaultVal[0], arr[1] ?? defaultVal[1], arr[2] ?? defaultVal[2]];
369
- }
370
- }
371
- return defaultVal;
372
- }
373
- extractColor(obj) {
374
- for (const prop of obj.properties) {
375
- if (prop.key === "color" && typeof prop.value === "string") return prop.value;
376
- }
377
- for (const trait of obj.traits ?? []) {
378
- if (trait.config["color"] && typeof trait.config["color"] === "string") {
379
- return trait.config["color"];
380
- }
381
- }
382
- return "#888888";
383
- }
384
- inferGeometry(obj) {
385
- for (const prop of obj.properties) {
386
- if ((prop.key === "geometry" || prop.key === "shape") && typeof prop.value === "string") {
387
- return this.mapGeometryName(prop.value);
388
- }
389
- }
390
- return "box";
391
- }
392
- mapGeometryName(name) {
393
- const map = {
394
- box: "box",
395
- cube: "box",
396
- sphere: "sphere",
397
- orb: "sphere",
398
- cylinder: "cylinder",
399
- cone: "cone",
400
- plane: "plane",
401
- torus: "torus",
402
- ring: "torus"
403
- };
404
- return map[name.toLowerCase()] ?? "box";
405
- }
406
- propsToJSXAttrs(properties) {
407
- return properties.map((p) => {
408
- if (typeof p.value === "string") return `${p.key}="${p.value}"`;
409
- if (typeof p.value === "number") return `${p.key}={${p.value}}`;
410
- if (typeof p.value === "boolean") return p.value ? p.key : "";
411
- if (Array.isArray(p.value)) return `${p.key}={[${p.value.join(", ")}]}`;
412
- return "";
413
- }).filter(Boolean).join(" ");
414
- }
415
- // ---------------------------------------------------------------------------
416
- // Utility
417
- // ---------------------------------------------------------------------------
418
- sanitizeId(name) {
419
- return name.replace(/[^a-zA-Z0-9]/g, "_").replace(/^[0-9]/, "_$&");
420
- }
421
- };
422
- var RemotionBridge_default = bridgeToRemotion;
423
-
424
- export { RemotionBridgeImpl, RemotionBridge_default, bridgeToRemotion };
425
- //# sourceMappingURL=chunk-YYXH45E2.js.map
426
- //# sourceMappingURL=chunk-YYXH45E2.js.map