EroticDungeonGame/node_modules/@commitlint/load/lib/utils/load-parser-opts.js
3944Realms 8c4ce2709c fix(兼容emotescraft和rideeverything): 修改骑乘逻辑和tick取消EmtoesCraft表情
使用Mixin中检测绕过骑乘取消和开始骑乘逻辑,避免原版的unRide方法导致非预期的退出设备;在每tick检测,如果在设备上则停止表情动画
2026-02-20 14:45:57 +08:00

56 lines
2.0 KiB
JavaScript

function isObjectLike(obj) {
return Boolean(obj) && typeof obj === "object"; // typeof null === 'object'
}
function isParserOptsFunction(obj) {
return typeof obj.parserOpts === "function";
}
export async function loadParserOpts(pendingParser) {
if (typeof pendingParser === "function") {
return loadParserOpts(pendingParser());
}
if (!pendingParser || typeof pendingParser !== "object") {
return undefined;
}
// Await for the module, loaded with require
const parser = await pendingParser;
// exit early, no opts to resolve
if (!parser.parserOpts) {
return parser;
}
// Pull nested parserOpts, might happen if overwritten with a module in main config
if (typeof parser.parserOpts === "object") {
// Await parser opts if applicable
parser.parserOpts = await parser.parserOpts;
if (isObjectLike(parser.parserOpts) &&
isObjectLike(parser.parserOpts.parserOpts)) {
parser.parserOpts = parser.parserOpts.parserOpts;
}
return parser;
}
// Create parser opts from factory
if (isParserOptsFunction(parser) &&
typeof parser.name === "string" &&
parser.name.startsWith("conventional-changelog-")) {
return new Promise((resolve) => {
const result = parser.parserOpts((_, opts) => {
resolve({
...parser,
parserOpts: opts?.parserOpts,
});
});
// If result has data or a promise, the parser doesn't support factory-init
// due to https://github.com/nodejs/promises-debugging/issues/16 it just quits, so let's use this fallback
if (result) {
Promise.resolve(result).then((opts) => {
resolve({
...parser,
parserOpts: opts?.parserOpts || opts?.parser,
});
});
}
return;
});
}
return parser;
}
//# sourceMappingURL=load-parser-opts.js.map