decord/source/utils/ContextUtils.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-08-27 16:17:25 +00:00
// Module ID: 7107
// Function ID: 7108
2026-07-20 16:05:17 +00:00
// Name: createDefinedContext
2026-07-29 08:29:29 +00:00
// Dependencies: [19, 21, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-08-27 16:17:25 +00:00
// Module 7107 (createDefinedContext)
2026-08-24 06:08:38 +00:00
import closure_0 from "noop" /* 19 */;
import { jsx } from "jsxProd" /* 21 */;
2026-07-23 10:11:24 +00:00
const result = require("set").fileFinishedImporting("utils/ContextUtils.tsx");
2026-07-20 16:05:17 +00:00
export default function createDefinedContext() {
2026-07-23 10:11:24 +00:00
context = context.createContext(undefined);
2026-07-20 16:05:17 +00:00
const items = [
context,
2026-07-29 08:29:29 +00:00
function useContext(context) {
context = context.useContext(context);
if (null == context) {
const _Error = Error;
2026-08-24 06:08:38 +00:00
error = new Error("Context was used outside of defined provider.");
2026-07-29 08:29:29 +00:00
throw error;
} else {
return context;
}
},
2026-07-20 16:05:17 +00:00
() => {
2026-07-29 08:29:29 +00:00
context = context.useContext(context);
if (null == context) {
const _Error = Error;
2026-08-24 06:08:38 +00:00
error = new Error("Context was used outside of defined provider.");
2026-07-29 08:29:29 +00:00
throw error;
} else {
2026-08-24 06:08:38 +00:00
return (children) => closure_2_1(context.Provider, { value: context, children: children.children });
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
}
];
return items;
};