ReviewOS

also looking at this

craft-native/craft

iOS: the Bluetooth scan pair — ratchet 35 → 33

#97
Merged glennmichael123 wants to merge feat/ios-bluetooth into main
10 files +679 -3
packages/ios/fixtures/zig-slice/page.mmodified+24-0
Changes to packages/ios/fixtures/zig-slice/page.m
@@ -51,6 +51,7 @@ const char craft_slice_page[] =
5151 "var sentAuth = false, sentSiriAdd = false, sentSiriDel = false;\n"
5252 "var sentPdfOpen = false, sentPdfClose = false;\n"
5353 "var sentDownload = false, sentWatch = false, sentSettings = false;\n"
54 "var sentBtStart = false, sentBtStop = false;\n"
5455 "window.__craftBridgeError = function (ctx) {\n"
5556 " // The message crossed Zig's escaping with a backslash, quote, and\n"
5657 " // newline intact; anything mangled and this equality fails, i=7 never\n"
@@ -77,6 +78,16 @@ const char craft_slice_page[] =
7778 " // NOT_FOUND, not PLATFORM_NOT_SUPPORTED: WatchConnectivity is linked,\n"
7879 " // so this is WCSession itself reporting no reachable watch rather than\n"
7980 " // a missing class. Before this phase the action was not served at all.\n"
81 " // PLATFORM_NOT_SUPPORTED, specifically: CoreBluetooth is linked and the\n"
82 " // usage description is present, so this is the radio's own state and\n"
83 " // not a missing class or a missing plist key. Swift answers all five\n"
84 " // unusable states with one string; this one names which.\n"
85 " if (!sentBtStart && ctx && ctx.error === true && ctx.id === 103\n"
86 " && ctx.code === 'PLATFORM_NOT_SUPPORTED') {\n"
87 " sentBtStart = true;\n"
88 " bridge.postMessage({t:'mobile', a:'getDeviceInfo', i:56});\n"
89 " bridge.postMessage({t:'mobile', a:'stopBluetoothScan', i:104});\n"
90 " }\n"
8091 " if (!sentWatch && ctx && ctx.error === true && ctx.id === 101\n"
8192 " && ctx.code === 'NOT_FOUND') {\n"
8293 " sentWatch = true;\n"
@@ -173,6 +184,10 @@ const char craft_slice_page[] =
173184 " // was parsed and routed — and the donation ran without throwing.\n"
174185 " // A bare string path, landed inside the app container's Documents.\n"
175186 " // Nothing but a real download-and-move produces it.\n"
187 " if (!sentBtStop && action === 'stopBluetoothScan' && payload === true) {\n"
188 " sentBtStop = true;\n"
189 " bridge.postMessage({t:'mobile', a:'getDeviceInfo', i:58});\n"
190 " }\n"
176191 " if (!sentSettings && action === 'openSettings' && typeof payload === 'boolean') {\n"
177192 " sentSettings = true;\n"
178193 " bridge.postMessage({t:'mobile', a:'getDeviceInfo', i:54});\n"
@@ -314,6 +329,15 @@ const char craft_slice_page[] =
314329 " // only branch the Swift shim reaches there.\n"
315330 " bridge.postMessage({t:'mobile', a:'sendToWatch',\n"
316331 " d: JSON.stringify({message:{action:'ping'}}), i:101});\n"
332 " // A simulator has no Bluetooth radio, so CBCentralManager reports\n"
333 " // unsupported and the scan is refused from the state callback — not\n"
334 " // from the handler, which returns before the radio has said anything.\n"
335 " // Only the start here. Posting the stop alongside it would race: a\n"
336 " // stop while a start is still awaiting its first state callback\n"
337 " // answers that start CANCELLED, which is the module's deliberate fix\n"
338 " // for the promise Swift drops — and would mask the state refusal this\n"
339 " // asserts. The stop goes out once the start has been answered.\n"
340 " bridge.postMessage({t:'mobile', a:'startBluetoothScan', i:103});\n"
317341 " // A Tier-0 action migrated in this phase, served by Zig directly.\n"
318342 " bridge.postMessage({t:'mobile', a:'getAppState', i:88});\n"
319343 " // And one the shim answers by rejecting, to prove the error route.\n"