decord/source/__polyfill/01xxx/module_1511.js
github-actions e510164e6b chore: update source for alpha 346.2
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4759.js (118.4 MB)
2026-09-10 05:38:07 +00:00

137 lines
3.8 KiB
JavaScript

// Module ID: 1511
// Function ID: 1512
// Dependencies: [19]
// Exports: useEventEmitter
// Module 1511
import noop from "module_19" /* 19 */;
export const useEventEmitter = function useEventEmitter(set, onEmitEvent) {
let current = set;
let current2 = onEmitEvent;
noop.useRef(set);
noop.useRef(onEmitEvent);
const insertionEffect = noop.useInsertionEffect(() => {
closure_2.current = current;
closure_3.current = current2;
});
noop.useRef(Object.create(null));
const create = noop.useCallback((arg0) => {
closure_0 = arg0;
return {
addListener(arg0, arg1) {
closure_0 = arg0;
closure_1 = arg1;
let obj = ref3.current[arg0];
if (!obj) {
obj = {};
}
ref3.current[arg0] = obj;
let items = tmp.current[arg0][closure_0];
if (!items) {
items = [];
}
ref3.current[arg0][closure_0] = items;
ref3.current[arg0][closure_0].push(arg1);
c2 = false;
return () => {
if (!c2) {
c2 = true;
let tmp3;
if (ref.current[closure_0]) {
tmp3 = ref.current[tmp][closure_0];
}
if (tmp3) {
const index = tmp3.indexOf(tmp2);
if (index > -1) {
tmp3.splice(index, 1);
}
}
tmp2 = closure_1;
}
};
},
removeListener(arg0, arg1) {
let tmp;
if (ref.current[arg0]) {
tmp = ref.current[arg0][closure_0];
}
if (tmp) {
const index = tmp.indexOf(arg1);
if (index > -1) {
tmp.splice(index, 1);
}
}
}
};
}, []);
const callback1 = noop.useCallback((arg0) => {
({ type, data, target } = arg0);
c1 = undefined;
c2 = undefined;
let substr = ref3.current[type];
if (undefined === substr) {
const obj = { type: null };
const obj2 = { enumerable: true, value: type };
obj.type = obj2;
if (undefined !== target) {
const obj3 = { enumerable: true, value: target };
obj.target = obj3;
}
if (undefined !== data) {
const obj4 = { enumerable: true, value: data };
obj.data = obj4;
}
c1 = false;
if (tmp) {
const obj5 = {
enumerable: true,
get() {
return c1;
}
};
obj.defaultPrevented = obj5;
const obj6 = {
enumerable: true,
value() {
c1 = true;
}
};
obj.preventDefault = obj6;
}
const _Object2 = Object;
const definePropertiesResult = Object.defineProperties({}, obj);
c2 = definePropertiesResult;
current = ref.current;
if (current != null) {
current(definePropertiesResult);
}
if (undefined != null) {
const item = undefined.forEach((fn) => fn(c2));
}
current2 = ref2.current;
if (current2 != null) {
current2(definePropertiesResult);
}
return definePropertiesResult;
} else if (undefined !== target) {
substr = undefined;
if (substr[target] != null) {
substr = arr5.slice();
}
let found = substr;
} else {
const items = [];
const concat = items.concat;
const _Object = Object;
const keys = Object.keys(substr);
const items1 = [];
HermesBuiltin.arraySpread(keys.map((item) => substr[item]), 0);
found = HermesBuiltin.apply(items1, items).filter((item, index, arr) => arr.lastIndexOf(item) === index);
const applyResult = HermesBuiltin.apply(items1, items);
}
}, []);
let items = [create, callback1];
return noop.useMemo(() => ({ create, emit: callback1 }), items);
};