@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 CHANGED
@@ -768,17 +768,13 @@ var LoginForm = ({
768
768
  const [codeSent, setCodeSent] = (0, import_react2.useState)(false);
769
769
  const [loginError, setLoginError] = (0, import_react2.useState)(null);
770
770
  const googleLogin = async () => {
771
- console.log("Google login clicked");
772
771
  };
773
772
  const githubLogin = async () => {
774
- console.log("GitHub login clicked");
775
773
  };
776
774
  const sendEmailCode = async (email2) => {
777
- console.log("Send code to:", email2, "for app:", appName);
778
775
  setCodeSent(true);
779
776
  };
780
777
  const loginWithEmail = async (email2, code2) => {
781
- console.log("Login with email:", email2, "code:", code2);
782
778
  if (onLoginSuccess) onLoginSuccess();
783
779
  };
784
780
  const clearError = () => {
@@ -1225,11 +1221,9 @@ var ElementSelectorProvider = ({ children }) => {
1225
1221
  type: "ELEMENT_SELECTION_CANCELLED"
1226
1222
  }, "*");
1227
1223
  }
1228
- console.log("\u{1F6AB} \u5143\u7D20\u9009\u62E9\u5DF2\u53D6\u6D88 (ESC)");
1229
1224
  }, []);
1230
1225
  const handleSelect = (0, import_react7.useCallback)((data) => {
1231
1226
  sendElementSelectionToParent(data);
1232
- console.log("\u{1F3AF} \u5143\u7D20\u5DF2\u9009\u4E2D:", data.element.tagName, data.sourceLocation?.file);
1233
1227
  }, []);
