Lines 2855-2895javascript
2855async function withTimeout(p, ms, what) {
2858 return await Promise.race([
2860 new Promise((_, reject) => {
2861 timer = setTimeout(() => reject(new Error(`${what} timed out after ${ms}ms`)), ms);
2865 if (timer) clearTimeout(timer);
2868function resolveAuthenticationKey(entry, token) {
2869 return entry.AUTHENTICATION_KEY ?? token ?? "";
2871async function pluginTransportWithKind(providerId, token, context) {
2872 const { path: pluginPath, kind } = resolvePluginOnDiskWithKind(providerId);
2873 const sideLabel = kind === "user" ? "user plugin" : kind === "builtin" ? "built-in plugin" : "plugin";
2876 module = await import(pathToFileURL(pluginPath).href);
2877 } catch (error) {
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/index.jsView on unpkg · L2875 2878 const message = `${sideLabel} ${pluginPath}: ${error.message ?? String(error)}`;
2879 append("warning", "fetch", message, Date.now());
2880 throw new Error(message);
2882 const plugin = module.default;
2883 if (!plugin || typeof plugin !== "object" || typeof plugin.fetchAccountCredit !== "function") {
2884 const message = `${sideLabel} ${pluginPath}: default export must be { fetchAccountCredit(authenticationKey, context?) }`;
2885 append("warning", "fetch", message, Date.now());
2886 throw new Error(message);
2889 const result = await withTimeout(
2890 Promise.resolve(plugin.fetchAccountCredit(token, context)),
2892 `${sideLabel} ${pluginPath} fetchAccountCredit`
2894 return { result, kind };