@buoy-gg/focus-inspector 7.0.41 → 7.0.42
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/lib/commonjs/detect/detectors.js +1 -369
- package/lib/commonjs/index.js +1 -106
- package/lib/commonjs/observe/focusEventObserver.js +1 -105
- package/lib/commonjs/observe/keyEventObserver.js +1 -94
- package/lib/commonjs/observe/keyEventObserver.web.js +1 -37
- package/lib/commonjs/observe/rawEventEmitter.js +1 -44
- package/lib/commonjs/observe/rawEventEmitter.web.js +1 -13
- package/lib/commonjs/scan/focusableScanner.js +1 -502
- package/lib/commonjs/store/focusStore.js +1 -325
- package/lib/commonjs/sync/focusInspectorSyncAdapter.js +1 -254
- package/lib/module/detect/detectors.js +1 -359
- package/lib/module/index.js +1 -36
- package/lib/module/observe/focusEventObserver.js +1 -99
- package/lib/module/observe/keyEventObserver.js +1 -86
- package/lib/module/observe/keyEventObserver.web.js +1 -30
- package/lib/module/observe/rawEventEmitter.js +1 -40
- package/lib/module/observe/rawEventEmitter.web.js +1 -4
- package/lib/module/scan/focusableScanner.js +1 -497
- package/lib/module/store/focusStore.js +1 -312
- package/lib/module/sync/focusInspectorSyncAdapter.js +1 -251
- package/lib/web/index.mjs +1 -2
- package/package.json +2 -2
- package/lib/commonjs/detect/detectors.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/observe/focusEventObserver.js.map +0 -1
- package/lib/commonjs/observe/keyEventObserver.js.map +0 -1
- package/lib/commonjs/observe/keyEventObserver.web.js.map +0 -1
- package/lib/commonjs/observe/rawEventEmitter.js.map +0 -1
- package/lib/commonjs/observe/rawEventEmitter.web.js.map +0 -1
- package/lib/commonjs/scan/focusableScanner.js.map +0 -1
- package/lib/commonjs/store/focusStore.js.map +0 -1
- package/lib/commonjs/sync/focusInspectorSyncAdapter.js.map +0 -1
- package/lib/module/detect/detectors.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/observe/focusEventObserver.js.map +0 -1
- package/lib/module/observe/keyEventObserver.js.map +0 -1
- package/lib/module/observe/keyEventObserver.web.js.map +0 -1
- package/lib/module/observe/rawEventEmitter.js.map +0 -1
- package/lib/module/observe/rawEventEmitter.web.js.map +0 -1
- package/lib/module/scan/focusableScanner.js.map +0 -1
- package/lib/module/store/focusStore.js.map +0 -1
- package/lib/module/sync/focusInspectorSyncAdapter.js.map +0 -1
- package/lib/typescript/detect/detectors.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/observe/focusEventObserver.d.ts.map +0 -1
- package/lib/typescript/observe/keyEventObserver.d.ts.map +0 -1
- package/lib/typescript/observe/keyEventObserver.web.d.ts.map +0 -1
- package/lib/typescript/observe/rawEventEmitter.d.ts.map +0 -1
- package/lib/typescript/observe/rawEventEmitter.web.d.ts.map +0 -1
- package/lib/typescript/scan/focusableScanner.d.ts.map +0 -1
- package/lib/typescript/store/focusStore.d.ts.map +0 -1
- package/lib/typescript/sync/focusInspectorSyncAdapter.d.ts.map +0 -1
|
@@ -1,94 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.attachKeyObserver = attachKeyObserver;
|
|
7
|
-
exports.detachKeyObserver = detachKeyObserver;
|
|
8
|
-
exports.isKeyObserverListening = isKeyObserverListening;
|
|
9
|
-
exports.platformOS = exports.isTV = void 0;
|
|
10
|
-
var ReactNative = _interopRequireWildcard(require("react-native"));
|
|
11
|
-
var _focusStore = require("../store/focusStore");
|
|
12
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
-
/**
|
|
14
|
-
* keyEventObserver — the direction half of the stream.
|
|
15
|
-
*
|
|
16
|
-
* D-pad HWEvents carry NO tag on either platform (an Android payload is exactly
|
|
17
|
-
* `{"eventKeyAction":1,"eventType":"right"}`), and focus events carry no
|
|
18
|
-
* direction. So key events tell you *which way the user pushed* and focus
|
|
19
|
-
* events tell you *where focus went*; the store joins them on time.
|
|
20
|
-
*
|
|
21
|
-
* `TVEventHandler.addListener` (not the `useTVEventHandler` hook) because sync
|
|
22
|
-
* adapters are not React components — nothing here mounts.
|
|
23
|
-
*
|
|
24
|
-
* On the 0.83 fork line iOS Fabric ALSO still emits tagged `focus`/`blur`
|
|
25
|
-
* HWEvents here. Those are folded into the same store as enrichment so the
|
|
26
|
-
* older line gets a focus source even if the RawEventEmitter path ever fails —
|
|
27
|
-
* never depended on, because 0.85 deleted them.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* `TVEventHandler` only exists on the react-native-tvos fork. A namespace read
|
|
32
|
-
* (rather than a named import) keeps this module importable on stock RN.
|
|
33
|
-
*/
|
|
34
|
-
const RN = ReactNative;
|
|
35
|
-
const isTV = exports.isTV = RN.Platform?.isTV === true;
|
|
36
|
-
const platformOS = exports.platformOS = RN.Platform?.OS ?? "unknown";
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Long-press variants move focus the same way a tap does, so they map to the
|
|
40
|
-
* same direction. Everything else (select, menu, playPause, pans, swipes) never
|
|
41
|
-
* moves focus and is dropped rather than logged as a probe that can't resolve.
|
|
42
|
-
*/
|
|
43
|
-
const DIRECTION_BY_EVENT_TYPE = {
|
|
44
|
-
up: "up",
|
|
45
|
-
down: "down",
|
|
46
|
-
left: "left",
|
|
47
|
-
right: "right",
|
|
48
|
-
longUp: "up",
|
|
49
|
-
longDown: "down",
|
|
50
|
-
longLeft: "left",
|
|
51
|
-
longRight: "right"
|
|
52
|
-
};
|
|
53
|
-
let subscription = null;
|
|
54
|
-
function handleEvent(raw) {
|
|
55
|
-
const event = raw;
|
|
56
|
-
const eventType = event?.eventType;
|
|
57
|
-
if (typeof eventType !== "string") return;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Dedupe by ignoring key DOWN, never key UP. tvOS emits keyAction 1 (up)
|
|
61
|
-
* ONLY for button presses — filtering to "down" would swallow every tvOS
|
|
62
|
-
* event — while Android's key-down dispatch sits behind a feature flag that
|
|
63
|
-
* is off by default. One press must open exactly one probe.
|
|
64
|
-
*/
|
|
65
|
-
if (event?.eventKeyAction === 0) return;
|
|
66
|
-
|
|
67
|
-
// 0.83-line iOS bonus: tagged focus/blur HWEvents. Guarded on the tag being
|
|
68
|
-
// present so 0.85's tag-less variants (if any ever return) can't record a
|
|
69
|
-
// transition to nowhere.
|
|
70
|
-
if (eventType === "focus" || eventType === "blur") {
|
|
71
|
-
if (typeof event?.tag !== "number") return;
|
|
72
|
-
if (eventType === "focus") (0, _focusStore.recordFocus)(event.tag);else (0, _focusStore.recordBlur)(event.tag);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const direction = DIRECTION_BY_EVENT_TYPE[eventType];
|
|
76
|
-
if (direction) (0, _focusStore.recordKey)(direction);
|
|
77
|
-
}
|
|
78
|
-
function attachKeyObserver() {
|
|
79
|
-
if (subscription || !isTV || !RN.TVEventHandler) return;
|
|
80
|
-
subscription = RN.TVEventHandler.addListener(handleEvent);
|
|
81
|
-
}
|
|
82
|
-
function detachKeyObserver() {
|
|
83
|
-
if (!subscription) return;
|
|
84
|
-
try {
|
|
85
|
-
subscription.remove();
|
|
86
|
-
} catch {
|
|
87
|
-
/* already gone */
|
|
88
|
-
}
|
|
89
|
-
subscription = null;
|
|
90
|
-
}
|
|
91
|
-
function isKeyObserverListening() {
|
|
92
|
-
return subscription !== null;
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=keyEventObserver.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.attachKeyObserver=attachKeyObserver;exports.detachKeyObserver=detachKeyObserver;exports.isKeyObserverListening=isKeyObserverListening;exports.platformOS=exports.isTV=void 0;var ReactNative=_interopRequireWildcard(require("react-native"));var _focusStore=require("../store/focusStore");function _interopRequireWildcard(f,t){if("function"==typeof WeakMap)var r=new WeakMap,s=new WeakMap;return(_interopRequireWildcard=function(e,c){if(!c&&e&&e.__esModule)return e;var n,u,i={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return i;if(n=c?s:r){if(n.has(e))return n.get(e);n.set(e,i)}for(const o in e)"default"!==o&&{}.hasOwnProperty.call(e,o)&&((u=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,o))&&(u.get||u.set)?n(i,o,u):i[o]=e[o]);return i})(f,t)}const RN=ReactNative;const isTV=exports.isTV=RN.Platform?.isTV===true;const platformOS=exports.platformOS=RN.Platform?.OS??"unknown";const DIRECTION_BY_EVENT_TYPE={up:"up",down:"down",left:"left",right:"right",longUp:"up",longDown:"down",longLeft:"left",longRight:"right"};let subscription=null;function handleEvent(f){const t=f;const r=t?.eventType;if(typeof r!=="string")return;if(t?.eventKeyAction===0)return;if(r==="focus"||r==="blur"){if(typeof t?.tag!=="number")return;if(r==="focus")(0,_focusStore.recordFocus)(t.tag);else(0,_focusStore.recordBlur)(t.tag);return}const s=DIRECTION_BY_EVENT_TYPE[r];if(s)(0,_focusStore.recordKey)(s)}function attachKeyObserver(){if(subscription||!isTV||!RN.TVEventHandler)return;subscription=RN.TVEventHandler.addListener(handleEvent)}function detachKeyObserver(){if(!subscription)return;try{subscription.remove()}catch{}subscription=null}function isKeyObserverListening(){return subscription!==null}
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.attachKeyObserver = attachKeyObserver;
|
|
7
|
-
exports.detachKeyObserver = detachKeyObserver;
|
|
8
|
-
exports.isKeyObserverListening = isKeyObserverListening;
|
|
9
|
-
exports.platformOS = exports.isTV = void 0;
|
|
10
|
-
var _focusStore = require("../store/focusStore");
|
|
11
|
-
const isTV = exports.isTV = false;
|
|
12
|
-
const platformOS = exports.platformOS = 'web';
|
|
13
|
-
let listening = false;
|
|
14
|
-
const directions = {
|
|
15
|
-
ArrowUp: 'up',
|
|
16
|
-
ArrowDown: 'down',
|
|
17
|
-
ArrowLeft: 'left',
|
|
18
|
-
ArrowRight: 'right'
|
|
19
|
-
};
|
|
20
|
-
function key(event) {
|
|
21
|
-
const direction = directions[event.key];
|
|
22
|
-
if (direction) (0, _focusStore.recordKey)(direction);
|
|
23
|
-
}
|
|
24
|
-
function attachKeyObserver() {
|
|
25
|
-
if (listening || typeof document === 'undefined') return;
|
|
26
|
-
listening = true;
|
|
27
|
-
document.addEventListener('keydown', key, true);
|
|
28
|
-
}
|
|
29
|
-
function detachKeyObserver() {
|
|
30
|
-
if (!listening) return;
|
|
31
|
-
listening = false;
|
|
32
|
-
document.removeEventListener('keydown', key, true);
|
|
33
|
-
}
|
|
34
|
-
function isKeyObserverListening() {
|
|
35
|
-
return listening;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=keyEventObserver.web.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.attachKeyObserver=attachKeyObserver;exports.detachKeyObserver=detachKeyObserver;exports.isKeyObserverListening=isKeyObserverListening;exports.platformOS=exports.isTV=void 0;var _focusStore=require("../store/focusStore");const isTV=exports.isTV=false;const platformOS=exports.platformOS="web";let listening=false;const directions={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function key(r){const e=directions[r.key];if(e)(0,_focusStore.recordKey)(e)}function attachKeyObserver(){if(listening||typeof document==="undefined")return;listening=true;document.addEventListener("keydown",key,true)}function detachKeyObserver(){if(!listening)return;listening=false;document.removeEventListener("keydown",key,true)}function isKeyObserverListening(){return listening}
|
|
@@ -1,44 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.resolveRawEventEmitter = resolveRawEventEmitter;
|
|
7
|
-
/**
|
|
8
|
-
* The one guarded require for React Native's RawEventEmitter, kept in its own
|
|
9
|
-
* module for two reasons.
|
|
10
|
-
*
|
|
11
|
-
* 1. `react-native/Libraries/Core/RawEventEmitter` is a DEEP import. It warns
|
|
12
|
-
* under 0.85's export map and could move in any release, so the failure has
|
|
13
|
-
* to degrade to "observer unavailable" in the snapshot rather than taking
|
|
14
|
-
* the host app's bundle down. Metro only treats a require as optional when
|
|
15
|
-
* it sits LEXICALLY inside a try statement — wrapping it in a helper or an
|
|
16
|
-
* arrow makes Metro hard-fail the bundle instead.
|
|
17
|
-
* 2. It gives the unit suite a seam. Node's `require` resolves through the
|
|
18
|
-
* filesystem and ignores Vitest's module mocks, so the emitter can only be
|
|
19
|
-
* faked by mocking a module that is reached with a real `import`.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
function resolveRawEventEmitter() {
|
|
23
|
-
let mod;
|
|
24
|
-
try {
|
|
25
|
-
mod = require("react-native/Libraries/Core/RawEventEmitter");
|
|
26
|
-
} catch (e) {
|
|
27
|
-
return {
|
|
28
|
-
emitter: null,
|
|
29
|
-
reason: e?.message ?? "RawEventEmitter is unavailable"
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const candidate = mod?.default ?? mod;
|
|
33
|
-
if (typeof candidate?.addListener !== "function") {
|
|
34
|
-
return {
|
|
35
|
-
emitter: null,
|
|
36
|
-
reason: "RawEventEmitter has no addListener"
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
emitter: candidate,
|
|
41
|
-
reason: null
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=rawEventEmitter.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveRawEventEmitter=resolveRawEventEmitter;function resolveRawEventEmitter(){let e;try{e=require("react-native/Libraries/Core/RawEventEmitter")}catch(r){return{emitter:null,reason:r?.message??"RawEventEmitter is unavailable"}}const t=e?.default??e;if(typeof t?.addListener!=="function"){return{emitter:null,reason:"RawEventEmitter has no addListener"}}return{emitter:t,reason:null}}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "resolveRawEventEmitter", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _utils.resolveDOMEventEmitter;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _utils = require("@buoy-gg/shared-ui/utils");
|
|
13
|
-
//# sourceMappingURL=rawEventEmitter.web.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"resolveRawEventEmitter",{enumerable:true,get:function(){return _utils.resolveDOMEventEmitter}});var _utils=require("@buoy-gg/shared-ui/utils");
|