@tora-editor/tora 0.1.0 → 0.2.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 (73) hide show
  1. package/README.md +108 -58
  2. package/assets/free-audio/arcade-pop/audio/loss.wav +0 -0
  3. package/assets/free-audio/arcade-pop/audio/reward.wav +0 -0
  4. package/assets/free-audio/arcade-pop/audio/win.wav +0 -0
  5. package/assets/free-audio/arcade-pop/source/INFO.txt +11 -11
  6. package/assets/kenney-food-starter/License.txt +28 -0
  7. package/assets/kenney-food-starter/burger.glb +0 -0
  8. package/assets/kenney-food-starter/frying-pan.glb +0 -0
  9. package/assets/kenney-food-starter/plan.json +61 -0
  10. package/assets/kenney-food-starter/plate.glb +0 -0
  11. package/assets/kenney-food-starter/pot.glb +0 -0
  12. package/assets/kenney-harvest/audio/victory.wav +0 -0
  13. package/assets/kenney-harvest/source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg +0 -0
  14. package/assets/kenney-harvest/source/music-jingles/OGG/jingles_PIZZA/jingles_PIZZA03.ogg +0 -0
  15. package/assets/kenney-harvest/source/music-jingles/license.txt +14 -0
  16. package/bin/tora.mjs +77 -9
  17. package/crates/packer/trusted/native-3d-meta.json +3 -2
  18. package/crates/packer/trusted/native-3d.js +181 -181
  19. package/crates/packer/trusted/native-meta.json +2 -2
  20. package/crates/packer/trusted/native.js +5 -5
  21. package/crates/packer/trusted/release-manifest.json +17 -17
  22. package/crates/packer/trusted/review-runtime-meta.json +3 -2
  23. package/crates/packer/trusted/review-runtime.js +182 -182
  24. package/docs/TORA_AGENT_SETUP.md +24 -13
  25. package/docs/TORA_CREATION_API.md +29 -12
  26. package/docs/reference/CORE_AUTHORING.md +2 -1
  27. package/docs/reference/PLAYABLE_STARTERS.md +20 -0
  28. package/docs/reference/packs/3d.md +9 -3
  29. package/network-rules/mintegral-appgrowth-single-html.json +10 -10
  30. package/package.json +6 -6
  31. package/packages/creative-project/project-v21.schema.json +264 -8
  32. package/scripts/lean/editor/review-editor.css +10 -0
  33. package/scripts/lean/editor/review-editor.js +117 -1
  34. package/scripts/lean/native/agent-tools.mjs +7 -7
  35. package/scripts/lean/native/api.mjs +16 -5
  36. package/scripts/lean/native/asset-catalog.mjs +7 -6
  37. package/scripts/lean/native/asset-lineage.mjs +54 -0
  38. package/scripts/lean/native/asset-prep.mjs +173 -40
  39. package/scripts/lean/native/assets.mjs +107 -11
  40. package/scripts/lean/native/author-expansion-proofs.mjs +2 -99
  41. package/scripts/lean/native/author-fps.mjs +545 -0
  42. package/scripts/lean/native/author-primitive-proofs.mjs +5 -4
  43. package/scripts/lean/native/build-cache.mjs +2 -2
  44. package/scripts/lean/native/cc0-inputs.mjs +24 -0
  45. package/scripts/lean/native/cc0-staging.mjs +28 -8
  46. package/scripts/lean/native/check-harvest-outcome-audio.mjs +7 -8
  47. package/scripts/lean/native/check-salvage.mjs +8 -5
  48. package/scripts/lean/native/compiler.mjs +9 -3
  49. package/scripts/lean/native/contracts.mjs +11 -8
  50. package/scripts/lean/native/creative-qa.mjs +305 -122
  51. package/scripts/lean/native/demos.mjs +47 -3
  52. package/scripts/lean/native/document.mjs +36 -10
  53. package/scripts/lean/native/export-budget.mjs +75 -0
  54. package/scripts/lean/native/glb-loader.mjs +468 -0
  55. package/scripts/lean/native/intake-creator-tools.mjs +83 -30
  56. package/scripts/lean/native/local-bundle.mjs +5 -3
  57. package/scripts/lean/native/mcp-server.mjs +33 -46
  58. package/scripts/lean/native/media-validate.mjs +124 -0
  59. package/scripts/lean/native/native-bin.mjs +3 -3
  60. package/scripts/lean/native/outcome-playthrough.mjs +97 -0
  61. package/scripts/lean/native/prepare-fps-assets.mjs +330 -0
  62. package/scripts/lean/native/project-bundle.mjs +3 -3
  63. package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
  64. package/scripts/lean/native/review-agent-tools.mjs +2 -2
  65. package/scripts/lean/native/review.mjs +3 -0
  66. package/scripts/lean/native/runtime.mjs +242 -56
  67. package/scripts/lean/native/schema.mjs +7 -5
  68. package/scripts/lean/native/service.mjs +159 -32
  69. package/scripts/lean/native/stage-3d.mjs +343 -40
  70. package/scripts/lean/native/starters.mjs +436 -0
  71. package/scripts/lean/native/verify.mjs +1 -1
  72. package/scripts/lean/native/win-cues.mjs +96 -0
  73. package/skills/tora-playables/SKILL.md +1 -1