1234
1228
  (0, import_react7.useEffect)(() => {
1235
1229
  const handleStartSelection = () => {
@@ -3250,6 +3244,20 @@ var ErrorTracking = class {
3250
3244
  const fileInfo = this.extractFileInfoFromStack(fullStack);
3251
3245
  const serializedArgs = args.map((arg) => DeepSerializer.quickSerialize(arg));
3252
3246
  const message = serializedArgs.map((arg) => typeof arg === "string" ? arg : JSON.stringify(arg, null, 2)).join(" ") + (stack ? "\n" + stack : "");
3247
+ const lowerMessage = message.toLowerCase();
3248
+ const isFromVite = (fileInfo.filename || "").toLowerCase().includes("vite") || lowerMessage.includes("@vite") || lowerMessage.includes("vite") || lowerMessage.includes("hmr");
3249
+ const ignoreVitePatterns = [
3250
+ /\[vite\]\s*hot updated/i,
3251
+ /\[vite\]\s*connected/i,
3252
+ /\[vite\]\s*connecting/i,
3253
+ /\bhot updated\b/i,
3254
+ /\bhmr\b.*\bupdated\b/i
3255
+ ];
3256
+ if (isFromVite && ignoreVitePatterns.some((re) => re.test(lowerMessage))) {
3257
+ return;
3258
+ }
3259
+ const hasErrorKeywords = /\b(error|failed|overlay|compile|exception)\b/.test(lowerMessage);
3260
+ const isViteHMRNonError = isFromVite && !hasErrorKeywords;
3253
3261
  if (method === "error") {
3254
3262
  const globalError = {
3255
3263
  id: `console-error-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
@@ -3266,9 +3274,11 @@ var ErrorTracking = class {
3266
3274
  pagePath: window.location.pathname + window.location.search + window.location.hash,
3267
3275
  interactionTrail: [...window.__AUTO_ENGINEER_INTERACTION_TRAIL__ || []]
3268
3276
  };
3269
- window.__AUTO_ENGINEER_ERRORS__ = window.__AUTO_ENGINEER_ERRORS__ || [];
3270
- window.__AUTO_ENGINEER_ERRORS__.push(globalError);
3271
- this.manageArrayLength(window.__AUTO_ENGINEER_ERRORS__, ERROR_CONFIG.MAX_ERRORS);
3277
+ if (!isViteHMRNonError) {
3278
+ window.__AUTO_ENGINEER_ERRORS__ = window.__AUTO_ENGINEER_ERRORS__ || [];
3279
+ window.__AUTO_ENGINEER_ERRORS__.push(globalError);
3280
+ this.manageArrayLength(window.__AUTO_ENGINEER_ERRORS__, ERROR_CONFIG.MAX_ERRORS);
3281
+ }
3272
3282
  }
3273
3283
  const consoleLevelMap = {
3274
3284
  log: "info",
@@ -3280,7 +3290,7 @@ var ErrorTracking = class {
3280
3290
  this.sendMessage({
3281
3291
  type: "CONSOLE_EVENT",
3282
3292
  payload: {
3283
- type: consoleLevelMap[method] === "info" ? "info" : consoleLevelMap[method] === "warning" ? "warning" : "error",
3293
+ type: consoleLevelMap[method] === "info" ? "info" : consoleLevelMap[method] === "warning" ? "warning" : consoleLevelMap[method] === "debug" ? "debug" : "error",
3284
3294
  message,
3285
3295
  logged_at: (/* @__PURE__ */ new Date()).toISOString(),
3286
3296
  filename: fileInfo.filename,
@@ -3301,15 +3311,44 @@ var ErrorTracking = class {
3301
3311
  * 设置网络监控
3302
3312
  */
3303
3313
  setupNetworkMonitoring() {
3314
+ const self = this;
3304
3315
  const originalFetch = window.fetch;
3305
3316
  window.fetch = async (...args) => {
3306
3317
  const startTime = Date.now();
3307
3318
  try {
3308
3319
  const response = await originalFetch(...args);
3309
- this.logNetworkRequest(args, response, Date.now() - startTime);
3320
+ self.logNetworkRequest(args, response, Date.now() - startTime);
3310
3321
  return response;
3311
3322
  } catch (error) {
3312
- this.logNetworkError(args, error, Date.now() - startTime);
3323
+ const duration = Date.now() - startTime;
3324
+ const message = error && (error.message || String(error));
3325
+ const match = typeof message === "string" ? message.match(/^HTTP\s+(\d+):\s*(.*)$/i) : null;
3326
+ if (match) {
3327
+ const status = Number(match[1]);
3328
+ const statusText = match[2] || "";
3329
+ const stack = new Error().stack;
3330
+ const fileInfo = self.extractFileInfoFromStack(stack);
3331
+ self.sendMessage({
3332
+ type: "NETWORK_EVENT",
3333
+ payload: {
3334
+ type: "request_error",
3335
+ url: args[0],
3336
+ method: args[1]?.method || "GET",
3337
+ status,
3338
+ statusText,
3339
+ filename: fileInfo.filename,
3340
+ lineno: fileInfo.lineno,
3341
+ colno: fileInfo.colno,
3342
+ duration,
3343
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3344
+ pageUrl: window.location.href,
3345
+ interactionTrail: self.getRecentInteractions()
3346
+ },
3347
+ timestamp: Date.now()
3348
+ });
3349
+ } else {
3350
+ self.logNetworkError(args, error, duration);
3351
+ }
3313
3352
  throw error;
3314
3353
  }
3315
3354
  };
@@ -4135,7 +4174,6 @@ var ElementSelector2 = class {
4135
4174
  this.waitForRootElement();
4136
4175
  this.createTooltip();
4137
4176
  this.createStyles();
4138
- console.log("[ElementSelector] \u5143\u7D20\u9009\u62E9\u5668\u521D\u59CB\u5316\u5B8C\u6210");
4139
4177
  }
4140
4178
  /**
4141
4179
  * 等待根元素加载
@@ -4273,7 +4311,6 @@ var ElementSelector2 = class {
4273
4311
  document.body.classList.add("element-selector-active");
4274
4312
  this.setupEventListeners();
4275
4313
  this.manageButtonStates(true);
4276
- console.log("[ElementSelector] \u9009\u62E9\u5668\u5DF2\u542F\u7528");
4277
4314
  this.sendMessage({
4278
4315
  type: "SELECTOR_ENABLED",
4279
4316
  payload: { isActive: true }
@@ -4291,7 +4328,6 @@ var ElementSelector2 = class {
4291
4328
  this.clearSelection();
4292
4329
  this.manageButtonStates(false);
4293
4330
  this.hideTooltip();
4294
- console.log("[ElementSelector] \u9009\u62E9\u5668\u5DF2\u7981\u7528");
4295
4331
  this.sendMessage({
4296
4332
  type: "SELECTOR_DISABLED",
4297
4333
  payload: { isActive: false }
@@ -4965,7 +5001,6 @@ var ElementSelector2 = class {
4965
5001
  this.styleElement.remove();
4966
5002
  this.styleElement = null;
4967
5003
  }
4968
- console.log("[ElementSelector] \u5143\u7D20\u9009\u62E9\u5668\u5DF2\u9500\u6BC1");
4969
5004
  }
4970
5005
  };
4971
5006
 
@@ -5628,7 +5663,6 @@ var ErrorHandler = class {
5628
5663
  enableInteractionTracking: true
5629
5664
  };
5630
5665
  this.config = { ...this.config, ...options };
5631
- console.log("[ErrorHandler] \u5F00\u59CB\u521D\u59CB\u5316\u7EDF\u4E00\u9519\u8BEF\u5904\u7406\u5668...");
5632
5666
  this.messageSender = createDefaultMessageSender({
5633
5667
  addTimestamp: true,
5634
5668
  enableDebugLog: false
@@ -5643,9 +5677,7 @@ var ErrorHandler = class {
5643
5677
  this.componentTreeGenerator = new ComponentTreeGenerator();
5644
5678
  if (this.config.enableViteHMR && ViteHMRDetector.isViteEnvironment()) {
5645
5679
  this.viteHMRDetector = new ViteHMRDetector(sendMessage);
5646
- console.log("[ErrorHandler] Vite HMR \u68C0\u6D4B\u5668\u5DF2\u521D\u59CB\u5316");
5647
5680
  }
5648
- console.log("[ErrorHandler] \u6A21\u5757\u521D\u59CB\u5316\u5B8C\u6210");
5649
5681
  }
5650
5682
  /** ----------------- 主要初始化方法 ----------------- */
5651
5683
  /**
@@ -5657,12 +5689,10 @@ var ErrorHandler = class {
5657
5689
  return;
5658
5690
  }
5659
5691
  try {
5660
- console.log("[ErrorHandler] \u5F00\u59CB\u521D\u59CB\u5316\u5404\u4E2A\u6A21\u5757...");
5661
5692
  this.initializeCore();
5662
5693
  this.setupModuleIntegration();
5663
5694
  this.enableFeatures();
5664
5695
  this.initialized = true;
5665
- console.log("[ErrorHandler] \u521D\u59CB\u5316\u5B8C\u6210");
5666
5696
  } catch (error) {
5667
5697
  console.error("[ErrorHandler] \u521D\u59CB\u5316\u5931\u8D25:", error);
5668
5698
  throw error;
@@ -5675,7 +5705,6 @@ var ErrorHandler = class {
5675
5705
  this.initializeGlobalState();
5676
5706
  this.setupDebugEndpoint();
5677
5707
  this.errorTracking.initialize();
5678
- console.log("[ErrorHandler] \u6838\u5FC3\u529F\u80FD\u521D\u59CB\u5316\u5B8C\u6210");
5679
5708
  }
5680
5709
  /**
5681
5710
  * 初始化全局状态
@@ -5687,7 +5716,6 @@ var ErrorHandler = class {
5687
5716
  if (!window.__AUTO_ENGINEER_INTERACTION_TRAIL__) {
5688
5717
  window.__AUTO_ENGINEER_INTERACTION_TRAIL__ = [];
5689
5718
  }
5690
- console.log("[ErrorHandler] \u5168\u5C40\u72B6\u6001\u521D\u59CB\u5316\u5B8C\u6210");
5691
5719
  }
5692
5720
  /**
5693
5721
  * 设置调试端点
@@ -5711,24 +5739,19 @@ var ErrorHandler = class {
5711
5739
  this.messageBridge.setComponentTreeGenerator(this.componentTreeGenerator);
5712
5740
  this.errorTracking.setViewDetector(this.viewDetector);
5713
5741
  this.errorTracking.setInteractionTracking(this.interactionTracking);
5714
- console.log("[ErrorHandler] \u6A21\u5757\u96C6\u6210\u8BBE\u7F6E\u5B8C\u6210");
5715
5742
  }
5716
5743
  /**
5717
5744
  * 启用功能模块
5718
5745
  */
5719
5746
  enableFeatures() {
5720
- console.log("[ErrorHandler] \u542F\u7528\u529F\u80FD\u6A21\u5757...");
5721
5747
  if (this.config.enableInteractionTracking) {
5722
5748
  this.interactionTracking.startTracking();
5723
- console.log("[ErrorHandler] \u4EA4\u4E92\u8FFD\u8E2A\u5DF2\u542F\u7528");
5724
5749
  }
5725
5750
  if (this.viteHMRDetector) {
5726
5751
  this.viteHMRDetector.initialize();
5727
- console.log("[ErrorHandler] Vite HMR \u68C0\u6D4B\u5668\u5DF2\u542F\u7528");
5728
5752
  }
5729
5753
  this.handleHardRefreshLogic();
5730
5754
  this.setupViewDetection();
5731
- console.log("[ErrorHandler] \u529F\u80FD\u6A21\u5757\u542F\u7528\u5B8C\u6210");
5732
5755
  }
5733
5756
  /**
5734
5757
  * 处理硬刷新逻辑
@@ -5737,7 +5760,6 @@ var ErrorHandler = class {
5737
5760
  HardRefreshManager.cleanupRefreshParams();
5738
5761
  const refreshStats = HardRefreshManager.getRefreshStats();
5739
5762
  if (refreshStats.isHardRefresh) {
5740
- console.log("[ErrorHandler] \u68C0\u6D4B\u5230\u786C\u5237\u65B0:", refreshStats);
5741
5763
  this.messageSender.send({
5742
5764
  type: "SYSTEM_EVENT",
5743
5765
  payload: {
@@ -5758,7 +5780,6 @@ var ErrorHandler = class {
5758
5780
  const currentView = this.viewDetector.getCurrentViewInfo();
5759
5781
  if (currentView.title !== lastViewTitle) {
5760
5782
  lastViewTitle = currentView.title;
5761
- console.log("[ErrorHandler] \u89C6\u56FE\u53D8\u5316:", currentView);
5762
5783
  }
5763
5784
  };
5764
5785
  setInterval(checkViewChange, 1e3);
@@ -5853,7 +5874,6 @@ var ErrorHandler = class {
5853
5874
  */
5854
5875
  updateConfig(newConfig) {
5855
5876
  this.config = { ...this.config, ...newConfig };
5856
- console.log("[ErrorHandler] \u914D\u7F6E\u5DF2\u66F4\u65B0:", this.config);
5857
5877
  }
5858
5878
  /**
5859
5879
  * 销毁错误处理器
@@ -5872,7 +5892,6 @@ var ErrorHandler = class {
5872
5892
  this.viewDetector.clearCache();
5873
5893
  }
5874
5894
  this.initialized = false;
5875
- console.log("[ErrorHandler] \u5DF2\u9500\u6BC1");
5876
5895
  } catch (error) {
5877
5896
  const originalConsole = getOriginalConsole3();
5878
5897
  originalConsole.error("[ErrorHandler] \u9500\u6BC1\u65F6\u53D1\u751F\u9519\u8BEF:", error);
@@ -5918,7 +5937,6 @@ var import_jsx_runtime7 = require("react/jsx-runtime");
5918
5937
  var globalErrorHandler = null;
5919
5938
  var initializeErrorHandler = () => {
5920
5939
  if (!globalErrorHandler) {
5921
- console.log("[HowOneProvider] \u5728\u6A21\u5757\u9876\u5C42\u521D\u59CB\u5316\u9519\u8BEF\u5904\u7406\u5668...");
5922
5940
  globalErrorHandler = new ErrorHandler({
5923
5941
  enableViteHMR: true,
5924
5942
  enableElementSelector: true,
@@ -5926,7 +5944,6 @@ var initializeErrorHandler = () => {
5926
5944
  });
5927
5945
  globalErrorHandler.init();
5928
5946
  window.__ERROR_HANDLER__ = globalErrorHandler;
5929
- console.log("[HowOneProvider] \u9519\u8BEF\u5904\u7406\u5668\u5DF2\u5728\u6A21\u5757\u9876\u5C42\u521D\u59CB\u5316\u5B8C\u6210");
5930
5947
  }
5931
5948
  return globalErrorHandler;
5932
5949
  };
@@ -5954,7 +5971,6 @@ var HowOneProvider = ({
5954
5971
  urlToken = hashParams.get("access_token") || hashParams.get("token");
5955
5972
  }
5956
5973
  if (urlToken) {
5957
- console.log("[HowOneProvider] Token captured from URL, storing to localStorage...");
5958
5974
  setToken(urlToken);
5959
5975
  setTokenState(urlToken);
5960
5976
  setUser(parseUserFromToken(urlToken));
@@ -5964,7 +5980,6 @@ var HowOneProvider = ({
5964
5980
  const newSearch = params.toString();
5965
5981
  const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "");
5966
5982
  window.history.replaceState({}, "", newUrl);
5967
- console.log("[HowOneProvider] Token stored successfully, URL cleaned");
5968
5983
  }
5969
5984
  } catch (e) {
5970
5985
  console.error("[HowOneProvider] Failed to capture token from URL:", e);
@@ -5979,7 +5994,6 @@ var HowOneProvider = ({
5979
5994
  if (redirectOnUnauthenticated && !token && !user) {
5980
5995
  const currentUrl = new URL(window.location.href);
5981
5996
  if (!currentUrl.pathname.includes("/auth")) {
5982
- console.log("[HowOneProvider] No token found, redirecting to auth page...");
5983
5997
  try {
5984
5998
  const authUrlObj = new URL(authUrl);
5985
5999
  const redirectUri = window.location.href;
@@ -5987,7 +6001,6 @@ var HowOneProvider = ({
5987
6001
  if (projectId) {
5988
6002
  authUrlObj.searchParams.set("project_id", projectId);
5989
6003
  }
5990
- console.log("[HowOneProvider] Redirecting to:", authUrlObj.toString());
5991
6004
  window.location.href = authUrlObj.toString();
5992
6005
  } catch (error) {
5993
6006
  console.error("[HowOneProvider] Failed to build auth URL:", error);
@@ -7267,7 +7280,6 @@ var SimpleErrorHandler = class {
7267
7280
  this.setupErrorListeners();
7268
7281
  this.setupCompatibility();
7269
7282
  this.initialized = true;
7270
- console.log("[\u7B80\u5316\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
7271
7283
  }
7272
7284
  /**
7273
7285
  * 设置错误监听器