ReviewOS

also looking at this

craft-native/craft

test(ios): preserve native shortcuts through bundle initialization

#423
Merged glennmichael123 wants to merge fix/native-screen-shortcuts-module into main
3 files +91 -0

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

packages/ios/src/index.test.tsmodified+13-0
Changes to packages/ios/src/index.test.ts
@@ -646,6 +646,19 @@ describe('Craft iOS builder', () => {
646646 expect(source).toContain('guard width > 0, abs(width - reportedViewportWidth) >= 0.5 else { return }')
647647 })
648648
649 it('keeps the shortcuts module present on a native screen, answering unsupported', () => {
650 // Added in 17e09f4d and deleted 28 minutes later by a merge from main
651 // (b1f32471) that nothing caught, because nothing asserted on it. The
652 // module has to exist even though a JavaScriptCore screen cannot register
653 // quick actions: without it `craft.shortcuts` is undefined and STX falls
654 // through to an undefined namespace instead of answering `unsupported`.
655 const source = readFileSync(join(import.meta.dir, '..', 'templates', 'CraftNativeScreen.swift'), 'utf8')
656 expect(source).toContain("keep('shortcuts', {")
657 expect(source).toContain('set: function() { return Promise.resolve(false); }')
658 expect(source).toContain('clear: function() { return Promise.resolve(false); }')
659 expect(source).toContain('onShortcut: function() { return function() {}; }')
660 })
661
649662 it('advertises mounted-view focus and measurement in native screens', () => {
650663 const source = readFileSync(join(import.meta.dir, '..', 'templates', 'CraftNativeScreen.swift'), 'utf8')
651664 const actions = readFileSync(join(import.meta.dir, '..', 'templates', 'CraftNativeActions.swift'), 'utf8')
packages/ios/templates/CraftNativeScreen.swiftmodified+9-0
Changes to packages/ios/templates/CraftNativeScreen.swift
@@ -7017,6 +7017,15 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
70177017 keep('navigation', {
70187018 setOptions: function(options) { craftNativeSetOptions(JSON.stringify(options || {})); }
70197019 });
7020 // Dynamic home-screen quick actions belong to the app shell,
7021 // not an individual JavaScriptCore screen. Keep the typed
7022 // module present so STX can answer `unsupported` honestly
7023 // instead of falling through to an undefined namespace.
7024 keep('shortcuts', {
7025 set: function() { return Promise.resolve(false); },
7026 clear: function() { return Promise.resolve(false); },
7027 onShortcut: function() { return function() {}; }
7028 });
70207029 })();
70217030 """)
70227031 }