@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.
- package/README.md +107 -58
- package/assets/free-audio/arcade-pop/audio/loss.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/reward.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/win.wav +0 -0
- package/assets/free-audio/arcade-pop/source/INFO.txt +11 -11
- package/assets/kenney-food-starter/License.txt +28 -0
- package/assets/kenney-food-starter/burger.glb +0 -0
- package/assets/kenney-food-starter/frying-pan.glb +0 -0
- package/assets/kenney-food-starter/plan.json +61 -0
- package/assets/kenney-food-starter/plate.glb +0 -0
- package/assets/kenney-food-starter/pot.glb +0 -0
- package/assets/kenney-harvest/audio/victory.wav +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_PIZZA/jingles_PIZZA03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/license.txt +14 -0
- package/bin/tora.mjs +322 -28
- package/crates/packer/trusted/native-3d-meta.json +4 -3
- package/crates/packer/trusted/native-3d.js +181 -181
- package/crates/packer/trusted/native-meta.json +3 -3
- package/crates/packer/trusted/native.js +5 -5
- package/crates/packer/trusted/release-manifest.json +17 -17
- package/crates/packer/trusted/review-runtime-meta.json +4 -3
- package/crates/packer/trusted/review-runtime.js +182 -182
- package/docs/MIGRATION_0_3.md +39 -0
- package/docs/NATIVE_AGENT_TOOLS.md +12 -363
- package/docs/TORA_AGENT_SETUP.md +24 -95
- package/docs/TORA_CREATION_API.md +63 -348
- package/docs/reference/CORE_AUTHORING.md +10 -3
- package/docs/reference/PLAYABLE_STARTERS.md +20 -0
- package/docs/reference/packs/3d.md +11 -3
- package/network-rules/mintegral-appgrowth-single-html.json +10 -10
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +372 -9
- package/scripts/lean/editor/entry.js +11 -6
- package/scripts/lean/editor/project-launcher.js +116 -0
- package/scripts/lean/editor/quick-edit-panel.js +479 -0
- package/scripts/lean/editor/review-editor.css +256 -68
- package/scripts/lean/editor/review-editor.js +1834 -1086
- package/scripts/lean/editor-state.mjs +6 -0
- package/scripts/lean/editor.mjs +6 -3
- package/scripts/lean/matrix.mjs +5 -0
- package/scripts/lean/native/agent-tools.mjs +39 -62
- package/scripts/lean/native/api.mjs +161 -136
- package/scripts/lean/native/asset-catalog.mjs +7 -6
- package/scripts/lean/native/asset-lineage.mjs +54 -0
- package/scripts/lean/native/asset-prep.mjs +173 -40
- package/scripts/lean/native/assets.mjs +107 -11
- package/scripts/lean/native/audio-assets.mjs +30 -0
- package/scripts/lean/native/browser-pool.mjs +34 -0
- package/scripts/lean/native/build-cache.mjs +38 -7
- package/scripts/lean/native/cc0-inputs.mjs +24 -0
- package/scripts/lean/native/cc0-staging.mjs +28 -8
- package/scripts/lean/native/compiler.mjs +9 -3
- package/scripts/lean/native/contracts.mjs +16 -11
- package/scripts/lean/native/creative-qa.mjs +365 -128
- package/scripts/lean/native/demos.mjs +53 -18
- package/scripts/lean/native/document.mjs +50 -12
- package/scripts/lean/native/export-budget.mjs +75 -0
- package/scripts/lean/native/local-bundle.mjs +7 -3
- package/scripts/lean/native/mcp-server.mjs +42 -74
- package/scripts/lean/native/media-validate.mjs +124 -0
- package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
- package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
- package/scripts/lean/native/modules/star-salvage.mjs +3 -368
- package/scripts/lean/native/native-bin.mjs +3 -3
- package/scripts/lean/native/outcome-playthrough.mjs +97 -0
- package/scripts/lean/native/project-bundle.mjs +6 -5
- package/scripts/lean/native/project-index.mjs +0 -2
- package/scripts/lean/native/qa-adapters.mjs +10 -0
- package/scripts/lean/native/quick-edit.mjs +328 -0
- package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
- package/scripts/lean/native/review.mjs +205 -571
- package/scripts/lean/native/schema-vocabulary.mjs +10 -0
- package/scripts/lean/native/schema.mjs +7 -5
- package/scripts/lean/native/scope.mjs +45 -0
- package/scripts/lean/native/service.mjs +378 -79
- package/scripts/lean/native/starters.mjs +563 -0
- package/scripts/lean/native/variant-adapters.mjs +8 -0
- package/scripts/lean/native/variants-core.mjs +186 -0
- package/scripts/lean/native/variants.mjs +63 -0
- package/scripts/lean/native/win-cues.mjs +96 -0
- package/skills/tora-playables/SKILL.md +1 -1
- package/scripts/lean/editor/review-intake.js +0 -837
- package/scripts/lean/model-client.mjs +0 -119
- package/scripts/lean/native/author-expansion-proofs.mjs +0 -240
- package/scripts/lean/native/author-games.mjs +0 -160
- package/scripts/lean/native/author-harvest.mjs +0 -74
- package/scripts/lean/native/author-primitive-proofs.mjs +0 -874
- package/scripts/lean/native/author-salvage.mjs +0 -71
- package/scripts/lean/native/chat-compose.mjs +0 -287
- package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -191
- package/scripts/lean/native/check-salvage.mjs +0 -197
- package/scripts/lean/native/compatibility.mjs +0 -34
- package/scripts/lean/native/concept.mjs +0 -633
- package/scripts/lean/native/draw-stroke.mjs +0 -26
- package/scripts/lean/native/erase-mask.mjs +0 -18
- package/scripts/lean/native/harvest-recipe.mjs +0 -21
- package/scripts/lean/native/instance-steering.mjs +0 -24
- package/scripts/lean/native/intake-creator-agent.mjs +0 -98
- package/scripts/lean/native/intake-creator-tools.mjs +0 -165
- package/scripts/lean/native/interaction-gestures.mjs +0 -45
- package/scripts/lean/native/match-board.mjs +0 -138
- package/scripts/lean/native/modules/index.mjs +0 -54
- package/scripts/lean/native/modules/tap-collect.mjs +0 -54
- package/scripts/lean/native/path-network.mjs +0 -132
- package/scripts/lean/native/physics-2d.mjs +0 -154
- package/scripts/lean/native/physics-3d.mjs +0 -259
- package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
- package/scripts/lean/native/prepare-game-audio.mjs +0 -372
- package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
- package/scripts/lean/native/prepare-golf-assets.py +0 -211
- package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
- package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
- package/scripts/lean/native/prepare-primitive-images.py +0 -25
- package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
- package/scripts/lean/native/prepare-traffic-assets.py +0 -329
- package/scripts/lean/native/presentation.mjs +0 -335
- package/scripts/lean/native/review-agent-tools.mjs +0 -561
- package/scripts/lean/native/review-connection.mjs +0 -303
- package/scripts/lean/native/review-fields.mjs +0 -24
- package/scripts/lean/native/review-intake.mjs +0 -385
- package/scripts/lean/native/review-intents.mjs +0 -217
- package/scripts/lean/native/review-provider.mjs +0 -580
- package/scripts/lean/native/review-receipts.mjs +0 -76
- package/scripts/lean/native/review-resolver.mjs +0 -429
- package/scripts/lean/native/review-targets.mjs +0 -35
- package/scripts/lean/native/runtime.mjs +0 -1623
- package/scripts/lean/native/salvage-recipe.mjs +0 -20
- package/scripts/lean/native/stage-3d.mjs +0 -818
- package/scripts/lean/native/verify.mjs +0 -4
- package/scripts/lean/scene-document.mjs +0 -48
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import {resolve} from 'node:path';
|
|
2
|
+
import {lstat,mkdir,writeFile} from 'node:fs/promises';
|
|
3
|
+
import {registerSourceBytes} from './assets.mjs';
|
|
4
|
+
import {inspectMedia} from './asset-catalog.mjs';
|
|
5
|
+
import {assertSingleVisualStyleFamily, compactAssetProvenance, resolveCc0SourceItem} from './cc0-staging.mjs';
|
|
6
|
+
import {hash} from './compiler.mjs';
|
|
7
|
+
import {applyOperations, check, emptyProject} from './document.mjs';
|
|
8
|
+
import {exportProjectFile} from './local-bundle.mjs';
|
|
9
|
+
|
|
10
|
+
const gameplay = 'scene.play';
|
|
11
|
+
const win = 'scene.win';
|
|
12
|
+
const timeout = 'scene.timeout';
|
|
13
|
+
const steps = 'starter.steps';
|
|
14
|
+
const dropFrame = 'starter.drop-frame';
|
|
15
|
+
const layers = ['patty', 'cheese', 'salad', 'tomato', 'bun-top'];
|
|
16
|
+
const cars = ['blue', 'red', 'yellow', 'green'];
|
|
17
|
+
const carSources = Object.fromEntries(cars.map(color => [
|
|
18
|
+
color, `assets/kenney-racing/source/racing-pack/extracted/PNG/Cars/car_${color}_1.png`,
|
|
19
|
+
]));
|
|
20
|
+
const targets3d = ['target1', 'target2', 'target3', 'target4'];
|
|
21
|
+
const target3dSources = {
|
|
22
|
+
target1: 'Models/GLB format/burger.glb',
|
|
23
|
+
target2: 'Models/GLB format/frying-pan.glb',
|
|
24
|
+
target3: 'Models/GLB format/pot.glb',
|
|
25
|
+
target4: 'Models/GLB format/plate.glb',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const definitions = {
|
|
29
|
+
'stack-and-serve': {
|
|
30
|
+
name: 'Stack & Serve',
|
|
31
|
+
genre: '3D Cooking',
|
|
32
|
+
tagline: 'Stack five 3D burger ingredients to complete an order with a celebratory end card.',
|
|
33
|
+
mechanic: 'Stack five 3D ingredients to finish an order.',
|
|
34
|
+
palette: {background: '#382322', surface: '#fff2d7', ink: '#321b1a', accent: '#ffc15e'},
|
|
35
|
+
winTitle: 'Order up!',
|
|
36
|
+
timeoutTitle: 'So close',
|
|
37
|
+
art: Object.fromEntries(['burger', 'plate', 'frying-pan', 'pot'].map(model => [model, `Models/GLB format/${model}.glb`])),
|
|
38
|
+
artPack: 'kenney-food-kit',
|
|
39
|
+
artMime: 'model/gltf-binary',
|
|
40
|
+
audio: {music: 'arcade-pop/ambient.wav', step: 'arcade-pop/reward.wav', win: 'arcade-pop/win.wav', loss: 'arcade-pop/loss.wav'},
|
|
41
|
+
},
|
|
42
|
+
'tap-targets': {
|
|
43
|
+
name: 'Pit Stop Dash',
|
|
44
|
+
genre: '2D Racing',
|
|
45
|
+
tagline: 'Tap cars arriving in pit boxes with crisp arcade feedback and a Store CTA.',
|
|
46
|
+
mechanic: 'Tap each car as it arrives at a pit box to finish the round.',
|
|
47
|
+
palette: {background: '#132635', surface: '#dbeaf2', ink: '#10232c', accent: '#ffc750'},
|
|
48
|
+
winTitle: 'Grid ready!',
|
|
49
|
+
timeoutTitle: 'Race awaits',
|
|
50
|
+
art: carSources,
|
|
51
|
+
artPack: 'kenney-racing-pack',
|
|
52
|
+
artMime: 'image/',
|
|
53
|
+
audio: {music: 'arcade-pop/ambient.wav', step: 'arcade-pop/reward.wav', win: 'audio/victory.wav', loss: 'arcade-pop/loss.wav'},
|
|
54
|
+
},
|
|
55
|
+
'tap-targets-3d': {
|
|
56
|
+
name: 'Bistro Rush',
|
|
57
|
+
genre: '3D Tap & Collect',
|
|
58
|
+
tagline: 'Tap four 3D dishes directly on the counter using projected 3D touch rings across portrait and landscape.',
|
|
59
|
+
mechanic: 'Tap all four 3D kitchen items on the counter to finish service.',
|
|
60
|
+
palette: {background: '#17323a', surface: '#fff5e1', ink: '#1f1a17', accent: '#ffb84d'},
|
|
61
|
+
winTitle: 'Table served!',
|
|
62
|
+
timeoutTitle: 'Orders waiting',
|
|
63
|
+
art: target3dSources,
|
|
64
|
+
artPack: 'kenney-food-kit',
|
|
65
|
+
artMime: 'model/gltf-binary',
|
|
66
|
+
audio: {music: 'arcade-pop/ambient.wav', step: 'arcade-pop/reward.wav', win: 'arcade-pop/win.wav', loss: 'arcade-pop/loss.wav'},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const starterNames = Object.keys(definitions);
|
|
71
|
+
const strings = keys => ({
|
|
72
|
+
type: 'object',
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
properties: Object.fromEntries(keys.map(key => [key, {type: 'string'}])),
|
|
75
|
+
});
|
|
76
|
+
export const starterInputProperties = {
|
|
77
|
+
...strings(['id','name','androidUrl','ctaLabel','winTitle','timeoutTitle']).properties,
|
|
78
|
+
starter: {type: 'string', enum: starterNames},
|
|
79
|
+
deliver: {type:'boolean',description:'Save a browser draft, editable bundle, and packaged-playback QA to a new folder in this workspace.'},
|
|
80
|
+
durationSeconds: {type: 'integer', minimum: 10, maximum: 60},
|
|
81
|
+
winHoldSeconds: {type: 'number', minimum: 0.25, maximum: 3},
|
|
82
|
+
palette: strings(['background','surface','ink','accent']),
|
|
83
|
+
art: strings([...Object.keys(definitions['stack-and-serve'].art), ...cars, ...targets3d]),
|
|
84
|
+
audio: strings(['music','step','win','loss']),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export function listStarters(){
|
|
88
|
+
return {
|
|
89
|
+
starters: Object.entries(definitions).map(([id, definition]) => ({
|
|
90
|
+
id, name: definition.name, mechanic: definition.mechanic,
|
|
91
|
+
genre: definition.genre, tagline: definition.tagline,
|
|
92
|
+
visualPack: definition.artPack, artRoles: Object.keys(definition.art),
|
|
93
|
+
})),
|
|
94
|
+
defaults: {durationSeconds: 25, winHoldSeconds: 0.9, ctaLabel: 'Play now'},
|
|
95
|
+
outputs: 'Use deliver:true for a browser draft, editable bundle, and packaged-playback evidence in a new folder.',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function contrast(a,b){
|
|
100
|
+
const luminance = color=>{
|
|
101
|
+
const channels = color.slice(1).match(/../g).map(hex=>parseInt(hex,16)/255);
|
|
102
|
+
const [red,green,blue] = channels.map(value=>value<=.04045?value/12.92:((value+.055)/1.055)**2.4);
|
|
103
|
+
return .2126*red+.7152*green+.0722*blue;
|
|
104
|
+
};
|
|
105
|
+
const colors = [luminance(a),luminance(b)];
|
|
106
|
+
return (Math.max(...colors)+.05)/(Math.min(...colors)+.05);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function settings(input){
|
|
110
|
+
check(Object.hasOwn(definitions, input.starter), 'E_STARTER_KIND');
|
|
111
|
+
const definition = definitions[input.starter];
|
|
112
|
+
const {durationSeconds=25, winHoldSeconds=0.9, ctaLabel='Play now',
|
|
113
|
+
winTitle=definition.winTitle, timeoutTitle=definition.timeoutTitle} = input;
|
|
114
|
+
for(const label of [ctaLabel, winTitle, timeoutTitle]){
|
|
115
|
+
check(typeof label === 'string' && label.trim().length && label.length <= 24 && label.trim().split(/\s+/).length <= 3,
|
|
116
|
+
'E_STARTER_COPY');
|
|
117
|
+
}
|
|
118
|
+
check(Number.isInteger(durationSeconds) && durationSeconds >= 10 && durationSeconds <= 60, 'E_STARTER_TIMING');
|
|
119
|
+
check(Number.isFinite(winHoldSeconds) && winHoldSeconds >= 0.25 && winHoldSeconds <= 3, 'E_STARTER_TIMING');
|
|
120
|
+
const palette = {...definition.palette, ...input.palette};
|
|
121
|
+
check(Object.values(palette).every(color => /^#[0-9a-f]{6}$/i.test(color)), 'E_STARTER_PALETTE');
|
|
122
|
+
for(const [foreground,background] of [['surface','background'],['ink','accent']]){
|
|
123
|
+
check(contrast(palette[foreground],palette[background])>=4.5,'E_STARTER_CONTRAST',
|
|
124
|
+
{foreground,background,minimumRatio:4.5});
|
|
125
|
+
}
|
|
126
|
+
check(Object.keys(input.art??{}).every(role => Object.hasOwn(definition.art, role)), 'E_STARTER_ART_ROLE');
|
|
127
|
+
return {definition, palette, durationSeconds, winHoldSeconds, ctaLabel, winTitle, timeoutTitle};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function builder(){
|
|
131
|
+
const operations = [];
|
|
132
|
+
const append = operation => operations.push(operation);
|
|
133
|
+
const component = (id, sceneId, kind, x, y, width, height, parameters={}, options={}) =>
|
|
134
|
+
append({kind:'createComponent',component:{
|
|
135
|
+
id, sceneId, contract:`native.${kind}.v1`, transform:[1,0,0,1,x,y],
|
|
136
|
+
parameters:{width,height,...parameters}, ...options,
|
|
137
|
+
}});
|
|
138
|
+
const behavior = (id, componentId, kind, parameters) =>
|
|
139
|
+
append({kind:'putBehavior',behavior:{id,componentId,kind,parameters}});
|
|
140
|
+
const bind = (id, event, actions, condition) =>
|
|
141
|
+
append({kind:'putBinding',binding:{id,event,actions,...(condition?{condition}:{})}});
|
|
142
|
+
const landscape = (componentId,x,y,scaleX=1,scaleY=scaleX) =>
|
|
143
|
+
behavior(componentId+'.layout',componentId,'responsive-layout',{x,y,scaleX,scaleY});
|
|
144
|
+
const placed = (id,scene,x,y,w,h,alternate,order=0) => {
|
|
145
|
+
const groupId = id+'.placement';
|
|
146
|
+
component(groupId,scene,'group',x,y,w,h,{}, {order});
|
|
147
|
+
landscape(groupId,...alternate);
|
|
148
|
+
return groupId;
|
|
149
|
+
};
|
|
150
|
+
const label = (id,scene,x,y,w,h,text,fontSize,color,parentId) =>
|
|
151
|
+
component(id,scene,'text',x,y,w,h,{text,fontSize,color,fontWeight:'900',align:'center',wrap:false,autoFit:true,minFontSize:14},
|
|
152
|
+
parentId?{parentId}:{});
|
|
153
|
+
const art = (id,scene,x,y,w,h,assetId,parentId) =>
|
|
154
|
+
component(id,scene,'image',x,y,w,h,{fit:'contain'},{parentId,assetSlots:[{slotId:'source',assetId}]});
|
|
155
|
+
const variable = id => append({kind:'putVariable',variable:{id,label:id,type:'number',initial:0}});
|
|
156
|
+
return {operations,append,component,behavior,bind,landscape,placed,label,art,variable};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const set = (componentId,key,value) => ({kind:'setComponent',componentId,key,value});
|
|
160
|
+
const play = name => ({kind:'playAudio',behaviorId:`starter.audio.${name}`});
|
|
161
|
+
const eq = (variableId,value) => ({variableId,op:'eq',value});
|
|
162
|
+
const timer = behaviorId => ({kind:'timer',behaviorId});
|
|
163
|
+
|
|
164
|
+
function button(make,id,scene,x,y,w,h,copy,palette,{landscapeX,landscapeY,cta=false}){
|
|
165
|
+
const parentId = make.placed(id,scene,x,y,w,h,[landscapeX,landscapeY],30);
|
|
166
|
+
make.component(id,scene,'button',0,0,w,h,{
|
|
167
|
+
radius:18, fill:palette.accent, hoverFill:palette.accent, pressedFill:palette.surface,
|
|
168
|
+
stroke:palette.ink, strokeWidth:2, presentation:cta?'shiny-cta':'flat',
|
|
169
|
+
}, {parentId});
|
|
170
|
+
make.label(id+'.label',scene,0,0,w,h,copy,26,palette.ink,id);
|
|
171
|
+
make.behavior(id+'.press',id,'press-feedback',{scaleDown:.94,springBackSeconds:.17,liftShadow:true});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function backdrop(make,scene,palette){
|
|
175
|
+
const id = scene+'.backdrop';
|
|
176
|
+
const parentId = make.placed(id,scene,0,0,390,700,[0,0,700/390,390/700]);
|
|
177
|
+
make.component(id,scene,'rectangle',0,0,390,700,{fill:palette.background},{parentId});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function progress(make,count,palette,landscapePos=[475,106]){
|
|
181
|
+
const totalWidth = Math.max(23, (count - 1) * 28 + 23);
|
|
182
|
+
const portraitX = Math.round((390 - totalWidth) / 2);
|
|
183
|
+
make.component('starter.progress',gameplay,'group',portraitX,62,totalWidth,20,{}, {order:15});
|
|
184
|
+
make.landscape('starter.progress',landscapePos[0],landscapePos[1]);
|
|
185
|
+
for(let i=0;i<count;i++){
|
|
186
|
+
make.component(`starter.pip.${i}`,gameplay,'rectangle',i*28,2,23,10,{
|
|
187
|
+
fill:palette.surface+'32',radius:5,
|
|
188
|
+
},{parentId:'starter.progress'});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function audioRig(make){
|
|
193
|
+
for(const [name,scene,bus,volume,role] of [
|
|
194
|
+
['music',gameplay,'music',.12,'ambient'],
|
|
195
|
+
['step',gameplay,'sfx',.22,'reward'],
|
|
196
|
+
['win',win,'stinger',.40,'win'],
|
|
197
|
+
['loss',timeout,'stinger',.27,'loss'],
|
|
198
|
+
]){
|
|
199
|
+
const id = `starter.sound.${name}`;
|
|
200
|
+
make.component(id,scene,'group',0,0,0,0,{visible:false},
|
|
201
|
+
{assetSlots:[{slotId:'source',assetId:`starter.asset.${name}`}]});
|
|
202
|
+
make.behavior(`starter.audio.${name}`,id,'audio',{
|
|
203
|
+
bus,volume,role,loop:name==='music',frequency:440,seconds:.4,cooldownMs:55,allowSynthFallback:false,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function completeStep(index,count,palette,winHoldSeconds){
|
|
209
|
+
return [
|
|
210
|
+
...(index===0?[play('music')]:[]),
|
|
211
|
+
play('step'),
|
|
212
|
+
set(`starter.pip.${index}`,'fill',palette.accent),
|
|
213
|
+
{kind:'add',variableId:steps,value:1},
|
|
214
|
+
...(index===count-1?[{kind:'changeScene',sceneId:win,delaySeconds:winHoldSeconds}]:[]),
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function outcome(make,scene,copy,ctaLabel,palette,addShowcase){
|
|
219
|
+
make.append({kind:'createScene',scene:{id:scene,label:scene===win?'Win':'Timeout',role:'end-card'}});
|
|
220
|
+
backdrop(make,scene,palette);
|
|
221
|
+
addShowcase();
|
|
222
|
+
const title = scene+'.title';
|
|
223
|
+
make.component(title,scene,'group',40,88,310,90,{}, {order:20});
|
|
224
|
+
make.landscape(title,374,105);
|
|
225
|
+
make.label(title+'.text',scene,0,0,310,90,copy,39,palette.surface,title);
|
|
226
|
+
const cta = scene+'.cta';
|
|
227
|
+
button(make,cta,scene,58,537,274,70,ctaLabel,palette,{landscapeX:392,landscapeY:208,cta:true});
|
|
228
|
+
make.behavior(cta+'.pulse',cta,'animation',{
|
|
229
|
+
property:'scale',from:1,to:1.035,seconds:1.8,loop:true,easing:'ease-in-out',
|
|
230
|
+
});
|
|
231
|
+
const enterActions = [{kind:'animate',behaviorId:cta+'.pulse'},play(scene===win?'win':'loss')];
|
|
232
|
+
if(scene===win){
|
|
233
|
+
const effect = scene+'.confetti';
|
|
234
|
+
make.behavior(effect,scene+'.backdrop','emitter',{
|
|
235
|
+
coverage:'screen',shape:'confetti',color:palette.accent,color2:palette.surface,color3:'#fc7657',
|
|
236
|
+
count:46,speed:110,lifetime:1.9,gravity:34,spread:280,
|
|
237
|
+
});
|
|
238
|
+
enterActions.push({kind:'emit',behaviorId:effect});
|
|
239
|
+
}
|
|
240
|
+
make.bind(scene+'.enter',{kind:'sceneEnter',sceneId:scene},enterActions);
|
|
241
|
+
make.bind(scene+'.store',{kind:'click',componentId:cta},[{kind:'store'}]);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function kitchen(make,scene,palette,{completed=false,plan}={}){
|
|
245
|
+
const stage = scene+'.kitchen';
|
|
246
|
+
const parentId = make.placed(stage,scene,0,128,390,402,[34,13,.9],1);
|
|
247
|
+
make.component(stage,scene,'stage3d',0,0,390,402,{
|
|
248
|
+
skyColor:palette.background, hemiSkyColor:'#fff0d6', hemiGroundColor:'#624032',
|
|
249
|
+
hemiIntensity:1.25,sunColor:'#fff1d2',sunIntensity:3.0,sunX:-4,sunY:8,sunZ:5,
|
|
250
|
+
shadowsEnabled:true,shadowMapSize:'1024',toneMapping:'aces',renderMaxDim:600,
|
|
251
|
+
cameraX:0,cameraY:1.85,cameraZ:3.25,cameraFov:32,
|
|
252
|
+
landscapeCameraX:0,landscapeCameraY:1.6,landscapeCameraZ:3.05,landscapeCameraFov:34,
|
|
253
|
+
lookAtY:.31,introLift:0,
|
|
254
|
+
},{parentId});
|
|
255
|
+
const mesh = (id, asset, parameters) =>
|
|
256
|
+
make.component(id,scene,'mesh3d',0,0,0,0,{
|
|
257
|
+
primitive:'model',materialMode:'lambert',castShadow:true,receiveShadow:true,...parameters,
|
|
258
|
+
},{parentId:stage,assetSlots:[{slotId:'source',assetId:`starter.asset.${asset}`}]});
|
|
259
|
+
mesh(stage+'.plate','plate',{x:0,y:0,z:0,sx:1.65,sy:1.25,sz:1.65});
|
|
260
|
+
if(scene===gameplay){
|
|
261
|
+
mesh(stage+'.pan','frying-pan',{x:-.72,y:.03,z:-.72,ry:.4,sx:.52,sy:.52,sz:.52});
|
|
262
|
+
mesh(stage+'.pot','pot',{x:.73,y:.04,z:-.92,ry:-.25,sx:.5,sy:.5,sz:.5});
|
|
263
|
+
}
|
|
264
|
+
if(completed){
|
|
265
|
+
mesh(stage+'.burger','burger',{y:.115,sx:1.35,sy:1.35,sz:1.35});
|
|
266
|
+
make.behavior(stage+'.hero-bob',stage+'.burger','oscillate-3d',{axis:'y',amplitude:.025,angularSpeed:1.35,phase:0});
|
|
267
|
+
}else{
|
|
268
|
+
const burgerSize = 1.2;
|
|
269
|
+
mesh(stage+'.base','burger',{subNode:'bun-bottom',y:.1,sx:burgerSize,sy:burgerSize,sz:burgerSize});
|
|
270
|
+
plan?.(mesh);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function stackAndServe(make,{palette,winHoldSeconds,ctaLabel,winTitle,timeoutTitle}){
|
|
275
|
+
const control = 'starter.drop';
|
|
276
|
+
button(make,control,gameplay,65,556,260,68,'Drop ingredient',palette,{landscapeX:414,landscapeY:185});
|
|
277
|
+
const fallTimer = 'starter.drop-step';
|
|
278
|
+
make.variable(dropFrame);
|
|
279
|
+
make.behavior(fallTimer,control,'timer',{seconds:.055,repeat:true});
|
|
280
|
+
const part = index => `starter.layer.${index}`;
|
|
281
|
+
const hoverY = .7;
|
|
282
|
+
kitchen(make,gameplay,palette,{plan:mesh=>{
|
|
283
|
+
layers.forEach((subNode,index)=>{
|
|
284
|
+
mesh(part(index),'burger',{subNode,y:hoverY,visible:index===0,sx:1.2,sy:1.2,sz:1.2});
|
|
285
|
+
});
|
|
286
|
+
}});
|
|
287
|
+
layers.forEach((_,index)=>{
|
|
288
|
+
const id = part(index), landedY = .1+index*.035;
|
|
289
|
+
const burst = id+'.burst';
|
|
290
|
+
make.behavior(burst,id,'emitter',{
|
|
291
|
+
origin:'contact-3d',coverage:'local',shape:'circle',color:palette.accent,color2:palette.surface,color3:'#ff7045',
|
|
292
|
+
count:13,speed:115,lifetime:.42,gravity:240,spread:230,
|
|
293
|
+
});
|
|
294
|
+
make.bind(id+'.drop',{kind:'click',componentId:control},[
|
|
295
|
+
set(id,'y',hoverY*0.87),{kind:'set',variableId:dropFrame,value:1},
|
|
296
|
+
],{all:[eq(steps,index),eq(dropFrame,0)]});
|
|
297
|
+
make.bind(id+'.land',timer(fallTimer),[
|
|
298
|
+
set(id,'y',landedY),{kind:'emit',behaviorId:burst},
|
|
299
|
+
{kind:'set',variableId:dropFrame,value:0},
|
|
300
|
+
...(index<layers.length-1?[set(part(index+1),'visible',true)]:[]),
|
|
301
|
+
...completeStep(index,layers.length,palette,winHoldSeconds),
|
|
302
|
+
],{all:[eq(steps,index),eq(dropFrame,3)]});
|
|
303
|
+
for(const [frame, fraction] of [[2,.24],[1,.51]]){
|
|
304
|
+
make.bind(id+'.advance-'+frame,timer(fallTimer),[
|
|
305
|
+
set(id,'y',landedY+(hoverY-landedY)*fraction),
|
|
306
|
+
{kind:'set',variableId:dropFrame,value:frame+1},
|
|
307
|
+
],{all:[eq(steps,index),eq(dropFrame,frame)]});
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
outcome(make,win,winTitle,ctaLabel,palette,()=>kitchen(make,win,palette,{completed:true}));
|
|
311
|
+
outcome(make,timeout,timeoutTitle,ctaLabel,palette,()=>kitchen(make,timeout,palette,{
|
|
312
|
+
plan:mesh=>layers.forEach((subNode,index)=>{
|
|
313
|
+
const id = `scene.timeout.layer.${index}`;
|
|
314
|
+
mesh(id,'burger',{subNode,y:.1+index*.035,visible:false,sx:1.2,sy:1.2,sz:1.2});
|
|
315
|
+
make.bind(id+'.reveal',{kind:'sceneEnter',sceneId:timeout},[set(id,'visible',true)],
|
|
316
|
+
{all:[{variableId:steps,op:'gt',value:index}]});
|
|
317
|
+
}),
|
|
318
|
+
}));
|
|
319
|
+
return layers.length;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function pitScene(make,scene,palette){
|
|
323
|
+
const panel = scene+'.pit';
|
|
324
|
+
const parentId = make.placed(panel,scene,23,141,344,370,[26,27,.9],1);
|
|
325
|
+
for(const [index,color] of cars.entries()){
|
|
326
|
+
make.component(panel+'.'+color,scene,'rectangle',index%2?188:20,index<2?11:181,136,165,{
|
|
327
|
+
fill:palette.ink,stroke:palette.surface+'45',strokeWidth:2,radius:20,
|
|
328
|
+
},{parentId,order:-1});
|
|
329
|
+
}
|
|
330
|
+
return parentId;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function tapTargets(make,{palette,winHoldSeconds,ctaLabel,winTitle,timeoutTitle}){
|
|
334
|
+
const panel = pitScene(make,gameplay,palette);
|
|
335
|
+
const w = 108, h = 139;
|
|
336
|
+
const targets = cars.map((color,index)=>{
|
|
337
|
+
const id = 'starter.car.'+color;
|
|
338
|
+
const x = index%2?202:34, y = index<2?24:194;
|
|
339
|
+
make.component(id,gameplay,'button',x,y,w,h,{
|
|
340
|
+
radius:18,fill:palette.accent,hoverFill:palette.accent,pressedFill:palette.surface,visible:index===0,
|
|
341
|
+
},{order:10,parentId:panel});
|
|
342
|
+
make.art(id+'.art',gameplay,23,10,62,119,`starter.asset.${color}`,id);
|
|
343
|
+
make.behavior(id+'.press',id,'press-feedback',{scaleDown:.88,springBackSeconds:.15,liftShadow:true});
|
|
344
|
+
make.behavior(id+'.spark',id,'emitter',{
|
|
345
|
+
count:12,origin:'center',coverage:'local',shape:'circle',color:palette.accent,
|
|
346
|
+
speed:125,lifetime:.45,gravity:180,spread:170,
|
|
347
|
+
});
|
|
348
|
+
return id;
|
|
349
|
+
});
|
|
350
|
+
targets.forEach((id,index)=>{
|
|
351
|
+
make.bind(id+'.collect',{kind:'click',componentId:id},[
|
|
352
|
+
set(id,'visible',false),{kind:'emit',behaviorId:id+'.spark'},
|
|
353
|
+
...(targets[index+1]?[set(targets[index+1],'visible',true)]:[]),
|
|
354
|
+
...completeStep(index,targets.length,palette,winHoldSeconds),
|
|
355
|
+
],{all:[eq(steps,index)]});
|
|
356
|
+
});
|
|
357
|
+
const instruction = 'starter.hint';
|
|
358
|
+
make.component(instruction,gameplay,'group',65,542,260,65,{}, {order:22});
|
|
359
|
+
make.landscape(instruction,410,183);
|
|
360
|
+
make.label(instruction+'.text',gameplay,0,0,260,65,'Tap the cars',28,palette.surface,instruction);
|
|
361
|
+
make.bind(instruction+'.hide',{kind:'variableChange',variableId:steps},[set(instruction,'visible',false)]);
|
|
362
|
+
for(const [scene,copy] of [[win,winTitle],[timeout,timeoutTitle]]){
|
|
363
|
+
outcome(make,scene,copy,ctaLabel,palette,()=>{
|
|
364
|
+
const panelId = pitScene(make,scene,palette);
|
|
365
|
+
cars.forEach((color,index)=>{
|
|
366
|
+
make.art(`${scene}.hero.${color}`,scene,index%2?190:54,index<2?27:176,95,144,`starter.asset.${color}`,panelId);
|
|
367
|
+
});
|
|
368
|
+
const lead = scene+'.hero.blue';
|
|
369
|
+
make.behavior(lead+'.lift',lead,'animation',{property:'y',from:55,to:27,seconds:.5,loop:false,easing:'ease-out'});
|
|
370
|
+
make.bind(lead+'.enter',{kind:'sceneEnter',sceneId:scene},[{kind:'animate',behaviorId:lead+'.lift'}]);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return targets.length;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function bistroStage(make,scene,palette,{fullBleed=false,plan}={}){
|
|
377
|
+
const stage = scene+'.counter';
|
|
378
|
+
const parentId = fullBleed
|
|
379
|
+
? make.placed(stage,scene,0,0,390,700,[0,0,700/390,390/700],1)
|
|
380
|
+
: make.placed(stage,scene,0,128,390,402,[34,13,.9],1);
|
|
381
|
+
make.component(stage,scene,'stage3d',0,0,390,fullBleed?700:402,{
|
|
382
|
+
skyColor:palette.background,hemiSkyColor:'#fff3dc',hemiGroundColor:'#355259',
|
|
383
|
+
hemiIntensity:1.35,sunColor:'#fff0cf',sunIntensity:3.0,sunX:-4,sunY:9,sunZ:5,
|
|
384
|
+
shadowsEnabled:true,shadowMapSize:'1024',toneMapping:'aces',renderMaxDim:600,
|
|
385
|
+
cameraX:0,cameraY:fullBleed?5.35:4.5,cameraZ:fullBleed?5.25:5.2,cameraFov:fullBleed?36:35,
|
|
386
|
+
landscapeCameraX:0,landscapeCameraY:fullBleed?5.5:4.3,landscapeCameraZ:fullBleed?3.9:4.9,landscapeCameraFov:fullBleed?36:34,
|
|
387
|
+
lookAtX:0,lookAtY:fullBleed?.04:.06,lookAtZ:fullBleed?.08:0,introLift:fullBleed?.001:0,
|
|
388
|
+
},{parentId});
|
|
389
|
+
const prop = (id,parameters) =>
|
|
390
|
+
make.component(id,scene,'mesh3d',0,0,0,0,{
|
|
391
|
+
primitive:'box',castShadow:false,receiveShadow:true,...parameters,
|
|
392
|
+
},{parentId:stage});
|
|
393
|
+
prop(stage+'.top',{x:0,y:-.14,z:0,sx:2.58,sy:.24,sz:2.54,color:'#734b36'});
|
|
394
|
+
prop(stage+'.trim',{x:0,y:-.28,z:0,sx:2.72,sy:.08,sz:2.68,color:'#d9b892'});
|
|
395
|
+
prop(stage+'.runner',{x:0,y:-.015,z:0,sx:2.26,sy:.02,sz:2.2,color:'#244852'});
|
|
396
|
+
const item = (id,role,parameters) =>
|
|
397
|
+
make.component(id,scene,'mesh3d',0,0,0,0,{
|
|
398
|
+
primitive:'model',materialMode:'lambert',pivotMode:'bottom-center',normalizeSize:.54,
|
|
399
|
+
castShadow:true,receiveShadow:true,...parameters,
|
|
400
|
+
},{parentId:stage,assetSlots:[{slotId:'source',assetId:`starter.asset.${role}`}]});
|
|
401
|
+
plan?.(item,stage);
|
|
402
|
+
return stage;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const bistroSpots = [
|
|
406
|
+
{role:'target1',x:-.68,y:.02,z:.71,ry:.35,phase:0},
|
|
407
|
+
{role:'target2',x:.68,y:.02,z:.71,ry:-.55,phase:1.5},
|
|
408
|
+
{role:'target3',x:-.68,y:.02,z:-.71,ry:.45,phase:3.0},
|
|
409
|
+
{role:'target4',x:.68,y:.02,z:-.71,ry:-.3,phase:4.5},
|
|
410
|
+
];
|
|
411
|
+
|
|
412
|
+
function tapTargets3d(make,{palette,winHoldSeconds,ctaLabel,winTitle,timeoutTitle}){
|
|
413
|
+
bistroStage(make,gameplay,palette,{fullBleed:true,plan:item=>{
|
|
414
|
+
for(const spot of bistroSpots){
|
|
415
|
+
const meshId = `starter.item.${spot.role}`;
|
|
416
|
+
item(meshId,spot.role,{x:spot.x,y:spot.y,z:spot.z,ry:spot.ry});
|
|
417
|
+
make.behavior(meshId+'.bob',meshId,'oscillate-3d',{axis:'y',amplitude:.02,angularSpeed:1.75,phase:spot.phase});
|
|
418
|
+
make.behavior(meshId+'.burst',meshId,'emitter',{
|
|
419
|
+
origin:'contact-3d',coverage:'local',shape:'confetti',color:palette.accent,color2:palette.surface,color3:'#ff7a59',
|
|
420
|
+
count:14,speed:130,lifetime:.48,gravity:240,spread:260,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}});
|
|
424
|
+
for(const spot of bistroSpots){
|
|
425
|
+
const meshId = `starter.item.${spot.role}`;
|
|
426
|
+
const btnId = `starter.target.${spot.role}`;
|
|
427
|
+
make.component(btnId,gameplay,'button',0,0,64,64,{
|
|
428
|
+
radius:48,fill:'#00000000',hoverFill:palette.accent+'22',pressedFill:palette.surface+'44',
|
|
429
|
+
stroke:palette.accent,strokeWidth:0,
|
|
430
|
+
},{order:12});
|
|
431
|
+
make.behavior(btnId+'.anchor',btnId,'ui-anchor-3d',{
|
|
432
|
+
targetId:meshId,anchor:'center',fitToProjectedBounds:true,paddingPx:6,minSizePx:54,maxSizePx:92,
|
|
433
|
+
squareBounds:true,showHighlight:true,highlightStyle:'pulse-ring',highlightColor:palette.accent,
|
|
434
|
+
syncVisibility:true,offscreen:'hide',
|
|
435
|
+
});
|
|
436
|
+
make.behavior(btnId+'.press',btnId,'press-feedback',{scaleDown:.9,springBackSeconds:.15,liftShadow:false});
|
|
437
|
+
make.bind(btnId+'.collect',{kind:'click',componentId:btnId},[
|
|
438
|
+
set(meshId,'visible',false),
|
|
439
|
+
set(btnId,'enabled',false),
|
|
440
|
+
{kind:'emit',behaviorId:meshId+'.burst'},
|
|
441
|
+
play('step'),
|
|
442
|
+
{kind:'add',variableId:steps,value:1},
|
|
443
|
+
]);
|
|
444
|
+
}
|
|
445
|
+
make.behavior('starter.guide','starter.target.target1','tutorial-hand',{
|
|
446
|
+
targetId:'starter.item.target1',mode:'tap',idleDelaySeconds:.85,hideOnFirstInput:true,
|
|
447
|
+
});
|
|
448
|
+
const instruction = 'starter.hint';
|
|
449
|
+
make.component(instruction,gameplay,'group',65,596,260,54,{}, {order:22});
|
|
450
|
+
make.landscape(instruction,220,330);
|
|
451
|
+
make.label(instruction+'.text',gameplay,0,0,260,54,'Tap every dish',28,palette.surface,instruction);
|
|
452
|
+
for(let index=0;index<bistroSpots.length;index++){
|
|
453
|
+
make.bind(`starter.step.${index+1}`,{kind:'variableChange',variableId:steps},[
|
|
454
|
+
...(index===0?[play('music'),set(instruction,'visible',false)]:[]),
|
|
455
|
+
set(`starter.pip.${index}`,'fill',palette.accent),
|
|
456
|
+
...(index===bistroSpots.length-1?[{kind:'changeScene',sceneId:win,delaySeconds:winHoldSeconds}]:[]),
|
|
457
|
+
],{all:[eq(steps,index+1)]});
|
|
458
|
+
}
|
|
459
|
+
outcome(make,win,winTitle,ctaLabel,palette,()=>bistroStage(make,win,palette,{
|
|
460
|
+
plan:item=>bistroSpots.forEach(spot=>{
|
|
461
|
+
const id = `${win}.hero.${spot.role}`;
|
|
462
|
+
item(id,spot.role,{x:spot.x,y:spot.y,z:spot.z,ry:spot.ry});
|
|
463
|
+
make.behavior(id+'.bob',id,'oscillate-3d',{axis:'y',amplitude:.028,angularSpeed:1.6,phase:spot.phase});
|
|
464
|
+
}),
|
|
465
|
+
}));
|
|
466
|
+
outcome(make,timeout,timeoutTitle,ctaLabel,palette,()=>bistroStage(make,timeout,palette,{
|
|
467
|
+
plan:item=>bistroSpots.forEach(spot=>{
|
|
468
|
+
item(`${timeout}.hero.${spot.role}`,spot.role,{x:spot.x,y:spot.y,z:spot.z,ry:spot.ry});
|
|
469
|
+
}),
|
|
470
|
+
}));
|
|
471
|
+
return bistroSpots.length;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function composition(input, settings){
|
|
475
|
+
const make = builder();
|
|
476
|
+
const {palette,durationSeconds} = settings;
|
|
477
|
+
backdrop(make,gameplay,palette);
|
|
478
|
+
make.variable(steps);
|
|
479
|
+
audioRig(make);
|
|
480
|
+
const count = (input.starter==='stack-and-serve'?stackAndServe:input.starter==='tap-targets-3d'?tapTargets3d:tapTargets)(make,settings);
|
|
481
|
+
progress(make,count,palette,input.starter==='tap-targets-3d'?[296,22]:[475,106]);
|
|
482
|
+
const deadline = 'starter.deadline';
|
|
483
|
+
make.behavior(deadline,gameplay+'.backdrop','timer',{seconds:durationSeconds,repeat:false});
|
|
484
|
+
make.bind(deadline+'.transition',timer(deadline),[
|
|
485
|
+
{kind:'changeScene',sceneId:timeout},
|
|
486
|
+
],{all:[{variableId:steps,op:'lt',value:count}]});
|
|
487
|
+
return make.operations;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
async function starterSources(input, definition, catalog, remoteFetcher){
|
|
491
|
+
await catalog.load();
|
|
492
|
+
const roles = [...Object.entries(definition.art),...Object.entries(definition.audio)];
|
|
493
|
+
const assets = await Promise.all(roles.map(async ([role,path])=>{
|
|
494
|
+
const isArt = Object.hasOwn(definition.art,role);
|
|
495
|
+
const requested = (isArt?input.art:input.audio)?.[role];
|
|
496
|
+
const entry = [...catalog.entries.values()].find(row=>row.sourceFile===path&&(!isArt||row.sourceId===definition.artPack));
|
|
497
|
+
const sourceId = requested ?? entry?.id;
|
|
498
|
+
check(sourceId,'E_STARTER_ASSET_UNAVAILABLE',{role,path});
|
|
499
|
+
const source = await resolveCc0SourceItem(sourceId,{catalog,remoteFetcher});
|
|
500
|
+
const expectedType = isArt?definition.artMime:'audio/';
|
|
501
|
+
check(source.mime.startsWith(expectedType),'E_STARTER_ASSET_TYPE',{role,expectedType});
|
|
502
|
+
if(input.starter==='stack-and-serve'&&role==='burger'){
|
|
503
|
+
const {subNodes=[]} = inspectMedia(source.bytes,source.mime);
|
|
504
|
+
check(['bun-bottom',...layers].every(layer=>subNodes.includes(layer)),'E_STARTER_BURGER_NODES',{role});
|
|
505
|
+
}
|
|
506
|
+
return {...source,id:`starter.asset.${role}`,provenance:compactAssetProvenance(source.provenance)};
|
|
507
|
+
}));
|
|
508
|
+
assertSingleVisualStyleFamily([],assets);
|
|
509
|
+
return assets;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export async function composeStarter(input,{service,catalog,remoteFetcher,workspaceRoot}){
|
|
513
|
+
const options = settings(input);
|
|
514
|
+
const createInput = {id:input.id,name:input.name??options.definition.name,androidUrl:input.androidUrl};
|
|
515
|
+
const blank = emptyProject(createInput);
|
|
516
|
+
const outputDir=input.deliver?resolve(workspaceRoot,input.id+'-draft'):undefined;
|
|
517
|
+
if(outputDir){
|
|
518
|
+
const existing=await lstat(outputDir).catch(error=>{if(error.code!=='ENOENT')throw error;});
|
|
519
|
+
check(!existing,'E_STARTER_OUTPUT_EXISTS',{outputDir});
|
|
520
|
+
}
|
|
521
|
+
const sources = await starterSources(input,options.definition,catalog,remoteFetcher);
|
|
522
|
+
const operations = composition(input,options);
|
|
523
|
+
const register = asset => ({kind:'registerAsset',asset});
|
|
524
|
+
// Resolve and validate the whole recipe before claiming a new project ID.
|
|
525
|
+
applyOperations(blank,[
|
|
526
|
+
...sources.map(({id,mime,rights,provenance,bytes})=>register({id,mime,rights,provenance,bytes:bytes.length,hash:hash(bytes)})),
|
|
527
|
+
...operations,
|
|
528
|
+
]);
|
|
529
|
+
const created = await service.create(createInput);
|
|
530
|
+
const projectRoot = resolve(service.store.root,input.id);
|
|
531
|
+
const assets = await Promise.all(sources.map(({id,mime,rights,bytes,provenance,master})=>
|
|
532
|
+
registerSourceBytes(projectRoot,{id,mime,rights,...(!master?{optimize:'none'}:{})},bytes,{provenance,master})));
|
|
533
|
+
const envelope = {
|
|
534
|
+
format:'tora-transaction-1',
|
|
535
|
+
expected:{revisionId:created.revisionId,contentHash:created.contentHash},
|
|
536
|
+
operations:[...assets.map(({optimization,...asset})=>{void optimization;return register(asset);}),...operations],
|
|
537
|
+
};
|
|
538
|
+
const preview = await service.preview(input.id,envelope);
|
|
539
|
+
const {revisionId, contentHash, editorUrl} = await service.transact(input.id,{
|
|
540
|
+
...envelope,previewDigest:preview.previewDigest,
|
|
541
|
+
},{registeredAssets:assets});
|
|
542
|
+
const result={status:'DRAFT',starter:input.starter,projectId:input.id,expected:{revisionId,contentHash},editorUrl};
|
|
543
|
+
if(!outputDir)return {...result,next:'Run tora_qa with recordVideo:true and inspect the packaged playthrough and audio.'};
|
|
544
|
+
const {project}=await service.read(input.id,revisionId);
|
|
545
|
+
const [artifact,bundle]=await Promise.all([service.build(input.id,project),exportProjectFile(service,input.id,revisionId)]);
|
|
546
|
+
await mkdir(outputDir);
|
|
547
|
+
const outputs={html:resolve(outputDir,input.id+'.html'),project:resolve(outputDir,input.id+'.tora.json')};
|
|
548
|
+
await Promise.all([writeFile(outputs.html,artifact.html,{flag:'wx'}),writeFile(outputs.project,bundle,{flag:'wx'})]);
|
|
549
|
+
const evidenceDir=resolve(outputDir,'qa');
|
|
550
|
+
let report;
|
|
551
|
+
try{report=await service.runQa(input.id,{revisionId,outputDir:evidenceDir,artifact,recordVideo:true});}
|
|
552
|
+
catch(error){
|
|
553
|
+
return {...result,outputs,qa:{status:'UNAVAILABLE',code:error.code??'E_STARTER_QA',outputDir:evidenceDir}};
|
|
554
|
+
}
|
|
555
|
+
const {ok,blockers,warnings,summary,video}=report;
|
|
556
|
+
const contactSheet=report.contactSheets?.find(sheet=>sheet.state==='all');
|
|
557
|
+
return {...result,outputs,qa:{
|
|
558
|
+
ok,blockers,warnings,checkedStates:summary.checkedStates,storeCta:report.checks.browser?.storeCta,
|
|
559
|
+
report:resolve(evidenceDir,'report.json'),
|
|
560
|
+
...(contactSheet?{contactSheet:resolve(evidenceDir,contactSheet.path)}:{}),
|
|
561
|
+
...(video?{video:resolve(evidenceDir,video.path),videoReachedEndCard:video.reachedEndCard}:{}),
|
|
562
|
+
}};
|
|
563
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import {createProjectIndex} from './project-index.mjs';
|
|
2
|
+
import {sortPuzzleCompatibility} from './modules/sort-puzzle.mjs';
|
|
3
|
+
|
|
4
|
+
export const variantAdapters=Object.freeze([sortPuzzleCompatibility]);
|
|
5
|
+
export function variantAdapterForProject(project){
|
|
6
|
+
const index=createProjectIndex(project);
|
|
7
|
+
return variantAdapters.find(adapter=>adapter.matches(index))??null;
|
|
8
|
+
}
|