@@ -1508,6 +1508,33 @@
1508
1508
  "minimum": 0,
1509
1509
  "maximum": 1
1510
1510
  },
1511
+ "shadowsEnabled": {
1512
+ "type": "boolean"
1513
+ },
1514
+ "shadowMapSize": {
1515
+ "enum": [
1516
+ "256",
1517
+ "512",
1518
+ "1024"
1519
+ ]
1520
+ },
1521
+ "toneMapping": {
1522
+ "enum": [
1523
+ "none",
1524
+ "neutral",
1525
+ "aces"
1526
+ ]
1527
+ },
1528
+ "envIntensity": {
1529
+ "type": "number",
1530
+ "minimum": 0,
1531
+ "maximum": 2
1532
+ },
1533
+ "renderMaxDim": {
1534
+ "type": "integer",
1535
+ "minimum": 320,
1536
+ "maximum": 1024
1537
+ },
1511
1538
  "skyColor": {
1512
1539
  "type": "string",
1513
1540
  "pattern": "^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"
@@ -1743,9 +1770,58 @@
1743
1770
  "minimum": 0,
1744
1771
  "maximum": 1
1745
1772
  },
1773
+ "subNode": {
1774
+ "type": "string",
1775
+ "maxLength": 96
1776
+ },
1777
+ "materialMode": {
1778
+ "enum": [
1779
+ "asset",
1780
+ "lambert",
1781
+ "standard",
1782
+ "unlit"
1783
+ ]
1784
+ },
1785
+ "overrideMaterialName": {
1786
+ "type": "string",
1787
+ "maxLength": 64
1788
+ },
1789
+ "tintColor": {
1790
+ "type": "string",
1791
+ "pattern": "^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"
1792
+ },
1793
+ "roughnessScale": {
1794
+ "type": "number",
1795
+ "minimum": 0,
1796
+ "maximum": 2
1797
+ },
1798
+ "metalnessScale": {
1799
+ "type": "number",
1800
+ "minimum": 0,
1801
+ "maximum": 2
1802
+ },
1803
+ "castShadow": {
1804
+ "type": "boolean"
1805
+ },
1806
+ "receiveShadow": {
1807
+ "type": "boolean"
1808
+ },
1809
+ "normalizeSize": {
1810
+ "type": "number",
1811
+ "minimum": 0,
1812
+ "maximum": 100
1813
+ },
1814
+ "pivotMode": {
1815
+ "enum": [
1816
+ "origin",
1817
+ "center",
1818
+ "bottom-center"
1819
+ ]
1820
+ },
1746
1821
  "primitive": {
1747
1822
  "enum": [
1748
1823
  "group",
1824
+ "model",
1749
1825
  "mesh",
1750
1826
  "box",
1751
1827
  "sphere",
@@ -1891,7 +1967,12 @@
1891
1967
  "additionalProperties": false,
1892
1968
  "properties": {
1893
1969
  "slotId": {
1894
- "const": "source"
1970
+ "enum": [
1971
+ "source",
1972
+ "texture",
1973
+ "normalMap",
1974
+ "emissiveMap"
1975
+ ]
1895
1976
  },
1896
1977
  "assetId": {
1897
1978
  "type": "string",
@@ -1903,7 +1984,7 @@
1903
1984
  "assetId"
1904
1985
  ]
1905
1986
  },
1906
- "maxItems": 1
1987
+ "maxItems": 4
1907
1988
  },
1908
1989
  "prototype": {
1909
1990
  "type": "boolean"
@@ -2831,7 +2912,8 @@
2831
2912
  "origin": {
2832
2913
  "enum": [
2833
2914
  "center",
2834
- "anchor"
2915
+ "anchor",
2916
+ "contact-3d"
2835
2917
  ]
2836
2918
  },
2837
2919
  "direction": {
@@ -4252,6 +4334,9 @@
4252
4334
  "type": "number",
4253
4335
  "minimum": 0.05,
4254
4336
  "maximum": 2
4337
+ },
4338
+ "fitColliderFromModel": {
4339
+ "type": "boolean"
4255
4340
  }
4256
4341
  },
4257
4342
  "required": [
@@ -4278,6 +4363,69 @@
4278
4363
  "parameters"
4279
4364
  ]
4280
4365
  },
4366
+ {
4367
+ "type": "object",
4368
+ "additionalProperties": false,
4369
+ "properties": {
4370
+ "id": {
4371
+ "type": "string",
4372
+ "pattern": "^[a-z][a-z0-9_.-]{0,95}$"
4373
+ },
4374
+ "componentId": {
4375
+ "type": "string",
4376
+ "pattern": "^[a-z][a-z0-9_.-]{0,95}$"
4377
+ },
4378
+ "kind": {
4379
+ "const": "animate-3d"
4380
+ },
4381
+ "parameters": {
4382
+ "type": "object",
4383
+ "additionalProperties": false,
4384
+ "properties": {
4385
+ "clipName": {
4386
+ "type": "string",
4387
+ "maxLength": 96
4388
+ },
4389
+ "loop": {
4390
+ "enum": [
4391
+ "repeat",
4392
+ "once",
4393
+ "pingpong"
4394
+ ]
4395
+ },
4396
+ "speed": {
4397
+ "type": "number",
4398
+ "minimum": 0,
4399
+ "maximum": 4
4400
+ },
4401
+ "autoplay": {
4402
+ "type": "boolean"
4403
+ },
4404
+ "fadeSeconds": {
4405
+ "type": "number",
4406
+ "minimum": 0,
4407
+ "maximum": 2
4408
+ },
4409
+ "startTime": {
4410
+ "type": "number",
4411
+ "minimum": 0,
4412
+ "maximum": 60
4413
+ }
4414
+ },
4415
+ "required": [
4416
+ "loop",
4417
+ "speed",
4418
+ "autoplay"
4419
+ ]
4420
+ }
4421
+ },
4422
+ "required": [
4423
+ "id",
4424
+ "componentId",
4425
+ "kind",
4426
+ "parameters"
4427
+ ]
4428
+ },
4281
4429
  {
4282
4430
  "type": "object",
4283
4431
  "additionalProperties": false,
@@ -5446,6 +5594,32 @@
5446
5594
  "componentId"
5447
5595
  ]
