ReviewOS

also looking at this

craft-native/craft

iOS: the audio recording pair — ratchet 33 → 31

#98
Merged glennmichael123 wants to merge feat/ios-audio-recording into main
9 files +744 -3
packages/ios/fixtures/zig-slice/page.mmodified+21-0
Changes to packages/ios/fixtures/zig-slice/page.m
@@ -52,6 +52,7 @@ const char craft_slice_page[] =
5252 "var sentPdfOpen = false, sentPdfClose = false;\n"
5353 "var sentDownload = false, sentWatch = false, sentSettings = false;\n"
5454 "var sentBtStart = false, sentBtStop = false;\n"
55 "var sentRecStart = false, sentRecStop = false;\n"
5556 "window.__craftBridgeError = function (ctx) {\n"
5657 " // The message crossed Zig's escaping with a backslash, quote, and\n"
5758 " // newline intact; anything mangled and this equality fails, i=7 never\n"
@@ -184,6 +185,25 @@ const char craft_slice_page[] =
184185 " // was parsed and routed — and the donation ran without throwing.\n"
185186 " // A bare string path, landed inside the app container's Documents.\n"
186187 " // Nothing but a real download-and-move produces it.\n"
188 " // The recorder is running. Give it a moment of audio before stopping,\n"
189 " // or the encoder writes a container with no samples in it.\n"
190 " if (!sentRecStart && action === 'startAudioRecording' && payload === true) {\n"
191 " sentRecStart = true;\n"
192 " bridge.postMessage({t:'mobile', a:'getDeviceInfo', i:62});\n"
193 " setTimeout(function () {\n"
194 " bridge.postMessage({t:'mobile', a:'stopAudioRecording', i:106});\n"
195 " }, 700);\n"
196 " }\n"
197 " // An M4A the encoder actually produced: 'ftyp' sits at offset 4 of\n"
198 " // every ISO base media file, and a stub has no way to emit one.\n"
199 " if (!sentRecStop && action === 'stopAudioRecording' && typeof payload === 'string'\n"
200 " && payload.indexOf('data:audio/m4a;base64,') === 0) {\n"
201 " var raw = atob(payload.slice('data:audio/m4a;base64,'.length));\n"
202 " if (raw.slice(4, 8) === 'ftyp' && raw.length > 500) {\n"
203 " sentRecStop = true;\n"
204 " bridge.postMessage({t:'mobile', a:'getDeviceInfo', i:64});\n"
205 " }\n"
206 " }\n"
187207 " if (!sentBtStop && action === 'stopBluetoothScan' && payload === true) {\n"
188208 " sentBtStop = true;\n"
189209 " bridge.postMessage({t:'mobile', a:'getDeviceInfo', i:58});\n"
@@ -338,6 +358,7 @@ const char craft_slice_page[] =
338358 " // for the promise Swift drops — and would mask the state refusal this\n"
339359 " // asserts. The stop goes out once the start has been answered.\n"
340360 " bridge.postMessage({t:'mobile', a:'startBluetoothScan', i:103});\n"
361 " bridge.postMessage({t:'mobile', a:'startAudioRecording', i:105});\n"
341362 " // A Tier-0 action migrated in this phase, served by Zig directly.\n"
342363 " bridge.postMessage({t:'mobile', a:'getAppState', i:88});\n"
343364 " // And one the shim answers by rejecting, to prove the error route.\n"