@tamagui/react-native-use-responder-events 1.112.4 → 1.112.5

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.
@@ -26,12 +26,12 @@ __export(useResponderEvents_exports, {
26
26
  module.exports = __toCommonJS(useResponderEvents_exports);
27
27
  var React = __toESM(require("react")), ResponderSystem = __toESM(require("./ResponderSystem"));
28
28
  __reExport(useResponderEvents_exports, require("./utils"), module.exports);
29
- const emptyObject = {};
29
+ const emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
30
30
  function useResponderEvents(hostRef, config = emptyObject) {
31
- const id = React.useId(), isAttachedRef = React.useRef(!1);
32
- React.useEffect(() => (ResponderSystem.attachListeners(), () => {
33
- ResponderSystem.removeNode(id);
34
- }), [id]), React.useEffect(() => {
31
+ Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
32
+ const id = Ids.get(hostRef);
33
+ React.useEffect(() => {
34
+ ResponderSystem.attachListeners();
35
35
  const {
36
36
  onMoveShouldSetResponder,
37
37
  onMoveShouldSetResponderCapture,
@@ -42,7 +42,11 @@ function useResponderEvents(hostRef, config = emptyObject) {
42
42
  onStartShouldSetResponder,
43
43
  onStartShouldSetResponderCapture
44
44
  } = config, requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture), node = hostRef.current.host;
45
- requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
45
+ if (requiresResponderSystem)
46
+ return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), () => {
47
+ ResponderSystem.removeNode(node);
48
+ };
49
+ Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
46
50
  }, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({
47
51
  isResponder: hostRef.current === ResponderSystem.getResponderNode()
48
52
  }), React.useDebugValue(config));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/useResponderEvents.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,YAAuB,2BAEvB,kBAAiC;AAEjC,uCAAc,oBAVd;AAYA,MAAM,cAAc,CAAC;AAEd,SAAS,mBACd,SACA,SAA0C,aAC1C;AACA,QAAM,KAAK,MAAM,MAAM,GACjB,gBAAgB,MAAM,OAAO,EAAK;AAKxC,QAAM,UAAU,OACd,gBAAgB,gBAAgB,GACzB,MAAM;AACX,oBAAgB,WAAW,EAAE;AAAA,EAC/B,IACC,CAAC,EAAE,CAAC,GAGP,MAAM,UAAU,MAAM;AACpB,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,QAEE,0BAA0B,GAC9B,4BACE,mCACA,8BACA,qCACA,uCACA,8CACA,6BACA,mCAGE,OAAO,QAAQ,QAAQ;AAE7B,IAAI,2BACF,gBAAgB,QAAQ,IAAI,MAAM,MAAM,GACxC,cAAc,UAAU,MACf,cAAc,YACvB,gBAAgB,WAAW,EAAE,GAC7B,cAAc,UAAU;AAAA,EAE5B,GAAG,CAAC,QAAQ,SAAS,EAAE,CAAC,GAEpB,QAAQ,IAAI,aAAa,kBAC3B,MAAM,cAAc;AAAA,IAClB,aAAa,QAAQ,YAAY,gBAAgB,iBAAiB;AAAA,EACpE,CAAC,GACD,MAAM,cAAc,MAAM;AAE9B;",
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,YAAuB,2BAEvB,kBAAiC;AAEjC,uCAAc,oBAVd;AAYA,MAAM,cAAc,CAAC,GAEf,WAAW,oBAAI,QAAsB,GACrC,MAAM,oBAAI,QAAqB;AAE9B,SAAS,mBACd,SACA,SAA0C,aAC1C;AACA,EAAK,IAAI,IAAI,OAAO,KAClB,IAAI,IAAI,SAAS,GAAG,KAAK,OAAO,CAAC,EAAE;AAErC,QAAM,KAAK,IAAI,IAAI,OAAO;AAG1B,QAAM,UAAU,MAAM;AACpB,oBAAgB,gBAAgB;AAEhC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,QAEE,0BAA0B,GAC9B,4BACE,mCACA,8BACA,qCACA,uCACA,8CACA,6BACA,mCAGE,OAAO,QAAQ,QAAQ;AAE7B,QAAI;AACF,6BAAgB,QAAQ,IAAI,MAAM,MAAM,GACxC,SAAS,IAAI,SAAS,EAAI,GAEnB,MAAM;AACX,wBAAgB,WAAW,IAAI;AAAA,MACjC;AAGF,IAAI,SAAS,IAAI,IAAI,MACnB,gBAAgB,WAAW,IAAI,GAC/B,SAAS,IAAI,SAAS,EAAK;AAAA,EAE/B,GAAG,CAAC,QAAQ,SAAS,EAAE,CAAC,GAEpB,QAAQ,IAAI,aAAa,kBAC3B,MAAM,cAAc;AAAA,IAClB,aAAa,QAAQ,YAAY,gBAAgB,iBAAiB;AAAA,EACpE,CAAC,GACD,MAAM,cAAc,MAAM;AAE9B;",
5
5
  "names": []
6
6
  }
@@ -27,18 +27,19 @@ __export(useResponderEvents_exports, {
27
27
  module.exports = __toCommonJS(useResponderEvents_exports);
28
28
  var React = __toESM(require("react")), ResponderSystem = __toESM(require("./ResponderSystem"));
29
29
  __reExport(useResponderEvents_exports, require("./utils"), module.exports);
30
- var emptyObject = {};
30
+ var emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
31
31
  function useResponderEvents(hostRef) {
32
- var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject, id = React.useId(), isAttachedRef = React.useRef(!1);
32
+ var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject;
33
+ Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
34
+ var id = Ids.get(hostRef);
33
35
  React.useEffect(function() {
34
- return ResponderSystem.attachListeners(), function() {
35
- ResponderSystem.removeNode(id);
36
- };
37
- }, [
38
- id
39
- ]), React.useEffect(function() {
36
+ ResponderSystem.attachListeners();
40
37
  var { onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onScrollShouldSetResponder, onScrollShouldSetResponderCapture, onSelectionChangeShouldSetResponder, onSelectionChangeShouldSetResponderCapture, onStartShouldSetResponder, onStartShouldSetResponderCapture } = config, requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture), node = hostRef.current.host;
41
- requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
38
+ if (requiresResponderSystem)
39
+ return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), function() {
40
+ ResponderSystem.removeNode(node);
41
+ };
42
+ Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
42
43
  }, [
43
44
  config,
44
45
  hostRef,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Users/n8/tamagui/code/core/react-native-use-responder-events/src/useResponderEvents.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAMA,YAAuB,2BAEvB,kBAAiC;AAEjC,uCAAc,oBAVd;AAYA,IAAMA,cAAc,CAAC;AAEd,SAASC,mBACdC,SAAY;MACZC,SAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAA0CH,aAEpCI,KAAKC,MAAMC,MAAK,GAChBC,gBAAgBF,MAAMG,OAAO,EAAA;AAKnCH,QAAMI,UAAU,WAAA;AACdC,2BAAgBC,gBAAe,GACxB,WAAA;AACLD,sBAAgBE,WAAWR,EAAAA;IAC7B;EACF,GAAG;IAACA;GAAG,GAGPC,MAAMI,UAAU,WAAA;AACd,QAAM,EACJI,0BACAC,iCACAC,4BACAC,mCACAC,qCACAC,4CACAC,2BACAC,iCAAgC,IAC9BjB,QAEEkB,0BAA0BC,GAC9BT,4BACEC,mCACAC,8BACAC,qCACAC,uCACAC,8CACAC,6BACAC,mCAGEG,OAAOrB,QAAQsB,QAAQC;AAE7B,IAAIJ,2BACFX,gBAAgBgB,QAAQtB,IAAImB,MAAMpB,MAAAA,GAClCI,cAAciB,UAAU,MACfjB,cAAciB,YACvBd,gBAAgBE,WAAWR,EAAAA,GAC3BG,cAAciB,UAAU;EAE5B,GAAG;IAACrB;IAAQD;IAASE;GAAG,GAEpBuB,QAAQC,IAAIC,aAAa,kBAC3BxB,MAAMyB,cAAc;IAClBC,aAAa7B,QAAQsB,YAAYd,gBAAgBsB,iBAAgB;EACnE,CAAA,GACA3B,MAAMyB,cAAc3B,MAAAA;AAExB;",
5
- "names": ["emptyObject", "useResponderEvents", "hostRef", "config", "id", "React", "useId", "isAttachedRef", "useRef", "useEffect", "ResponderSystem", "attachListeners", "removeNode", "onMoveShouldSetResponder", "onMoveShouldSetResponderCapture", "onScrollShouldSetResponder", "onScrollShouldSetResponderCapture", "onSelectionChangeShouldSetResponder", "onSelectionChangeShouldSetResponderCapture", "onStartShouldSetResponder", "onStartShouldSetResponderCapture", "requiresResponderSystem", "Boolean", "node", "current", "host", "addNode", "process", "env", "NODE_ENV", "useDebugValue", "isResponder", "getResponderNode"]
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAMA,YAAuB,2BAEvB,kBAAiC;AAEjC,uCAAc,oBAVd;AAYA,IAAMA,cAAc,CAAC,GAEfC,WAAW,oBAAIC,QAAAA,GACfC,MAAM,oBAAID,QAAAA;AAET,SAASE,mBACdC,SAAY;MACZC,SAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAA0CN;AAE1C,EAAKG,IAAII,IAAIF,OAAAA,KACXF,IAAIK,IAAIH,SAAS,GAAGI,KAAKC,OAAM,CAAA,EAAI;AAErC,MAAMC,KAAKR,IAAIS,IAAIP,OAAAA;AAGnBQ,QAAMC,UAAU,WAAA;AACdC,oBAAgBC,gBAAe;AAE/B,QAAM,EACJC,0BACAC,iCACAC,4BACAC,mCACAC,qCACAC,4CACAC,2BACAC,iCAAgC,IAC9BlB,QAEEmB,0BAA0BC,GAC9BT,4BACEC,mCACAC,8BACAC,qCACAC,uCACAC,8CACAC,6BACAC,mCAGEG,OAAOtB,QAAQuB,QAAQC;AAE7B,QAAIJ;AACFV,6BAAgBe,QAAQnB,IAAIgB,MAAMrB,MAAAA,GAClCL,SAASO,IAAIH,SAAS,EAAA,GAEf,WAAA;AACLU,wBAAgBgB,WAAWJ,IAAAA;MAC7B;AAGF,IAAI1B,SAASW,IAAIe,IAAAA,MACfZ,gBAAgBgB,WAAWJ,IAAAA,GAC3B1B,SAASO,IAAIH,SAAS,EAAA;EAE1B,GAAG;IAACC;IAAQD;IAASM;GAAG,GAEpBqB,QAAQC,IAAIC,aAAa,kBAC3BrB,MAAMsB,cAAc;IAClBC,aAAa/B,QAAQuB,YAAYb,gBAAgBsB,iBAAgB;EACnE,CAAA,GACAxB,MAAMsB,cAAc7B,MAAAA;AAExB;",
5
+ "names": ["emptyObject", "Attached", "WeakMap", "Ids", "useResponderEvents", "hostRef", "config", "has", "set", "Math", "random", "id", "get", "React", "useEffect", "ResponderSystem", "attachListeners", "onMoveShouldSetResponder", "onMoveShouldSetResponderCapture", "onScrollShouldSetResponder", "onScrollShouldSetResponderCapture", "onSelectionChangeShouldSetResponder", "onSelectionChangeShouldSetResponderCapture", "onStartShouldSetResponder", "onStartShouldSetResponderCapture", "requiresResponderSystem", "Boolean", "node", "current", "host", "addNode", "removeNode", "process", "env", "NODE_ENV", "useDebugValue", "isResponder", "getResponderNode"]
6
6
  }
@@ -1,12 +1,12 @@
1
1
  import * as React from "react";
2
2
  import * as ResponderSystem from "./ResponderSystem";
3
3
  export * from "./utils";
4
- const emptyObject = {};
4
+ const emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
5
5
  function useResponderEvents(hostRef, config = emptyObject) {
6
- const id = React.useId(), isAttachedRef = React.useRef(!1);
7
- React.useEffect(() => (ResponderSystem.attachListeners(), () => {
8
- ResponderSystem.removeNode(id);
9
- }), [id]), React.useEffect(() => {
6
+ Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
7
+ const id = Ids.get(hostRef);
8
+ React.useEffect(() => {
9
+ ResponderSystem.attachListeners();
10
10
  const {
11
11
  onMoveShouldSetResponder,
12
12
  onMoveShouldSetResponderCapture,
@@ -17,7 +17,11 @@ function useResponderEvents(hostRef, config = emptyObject) {
17
17
  onStartShouldSetResponder,
18
18
  onStartShouldSetResponderCapture
19
19
  } = config, requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture), node = hostRef.current.host;
20
- requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
20
+ if (requiresResponderSystem)
21
+ return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), () => {
22
+ ResponderSystem.removeNode(node);
23
+ };
24
+ Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
21
25
  }, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({
22
26
  isResponder: hostRef.current === ResponderSystem.getResponderNode()
23
27
  }), React.useDebugValue(config));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/useResponderEvents.ts"],
4
- "mappings": "AAMA,YAAY,WAAW;AAEvB,YAAY,qBAAqB;AAEjC,cAAc;AAEd,MAAM,cAAc,CAAC;AAEd,SAAS,mBACd,SACA,SAA0C,aAC1C;AACA,QAAM,KAAK,MAAM,MAAM,GACjB,gBAAgB,MAAM,OAAO,EAAK;AAKxC,QAAM,UAAU,OACd,gBAAgB,gBAAgB,GACzB,MAAM;AACX,oBAAgB,WAAW,EAAE;AAAA,EAC/B,IACC,CAAC,EAAE,CAAC,GAGP,MAAM,UAAU,MAAM;AACpB,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,QAEE,0BAA0B,GAC9B,4BACE,mCACA,8BACA,qCACA,uCACA,8CACA,6BACA,mCAGE,OAAO,QAAQ,QAAQ;AAE7B,IAAI,2BACF,gBAAgB,QAAQ,IAAI,MAAM,MAAM,GACxC,cAAc,UAAU,MACf,cAAc,YACvB,gBAAgB,WAAW,EAAE,GAC7B,cAAc,UAAU;AAAA,EAE5B,GAAG,CAAC,QAAQ,SAAS,EAAE,CAAC,GAEpB,QAAQ,IAAI,aAAa,kBAC3B,MAAM,cAAc;AAAA,IAClB,aAAa,QAAQ,YAAY,gBAAgB,iBAAiB;AAAA,EACpE,CAAC,GACD,MAAM,cAAc,MAAM;AAE9B;",
4
+ "mappings": "AAMA,YAAY,WAAW;AAEvB,YAAY,qBAAqB;AAEjC,cAAc;AAEd,MAAM,cAAc,CAAC,GAEf,WAAW,oBAAI,QAAsB,GACrC,MAAM,oBAAI,QAAqB;AAE9B,SAAS,mBACd,SACA,SAA0C,aAC1C;AACA,EAAK,IAAI,IAAI,OAAO,KAClB,IAAI,IAAI,SAAS,GAAG,KAAK,OAAO,CAAC,EAAE;AAErC,QAAM,KAAK,IAAI,IAAI,OAAO;AAG1B,QAAM,UAAU,MAAM;AACpB,oBAAgB,gBAAgB;AAEhC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,QAEE,0BAA0B,GAC9B,4BACE,mCACA,8BACA,qCACA,uCACA,8CACA,6BACA,mCAGE,OAAO,QAAQ,QAAQ;AAE7B,QAAI;AACF,6BAAgB,QAAQ,IAAI,MAAM,MAAM,GACxC,SAAS,IAAI,SAAS,EAAI,GAEnB,MAAM;AACX,wBAAgB,WAAW,IAAI;AAAA,MACjC;AAGF,IAAI,SAAS,IAAI,IAAI,MACnB,gBAAgB,WAAW,IAAI,GAC/B,SAAS,IAAI,SAAS,EAAK;AAAA,EAE/B,GAAG,CAAC,QAAQ,SAAS,EAAE,CAAC,GAEpB,QAAQ,IAAI,aAAa,kBAC3B,MAAM,cAAc;AAAA,IAClB,aAAa,QAAQ,YAAY,gBAAgB,iBAAiB;AAAA,EACpE,CAAC,GACD,MAAM,cAAc,MAAM;AAE9B;",
5
5
  "names": []
6
6
  }
@@ -1,13 +1,14 @@
1
1
  import * as React from "react";
2
2
  import * as ResponderSystem from "./ResponderSystem.mjs";
3
3
  export * from "./utils.mjs";
4
- const emptyObject = {};
4
+ const emptyObject = {},
5
+ Attached = /* @__PURE__ */new WeakMap(),
6
+ Ids = /* @__PURE__ */new WeakMap();
5
7
  function useResponderEvents(hostRef, config = emptyObject) {
6
- const id = React.useId(),
7
- isAttachedRef = React.useRef(!1);
8
- React.useEffect(() => (ResponderSystem.attachListeners(), () => {
9
- ResponderSystem.removeNode(id);
10
- }), [id]), React.useEffect(() => {
8
+ Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
9
+ const id = Ids.get(hostRef);
10
+ React.useEffect(() => {
11
+ ResponderSystem.attachListeners();
11
12
  const {
12
13
  onMoveShouldSetResponder,
13
14
  onMoveShouldSetResponderCapture,
@@ -20,7 +21,10 @@ function useResponderEvents(hostRef, config = emptyObject) {
20
21
  } = config,
21
22
  requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture),
22
23
  node = hostRef.current.host;
23
- requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
24
+ if (requiresResponderSystem) return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), () => {
25
+ ResponderSystem.removeNode(node);
26
+ };
27
+ Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
24
28
  }, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({
25
29
  isResponder: hostRef.current === ResponderSystem.getResponderNode()
26
30
  }), React.useDebugValue(config));
@@ -1 +1 @@
1
- {"version":3,"names":["React","ResponderSystem","emptyObject","useResponderEvents","hostRef","config","id","useId","isAttachedRef","useRef","useEffect","attachListeners","removeNode","onMoveShouldSetResponder","onMoveShouldSetResponderCapture","onScrollShouldSetResponder","onScrollShouldSetResponderCapture","onSelectionChangeShouldSetResponder","onSelectionChangeShouldSetResponderCapture","onStartShouldSetResponder","onStartShouldSetResponderCapture","requiresResponderSystem","node","current","host","addNode","process","env","NODE_ENV","useDebugValue","isResponder","getResponderNode"],"sources":["../../src/useResponderEvents.ts"],"sourcesContent":[null],"mappings":"AAMA,YAAYA,KAAA,MAAW;AAEvB,YAAYC,eAAA,MAAqB;AAEjC,cAAc;AAEd,MAAMC,WAAA,GAAc,CAAC;AAEd,SAASC,mBACdC,OAAA,EACAC,MAAA,GAA0CH,WAAA,EAC1C;EACA,MAAMI,EAAA,GAAKN,KAAA,CAAMO,KAAA,CAAM;IACjBC,aAAA,GAAgBR,KAAA,CAAMS,MAAA,CAAO,EAAK;EAKxCT,KAAA,CAAMU,SAAA,CAAU,OACdT,eAAA,CAAgBU,eAAA,CAAgB,GACzB,MAAM;IACXV,eAAA,CAAgBW,UAAA,CAAWN,EAAE;EAC/B,IACC,CAACA,EAAE,CAAC,GAGPN,KAAA,CAAMU,SAAA,CAAU,MAAM;IACpB,MAAM;QACJG,wBAAA;QACAC,+BAAA;QACAC,0BAAA;QACAC,iCAAA;QACAC,mCAAA;QACAC,0CAAA;QACAC,yBAAA;QACAC;MACF,IAAIf,MAAA;MAEEgB,uBAAA,GAA0B,GAC9BR,wBAAA,IACEC,+BAAA,IACAC,0BAAA,IACAC,iCAAA,IACAC,mCAAA,IACAC,0CAAA,IACAC,yBAAA,IACAC,gCAAA;MAGEE,IAAA,GAAOlB,OAAA,CAAQmB,OAAA,CAAQC,IAAA;IAEzBH,uBAAA,IACFpB,eAAA,CAAgBwB,OAAA,CAAQnB,EAAA,EAAIgB,IAAA,EAAMjB,MAAM,GACxCG,aAAA,CAAce,OAAA,GAAU,MACff,aAAA,CAAce,OAAA,KACvBtB,eAAA,CAAgBW,UAAA,CAAWN,EAAE,GAC7BE,aAAA,CAAce,OAAA,GAAU;EAE5B,GAAG,CAAClB,MAAA,EAAQD,OAAA,EAASE,EAAE,CAAC,GAEpBoB,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,kBAC3B5B,KAAA,CAAM6B,aAAA,CAAc;IAClBC,WAAA,EAAa1B,OAAA,CAAQmB,OAAA,KAAYtB,eAAA,CAAgB8B,gBAAA,CAAiB;EACpE,CAAC,GACD/B,KAAA,CAAM6B,aAAA,CAAcxB,MAAM;AAE9B","ignoreList":[]}
1
+ {"version":3,"names":["React","ResponderSystem","emptyObject","Attached","WeakMap","Ids","useResponderEvents","hostRef","config","has","set","Math","random","id","get","useEffect","attachListeners","onMoveShouldSetResponder","onMoveShouldSetResponderCapture","onScrollShouldSetResponder","onScrollShouldSetResponderCapture","onSelectionChangeShouldSetResponder","onSelectionChangeShouldSetResponderCapture","onStartShouldSetResponder","onStartShouldSetResponderCapture","requiresResponderSystem","node","current","host","addNode","removeNode","process","env","NODE_ENV","useDebugValue","isResponder","getResponderNode"],"sources":["../../src/useResponderEvents.ts"],"sourcesContent":[null],"mappings":"AAMA,YAAYA,KAAA,MAAW;AAEvB,YAAYC,eAAA,MAAqB;AAEjC,cAAc;AAEd,MAAMC,WAAA,GAAc,CAAC;EAEfC,QAAA,GAAW,mBAAIC,OAAA,CAAsB;EACrCC,GAAA,GAAM,mBAAID,OAAA,CAAqB;AAE9B,SAASE,mBACdC,OAAA,EACAC,MAAA,GAA0CN,WAAA,EAC1C;EACKG,GAAA,CAAII,GAAA,CAAIF,OAAO,KAClBF,GAAA,CAAIK,GAAA,CAAIH,OAAA,EAAS,GAAGI,IAAA,CAAKC,MAAA,CAAO,CAAC,EAAE;EAErC,MAAMC,EAAA,GAAKR,GAAA,CAAIS,GAAA,CAAIP,OAAO;EAG1BP,KAAA,CAAMe,SAAA,CAAU,MAAM;IACpBd,eAAA,CAAgBe,eAAA,CAAgB;IAEhC,MAAM;QACJC,wBAAA;QACAC,+BAAA;QACAC,0BAAA;QACAC,iCAAA;QACAC,mCAAA;QACAC,0CAAA;QACAC,yBAAA;QACAC;MACF,IAAIhB,MAAA;MAEEiB,uBAAA,GAA0B,GAC9BR,wBAAA,IACEC,+BAAA,IACAC,0BAAA,IACAC,iCAAA,IACAC,mCAAA,IACAC,0CAAA,IACAC,yBAAA,IACAC,gCAAA;MAGEE,IAAA,GAAOnB,OAAA,CAAQoB,OAAA,CAAQC,IAAA;IAE7B,IAAIH,uBAAA,EACF,OAAAxB,eAAA,CAAgB4B,OAAA,CAAQhB,EAAA,EAAIa,IAAA,EAAMlB,MAAM,GACxCL,QAAA,CAASO,GAAA,CAAIH,OAAA,EAAS,EAAI,GAEnB,MAAM;MACXN,eAAA,CAAgB6B,UAAA,CAAWJ,IAAI;IACjC;IAGEvB,QAAA,CAASW,GAAA,CAAIY,IAAI,MACnBzB,eAAA,CAAgB6B,UAAA,CAAWJ,IAAI,GAC/BvB,QAAA,CAASO,GAAA,CAAIH,OAAA,EAAS,EAAK;EAE/B,GAAG,CAACC,MAAA,EAAQD,OAAA,EAASM,EAAE,CAAC,GAEpBkB,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,kBAC3BjC,KAAA,CAAMkC,aAAA,CAAc;IAClBC,WAAA,EAAa5B,OAAA,CAAQoB,OAAA,KAAY1B,eAAA,CAAgBmC,gBAAA,CAAiB;EACpE,CAAC,GACDpC,KAAA,CAAMkC,aAAA,CAAc1B,MAAM;AAE9B","ignoreList":[]}
@@ -1,16 +1,15 @@
1
1
  import * as React from "react";
2
2
  import * as ResponderSystem from "./ResponderSystem.native.js";
3
3
  export * from "./utils.native.js";
4
- var emptyObject = {};
4
+ var emptyObject = {},
5
+ Attached = /* @__PURE__ */new WeakMap(),
6
+ Ids = /* @__PURE__ */new WeakMap();
5
7
  function useResponderEvents(hostRef) {
6
- var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject,
7
- id = React.useId(),
8
- isAttachedRef = React.useRef(!1);
8
+ var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject;
9
+ Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
10
+ var id = Ids.get(hostRef);
9
11
  React.useEffect(function () {
10
- return ResponderSystem.attachListeners(), function () {
11
- ResponderSystem.removeNode(id);
12
- };
13
- }, [id]), React.useEffect(function () {
12
+ ResponderSystem.attachListeners();
14
13
  var {
15
14
  onMoveShouldSetResponder,
16
15
  onMoveShouldSetResponderCapture,
@@ -23,7 +22,10 @@ function useResponderEvents(hostRef) {
23
22
  } = config,
24
23
  requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture),
25
24
  node = hostRef.current.host;
26
- requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
25
+ if (requiresResponderSystem) return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), function () {
26
+ ResponderSystem.removeNode(node);
27
+ };
28
+ Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
27
29
  }, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({
28
30
  isResponder: hostRef.current === ResponderSystem.getResponderNode()
29
31
  }), React.useDebugValue(config));
@@ -1 +1 @@
1
- {"version":3,"names":["React","ResponderSystem","emptyObject","useResponderEvents","hostRef","config","arguments","length","id","useId","isAttachedRef","useRef","useEffect","attachListeners","removeNode","onMoveShouldSetResponder","onMoveShouldSetResponderCapture","onScrollShouldSetResponder","onScrollShouldSetResponderCapture","onSelectionChangeShouldSetResponder","onSelectionChangeShouldSetResponderCapture","onStartShouldSetResponder","onStartShouldSetResponderCapture","requiresResponderSystem","node","current","host","addNode","process","env","NODE_ENV","useDebugValue","isResponder","getResponderNode"],"sources":["../../src/useResponderEvents.ts"],"sourcesContent":[null],"mappings":"AAMA,YAAYA,KAAA,MAAW;AAEvB,YAAYC,eAAA,MAAqB;AAEjC,cAAc;AAEd,IAAAC,WAAM,KAAc;AAEb,SAASC,mBACdC,OAAA,EACA;EAEA,IAAAC,MAAM,GAAKC,SAAM,CAAMC,MACjB,QAAAD,SAAgB,EAAM,WAAY,IAAAA,SAAA,MAAAJ,WAAA;IAAAM,EAAA,GAAAR,KAAA,CAAAS,KAAA;IAAAC,aAAA,GAAAV,KAAA,CAAAW,MAAA;EAKxCX,KAAA,CAAMY,SAAA,CAAU,YACd;IAEE,OAAAX,eAAgB,CAAAY,eAAa;MAE9BZ,eAGG,CAAAa,UAAU,CAAAN,EAAM;IACpB;EAAM,IACJA,EACA,IACAR,KAAA,CAAAY,SAAA;IAAA,IACA;QAAAG,wBAAA;QAAAC,+BAAA;QAAAC,0BAAA;QAAAC,iCAAA;QAAAC,mCAAA;QAAAC,0CAAA;QAAAC,yBAAA;QAAAC;MAAA,IAAAjB,MAAA;MAAAkB,uBAAA,MAAAR,wBAAA,IAAAC,+BAAA,IAAAC,0BAAA,IAAAC,iCAAA,IAAAC,mCAAA,IAAAC,0CAAA,IAAAC,yBAAA,IAAAC,gCAAA;MAAAE,IAAA,GAAApB,OAAA,CAAAqB,OAAA,CAAAC,IAAA;IAAAH,uBACA,IAAAtB,eAAA,CAAA0B,OAAA,CAAAnB,EAAA,EAAAgB,IAAA,EAAAnB,MAAA,GAAAK,aAAA,CAAAe,OAAA,SAAAf,aAAA,CAAAe,OAAA,KAAAxB,eAAA,CAAAa,UAAA,CAAAN,EAAA,GAAAE,aAAA,CAAAe,OAAA;EAAA,IACApB,MACA,EAAAD,OACA,EACFI,EAAA,CAeA,CAAI,EAAAoB,OAAA,CAAAC,GAAA,CAAAC,QAAA,KACF,kBAAgB9B,KAAA,CAAQ+B,aAAU;IAMtCC,WAAY,EAAA5B,OAAS,CAAEqB,OAEnB,KAAQxB,eAAI,CAAAgC,gBAAa;EACP,EAClB,EAAAjC,KAAA,CAAA+B,aAAqB,CAAA1B,MAAA;AAA6C;AAIxE,S","ignoreList":[]}
1
+ {"version":3,"names":["React","ResponderSystem","emptyObject","Attached","WeakMap","Ids","useResponderEvents","hostRef","config","arguments","length","has","set","Math","random","id","get","useEffect","attachListeners","onMoveShouldSetResponder","onMoveShouldSetResponderCapture","onScrollShouldSetResponder","onScrollShouldSetResponderCapture","onSelectionChangeShouldSetResponder","onSelectionChangeShouldSetResponderCapture","onStartShouldSetResponder","onStartShouldSetResponderCapture","requiresResponderSystem","node","current","host","addNode","removeNode","process","env","NODE_ENV","useDebugValue","isResponder","getResponderNode"],"sources":["../../src/useResponderEvents.ts"],"sourcesContent":[null],"mappings":"AAMA,YAAYA,KAAA,MAAW;AAEvB,YAAYC,eAAA,MAAqB;AAEjC,cAAc;AAEd,IAAAC,WAAM,KAAc;EAACC,QAEf,kBAAW,IAAAC,OAAI;EAAsBC,GACrC,kBAAM,IAAAD,OAAI;AAET,SAASE,mBACdC,OAAA,EACA;EAEK,IAAIC,MAAI,GAAAC,SACX,CAAAC,MAAQ,QAASD,SAAQ,QAAQ,KAAE,IAAAA,SAAA,MAAAP,WAAA;EAErCG,GAAA,CAAAM,GAAM,CAAAJ,OAAS,KAAIF,GAAA,CAAAO,GAAO,CAAAL,OAAA,KAAAM,IAAA,CAAAC,MAAA;EAG1B,IAAAC,EAAM,GAAAV,GAAA,CAAAW,GAAU,CAAAT,OAAM;EACpBP,KAAA,CAAAiB,SAAA,aAAgB;IAEhBhB,eAAM,CAAAiB,eAAA;IAAA,IACJ;QAAAC,wBAAA;QAAAC,+BAAA;QAAAC,0BAAA;QAAAC,iCAAA;QAAAC,mCAAA;QAAAC,0CAAA;QAAAC,yBAAA;QAAAC;MAAA,IAAAlB,MAAA;MAAAmB,uBAAA,MAAAR,wBAAA,IAAAC,+BAAA,IAAAC,0BAAA,IAAAC,iCAAA,IAAAC,mCAAA,IAAAC,0CAAA,IAAAC,yBAAA,IAAAC,gCAAA;MAAAE,IAAA,GAAArB,OAAA,CAAAsB,OAAA,CAAAC,IAAA;IAAA,IACAH,uBAAA,EACA,OAAA1B,eAAA,CAAA8B,OAAA,CAAAhB,EAAA,EAAAa,IAAA,EAAApB,MAAA,GAAAL,QAAA,CAAAS,GAAA,CAAAL,OAAA;MACAN,eAAA,CAAA+B,UAAA,CAAAJ,IAAA;IACA;IAAAzB,QACA,CAAAa,GAAA,CAAAY,IAAA,MAAA3B,eAAA,CAAA+B,UAAA,CAAAJ,IAAA,GAAAzB,QAAA,CAAAS,GAAA,CAAAL,OAAA;EAAA,IACAC,MACA,EACFD,OAAI,EAeJQ,EAAA,CACE,GAAAkB,OAAA,CAAAC,GAAA,CAAAC,QAAA,KAAgB,aAAY,KAAMnC,KAAM,CAAAoC,aAC/B,CAAI;IAGXC,WAAA,EAAA9B,OAAgB,CAAAsB,OAAA,KAAW5B,eAAI,CAAAqC,gBAAA;EAAA,IACjCtC,KAAA,CAAAoC,aAAA,CAAA5B,MAAA;AAGF;AAE6B,SAKTF,kBACL","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/react-native-use-responder-events",
3
- "version": "1.112.4",
3
+ "version": "1.112.5",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -28,7 +28,7 @@
28
28
  }
29
29
  },
30
30
  "devDependencies": {
31
- "@tamagui/build": "1.112.4",
31
+ "@tamagui/build": "1.112.5",
32
32
  "react": "^18.2.0 || ^19.0.0"
33
33
  },
34
34
  "publishConfig": {
@@ -12,25 +12,22 @@ export * from './utils'
12
12
 
13
13
  const emptyObject = {}
14
14
 
15
+ const Attached = new WeakMap<any, boolean>()
16
+ const Ids = new WeakMap<any, string>()
17
+
15
18
  export function useResponderEvents(
16
19
  hostRef: any,
17
20
  config: ResponderSystem.ResponderConfig = emptyObject
18
21
  ) {
19
- const id = React.useId()
20
- const isAttachedRef = React.useRef(false)
22
+ if (!Ids.has(hostRef)) {
23
+ Ids.set(hostRef, `${Math.random()}`)
24
+ }
25
+ const id = Ids.get(hostRef)!
21
26
 
22
- // This is a separate effects so it doesn't run when the config changes.
23
- // On initial mount, attach global listeners if needed.
24
- // On unmount, remove node potentially attached to the Responder System.
27
+ // Register and unregister with the Responder System as necessary
25
28
  React.useEffect(() => {
26
29
  ResponderSystem.attachListeners()
27
- return () => {
28
- ResponderSystem.removeNode(id)
29
- }
30
- }, [id])
31
30
 
32
- // Register and unregister with the Responder System as necessary
33
- React.useEffect(() => {
34
31
  const {
35
32
  onMoveShouldSetResponder,
36
33
  onMoveShouldSetResponderCapture,
@@ -57,10 +54,16 @@ export function useResponderEvents(
57
54
 
58
55
  if (requiresResponderSystem) {
59
56
  ResponderSystem.addNode(id, node, config)
60
- isAttachedRef.current = true
61
- } else if (isAttachedRef.current) {
62
- ResponderSystem.removeNode(id)
63
- isAttachedRef.current = false
57
+ Attached.set(hostRef, true)
58
+
59
+ return () => {
60
+ ResponderSystem.removeNode(node)
61
+ }
62
+ }
63
+
64
+ if (Attached.get(node)) {
65
+ ResponderSystem.removeNode(node)
66
+ Attached.set(hostRef, false)
64
67
  }
65
68
  }, [config, hostRef, id])
66
69
 
@@ -1 +1 @@
1
- {"version":3,"file":"useResponderEvents.d.ts","sourceRoot":"","sources":["../src/useResponderEvents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAA;AAEpD,cAAc,SAAS,CAAA;AAIvB,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,GAAG,EACZ,MAAM,GAAE,eAAe,CAAC,eAA6B,QAwDtD"}
1
+ {"version":3,"file":"useResponderEvents.d.ts","sourceRoot":"","sources":["../src/useResponderEvents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAA;AAEpD,cAAc,SAAS,CAAA;AAOvB,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,GAAG,EACZ,MAAM,GAAE,eAAe,CAAC,eAA6B,QAwDtD"}