@tora-editor/tora 0.1.0 → 0.3.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 (131) hide show
  1. package/README.md +107 -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 +322 -28
  17. package/crates/packer/trusted/native-3d-meta.json +4 -3
  18. package/crates/packer/trusted/native-3d.js +181 -181
  19. package/crates/packer/trusted/native-meta.json +3 -3
  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 +4 -3
  23. package/crates/packer/trusted/review-runtime.js +182 -182
  24. package/docs/MIGRATION_0_3.md +39 -0
  25. package/docs/NATIVE_AGENT_TOOLS.md +12 -363
  26. package/docs/TORA_AGENT_SETUP.md +24 -95
  27. package/docs/TORA_CREATION_API.md +63 -348
  28. package/docs/reference/CORE_AUTHORING.md +10 -3
  29. package/docs/reference/PLAYABLE_STARTERS.md +20 -0
  30. package/docs/reference/packs/3d.md +11 -3
  31. package/network-rules/mintegral-appgrowth-single-html.json +10 -10
  32. package/package.json +6 -6
  33. package/packages/creative-project/project-v21.schema.json +372 -9
  34. package/scripts/lean/editor/entry.js +11 -6
  35. package/scripts/lean/editor/project-launcher.js +116 -0
  36. package/scripts/lean/editor/quick-edit-panel.js +479 -0
  37. package/scripts/lean/editor/review-editor.css +256 -68
  38. package/scripts/lean/editor/review-editor.js +1834 -1086
  39. package/scripts/lean/editor-state.mjs +6 -0
  40. package/scripts/lean/editor.mjs +6 -3
  41. package/scripts/lean/matrix.mjs +5 -0
  42. package/scripts/lean/native/agent-tools.mjs +39 -62
  43. package/scripts/lean/native/api.mjs +161 -136
  44. package/scripts/lean/native/asset-catalog.mjs +7 -6
  45. package/scripts/lean/native/asset-lineage.mjs +54 -0
  46. package/scripts/lean/native/asset-prep.mjs +173 -40
  47. package/scripts/lean/native/assets.mjs +107 -11
  48. package/scripts/lean/native/audio-assets.mjs +30 -0
  49. package/scripts/lean/native/browser-pool.mjs +34 -0
  50. package/scripts/lean/native/build-cache.mjs +38 -7
  51. package/scripts/lean/native/cc0-inputs.mjs +24 -0
  52. package/scripts/lean/native/cc0-staging.mjs +28 -8
  53. package/scripts/lean/native/compiler.mjs +9 -3
  54. package/scripts/lean/native/contracts.mjs +16 -11
  55. package/scripts/lean/native/creative-qa.mjs +365 -128
  56. package/scripts/lean/native/demos.mjs +53 -18
  57. package/scripts/lean/native/document.mjs +50 -12
  58. package/scripts/lean/native/export-budget.mjs +75 -0
  59. package/scripts/lean/native/local-bundle.mjs +7 -3
  60. package/scripts/lean/native/mcp-server.mjs +42 -74
  61. package/scripts/lean/native/media-validate.mjs +124 -0
  62. package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
  63. package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
  64. package/scripts/lean/native/modules/star-salvage.mjs +3 -368
  65. package/scripts/lean/native/native-bin.mjs +3 -3
  66. package/scripts/lean/native/outcome-playthrough.mjs +97 -0
  67. package/scripts/lean/native/project-bundle.mjs +6 -5
  68. package/scripts/lean/native/project-index.mjs +0 -2
  69. package/scripts/lean/native/qa-adapters.mjs +10 -0
  70. package/scripts/lean/native/quick-edit.mjs +328 -0
  71. package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
  72. package/scripts/lean/native/review.mjs +205 -571
  73. package/scripts/lean/native/schema-vocabulary.mjs +10 -0
  74. package/scripts/lean/native/schema.mjs +7 -5
  75. package/scripts/lean/native/scope.mjs +45 -0
  76. package/scripts/lean/native/service.mjs +378 -79
  77. package/scripts/lean/native/starters.mjs +563 -0
  78. package/scripts/lean/native/variant-adapters.mjs +8 -0
  79. package/scripts/lean/native/variants-core.mjs +186 -0
  80. package/scripts/lean/native/variants.mjs +63 -0
  81. package/scripts/lean/native/win-cues.mjs +96 -0
  82. package/skills/tora-playables/SKILL.md +1 -1
  83. package/scripts/lean/editor/review-intake.js +0 -837
  84. package/scripts/lean/model-client.mjs +0 -119
  85. package/scripts/lean/native/author-expansion-proofs.mjs +0 -240
  86. package/scripts/lean/native/author-games.mjs +0 -160
  87. package/scripts/lean/native/author-harvest.mjs +0 -74
  88. package/scripts/lean/native/author-primitive-proofs.mjs +0 -874
  89. package/scripts/lean/native/author-salvage.mjs +0 -71
  90. package/scripts/lean/native/chat-compose.mjs +0 -287
  91. package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -191
  92. package/scripts/lean/native/check-salvage.mjs +0 -197
  93. package/scripts/lean/native/compatibility.mjs +0 -34
  94. package/scripts/lean/native/concept.mjs +0 -633
  95. package/scripts/lean/native/draw-stroke.mjs +0 -26
  96. package/scripts/lean/native/erase-mask.mjs +0 -18
  97. package/scripts/lean/native/harvest-recipe.mjs +0 -21
  98. package/scripts/lean/native/instance-steering.mjs +0 -24
  99. package/scripts/lean/native/intake-creator-agent.mjs +0 -98
  100. package/scripts/lean/native/intake-creator-tools.mjs +0 -165
  101. package/scripts/lean/native/interaction-gestures.mjs +0 -45
  102. package/scripts/lean/native/match-board.mjs +0 -138
  103. package/scripts/lean/native/modules/index.mjs +0 -54
  104. package/scripts/lean/native/modules/tap-collect.mjs +0 -54
  105. package/scripts/lean/native/path-network.mjs +0 -132
  106. package/scripts/lean/native/physics-2d.mjs +0 -154
  107. package/scripts/lean/native/physics-3d.mjs +0 -259
  108. package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
  109. package/scripts/lean/native/prepare-game-audio.mjs +0 -372
  110. package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
  111. package/scripts/lean/native/prepare-golf-assets.py +0 -211
  112. package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
  113. package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
  114. package/scripts/lean/native/prepare-primitive-images.py +0 -25
  115. package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
  116. package/scripts/lean/native/prepare-traffic-assets.py +0 -329
  117. package/scripts/lean/native/presentation.mjs +0 -335
  118. package/scripts/lean/native/review-agent-tools.mjs +0 -561
  119. package/scripts/lean/native/review-connection.mjs +0 -303
  120. package/scripts/lean/native/review-fields.mjs +0 -24
  121. package/scripts/lean/native/review-intake.mjs +0 -385
  122. package/scripts/lean/native/review-intents.mjs +0 -217
  123. package/scripts/lean/native/review-provider.mjs +0 -580
  124. package/scripts/lean/native/review-receipts.mjs +0 -76
  125. package/scripts/lean/native/review-resolver.mjs +0 -429
  126. package/scripts/lean/native/review-targets.mjs +0 -35
  127. package/scripts/lean/native/runtime.mjs +0 -1623
  128. package/scripts/lean/native/salvage-recipe.mjs +0 -20
  129. package/scripts/lean/native/stage-3d.mjs +0 -818
  130. package/scripts/lean/native/verify.mjs +0 -4
  131. package/scripts/lean/scene-document.mjs +0 -48
