@howone/sdk 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -697,17 +697,13 @@ var LoginForm = ({
|
|
|
697
697
|
const [codeSent, setCodeSent] = useState2(false);
|
|
698
698
|
const [loginError, setLoginError] = useState2(null);
|
|
699
699
|
const googleLogin = async () => {
|
|
700
|
-
console.log("Google login clicked");
|
|
701
700
|
};
|
|
702
701
|
const githubLogin = async () => {
|
|
703
|
-
console.log("GitHub login clicked");
|
|
704
702
|
};
|
|
705
703
|
const sendEmailCode = async (email2) => {
|
|
706
|
-
console.log("Send code to:", email2, "for app:", appName);
|
|
707
704
|
setCodeSent(true);
|
|
708
705
|
};
|
|
709
706
|
const loginWithEmail = async (email2, code2) => {
|
|
710
|
-
console.log("Login with email:", email2, "code:", code2);
|
|
711
707
|
if (onLoginSuccess) onLoginSuccess();
|
|
712
708
|
};
|
|
713
709
|
const clearError = () => {
|
|
@@ -1154,11 +1150,9 @@ var ElementSelectorProvider = ({ children }) => {
|
|
|
1154
1150
|
type: "ELEMENT_SELECTION_CANCELLED"
|
|
1155
1151
|
}, "*");
|
|
1156
1152
|
}
|
|
1157
|
-
console.log("\u{1F6AB} \u5143\u7D20\u9009\u62E9\u5DF2\u53D6\u6D88 (ESC)");
|
|
1158
1153
|
}, []);
|
|
1159
1154
|
const handleSelect = useCallback3((data) => {
|
|
1160
1155
|
sendElementSelectionToParent(data);
|
|
1161
|
-
console.log("\u{1F3AF} \u5143\u7D20\u5DF2\u9009\u4E2D:", data.element.tagName, data.sourceLocation?.file);
|
|
1162
1156
|
}, []);
|
|
1163
1157
|
useEffect5(() => {
|
|
1164
1158
|
const handleStartSelection = () => {
|
|
@@ -3179,6 +3173,20 @@ var ErrorTracking = class {
|
|
|
3179
3173
|
const fileInfo = this.extractFileInfoFromStack(fullStack);
|
|
3180
3174
|
const serializedArgs = args.map((arg) => DeepSerializer.quickSerialize(arg));
|
|
3181
3175
|
const message = serializedArgs.map((arg) => typeof arg === "string" ? arg : JSON.stringify(arg, null, 2)).join(" ") + (stack ? "\n" + stack : "");
|
|
3176
|
+
const lowerMessage = message.toLowerCase();
|
|
3177
|
+
const isFromVite = (fileInfo.filename || "").toLowerCase().includes("vite") || lowerMessage.includes("@vite") || lowerMessage.includes("vite") || lowerMessage.includes("hmr");
|
|
3178
|
+
const ignoreVitePatterns = [
|
|
3179
|
+
/\[vite\]\s*hot updated/i,
|
|
3180
|
+
/\[vite\]\s*connected/i,
|
|
3181
|
+
/\[vite\]\s*connecting/i,
|
|
3182
|
+
/\bhot updated\b/i,
|
|
3183
|
+
/\bhmr\b.*\bupdated\b/i
|
|
3184
|
+
];
|
|
3185
|
+
if (isFromVite && ignoreVitePatterns.some((re) => re.test(lowerMessage))) {
|
|
3186
|
+
return;
|
|
3187
|
+
}
|
|
3188
|
+
const hasErrorKeywords = /\b(error|failed|overlay|compile|exception)\b/.test(lowerMessage);
|
|
3189
|
+
const isViteHMRNonError = isFromVite && !hasErrorKeywords;
|
|
3182
3190
|
if (method === "error") {
|
|
3183
3191
|
const globalError = {
|
|
3184
3192
|
id: `console-error-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
@@ -3195,9 +3203,11 @@ var ErrorTracking = class {
|
|
|
3195
3203
|
pagePath: window.location.pathname + window.location.search + window.location.hash,
|
|
3196
3204
|
interactionTrail: [...window.__AUTO_ENGINEER_INTERACTION_TRAIL__ || []]
|
|
3197
3205
|
};
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3206
|
+
if (!isViteHMRNonError) {
|
|
3207
|
+
window.__AUTO_ENGINEER_ERRORS__ = window.__AUTO_ENGINEER_ERRORS__ || [];
|
|
3208
|
+
window.__AUTO_ENGINEER_ERRORS__.push(globalError);
|
|
3209
|
+
this.manageArrayLength(window.__AUTO_ENGINEER_ERRORS__, ERROR_CONFIG.MAX_ERRORS);
|
|
3210
|
+
}
|
|
3201
3211
|
}
|
|
3202
3212
|
const consoleLevelMap = {
|
|
3203
3213
|
log: "info",
|
|
@@ -3209,7 +3219,7 @@ var ErrorTracking = class {
|
|
|
3209
3219
|
this.sendMessage({
|
|
3210
3220
|
type: "CONSOLE_EVENT",
|
|
3211
3221
|
payload: {
|
|
3212
|
-
type: consoleLevelMap[method] === "info" ? "info" : consoleLevelMap[method] === "warning" ? "warning" : "error",
|
|
3222
|
+
type: consoleLevelMap[method] === "info" ? "info" : consoleLevelMap[method] === "warning" ? "warning" : consoleLevelMap[method] === "debug" ? "debug" : "error",
|
|
3213
3223
|
message,
|
|
3214
3224
|
logged_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3215
3225
|
filename: fileInfo.filename,
|
|
@@ -3230,15 +3240,44 @@ var ErrorTracking = class {
|
|
|
3230
3240
|
* 设置网络监控
|
|
3231
3241
|
*/
|
|
3232
3242
|
setupNetworkMonitoring() {
|
|
3243
|
+
const self = this;
|
|
3233
3244
|
const originalFetch = window.fetch;
|
|
3234
3245
|
window.fetch = async (...args) => {
|
|
3235
3246
|
const startTime = Date.now();
|
|
3236
3247
|
try {
|
|
3237
3248
|
const response = await originalFetch(...args);
|
|
3238
|
-
|
|
3249
|
+
self.logNetworkRequest(args, response, Date.now() - startTime);
|
|
3239
3250
|
return response;
|
|
3240
3251
|
} catch (error) {
|
|
3241
|
-
|
|
3252
|
+
const duration = Date.now() - startTime;
|
|
3253
|
+
const message = error && (error.message || String(error));
|
|
3254
|
+
const match = typeof message === "string" ? message.match(/^HTTP\s+(\d+):\s*(.*)$/i) : null;
|
|
3255
|
+
if (match) {
|
|
3256
|
+
const status = Number(match[1]);
|
|
3257
|
+
const statusText = match[2] || "";
|
|
3258
|
+
const stack = new Error().stack;
|
|
3259
|
+
const fileInfo = self.extractFileInfoFromStack(stack);
|
|
3260
|
+
self.sendMessage({
|
|
3261
|
+
type: "NETWORK_EVENT",
|
|
3262
|
+
payload: {
|
|
3263
|
+
type: "request_error",
|
|
3264
|
+
url: args[0],
|
|
3265
|
+
method: args[1]?.method || "GET",
|
|
3266
|
+
status,
|
|
3267
|
+
statusText,
|
|
3268
|
+
filename: fileInfo.filename,
|
|
3269
|
+
lineno: fileInfo.lineno,
|
|
3270
|
+
colno: fileInfo.colno,
|
|
3271
|
+
duration,
|
|
3272
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3273
|
+
pageUrl: window.location.href,
|
|
3274
|
+
interactionTrail: self.getRecentInteractions()
|
|
3275
|
+
},
|
|
3276
|
+
timestamp: Date.now()
|
|
3277
|
+
});
|
|
3278
|
+
} else {
|
|
3279
|
+
self.logNetworkError(args, error, duration);
|
|
3280
|
+
}
|
|
3242
3281
|
throw error;
|
|
3243
3282
|
}
|
|
3244
3283
|
};
|
|
@@ -4064,7 +4103,6 @@ var ElementSelector2 = class {
|
|
|
4064
4103
|
this.waitForRootElement();
|
|
4065
4104
|
this.createTooltip();
|
|
4066
4105
|
this.createStyles();
|
|
4067
|
-
console.log("[ElementSelector] \u5143\u7D20\u9009\u62E9\u5668\u521D\u59CB\u5316\u5B8C\u6210");
|
|
4068
4106
|
}
|
|
4069
4107
|
/**
|
|
4070
4108
|
* 等待根元素加载
|
|
@@ -4202,7 +4240,6 @@ var ElementSelector2 = class {
|
|
|
4202
4240
|
document.body.classList.add("element-selector-active");
|
|
4203
4241
|
this.setupEventListeners();
|
|
4204
4242
|
this.manageButtonStates(true);
|
|
4205
|
-
console.log("[ElementSelector] \u9009\u62E9\u5668\u5DF2\u542F\u7528");
|
|
4206
4243
|
this.sendMessage({
|
|
4207
4244
|
type: "SELECTOR_ENABLED",
|
|
4208
4245
|
payload: { isActive: true }
|
|
@@ -4220,7 +4257,6 @@ var ElementSelector2 = class {
|
|
|
4220
4257
|
this.clearSelection();
|
|
4221
4258
|
this.manageButtonStates(false);
|
|
4222
4259
|
this.hideTooltip();
|
|
4223
|
-
console.log("[ElementSelector] \u9009\u62E9\u5668\u5DF2\u7981\u7528");
|
|
4224
4260
|
this.sendMessage({
|
|
4225
4261
|
type: "SELECTOR_DISABLED",
|
|
4226
4262
|
payload: { isActive: false }
|
|
@@ -4894,7 +4930,6 @@ var ElementSelector2 = class {
|
|
|
4894
4930
|
this.styleElement.remove();
|
|
4895
4931
|
this.styleElement = null;
|
|
4896
4932
|
}
|
|
4897
|
-
console.log("[ElementSelector] \u5143\u7D20\u9009\u62E9\u5668\u5DF2\u9500\u6BC1");
|
|
4898
4933
|
}
|
|
4899
4934
|
};
|
|
4900
4935
|
|
|
@@ -5557,7 +5592,6 @@ var ErrorHandler = class {
|
|
|
5557
5592
|
enableInteractionTracking: true
|
|
5558
5593
|
};
|
|
5559
5594
|
this.config = { ...this.config, ...options };
|
|
5560
|
-
console.log("[ErrorHandler] \u5F00\u59CB\u521D\u59CB\u5316\u7EDF\u4E00\u9519\u8BEF\u5904\u7406\u5668...");
|
|
5561
5595
|
this.messageSender = createDefaultMessageSender({
|
|
5562
5596
|
addTimestamp: true,
|
|
5563
5597
|
enableDebugLog: false
|
|
@@ -5572,9 +5606,7 @@ var ErrorHandler = class {
|
|
|
5572
5606
|
this.componentTreeGenerator = new ComponentTreeGenerator();
|
|
5573
5607
|
if (this.config.enableViteHMR && ViteHMRDetector.isViteEnvironment()) {
|
|
5574
5608
|
this.viteHMRDetector = new ViteHMRDetector(sendMessage);
|
|
5575
|
-
console.log("[ErrorHandler] Vite HMR \u68C0\u6D4B\u5668\u5DF2\u521D\u59CB\u5316");
|
|
5576
5609
|
}
|
|
5577
|
-
console.log("[ErrorHandler] \u6A21\u5757\u521D\u59CB\u5316\u5B8C\u6210");
|
|
5578
5610
|
}
|
|
5579
5611
|
/** ----------------- 主要初始化方法 ----------------- */
|
|
5580
5612
|
/**
|
|
@@ -5586,12 +5618,10 @@ var ErrorHandler = class {
|
|
|
5586
5618
|
return;
|
|
5587
5619
|
}
|
|
5588
5620
|
try {
|
|
5589
|
-
console.log("[ErrorHandler] \u5F00\u59CB\u521D\u59CB\u5316\u5404\u4E2A\u6A21\u5757...");
|
|
5590
5621
|
this.initializeCore();
|
|
5591
5622
|
this.setupModuleIntegration();
|
|
5592
5623
|
this.enableFeatures();
|
|
5593
5624
|
this.initialized = true;
|
|
5594
|
-
console.log("[ErrorHandler] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
5595
5625
|
} catch (error) {
|
|
5596
5626
|
console.error("[ErrorHandler] \u521D\u59CB\u5316\u5931\u8D25:", error);
|
|
5597
5627
|
throw error;
|
|
@@ -5604,7 +5634,6 @@ var ErrorHandler = class {
|
|
|
5604
5634
|
this.initializeGlobalState();
|
|
5605
5635
|
this.setupDebugEndpoint();
|
|
5606
5636
|
this.errorTracking.initialize();
|
|
5607
|
-
console.log("[ErrorHandler] \u6838\u5FC3\u529F\u80FD\u521D\u59CB\u5316\u5B8C\u6210");
|
|
5608
5637
|
}
|
|
5609
5638
|
/**
|
|
5610
5639
|
* 初始化全局状态
|
|
@@ -5616,7 +5645,6 @@ var ErrorHandler = class {
|
|
|
5616
5645
|
if (!window.__AUTO_ENGINEER_INTERACTION_TRAIL__) {
|
|
5617
5646
|
window.__AUTO_ENGINEER_INTERACTION_TRAIL__ = [];
|
|
5618
5647
|
}
|
|
5619
|
-
console.log("[ErrorHandler] \u5168\u5C40\u72B6\u6001\u521D\u59CB\u5316\u5B8C\u6210");
|
|
5620
5648
|
}
|
|
5621
5649
|
/**
|
|
5622
5650
|
* 设置调试端点
|
|
@@ -5640,24 +5668,19 @@ var ErrorHandler = class {
|
|
|
5640
5668
|
this.messageBridge.setComponentTreeGenerator(this.componentTreeGenerator);
|
|
5641
5669
|
this.errorTracking.setViewDetector(this.viewDetector);
|
|
5642
5670
|
this.errorTracking.setInteractionTracking(this.interactionTracking);
|
|
5643
|
-
console.log("[ErrorHandler] \u6A21\u5757\u96C6\u6210\u8BBE\u7F6E\u5B8C\u6210");
|
|
5644
5671
|
}
|
|
5645
5672
|
/**
|
|
5646
5673
|
* 启用功能模块
|
|
5647
5674
|
*/
|
|
5648
5675
|
enableFeatures() {
|
|
5649
|
-
console.log("[ErrorHandler] \u542F\u7528\u529F\u80FD\u6A21\u5757...");
|
|
5650
5676
|
if (this.config.enableInteractionTracking) {
|
|
5651
5677
|
this.interactionTracking.startTracking();
|
|
5652
|
-
console.log("[ErrorHandler] \u4EA4\u4E92\u8FFD\u8E2A\u5DF2\u542F\u7528");
|
|
5653
5678
|
}
|
|
5654
5679
|
if (this.viteHMRDetector) {
|
|
5655
5680
|
this.viteHMRDetector.initialize();
|
|
5656
|
-
console.log("[ErrorHandler] Vite HMR \u68C0\u6D4B\u5668\u5DF2\u542F\u7528");
|
|
5657
5681
|
}
|
|
5658
5682
|
this.handleHardRefreshLogic();
|
|
5659
5683
|
this.setupViewDetection();
|
|
5660
|
-
console.log("[ErrorHandler] \u529F\u80FD\u6A21\u5757\u542F\u7528\u5B8C\u6210");
|
|
5661
5684
|
}
|
|
5662
5685
|
/**
|
|
5663
5686
|
* 处理硬刷新逻辑
|
|
@@ -5666,7 +5689,6 @@ var ErrorHandler = class {
|
|
|
5666
5689
|
HardRefreshManager.cleanupRefreshParams();
|
|
5667
5690
|
const refreshStats = HardRefreshManager.getRefreshStats();
|
|
5668
5691
|
if (refreshStats.isHardRefresh) {
|
|
5669
|
-
console.log("[ErrorHandler] \u68C0\u6D4B\u5230\u786C\u5237\u65B0:", refreshStats);
|
|
5670
5692
|
this.messageSender.send({
|
|
5671
5693
|
type: "SYSTEM_EVENT",
|
|
5672
5694
|
payload: {
|
|
@@ -5687,7 +5709,6 @@ var ErrorHandler = class {
|
|
|
5687
5709
|
const currentView = this.viewDetector.getCurrentViewInfo();
|
|
5688
5710
|
if (currentView.title !== lastViewTitle) {
|
|
5689
5711
|
lastViewTitle = currentView.title;
|
|
5690
|
-
console.log("[ErrorHandler] \u89C6\u56FE\u53D8\u5316:", currentView);
|
|
5691
5712
|
}
|
|
5692
5713
|
};
|
|
5693
5714
|
setInterval(checkViewChange, 1e3);
|
|
@@ -5782,7 +5803,6 @@ var ErrorHandler = class {
|
|
|
5782
5803
|
*/
|
|
5783
5804
|
updateConfig(newConfig) {
|
|
5784
5805
|
this.config = { ...this.config, ...newConfig };
|
|
5785
|
-
console.log("[ErrorHandler] \u914D\u7F6E\u5DF2\u66F4\u65B0:", this.config);
|
|
5786
5806
|
}
|
|
5787
5807
|
/**
|
|
5788
5808
|
* 销毁错误处理器
|
|
@@ -5801,7 +5821,6 @@ var ErrorHandler = class {
|
|
|
5801
5821
|
this.viewDetector.clearCache();
|
|
5802
5822
|
}
|
|
5803
5823
|
this.initialized = false;
|
|
5804
|
-
console.log("[ErrorHandler] \u5DF2\u9500\u6BC1");
|
|
5805
5824
|
} catch (error) {
|
|
5806
5825
|
const originalConsole = getOriginalConsole3();
|
|
5807
5826
|
originalConsole.error("[ErrorHandler] \u9500\u6BC1\u65F6\u53D1\u751F\u9519\u8BEF:", error);
|
|
@@ -5847,7 +5866,6 @@ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
|
5847
5866
|
var globalErrorHandler = null;
|
|
5848
5867
|
var initializeErrorHandler = () => {
|
|
5849
5868
|
if (!globalErrorHandler) {
|
|
5850
|
-
console.log("[HowOneProvider] \u5728\u6A21\u5757\u9876\u5C42\u521D\u59CB\u5316\u9519\u8BEF\u5904\u7406\u5668...");
|
|
5851
5869
|
globalErrorHandler = new ErrorHandler({
|
|
5852
5870
|
enableViteHMR: true,
|
|
5853
5871
|
enableElementSelector: true,
|
|
@@ -5855,7 +5873,6 @@ var initializeErrorHandler = () => {
|
|
|
5855
5873
|
});
|
|
5856
5874
|
globalErrorHandler.init();
|
|
5857
5875
|
window.__ERROR_HANDLER__ = globalErrorHandler;
|
|
5858
|
-
console.log("[HowOneProvider] \u9519\u8BEF\u5904\u7406\u5668\u5DF2\u5728\u6A21\u5757\u9876\u5C42\u521D\u59CB\u5316\u5B8C\u6210");
|
|
5859
5876
|
}
|
|
5860
5877
|
return globalErrorHandler;
|
|
5861
5878
|
};
|
|
@@ -5883,7 +5900,6 @@ var HowOneProvider = ({
|
|
|
5883
5900
|
urlToken = hashParams.get("access_token") || hashParams.get("token");
|
|
5884
5901
|
}
|
|
5885
5902
|
if (urlToken) {
|
|
5886
|
-
console.log("[HowOneProvider] Token captured from URL, storing to localStorage...");
|
|
5887
5903
|
setToken(urlToken);
|
|
5888
5904
|
setTokenState(urlToken);
|
|
5889
5905
|
setUser(parseUserFromToken(urlToken));
|
|
@@ -5893,7 +5909,6 @@ var HowOneProvider = ({
|
|
|
5893
5909
|
const newSearch = params.toString();
|
|
5894
5910
|
const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "");
|
|
5895
5911
|
window.history.replaceState({}, "", newUrl);
|
|
5896
|
-
console.log("[HowOneProvider] Token stored successfully, URL cleaned");
|
|
5897
5912
|
}
|
|
5898
5913
|
} catch (e) {
|
|
5899
5914
|
console.error("[HowOneProvider] Failed to capture token from URL:", e);
|
|
@@ -5908,7 +5923,6 @@ var HowOneProvider = ({
|
|
|
5908
5923
|
if (redirectOnUnauthenticated && !token && !user) {
|
|
5909
5924
|
const currentUrl = new URL(window.location.href);
|
|
5910
5925
|
if (!currentUrl.pathname.includes("/auth")) {
|
|
5911
|
-
console.log("[HowOneProvider] No token found, redirecting to auth page...");
|
|
5912
5926
|
try {
|
|
5913
5927
|
const authUrlObj = new URL(authUrl);
|
|
5914
5928
|
const redirectUri = window.location.href;
|
|
@@ -5916,7 +5930,6 @@ var HowOneProvider = ({
|
|
|
5916
5930
|
if (projectId) {
|
|
5917
5931
|
authUrlObj.searchParams.set("project_id", projectId);
|
|
5918
5932
|
}
|
|
5919
|
-
console.log("[HowOneProvider] Redirecting to:", authUrlObj.toString());
|
|
5920
5933
|
window.location.href = authUrlObj.toString();
|
|
5921
5934
|
} catch (error) {
|
|
5922
5935
|
console.error("[HowOneProvider] Failed to build auth URL:", error);
|
|
@@ -7196,7 +7209,6 @@ var SimpleErrorHandler = class {
|
|
|
7196
7209
|
this.setupErrorListeners();
|
|
7197
7210
|
this.setupCompatibility();
|
|
7198
7211
|
this.initialized = true;
|
|
7199
|
-
console.log("[\u7B80\u5316\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
7200
7212
|
}
|
|
7201
7213
|
/**
|
|
7202
7214
|
* 设置错误监听器
|