@flighthq/keyboard 0.4.0-next.1903.50bfa67 → 0.4.0-next.1908.751021c

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/keyboard",
3
- "version": "0.4.0-next.1903.50bfa67",
3
+ "version": "0.4.0-next.1908.751021c",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/signals": "0.4.0-next.1903.50bfa67",
42
- "@flighthq/types": "0.4.0-next.1903.50bfa67"
41
+ "@flighthq/signals": "0.4.0-next.1908.751021c",
42
+ "@flighthq/types": "0.4.0-next.1908.751021c"
43
43
  },
44
44
  "devDependencies": {
45
45
  "typescript": "^5.3.0"
@@ -34,6 +34,10 @@ import {
34
34
  setSoftKeyboardScrollAssistEnabled,
35
35
  setSoftKeyboardStyle,
36
36
  showSoftKeyboard,
37
+ explainSoftKeyboardBackend,
38
+ installSoftKeyboardHostBackend,
39
+ observeSoftKeyboardHostResult,
40
+ resetSoftKeyboardBackendForTest,
37
41
  } from './keyboard';
38
42
 
39
43
  type BackendListener = (phase: SoftKeyboardPhase, transition: Readonly<SoftKeyboardTransition>) => void;
@@ -670,6 +674,34 @@ describe('disposeSoftKeyboard', () => {
670
674
  });
671
675
  });
672
676
 
677
+ describe('explainSoftKeyboardBackend', () => {
678
+ afterEach(() => resetSoftKeyboardBackendForTest());
679
+
680
+ it('reports host-not-enabled when no backend is installed', () => {
681
+ resetSoftKeyboardBackendForTest();
682
+ const explanation = explainSoftKeyboardBackend();
683
+ expect(explanation.layer).toBe('host-not-enabled');
684
+ expect(explanation.conflict).toBe(false);
685
+ expect(explanation.viability).toBe('unobserved');
686
+ });
687
+
688
+ it('reports custom layer when a custom backend is set', () => {
689
+ setSoftKeyboardBackend(fakeBackend());
690
+ expect(explainSoftKeyboardBackend().layer).toBe('custom');
691
+ });
692
+
693
+ it('reports host layer when a host backend is installed', () => {
694
+ installSoftKeyboardHostBackend(fakeBackend());
695
+ expect(explainSoftKeyboardBackend().layer).toBe('host');
696
+ });
697
+
698
+ it('reports conflict when two different host backends are installed', () => {
699
+ installSoftKeyboardHostBackend(fakeBackend());
700
+ installSoftKeyboardHostBackend(fakeBackend());
701
+ expect(explainSoftKeyboardBackend().conflict).toBe(true);
702
+ });
703
+ });
704
+
673
705
  describe('getSoftKeyboardBackend', () => {
674
706
  it('falls back to a web backend', () => {
675
707
  expect(getSoftKeyboardBackend()).not.toBeNull();
@@ -752,6 +784,25 @@ describe('hideSoftKeyboard', () => {
752
784
  });
753
785
  });
754
786
 
787
+ describe('installSoftKeyboardHostBackend', () => {
788
+ afterEach(() => resetSoftKeyboardBackendForTest());
789
+
790
+ it('installs a host backend that getSoftKeyboardBackend returns', () => {
791
+ const backend = fakeBackend();
792
+ installSoftKeyboardHostBackend(backend);
793
+ expect(getSoftKeyboardBackend()).toBe(backend);
794
+ });
795
+
796
+ it('is first-host-wins: a second different backend sets conflict', () => {
797
+ const first = fakeBackend();
798
+ const second = fakeBackend();
799
+ installSoftKeyboardHostBackend(first);
800
+ installSoftKeyboardHostBackend(second);
801
+ expect(getSoftKeyboardBackend()).toBe(first);
802
+ expect(explainSoftKeyboardBackend().conflict).toBe(true);
803
+ });
804
+ });
805
+
755
806
  describe('isSoftKeyboardAccessoryBarVisible', () => {
756
807
  it('delegates to backend getAccessoryBarVisible', () => {
757
808
  const backend = fakeBackend();
@@ -800,6 +851,36 @@ describe('isSoftKeyboardScrollAssistEnabled', () => {
800
851
  });
801
852
  });
802
853
 
854
+ describe('observeSoftKeyboardHostResult', () => {
855
+ afterEach(() => resetSoftKeyboardBackendForTest());
856
+
857
+ it('records a successful observation', () => {
858
+ installSoftKeyboardHostBackend(fakeBackend());
859
+ observeSoftKeyboardHostResult('getInfo', true);
860
+ const explanation = explainSoftKeyboardBackend();
861
+ expect(explanation.operation).toBe('getInfo');
862
+ expect(explanation.viability).toBe('available');
863
+ });
864
+
865
+ it('records a failed observation', () => {
866
+ installSoftKeyboardHostBackend(fakeBackend());
867
+ observeSoftKeyboardHostResult('getInfo', false);
868
+ expect(explainSoftKeyboardBackend().viability).toBe('runtime-api-unavailable');
869
+ });
870
+ });
871
+
872
+ describe('resetSoftKeyboardBackendForTest', () => {
873
+ it('clears all backend slots', () => {
874
+ setSoftKeyboardBackend(fakeBackend());
875
+ installSoftKeyboardHostBackend(fakeBackend());
876
+ observeSoftKeyboardHostResult('getInfo', true);
877
+ resetSoftKeyboardBackendForTest();
878
+ expect(explainSoftKeyboardBackend().layer).toBe('host-not-enabled');
879
+ expect(explainSoftKeyboardBackend().conflict).toBe(false);
880
+ expect(explainSoftKeyboardBackend().viability).toBe('unobserved');
881
+ });
882
+ });
883
+
803
884
  describe('setSoftKeyboardAccessoryBarVisible', () => {
804
885
  it('delegates to backend setAccessoryBarVisible', () => {
805
886
  const backend = fakeBackend();