@@ -1,211 +0,0 @@
1
- """Render crisp high-DPI sunlit sprites from verified CC0 Kenney Mini Golf Kit OBJ models via Blender."""
2
- import hashlib
3
- import json
4
- import math
5
- import os
6
- from pathlib import Path
7
-
8
- import bpy
9
- from mathutils import Vector
10
-
11
- ROOT = Path(__file__).resolve().parents[3]
12
- KIT = ROOT / ".data" / "T029" / "originals" / "minigolf-kit" / "Models" / "OBJ format"
13
- FALLBACK_KIT = ROOT / "fixtures" / "mini-golf" / "models"
14
- OUT = ROOT / "assets" / "tora-golf" / "imported"
15
- PLAN_PATH = ROOT / "assets" / "tora-golf" / "plan.json"
16
- OUT.mkdir(parents=True, exist_ok=True)
17
-
18
-
19
- def sha256_file(path: Path) -> str:
20
- return "sha256:" + hashlib.sha256(path.read_bytes()).hexdigest()
21
-
22
-
23
- def reset_scene():
24
- bpy.ops.wm.read_factory_settings(use_empty=True)
25
- scene = bpy.context.scene
26
- scene.render.engine = "BLENDER_EEVEE_NEXT" if "BLENDER_EEVEE_NEXT" in bpy.types.RenderSettings.bl_rna.properties["engine"].enum_items.keys() else "CYCLES"
27
- if scene.render.engine == "CYCLES":
28
- scene.cycles.samples = 16
29
- scene.cycles.use_denoising = False
30
- else:
31
- scene.eevee.taa_render_samples = 16
32
- scene.render.film_transparent = True
33
- scene.render.image_settings.file_format = "PNG"
34
- scene.render.image_settings.color_mode = "RGBA"
35
- scene.view_settings.view_transform = "Standard"
36
-
37
- # Bright warm sunlit world ambient
38
- world = bpy.data.worlds.new("SunlitWorld")
39
- scene.world = world
40
- world.use_nodes = True
41
- bg = world.node_tree.nodes.get("Background")
42
- if bg:
43
- bg.inputs[0].default_value = (0.95, 0.98, 1.0, 1.0)
44
- bg.inputs[1].default_value = 0.85
45
-
46
- # Warm key sun
47
- sun_data = bpy.data.lights.new("SunKey", type="SUN")
48
- sun_data.energy = 2.6
49
- sun_data.color = (1.0, 0.97, 0.91)
50
- sun = bpy.data.objects.new("SunKey", sun_data)
51
- scene.collection.objects.link(sun)
52
- sun.rotation_euler = (math.radians(42), math.radians(15), math.radians(-35))
53
-
54
- # Cool sky fill sun
55
- fill_data = bpy.data.lights.new("SkyFill", type="SUN")
56
- fill_data.energy = 0.9
57
- fill_data.color = (0.78, 0.92, 1.0)
58
- fill = bpy.data.objects.new("SkyFill", fill_data)
59
- scene.collection.objects.link(fill)
60
- fill.rotation_euler = (math.radians(60), math.radians(-20), math.radians(135))
61
- return scene
62
-
63
-
64
- def import_obj(obj_path: Path):
65
- before = set(bpy.context.scene.objects)
66
- bpy.ops.wm.obj_import(filepath=str(obj_path))
67
- imported = [obj for obj in bpy.context.scene.objects if obj not in before]
68
- for obj in imported:
69
- if obj.type == "MESH":
70
- for mat in obj.data.materials:
71
- if mat and mat.use_nodes:
72
- for node in mat.node_tree.nodes:
73
- if node.type == "BSDF_PRINCIPLED":
74
- node.inputs["Roughness"].default_value = 0.42
75
- if "Specular IOR Level" in node.inputs:
76
- node.inputs["Specular IOR Level"].default_value = 0.35
77
- return imported
78
-
79
-
80
- def render_model(asset_id: str, obj_name: str, res: tuple[int, int], elev_deg: float, azim_deg: float, padding: float = 1.18, tint_white: bool = False):
81
- scene = reset_scene()
82
- obj_path = KIT / obj_name
83
- if not obj_path.exists():
84
- obj_path = FALLBACK_KIT / obj_name
85
- objs = import_obj(obj_path)
86
- if tint_white:
87
- if scene.world and scene.world.use_nodes:
88
- bg = scene.world.node_tree.nodes.get("Background")
89
- if bg:
90
- bg.inputs[1].default_value = 0.28
91
- for obj in objs:
92
- if obj.type == "MESH":
93
- mat = bpy.data.materials.new("IvoryGolfBall")
94
- mat.use_nodes = True
95
- bsdf = mat.node_tree.nodes.get("Principled BSDF")
96
- if bsdf:
97
- bsdf.inputs["Base Color"].default_value = (0.94, 0.95, 0.92, 1.0)
98
- bsdf.inputs["Roughness"].default_value = 0.35
99
- obj.data.materials.clear()
100
- obj.data.materials.append(mat)
101
-
102
- # Compute world-space bounding box
103
- bpy.context.view_layer.update()
104
- corners = []
105
- for obj in objs:
106
- if obj.type == "MESH":
107
- for v in obj.bound_box:
108
- corners.append(obj.matrix_world @ Vector(v))
109
- min_v = Vector((min(c.x for c in corners), min(c.y for c in corners), min(c.z for c in corners)))
110
- max_v = Vector((max(c.x for c in corners), max(c.y for c in corners), max(c.z for c in corners)))
111
- center = (min_v + max_v) * 0.5
112
- size = max_v - min_v
113
-
114
- cam_data = bpy.data.cameras.new("Cam")
115
- cam_data.type = "ORTHO"
116
- cam = bpy.data.objects.new("Cam", cam_data)
117
- scene.collection.objects.link(cam)
118
- scene.camera = cam
119
-
120
- elev = math.radians(elev_deg)
121
- azim = math.radians(azim_deg)
122
- dist = max(size.length * 3.0, 4.0)
123
- cam.location = center + Vector((
124
- dist * math.cos(elev) * math.sin(azim),
125
- -dist * math.cos(elev) * math.cos(azim),
126
- dist * math.sin(elev),
127
- ))
128
- direction = (center - cam.location).normalized()
129
- cam.rotation_euler = direction.to_track_quat("-Z", "Y").to_euler()
130
- bpy.context.view_layer.update()
131
-
132
- # Exact ortho framing from projected bounding box corners
133
- inv = cam.matrix_world.inverted()
134
- proj = [inv @ c for c in corners]
135
- span_x = max(p.x for p in proj) - min(p.x for p in proj)
136
- span_y = max(p.y for p in proj) - min(p.y for p in proj)
137
- aspect = res[0] / res[1]
138
- ortho_w = max(span_x, span_y * aspect) * padding
139
- cam_data.ortho_scale = max(ortho_w, 0.05)
140
-
141
- # Re-center camera cleanly onto projected bbox center
142
- cx = (max(p.x for p in proj) + min(p.x for p in proj)) * 0.5
143
- cy = (max(p.y for p in proj) + min(p.y for p in proj)) * 0.5
144
- cam.location = cam.matrix_world @ Vector((cx, cy, 0.0))
145
-
146
- scene.render.resolution_x = res[0]
147
- scene.render.resolution_y = res[1]
148
- scene.render.resolution_percentage = 100
149
- dest = OUT / f"{asset_id}.png"
150
- scene.render.filepath = str(dest)
151
- bpy.ops.render.render(write_still=True)
152
-
153
- return {
154
- "id": asset_id,
155
- "file": str(dest.relative_to(ROOT)),
156
- "sha256": sha256_file(dest),
157
- "processing": {
158
- "kind": "blender-orthographic-render",
159
- "sourceFile": str(obj_path.relative_to(ROOT)),
160
- "sourceSha256": sha256_file(obj_path),
161
- "tool": "Blender 4.5.9 LTS orthographic render from immutable Kenney CC0 OBJ",
162
- },
163
- }
164
-
165
-
166
- def main():
167
- manifest = [
168
- render_model("golf.ball", "ball-blue.obj", (96, 96), elev_deg=50, azim_deg=35, padding=1.22, tint_white=True),
169
- render_model("golf.flag", "flag-red.obj", (128, 160), elev_deg=20, azim_deg=35, padding=1.28),
170
- render_model("golf.club", "club-red.obj", (128, 160), elev_deg=18, azim_deg=-30, padding=1.28),
171
- render_model("golf.castle", "castle.obj", (192, 160), elev_deg=36, azim_deg=32, padding=1.18),
172
- render_model("golf.windmill", "windmill.obj", (192, 192), elev_deg=32, azim_deg=30, padding=1.18),
173
- ]
174
-
175
- # Copy faithful Kenney CC0 isometric tree for lush course border framing
176
- tree_src = ROOT / "fixtures" / "traffic-tycoon" / "assets" / "tree.png"
177
- tree_dst = OUT / "golf.tree.png"
178
- tree_dst.write_bytes(tree_src.read_bytes())
179
- manifest.append({
180
- "id": "golf.tree",
181
- "file": str(tree_dst.relative_to(ROOT)),
182
- "sha256": sha256_file(tree_dst),
183
- "processing": {
184
- "kind": "identity-copy",
185
- "sourceFile": str(tree_src.relative_to(ROOT)),
186
- "sourceSha256": sha256_file(tree_src),
187
- "tool": "exact byte copy",
188
- },
189
- })
190
-
191
- plan = {
192
- "format": "tora-native-asset-plan-1",
193
- "source": {
194
- "id": "kenney-minigolf-kit",
195
- "author": "Kenney",
196
- "sourceUrl": "https://kenney.nl/assets/minigolf-kit",
197
- "license": "CC0-1.0",
198
- "licenseUrl": "https://creativecommons.org/publicdomain/zero/1.0/",
199
- "licenseFile": "fixtures/mini-golf/licenses/minigolf-kit.txt",
200
- "attributionRequired": False,
201
- },
202
- "visualDirection": "Sunlit miniature golf course with sky-blue backdrop, lush mowed emerald fairway, warm cedar wooden rails, crisp red flag, castle & windmill course props, and warm cream HUD pills.",
203
- "preparation": "High-resolution orthographic PNG sprites rendered deterministically via Blender from immutable CC0 Kenney Mini Golf Kit OBJ models.",
204
- "files": manifest,
205
- }
206
- PLAN_PATH.write_text(json.dumps(plan, indent=2) + "\n")
207
- print(f"Prepared {len(manifest)} Mini Golf assets -> {PLAN_PATH.relative_to(ROOT)}")
208
-
209
-
210
- if __name__ == "__main__":
211
- main()
@@ -1,83 +0,0 @@
1
- import {chromium} from 'playwright';
2
- import {readFile,writeFile,mkdir} from 'node:fs/promises';
3
- import {resolve} from 'node:path';
4
- import {createHash} from 'node:crypto';
5
- import {Buffer} from 'node:buffer';
6
- import process from 'node:process';
7
-
8
- // Format conversion of downloaded CC0 audio only. No oscillators or composed content.
9
- const root=resolve(import.meta.dirname,'../../..');
10
- const folder=resolve(root,'assets/kenney-harvest');
11
- const hash=bytes=>'sha256:'+createHash('sha256').update(bytes).digest('hex');
12
- const sources=[
13
- {id:'kenney-interface-sounds',author:'Kenney',license:'CC0-1.0',sourceUrl:'https://kenney.nl/assets/interface-sounds',styleFamily:'kenney-interface-sounds',licenseFile:'assets/kenney-harvest/source/interface-sounds/License.txt',archive:{url:'https://opengameart.org/sites/default/files/kenney_interfaceSounds.zip',file:'assets/kenney-harvest/source/interface-sounds.zip'}},
14
- {id:'kenney-music-jingles',author:'Kenney',license:'CC0-1.0',sourceUrl:'https://kenney.nl/assets/music-jingles',styleFamily:'kenney-music-jingles',licenseFile:'assets/kenney-harvest/source/music-jingles/license.txt',archive:{url:'https://opengameart.org/sites/default/files/jingleSounds_Kenney.zip',file:'assets/kenney-harvest/source/music-jingles.zip'}},
15
- {id:'zane-little-flowerbed-fields',author:'Zane Little Music',license:'CC0-1.0',sourceUrl:'https://opengameart.org/content/flowerbed-fields-loop',styleFamily:'zane-little-chiptune',licenseFile:'assets/kenney-harvest/source/flowerbed-fields/source-page.html',archive:{url:'https://opengameart.org/sites/default/files/flowerbed_fields.ogg',file:'assets/kenney-harvest/source/flowerbed-fields/flowerbed_fields.ogg'}},
16
- ];
17
- const cues=[
18
- {id:'audio-match',role:'match',sourceId:sources[0].id,input:'source/interface-sounds/Audio/confirmation_001.ogg',duration:.65},
19
- {id:'audio-reject',role:'reject',sourceId:sources[0].id,input:'source/interface-sounds/Audio/error_004.ogg',duration:.3},
20
- {id:'audio-repair',role:'repair',sourceId:sources[1].id,input:'source/music-jingles/OGG/jingles_NES/jingles_NES09.ogg',duration:1.4},
21
- {id:'audio-complete',role:'complete',sourceId:sources[1].id,input:'source/music-jingles/OGG/jingles_NES/jingles_NES00.ogg',duration:3},
22
- {id:'audio-victory',role:'victory',sourceId:sources[1].id,input:'source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg',catalogOnly:true},
23
- {id:'audio-ambient',role:'ambient',sourceId:sources[2].id,input:'source/flowerbed-fields/flowerbed_fields.ogg',duration:16},
24
- ];
25
- const browser=await chromium.launch();
26
- const report=[];
27
- try {
28
- const page=await browser.newPage();
29
- await mkdir(resolve(folder,'audio'),{recursive:true});
30
- for(const cue of cues){
31
- const input=await readFile(resolve(folder,cue.input));
32
- const converted=await page.evaluate(async({base64,duration})=>{
33
- const bytes=Uint8Array.from(globalThis.atob(base64),c=>c.charCodeAt(0));
34
- const decoder=new globalThis.OfflineAudioContext(1,1,16000);
35
- const decoded=await decoder.decodeAudioData(bytes.buffer);
36
- const seconds=Math.min(decoded.duration,duration??decoded.duration);
37
- const context=new globalThis.OfflineAudioContext(1,Math.ceil(seconds*16000),16000);
38
- const source=context.createBufferSource();source.buffer=decoded;source.connect(context.destination);source.start();
39
- const pcm=(await context.startRendering()).getChannelData(0);
40
- const output=new Uint8Array(44+pcm.length*2),view=new DataView(output.buffer);
41
- const text=(at,value)=>{for(let i=0;i<value.length;i++)output[at+i]=value.charCodeAt(i);};
42
- text(0,'RIFF');view.setUint32(4,output.length-8,true);text(8,'WAVEfmt ');view.setUint32(16,16,true);view.setUint16(20,1,true);view.setUint16(22,1,true);view.setUint32(24,16000,true);view.setUint32(28,32000,true);view.setUint16(32,2,true);view.setUint16(34,16,true);text(36,'data');view.setUint32(40,pcm.length*2,true);
43
- // Source excerpt boundary fades prevent a hard cut; no notes or layers added.
44
- const fade=duration?320:0;let peak=0,clipped=0;
45
- for(let i=0;i<pcm.length;i++){
46
- const gain=fade?Math.min(1,i/fade,(pcm.length-1-i)/fade):1;
47
- const sample=Math.max(-1,Math.min(1,pcm[i]*gain));
48
- peak=Math.max(peak,Math.abs(sample));if(Math.abs(pcm[i]*gain)>1)clipped++;
49
- view.setInt16(44+i*2,Math.round(sample*(sample<0?32768:32767)),true);
50
- }
51
- let encoded='';for(let i=0;i<output.length;i+=8192)encoded+=String.fromCharCode(...output.subarray(i,i+8192));
52
- return {base64:globalThis.btoa(encoded),sourceDuration:decoded.duration,duration:pcm.length/16000,peak,clipped};
53
- },{base64:input.toString('base64'),duration:cue.duration});
54
- const bytes=Buffer.from(converted.base64,'base64');
55
- const file='audio/'+cue.role+'.wav';await writeFile(resolve(folder,file),bytes);
56
- report.push({...cue,file,sha256:hash(bytes),sourceSha256:hash(input),sourceDuration:converted.sourceDuration,duration:converted.duration,peak:converted.peak,clipped:converted.clipped});
57
- }
58
- const catalogFile=resolve(root,'assets/free-assets/catalog.json');
59
- const catalog=JSON.parse(await readFile(catalogFile,'utf8'));
60
- for(const record of sources){
61
- const {archive,...source}=record;
62
- source.licenseUrl='https://creativecommons.org/publicdomain/zero/1.0/';
63
- source.licenseSha256=hash(await readFile(resolve(root,record.licenseFile)));
64
- source.archive={url:archive.url,sha256:hash(await readFile(resolve(root,archive.file)))};
65
- source.files=report.filter(cue=>cue.sourceId===source.id).map(cue=>({
66
- path:cue.file,file:'assets/kenney-harvest/'+cue.file,mime:'audio/wav',sha256:cue.sha256,
67
- processing:{kind:'audio-transcode',sourceFile:'assets/kenney-harvest/'+cue.input,sourceSha256:cue.sourceSha256,tool:'Web Audio OfflineAudioContext',arguments:['decodeAudioData','mono','16000 Hz','16-bit PCM',...(cue.duration?[`first ${cue.duration} seconds`,'20ms source boundary fades']:['full source duration'])]},
68
- }));
69
- catalog.sources=catalog.sources.filter(old=>old.id!==source.id);catalog.sources.push(source);
70
- }
71
- await writeFile(catalogFile,JSON.stringify(catalog,null,2)+'\n');
72
- const planFile=resolve(folder,'plan.json'),plan=JSON.parse(await readFile(planFile));
73
- plan.assets=plan.assets.filter(asset=>!asset.id.startsWith('audio-'));
74
- plan.audio={};
75
- for(const cue of report.filter(item=>!item.catalogOnly)){
76
- const source=sources.find(source=>source.id===cue.sourceId);
77
- const provenance={origin:'third-party-free',sourceId:source.id,sourceFile:cue.file,sourceHash:cue.sha256,author:source.author,license:source.license,sourceUrl:source.sourceUrl,styleFamily:source.styleFamily};
78
- plan.assets.push({id:cue.id,file:cue.file,mime:'audio/wav',rights:`${source.author}, CC0-1.0. ${source.sourceUrl}`,provenance});plan.audio[cue.role]=cue.id;
79
- }
80
- await writeFile(planFile,JSON.stringify(plan,null,2)+'\n');
81
- await writeFile(resolve(folder,'audio-conversion.json'),JSON.stringify({method:'Sourced audio format conversion only',browser:browser.version(),script:'scripts/lean/native/prepare-harvest-audio.mjs',cues:report},null,2)+'\n');
82
- process.stdout.write(JSON.stringify(report.map(({role,duration,clipped})=>({role,duration,clipped})))+'\n');
83
- } finally {await browser.close();}
@@ -1,31 +0,0 @@
1
- import {readFile,writeFile,mkdir} from 'node:fs/promises';
2
- import {createHash} from 'node:crypto';
3
- import {resolve,dirname} from 'node:path';
4
- import process from 'node:process';
5
- import {preparePngSource} from './asset-policy.mjs';
6
-
7
- // Import preparation only. Original pixels/IDAT and source files stay intact.
8
- const root=resolve(import.meta.dirname,'../../..');
9
- const catalogFile=resolve(root,'assets/free-assets/catalog.json');
10
- const catalog=JSON.parse(await readFile(catalogFile,'utf8'));
11
- const source=catalog.sources.find(source=>source.id==='kenney-tiny-farm');
12
- const hash=bytes=>'sha256:'+createHash('sha256').update(bytes).digest('hex');
13
- for(const file of source.files){
14
- const raw='assets/kenney-harvest/source/tiny-farm/'+file.path;
15
- const bytes=await readFile(resolve(root,raw));
16
- const prepared=preparePngSource(bytes);
17
- const imported='assets/kenney-harvest/imported/'+file.path;
18
- await mkdir(dirname(resolve(root,imported)),{recursive:true});
19
- await writeFile(resolve(root,imported),prepared);
20
- Object.assign(file,{file:imported,sha256:hash(prepared),processing:{kind:'png-strip-color-metadata',sourceFile:raw,sourceSha256:hash(bytes)}});
21
- }
22
- await writeFile(catalogFile,JSON.stringify(catalog,null,2)+'\n');
23
- const planFile=resolve(root,'assets/kenney-harvest/plan.json');
24
- const plan=JSON.parse(await readFile(planFile,'utf8'));
25
- for(const asset of plan.assets){
26
- if(asset.provenance.sourceId!==source.id)continue;
27
- const file=source.files.find(file=>file.path===asset.provenance.sourceFile);
28
- asset.file=file.file.slice('assets/kenney-harvest/'.length);asset.provenance.sourceHash=file.sha256;
29
- }
30
- await writeFile(planFile,JSON.stringify(plan,null,2)+'\n');
31
- process.stdout.write(`Prepared ${source.files.length} licensed PNGs with exact retained image bytes.\n`);
@@ -1,25 +0,0 @@
1
- from pathlib import Path
2
- from PIL import Image
3
- import hashlib
4
- import json
5
-
6
- for kind in ("sports", "racing"):
7
- root = Path("assets") / f"kenney-{kind}"
8
- plan_path = root / "plan.json"
9
- plan = json.loads(plan_path.read_text())
10
- for entry in plan["files"]:
11
- source = Path(entry["file"])
12
- output = root / "imported" / f"{entry['id']}.png"
13
- output.parent.mkdir(parents=True, exist_ok=True)
14
- with Image.open(source) as image:
15
- image.convert("RGBA").save(output, format="PNG", optimize=True)
16
- original = entry["sha256"]
17
- entry["processing"] = {
18
- "kind": "png-rgba8-conversion",
19
- "sourceFile": str(source),
20
- "sourceSha256": original,
21
- "tool": "Pillow Image.convert(RGBA)",
22
- }
23
- entry["file"] = str(output)
24
- entry["sha256"] = "sha256:" + hashlib.sha256(output.read_bytes()).hexdigest()
25
- plan_path.write_text(json.dumps(plan, indent=2) + "\n")
@@ -1,89 +0,0 @@
1
- import {createHash} from 'node:crypto';
2
- import {mkdir,readFile,writeFile} from 'node:fs/promises';
3
- import {dirname,resolve} from 'node:path';
4
- import process from 'node:process';
5
- import {preparePngSource} from './asset-policy.mjs';
6
-
7
- const root=resolve(import.meta.dirname,'../../..');
8
- const assetRoot='assets/kenney-space-salvage';
9
- const sourceRoot=assetRoot+'/source/space-shooter-redux';
10
- const archiveFile=assetRoot+'/source/SpaceShooterRedux.zip';
11
- const catalogFile=resolve(root,'assets/free-assets/catalog.json');
12
- const hash=bytes=>'sha256:'+createHash('sha256').update(bytes).digest('hex');
13
- const curated=[
14
- ['salvage-backdrop','Backgrounds/darkPurple.png'],
15
- ['salvage-ship','PNG/playerShip1_blue.png'],
16
- ['salvage-thruster','PNG/Effects/fire03.png'],
17
- ['salvage-shield-1','PNG/Effects/shield1.png'],
18
- ['salvage-shield-2','PNG/Effects/shield2.png'],
19
- ['salvage-shield-3','PNG/Effects/shield3.png'],
20
- ['salvage-core','PNG/Power-ups/powerupYellow_star.png'],
21
- ['salvage-core-alt','PNG/Power-ups/star_gold.png'],
22
- ['salvage-hazard','PNG/Meteors/meteorBrown_med1.png'],
23
- ['salvage-hazard-alt','PNG/Meteors/meteorGrey_big1.png'],
24
- ['salvage-bay','PNG/ufoBlue.png'],
25
- ['salvage-engine','PNG/Parts/engine2.png'],
26
- ['salvage-cockpit','PNG/Parts/cockpitBlue_2.png'],
27
- ['salvage-wing','PNG/Parts/wingBlue_0.png'],
28
- ['salvage-spark','PNG/Effects/star2.png'],
29
- ['salvage-numeral-3','PNG/UI/numeral3.png'],
30
- ];
31
- const audio=[
32
- ['ambient','arcade-pop-ambient'],
33
- ['catch','arcade-pop-match'],
34
- ['repair','arcade-pop-reward'],
35
- ['complete','arcade-pop-win'],
36
- ['loss','arcade-pop-loss'],
37
- ['reject','arcade-pop-reject'],
38
- ];
39
- const catalog=JSON.parse(await readFile(catalogFile,'utf8'));
40
- const source={
41
- id:'kenney-space-shooter-redux',author:'Kenney',license:'CC0-1.0',
42
- sourceUrl:'https://opengameart.org/content/space-shooter-redux',
43
- licenseUrl:'https://creativecommons.org/publicdomain/zero/1.0/',
44
- styleFamily:'kenney-space-shooter-redux',licenseFile:sourceRoot+'/License.txt',
45
- licenseSha256:hash(await readFile(resolve(root,sourceRoot,'License.txt'))),
46
- archive:{url:'https://opengameart.org/sites/default/files/SpaceShooterRedux.zip',sha256:hash(await readFile(resolve(root,archiveFile)))},
47
- files:[],
48
- };
49
- const plan={
50
- format:'tora-star-salvage-plan-1',seed:9173,firstHintSeconds:.8,
51
- rewardRecipe:{id:'salvage-reward-1',variant:'seeded'},
52
- sprites:{ship:'salvage-ship',core:'salvage-core',hazard:'salvage-hazard',backdrop:'salvage-backdrop'},
53
- coreVariants:['salvage-core','salvage-core-alt'],hazardVariants:['salvage-hazard','salvage-hazard-alt'],
54
- bay:[
55
- {id:'bay-station',assetId:'salvage-bay',unlockAt:0},
56
- {id:'bay-thrusters',assetId:'salvage-engine',unlockAt:1},
57
- {id:'bay-shield',assetId:'salvage-shield-2',unlockAt:2},
58
- {id:'bay-core',assetId:'salvage-shield-3',unlockAt:3},
59
- ],
60
- audio:Object.fromEntries(audio.map(([role])=>[role,'salvage-audio-'+role])),assets:[],
61
- };
62
- for(const [id,path] of curated){
63
- const sourceFile=sourceRoot+'/'+path,bytes=await readFile(resolve(root,sourceFile)),prepared=preparePngSource(bytes);
64
- const imported=assetRoot+'/imported/'+path;
65
- await mkdir(dirname(resolve(root,imported)),{recursive:true});
66
- await writeFile(resolve(root,imported),prepared);
67
- const sha256=hash(prepared);
68
- source.files.push({path,file:imported,mime:'image/png',sha256,processing:{kind:'png-strip-color-metadata',sourceFile,sourceSha256:hash(bytes)}});
69
- plan.assets.push({id,file:imported.slice(assetRoot.length+1),mime:'image/png',rights:'Kenney Space Shooter Redux, CC0-1.0. https://opengameart.org/content/space-shooter-redux',provenance:{
70
- origin:'third-party-free',sourceId:source.id,sourceFile:path,sourceHash:sha256,author:source.author,license:source.license,sourceUrl:source.sourceUrl,styleFamily:source.styleFamily,
71
- }});
72
- }
73
- const catalogFiles=catalog.sources.flatMap(entry=>entry.files.map(file=>({file,source:entry})));
74
- for(const [role,catalogId] of audio){
75
- const match=catalogFiles.find(({file})=>file.id===catalogId);
76
- if(!match)throw Error('Missing verified audio catalog entry: '+catalogId);
77
- const {file,source:audioSource}=match,bytes=await readFile(resolve(root,file.file));
78
- if(hash(bytes)!==file.sha256)throw Error('Audio hash mismatch: '+catalogId);
79
- const output=assetRoot+'/audio/'+role+'.wav';
80
- await mkdir(dirname(resolve(root,output)),{recursive:true});
81
- await writeFile(resolve(root,output),bytes);
82
- plan.assets.push({id:'salvage-audio-'+role,file:output.slice(assetRoot.length+1),mime:'audio/wav',rights:audioSource.author+', CC0-1.0. '+audioSource.sourceUrl,provenance:{
83
- origin:'third-party-free',sourceId:audioSource.id,sourceFile:file.path,sourceHash:file.sha256,author:audioSource.author,license:audioSource.license,sourceUrl:audioSource.sourceUrl,styleFamily:audioSource.styleFamily,
84
- }});
85
- }
86
- catalog.sources=[...catalog.sources.filter(entry=>entry.id!==source.id),source];
87
- await writeFile(catalogFile,JSON.stringify(catalog,null,2)+'\n');
88
- await writeFile(resolve(root,assetRoot,'plan.json'),JSON.stringify(plan,null,2)+'\n');
89
- process.stdout.write(`Prepared ${source.files.length} verified Redux PNGs and ${audio.length} unchanged arcade-pop WAVs.\n`);