124 lines
3.4 KiB
TypeScript
124 lines
3.4 KiB
TypeScript
// Metro module 8118 (f8119).
|
|
import { useState, useLayoutEffect, useRef, useCallback } from "react";
|
|
function $mk79879($env) {
|
|
return () => {
|
|
const r4 = $env;
|
|
const r8 = $env.$parent;
|
|
const r5 = r8[5];
|
|
const sharedValue = r4[0];
|
|
let r3 = r5.get(sharedValue);
|
|
if (r3 == null) {
|
|
let env26109 = {
|
|
$parent: r8
|
|
};
|
|
const set = new Set();
|
|
env26109[0] = set;
|
|
const valueListener = (c31444_0) => {
|
|
const r4 = env26109.$parent;
|
|
(0, r4[0])(r4[1][2]).batchUpdates(() => {
|
|
for (const item of env26109[0]) {
|
|
item(c31444_0);
|
|
}
|
|
});
|
|
};
|
|
const listenerId = r8[4] + 1;
|
|
r8[4] = listenerId;
|
|
r3 = {
|
|
sharedValue,
|
|
listeners: set,
|
|
valueListener,
|
|
listenerId
|
|
};
|
|
}
|
|
let env26110 = {
|
|
$parent: $env
|
|
};
|
|
env26110[0] = r3;
|
|
r3.listeners.add(r4[1]);
|
|
if (r3.listeners.size === 1) {
|
|
r5.set(sharedValue, r3);
|
|
const r11 = r8[0];
|
|
const r10 = r8[1];
|
|
const r35 = r11(r10[3]);
|
|
const r37 = $mk105605(r8);
|
|
r37.__closure = {
|
|
runOnJS: r11(r10[3]).runOnJS
|
|
};
|
|
r37.__workletHash = 568027628003;
|
|
r37.__initData = r8[6];
|
|
r35.runOnUI(r37)(r3.listenerId, r3.valueListener, sharedValue);
|
|
}
|
|
return () => {
|
|
const r3 = env26110[0];
|
|
const listeners = r3.listeners;
|
|
const r4 = env26110.$parent;
|
|
listeners.delete(r4[1]);
|
|
if (r3.listeners.size === 0) {
|
|
const r13 = env26110.$parent.$parent;
|
|
const r7 = (0, r13[0])(r13[1][3]);
|
|
const r18 = function n(a0, a1) {
|
|
a1.removeListener(a0);
|
|
};
|
|
r18.__closure = {};
|
|
r18.__workletHash = 15997703035823;
|
|
r18.__initData = r13[7];
|
|
const r21 = r7.runOnUI(r18);
|
|
const listenerId = r3.listenerId;
|
|
const r23 = r4[0];
|
|
r21(listenerId, r23);
|
|
r13[5].delete(r23);
|
|
}
|
|
};
|
|
};
|
|
}
|
|
function $mk105605($env) {
|
|
return function n(a0, a1, a2) {
|
|
let env29893 = {
|
|
$parent: $env
|
|
};
|
|
env29893[0] = a1;
|
|
a2.addListener(a0, (a0) => {
|
|
const r1 = env29893.$parent;
|
|
return (0, r1[0])(r1[1][3]).runOnJS(env29893[0])(a0);
|
|
});
|
|
};
|
|
}
|
|
let env5154 = {};
|
|
const c5154_4 = 9999999;
|
|
const c5154_5 = new Map();
|
|
const c5154_6 = {
|
|
code: "function useStateFromSharedValueTsx1(id,listener,sharedValue){const{runOnJS}=this.__closure;sharedValue.addListener(id,function(value){return runOnJS(listener)(value);});}"
|
|
};
|
|
const c5154_7 = {
|
|
code: "function useStateFromSharedValueTsx2(id,sharedValue){sharedValue.removeListener(id);}"
|
|
};
|
|
export default function useStateFromSharedValue(a0) {
|
|
let env16265;
|
|
const [state, setState] = useState(() => a0.get());
|
|
const r14 = env16265 = {
|
|
$parent: env5154
|
|
};
|
|
env16265[0] = a0;
|
|
env16265[1] = setState;
|
|
useLayoutEffect($mk79879(r14), [a0, setState]);
|
|
return state;
|
|
};
|
|
export function useDerivedStateFromSharedValue(a0, a1) {
|
|
let ref;
|
|
let env16267;
|
|
const current = a1;
|
|
const [state, setState] = useState(() => current(a0.get(), void 0));
|
|
ref = useRef(a1);
|
|
useLayoutEffect(() => {
|
|
ref.current = current;
|
|
});
|
|
const callback = useCallback((c26111_0) => setState((prevState) => ref.current(c26111_0, prevState)), []);
|
|
const r23 = env16267 = {
|
|
$parent: env5154
|
|
};
|
|
env16267[0] = a0;
|
|
env16267[1] = callback;
|
|
useLayoutEffect($mk79879(r23), [a0, callback]);
|
|
return state;
|
|
}
|