Files
FlowPilot/content/activation-utils.js
T
QLHazyCoder c745405f90 feat: Enhance Step 9 diagnostics and error handling
- Refactor getStatusBadgeEntries to use createStep9Entry for better encapsulation.
- Introduce error visual signals detection in createStep9Entry.
- Add functions to identify OAuth callback timeout failures and step 9 failure texts.
- Update buildStep9StatusDiagnostics to include error visual summaries and handle conflicts between success and failure states.
- Implement new tests for step 9 diagnostics, ensuring correct behavior with success badges and error banners.
- Remove outdated tests related to step 5 onboarding and redirect race conditions.
- Add new tests for auto-run behavior in step 6 restart scenarios.
2026-04-17 04:33:14 +08:00

58 lines
1.6 KiB
JavaScript

(function activationUtilsModule(root, factory) {
if (typeof module !== 'undefined' && module.exports) {
module.exports = factory();
return;
}
root.MultiPageActivationUtils = factory();
})(typeof self !== 'undefined' ? self : globalThis, function createActivationUtils() {
function normalizeTagName(tagName) {
return String(tagName || '').trim().toLowerCase();
}
function normalizeType(type) {
return String(type || '').trim().toLowerCase();
}
function normalizePathname(pathname) {
return String(pathname || '').trim().toLowerCase();
}
function getActivationStrategy(target = {}) {
const tagName = normalizeTagName(target.tagName);
const type = normalizeType(target.type);
const pathname = normalizePathname(target.pathname);
const hasForm = Boolean(target.hasForm);
const isEmailVerificationRoute = /\/email-verification(?:[/?#]|$)/i.test(pathname);
const isSubmitButton = hasForm
&& (
(tagName === 'button' && (!type || type === 'submit'))
|| (tagName === 'input' && type === 'submit')
);
if (isSubmitButton && isEmailVerificationRoute) {
return { method: 'requestSubmit' };
}
return { method: 'click' };
}
function isRecoverableStep9AuthFailure(statusText) {
const text = String(statusText || '').replace(/\s+/g, ' ').trim();
if (!text) {
return false;
}
if (/oauth flow is not pending/i.test(text)) {
return true;
}
return /(?:认证失败|回调 URL 提交失败):\s*/i.test(text);
}
return {
getActivationStrategy,
isRecoverableStep9AuthFailure,
};
});