5448
5596
  },
5597
+ {
5598
+ "type": "object",
5599
+ "additionalProperties": false,
5600
+ "properties": {
5601
+ "id": {
5602
+ "type": "string",
5603
+ "pattern": "^[a-z][a-z0-9_.-]{0,95}$"
5604
+ },
5605
+ "kind": {
5606
+ "const": "modelAnimationEnd"
5607
+ },
5608
+ "componentId": {
5609
+ "type": "string",
5610
+ "pattern": "^[a-z][a-z0-9_.-]{0,95}$"
5611
+ },
5612
+ "clipName": {
5613
+ "type": "string",
5614
+ "maxLength": 96
5615
+ }
5616
+ },
5617
+ "required": [
5618
+ "id",
5619
+ "kind",
5620
+ "componentId"
5621
+ ]
5622
+ },
5449
5623
  {
5450
5624
  "type": "object",
5451
5625
  "additionalProperties": false,
@@ -5615,6 +5789,14 @@
5615
5789
  "assetId": {
5616
5790
  "type": "string",
5617
5791
  "pattern": "^[a-z][a-z0-9_.-]{0,95}$"
5792
+ },
5793
+ "slotId": {
5794
+ "enum": [
5795
+ "source",
5796
+ "texture",
5797
+ "normalMap",
5798
+ "emissiveMap"
5799
+ ]
5618
5800
  }
5619
5801
  },
5620
5802
  "required": [
@@ -6412,6 +6594,11 @@
6412
6594
  "sceneId": {
6413
6595
  "type": "string",
6414
6596
  "pattern": "^[a-z][a-z0-9_.-]{0,95}$"
6597
+ },
6598
+ "delaySeconds": {
6599
+ "type": "number",
6600
+ "minimum": 0,
6601
+ "maximum": 10
6415
6602
  }
6416
6603
  },
6417
6604
  "required": [
@@ -6566,6 +6753,20 @@
6566
6753
  "type": "string",
6567
6754
  "pattern": "^[a-z][a-z0-9_.-]{0,95}$"
6568
6755
  },
6756
+ "fromComponentId": {
6757
+ "type": "string",
6758
+ "pattern": "^[a-z][a-z0-9_.-]{0,95}$"
6759
+ },
6760
+ "fromTeam": {
6761
+ "enum": [
6762
+ "any",
6763
+ "neutral",
6764
+ "player",
6765
+ "enemy",
6766
+ "hazard",
6767
+ "pickup"
6768
+ ]
6769
+ },
6569
6770
  "x": {
6570
6771
  "type": "number",
6571
6772
  "minimum": -500,
@@ -6581,6 +6782,21 @@
6581
6782
  "minimum": -500,
6582
6783
  "maximum": 500
6583
6784
  },
6785
+ "offsetX": {
6786
+ "type": "number",
6787
+ "minimum": -50,
6788
+ "maximum": 50
6789
+ },
6790
+ "offsetY": {
6791
+ "type": "number",
6792
+ "minimum": -50,
6793
+ "maximum": 50
6794
+ },
6795
+ "offsetZ": {
6796
+ "type": "number",
6797
+ "minimum": -50,
6798
+ "maximum": 50
6799
+ },
6584
6800
  "jitterX": {
6585
6801
  "type": "number",
6586
6802
  "minimum": 0,
@@ -6599,10 +6815,49 @@
6599
6815
  },
6600
6816
  "required": [
6601
6817
  "kind",
6602
- "prototypeId",
6603
- "x",
6604
- "y",
6605
- "z"
6818
+ "prototypeId"
6819
+ ]
6820
+ },
6821
+ {
6822
+ "type": "object",
6823
+ "additionalProperties": false,
6824
+ "properties": {
6825
+ "kind": {
6826
+ "const": "playModelAnimation"
6827
+ },
6828
+ "componentId": {
6829
+ "type": "string",
6830
+ "pattern": "^[a-z][a-z0-9_.-]{0,95}$"
6831
+ },
6832
+ "clipName": {
6833
+ "type": "string",
6834
+ "maxLength": 96
6835
+ },
6836
+ "loop": {
6837
+ "enum": [
6838
+ "repeat",
6839
+ "once",
6840
+ "pingpong"
6841
+ ]
6842
+ },
6843
+ "speed": {
6844
+ "type": "number",
6845
+ "minimum": 0,
6846
+ "maximum": 4
6847
+ },
6848
+ "fadeSeconds": {
6849
+ "type": "number",
6850
+ "minimum": 0,
6851
+ "maximum": 2
6852
+ },
6853
+ "restart": {
6854
+ "type": "boolean"
6855
+ }
6856
+ },
6857
+ "required": [
6858
+ "kind",
6859
+ "componentId",
6860
+ "clipName"
6606
6861
  ]
6607
6862
  },
