@expofp/debug 3.4.0 → 3.4.2

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.
@@ -53,7 +53,7 @@ export function registerSetting(options) {
53
53
  return _jsx(Editor, { label: key, value: state, context: context, onChange: setState });
54
54
  };
55
55
  EditorImpl.displayName = `DebugSetting(${key})`;
56
- editors.push(EditorImpl);
56
+ editors.push({ key, Editor: EditorImpl });
57
57
  return {
58
58
  get,
59
59
  set,
@@ -1,4 +1,8 @@
1
1
  import type { FC } from 'react';
2
- export declare const editors: FC[];
2
+ export interface RegisteredEditor {
3
+ key: string;
4
+ Editor: FC;
5
+ }
6
+ export declare const editors: RegisteredEditor[];
3
7
  export declare const resets: (() => void)[];
4
8
  //# sourceMappingURL=setting-registry.d.ts.map
@@ -6,7 +6,6 @@ export const DebugOverlay = ({ onClose }) => {
6
6
  return (_jsx(Theme, { appearance: "dark", style: {
7
7
  // gradient
8
8
  backgroundColor: 'rgba(0, 0, 0, 0.9)',
9
- backdropFilter: 'blur(10px)',
10
9
  position: 'fixed',
11
10
  top: 0,
12
11
  right: 0,
@@ -5,25 +5,25 @@ import { SideButton } from './side-button.js';
5
5
  const LazyDebugOverlay = lazy(async () => ({
6
6
  default: (await import('./debug-overlay.js')).DebugOverlay,
7
7
  }));
8
- // const DEFAULT_HOST_SELECTOR = '[data-efp-floorplan-defaults]';
8
+ const DEFAULT_HOST_SELECTOR = '[data-efp-floorplan-defaults]';
9
9
  export const DebugUi = (props) => {
10
10
  const [isOpen, setIsOpen] = useState(props.open);
11
11
  const [debugButtonEnabled, setDebugButtonEnabled] = props.useDebugButtonState();
12
- // const selector = props.hostSelector ?? DEFAULT_HOST_SELECTOR;
12
+ const selector = props.hostSelector ?? DEFAULT_HOST_SELECTOR;
13
13
  useEffect(() => {
14
14
  return addDebugSecretListener(() => {
15
15
  setDebugButtonEnabled(true);
16
16
  setIsOpen(true);
17
17
  });
18
18
  }, []);
19
- //// set visibility of efp floorplan to none when debug ui is open
20
- //// otherwise, z-index issues occur
21
- // useEffect(() => {
22
- // const efpFloorplan = document.querySelector(selector) as HTMLElement | null;
23
- // if (efpFloorplan) {
24
- // efpFloorplan.style.visibility = isOpen ? 'hidden' : 'visible';
25
- // }
26
- // }, [isOpen, selector]);
19
+ // set visibility of efp floorplan to none when debug ui is open
20
+ // otherwise, z-index issues occur
21
+ useEffect(() => {
22
+ const efpFloorplan = document.querySelector(selector);
23
+ if (efpFloorplan) {
24
+ efpFloorplan.style.visibility = isOpen ? 'hidden' : 'visible';
25
+ }
26
+ }, [isOpen, selector]);
27
27
  if (isOpen) {
28
28
  return (_jsx(Suspense, { fallback: null, children: _jsx(LazyDebugOverlay, { onClose: () => {
29
29
  setIsOpen(false);
@@ -5,5 +5,7 @@ import { adoptGlobalSettings } from '../settings/adopt-global-settings.js';
5
5
  import { editors } from '../settings/setting-registry.js';
6
6
  export const SettingsList = () => {
7
7
  adoptGlobalSettings();
8
- return editors.map((Editor, index) => (_jsx(Suspense, { fallback: _jsx(Skeleton, { height: "60px" }), children: _jsx(Editor, {}) }, index)));
8
+ return [...editors]
9
+ .sort((a, b) => a.key.localeCompare(b.key))
10
+ .map(({ key, Editor }) => (_jsx(Suspense, { fallback: _jsx(Skeleton, { height: "60px" }), children: _jsx(Editor, {}) }, key)));
9
11
  };
@@ -1,37 +1,69 @@
1
1
  const SECRET_PHRASE = 'dbg123';
2
2
  const callbacks = [];
3
3
  let initialized = false;
4
- let listenerRef = null;
4
+ let teardown = null;
5
5
  export function addDebugSecretListener(callback) {
6
6
  callbacks.push(callback);
7
7
  if (!initialized) {
8
8
  initialized = true;
9
9
  let buffer = '';
10
- function onKeyDown(e) {
11
- // Ignore modifier keys
10
+ // A physical keypress fires both `keydown` and `input`. When `keydown`
11
+ // already fed a real character, this flag tells the `input` handler to skip
12
+ // the paired event so the character is not counted twice.
13
+ let consumedByKeydown = false;
14
+ const feed = (text) => {
15
+ for (const ch of text.toLowerCase()) {
16
+ buffer = (buffer + ch).slice(-SECRET_PHRASE.length);
17
+ if (buffer === SECRET_PHRASE) {
18
+ buffer = '';
19
+ callbacks.forEach((cb) => cb());
20
+ return;
21
+ }
22
+ }
23
+ };
24
+ // Physical keyboards expose the real character here. Android soft keyboards
25
+ // instead report keyCode 229 / key 'Unidentified' (IME composition), so
26
+ // those keystrokes fall through to the `input` handler below.
27
+ const onKeyDown = (e) => {
12
28
  if (e.ctrlKey || e.metaKey || e.altKey)
13
29
  return;
14
- if (e.key.length !== 1)
30
+ if (e.isComposing || e.key.length !== 1) {
31
+ consumedByKeydown = false;
15
32
  return;
16
- buffer += e.key.toLowerCase();
17
- // Keep buffer length sane
18
- buffer = buffer.slice(-SECRET_PHRASE.length);
19
- if (buffer === SECRET_PHRASE) {
20
- buffer = '';
21
- callbacks.forEach((cb) => cb());
22
33
  }
23
- }
24
- listenerRef = onKeyDown;
34
+ consumedByKeydown = true;
35
+ feed(e.key);
36
+ };
37
+ // Soft keyboards / IMEs deliver the typed text only as `InputEvent.data`.
38
+ // Listen in the capture phase so we still see it when an input component
39
+ // stops propagation. `data` is null for deletions, and we ignore in-flight
40
+ // composition to avoid re-counting the running composition string.
41
+ const onInput = (e) => {
42
+ if (consumedByKeydown) {
43
+ consumedByKeydown = false;
44
+ return;
45
+ }
46
+ const ie = e;
47
+ if (ie.isComposing)
48
+ return;
49
+ if (ie.data)
50
+ feed(ie.data);
51
+ };
25
52
  document.addEventListener('keydown', onKeyDown);
53
+ document.addEventListener('input', onInput, true);
54
+ teardown = () => {
55
+ document.removeEventListener('keydown', onKeyDown);
56
+ document.removeEventListener('input', onInput, true);
57
+ };
26
58
  }
27
59
  return () => {
28
60
  const index = callbacks.indexOf(callback);
29
61
  if (index !== -1) {
30
62
  callbacks.splice(index, 1);
31
63
  }
32
- if (callbacks.length === 0 && listenerRef) {
33
- document.removeEventListener('keydown', listenerRef);
34
- listenerRef = null;
64
+ if (callbacks.length === 0 && teardown) {
65
+ teardown();
66
+ teardown = null;
35
67
  initialized = false;
36
68
  }
37
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expofp/debug",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "type": "module",
5
5
  "description": "ExpoFP SDK internal: debug utilities",
6
6
  "homepage": "https://developer.expofp.com/",