6608
6863
  {
@@ -6707,7 +6962,8 @@
6707
6962
  "image/jpeg",
6708
6963
  "audio/wav",
6709
6964
  "audio/mpeg",
6710
- "model/tora-mesh"
6965
+ "model/tora-mesh",
6966
+ "model/gltf-binary"
6711
6967
  ]
6712
6968
  },
6713
6969
  "bytes": {
@@ -889,3 +889,13 @@ dialog.tora-modal::backdrop{background:rgba(12,22,42,.58)}
889
889
  .tora-build-failure{display:grid;gap:10px}
890
890
  .tora-build-failure>p{margin:0;line-height:1.5;font-size:13px}
891
891
  @media(max-width:560px){.tora-completion-card h2{font-size:21px}.tora-build-progress-head{align-items:flex-start}.tora-completion-top{gap:8px}}
892
+ .review-win-sound-controls {
893
+ display: flex;
894
+ flex-wrap: wrap;
895
+ gap: .5rem;
896
+ margin-top: .5rem;
897
+ }
898
+
899
+ .review-win-sound-controls select {
900
+ max-width: 100%;
901
+ }
@@ -1078,6 +1078,15 @@ export async function openReview(projectId, initialMetadata) {
1078
1078
  <div class="tora-bubble-meta"><strong>Tora</strong><span>Ready</span></div>
1079
1079
  <p>Tell me what to change in this playable — copy, button text, timing, sound, or layout. Use <strong>🎯 Target</strong> to click a part on screen, or <strong>+</strong> to upload new sprites or audio.</p>
1080
1080
  <div class="tora-starter-row" id="review-quick-chips"></div>
1081
+ <details id="review-win-sound" hidden>
1082
+ <summary>Win sound</summary>
1083
+ <div class="review-win-sound-controls">
1084
+ <select id="review-win-sound-option" aria-label="Win sound"></select>
1085
+ <button type="button" id="review-win-sound-preview">Listen</button>
1086
+ <button type="button" id="review-win-sound-apply">Use sound</button>
1087
+ </div>
1088
+ <p id="review-win-sound-status" aria-live="polite"></p>
1089
+ </details>
1081
1090
  </div>
1082
1091
  <div id="review-requests" class="tora-chat-turns"></div>
1083
1092
  <div id="review-active" class="tora-chat-turns"></div>
@@ -1167,6 +1176,11 @@ export async function openReview(projectId, initialMetadata) {
1167
1176
  const attachment = $('review-attachment');
1168
1177
  const feedbackStatus = $('review-status');
1169
1178
  const threadEl = $('review-thread');
1179
+ const winSoundPanel = $('review-win-sound');
1180
+ const winSoundSelect = $('review-win-sound-option');
1181
+ const winSoundApply = $('review-win-sound-apply');
1182
+ const winSoundStatus = $('review-win-sound-status');
1183
+ let previewAudio;
1170
1184
  let exportTargets = [
1171
1185
  {id:'unity-ads-ua-playable',label:'Unity Ads',mraidVersion:'3.0',filenameSuffix:'unity',hostKind:'mraid',requiresStoreUrl:true,officialPreviewLabel:'Unity Ads Creative Testing tool'},
1172
1186
  {id:'applovin-growth-playable',label:'AppLovin',mraidVersion:'2.0',filenameSuffix:'applovin',hostKind:'mraid',requiresStoreUrl:true,officialPreviewLabel:'AppLovin Playable Preview',officialPreviewUrl:'https://p.applov.in/playablePreview?create=1'},
@@ -1271,10 +1285,106 @@ export async function openReview(projectId, initialMetadata) {
1271
1285
  };
1272
1286
  }
1273
1287
 
1288
+ function stopWinSoundPreview() {
1289
+ const running = previewAudio;
1290
+ previewAudio = undefined;
1291
+ if (running && running.state !== 'closed') void running.close().catch(() => {});
1292
+ }
1293
+
1294
+ function updateWinSoundApply() {
1295
+ const choice = metadata.winCue?.choices.find(item => item.key === winSoundSelect.value);
1296
+ winSoundApply.disabled = !choice || choice.current || Boolean(candidateId);
1297
+ }
1298
+
1299
+ function drawWinSoundControls() {
1300
+ winSoundPanel.hidden = !metadata.winCue;
1301
+ if (!metadata.winCue) return;
1302
+ const {choices} = metadata.winCue;
1303
+ const selected = winSoundSelect.value || choices.find(choice => choice.current)?.key || 'current';
1304
+ const options = choices.map(choice => {
1305
+ const option = reviewElement('option', choice.label + (choice.current ? ' (Current)' : ''));
1306
+ option.value = choice.key;
1307
+ return option;
1308
+ });
1309
+ if (!choices.some(choice => choice.current)) {
1310
+ const current = reviewElement('option', 'Current win sound');
1311
+ current.value = 'current';
1312
+ options.unshift(current);
1313
+ }
1314
+ winSoundSelect.replaceChildren(...options);
1315
+ if (options.some(option => option.value === selected)) winSoundSelect.value = selected;
1316
+ updateWinSoundApply();
1317
+ }
1318
+
1319
+ winSoundSelect.onchange = () => {
1320
+ stopWinSoundPreview();
1321
+ winSoundStatus.textContent = '';
1322
+ updateWinSoundApply();
1323
+ };
1324
+ $('review-win-sound-preview').onclick = async () => {
1325
+ const cue = metadata.winCue;
1326
+ if (!cue) return;
1327
+ stopWinSoundPreview();
1328
+ const key = winSoundSelect.value;
1329
+ const current = key === 'current' || cue.choices.some(choice => choice.key === key && choice.current);
1330
+ const url = current ? prefix + '/win-cue?track=current' : '/api/catalog/win-cues/' + encodeURIComponent(key);
1331
+ let context;
1332
+ try {
1333
+ const AudioContext = window.AudioContext || window.webkitAudioContext;
1334
+ context = previewAudio = new AudioContext();
1335
+ const decode = async path => {
1336
+ const response = await fetch(path);
1337
+ if (!response.ok) throw Error('Could not load the sound.');
1338
+ return context.decodeAudioData(await response.arrayBuffer());
1339
+ };
1340
+ await context.resume();
1341
+ const [sound, music] = await Promise.all([
1342
+ decode(url),
1343
+ cue.musicVolume > 0 ? decode(prefix + '/win-cue?track=music') : undefined,
1344
+ ]);
1345
+ if (previewAudio !== context) return;
1346
+ const start = context.currentTime + .04, impact = start + (music ? .24 : 0);
1347
+ const gain = context.createGain();
1348
+ gain.gain.value = cue.volume;
1349
+ gain.connect(context.destination);
1350
+ const source = context.createBufferSource();
1351
+ source.buffer = sound;
1352
+ source.connect(gain);
1353
+ if (music) {
1354
+ const backing = context.createBufferSource();
1355
+ const mix = context.createGain();
1356
+ backing.buffer = music;
1357
+ backing.loop = true;
1358
+ mix.gain.setValueAtTime(cue.musicVolume, start);
1359
+ if (cue.duckMusic) mix.gain.setTargetAtTime(cue.musicVolume * .2, impact, .04);
1360
+ backing.connect(mix);
1361
+ mix.connect(context.destination);
1362
+ backing.start(start);
1363
+ backing.stop(impact + sound.duration);
1364
+ }
1365
+ source.onended = () => { if (previewAudio === context) stopWinSoundPreview(); };
1366
+ source.start(impact);
1367
+ winSoundStatus.textContent = music ? 'Preview with gameplay music' : 'Win sound preview';
1368
+ } catch {
1369
+ if (previewAudio === context) {
1370
+ stopWinSoundPreview();
1371
+ winSoundStatus.textContent = 'Could not preview the sound.';
1372
+ }
1373
+ }
1374
+ };
1375
+ winSoundApply.onclick = handle(async () => {
1376
+ if (candidateId) throw Error('Choose Use this version or Discard before editing the win sound.');
1377
+ stopWinSoundPreview();
1378
+ await api('/win-cue', {expected: metadata.expected, key: winSoundSelect.value});
1379
+ await updateMetadata();
1380
+ winSoundStatus.textContent = 'Win sound saved.';
1381
+ });
1382
+
1274
1383
  function syncComparisonChoice() {
1275
1384
  $('review-before').dataset.selected = String(Boolean(candidateId) && comparisonVersion === 'before');
1276
1385
  $('review-after').dataset.selected = String(Boolean(candidateId) && comparisonVersion === 'after');
1277
1386
  $('review-replay-change').disabled = false;
1387
+ updateWinSoundApply();
1278
1388
  }
1279
1389
 
1280
1390
  function paintOutline() {
@@ -1311,10 +1421,15 @@ export async function openReview(projectId, initialMetadata) {
1311
1421
  },
1312
1422
  });
1313
1423
  }
1314
- if (metadata.targets.some(t => t.id === 'ending')) {
1424
+ if (metadata.winCue || metadata.targets.some(t => t.id === 'ending')) {
1315
1425
  chips.push({
1316
1426
  label: 'Change win sound',
1317
1427
  run: () => {
1428
+ if (metadata.winCue) {
1429
+ winSoundPanel.open = true;
1430
+ winSoundSelect.focus();
1431
+ return;
1432
+ }
1318
1433
  selectMoment('end-card');
1319
1434
  toggleAttachment(true);
1320
1435
  targetMenu.value = 'ending';
@@ -1789,6 +1904,7 @@ export async function openReview(projectId, initialMetadata) {
1789
1904
  }
1790
1905
  drawQueued();
1791
1906
  drawQuickChips();
1907
+ drawWinSoundControls();
1792
1908
  $('review-undo').hidden = !metadata.canUndo;
1793
1909
  updateExportButton();
1794
1910
  const isDraftStore = url => !url || url === 'https://play.google.com/store/apps/details?id=com.playablelab.draft' || /id=com\.(?:example|yourcompany|yourapp|demo|test)\./i.test(url);
@@ -5,7 +5,7 @@ import {resolve,dirname,basename} from 'node:path';
5
5
  import {ProjectStore} from '../project-store.mjs';
6
6
  import {EditorState} from '../editor-state.mjs';
7
7
  import {NativeService} from './service.mjs';
8
- import {runtimeBundle} from './compiler.mjs';
8
+ import {runtimeBundle,runtime3dBundle,projectUses3d} from './compiler.mjs';
9
9
  import {exportProjectFile,importProjectPath} from './local-bundle.mjs';
10
10
  import {playableHTML} from './html.mjs';
11
11
  import {registerSource} from './assets.mjs';
@@ -66,14 +66,14 @@ export function buildInspectTree(projectId,current,sceneId){
66
66
  for(const c of childrenOf(parentKey)){
67
67
  const p=c.parameters??{},parts=[`${' '.repeat(depth)}${c.id} [${shortContract(c.contract)}]`];
68
68
  if(c.contract==='native.mesh3d.v1'){
69
+ if(p.subNode)parts.push(`subNode:${p.subNode}`);
69
70
  parts.push(`${p.primitive??'box'}@(${round1(p.x??0)},${round1(p.y??0)},${round1(p.z??0)})`);
70
71
  }else{
71
72
  const t=c.transform??[1,0,0,1,0,0],tx=round1(t[4]),ty=round1(t[5]),w=round1(p.width??0),h=round1(p.height??0);
72
73
  if(tx!==0||ty!==0)parts.push(`@(${tx},${ty})`);
73
74
  if(w!==0||h!==0)parts.push(`${w}x${h}`);
74
75
  }
75
- const assetId=c.assetSlots?.[0]?.assetId;
76
- if(assetId)parts.push(`a:${assetId}`);
76
+ for(const slot of c.assetSlots??[])parts.push(`${slot.slotId==='source'?'a':slot.slotId}:${slot.assetId}`);
77
77
  if(typeof p.text==='string'){const clean=p.text.replace(/\s+/g,' ');parts.push(`"${clean.length>24?clean.slice(0,23)+'…':clean}"`);}
78
78
  if(p.visible===false)parts.push('hidden');
79
79
  if(c.prototype)parts.push('proto');
@@ -213,15 +213,15 @@ export class NativeAgentTools{
213
213
  }
214
214
  if(command==='history'){check(input.expected,'E_AGENT_EXPECTED');const r=await this.service.navigate(id,{expected:input.expected,action:input.action});return {status:'SAVED',expected:identity(r)};}
215
215
  if(command==='export'||command==='render'||command==='qa'){
216
- if(command==='qa'){const output=input.output!==undefined?resolve(input.output):undefined;return bounded(await this.service.runQa(id,{revisionId:current.revisionId,target:input.target??'standalone-browser-draft',...(output?{outputDir:output}:{}),...(input.motionFilmstrip!==undefined?{motionFilmstrip:input.motionFilmstrip}:{}),...(input.recordVideo!==undefined?{recordVideo:input.recordVideo}:{})}),65536);}
216
+ if(command==='qa'){const output=input.output!==undefined?resolve(input.output):undefined;return bounded(await this.service.runQa(id,{revisionId:current.revisionId,target:input.target??'standalone-browser-draft',...(output?{outputDir:output}:{}),...(input.motionFilmstrip!==undefined?{motionFilmstrip:input.motionFilmstrip}:{}),...(input.recordVideo!==undefined?{recordVideo:input.recordVideo}:{}),...(input.fitTargetBudget!==undefined?{fitTargetBudget:Boolean(input.fitTargetBudget)}:{})}),65536);}
217
217
  if(command==='export'&&input.targets!==undefined){
218
218
  check(input.format===undefined&&input.output===undefined&&input.target===undefined,'E_AGENT_ARGUMENT');
219
219
  check(typeof input.outputDir==='string'&&input.outputDir.length>0,'E_AGENT_OUTPUT');
220
- return bounded(await this.service.exportBatch(id,{revisionId:current.revisionId,targets:input.targets,outputDir:input.outputDir}),16384);
220
+ return bounded(await this.service.exportBatch(id,{revisionId:current.revisionId,targets:input.targets,outputDir:input.outputDir,...(input.fitTargetBudget!==undefined?{fitTargetBudget:Boolean(input.fitTargetBudget)}:{})}),16384);
221
221
  }
222
222
  check(typeof input.output==='string'&&input.output.length>0,'E_AGENT_OUTPUT');const output=resolve(input.output);let html,archiveBytes,artifactHash,sceneId,manifest;
223
- if(command==='render'){sceneId=input.sceneId??current.project.base.startScene;check(current.project.scenes.some(scene=>scene.id===sceneId),'E_AGENT_UNKNOWN_SCENE');const render=await this.service.render(id,current.revisionId);html=playableHTML({...current.project,assets:render.assets},await runtimeBundle(),{edit:true,sceneId});const {hash}=await import('./compiler.mjs');artifactHash=hash(html);}else{const artifact=await this.service.export(id,{revisionId:current.revisionId,target:input.target??'standalone-browser-draft'});html=artifact.html;archiveBytes=artifact.archiveBytes;artifactHash=artifact.manifest.artifactHash;manifest=artifact.manifest;if(artifact.archiveBytes){check(output.toLowerCase().endsWith('.zip'),'E_AGENT_OUTPUT');if((input.target??'') === 'mintegral-appgrowth-zip')check(basename(output)===`${id}.zip`,'E_AGENT_OUTPUT');}}
224
- await mkdir(dirname(output),{recursive:true});await writeFile(output,archiveBytes??html);return bounded({status:command==='render'?'RENDER_READY':'EXPORTED',projectId:id,expected:identity(current),output,artifactHash,target:command==='render'?'editor-preview':input.target??'standalone-browser-draft',...(manifest?{bytes:manifest.bytes,packaging:manifest.packaging}:{}),...(sceneId?{sceneId,edit:true}:{})},4096);
223
+ if(command==='render'){sceneId=input.sceneId??current.project.base.startScene;check(current.project.scenes.some(scene=>scene.id===sceneId),'E_AGENT_UNKNOWN_SCENE');const render=await this.service.render(id,current.revisionId);html=playableHTML({...current.project,assets:render.assets},projectUses3d(current.project)?await runtime3dBundle():await runtimeBundle(),{edit:true,sceneId});const {hash}=await import('./compiler.mjs');artifactHash=hash(html);}else{const artifact=await this.service.export(id,{revisionId:current.revisionId,target:input.target??'standalone-browser-draft',...(input.fitTargetBudget!==undefined?{fitTargetBudget:Boolean(input.fitTargetBudget)}:{})});html=artifact.html;archiveBytes=artifact.archiveBytes;artifactHash=artifact.manifest.artifactHash;manifest=artifact.manifest;if(artifact.archiveBytes){check(output.toLowerCase().endsWith('.zip'),'E_AGENT_OUTPUT');if((input.target??'') === 'mintegral-appgrowth-zip')check(basename(output)===`${id}.zip`,'E_AGENT_OUTPUT');}}
224
+ await mkdir(dirname(output),{recursive:true});await writeFile(output,archiveBytes??html);return bounded({status:command==='render'?'RENDER_READY':'EXPORTED',projectId:id,expected:identity(current),output,artifactHash,target:command==='render'?'editor-preview':input.target??'standalone-browser-draft',...(manifest?{bytes:manifest.bytes,packaging:manifest.packaging,...(manifest.budgetOptimization?{fitTargetBudget:true}:{})}:{}),...(sceneId?{sceneId,edit:true}:{})},4096);
225
225
  }
226
226
  throw Error('E_AGENT_COMMAND');
227
227
  }
@@ -15,8 +15,10 @@ import {listDemosWithStatus,materializeDemo} from './demos.mjs';
15
15
  import {AssetCatalog} from './asset-catalog.mjs';
16
16
  import {RemoteCc0Fetcher} from './remote-cc0-fetcher.mjs';
17
17
  import {stageVerifiedCc0Assets} from './cc0-staging.mjs';
18
+ import {fetchCc0Properties} from './cc0-inputs.mjs';
18
19
  import {prepAssets} from './asset-prep.mjs';
19
20
  import {PACKAGE_ROOT} from '../runtime-paths.mjs';
21
+ import {projectWinCueTrack,replaceProjectWinCue,winCuePreview} from './win-cues.mjs';
20
22
 
21
23
  const connectionErrors={
22
24
  E_REVIEW_KEY_FORMAT:400,E_REVIEW_KEY_SAVE:500,E_MODEL_AUTH:401,E_MODEL_FORBIDDEN:403,
@@ -78,9 +80,10 @@ export function nativeApi(service,connection=new ReviewConnection(service.store.
78
80
  });
79
81
  };
80
82
  return async(req,res,url,port)=>{
81
- const match=/^\/api\/projects\/([a-z][a-z0-9-]{1,47})(?:\/(transactions\/preview|transactions|history|accept|export|render|review|stage-cc0|assets(?:\/[a-z][a-z0-9_.-]{0,95})?))?$/.exec(url.pathname);
83
+ const match=/^\/api\/projects\/([a-z][a-z0-9-]{1,47})(?:\/(transactions\/preview|transactions|history|accept|export|render|review|win-cue|stage-cc0|assets(?:\/[a-z][a-z0-9_.-]{0,95})?))?$/.exec(url.pathname);
82
84
  const intake=/^\/api\/review-intakes(?:\/([a-f0-9-]{36})(?:\/(submit|assets|references|cancel|retry)(?:\/([a-z0-9_.-]+))?)?)?$/.exec(url.pathname);
83
85
  const previewMatch=/^\/api\/catalog\/preview\/([a-z0-9-]+)$/.exec(url.pathname);
86
+ const winCueMatch=/^\/api\/catalog\/win-cues\/([a-z0-9-]+)$/.exec(url.pathname);
84
87
  const connectionRoute=url.pathname==='/api/review/connection';
85
88
  const catalogRoute=url.pathname==='/api/catalog/packs';
86
89
  const assetsCatalogRoute=url.pathname==='/api/assets/catalog';
@@ -90,13 +93,19 @@ export function nativeApi(service,connection=new ReviewConnection(service.store.
90
93
  const demosRoute=url.pathname==='/api/demos';
91
94
  const demosOpenRoute=url.pathname==='/api/demos/open';
92
95
  const top=connectionRoute||catalogRoute||assetsCatalogRoute||assetsFetchRoute||assetsPrepRoute||fromChatRoute||demosRoute||demosOpenRoute||['/api/open','/api/creation/capabilities','/api/projects'].includes(url.pathname);
93
- if(!match&&!intake&&!previewMatch&&!top&&url.pathname!=='/review-runtime.js')return false;
96
+ if(!match&&!intake&&!previewMatch&&!winCueMatch&&!top&&url.pathname!=='/review-runtime.js')return false;
94
97
  const json=(status,value)=>{res.writeHead(status,{'Content-Type':'application/json'});res.end(JSON.stringify(value));};
95
98
  try{check(req.headers.host==='127.0.0.1:'+port,'E_NATIVE_ORIGIN');
96
99
  if(url.pathname==='/review-runtime.js'){
97
100
  check(req.method==='GET','E_NATIVE_METHOD');
98
101
  res.setHeader('Content-Type','text/javascript');res.end(await reviewRuntimeBundle());return true;
99
102
  }
103
+ if(winCueMatch||(match?.[2]==='win-cue'&&req.method==='GET')){
104
+ check(req.method==='GET','E_NATIVE_METHOD');
105
+ const asset=winCueMatch?await winCuePreview(winCueMatch[1]):await projectWinCueTrack(service,match[1],url.searchParams.get('track'));
106
+ res.writeHead(200,{'Content-Type':asset.mime,'X-Content-Type-Options':'nosniff'});res.end(asset.bytes);
107
+ return true;
108
+ }
100
109
  if(catalogRoute){
101
110
  check(req.method==='GET','E_NATIVE_METHOD');
102
111
  json(200,await listFreePacks());return true;
@@ -173,8 +182,8 @@ export function nativeApi(service,connection=new ReviewConnection(service.store.
173
182
  return true;
174
183
  }
175
184
  if(assetsFetchRoute){
176
- check(exact(body,['sourceUrl','packId','fileFilter'])&&typeof body.sourceUrl==='string','E_NATIVE_ARGUMENT');
177
- json(200,await cc0Fetcher.fetchPackWithFallback({sourceUrl:body.sourceUrl,packId:body.packId,fileFilter:body.fileFilter}));
185
+ check(exact(body,Object.keys(fetchCc0Properties))&&typeof body.sourceUrl==='string','E_NATIVE_ARGUMENT');
186
+ json(200,await cc0Fetcher.fetchPackWithFallback(body));
178
187
  return true;
179
188
  }
180
189
  if(assetsPrepRoute){
@@ -199,7 +208,8 @@ export function nativeApi(service,connection=new ReviewConnection(service.store.
199
208
  return true;
200
209
  }
201
210
  if(url.pathname==='/api/projects'){check(body.kind===undefined||body.kind==='native-scene','E_NATIVE_KIND');json(201,await service.create(body));return true;}
202
- check(match,'E_NATIVE_NOT_FOUND');const [,id,route]=match;const fields={history:['expected','action'],accept:['revisionId','contentHash'],export:['revisionId','target']}[route];if(fields)check(exact(body,fields)&&fields.every(key=>Object.hasOwn(body,key)),'E_NATIVE_ARGUMENT');
211
+ check(match,'E_NATIVE_NOT_FOUND');const [,id,route]=match;const fields={history:['expected','action'],accept:['revisionId','contentHash']}[route];if(fields)check(exact(body,fields)&&fields.every(key=>Object.hasOwn(body,key)),'E_NATIVE_ARGUMENT');
212
+ if(route==='export')check(exact(body,['revisionId','target','fitTargetBudget'])&&Object.hasOwn(body,'revisionId')&&Object.hasOwn(body,'target')&&(body.fitTargetBudget===undefined||typeof body.fitTargetBudget==='boolean'),'E_NATIVE_ARGUMENT');
203
213
  if(route==='assets')check((exact(body,['expected','asset'])&&Object.hasOwn(body,'expected')&&Object.hasOwn(body,'asset'))||(exact(body,['expected','assets'])&&Object.hasOwn(body,'expected')&&Object.hasOwn(body,'assets')),'E_NATIVE_ARGUMENT');
204
214
  if(route==='stage-cc0')check(exact(body,['expected','items'])&&Object.hasOwn(body,'expected')&&Array.isArray(body.items),'E_NATIVE_ARGUMENT');
205
215
  if(route==='review'){
@@ -213,6 +223,7 @@ export function nativeApi(service,connection=new ReviewConnection(service.store.
213
223
  else if(route==='transactions')json(201,await service.transact(id,body));
214
224
  else if(route==='assets')json(201,Array.isArray(body.assets)?await service.uploadBatch(id,body):await service.upload(id,body));
215
225
  else if(route==='stage-cc0')json(201,await stageVerifiedCc0Assets({service,projectId:id,expected:body.expected,items:body.items,catalog:assetCatalog,remoteFetcher:cc0Fetcher}));
226
+ else if(route==='win-cue')json(201,await replaceProjectWinCue(service,id,body));
216
227
  else if(route==='history')json(200,await service.navigate(id,body));
217
228
  else if(route==='accept')json(200,await service.accept(id,body));
218
229
  else if(route==='export')json(200,await service.export(id,body));