@howone/sdk 0.2.1 → 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.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1697 -1604
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1697 -1604
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 = () => {
|
|
@@ -1281,14 +1275,12 @@ var ERROR_CONFIG = {
|
|
|
1281
1275
|
LOW: ["info", "debug", "trace", "notice"]
|
|
1282
1276
|
},
|
|
1283
1277
|
CATEGORY_KEYWORDS: {
|
|
1284
|
-
SYNTAX: ["syntaxerror", "unexpected token", "parse error", "invalid syntax"],
|
|
1278
|
+
SYNTAX: ["syntaxerror", "unexpected token", "parse error", "invalid syntax", "expected", "transform failed"],
|
|
1285
1279
|
NETWORK: ["fetch", "xhr", "network", "cors", "timeout", "connection"],
|
|
1286
1280
|
RUNTIME: ["referenceerror", "typeerror", "rangeerror", "undefined"],
|
|
1287
1281
|
SECURITY: ["csp", "xss", "csrf", "security", "unauthorized"],
|
|
1288
1282
|
PERFORMANCE: ["slow", "memory", "leak", "performance", "timeout"],
|
|
1289
|
-
DEVELOPMENT: ["vite", "hmr", "hot reload", "dev server", "webpack"]
|
|
1290
|
-
REACT: ["react", "jsx", "component", "hook", "render"],
|
|
1291
|
-
VITE: ["vite", "[vite]", "vite:react", "transform failed"]
|
|
1283
|
+
DEVELOPMENT: ["vite", "hmr", "hot reload", "dev server", "webpack", "esbuild", "plugin:vite:esbuild"]
|
|
1292
1284
|
}
|
|
1293
1285
|
};
|
|
1294
1286
|
var GLOBAL_CONFIG = {
|
|
@@ -1629,9 +1621,13 @@ var ViteHMRDetector = class {
|
|
|
1629
1621
|
setupHMREventListeners() {
|
|
1630
1622
|
if (typeof window !== "undefined" && window.import?.meta?.hot) {
|
|
1631
1623
|
const hot = window.import.meta.hot;
|
|
1632
|
-
hot.on("vite:error", () => {
|
|
1624
|
+
hot.on("vite:error", (data) => {
|
|
1625
|
+
this.handleViteError(data);
|
|
1633
1626
|
requestAnimationFrame(() => this.checkForViteErrorOverlay());
|
|
1634
1627
|
});
|
|
1628
|
+
hot.on("vite:invalidate", (data) => {
|
|
1629
|
+
setTimeout(() => this.checkForCompileErrors(), 500);
|
|
1630
|
+
});
|
|
1635
1631
|
hot.on("vite:beforeUpdate", () => {
|
|
1636
1632
|
console.log("[ViteHMRDetector] HMR \u66F4\u65B0\u5F00\u59CB");
|
|
1637
1633
|
});
|
|
@@ -1808,6 +1804,90 @@ File: ${errorInfo.fileText}`;
|
|
|
1808
1804
|
}
|
|
1809
1805
|
}
|
|
1810
1806
|
}
|
|
1807
|
+
/**
|
|
1808
|
+
* 处理 Vite 错误事件
|
|
1809
|
+
*/
|
|
1810
|
+
handleViteError(errorData) {
|
|
1811
|
+
try {
|
|
1812
|
+
const errorPayload = {
|
|
1813
|
+
id: `vite-error-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
1814
|
+
type: "vite_hmr",
|
|
1815
|
+
error: {
|
|
1816
|
+
name: "ViteError",
|
|
1817
|
+
message: errorData?.message || "Vite error",
|
|
1818
|
+
stack: errorData?.stack || ""
|
|
1819
|
+
},
|
|
1820
|
+
source: "vite:error",
|
|
1821
|
+
timestamp: Date.now(),
|
|
1822
|
+
severity: "error",
|
|
1823
|
+
context: {
|
|
1824
|
+
viteErrorData: errorData,
|
|
1825
|
+
url: window.location.href,
|
|
1826
|
+
userAgent: navigator.userAgent
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
if (window.__AUTO_ENGINEER_ERRORS__) {
|
|
1830
|
+
window.__AUTO_ENGINEER_ERRORS__.push(errorPayload);
|
|
1831
|
+
}
|
|
1832
|
+
this.sendMessage({
|
|
1833
|
+
type: "SYSTEM_EVENT",
|
|
1834
|
+
payload: errorPayload,
|
|
1835
|
+
timestamp: Date.now()
|
|
1836
|
+
});
|
|
1837
|
+
} catch (error) {
|
|
1838
|
+
console.error("[ViteHMRDetector] \u5904\u7406 Vite \u9519\u8BEF\u5931\u8D25:", error);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
/**
|
|
1842
|
+
* 检查编译错误
|
|
1843
|
+
*/
|
|
1844
|
+
async checkForCompileErrors() {
|
|
1845
|
+
try {
|
|
1846
|
+
if (document.querySelector("vite-error-overlay")) {
|
|
1847
|
+
this.checkForViteErrorOverlay();
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
const response = await fetch(window.location.href, {
|
|
1851
|
+
method: "HEAD",
|
|
1852
|
+
cache: "no-cache"
|
|
1853
|
+
});
|
|
1854
|
+
if (!response.ok) {
|
|
1855
|
+
this.handleCompileError(`HTTP ${response.status}: ${response.statusText}`);
|
|
1856
|
+
}
|
|
1857
|
+
} catch (error) {
|
|
1858
|
+
this.handleCompileError(`Error: ${error.message}`);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* 处理编译错误
|
|
1863
|
+
*/
|
|
1864
|
+
handleCompileError(errorMessage) {
|
|
1865
|
+
const errorPayload = {
|
|
1866
|
+
id: `compile-error-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
1867
|
+
type: "compile_error",
|
|
1868
|
+
error: {
|
|
1869
|
+
name: "CompileError",
|
|
1870
|
+
message: `Compile error: ${errorMessage}`,
|
|
1871
|
+
stack: ""
|
|
1872
|
+
},
|
|
1873
|
+
source: "vite:compile",
|
|
1874
|
+
timestamp: Date.now(),
|
|
1875
|
+
severity: "error",
|
|
1876
|
+
context: {
|
|
1877
|
+
url: window.location.href,
|
|
1878
|
+
userAgent: navigator.userAgent,
|
|
1879
|
+
compilationFailed: true
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
if (window.__AUTO_ENGINEER_ERRORS__) {
|
|
1883
|
+
window.__AUTO_ENGINEER_ERRORS__.push(errorPayload);
|
|
1884
|
+
}
|
|
1885
|
+
this.sendMessage({
|
|
1886
|
+
type: "SYSTEM_EVENT",
|
|
1887
|
+
payload: errorPayload,
|
|
1888
|
+
timestamp: Date.now()
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1811
1891
|
/**
|
|
1812
1892
|
* 检查当前环境是否支持 Vite HMR
|
|
1813
1893
|
*/
|
|
@@ -3164,6 +3244,20 @@ var ErrorTracking = class {
|
|
|
3164
3244
|
const fileInfo = this.extractFileInfoFromStack(fullStack);
|
|
3165
3245
|
const serializedArgs = args.map((arg) => DeepSerializer.quickSerialize(arg));
|
|
3166
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;
|
|
3167
3261
|
if (method === "error") {
|
|
3168
3262
|
const globalError = {
|
|
3169
3263
|
id: `console-error-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
@@ -3180,9 +3274,11 @@ var ErrorTracking = class {
|
|
|
3180
3274
|
pagePath: window.location.pathname + window.location.search + window.location.hash,
|
|
3181
3275
|
interactionTrail: [...window.__AUTO_ENGINEER_INTERACTION_TRAIL__ || []]
|
|
3182
3276
|
};
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
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
|
+
}
|
|
3186
3282
|
}
|
|
3187
3283
|
const consoleLevelMap = {
|
|
3188
3284
|
log: "info",
|
|
@@ -3194,7 +3290,7 @@ var ErrorTracking = class {
|
|
|
3194
3290
|
this.sendMessage({
|
|
3195
3291
|
type: "CONSOLE_EVENT",
|
|
3196
3292
|
payload: {
|
|
3197
|
-
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",
|
|
3198
3294
|
message,
|
|
3199
3295
|
logged_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3200
3296
|
filename: fileInfo.filename,
|
|
@@ -3215,15 +3311,44 @@ var ErrorTracking = class {
|
|
|
3215
3311
|
* 设置网络监控
|
|
3216
3312
|
*/
|
|
3217
3313
|
setupNetworkMonitoring() {
|
|
3314
|
+
const self = this;
|
|
3218
3315
|
const originalFetch = window.fetch;
|
|
3219
3316
|
window.fetch = async (...args) => {
|
|
3220
3317
|
const startTime = Date.now();
|
|
3221
3318
|
try {
|
|
3222
3319
|
const response = await originalFetch(...args);
|
|
3223
|
-
|
|
3320
|
+
self.logNetworkRequest(args, response, Date.now() - startTime);
|
|
3224
3321
|
return response;
|
|
3225
3322
|
} catch (error) {
|
|
3226
|
-
|
|
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
|
+
}
|
|
3227
3352
|
throw error;
|
|
3228
3353
|
}
|
|
3229
3354
|
};
|
|
@@ -3416,12 +3541,6 @@ var ErrorTracking = class {
|
|
|
3416
3541
|
if (ERROR_CONFIG.CATEGORY_KEYWORDS.DEVELOPMENT.some((keyword) => lowerMessage.includes(keyword))) {
|
|
3417
3542
|
return "DEVELOPMENT";
|
|
3418
3543
|
}
|
|
3419
|
-
if (ERROR_CONFIG.CATEGORY_KEYWORDS.REACT.some((keyword) => lowerMessage.includes(keyword))) {
|
|
3420
|
-
return "REACT";
|
|
3421
|
-
}
|
|
3422
|
-
if (ERROR_CONFIG.CATEGORY_KEYWORDS.VITE.some((keyword) => lowerMessage.includes(keyword))) {
|
|
3423
|
-
return "VITE";
|
|
3424
|
-
}
|
|
3425
3544
|
return "UNKNOWN";
|
|
3426
3545
|
}
|
|
3427
3546
|
/**
|
|
@@ -4055,7 +4174,6 @@ var ElementSelector2 = class {
|
|
|
4055
4174
|
this.waitForRootElement();
|
|
4056
4175
|
this.createTooltip();
|
|
4057
4176
|
this.createStyles();
|
|
4058
|
-
console.log("[ElementSelector] \u5143\u7D20\u9009\u62E9\u5668\u521D\u59CB\u5316\u5B8C\u6210");
|
|
4059
4177
|
}
|
|
4060
4178
|
/**
|
|
4061
4179
|
* 等待根元素加载
|
|
@@ -4193,7 +4311,6 @@ var ElementSelector2 = class {
|
|
|
4193
4311
|
document.body.classList.add("element-selector-active");
|
|
4194
4312
|
this.setupEventListeners();
|
|
4195
4313
|
this.manageButtonStates(true);
|
|
4196
|
-
console.log("[ElementSelector] \u9009\u62E9\u5668\u5DF2\u542F\u7528");
|
|
4197
4314
|
this.sendMessage({
|
|
4198
4315
|
type: "SELECTOR_ENABLED",
|
|
4199
4316
|
payload: { isActive: true }
|
|
@@ -4211,7 +4328,6 @@ var ElementSelector2 = class {
|
|
|
4211
4328
|
this.clearSelection();
|
|
4212
4329
|
this.manageButtonStates(false);
|
|
4213
4330
|
this.hideTooltip();
|
|
4214
|
-
console.log("[ElementSelector] \u9009\u62E9\u5668\u5DF2\u7981\u7528");
|
|
4215
4331
|
this.sendMessage({
|
|
4216
4332
|
type: "SELECTOR_DISABLED",
|
|
4217
4333
|
payload: { isActive: false }
|
|
@@ -4885,7 +5001,6 @@ var ElementSelector2 = class {
|
|
|
4885
5001
|
this.styleElement.remove();
|
|
4886
5002
|
this.styleElement = null;
|
|
4887
5003
|
}
|
|
4888
|
-
console.log("[ElementSelector] \u5143\u7D20\u9009\u62E9\u5668\u5DF2\u9500\u6BC1");
|
|
4889
5004
|
}
|
|
4890
5005
|
};
|
|
4891
5006
|
|
|
@@ -5548,7 +5663,6 @@ var ErrorHandler = class {
|
|
|
5548
5663
|
enableInteractionTracking: true
|
|
5549
5664
|
};
|
|
5550
5665
|
this.config = { ...this.config, ...options };
|
|
5551
|
-
console.log("[ErrorHandler] \u5F00\u59CB\u521D\u59CB\u5316\u7EDF\u4E00\u9519\u8BEF\u5904\u7406\u5668...");
|
|
5552
5666
|
this.messageSender = createDefaultMessageSender({
|
|
5553
5667
|
addTimestamp: true,
|
|
5554
5668
|
enableDebugLog: false
|
|
@@ -5563,9 +5677,7 @@ var ErrorHandler = class {
|
|
|
5563
5677
|
this.componentTreeGenerator = new ComponentTreeGenerator();
|
|
5564
5678
|
if (this.config.enableViteHMR && ViteHMRDetector.isViteEnvironment()) {
|
|
5565
5679
|
this.viteHMRDetector = new ViteHMRDetector(sendMessage);
|
|
5566
|
-
console.log("[ErrorHandler] Vite HMR \u68C0\u6D4B\u5668\u5DF2\u521D\u59CB\u5316");
|
|
5567
5680
|
}
|
|
5568
|
-
console.log("[ErrorHandler] \u6A21\u5757\u521D\u59CB\u5316\u5B8C\u6210");
|
|
5569
5681
|
}
|
|
5570
5682
|
/** ----------------- 主要初始化方法 ----------------- */
|
|
5571
5683
|
/**
|
|
@@ -5577,12 +5689,10 @@ var ErrorHandler = class {
|
|
|
5577
5689
|
return;
|
|
5578
5690
|
}
|
|
5579
5691
|
try {
|
|
5580
|
-
console.log("[ErrorHandler] \u5F00\u59CB\u521D\u59CB\u5316\u5404\u4E2A\u6A21\u5757...");
|
|
5581
5692
|
this.initializeCore();
|
|
5582
5693
|
this.setupModuleIntegration();
|
|
5583
5694
|
this.enableFeatures();
|
|
5584
5695
|
this.initialized = true;
|
|
5585
|
-
console.log("[ErrorHandler] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
5586
5696
|
} catch (error) {
|
|
5587
5697
|
console.error("[ErrorHandler] \u521D\u59CB\u5316\u5931\u8D25:", error);
|
|
5588
5698
|
throw error;
|
|
@@ -5595,7 +5705,6 @@ var ErrorHandler = class {
|
|
|
5595
5705
|
this.initializeGlobalState();
|
|
5596
5706
|
this.setupDebugEndpoint();
|
|
5597
5707
|
this.errorTracking.initialize();
|
|
5598
|
-
console.log("[ErrorHandler] \u6838\u5FC3\u529F\u80FD\u521D\u59CB\u5316\u5B8C\u6210");
|
|
5599
5708
|
}
|
|
5600
5709
|
/**
|
|
5601
5710
|
* 初始化全局状态
|
|
@@ -5607,7 +5716,6 @@ var ErrorHandler = class {
|
|
|
5607
5716
|
if (!window.__AUTO_ENGINEER_INTERACTION_TRAIL__) {
|
|
5608
5717
|
window.__AUTO_ENGINEER_INTERACTION_TRAIL__ = [];
|
|
5609
5718
|
}
|
|
5610
|
-
console.log("[ErrorHandler] \u5168\u5C40\u72B6\u6001\u521D\u59CB\u5316\u5B8C\u6210");
|
|
5611
5719
|
}
|
|
5612
5720
|
/**
|
|
5613
5721
|
* 设置调试端点
|
|
@@ -5631,24 +5739,19 @@ var ErrorHandler = class {
|
|
|
5631
5739
|
this.messageBridge.setComponentTreeGenerator(this.componentTreeGenerator);
|
|
5632
5740
|
this.errorTracking.setViewDetector(this.viewDetector);
|
|
5633
5741
|
this.errorTracking.setInteractionTracking(this.interactionTracking);
|
|
5634
|
-
console.log("[ErrorHandler] \u6A21\u5757\u96C6\u6210\u8BBE\u7F6E\u5B8C\u6210");
|
|
5635
5742
|
}
|
|
5636
5743
|
/**
|
|
5637
5744
|
* 启用功能模块
|
|
5638
5745
|
*/
|
|
5639
5746
|
enableFeatures() {
|
|
5640
|
-
console.log("[ErrorHandler] \u542F\u7528\u529F\u80FD\u6A21\u5757...");
|
|
5641
5747
|
if (this.config.enableInteractionTracking) {
|
|
5642
5748
|
this.interactionTracking.startTracking();
|
|
5643
|
-
console.log("[ErrorHandler] \u4EA4\u4E92\u8FFD\u8E2A\u5DF2\u542F\u7528");
|
|
5644
5749
|
}
|
|
5645
5750
|
if (this.viteHMRDetector) {
|
|
5646
5751
|
this.viteHMRDetector.initialize();
|
|
5647
|
-
console.log("[ErrorHandler] Vite HMR \u68C0\u6D4B\u5668\u5DF2\u542F\u7528");
|
|
5648
5752
|
}
|
|
5649
5753
|
this.handleHardRefreshLogic();
|
|
5650
5754
|
this.setupViewDetection();
|
|
5651
|
-
console.log("[ErrorHandler] \u529F\u80FD\u6A21\u5757\u542F\u7528\u5B8C\u6210");
|
|
5652
5755
|
}
|
|
5653
5756
|
/**
|
|
5654
5757
|
* 处理硬刷新逻辑
|
|
@@ -5657,7 +5760,6 @@ var ErrorHandler = class {
|
|
|
5657
5760
|
HardRefreshManager.cleanupRefreshParams();
|
|
5658
5761
|
const refreshStats = HardRefreshManager.getRefreshStats();
|
|
5659
5762
|
if (refreshStats.isHardRefresh) {
|
|
5660
|
-
console.log("[ErrorHandler] \u68C0\u6D4B\u5230\u786C\u5237\u65B0:", refreshStats);
|
|
5661
5763
|
this.messageSender.send({
|
|
5662
5764
|
type: "SYSTEM_EVENT",
|
|
5663
5765
|
payload: {
|
|
@@ -5678,7 +5780,6 @@ var ErrorHandler = class {
|
|
|
5678
5780
|
const currentView = this.viewDetector.getCurrentViewInfo();
|
|
5679
5781
|
if (currentView.title !== lastViewTitle) {
|
|
5680
5782
|
lastViewTitle = currentView.title;
|
|
5681
|
-
console.log("[ErrorHandler] \u89C6\u56FE\u53D8\u5316:", currentView);
|
|
5682
5783
|
}
|
|
5683
5784
|
};
|
|
5684
5785
|
setInterval(checkViewChange, 1e3);
|
|
@@ -5773,7 +5874,6 @@ var ErrorHandler = class {
|
|
|
5773
5874
|
*/
|
|
5774
5875
|
updateConfig(newConfig) {
|
|
5775
5876
|
this.config = { ...this.config, ...newConfig };
|
|
5776
|
-
console.log("[ErrorHandler] \u914D\u7F6E\u5DF2\u66F4\u65B0:", this.config);
|
|
5777
5877
|
}
|
|
5778
5878
|
/**
|
|
5779
5879
|
* 销毁错误处理器
|
|
@@ -5792,7 +5892,6 @@ var ErrorHandler = class {
|
|
|
5792
5892
|
this.viewDetector.clearCache();
|
|
5793
5893
|
}
|
|
5794
5894
|
this.initialized = false;
|
|
5795
|
-
console.log("[ErrorHandler] \u5DF2\u9500\u6BC1");
|
|
5796
5895
|
} catch (error) {
|
|
5797
5896
|
const originalConsole = getOriginalConsole3();
|
|
5798
5897
|
originalConsole.error("[ErrorHandler] \u9500\u6BC1\u65F6\u53D1\u751F\u9519\u8BEF:", error);
|
|
@@ -5833,1708 +5932,1702 @@ var ErrorHandler = class {
|
|
|
5833
5932
|
}
|
|
5834
5933
|
};
|
|
5835
5934
|
|
|
5836
|
-
// src/
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5935
|
+
// src/components/auth/HowoneProvider.tsx
|
|
5936
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
5937
|
+
var globalErrorHandler = null;
|
|
5938
|
+
var initializeErrorHandler = () => {
|
|
5939
|
+
if (!globalErrorHandler) {
|
|
5940
|
+
globalErrorHandler = new ErrorHandler({
|
|
5941
|
+
enableViteHMR: true,
|
|
5942
|
+
enableElementSelector: true,
|
|
5943
|
+
enableInteractionTracking: true
|
|
5944
|
+
});
|
|
5945
|
+
globalErrorHandler.init();
|
|
5946
|
+
window.__ERROR_HANDLER__ = globalErrorHandler;
|
|
5844
5947
|
}
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5948
|
+
return globalErrorHandler;
|
|
5949
|
+
};
|
|
5950
|
+
initializeErrorHandler();
|
|
5951
|
+
var HowoneContext = (0, import_react8.createContext)(null);
|
|
5952
|
+
var HowOneProvider = ({
|
|
5953
|
+
children,
|
|
5954
|
+
showFloatingButton = true,
|
|
5955
|
+
projectId,
|
|
5956
|
+
defaultTheme = "system",
|
|
5957
|
+
themeStorageKey = "howone-theme",
|
|
5958
|
+
forceDefaultTheme = false,
|
|
5959
|
+
authUrl = "https://howone.dev/auth",
|
|
5960
|
+
redirectOnUnauthenticated = true
|
|
5961
|
+
}) => {
|
|
5962
|
+
const [user, setUser] = (0, import_react8.useState)(() => parseUserFromToken(getToken()));
|
|
5963
|
+
const [token, setTokenState] = (0, import_react8.useState)(() => getToken());
|
|
5964
|
+
const [hasCheckedUrlToken, setHasCheckedUrlToken] = (0, import_react8.useState)(false);
|
|
5965
|
+
(0, import_react8.useEffect)(() => {
|
|
5966
|
+
try {
|
|
5967
|
+
const params = new URLSearchParams(window.location.search);
|
|
5968
|
+
let urlToken = params.get("access_token") || params.get("token");
|
|
5969
|
+
if (!urlToken && window.location.hash) {
|
|
5970
|
+
const hashParams = new URLSearchParams(window.location.hash.slice(1));
|
|
5971
|
+
urlToken = hashParams.get("access_token") || hashParams.get("token");
|
|
5972
|
+
}
|
|
5973
|
+
if (urlToken) {
|
|
5974
|
+
setToken(urlToken);
|
|
5975
|
+
setTokenState(urlToken);
|
|
5976
|
+
setUser(parseUserFromToken(urlToken));
|
|
5977
|
+
params.delete("access_token");
|
|
5978
|
+
params.delete("token");
|
|
5979
|
+
params.delete("project_id");
|
|
5980
|
+
const newSearch = params.toString();
|
|
5981
|
+
const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "");
|
|
5982
|
+
window.history.replaceState({}, "", newUrl);
|
|
5983
|
+
}
|
|
5984
|
+
} catch (e) {
|
|
5985
|
+
console.error("[HowOneProvider] Failed to capture token from URL:", e);
|
|
5986
|
+
} finally {
|
|
5987
|
+
setHasCheckedUrlToken(true);
|
|
5988
|
+
}
|
|
5989
|
+
}, []);
|
|
5990
|
+
(0, import_react8.useEffect)(() => {
|
|
5991
|
+
if (!hasCheckedUrlToken) {
|
|
5992
|
+
return;
|
|
5993
|
+
}
|
|
5994
|
+
if (redirectOnUnauthenticated && !token && !user) {
|
|
5995
|
+
const currentUrl = new URL(window.location.href);
|
|
5996
|
+
if (!currentUrl.pathname.includes("/auth")) {
|
|
5997
|
+
try {
|
|
5998
|
+
const authUrlObj = new URL(authUrl);
|
|
5999
|
+
const redirectUri = window.location.href;
|
|
6000
|
+
authUrlObj.searchParams.set("redirect_uri", redirectUri);
|
|
6001
|
+
if (projectId) {
|
|
6002
|
+
authUrlObj.searchParams.set("project_id", projectId);
|
|
6003
|
+
}
|
|
6004
|
+
window.location.href = authUrlObj.toString();
|
|
6005
|
+
} catch (error) {
|
|
6006
|
+
console.error("[HowOneProvider] Failed to build auth URL:", error);
|
|
6007
|
+
window.location.href = authUrl;
|
|
6008
|
+
}
|
|
6009
|
+
}
|
|
6010
|
+
}
|
|
6011
|
+
}, [token, user, redirectOnUnauthenticated, authUrl, projectId, hasCheckedUrlToken]);
|
|
6012
|
+
const logout = () => {
|
|
6013
|
+
try {
|
|
6014
|
+
setToken(null);
|
|
6015
|
+
} catch {
|
|
6016
|
+
}
|
|
6017
|
+
setTokenState(null);
|
|
6018
|
+
setUser(null);
|
|
6019
|
+
};
|
|
6020
|
+
const value = {
|
|
6021
|
+
user,
|
|
6022
|
+
token,
|
|
6023
|
+
isAuthenticated: hasCheckedUrlToken && !!token,
|
|
6024
|
+
logout
|
|
6025
|
+
};
|
|
6026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
6027
|
+
ThemeProvider,
|
|
6028
|
+
{
|
|
6029
|
+
defaultTheme,
|
|
6030
|
+
storageKey: themeStorageKey,
|
|
6031
|
+
forceDefault: forceDefaultTheme,
|
|
6032
|
+
children: [
|
|
6033
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ElementSelectorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(HowoneContext.Provider, { value, children: [
|
|
6034
|
+
children,
|
|
6035
|
+
showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
6036
|
+
] }) }),
|
|
6037
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(GlobalToastContainer, {})
|
|
6038
|
+
]
|
|
6039
|
+
}
|
|
6040
|
+
);
|
|
6041
|
+
};
|
|
6042
|
+
function useHowoneContext() {
|
|
6043
|
+
const ctx = (0, import_react8.useContext)(HowoneContext);
|
|
6044
|
+
if (!ctx) {
|
|
6045
|
+
const t = getToken();
|
|
6046
|
+
return {
|
|
6047
|
+
user: parseUserFromToken(t),
|
|
6048
|
+
token: t,
|
|
6049
|
+
isAuthenticated: !!t,
|
|
6050
|
+
logout: () => {
|
|
6051
|
+
try {
|
|
6052
|
+
setToken(null);
|
|
6053
|
+
} catch {
|
|
6054
|
+
}
|
|
6055
|
+
}
|
|
5850
6056
|
};
|
|
5851
6057
|
}
|
|
5852
|
-
return
|
|
6058
|
+
return ctx;
|
|
5853
6059
|
}
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
6060
|
+
|
|
6061
|
+
// src/components/index.ts
|
|
6062
|
+
init_auth();
|
|
6063
|
+
|
|
6064
|
+
// src/howone/client.ts
|
|
6065
|
+
init_auth();
|
|
6066
|
+
init_config();
|
|
6067
|
+
var HowoneAuthClient = class {
|
|
6068
|
+
constructor() {
|
|
6069
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
6070
|
+
this.loading = false;
|
|
5857
6071
|
}
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
6072
|
+
emit() {
|
|
6073
|
+
const state = {
|
|
6074
|
+
user: parseUserFromToken(getToken()),
|
|
6075
|
+
isLoading: this.loading
|
|
5862
6076
|
};
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
const canGoForward = navState.currentHistoryIndex < navState.navigationHistory.length - 1;
|
|
5870
|
-
const state = {
|
|
5871
|
-
type: "NAVIGATION_STATE",
|
|
5872
|
-
payload: {
|
|
5873
|
-
canGoBack,
|
|
5874
|
-
canGoForward,
|
|
5875
|
-
historyLength: navState.navigationHistory.length,
|
|
5876
|
-
currentIndex: navState.currentHistoryIndex,
|
|
5877
|
-
maxIndex: navState.navigationHistory.length - 1
|
|
6077
|
+
for (const l of this.listeners) {
|
|
6078
|
+
try {
|
|
6079
|
+
l(state);
|
|
6080
|
+
} catch (e) {
|
|
6081
|
+
void e;
|
|
6082
|
+
}
|
|
5878
6083
|
}
|
|
5879
|
-
}
|
|
5880
|
-
|
|
6084
|
+
}
|
|
6085
|
+
onAuthStateChanged(listener) {
|
|
6086
|
+
this.listeners.add(listener);
|
|
5881
6087
|
try {
|
|
5882
|
-
|
|
6088
|
+
listener({ user: parseUserFromToken(getToken()), isLoading: this.loading });
|
|
5883
6089
|
} catch (e) {
|
|
5884
|
-
|
|
5885
|
-
console.warn("Failed to send navigation state:", e.message);
|
|
5886
|
-
}
|
|
6090
|
+
void e;
|
|
5887
6091
|
}
|
|
6092
|
+
return () => {
|
|
6093
|
+
this.listeners.delete(listener);
|
|
6094
|
+
};
|
|
5888
6095
|
}
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
6096
|
+
// Simple redirect-based login trigger (consumer can override)
|
|
6097
|
+
login() {
|
|
6098
|
+
const root = getEnvs().AUTH_ROOT_VALUE;
|
|
6099
|
+
try {
|
|
6100
|
+
const loc = window.location.href;
|
|
6101
|
+
const authUrl = new URL("/auth", String(root));
|
|
6102
|
+
authUrl.searchParams.set("redirect_uri", String(loc));
|
|
6103
|
+
try {
|
|
6104
|
+
const cfg = (init_config(), __toCommonJS(config_exports));
|
|
6105
|
+
const pid = cfg.getDefaultProjectId && cfg.getDefaultProjectId();
|
|
6106
|
+
if (pid) authUrl.searchParams.set("project_id", String(pid));
|
|
6107
|
+
} catch {
|
|
6108
|
+
}
|
|
6109
|
+
try {
|
|
6110
|
+
if (window.top && window.top !== window) {
|
|
6111
|
+
window.top.location.replace(authUrl.toString());
|
|
6112
|
+
} else {
|
|
6113
|
+
window.location.replace(authUrl.toString());
|
|
6114
|
+
}
|
|
6115
|
+
} catch {
|
|
6116
|
+
try {
|
|
6117
|
+
window.location.replace(String(root));
|
|
6118
|
+
} catch {
|
|
6119
|
+
}
|
|
6120
|
+
}
|
|
6121
|
+
} catch {
|
|
6122
|
+
try {
|
|
6123
|
+
window.location.replace(String(root));
|
|
6124
|
+
} catch {
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6127
|
+
}
|
|
6128
|
+
logout() {
|
|
6129
|
+
setToken(null);
|
|
6130
|
+
this.emit();
|
|
6131
|
+
}
|
|
6132
|
+
getUser() {
|
|
6133
|
+
return parseUserFromToken(getToken());
|
|
6134
|
+
}
|
|
6135
|
+
// helper to programmatically set token (e.g., after callback handling)
|
|
6136
|
+
setToken(token) {
|
|
6137
|
+
setToken(token);
|
|
6138
|
+
this.emit();
|
|
6139
|
+
}
|
|
6140
|
+
};
|
|
6141
|
+
var howone = {
|
|
6142
|
+
auth: new HowoneAuthClient()
|
|
6143
|
+
};
|
|
6144
|
+
var client_default = howone;
|
|
6145
|
+
|
|
6146
|
+
// src/components/ui/Loading.tsx
|
|
6147
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
6148
|
+
var Loading = ({
|
|
6149
|
+
size = "md",
|
|
6150
|
+
text = "Loading...",
|
|
6151
|
+
className = "",
|
|
6152
|
+
fullScreen = false
|
|
6153
|
+
}) => {
|
|
6154
|
+
const sizeClasses = {
|
|
6155
|
+
sm: "h-4 w-4",
|
|
6156
|
+
md: "h-8 w-8",
|
|
6157
|
+
lg: "h-12 w-12"
|
|
5906
6158
|
};
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
6159
|
+
const containerClasses = fullScreen ? "fixed inset-0 flex items-center justify-center bg-white/80 backdrop-blur-sm z-50" : "flex items-center justify-center p-4";
|
|
6160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "text-center", children: [
|
|
6161
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
6162
|
+
"div",
|
|
6163
|
+
{
|
|
6164
|
+
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
|
|
6165
|
+
}
|
|
6166
|
+
),
|
|
6167
|
+
text && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "mt-2 text-sm text-gray-600", children: text })
|
|
6168
|
+
] }) });
|
|
6169
|
+
};
|
|
6170
|
+
var LoadingSpinner = ({
|
|
6171
|
+
size = "md",
|
|
6172
|
+
className = ""
|
|
6173
|
+
}) => {
|
|
6174
|
+
const sizeClasses = {
|
|
6175
|
+
sm: "h-4 w-4",
|
|
6176
|
+
md: "h-8 w-8",
|
|
6177
|
+
lg: "h-12 w-12"
|
|
6178
|
+
};
|
|
6179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
6180
|
+
"div",
|
|
6181
|
+
{
|
|
6182
|
+
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
|
|
6183
|
+
}
|
|
6184
|
+
);
|
|
6185
|
+
};
|
|
6186
|
+
|
|
6187
|
+
// src/components/ui/ErrorBoundary.tsx
|
|
6188
|
+
var import_react9 = require("react");
|
|
6189
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
6190
|
+
var ErrorBoundary = class extends import_react9.Component {
|
|
6191
|
+
constructor(props) {
|
|
6192
|
+
super(props);
|
|
6193
|
+
this.handleRetry = () => {
|
|
6194
|
+
this.setState({ hasError: false, error: void 0, errorInfo: void 0 });
|
|
6195
|
+
};
|
|
6196
|
+
this.state = { hasError: false };
|
|
5911
6197
|
}
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
6198
|
+
static getDerivedStateFromError(error) {
|
|
6199
|
+
return { hasError: true, error };
|
|
6200
|
+
}
|
|
6201
|
+
componentDidCatch(error, errorInfo) {
|
|
6202
|
+
this.setState({
|
|
6203
|
+
error,
|
|
6204
|
+
errorInfo
|
|
6205
|
+
});
|
|
6206
|
+
this.props.onError?.(error, errorInfo);
|
|
6207
|
+
}
|
|
6208
|
+
render() {
|
|
6209
|
+
if (this.state.hasError) {
|
|
6210
|
+
if (this.props.fallback) {
|
|
6211
|
+
const FallbackComponent = this.props.fallback;
|
|
6212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FallbackComponent, { error: this.state.error, retry: this.handleRetry });
|
|
6213
|
+
}
|
|
6214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "min-h-[400px] flex items-center justify-center p-4", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-center max-w-md", children: [
|
|
6215
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-red-500 text-6xl mb-4", children: "\u26A0\uFE0F" }),
|
|
6216
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: "Something went wrong" }),
|
|
6217
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-gray-600 mb-4", children: "An unexpected error occurred. Please try refreshing the page." }),
|
|
6218
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6219
|
+
"button",
|
|
6220
|
+
{
|
|
6221
|
+
onClick: this.handleRetry,
|
|
6222
|
+
className: "px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors",
|
|
6223
|
+
children: "Try Again"
|
|
6224
|
+
}
|
|
6225
|
+
),
|
|
6226
|
+
false
|
|
6227
|
+
] }) });
|
|
5919
6228
|
}
|
|
5920
|
-
return
|
|
6229
|
+
return this.props.children;
|
|
5921
6230
|
}
|
|
5922
|
-
|
|
5923
|
-
}
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
6231
|
+
};
|
|
6232
|
+
var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "min-h-[200px] flex items-center justify-center p-4", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-center", children: [
|
|
6233
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-red-500 text-4xl mb-2", children: "\u26A0\uFE0F" }),
|
|
6234
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-gray-600 mb-2", children: "Something went wrong" }),
|
|
6235
|
+
retry && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6236
|
+
"button",
|
|
6237
|
+
{
|
|
6238
|
+
onClick: retry,
|
|
6239
|
+
className: "px-3 py-1 bg-blue-600 text-white text-sm rounded hover:bg-blue-700 transition-colors",
|
|
6240
|
+
children: "Retry"
|
|
6241
|
+
}
|
|
6242
|
+
)
|
|
6243
|
+
] }) });
|
|
6244
|
+
|
|
6245
|
+
// src/components/ui/ClayxButton.tsx
|
|
6246
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
6247
|
+
var getSizeClasses = (size, isIconOnly) => {
|
|
6248
|
+
if (isIconOnly) {
|
|
6249
|
+
switch (size) {
|
|
6250
|
+
case "sm":
|
|
6251
|
+
return "h-8 w-8 min-w-8 p-0";
|
|
6252
|
+
case "md":
|
|
6253
|
+
return "h-10 w-10 min-w-10 p-0";
|
|
6254
|
+
case "lg":
|
|
6255
|
+
return "h-12 w-12 min-w-12 p-0";
|
|
6256
|
+
default:
|
|
6257
|
+
return "h-10 w-10 min-w-10 p-0";
|
|
5930
6258
|
}
|
|
5931
|
-
return true;
|
|
5932
6259
|
}
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
6260
|
+
switch (size) {
|
|
6261
|
+
case "sm":
|
|
6262
|
+
return "h-8 px-3 text-sm";
|
|
6263
|
+
case "md":
|
|
6264
|
+
return "h-10 px-4 text-base";
|
|
6265
|
+
case "lg":
|
|
6266
|
+
return "h-12 px-6 text-lg";
|
|
6267
|
+
default:
|
|
6268
|
+
return "h-10 px-4 text-base";
|
|
6269
|
+
}
|
|
6270
|
+
};
|
|
6271
|
+
var getVariantClasses = (variant) => {
|
|
6272
|
+
switch (variant) {
|
|
6273
|
+
case "solid":
|
|
6274
|
+
return "bg-primary text-white hover:bg-primary/90";
|
|
6275
|
+
case "ghost":
|
|
6276
|
+
return "bg-transparent hover:bg-white/10";
|
|
6277
|
+
case "flat":
|
|
6278
|
+
return "bg-white/5 hover:bg-white/10";
|
|
6279
|
+
default:
|
|
6280
|
+
return "";
|
|
6281
|
+
}
|
|
6282
|
+
};
|
|
6283
|
+
var ClayxButton = ({
|
|
6284
|
+
isIconOnly = false,
|
|
6285
|
+
size = "md",
|
|
6286
|
+
variant = "solid",
|
|
6287
|
+
className = "",
|
|
6288
|
+
children,
|
|
6289
|
+
disabled = false,
|
|
6290
|
+
...props
|
|
6291
|
+
}) => {
|
|
6292
|
+
const sizeClasses = getSizeClasses(size, isIconOnly);
|
|
6293
|
+
const variantClasses = getVariantClasses(variant);
|
|
6294
|
+
const baseClasses = `
|
|
6295
|
+
inline-flex items-center justify-center
|
|
6296
|
+
rounded-md font-medium
|
|
6297
|
+
transition-all duration-200
|
|
6298
|
+
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-transparent
|
|
6299
|
+
disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none
|
|
6300
|
+
`.replace(/\s+/g, " ").trim();
|
|
6301
|
+
const combinedClasses = `${baseClasses} ${sizeClasses} ${variantClasses} ${className}`.trim();
|
|
6302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6303
|
+
"button",
|
|
6304
|
+
{
|
|
6305
|
+
className: combinedClasses,
|
|
6306
|
+
disabled,
|
|
6307
|
+
...props,
|
|
6308
|
+
children
|
|
5959
6309
|
}
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
6310
|
+
);
|
|
6311
|
+
};
|
|
6312
|
+
|
|
6313
|
+
// src/components/ui/LimitUpgradeToast.tsx
|
|
6314
|
+
var import_react13 = require("@iconify/react");
|
|
6315
|
+
|
|
6316
|
+
// src/components/ui/Toast/ClayxToast.tsx
|
|
6317
|
+
var import_react11 = __toESM(require("react"));
|
|
6318
|
+
var import_react_toastify2 = require("react-toastify");
|
|
6319
|
+
var import_react12 = require("@iconify/react");
|
|
6320
|
+
|
|
6321
|
+
// src/components/theme/ThemeToggle.tsx
|
|
6322
|
+
var React6 = __toESM(require("react"));
|
|
6323
|
+
var import_react10 = require("@iconify/react");
|
|
6324
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
6325
|
+
function ThemeToggle({ className }) {
|
|
6326
|
+
const { setTheme, theme } = useTheme();
|
|
6327
|
+
const [mounted, setMounted] = React6.useState(false);
|
|
6328
|
+
React6.useEffect(() => {
|
|
6329
|
+
setMounted(true);
|
|
6330
|
+
}, []);
|
|
6331
|
+
const handleToggle = () => {
|
|
6332
|
+
if (theme === "dark") {
|
|
6333
|
+
setTheme("light");
|
|
6334
|
+
} else {
|
|
6335
|
+
setTheme("dark");
|
|
6336
|
+
}
|
|
6337
|
+
};
|
|
6338
|
+
if (!mounted) {
|
|
6339
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
6340
|
+
"button",
|
|
6341
|
+
{
|
|
6342
|
+
className: `relative inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground ${className || ""}`,
|
|
6343
|
+
disabled: true,
|
|
6344
|
+
children: [
|
|
6345
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react10.Icon, { icon: "solar:sun-bold", width: 20, height: 20 }),
|
|
6346
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sr-only", children: "\u5207\u6362\u4E3B\u9898" })
|
|
6347
|
+
]
|
|
6348
|
+
}
|
|
6349
|
+
);
|
|
6350
|
+
}
|
|
6351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
6352
|
+
"button",
|
|
6353
|
+
{
|
|
6354
|
+
className: `inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors ${className || ""}`,
|
|
6355
|
+
onClick: handleToggle,
|
|
6356
|
+
children: [
|
|
6357
|
+
theme === "light" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react10.Icon, { icon: "solar:sun-bold", width: 20, height: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react10.Icon, { icon: "solar:moon-linear", width: 20, height: 20 }),
|
|
6358
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sr-only", children: "\u5207\u6362\u4E3B\u9898" })
|
|
6359
|
+
]
|
|
6360
|
+
}
|
|
6361
|
+
);
|
|
6362
|
+
}
|
|
6363
|
+
|
|
6364
|
+
// src/components/ui/Toast/ClayxToast.tsx
|
|
6365
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
6366
|
+
var TOAST_ICONS = {
|
|
6367
|
+
success: {
|
|
6368
|
+
icon: "mdi:success",
|
|
6369
|
+
color: "text-green-400",
|
|
6370
|
+
className: "text-green-400",
|
|
6371
|
+
// 深色主题配置
|
|
6372
|
+
dark: {
|
|
6373
|
+
bgGradient: "bg-[#14181d]",
|
|
6374
|
+
// 移除透明度 f2
|
|
6375
|
+
gradientColor: "#389726",
|
|
6376
|
+
borderGradient: "border-[#389726]",
|
|
6377
|
+
borderGradientColor: "#389726"
|
|
6378
|
+
},
|
|
6379
|
+
// 浅色主题配置
|
|
6380
|
+
light: {
|
|
6381
|
+
bgGradient: "bg-[#fafafa]",
|
|
6382
|
+
// 移除透明度 ff
|
|
6383
|
+
gradientColor: "#22c55e",
|
|
6384
|
+
borderGradient: "border-[#22c55e]",
|
|
6385
|
+
borderGradientColor: "#22c55e"
|
|
6386
|
+
}
|
|
6387
|
+
},
|
|
6388
|
+
error: {
|
|
6389
|
+
icon: "ic:outline-close",
|
|
6390
|
+
color: "text-red-400",
|
|
6391
|
+
className: "text-red-400",
|
|
6392
|
+
dark: {
|
|
6393
|
+
bgGradient: "bg-[#14181d]",
|
|
6394
|
+
// 移除透明度 f2
|
|
6395
|
+
gradientColor: "#ef4444",
|
|
6396
|
+
borderGradient: "border-[#ef4444]",
|
|
6397
|
+
borderGradientColor: "#ef4444"
|
|
6398
|
+
},
|
|
6399
|
+
light: {
|
|
6400
|
+
bgGradient: "bg-[#fafafa]",
|
|
6401
|
+
// 移除透明度 ff
|
|
6402
|
+
gradientColor: "#f87171",
|
|
6403
|
+
borderGradient: "border-[#f87171]",
|
|
6404
|
+
borderGradientColor: "#f87171"
|
|
6405
|
+
}
|
|
6406
|
+
},
|
|
6407
|
+
warning: {
|
|
6408
|
+
icon: "mi:warning",
|
|
6409
|
+
color: "text-yellow-400",
|
|
6410
|
+
className: "text-yellow-400",
|
|
6411
|
+
dark: {
|
|
6412
|
+
bgGradient: "bg-[#14181d]",
|
|
6413
|
+
// 移除透明度 f2
|
|
6414
|
+
gradientColor: "#facc15",
|
|
6415
|
+
borderGradient: "border-[#facc15]",
|
|
6416
|
+
borderGradientColor: "#facc15"
|
|
6417
|
+
},
|
|
6418
|
+
light: {
|
|
6419
|
+
bgGradient: "bg-[#fafafa]",
|
|
6420
|
+
// 移除透明度 ff
|
|
6421
|
+
gradientColor: "#f59e0b",
|
|
6422
|
+
borderGradient: "border-[#f59e0b]",
|
|
6423
|
+
borderGradientColor: "#f59e0b"
|
|
6424
|
+
}
|
|
6425
|
+
},
|
|
6426
|
+
info: {
|
|
6427
|
+
icon: "ic:outline-info",
|
|
6428
|
+
color: "text-blue-400",
|
|
6429
|
+
className: "text-blue-400",
|
|
6430
|
+
dark: {
|
|
6431
|
+
bgGradient: "bg-[#14181d]",
|
|
6432
|
+
// 移除透明度 f2
|
|
6433
|
+
gradientColor: "#60a5fa",
|
|
6434
|
+
borderGradient: "border-[#60a5fa]",
|
|
6435
|
+
borderGradientColor: "#f0f0f0"
|
|
6436
|
+
},
|
|
6437
|
+
light: {
|
|
6438
|
+
bgGradient: "bg-[#fafafa]",
|
|
6439
|
+
// 移除透明度 ff
|
|
6440
|
+
gradientColor: "#3b82f6",
|
|
6441
|
+
borderGradient: "border-[#3b82f6]",
|
|
6442
|
+
borderGradientColor: "#3b82f6"
|
|
6443
|
+
}
|
|
6444
|
+
},
|
|
6445
|
+
default: {
|
|
6446
|
+
icon: "ic:round-notifications",
|
|
6447
|
+
color: "text-gray-400",
|
|
6448
|
+
className: "text-gray-400",
|
|
6449
|
+
dark: {
|
|
6450
|
+
bgGradient: "bg-[#14181d]",
|
|
6451
|
+
// 移除透明度 f2
|
|
6452
|
+
gradientColor: "#9ca3af",
|
|
6453
|
+
borderGradient: "border-[#9ca3af]",
|
|
6454
|
+
borderGradientColor: "#9ca3af"
|
|
6455
|
+
},
|
|
6456
|
+
light: {
|
|
6457
|
+
bgGradient: "bg-[#fafafa]",
|
|
6458
|
+
// 移除透明度 ff
|
|
6459
|
+
gradientColor: "#6b7280",
|
|
6460
|
+
borderGradient: "border-[#6b7280]",
|
|
6461
|
+
borderGradientColor: "#6b7280"
|
|
6462
|
+
}
|
|
6463
|
+
}
|
|
6464
|
+
};
|
|
6465
|
+
var CloseButton = import_react11.default.memo(({ closeToast }) => {
|
|
6466
|
+
const { theme } = useTheme();
|
|
6467
|
+
const handleClick = (0, import_react11.useCallback)((e) => {
|
|
6468
|
+
e.preventDefault();
|
|
6469
|
+
e.stopPropagation();
|
|
6470
|
+
closeToast?.();
|
|
6471
|
+
}, [closeToast]);
|
|
6472
|
+
const getCloseButtonColor = () => {
|
|
6473
|
+
const actualTheme = theme === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
6474
|
+
return actualTheme === "dark" ? "#b4b4b4" : "#6b7280";
|
|
6475
|
+
};
|
|
6476
|
+
const getCloseButtonHoverColor = () => {
|
|
6477
|
+
const actualTheme = theme === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
6478
|
+
return actualTheme === "dark" ? "white" : "#374151";
|
|
6479
|
+
};
|
|
6480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6481
|
+
import_react12.Icon,
|
|
6482
|
+
{
|
|
6483
|
+
icon: "vaadin:close",
|
|
6484
|
+
className: "flex items-center justify-center rounded-full relative z-10 flex-shrink-0 cursor-pointer \n transition-colors duration-200 drop-shadow-sm",
|
|
6485
|
+
onClick: handleClick,
|
|
6486
|
+
width: 14,
|
|
6487
|
+
height: 14,
|
|
6488
|
+
style: {
|
|
6489
|
+
color: getCloseButtonColor()
|
|
6490
|
+
},
|
|
6491
|
+
onMouseEnter: (e) => {
|
|
6492
|
+
e.currentTarget.style.color = getCloseButtonHoverColor();
|
|
6493
|
+
},
|
|
6494
|
+
onMouseLeave: (e) => {
|
|
6495
|
+
e.currentTarget.style.color = getCloseButtonColor();
|
|
6496
|
+
}
|
|
6497
|
+
}
|
|
6498
|
+
);
|
|
6499
|
+
});
|
|
6500
|
+
CloseButton.displayName = "CloseButton";
|
|
6501
|
+
var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
6502
|
+
const iconConfig = TOAST_ICONS[type];
|
|
6503
|
+
const { theme } = useTheme();
|
|
6504
|
+
const handleClose = (0, import_react11.useCallback)(() => {
|
|
6505
|
+
closeToast?.();
|
|
6506
|
+
}, [closeToast]);
|
|
6507
|
+
const getTextColor = () => {
|
|
6508
|
+
const actualTheme = theme === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
6509
|
+
return actualTheme === "dark" ? "white" : "#1f2937";
|
|
6510
|
+
};
|
|
6511
|
+
const getThemeConfig = () => {
|
|
6512
|
+
const actualTheme = theme === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
6513
|
+
return actualTheme === "dark" ? iconConfig.dark : iconConfig.light;
|
|
6514
|
+
};
|
|
6515
|
+
const themeConfig = getThemeConfig();
|
|
6516
|
+
if (component) {
|
|
6517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `flex items-start gap-3 !min-h-[90px] w-full backdrop-blur-md p-4 shadow-2xl relative overflow-hidden ${themeConfig.bgGradient}`, children: [
|
|
6518
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex-1 relative z-10", children: component }),
|
|
6519
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseButton, { closeToast: handleClose }) })
|
|
6520
|
+
] });
|
|
6521
|
+
}
|
|
6522
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `flex items-start gap-3 !min-h-[90px] w-full backdrop-blur-md p-4 shadow-2xl relative overflow-hidden ${themeConfig.bgGradient}`, children: [
|
|
6523
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6524
|
+
"div",
|
|
6525
|
+
{
|
|
6526
|
+
className: "absolute left-0 top-0 w-full h-full rounded-xl",
|
|
6527
|
+
style: {
|
|
6528
|
+
background: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "#0f1419" : "#ffffff",
|
|
6529
|
+
zIndex: -2
|
|
6530
|
+
}
|
|
6531
|
+
}
|
|
6532
|
+
),
|
|
6533
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6534
|
+
"div",
|
|
6535
|
+
{
|
|
6536
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
|
|
6537
|
+
style: {
|
|
6538
|
+
background: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? `linear-gradient(135deg, ${themeConfig.gradientColor}30 0%, ${themeConfig.gradientColor}20 15%, #14181df2 30%)` : `linear-gradient(135deg, ${themeConfig.gradientColor}15 0%, ${themeConfig.gradientColor}08 15%, #fafafaff 30%)`,
|
|
6539
|
+
zIndex: -1
|
|
6540
|
+
}
|
|
6541
|
+
}
|
|
6542
|
+
),
|
|
6543
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6544
|
+
"div",
|
|
6545
|
+
{
|
|
6546
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
|
|
6547
|
+
style: {
|
|
6548
|
+
border: "2px solid transparent",
|
|
6549
|
+
backgroundImage: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? `linear-gradient(135deg, ${themeConfig.borderGradientColor}60 0%, ${themeConfig.borderGradientColor}40 5%, transparent 22%)` : `linear-gradient(135deg, ${themeConfig.borderGradientColor}40 0%, ${themeConfig.borderGradientColor}25 5%, transparent 22%)`,
|
|
6550
|
+
backgroundOrigin: "border-box",
|
|
6551
|
+
backgroundClip: "border-box",
|
|
6552
|
+
WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
6553
|
+
WebkitMaskComposite: "xor",
|
|
6554
|
+
mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
6555
|
+
maskComposite: "exclude"
|
|
6556
|
+
}
|
|
6557
|
+
}
|
|
6558
|
+
),
|
|
6559
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex-shrink-0 mt-0.5 relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `w-7 h-7 backdrop-blur-sm rounded-full flex items-center justify-center ${theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "bg-white/10" : "bg-black/5"}`, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6560
|
+
import_react12.Icon,
|
|
6561
|
+
{
|
|
6562
|
+
icon: iconConfig.icon,
|
|
6563
|
+
width: 16,
|
|
6564
|
+
height: 16,
|
|
6565
|
+
className: iconConfig.color,
|
|
6566
|
+
style: {
|
|
6567
|
+
color: themeConfig.gradientColor
|
|
6568
|
+
}
|
|
6569
|
+
}
|
|
6570
|
+
) }) }),
|
|
6571
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-1 flex-1 relative z-10", children: [
|
|
6572
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6573
|
+
"div",
|
|
6574
|
+
{
|
|
6575
|
+
className: "text-[16px] font-semibold leading-tight drop-shadow-sm",
|
|
6576
|
+
style: {
|
|
6577
|
+
color: getTextColor(),
|
|
6578
|
+
backgroundClip: "text"
|
|
6579
|
+
},
|
|
6580
|
+
children: title
|
|
6581
|
+
}
|
|
6582
|
+
),
|
|
6583
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6584
|
+
"div",
|
|
6585
|
+
{
|
|
6586
|
+
className: "text-[13px] font-normal leading-relaxed drop-shadow-sm",
|
|
6587
|
+
style: {
|
|
6588
|
+
color: getTextColor(),
|
|
6589
|
+
backgroundClip: "text"
|
|
6590
|
+
},
|
|
6591
|
+
children: message
|
|
6592
|
+
}
|
|
6593
|
+
)
|
|
6594
|
+
] }),
|
|
6595
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseButton, { closeToast: handleClose }) })
|
|
6596
|
+
] });
|
|
6597
|
+
};
|
|
6598
|
+
var defaultToastOptions = {
|
|
6599
|
+
position: "bottom-right",
|
|
6600
|
+
autoClose: 3e3,
|
|
6601
|
+
hideProgressBar: true,
|
|
6602
|
+
closeOnClick: false,
|
|
6603
|
+
pauseOnHover: true,
|
|
6604
|
+
draggable: true,
|
|
6605
|
+
pauseOnFocusLoss: false,
|
|
6606
|
+
theme: "dark",
|
|
6607
|
+
transition: import_react_toastify2.Bounce
|
|
6608
|
+
};
|
|
6609
|
+
var createToast = (type) => {
|
|
6610
|
+
return (params) => {
|
|
6611
|
+
const { title, message, component, options } = params;
|
|
6612
|
+
(0, import_react_toastify2.toast)(
|
|
6613
|
+
({ closeToast }) => {
|
|
6614
|
+
if (params.render) return params.render(closeToast);
|
|
6615
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6616
|
+
ToastContent,
|
|
6617
|
+
{
|
|
6618
|
+
type,
|
|
6619
|
+
title,
|
|
6620
|
+
message: message || "",
|
|
6621
|
+
component,
|
|
6622
|
+
closeToast
|
|
5989
6623
|
}
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
window.addEventListener("popstate", () => {
|
|
5999
|
-
setTimeout(() => {
|
|
6000
|
-
if (window.parent && window.parent !== window) {
|
|
6001
|
-
sendNavigationState(window.parent, "*");
|
|
6002
|
-
}
|
|
6003
|
-
}, 50);
|
|
6004
|
-
});
|
|
6005
|
-
window.addEventListener("hashchange", () => {
|
|
6006
|
-
handlePageChange();
|
|
6007
|
-
});
|
|
6008
|
-
window.addEventListener("load", () => {
|
|
6009
|
-
if (!navState.initialized) {
|
|
6010
|
-
addToNavigationHistory(window.location.href, document.title);
|
|
6011
|
-
navState.initialized = true;
|
|
6012
|
-
}
|
|
6013
|
-
setTimeout(() => {
|
|
6014
|
-
if (window.parent && window.parent !== window) {
|
|
6015
|
-
sendNavigationState(window.parent, "*");
|
|
6016
|
-
}
|
|
6017
|
-
}, 500);
|
|
6018
|
-
});
|
|
6019
|
-
if (document.readyState === "loading") {
|
|
6020
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
6021
|
-
if (!navState.initialized) {
|
|
6022
|
-
addToNavigationHistory(window.location.href, document.title);
|
|
6023
|
-
navState.initialized = true;
|
|
6024
|
-
}
|
|
6025
|
-
});
|
|
6026
|
-
} else if (!navState.initialized) {
|
|
6027
|
-
addToNavigationHistory(window.location.href, document.title);
|
|
6028
|
-
navState.initialized = true;
|
|
6029
|
-
}
|
|
6030
|
-
window.iframeElementSelector = {
|
|
6031
|
-
startSelection: function() {
|
|
6032
|
-
triggerElementSelection();
|
|
6033
|
-
}
|
|
6034
|
-
};
|
|
6035
|
-
window.iframeNavigation = {
|
|
6036
|
-
addPage: function(url, title) {
|
|
6037
|
-
addToNavigationHistory(
|
|
6038
|
-
url || window.location.href,
|
|
6039
|
-
title || document.title
|
|
6040
|
-
);
|
|
6041
|
-
},
|
|
6042
|
-
getState: function() {
|
|
6043
|
-
return {
|
|
6044
|
-
canGoBack: navState.currentHistoryIndex > 0,
|
|
6045
|
-
canGoForward: navState.currentHistoryIndex < navState.navigationHistory.length - 1,
|
|
6046
|
-
historyLength: navState.navigationHistory.length,
|
|
6047
|
-
currentIndex: navState.currentHistoryIndex,
|
|
6048
|
-
currentPage: navState.navigationHistory[navState.currentHistoryIndex]
|
|
6049
|
-
};
|
|
6050
|
-
},
|
|
6051
|
-
updateState: function() {
|
|
6052
|
-
if (window.parent && window.parent !== window) {
|
|
6053
|
-
sendNavigationState(window.parent, "*");
|
|
6624
|
+
);
|
|
6625
|
+
},
|
|
6626
|
+
{
|
|
6627
|
+
...defaultToastOptions,
|
|
6628
|
+
...options,
|
|
6629
|
+
// 确保圆角样式不被覆盖,添加 rounded-xl 类
|
|
6630
|
+
className: "!p-0 !shadow-none !rounded-xl",
|
|
6631
|
+
style: { padding: 0, borderRadius: "0.75rem" }
|
|
6054
6632
|
}
|
|
6055
|
-
}
|
|
6056
|
-
};
|
|
6057
|
-
}
|
|
6058
|
-
var iframeNavigation = {
|
|
6059
|
-
/**
|
|
6060
|
-
* Initialize the navigation system
|
|
6061
|
-
*/
|
|
6062
|
-
init: initIframeNavigation,
|
|
6063
|
-
/**
|
|
6064
|
-
* Add a page to navigation history
|
|
6065
|
-
*/
|
|
6066
|
-
addPage: (url, title) => {
|
|
6067
|
-
if (typeof window === "undefined") return;
|
|
6068
|
-
addToNavigationHistory(
|
|
6069
|
-
url || window.location.href,
|
|
6070
|
-
title || (typeof document !== "undefined" ? document.title : "")
|
|
6071
6633
|
);
|
|
6072
|
-
}
|
|
6073
|
-
/**
|
|
6074
|
-
* Get current navigation state
|
|
6075
|
-
*/
|
|
6076
|
-
getState: () => {
|
|
6077
|
-
const navState = getNavState();
|
|
6078
|
-
return {
|
|
6079
|
-
canGoBack: navState.currentHistoryIndex > 0,
|
|
6080
|
-
canGoForward: navState.currentHistoryIndex < navState.navigationHistory.length - 1,
|
|
6081
|
-
historyLength: navState.navigationHistory.length,
|
|
6082
|
-
currentIndex: navState.currentHistoryIndex,
|
|
6083
|
-
currentPage: navState.navigationHistory[navState.currentHistoryIndex]
|
|
6084
|
-
};
|
|
6085
|
-
},
|
|
6086
|
-
/**
|
|
6087
|
-
* Update navigation state (send to parent)
|
|
6088
|
-
*/
|
|
6089
|
-
updateState: () => {
|
|
6090
|
-
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
6091
|
-
sendNavigationState(window.parent, "*");
|
|
6092
|
-
}
|
|
6093
|
-
},
|
|
6094
|
-
/**
|
|
6095
|
-
* Go back in history
|
|
6096
|
-
*/
|
|
6097
|
-
goBack: customGoBack,
|
|
6098
|
-
/**
|
|
6099
|
-
* Go forward in history
|
|
6100
|
-
*/
|
|
6101
|
-
goForward: customGoForward
|
|
6634
|
+
};
|
|
6102
6635
|
};
|
|
6103
|
-
var
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
* Cancel element selection mode
|
|
6110
|
-
*/
|
|
6111
|
-
cancel: cancelElementSelection,
|
|
6112
|
-
/**
|
|
6113
|
-
* Check if selector is active
|
|
6114
|
-
*/
|
|
6115
|
-
isActive: () => getElementSelectorState().active
|
|
6636
|
+
var ClayxToast = {
|
|
6637
|
+
success: createToast("success"),
|
|
6638
|
+
error: createToast("error"),
|
|
6639
|
+
warning: createToast("warning"),
|
|
6640
|
+
info: createToast("info"),
|
|
6641
|
+
default: createToast("default")
|
|
6116
6642
|
};
|
|
6117
6643
|
|
|
6118
|
-
// src/components/
|
|
6119
|
-
var
|
|
6120
|
-
var
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
}) => {
|
|
6131
|
-
const [user, setUser] = (0, import_react8.useState)(() => parseUserFromToken(getToken()));
|
|
6132
|
-
const [token, setTokenState] = (0, import_react8.useState)(() => getToken());
|
|
6133
|
-
const [hasCheckedUrlToken, setHasCheckedUrlToken] = (0, import_react8.useState)(false);
|
|
6134
|
-
(0, import_react8.useEffect)(() => {
|
|
6135
|
-
const errorHandler = new ErrorHandler({
|
|
6136
|
-
enableViteHMR: true,
|
|
6137
|
-
enableElementSelector: true,
|
|
6138
|
-
enableInteractionTracking: true
|
|
6139
|
-
// enableConsoleCapture: true,
|
|
6140
|
-
// enableNetworkCapture: true,
|
|
6141
|
-
// maxErrors: 100,
|
|
6142
|
-
// maxInteractions: 50,
|
|
6143
|
-
// debounceTime: 100,
|
|
6144
|
-
// reportToParent: true,
|
|
6145
|
-
// reportToConsole: true
|
|
6146
|
-
});
|
|
6147
|
-
errorHandler.init();
|
|
6148
|
-
window.__ERROR_HANDLER__ = errorHandler;
|
|
6149
|
-
initIframeNavigation();
|
|
6150
|
-
try {
|
|
6151
|
-
const params = new URLSearchParams(window.location.search);
|
|
6152
|
-
let urlToken = params.get("access_token") || params.get("token");
|
|
6153
|
-
if (!urlToken && window.location.hash) {
|
|
6154
|
-
const hashParams = new URLSearchParams(window.location.hash.slice(1));
|
|
6155
|
-
urlToken = hashParams.get("access_token") || hashParams.get("token");
|
|
6644
|
+
// src/components/ui/LimitUpgradeToast.tsx
|
|
6645
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
6646
|
+
var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
|
|
6647
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative w-full max-w-[420px] overflow-hidden rounded-md bg-gradient-to-br from-[#1A1A1A] via-[#151515] to-[#1A1A1A] shadow-[0_20px_60px_rgba(168,85,247,0.2)] backdrop-blur-sm", children: [
|
|
6648
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6649
|
+
"div",
|
|
6650
|
+
{
|
|
6651
|
+
className: "absolute left-0 top-0 w-full h-full rounded-md",
|
|
6652
|
+
style: {
|
|
6653
|
+
background: "#0f1419",
|
|
6654
|
+
zIndex: -2
|
|
6655
|
+
}
|
|
6156
6656
|
}
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "");
|
|
6167
|
-
window.history.replaceState({}, "", newUrl);
|
|
6168
|
-
console.log("[HowOneProvider] Token stored successfully, URL cleaned");
|
|
6657
|
+
),
|
|
6658
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6659
|
+
"div",
|
|
6660
|
+
{
|
|
6661
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-md",
|
|
6662
|
+
style: {
|
|
6663
|
+
background: `linear-gradient(135deg, rgba(168,85,247,0.3) 0%, rgba(168,85,247,0.2) 15%, #1A1A1A 30%)`,
|
|
6664
|
+
zIndex: -1
|
|
6665
|
+
}
|
|
6169
6666
|
}
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6667
|
+
),
|
|
6668
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6669
|
+
"div",
|
|
6670
|
+
{
|
|
6671
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-md",
|
|
6672
|
+
style: {
|
|
6673
|
+
border: "2px solid transparent",
|
|
6674
|
+
backgroundImage: `linear-gradient(135deg, rgba(168,85,247,0.6) 0%, rgba(168,85,247,0.4) 5%, transparent 22%)`,
|
|
6675
|
+
backgroundOrigin: "border-box",
|
|
6676
|
+
backgroundClip: "border-box",
|
|
6677
|
+
WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
6678
|
+
WebkitMaskComposite: "xor",
|
|
6679
|
+
mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
6680
|
+
maskComposite: "exclude"
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
),
|
|
6684
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "absolute -top-16 -right-16 h-32 w-32 rounded-full bg-gradient-to-br from-purple-500/20 via-pink-500/10 to-transparent blur-3xl animate-pulse" }),
|
|
6685
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "absolute -bottom-16 -left-16 h-32 w-32 rounded-full bg-gradient-to-tr from-blue-500/10 to-transparent blur-2xl animate-pulse", style: { animationDelay: "1s" } }),
|
|
6686
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "relative z-10 flex items-start gap-4 p-4", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-1 flex-col gap-3", children: [
|
|
6687
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
6688
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
6689
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-lg font-bold bg-gradient-to-r from-white to-gray-400 bg-clip-text text-transparent", children: "Upgrade Required" }),
|
|
6690
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "px-2 py-0.5 text-xs font-bold bg-purple-500/20 text-purple-400 rounded-md border border-purple-500/30", children: "Premium" })
|
|
6691
|
+
] }),
|
|
6692
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6693
|
+
ClayxButton,
|
|
6694
|
+
{
|
|
6695
|
+
onClick: closeToast,
|
|
6696
|
+
isIconOnly: true,
|
|
6697
|
+
size: "sm",
|
|
6698
|
+
className: "h-6 w-6 min-w-6 rounded-full bg-white/5 hover:bg-white/10 transition-colors",
|
|
6699
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react13.Icon, { icon: "iconamoon:close", className: "w-4 h-4 text-gray-400" })
|
|
6190
6700
|
}
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6701
|
+
)
|
|
6702
|
+
] }),
|
|
6703
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-sm text-gray-300 leading-relaxed", children: message }),
|
|
6704
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "mt-1 flex items-center gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6705
|
+
ClayxButton,
|
|
6706
|
+
{
|
|
6707
|
+
onClick: () => {
|
|
6708
|
+
onUpgrade();
|
|
6709
|
+
closeToast?.();
|
|
6710
|
+
},
|
|
6711
|
+
className: "flex-1 bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white font-semibold transition-all duration-300 hover:shadow-lg hover:shadow-purple-500/30 cursor-pointer",
|
|
6712
|
+
style: { cursor: "pointer" },
|
|
6713
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "flex items-center gap-2", children: [
|
|
6714
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react13.Icon, { icon: "solar:rocket-2-bold", className: "w-4 h-4" }),
|
|
6715
|
+
"Upgrade Now"
|
|
6716
|
+
] })
|
|
6196
6717
|
}
|
|
6197
|
-
}
|
|
6198
|
-
}
|
|
6199
|
-
}
|
|
6200
|
-
const logout = () => {
|
|
6201
|
-
try {
|
|
6202
|
-
setToken(null);
|
|
6203
|
-
} catch {
|
|
6204
|
-
}
|
|
6205
|
-
setTokenState(null);
|
|
6206
|
-
setUser(null);
|
|
6207
|
-
};
|
|
6208
|
-
const value = {
|
|
6209
|
-
user,
|
|
6210
|
-
token,
|
|
6211
|
-
isAuthenticated: hasCheckedUrlToken && !!token,
|
|
6212
|
-
logout
|
|
6213
|
-
};
|
|
6214
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
6215
|
-
ThemeProvider,
|
|
6216
|
-
{
|
|
6217
|
-
defaultTheme,
|
|
6218
|
-
storageKey: themeStorageKey,
|
|
6219
|
-
forceDefault: forceDefaultTheme,
|
|
6220
|
-
children: [
|
|
6221
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ElementSelectorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(HowoneContext.Provider, { value, children: [
|
|
6222
|
-
children,
|
|
6223
|
-
showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
6224
|
-
] }) }),
|
|
6225
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(GlobalToastContainer, {})
|
|
6226
|
-
]
|
|
6227
|
-
}
|
|
6228
|
-
);
|
|
6718
|
+
) })
|
|
6719
|
+
] }) })
|
|
6720
|
+
] });
|
|
6229
6721
|
};
|
|
6230
|
-
function
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6722
|
+
function showLimitUpgradeToast(message, onUpgrade) {
|
|
6723
|
+
ClayxToast.default({
|
|
6724
|
+
render: (closeToast) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LimitToastContainer, { message, onUpgrade, closeToast }),
|
|
6725
|
+
options: {
|
|
6726
|
+
position: "bottom-right",
|
|
6727
|
+
closeOnClick: false,
|
|
6728
|
+
autoClose: false,
|
|
6729
|
+
hideProgressBar: true,
|
|
6730
|
+
draggable: false,
|
|
6731
|
+
pauseOnHover: true,
|
|
6732
|
+
className: "!bg-transparent !shadow-none",
|
|
6733
|
+
style: {
|
|
6734
|
+
background: "transparent",
|
|
6735
|
+
padding: 0,
|
|
6736
|
+
width: "auto",
|
|
6737
|
+
maxWidth: "420px"
|
|
6243
6738
|
}
|
|
6244
|
-
}
|
|
6245
|
-
}
|
|
6246
|
-
return ctx;
|
|
6739
|
+
}
|
|
6740
|
+
});
|
|
6247
6741
|
}
|
|
6248
6742
|
|
|
6249
|
-
// src/
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
constructor() {
|
|
6257
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
6258
|
-
this.loading = false;
|
|
6743
|
+
// src/services/ai-workflow.ts
|
|
6744
|
+
var AIWorkflowClient = class {
|
|
6745
|
+
constructor(options = {}) {
|
|
6746
|
+
this.baseUrl = options.baseUrl?.replace(/\/+$/, "") || "";
|
|
6747
|
+
this.apiKey = options.apiKey;
|
|
6748
|
+
this.headers = { "Content-Type": "application/json", ...options.headers || {} };
|
|
6749
|
+
this.fetchImpl = options.fetchImpl || fetch.bind(globalThis);
|
|
6259
6750
|
}
|
|
6260
|
-
|
|
6261
|
-
const
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
};
|
|
6265
|
-
for (const l of this.listeners) {
|
|
6266
|
-
try {
|
|
6267
|
-
l(state);
|
|
6268
|
-
} catch (e) {
|
|
6269
|
-
void e;
|
|
6270
|
-
}
|
|
6751
|
+
buildHeaders(extra) {
|
|
6752
|
+
const h = { ...this.headers, ...extra || {} };
|
|
6753
|
+
if (this.apiKey && !h["Authorization"]) {
|
|
6754
|
+
h["Authorization"] = `Bearer ${this.apiKey}`;
|
|
6271
6755
|
}
|
|
6756
|
+
return h;
|
|
6272
6757
|
}
|
|
6273
|
-
|
|
6274
|
-
this.listeners.add(listener);
|
|
6758
|
+
async safeJson(resp) {
|
|
6275
6759
|
try {
|
|
6276
|
-
|
|
6277
|
-
} catch (
|
|
6278
|
-
|
|
6760
|
+
return await resp.json();
|
|
6761
|
+
} catch (_e) {
|
|
6762
|
+
return null;
|
|
6279
6763
|
}
|
|
6280
|
-
return () => {
|
|
6281
|
-
this.listeners.delete(listener);
|
|
6282
|
-
};
|
|
6283
6764
|
}
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6765
|
+
/**
|
|
6766
|
+
* 按 ID 执行工作流:POST {baseUrl}/workflow/{workflowId}/execute
|
|
6767
|
+
* body: { input, options }
|
|
6768
|
+
*/
|
|
6769
|
+
async executeWorkflow(workflowId, inputs, options) {
|
|
6770
|
+
if (!this.baseUrl) {
|
|
6771
|
+
throw new Error("AI workflow client requires a baseUrl (e.g. https://evoagentx-server.fly.dev)");
|
|
6772
|
+
}
|
|
6773
|
+
const url = `${this.baseUrl}/workflow/${workflowId}/execute`;
|
|
6287
6774
|
try {
|
|
6288
|
-
const
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
}
|
|
6297
|
-
try {
|
|
6298
|
-
if (window.top && window.top !== window) {
|
|
6299
|
-
window.top.location.replace(authUrl.toString());
|
|
6300
|
-
} else {
|
|
6301
|
-
window.location.replace(authUrl.toString());
|
|
6302
|
-
}
|
|
6303
|
-
} catch {
|
|
6304
|
-
try {
|
|
6305
|
-
window.location.replace(String(root));
|
|
6306
|
-
} catch {
|
|
6307
|
-
}
|
|
6775
|
+
const res = await this.fetchImpl(url, {
|
|
6776
|
+
method: "POST",
|
|
6777
|
+
headers: this.buildHeaders(),
|
|
6778
|
+
body: JSON.stringify({ inputs, options })
|
|
6779
|
+
});
|
|
6780
|
+
const data = await this.safeJson(res);
|
|
6781
|
+
if (!res.ok) {
|
|
6782
|
+
return { success: false, error: data?.error || `HTTP ${res.status}` };
|
|
6308
6783
|
}
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6784
|
+
if (data && data.status && data.status === 4003) {
|
|
6785
|
+
showLimitUpgradeToast(
|
|
6786
|
+
"Your credits are exhausted. Please upgrade your plan to continue generating projects.",
|
|
6787
|
+
() => window.open("https://clayx.ai/pricing", "_blank")
|
|
6788
|
+
);
|
|
6789
|
+
return null;
|
|
6313
6790
|
}
|
|
6791
|
+
return data || { success: true };
|
|
6792
|
+
} catch (error) {
|
|
6793
|
+
return { success: false, error: error instanceof Error ? error.message : "Network error" };
|
|
6314
6794
|
}
|
|
6315
6795
|
}
|
|
6316
|
-
logout() {
|
|
6317
|
-
setToken(null);
|
|
6318
|
-
this.emit();
|
|
6319
|
-
}
|
|
6320
|
-
getUser() {
|
|
6321
|
-
return parseUserFromToken(getToken());
|
|
6322
|
-
}
|
|
6323
|
-
// helper to programmatically set token (e.g., after callback handling)
|
|
6324
|
-
setToken(token) {
|
|
6325
|
-
setToken(token);
|
|
6326
|
-
this.emit();
|
|
6327
|
-
}
|
|
6328
6796
|
};
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
}
|
|
6332
|
-
var
|
|
6797
|
+
function createAIWorkflowClient(options = {}) {
|
|
6798
|
+
return new AIWorkflowClient(options);
|
|
6799
|
+
}
|
|
6800
|
+
var aiWorkflow = createAIWorkflowClient({ baseUrl: "https://evoagentx-server" });
|
|
6333
6801
|
|
|
6334
|
-
// src/
|
|
6335
|
-
var
|
|
6336
|
-
var
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6802
|
+
// src/services/request/index.ts
|
|
6803
|
+
var import_axios = __toESM(require("axios"));
|
|
6804
|
+
var Request = class {
|
|
6805
|
+
constructor(config) {
|
|
6806
|
+
this.abortControllers = /* @__PURE__ */ new Map();
|
|
6807
|
+
this.instance = import_axios.default.create({
|
|
6808
|
+
...config,
|
|
6809
|
+
validateStatus: (status) => {
|
|
6810
|
+
return status >= 200 && status < 300;
|
|
6811
|
+
}
|
|
6812
|
+
});
|
|
6813
|
+
this.interceptors = config.interceptors;
|
|
6814
|
+
this.instance.interceptors.request.use(
|
|
6815
|
+
this.interceptors?.requestInterceptor,
|
|
6816
|
+
this.interceptors?.requestInterceptorCatch
|
|
6817
|
+
);
|
|
6818
|
+
this.instance.interceptors.response.use(
|
|
6819
|
+
this.interceptors?.responseInterceptor,
|
|
6820
|
+
this.interceptors?.responseInterceptorCatch
|
|
6821
|
+
);
|
|
6822
|
+
this.instance.interceptors.request.use(
|
|
6823
|
+
(config2) => {
|
|
6824
|
+
return config2;
|
|
6825
|
+
},
|
|
6826
|
+
(err) => {
|
|
6827
|
+
return Promise.reject(err);
|
|
6828
|
+
}
|
|
6829
|
+
);
|
|
6830
|
+
this.instance.interceptors.response.use(
|
|
6831
|
+
(res) => {
|
|
6832
|
+
return res.data;
|
|
6833
|
+
},
|
|
6834
|
+
(err) => {
|
|
6835
|
+
if (import_axios.default.isCancel(err)) {
|
|
6836
|
+
return Promise.reject({
|
|
6837
|
+
isCanceled: true,
|
|
6838
|
+
message: "request canceled",
|
|
6839
|
+
originalError: err
|
|
6840
|
+
});
|
|
6841
|
+
}
|
|
6842
|
+
if (err.response?.data?.error) {
|
|
6843
|
+
return Promise.reject(err.response.data.error);
|
|
6844
|
+
}
|
|
6845
|
+
return Promise.reject(err);
|
|
6353
6846
|
}
|
|
6354
|
-
)
|
|
6355
|
-
text && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "mt-2 text-sm text-gray-600", children: text })
|
|
6356
|
-
] }) });
|
|
6357
|
-
};
|
|
6358
|
-
var LoadingSpinner = ({
|
|
6359
|
-
size = "md",
|
|
6360
|
-
className = ""
|
|
6361
|
-
}) => {
|
|
6362
|
-
const sizeClasses = {
|
|
6363
|
-
sm: "h-4 w-4",
|
|
6364
|
-
md: "h-8 w-8",
|
|
6365
|
-
lg: "h-12 w-12"
|
|
6366
|
-
};
|
|
6367
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
6368
|
-
"div",
|
|
6369
|
-
{
|
|
6370
|
-
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
|
|
6371
|
-
}
|
|
6372
|
-
);
|
|
6373
|
-
};
|
|
6374
|
-
|
|
6375
|
-
// src/components/ui/ErrorBoundary.tsx
|
|
6376
|
-
var import_react9 = require("react");
|
|
6377
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
6378
|
-
var ErrorBoundary = class extends import_react9.Component {
|
|
6379
|
-
constructor(props) {
|
|
6380
|
-
super(props);
|
|
6381
|
-
this.handleRetry = () => {
|
|
6382
|
-
this.setState({ hasError: false, error: void 0, errorInfo: void 0 });
|
|
6383
|
-
};
|
|
6384
|
-
this.state = { hasError: false };
|
|
6847
|
+
);
|
|
6385
6848
|
}
|
|
6386
|
-
|
|
6387
|
-
|
|
6849
|
+
cancelRequest(url) {
|
|
6850
|
+
this.abortControllers.forEach((controller, key) => {
|
|
6851
|
+
if (key.includes(url)) {
|
|
6852
|
+
controller.abort();
|
|
6853
|
+
this.abortControllers.delete(key);
|
|
6854
|
+
}
|
|
6855
|
+
});
|
|
6388
6856
|
}
|
|
6389
|
-
|
|
6390
|
-
this.
|
|
6391
|
-
|
|
6392
|
-
errorInfo
|
|
6857
|
+
cancelAllRequests() {
|
|
6858
|
+
this.abortControllers.forEach((controller) => {
|
|
6859
|
+
controller.abort();
|
|
6393
6860
|
});
|
|
6394
|
-
this.
|
|
6861
|
+
this.abortControllers.clear();
|
|
6395
6862
|
}
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6863
|
+
request(config) {
|
|
6864
|
+
const controller = new AbortController();
|
|
6865
|
+
const url = config.url || "";
|
|
6866
|
+
const method = config.method || "GET";
|
|
6867
|
+
const key = `${method}:${url}`;
|
|
6868
|
+
this.abortControllers.set(key, controller);
|
|
6869
|
+
config.signal = controller.signal;
|
|
6870
|
+
return new Promise((resolve, reject) => {
|
|
6871
|
+
if (config.interceptors?.requestInterceptor) {
|
|
6872
|
+
config = config.interceptors.requestInterceptor(config);
|
|
6401
6873
|
}
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
),
|
|
6414
|
-
false
|
|
6415
|
-
] }) });
|
|
6416
|
-
}
|
|
6417
|
-
return this.props.children;
|
|
6874
|
+
this.instance.request(config).then((res) => {
|
|
6875
|
+
this.abortControllers.delete(key);
|
|
6876
|
+
if (config.interceptors?.responseInterceptor) {
|
|
6877
|
+
res = config.interceptors.responseInterceptor(res);
|
|
6878
|
+
}
|
|
6879
|
+
resolve(res);
|
|
6880
|
+
}).catch((err) => {
|
|
6881
|
+
this.abortControllers.delete(key);
|
|
6882
|
+
reject(err);
|
|
6883
|
+
});
|
|
6884
|
+
});
|
|
6418
6885
|
}
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-red-500 text-4xl mb-2", children: "\u26A0\uFE0F" }),
|
|
6422
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-gray-600 mb-2", children: "Something went wrong" }),
|
|
6423
|
-
retry && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6424
|
-
"button",
|
|
6425
|
-
{
|
|
6426
|
-
onClick: retry,
|
|
6427
|
-
className: "px-3 py-1 bg-blue-600 text-white text-sm rounded hover:bg-blue-700 transition-colors",
|
|
6428
|
-
children: "Retry"
|
|
6429
|
-
}
|
|
6430
|
-
)
|
|
6431
|
-
] }) });
|
|
6432
|
-
|
|
6433
|
-
// src/components/ui/ClayxButton.tsx
|
|
6434
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
6435
|
-
var getSizeClasses = (size, isIconOnly) => {
|
|
6436
|
-
if (isIconOnly) {
|
|
6437
|
-
switch (size) {
|
|
6438
|
-
case "sm":
|
|
6439
|
-
return "h-8 w-8 min-w-8 p-0";
|
|
6440
|
-
case "md":
|
|
6441
|
-
return "h-10 w-10 min-w-10 p-0";
|
|
6442
|
-
case "lg":
|
|
6443
|
-
return "h-12 w-12 min-w-12 p-0";
|
|
6444
|
-
default:
|
|
6445
|
-
return "h-10 w-10 min-w-10 p-0";
|
|
6446
|
-
}
|
|
6886
|
+
get(config) {
|
|
6887
|
+
return this.request({ ...config, method: "GET" });
|
|
6447
6888
|
}
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
return "h-8 px-3 text-sm";
|
|
6451
|
-
case "md":
|
|
6452
|
-
return "h-10 px-4 text-base";
|
|
6453
|
-
case "lg":
|
|
6454
|
-
return "h-12 px-6 text-lg";
|
|
6455
|
-
default:
|
|
6456
|
-
return "h-10 px-4 text-base";
|
|
6889
|
+
post(config) {
|
|
6890
|
+
return this.request({ ...config, method: "POST" });
|
|
6457
6891
|
}
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
return "bg-white/5 hover:bg-white/10";
|
|
6467
|
-
default:
|
|
6468
|
-
return "";
|
|
6892
|
+
delete(config) {
|
|
6893
|
+
return this.request({ ...config, method: "DELETE" });
|
|
6894
|
+
}
|
|
6895
|
+
put(config) {
|
|
6896
|
+
return this.request({ ...config, method: "PUT" });
|
|
6897
|
+
}
|
|
6898
|
+
patch(config) {
|
|
6899
|
+
return this.request({ ...config, method: "PATCH" });
|
|
6469
6900
|
}
|
|
6470
6901
|
};
|
|
6471
|
-
var
|
|
6472
|
-
isIconOnly = false,
|
|
6473
|
-
size = "md",
|
|
6474
|
-
variant = "solid",
|
|
6475
|
-
className = "",
|
|
6476
|
-
children,
|
|
6477
|
-
disabled = false,
|
|
6478
|
-
...props
|
|
6479
|
-
}) => {
|
|
6480
|
-
const sizeClasses = getSizeClasses(size, isIconOnly);
|
|
6481
|
-
const variantClasses = getVariantClasses(variant);
|
|
6482
|
-
const baseClasses = `
|
|
6483
|
-
inline-flex items-center justify-center
|
|
6484
|
-
rounded-md font-medium
|
|
6485
|
-
transition-all duration-200
|
|
6486
|
-
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-transparent
|
|
6487
|
-
disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none
|
|
6488
|
-
`.replace(/\s+/g, " ").trim();
|
|
6489
|
-
const combinedClasses = `${baseClasses} ${sizeClasses} ${variantClasses} ${className}`.trim();
|
|
6490
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6491
|
-
"button",
|
|
6492
|
-
{
|
|
6493
|
-
className: combinedClasses,
|
|
6494
|
-
disabled,
|
|
6495
|
-
...props,
|
|
6496
|
-
children
|
|
6497
|
-
}
|
|
6498
|
-
);
|
|
6499
|
-
};
|
|
6500
|
-
|
|
6501
|
-
// src/components/ui/LimitUpgradeToast.tsx
|
|
6502
|
-
var import_react13 = require("@iconify/react");
|
|
6503
|
-
|
|
6504
|
-
// src/components/ui/Toast/ClayxToast.tsx
|
|
6505
|
-
var import_react11 = __toESM(require("react"));
|
|
6506
|
-
var import_react_toastify2 = require("react-toastify");
|
|
6507
|
-
var import_react12 = require("@iconify/react");
|
|
6902
|
+
var request_default = Request;
|
|
6508
6903
|
|
|
6509
|
-
// src/
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
const
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
disabled: true,
|
|
6532
|
-
children: [
|
|
6533
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react10.Icon, { icon: "solar:sun-bold", width: 20, height: 20 }),
|
|
6534
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sr-only", children: "\u5207\u6362\u4E3B\u9898" })
|
|
6535
|
-
]
|
|
6536
|
-
}
|
|
6537
|
-
);
|
|
6538
|
-
}
|
|
6539
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
6540
|
-
"button",
|
|
6541
|
-
{
|
|
6542
|
-
className: `inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors ${className || ""}`,
|
|
6543
|
-
onClick: handleToggle,
|
|
6544
|
-
children: [
|
|
6545
|
-
theme === "light" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react10.Icon, { icon: "solar:sun-bold", width: 20, height: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react10.Icon, { icon: "solar:moon-linear", width: 20, height: 20 }),
|
|
6546
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sr-only", children: "\u5207\u6362\u4E3B\u9898" })
|
|
6547
|
-
]
|
|
6904
|
+
// src/services/ai-workflow-axios.ts
|
|
6905
|
+
function createAIWorkflowClientAxios(options = {}) {
|
|
6906
|
+
const basePath = options.basePath ?? "/api";
|
|
6907
|
+
const baseUrl = (options.baseUrl || "https://evoagentx-server.fly.dev").replace(/\/+$/, "");
|
|
6908
|
+
const baseAPI = `${baseUrl}${basePath.startsWith("/") ? "" : "/"}${basePath}`.replace(/\/+$/, "");
|
|
6909
|
+
const client = options.requestInstance || new request_default({
|
|
6910
|
+
baseURL: baseAPI,
|
|
6911
|
+
timeout: options.timeout ?? 6e4,
|
|
6912
|
+
interceptors: {
|
|
6913
|
+
requestInterceptor: (config) => {
|
|
6914
|
+
config.headers = config.headers || {};
|
|
6915
|
+
if (options.apiKey && !config.headers["Authorization"]) {
|
|
6916
|
+
config.headers["Authorization"] = `Bearer ${options.apiKey}`;
|
|
6917
|
+
}
|
|
6918
|
+
if (options.headers) {
|
|
6919
|
+
config.headers = { ...config.headers || {}, ...options.headers };
|
|
6920
|
+
}
|
|
6921
|
+
return config;
|
|
6922
|
+
},
|
|
6923
|
+
requestInterceptorCatch: (err) => Promise.reject(err),
|
|
6924
|
+
responseInterceptor: (res) => res,
|
|
6925
|
+
responseInterceptorCatch: (err) => Promise.reject(err)
|
|
6548
6926
|
}
|
|
6549
|
-
);
|
|
6927
|
+
});
|
|
6928
|
+
return {
|
|
6929
|
+
async executeWorkflow(workflowId, inputs, opts) {
|
|
6930
|
+
const url = `${baseUrl}/workflow/${workflowId}/execute`;
|
|
6931
|
+
const data = await client.post({ url, data: { inputs, options: opts } });
|
|
6932
|
+
return data;
|
|
6933
|
+
}
|
|
6934
|
+
};
|
|
6550
6935
|
}
|
|
6551
6936
|
|
|
6552
|
-
// src/
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6937
|
+
// src/services/artifact-types.ts
|
|
6938
|
+
function canAccessArtifact(a, ctx = {}) {
|
|
6939
|
+
if (!a) return false;
|
|
6940
|
+
if (a.visibility === "public") return true;
|
|
6941
|
+
if (a.visibility === "project") {
|
|
6942
|
+
if (ctx.projectId && a.projectId && ctx.projectId === a.projectId) return true;
|
|
6943
|
+
if (ctx.tokenScopes && ctx.tokenScopes.includes("project:read")) return true;
|
|
6944
|
+
return false;
|
|
6945
|
+
}
|
|
6946
|
+
if (a.visibility === "private") {
|
|
6947
|
+
if (ctx.userId && a.ownerId && ctx.userId === a.ownerId) return true;
|
|
6948
|
+
if (ctx.tokenScopes && (ctx.tokenScopes.includes("artifact:read:all") || ctx.tokenScopes.includes("admin"))) return true;
|
|
6949
|
+
return false;
|
|
6950
|
+
}
|
|
6951
|
+
if (a.visibility === "shared") {
|
|
6952
|
+
if (ctx.userId && a.sharedWith && a.sharedWith.includes(ctx.userId)) return true;
|
|
6953
|
+
if (ctx.tokenScopes && (ctx.tokenScopes.includes("artifact:read:all") || ctx.tokenScopes.includes("admin"))) return true;
|
|
6954
|
+
return false;
|
|
6955
|
+
}
|
|
6956
|
+
return false;
|
|
6957
|
+
}
|
|
6958
|
+
|
|
6959
|
+
// src/services/artifacts-client.ts
|
|
6960
|
+
function createArtifactsClient(req) {
|
|
6961
|
+
return {
|
|
6962
|
+
async create(input) {
|
|
6963
|
+
return await req.post({ url: "/artifacts", data: input });
|
|
6566
6964
|
},
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
bgGradient: "bg-[#fafafa]",
|
|
6570
|
-
// 移除透明度 ff
|
|
6571
|
-
gradientColor: "#22c55e",
|
|
6572
|
-
borderGradient: "border-[#22c55e]",
|
|
6573
|
-
borderGradientColor: "#22c55e"
|
|
6574
|
-
}
|
|
6575
|
-
},
|
|
6576
|
-
error: {
|
|
6577
|
-
icon: "ic:outline-close",
|
|
6578
|
-
color: "text-red-400",
|
|
6579
|
-
className: "text-red-400",
|
|
6580
|
-
dark: {
|
|
6581
|
-
bgGradient: "bg-[#14181d]",
|
|
6582
|
-
// 移除透明度 f2
|
|
6583
|
-
gradientColor: "#ef4444",
|
|
6584
|
-
borderGradient: "border-[#ef4444]",
|
|
6585
|
-
borderGradientColor: "#ef4444"
|
|
6965
|
+
async list(query) {
|
|
6966
|
+
return await req.get({ url: "/artifacts", params: query });
|
|
6586
6967
|
},
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
// 移除透明度 ff
|
|
6590
|
-
gradientColor: "#f87171",
|
|
6591
|
-
borderGradient: "border-[#f87171]",
|
|
6592
|
-
borderGradientColor: "#f87171"
|
|
6593
|
-
}
|
|
6594
|
-
},
|
|
6595
|
-
warning: {
|
|
6596
|
-
icon: "mi:warning",
|
|
6597
|
-
color: "text-yellow-400",
|
|
6598
|
-
className: "text-yellow-400",
|
|
6599
|
-
dark: {
|
|
6600
|
-
bgGradient: "bg-[#14181d]",
|
|
6601
|
-
// 移除透明度 f2
|
|
6602
|
-
gradientColor: "#facc15",
|
|
6603
|
-
borderGradient: "border-[#facc15]",
|
|
6604
|
-
borderGradientColor: "#facc15"
|
|
6968
|
+
async get(id) {
|
|
6969
|
+
return await req.get({ url: `/artifacts/${encodeURIComponent(id)}` });
|
|
6605
6970
|
},
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
// 移除透明度 ff
|
|
6609
|
-
gradientColor: "#f59e0b",
|
|
6610
|
-
borderGradient: "border-[#f59e0b]",
|
|
6611
|
-
borderGradientColor: "#f59e0b"
|
|
6612
|
-
}
|
|
6613
|
-
},
|
|
6614
|
-
info: {
|
|
6615
|
-
icon: "ic:outline-info",
|
|
6616
|
-
color: "text-blue-400",
|
|
6617
|
-
className: "text-blue-400",
|
|
6618
|
-
dark: {
|
|
6619
|
-
bgGradient: "bg-[#14181d]",
|
|
6620
|
-
// 移除透明度 f2
|
|
6621
|
-
gradientColor: "#60a5fa",
|
|
6622
|
-
borderGradient: "border-[#60a5fa]",
|
|
6623
|
-
borderGradientColor: "#f0f0f0"
|
|
6971
|
+
async setVisibility(id, visibility) {
|
|
6972
|
+
await req.patch({ url: `/artifacts/${encodeURIComponent(id)}/visibility`, data: { visibility } });
|
|
6624
6973
|
},
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
// 移除透明度 ff
|
|
6628
|
-
gradientColor: "#3b82f6",
|
|
6629
|
-
borderGradient: "border-[#3b82f6]",
|
|
6630
|
-
borderGradientColor: "#3b82f6"
|
|
6631
|
-
}
|
|
6632
|
-
},
|
|
6633
|
-
default: {
|
|
6634
|
-
icon: "ic:round-notifications",
|
|
6635
|
-
color: "text-gray-400",
|
|
6636
|
-
className: "text-gray-400",
|
|
6637
|
-
dark: {
|
|
6638
|
-
bgGradient: "bg-[#14181d]",
|
|
6639
|
-
// 移除透明度 f2
|
|
6640
|
-
gradientColor: "#9ca3af",
|
|
6641
|
-
borderGradient: "border-[#9ca3af]",
|
|
6642
|
-
borderGradientColor: "#9ca3af"
|
|
6974
|
+
async delete(id) {
|
|
6975
|
+
await req.delete({ url: `/artifacts/${encodeURIComponent(id)}` });
|
|
6643
6976
|
},
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
};
|
|
6653
|
-
var CloseButton = import_react11.default.memo(({ closeToast }) => {
|
|
6654
|
-
const { theme } = useTheme();
|
|
6655
|
-
const handleClick = (0, import_react11.useCallback)((e) => {
|
|
6656
|
-
e.preventDefault();
|
|
6657
|
-
e.stopPropagation();
|
|
6658
|
-
closeToast?.();
|
|
6659
|
-
}, [closeToast]);
|
|
6660
|
-
const getCloseButtonColor = () => {
|
|
6661
|
-
const actualTheme = theme === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
6662
|
-
return actualTheme === "dark" ? "#b4b4b4" : "#6b7280";
|
|
6663
|
-
};
|
|
6664
|
-
const getCloseButtonHoverColor = () => {
|
|
6665
|
-
const actualTheme = theme === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
6666
|
-
return actualTheme === "dark" ? "white" : "#374151";
|
|
6667
|
-
};
|
|
6668
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6669
|
-
import_react12.Icon,
|
|
6670
|
-
{
|
|
6671
|
-
icon: "vaadin:close",
|
|
6672
|
-
className: "flex items-center justify-center rounded-full relative z-10 flex-shrink-0 cursor-pointer \n transition-colors duration-200 drop-shadow-sm",
|
|
6673
|
-
onClick: handleClick,
|
|
6674
|
-
width: 14,
|
|
6675
|
-
height: 14,
|
|
6676
|
-
style: {
|
|
6677
|
-
color: getCloseButtonColor()
|
|
6678
|
-
},
|
|
6679
|
-
onMouseEnter: (e) => {
|
|
6680
|
-
e.currentTarget.style.color = getCloseButtonHoverColor();
|
|
6681
|
-
},
|
|
6682
|
-
onMouseLeave: (e) => {
|
|
6683
|
-
e.currentTarget.style.color = getCloseButtonColor();
|
|
6684
|
-
}
|
|
6977
|
+
// convenience local check (server is authoritative)
|
|
6978
|
+
canAccessLocal(a, ctx) {
|
|
6979
|
+
if (!a) return false;
|
|
6980
|
+
if (a.visibility === "public") return true;
|
|
6981
|
+
if (a.visibility === "project") return Boolean(ctx.projectId && a.projectId && ctx.projectId === a.projectId);
|
|
6982
|
+
if (a.visibility === "private") return Boolean(ctx.userId && a.ownerId && ctx.userId === a.ownerId);
|
|
6983
|
+
if (a.visibility === "shared") return Boolean(ctx.userId && a.sharedWith && a.sharedWith.includes(ctx.userId));
|
|
6984
|
+
return false;
|
|
6685
6985
|
}
|
|
6686
|
-
);
|
|
6687
|
-
});
|
|
6688
|
-
CloseButton.displayName = "CloseButton";
|
|
6689
|
-
var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
6690
|
-
const iconConfig = TOAST_ICONS[type];
|
|
6691
|
-
const { theme } = useTheme();
|
|
6692
|
-
const handleClose = (0, import_react11.useCallback)(() => {
|
|
6693
|
-
closeToast?.();
|
|
6694
|
-
}, [closeToast]);
|
|
6695
|
-
const getTextColor = () => {
|
|
6696
|
-
const actualTheme = theme === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
6697
|
-
return actualTheme === "dark" ? "white" : "#1f2937";
|
|
6698
|
-
};
|
|
6699
|
-
const getThemeConfig = () => {
|
|
6700
|
-
const actualTheme = theme === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
6701
|
-
return actualTheme === "dark" ? iconConfig.dark : iconConfig.light;
|
|
6702
6986
|
};
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
)
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
}
|
|
6729
|
-
}
|
|
6730
|
-
),
|
|
6731
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6732
|
-
"div",
|
|
6733
|
-
{
|
|
6734
|
-
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
|
|
6735
|
-
style: {
|
|
6736
|
-
border: "2px solid transparent",
|
|
6737
|
-
backgroundImage: theme === "dark" || theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches ? `linear-gradient(135deg, ${themeConfig.borderGradientColor}60 0%, ${themeConfig.borderGradientColor}40 5%, transparent 22%)` : `linear-gradient(135deg, ${themeConfig.borderGradientColor}40 0%, ${themeConfig.borderGradientColor}25 5%, transparent 22%)`,
|
|
6738
|
-
backgroundOrigin: "border-box",
|
|
6739
|
-
backgroundClip: "border-box",
|
|
6740
|
-
WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
6741
|
-
WebkitMaskComposite: "xor",
|
|
6742
|
-
mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
6743
|
-
maskComposite: "exclude"
|
|
6987
|
+
}
|
|
6988
|
+
|
|
6989
|
+
// src/services/index.ts
|
|
6990
|
+
init_auth();
|
|
6991
|
+
init_config();
|
|
6992
|
+
init_config();
|
|
6993
|
+
init_auth();
|
|
6994
|
+
|
|
6995
|
+
// src/utils/urlSanitizer.ts
|
|
6996
|
+
var DEFAULT_SENSITIVE = ["token", "access_token", "auth", "auth_token"];
|
|
6997
|
+
function removeSensitiveParamsFromUrl(opts) {
|
|
6998
|
+
if (typeof window === "undefined") return;
|
|
6999
|
+
try {
|
|
7000
|
+
const { clearAll, sensitiveParams, includeHash = true, onChanged } = opts || {};
|
|
7001
|
+
const sens = (sensitiveParams && sensitiveParams.length > 0 ? sensitiveParams : DEFAULT_SENSITIVE).map((s) => s.toLowerCase());
|
|
7002
|
+
const before = window.location.href;
|
|
7003
|
+
const url = new URL(before);
|
|
7004
|
+
if (clearAll) {
|
|
7005
|
+
url.search = "";
|
|
7006
|
+
} else if (url.search) {
|
|
7007
|
+
let changed = false;
|
|
7008
|
+
for (const [k] of url.searchParams) {
|
|
7009
|
+
if (sens.includes(k.toLowerCase())) {
|
|
7010
|
+
url.searchParams.delete(k);
|
|
7011
|
+
changed = true;
|
|
6744
7012
|
}
|
|
6745
7013
|
}
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
{
|
|
6750
|
-
icon: iconConfig.icon,
|
|
6751
|
-
width: 16,
|
|
6752
|
-
height: 16,
|
|
6753
|
-
className: iconConfig.color,
|
|
6754
|
-
style: {
|
|
6755
|
-
color: themeConfig.gradientColor
|
|
6756
|
-
}
|
|
7014
|
+
if (changed) {
|
|
7015
|
+
const qs = url.searchParams.toString();
|
|
7016
|
+
url.search = qs ? `?${qs}` : "";
|
|
6757
7017
|
}
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
children: title
|
|
6769
|
-
}
|
|
6770
|
-
),
|
|
6771
|
-
message && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6772
|
-
"div",
|
|
6773
|
-
{
|
|
6774
|
-
className: "text-[13px] font-normal leading-relaxed drop-shadow-sm",
|
|
6775
|
-
style: {
|
|
6776
|
-
color: getTextColor(),
|
|
6777
|
-
backgroundClip: "text"
|
|
6778
|
-
},
|
|
6779
|
-
children: message
|
|
6780
|
-
}
|
|
6781
|
-
)
|
|
6782
|
-
] }),
|
|
6783
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseButton, { closeToast: handleClose }) })
|
|
6784
|
-
] });
|
|
6785
|
-
};
|
|
6786
|
-
var defaultToastOptions = {
|
|
6787
|
-
position: "bottom-right",
|
|
6788
|
-
autoClose: 3e3,
|
|
6789
|
-
hideProgressBar: true,
|
|
6790
|
-
closeOnClick: false,
|
|
6791
|
-
pauseOnHover: true,
|
|
6792
|
-
draggable: true,
|
|
6793
|
-
pauseOnFocusLoss: false,
|
|
6794
|
-
theme: "dark",
|
|
6795
|
-
transition: import_react_toastify2.Bounce
|
|
6796
|
-
};
|
|
6797
|
-
var createToast = (type) => {
|
|
6798
|
-
return (params) => {
|
|
6799
|
-
const { title, message, component, options } = params;
|
|
6800
|
-
(0, import_react_toastify2.toast)(
|
|
6801
|
-
({ closeToast }) => {
|
|
6802
|
-
if (params.render) return params.render(closeToast);
|
|
6803
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6804
|
-
ToastContent,
|
|
6805
|
-
{
|
|
6806
|
-
type,
|
|
6807
|
-
title,
|
|
6808
|
-
message: message || "",
|
|
6809
|
-
component,
|
|
6810
|
-
closeToast
|
|
7018
|
+
}
|
|
7019
|
+
if (includeHash && url.hash) {
|
|
7020
|
+
const raw = url.hash.slice(1);
|
|
7021
|
+
if (raw.includes("=")) {
|
|
7022
|
+
const hp = new URLSearchParams(raw);
|
|
7023
|
+
let changed = false;
|
|
7024
|
+
for (const [k] of hp) {
|
|
7025
|
+
if (clearAll || sens.includes(k.toLowerCase())) {
|
|
7026
|
+
hp.delete(k);
|
|
7027
|
+
changed = true;
|
|
6811
7028
|
}
|
|
6812
|
-
);
|
|
6813
|
-
},
|
|
6814
|
-
{
|
|
6815
|
-
...defaultToastOptions,
|
|
6816
|
-
...options,
|
|
6817
|
-
// 确保圆角样式不被覆盖,添加 rounded-xl 类
|
|
6818
|
-
className: "!p-0 !shadow-none !rounded-xl",
|
|
6819
|
-
style: { padding: 0, borderRadius: "0.75rem" }
|
|
6820
|
-
}
|
|
6821
|
-
);
|
|
6822
|
-
};
|
|
6823
|
-
};
|
|
6824
|
-
var ClayxToast = {
|
|
6825
|
-
success: createToast("success"),
|
|
6826
|
-
error: createToast("error"),
|
|
6827
|
-
warning: createToast("warning"),
|
|
6828
|
-
info: createToast("info"),
|
|
6829
|
-
default: createToast("default")
|
|
6830
|
-
};
|
|
6831
|
-
|
|
6832
|
-
// src/components/ui/LimitUpgradeToast.tsx
|
|
6833
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
6834
|
-
var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
|
|
6835
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative w-full max-w-[420px] overflow-hidden rounded-md bg-gradient-to-br from-[#1A1A1A] via-[#151515] to-[#1A1A1A] shadow-[0_20px_60px_rgba(168,85,247,0.2)] backdrop-blur-sm", children: [
|
|
6836
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6837
|
-
"div",
|
|
6838
|
-
{
|
|
6839
|
-
className: "absolute left-0 top-0 w-full h-full rounded-md",
|
|
6840
|
-
style: {
|
|
6841
|
-
background: "#0f1419",
|
|
6842
|
-
zIndex: -2
|
|
6843
7029
|
}
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
"div",
|
|
6848
|
-
{
|
|
6849
|
-
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-md",
|
|
6850
|
-
style: {
|
|
6851
|
-
background: `linear-gradient(135deg, rgba(168,85,247,0.3) 0%, rgba(168,85,247,0.2) 15%, #1A1A1A 30%)`,
|
|
6852
|
-
zIndex: -1
|
|
7030
|
+
if (changed) {
|
|
7031
|
+
const hs = hp.toString();
|
|
7032
|
+
url.hash = hs ? `#${hs}` : "";
|
|
6853
7033
|
}
|
|
6854
|
-
}
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-md",
|
|
6860
|
-
style: {
|
|
6861
|
-
border: "2px solid transparent",
|
|
6862
|
-
backgroundImage: `linear-gradient(135deg, rgba(168,85,247,0.6) 0%, rgba(168,85,247,0.4) 5%, transparent 22%)`,
|
|
6863
|
-
backgroundOrigin: "border-box",
|
|
6864
|
-
backgroundClip: "border-box",
|
|
6865
|
-
WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
6866
|
-
WebkitMaskComposite: "xor",
|
|
6867
|
-
mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
6868
|
-
maskComposite: "exclude"
|
|
7034
|
+
} else {
|
|
7035
|
+
if (!clearAll && sens.some((p) => raw.toLowerCase().startsWith(p))) {
|
|
7036
|
+
url.hash = "";
|
|
7037
|
+
} else if (clearAll) {
|
|
7038
|
+
url.hash = "";
|
|
6869
7039
|
}
|
|
6870
7040
|
}
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
7041
|
+
}
|
|
7042
|
+
const next = url.pathname + url.search + url.hash;
|
|
7043
|
+
if (next !== window.location.pathname + window.location.search + window.location.hash) {
|
|
7044
|
+
window.history.replaceState(window.history.state, document.title, next);
|
|
7045
|
+
onChanged && onChanged(next);
|
|
7046
|
+
}
|
|
7047
|
+
} catch (e) {
|
|
7048
|
+
console.warn("[howone][urlSanitizer] failed", e);
|
|
7049
|
+
}
|
|
7050
|
+
}
|
|
7051
|
+
|
|
7052
|
+
// src/services/index.ts
|
|
7053
|
+
function getGlobalAvailableToken() {
|
|
7054
|
+
try {
|
|
7055
|
+
return getToken() || null;
|
|
7056
|
+
} catch {
|
|
7057
|
+
return null;
|
|
7058
|
+
}
|
|
7059
|
+
}
|
|
7060
|
+
function wrapRequestWithProjectPrefix(biz, projectId) {
|
|
7061
|
+
if (!projectId) return biz;
|
|
7062
|
+
const prefix = `/entities/apps/${String(projectId)}`;
|
|
7063
|
+
function shouldPrefix(url) {
|
|
7064
|
+
if (!url) return false;
|
|
7065
|
+
const u = String(url);
|
|
7066
|
+
if (u.startsWith(prefix)) return false;
|
|
7067
|
+
if (/^https?:\/\//.test(u) || u.startsWith("//")) return false;
|
|
7068
|
+
if (u.startsWith("/data")) return true;
|
|
7069
|
+
return false;
|
|
7070
|
+
}
|
|
7071
|
+
const wrapped = {
|
|
7072
|
+
instance: biz.instance,
|
|
7073
|
+
request: (config) => {
|
|
7074
|
+
try {
|
|
7075
|
+
if (config && typeof config.url === "string" && shouldPrefix(config.url)) {
|
|
7076
|
+
config = { ...config, url: `${prefix}${config.url}` };
|
|
6905
7077
|
}
|
|
6906
|
-
)
|
|
6907
|
-
] }) })
|
|
6908
|
-
] });
|
|
6909
|
-
};
|
|
6910
|
-
function showLimitUpgradeToast(message, onUpgrade) {
|
|
6911
|
-
ClayxToast.default({
|
|
6912
|
-
render: (closeToast) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LimitToastContainer, { message, onUpgrade, closeToast }),
|
|
6913
|
-
options: {
|
|
6914
|
-
position: "bottom-right",
|
|
6915
|
-
closeOnClick: false,
|
|
6916
|
-
autoClose: false,
|
|
6917
|
-
hideProgressBar: true,
|
|
6918
|
-
draggable: false,
|
|
6919
|
-
pauseOnHover: true,
|
|
6920
|
-
className: "!bg-transparent !shadow-none",
|
|
6921
|
-
style: {
|
|
6922
|
-
background: "transparent",
|
|
6923
|
-
padding: 0,
|
|
6924
|
-
width: "auto",
|
|
6925
|
-
maxWidth: "420px"
|
|
7078
|
+
} catch (_e) {
|
|
6926
7079
|
}
|
|
6927
|
-
|
|
6928
|
-
|
|
7080
|
+
return biz.request(config);
|
|
7081
|
+
},
|
|
7082
|
+
get: (config) => wrapped.request({ ...config, method: "GET" }),
|
|
7083
|
+
post: (config) => wrapped.request({ ...config, method: "POST" }),
|
|
7084
|
+
put: (config) => wrapped.request({ ...config, method: "PUT" }),
|
|
7085
|
+
patch: (config) => wrapped.request({ ...config, method: "PATCH" }),
|
|
7086
|
+
delete: (config) => wrapped.request({ ...config, method: "DELETE" }),
|
|
7087
|
+
cancelRequest: (url) => biz.cancelRequest(url),
|
|
7088
|
+
cancelAllRequests: () => biz.cancelAllRequests()
|
|
7089
|
+
};
|
|
7090
|
+
return wrapped;
|
|
6929
7091
|
}
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
7092
|
+
function createClient(opts) {
|
|
7093
|
+
const envValue = opts.env || getGlobalEnvironment() || "prod";
|
|
7094
|
+
const env2 = setEnvironment(envValue);
|
|
7095
|
+
function makeRequestFromBase(base) {
|
|
7096
|
+
return new request_default({
|
|
7097
|
+
baseURL: base,
|
|
7098
|
+
timeout: 6e4,
|
|
7099
|
+
interceptors: {
|
|
7100
|
+
requestInterceptor: (config) => {
|
|
7101
|
+
config.headers = config.headers || {};
|
|
7102
|
+
if (!config.headers["Authorization"]) {
|
|
7103
|
+
const availableToken = getAvailableToken();
|
|
7104
|
+
if (availableToken) {
|
|
7105
|
+
config.headers["Authorization"] = `Bearer ${availableToken}`;
|
|
7106
|
+
}
|
|
7107
|
+
}
|
|
7108
|
+
return config;
|
|
7109
|
+
},
|
|
7110
|
+
requestInterceptorCatch: (err) => Promise.reject(err),
|
|
7111
|
+
responseInterceptor: (res) => {
|
|
7112
|
+
const data = res.data;
|
|
7113
|
+
if (data && data.status && data.status === 4003) {
|
|
7114
|
+
showLimitUpgradeToast(
|
|
7115
|
+
"Your credits are exhausted. Please upgrade your plan to continue generating projects.",
|
|
7116
|
+
() => window.open(`${getEnvs().AUTH_ROOT_VALUE}/price`, "_blank")
|
|
7117
|
+
);
|
|
7118
|
+
return res;
|
|
7119
|
+
}
|
|
7120
|
+
return res;
|
|
7121
|
+
},
|
|
7122
|
+
responseInterceptorCatch: (err) => Promise.reject(err)
|
|
7123
|
+
}
|
|
7124
|
+
});
|
|
6938
7125
|
}
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
return
|
|
7126
|
+
const biz = makeRequestFromBase(env2.baseUrl);
|
|
7127
|
+
const ai = makeRequestFromBase(env2.aiBaseUrl);
|
|
7128
|
+
const bizWrapped = wrapRequestWithProjectPrefix(biz, opts?.projectId);
|
|
7129
|
+
let token = null;
|
|
7130
|
+
function getAvailableToken() {
|
|
7131
|
+
return token || getGlobalAvailableToken();
|
|
6945
7132
|
}
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
} catch (_e) {
|
|
6950
|
-
return null;
|
|
7133
|
+
try {
|
|
7134
|
+
if (opts?.projectId) {
|
|
7135
|
+
setDefaultProjectId(String(opts.projectId));
|
|
6951
7136
|
}
|
|
7137
|
+
} catch {
|
|
6952
7138
|
}
|
|
6953
|
-
|
|
6954
|
-
* 按 ID 执行工作流:POST {baseUrl}/workflow/{workflowId}/execute
|
|
6955
|
-
* body: { input, options }
|
|
6956
|
-
*/
|
|
6957
|
-
async executeWorkflow(workflowId, inputs, options) {
|
|
6958
|
-
if (!this.baseUrl) {
|
|
6959
|
-
throw new Error("AI workflow client requires a baseUrl (e.g. https://evoagentx-server.fly.dev)");
|
|
6960
|
-
}
|
|
6961
|
-
const url = `${this.baseUrl}/workflow/${workflowId}/execute`;
|
|
7139
|
+
function applyToken(t) {
|
|
6962
7140
|
try {
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
showLimitUpgradeToast(
|
|
6974
|
-
"Your credits are exhausted. Please upgrade your plan to continue generating projects.",
|
|
6975
|
-
() => window.open("https://clayx.ai/pricing", "_blank")
|
|
6976
|
-
);
|
|
6977
|
-
return null;
|
|
7141
|
+
try {
|
|
7142
|
+
if (biz && biz.instance) {
|
|
7143
|
+
if (t) biz.instance.defaults.headers.common["Authorization"] = `Bearer ${t}`;
|
|
7144
|
+
else delete biz.instance.defaults.headers.common["Authorization"];
|
|
7145
|
+
}
|
|
7146
|
+
if (ai && ai.instance) {
|
|
7147
|
+
if (t) ai.instance.defaults.headers.common["Authorization"] = `Bearer ${t}`;
|
|
7148
|
+
else delete ai.instance.defaults.headers.common["Authorization"];
|
|
7149
|
+
}
|
|
7150
|
+
} catch (_e) {
|
|
6978
7151
|
}
|
|
6979
|
-
|
|
6980
|
-
} catch (error) {
|
|
6981
|
-
return { success: false, error: error instanceof Error ? error.message : "Network error" };
|
|
7152
|
+
} catch (_e) {
|
|
6982
7153
|
}
|
|
6983
7154
|
}
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
}
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
this.instance = import_axios.default.create({
|
|
6996
|
-
...config,
|
|
6997
|
-
validateStatus: (status) => {
|
|
6998
|
-
return status >= 200 && status < 300;
|
|
7155
|
+
const workflowRequestWrapped = {
|
|
7156
|
+
get: ai.get.bind(ai),
|
|
7157
|
+
post: (config) => {
|
|
7158
|
+
const modifiedConfig = { ...config };
|
|
7159
|
+
if (opts?.projectId && modifiedConfig.url) {
|
|
7160
|
+
const workflowPattern = /^\/?(?:workflow\/)?([^\/]+)\/execute/;
|
|
7161
|
+
const match = modifiedConfig.url.match(workflowPattern);
|
|
7162
|
+
if (match) {
|
|
7163
|
+
const workflowId = match[1];
|
|
7164
|
+
modifiedConfig.url = `/workflow/${opts.projectId}/${workflowId}/execute`;
|
|
7165
|
+
}
|
|
6999
7166
|
}
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
)
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7167
|
+
return ai.post(modifiedConfig);
|
|
7168
|
+
},
|
|
7169
|
+
put: ai.put.bind(ai),
|
|
7170
|
+
delete: ai.delete.bind(ai),
|
|
7171
|
+
request: ai.request.bind(ai),
|
|
7172
|
+
cancelRequest: ai.cancelRequest?.bind(ai),
|
|
7173
|
+
cancelAllRequests: ai.cancelAllRequests?.bind(ai)
|
|
7174
|
+
};
|
|
7175
|
+
return {
|
|
7176
|
+
// expose projectId so consumers can read it from the client instance
|
|
7177
|
+
projectId: opts?.projectId ?? null,
|
|
7178
|
+
request: bizWrapped,
|
|
7179
|
+
aiRequest: ai,
|
|
7180
|
+
workflowRequest: workflowRequestWrapped,
|
|
7181
|
+
// artifact helpers using artifacts-client
|
|
7182
|
+
artifacts: createArtifactsClient(biz),
|
|
7183
|
+
me: async () => {
|
|
7184
|
+
try {
|
|
7185
|
+
const t = token ?? (opts?.auth?.getToken ? await opts.auth.getToken() : null) ?? getToken();
|
|
7186
|
+
if (!t) return null;
|
|
7187
|
+
return parseUserFromToken(t);
|
|
7188
|
+
} catch (_e2) {
|
|
7189
|
+
return null;
|
|
7016
7190
|
}
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7191
|
+
},
|
|
7192
|
+
// auth helpers
|
|
7193
|
+
auth: {
|
|
7194
|
+
setToken: (t) => {
|
|
7195
|
+
token = t;
|
|
7196
|
+
applyToken(t);
|
|
7021
7197
|
},
|
|
7022
|
-
(
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7198
|
+
getToken: () => token,
|
|
7199
|
+
isAuthenticated: () => Boolean(token),
|
|
7200
|
+
// minimal login/logout stubs - consumers can override behavior
|
|
7201
|
+
login: (redirect) => {
|
|
7202
|
+
if (typeof window === "undefined") return;
|
|
7203
|
+
const loc = redirect || window.location.href;
|
|
7204
|
+
try {
|
|
7205
|
+
const root = env2.baseUrl;
|
|
7206
|
+
const authUrl = new URL("/auth", String(root));
|
|
7207
|
+
authUrl.searchParams.set("redirect_uri", String(loc));
|
|
7208
|
+
if (opts?.projectId) authUrl.searchParams.set("project_id", String(opts.projectId));
|
|
7209
|
+
window.location.href = authUrl.toString();
|
|
7210
|
+
} catch {
|
|
7211
|
+
const encoded = encodeURIComponent(String(loc));
|
|
7212
|
+
const pid = opts?.projectId ? `&project_id=${encodeURIComponent(String(opts.projectId))}` : "";
|
|
7213
|
+
const root = env2.baseUrl;
|
|
7214
|
+
window.location.href = `${root}/auth?redirect_uri=${encoded}${pid}`;
|
|
7032
7215
|
}
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
cancelRequest(url) {
|
|
7038
|
-
this.abortControllers.forEach((controller, key) => {
|
|
7039
|
-
if (key.includes(url)) {
|
|
7040
|
-
controller.abort();
|
|
7041
|
-
this.abortControllers.delete(key);
|
|
7216
|
+
},
|
|
7217
|
+
logout: () => {
|
|
7218
|
+
token = null;
|
|
7219
|
+
applyToken(null);
|
|
7042
7220
|
}
|
|
7043
|
-
}
|
|
7221
|
+
},
|
|
7222
|
+
sanitizeUrl: (o) => {
|
|
7223
|
+
if (typeof window === "undefined") return;
|
|
7224
|
+
removeSensitiveParamsFromUrl({
|
|
7225
|
+
clearAll: o?.clearAll,
|
|
7226
|
+
sensitiveParams: o?.sensitiveParams
|
|
7227
|
+
});
|
|
7228
|
+
}
|
|
7229
|
+
};
|
|
7230
|
+
}
|
|
7231
|
+
|
|
7232
|
+
// src/hooks/use-mobile.ts
|
|
7233
|
+
var React8 = __toESM(require("react"));
|
|
7234
|
+
var MOBILE_BREAKPOINT = 768;
|
|
7235
|
+
function useIsMobile() {
|
|
7236
|
+
const [isMobile, setIsMobile] = React8.useState(void 0);
|
|
7237
|
+
React8.useEffect(() => {
|
|
7238
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
7239
|
+
const onChange = () => {
|
|
7240
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
7241
|
+
};
|
|
7242
|
+
mql.addEventListener("change", onChange);
|
|
7243
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
7244
|
+
return () => mql.removeEventListener("change", onChange);
|
|
7245
|
+
}, []);
|
|
7246
|
+
return !!isMobile;
|
|
7247
|
+
}
|
|
7248
|
+
|
|
7249
|
+
// src/hooks/use-debounce.ts
|
|
7250
|
+
var import_react14 = require("react");
|
|
7251
|
+
function useDebounce(value, delay) {
|
|
7252
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
|
|
7253
|
+
(0, import_react14.useEffect)(() => {
|
|
7254
|
+
const handler = setTimeout(() => {
|
|
7255
|
+
setDebouncedValue(value);
|
|
7256
|
+
}, delay);
|
|
7257
|
+
return () => {
|
|
7258
|
+
clearTimeout(handler);
|
|
7259
|
+
};
|
|
7260
|
+
}, [value, delay]);
|
|
7261
|
+
return debouncedValue;
|
|
7262
|
+
}
|
|
7263
|
+
|
|
7264
|
+
// src/utils/unified-error-handler/simple.ts
|
|
7265
|
+
var SimpleErrorHandler = class {
|
|
7266
|
+
constructor() {
|
|
7267
|
+
this.initialized = false;
|
|
7044
7268
|
}
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7269
|
+
// 使用明确赋值断言,因为在 init() 方法中会初始化
|
|
7270
|
+
/**
|
|
7271
|
+
* 初始化错误处理器
|
|
7272
|
+
*/
|
|
7273
|
+
init() {
|
|
7274
|
+
if (this.initialized) return;
|
|
7275
|
+
this.sendMessage = createSimpleSendFunction({
|
|
7276
|
+
addTimestamp: false,
|
|
7277
|
+
// 简化版自己处理时间戳
|
|
7278
|
+
enableDebugLog: false
|
|
7048
7279
|
});
|
|
7049
|
-
this.
|
|
7280
|
+
this.setupErrorListeners();
|
|
7281
|
+
this.setupCompatibility();
|
|
7282
|
+
this.initialized = true;
|
|
7050
7283
|
}
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
}
|
|
7062
|
-
this.instance.request(config).then((res) => {
|
|
7063
|
-
this.abortControllers.delete(key);
|
|
7064
|
-
if (config.interceptors?.responseInterceptor) {
|
|
7065
|
-
res = config.interceptors.responseInterceptor(res);
|
|
7066
|
-
}
|
|
7067
|
-
resolve(res);
|
|
7068
|
-
}).catch((err) => {
|
|
7069
|
-
this.abortControllers.delete(key);
|
|
7070
|
-
reject(err);
|
|
7284
|
+
/**
|
|
7285
|
+
* 设置错误监听器
|
|
7286
|
+
*/
|
|
7287
|
+
setupErrorListeners() {
|
|
7288
|
+
window.addEventListener("error", (event) => {
|
|
7289
|
+
this.sendError(event.error || new Error(event.message), {
|
|
7290
|
+
filename: event.filename,
|
|
7291
|
+
lineno: event.lineno,
|
|
7292
|
+
colno: event.colno,
|
|
7293
|
+
type: "runtime"
|
|
7071
7294
|
});
|
|
7072
7295
|
});
|
|
7296
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
7297
|
+
const error = event.reason instanceof Error ? event.reason : new Error(String(event.reason));
|
|
7298
|
+
this.sendError(error, { type: "promise" });
|
|
7299
|
+
});
|
|
7073
7300
|
}
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7301
|
+
/**
|
|
7302
|
+
* 设置兼容性函数
|
|
7303
|
+
*/
|
|
7304
|
+
setupCompatibility() {
|
|
7305
|
+
window.__SEND_ERROR_TO_PARENT__ = (error, details) => {
|
|
7306
|
+
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
7307
|
+
this.sendError(errorObj, details);
|
|
7308
|
+
};
|
|
7082
7309
|
}
|
|
7083
|
-
|
|
7084
|
-
|
|
7310
|
+
/**
|
|
7311
|
+
* 发送错误到父窗口
|
|
7312
|
+
*/
|
|
7313
|
+
sendError(error, details = {}) {
|
|
7314
|
+
const payload = {
|
|
7315
|
+
message: error.message,
|
|
7316
|
+
stack: error.stack,
|
|
7317
|
+
filename: details.filename || details.file,
|
|
7318
|
+
lineno: details.lineno || details.line,
|
|
7319
|
+
colno: details.colno || details.column,
|
|
7320
|
+
timestamp: Date.now(),
|
|
7321
|
+
type: details.type || "unknown",
|
|
7322
|
+
severity: "medium",
|
|
7323
|
+
// 简化版使用默认严重性级别
|
|
7324
|
+
details
|
|
7325
|
+
};
|
|
7326
|
+
try {
|
|
7327
|
+
this.sendMessage({
|
|
7328
|
+
type: "ERROR_EVENT",
|
|
7329
|
+
payload,
|
|
7330
|
+
timestamp: Date.now()
|
|
7331
|
+
});
|
|
7332
|
+
} catch (e) {
|
|
7333
|
+
const originalConsole = window.__originalConsole;
|
|
7334
|
+
if (originalConsole?.error) {
|
|
7335
|
+
originalConsole.error("[\u7B80\u5316\u9519\u8BEF\u5904\u7406] \u53D1\u9001\u5931\u8D25:", e);
|
|
7336
|
+
}
|
|
7337
|
+
}
|
|
7085
7338
|
}
|
|
7086
|
-
|
|
7087
|
-
|
|
7339
|
+
/**
|
|
7340
|
+
* 手动捕获错误
|
|
7341
|
+
*/
|
|
7342
|
+
captureError(error, details) {
|
|
7343
|
+
this.sendError(error, details);
|
|
7088
7344
|
}
|
|
7089
7345
|
};
|
|
7090
|
-
var request_default = Request;
|
|
7091
7346
|
|
|
7092
|
-
// src/
|
|
7093
|
-
|
|
7094
|
-
const basePath = options.basePath ?? "/api";
|
|
7095
|
-
const baseUrl = (options.baseUrl || "https://evoagentx-server.fly.dev").replace(/\/+$/, "");
|
|
7096
|
-
const baseAPI = `${baseUrl}${basePath.startsWith("/") ? "" : "/"}${basePath}`.replace(/\/+$/, "");
|
|
7097
|
-
const client = options.requestInstance || new request_default({
|
|
7098
|
-
baseURL: baseAPI,
|
|
7099
|
-
timeout: options.timeout ?? 6e4,
|
|
7100
|
-
interceptors: {
|
|
7101
|
-
requestInterceptor: (config) => {
|
|
7102
|
-
config.headers = config.headers || {};
|
|
7103
|
-
if (options.apiKey && !config.headers["Authorization"]) {
|
|
7104
|
-
config.headers["Authorization"] = `Bearer ${options.apiKey}`;
|
|
7105
|
-
}
|
|
7106
|
-
if (options.headers) {
|
|
7107
|
-
config.headers = { ...config.headers || {}, ...options.headers };
|
|
7108
|
-
}
|
|
7109
|
-
return config;
|
|
7110
|
-
},
|
|
7111
|
-
requestInterceptorCatch: (err) => Promise.reject(err),
|
|
7112
|
-
responseInterceptor: (res) => res,
|
|
7113
|
-
responseInterceptorCatch: (err) => Promise.reject(err)
|
|
7114
|
-
}
|
|
7115
|
-
});
|
|
7116
|
-
return {
|
|
7117
|
-
async executeWorkflow(workflowId, inputs, opts) {
|
|
7118
|
-
const url = `${baseUrl}/workflow/${workflowId}/execute`;
|
|
7119
|
-
const data = await client.post({ url, data: { inputs, options: opts } });
|
|
7120
|
-
return data;
|
|
7121
|
-
}
|
|
7122
|
-
};
|
|
7123
|
-
}
|
|
7347
|
+
// src/index.ts
|
|
7348
|
+
init_config();
|
|
7124
7349
|
|
|
7125
|
-
// src/
|
|
7126
|
-
function
|
|
7127
|
-
if (
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
}
|
|
7134
|
-
if (a.visibility === "private") {
|
|
7135
|
-
if (ctx.userId && a.ownerId && ctx.userId === a.ownerId) return true;
|
|
7136
|
-
if (ctx.tokenScopes && (ctx.tokenScopes.includes("artifact:read:all") || ctx.tokenScopes.includes("admin"))) return true;
|
|
7137
|
-
return false;
|
|
7350
|
+
// src/utils/iframe-navigation.ts
|
|
7351
|
+
function getNavState() {
|
|
7352
|
+
if (typeof window === "undefined") {
|
|
7353
|
+
return {
|
|
7354
|
+
navigationHistory: [],
|
|
7355
|
+
currentHistoryIndex: -1,
|
|
7356
|
+
initialized: false
|
|
7357
|
+
};
|
|
7138
7358
|
}
|
|
7139
|
-
if (
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7359
|
+
if (!window.customNavigationState) {
|
|
7360
|
+
window.customNavigationState = {
|
|
7361
|
+
navigationHistory: [],
|
|
7362
|
+
currentHistoryIndex: -1,
|
|
7363
|
+
initialized: false
|
|
7364
|
+
};
|
|
7143
7365
|
}
|
|
7144
|
-
return
|
|
7366
|
+
return window.customNavigationState;
|
|
7145
7367
|
}
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
return await req.get({ url: `/artifacts/${encodeURIComponent(id)}` });
|
|
7158
|
-
},
|
|
7159
|
-
async setVisibility(id, visibility) {
|
|
7160
|
-
await req.patch({ url: `/artifacts/${encodeURIComponent(id)}/visibility`, data: { visibility } });
|
|
7161
|
-
},
|
|
7162
|
-
async delete(id) {
|
|
7163
|
-
await req.delete({ url: `/artifacts/${encodeURIComponent(id)}` });
|
|
7164
|
-
},
|
|
7165
|
-
// convenience local check (server is authoritative)
|
|
7166
|
-
canAccessLocal(a, ctx) {
|
|
7167
|
-
if (!a) return false;
|
|
7168
|
-
if (a.visibility === "public") return true;
|
|
7169
|
-
if (a.visibility === "project") return Boolean(ctx.projectId && a.projectId && ctx.projectId === a.projectId);
|
|
7170
|
-
if (a.visibility === "private") return Boolean(ctx.userId && a.ownerId && ctx.userId === a.ownerId);
|
|
7171
|
-
if (a.visibility === "shared") return Boolean(ctx.userId && a.sharedWith && a.sharedWith.includes(ctx.userId));
|
|
7172
|
-
return false;
|
|
7173
|
-
}
|
|
7174
|
-
};
|
|
7368
|
+
function getElementSelectorState() {
|
|
7369
|
+
if (typeof window === "undefined") {
|
|
7370
|
+
return { active: false, callback: null };
|
|
7371
|
+
}
|
|
7372
|
+
if (!window.elementSelectorState) {
|
|
7373
|
+
window.elementSelectorState = {
|
|
7374
|
+
active: false,
|
|
7375
|
+
callback: null
|
|
7376
|
+
};
|
|
7377
|
+
}
|
|
7378
|
+
return window.elementSelectorState;
|
|
7175
7379
|
}
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
const { clearAll, sensitiveParams, includeHash = true, onChanged } = opts || {};
|
|
7189
|
-
const sens = (sensitiveParams && sensitiveParams.length > 0 ? sensitiveParams : DEFAULT_SENSITIVE).map((s) => s.toLowerCase());
|
|
7190
|
-
const before = window.location.href;
|
|
7191
|
-
const url = new URL(before);
|
|
7192
|
-
if (clearAll) {
|
|
7193
|
-
url.search = "";
|
|
7194
|
-
} else if (url.search) {
|
|
7195
|
-
let changed = false;
|
|
7196
|
-
for (const [k] of url.searchParams) {
|
|
7197
|
-
if (sens.includes(k.toLowerCase())) {
|
|
7198
|
-
url.searchParams.delete(k);
|
|
7199
|
-
changed = true;
|
|
7200
|
-
}
|
|
7201
|
-
}
|
|
7202
|
-
if (changed) {
|
|
7203
|
-
const qs = url.searchParams.toString();
|
|
7204
|
-
url.search = qs ? `?${qs}` : "";
|
|
7205
|
-
}
|
|
7380
|
+
function sendNavigationState(targetWindow, targetOrigin) {
|
|
7381
|
+
const navState = getNavState();
|
|
7382
|
+
const canGoBack = navState.currentHistoryIndex > 0;
|
|
7383
|
+
const canGoForward = navState.currentHistoryIndex < navState.navigationHistory.length - 1;
|
|
7384
|
+
const state = {
|
|
7385
|
+
type: "NAVIGATION_STATE",
|
|
7386
|
+
payload: {
|
|
7387
|
+
canGoBack,
|
|
7388
|
+
canGoForward,
|
|
7389
|
+
historyLength: navState.navigationHistory.length,
|
|
7390
|
+
currentIndex: navState.currentHistoryIndex,
|
|
7391
|
+
maxIndex: navState.navigationHistory.length - 1
|
|
7206
7392
|
}
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
hp.delete(k);
|
|
7215
|
-
changed = true;
|
|
7216
|
-
}
|
|
7217
|
-
}
|
|
7218
|
-
if (changed) {
|
|
7219
|
-
const hs = hp.toString();
|
|
7220
|
-
url.hash = hs ? `#${hs}` : "";
|
|
7221
|
-
}
|
|
7222
|
-
} else {
|
|
7223
|
-
if (!clearAll && sens.some((p) => raw.toLowerCase().startsWith(p))) {
|
|
7224
|
-
url.hash = "";
|
|
7225
|
-
} else if (clearAll) {
|
|
7226
|
-
url.hash = "";
|
|
7227
|
-
}
|
|
7393
|
+
};
|
|
7394
|
+
if (targetWindow && targetOrigin) {
|
|
7395
|
+
try {
|
|
7396
|
+
targetWindow.postMessage(state, targetOrigin);
|
|
7397
|
+
} catch (e) {
|
|
7398
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
7399
|
+
console.warn("Failed to send navigation state:", e.message);
|
|
7228
7400
|
}
|
|
7229
7401
|
}
|
|
7230
|
-
const next = url.pathname + url.search + url.hash;
|
|
7231
|
-
if (next !== window.location.pathname + window.location.search + window.location.hash) {
|
|
7232
|
-
window.history.replaceState(window.history.state, document.title, next);
|
|
7233
|
-
onChanged && onChanged(next);
|
|
7234
|
-
}
|
|
7235
|
-
} catch (e) {
|
|
7236
|
-
console.warn("[howone][urlSanitizer] failed", e);
|
|
7237
7402
|
}
|
|
7238
7403
|
}
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7404
|
+
function addToNavigationHistory(url, title) {
|
|
7405
|
+
const navState = getNavState();
|
|
7406
|
+
if (navState.currentHistoryIndex < navState.navigationHistory.length - 1) {
|
|
7407
|
+
navState.navigationHistory = navState.navigationHistory.slice(
|
|
7408
|
+
0,
|
|
7409
|
+
navState.currentHistoryIndex + 1
|
|
7410
|
+
);
|
|
7246
7411
|
}
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
const prefix = `/entities/apps/${String(projectId)}`;
|
|
7251
|
-
function shouldPrefix(url) {
|
|
7252
|
-
if (!url) return false;
|
|
7253
|
-
const u = String(url);
|
|
7254
|
-
if (u.startsWith(prefix)) return false;
|
|
7255
|
-
if (/^https?:\/\//.test(u) || u.startsWith("//")) return false;
|
|
7256
|
-
if (u.startsWith("/data")) return true;
|
|
7257
|
-
return false;
|
|
7412
|
+
const currentPage = navState.navigationHistory[navState.currentHistoryIndex];
|
|
7413
|
+
if (currentPage && currentPage.url === url) {
|
|
7414
|
+
return;
|
|
7258
7415
|
}
|
|
7259
|
-
const
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
if (config && typeof config.url === "string" && shouldPrefix(config.url)) {
|
|
7264
|
-
config = { ...config, url: `${prefix}${config.url}` };
|
|
7265
|
-
}
|
|
7266
|
-
} catch (_e) {
|
|
7267
|
-
}
|
|
7268
|
-
return biz.request(config);
|
|
7269
|
-
},
|
|
7270
|
-
get: (config) => wrapped.request({ ...config, method: "GET" }),
|
|
7271
|
-
post: (config) => wrapped.request({ ...config, method: "POST" }),
|
|
7272
|
-
put: (config) => wrapped.request({ ...config, method: "PUT" }),
|
|
7273
|
-
patch: (config) => wrapped.request({ ...config, method: "PATCH" }),
|
|
7274
|
-
delete: (config) => wrapped.request({ ...config, method: "DELETE" }),
|
|
7275
|
-
cancelRequest: (url) => biz.cancelRequest(url),
|
|
7276
|
-
cancelAllRequests: () => biz.cancelAllRequests()
|
|
7416
|
+
const pageInfo = {
|
|
7417
|
+
url,
|
|
7418
|
+
title: title || (typeof document !== "undefined" ? document.title : "") || url,
|
|
7419
|
+
timestamp: Date.now()
|
|
7277
7420
|
};
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
const env2 = setEnvironment(envValue);
|
|
7283
|
-
function makeRequestFromBase(base) {
|
|
7284
|
-
return new request_default({
|
|
7285
|
-
baseURL: base,
|
|
7286
|
-
timeout: 6e4,
|
|
7287
|
-
interceptors: {
|
|
7288
|
-
requestInterceptor: (config) => {
|
|
7289
|
-
config.headers = config.headers || {};
|
|
7290
|
-
if (!config.headers["Authorization"]) {
|
|
7291
|
-
const availableToken = getAvailableToken();
|
|
7292
|
-
if (availableToken) {
|
|
7293
|
-
config.headers["Authorization"] = `Bearer ${availableToken}`;
|
|
7294
|
-
}
|
|
7295
|
-
}
|
|
7296
|
-
return config;
|
|
7297
|
-
},
|
|
7298
|
-
requestInterceptorCatch: (err) => Promise.reject(err),
|
|
7299
|
-
responseInterceptor: (res) => {
|
|
7300
|
-
const data = res.data;
|
|
7301
|
-
if (data && data.status && data.status === 4003) {
|
|
7302
|
-
showLimitUpgradeToast(
|
|
7303
|
-
"Your credits are exhausted. Please upgrade your plan to continue generating projects.",
|
|
7304
|
-
() => window.open(`${getEnvs().AUTH_ROOT_VALUE}/price`, "_blank")
|
|
7305
|
-
);
|
|
7306
|
-
return res;
|
|
7307
|
-
}
|
|
7308
|
-
return res;
|
|
7309
|
-
},
|
|
7310
|
-
responseInterceptorCatch: (err) => Promise.reject(err)
|
|
7311
|
-
}
|
|
7312
|
-
});
|
|
7421
|
+
navState.navigationHistory.push(pageInfo);
|
|
7422
|
+
navState.currentHistoryIndex = navState.navigationHistory.length - 1;
|
|
7423
|
+
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
7424
|
+
sendNavigationState(window.parent, "*");
|
|
7313
7425
|
}
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
const
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7426
|
+
}
|
|
7427
|
+
function customGoBack() {
|
|
7428
|
+
const navState = getNavState();
|
|
7429
|
+
if (navState.currentHistoryIndex > 0) {
|
|
7430
|
+
navState.currentHistoryIndex--;
|
|
7431
|
+
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
7432
|
+
sendNavigationState(window.parent, "*");
|
|
7433
|
+
}
|
|
7434
|
+
return true;
|
|
7320
7435
|
}
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7436
|
+
return false;
|
|
7437
|
+
}
|
|
7438
|
+
function customGoForward() {
|
|
7439
|
+
const navState = getNavState();
|
|
7440
|
+
if (navState.currentHistoryIndex < navState.navigationHistory.length - 1) {
|
|
7441
|
+
navState.currentHistoryIndex++;
|
|
7442
|
+
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
7443
|
+
sendNavigationState(window.parent, "*");
|
|
7324
7444
|
}
|
|
7325
|
-
|
|
7445
|
+
return true;
|
|
7326
7446
|
}
|
|
7327
|
-
|
|
7447
|
+
return false;
|
|
7448
|
+
}
|
|
7449
|
+
function triggerElementSelection() {
|
|
7450
|
+
if (typeof window === "undefined") return;
|
|
7451
|
+
const event = new CustomEvent("howone:start-element-selection");
|
|
7452
|
+
window.dispatchEvent(event);
|
|
7453
|
+
getElementSelectorState().active = true;
|
|
7454
|
+
}
|
|
7455
|
+
function cancelElementSelection() {
|
|
7456
|
+
if (typeof window === "undefined") return;
|
|
7457
|
+
const event = new CustomEvent("howone:cancel-element-selection");
|
|
7458
|
+
window.dispatchEvent(event);
|
|
7459
|
+
getElementSelectorState().active = false;
|
|
7460
|
+
}
|
|
7461
|
+
function handlePageChange() {
|
|
7462
|
+
if (typeof window === "undefined") return;
|
|
7463
|
+
const currentUrl = window.location.href;
|
|
7464
|
+
const currentTitle = document.title;
|
|
7465
|
+
addToNavigationHistory(currentUrl, currentTitle);
|
|
7466
|
+
}
|
|
7467
|
+
function initIframeNavigation() {
|
|
7468
|
+
if (typeof window === "undefined") return;
|
|
7469
|
+
const navState = getNavState();
|
|
7470
|
+
window.addEventListener("keydown", function(e) {
|
|
7471
|
+
if (e.key === "Escape" && getElementSelectorState().active) {
|
|
7472
|
+
cancelElementSelection();
|
|
7473
|
+
}
|
|
7474
|
+
});
|
|
7475
|
+
window.addEventListener("message", (event) => {
|
|
7328
7476
|
try {
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7477
|
+
const { type, payload } = event.data;
|
|
7478
|
+
switch (type) {
|
|
7479
|
+
case "NAVIGATE_BACK":
|
|
7480
|
+
case "GO_BACK":
|
|
7481
|
+
customGoBack();
|
|
7482
|
+
break;
|
|
7483
|
+
case "NAVIGATE_FORWARD":
|
|
7484
|
+
case "GO_FORWARD":
|
|
7485
|
+
customGoForward();
|
|
7486
|
+
break;
|
|
7487
|
+
case "REQUEST_NAVIGATION_STATE":
|
|
7488
|
+
case "CHECK_NAVIGATION_STATE":
|
|
7489
|
+
sendNavigationState(event.source, event.origin);
|
|
7490
|
+
break;
|
|
7491
|
+
case "START_ELEMENT_SELECTION":
|
|
7492
|
+
triggerElementSelection();
|
|
7493
|
+
break;
|
|
7494
|
+
case "ELEMENT_SELECTED":
|
|
7495
|
+
if (event.source && event.source !== window) {
|
|
7496
|
+
window.parent.postMessage(
|
|
7497
|
+
{
|
|
7498
|
+
type: "ELEMENT_SELECTED",
|
|
7499
|
+
payload
|
|
7500
|
+
},
|
|
7501
|
+
"*"
|
|
7502
|
+
);
|
|
7503
|
+
}
|
|
7504
|
+
break;
|
|
7505
|
+
case "CANCEL_ELEMENT_SELECTION":
|
|
7506
|
+
cancelElementSelection();
|
|
7507
|
+
break;
|
|
7508
|
+
}
|
|
7509
|
+
} catch (e) {
|
|
7510
|
+
}
|
|
7511
|
+
});
|
|
7512
|
+
window.addEventListener("popstate", () => {
|
|
7513
|
+
setTimeout(() => {
|
|
7514
|
+
if (window.parent && window.parent !== window) {
|
|
7515
|
+
sendNavigationState(window.parent, "*");
|
|
7516
|
+
}
|
|
7517
|
+
}, 50);
|
|
7518
|
+
});
|
|
7519
|
+
window.addEventListener("hashchange", () => {
|
|
7520
|
+
handlePageChange();
|
|
7521
|
+
});
|
|
7522
|
+
window.addEventListener("load", () => {
|
|
7523
|
+
if (!navState.initialized) {
|
|
7524
|
+
addToNavigationHistory(window.location.href, document.title);
|
|
7525
|
+
navState.initialized = true;
|
|
7526
|
+
}
|
|
7527
|
+
setTimeout(() => {
|
|
7528
|
+
if (window.parent && window.parent !== window) {
|
|
7529
|
+
sendNavigationState(window.parent, "*");
|
|
7530
|
+
}
|
|
7531
|
+
}, 500);
|
|
7532
|
+
});
|
|
7533
|
+
if (document.readyState === "loading") {
|
|
7534
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
7535
|
+
if (!navState.initialized) {
|
|
7536
|
+
addToNavigationHistory(window.location.href, document.title);
|
|
7537
|
+
navState.initialized = true;
|
|
7339
7538
|
}
|
|
7340
|
-
}
|
|
7341
|
-
|
|
7539
|
+
});
|
|
7540
|
+
} else if (!navState.initialized) {
|
|
7541
|
+
addToNavigationHistory(window.location.href, document.title);
|
|
7542
|
+
navState.initialized = true;
|
|
7342
7543
|
}
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
if (opts?.projectId && modifiedConfig.url) {
|
|
7348
|
-
const workflowPattern = /^\/?(?:workflow\/)?([^\/]+)\/execute/;
|
|
7349
|
-
const match = modifiedConfig.url.match(workflowPattern);
|
|
7350
|
-
if (match) {
|
|
7351
|
-
const workflowId = match[1];
|
|
7352
|
-
modifiedConfig.url = `/workflow/${opts.projectId}/${workflowId}/execute`;
|
|
7353
|
-
}
|
|
7354
|
-
}
|
|
7355
|
-
return ai.post(modifiedConfig);
|
|
7356
|
-
},
|
|
7357
|
-
put: ai.put.bind(ai),
|
|
7358
|
-
delete: ai.delete.bind(ai),
|
|
7359
|
-
request: ai.request.bind(ai),
|
|
7360
|
-
cancelRequest: ai.cancelRequest?.bind(ai),
|
|
7361
|
-
cancelAllRequests: ai.cancelAllRequests?.bind(ai)
|
|
7544
|
+
window.iframeElementSelector = {
|
|
7545
|
+
startSelection: function() {
|
|
7546
|
+
triggerElementSelection();
|
|
7547
|
+
}
|
|
7362
7548
|
};
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
// artifact helpers using artifacts-client
|
|
7370
|
-
artifacts: createArtifactsClient(biz),
|
|
7371
|
-
me: async () => {
|
|
7372
|
-
try {
|
|
7373
|
-
const t = token ?? (opts?.auth?.getToken ? await opts.auth.getToken() : null) ?? getToken();
|
|
7374
|
-
if (!t) return null;
|
|
7375
|
-
return parseUserFromToken(t);
|
|
7376
|
-
} catch (_e2) {
|
|
7377
|
-
return null;
|
|
7378
|
-
}
|
|
7549
|
+
window.iframeNavigation = {
|
|
7550
|
+
addPage: function(url, title) {
|
|
7551
|
+
addToNavigationHistory(
|
|
7552
|
+
url || window.location.href,
|
|
7553
|
+
title || document.title
|
|
7554
|
+
);
|
|
7379
7555
|
},
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
// minimal login/logout stubs - consumers can override behavior
|
|
7389
|
-
login: (redirect) => {
|
|
7390
|
-
if (typeof window === "undefined") return;
|
|
7391
|
-
const loc = redirect || window.location.href;
|
|
7392
|
-
try {
|
|
7393
|
-
const root = env2.baseUrl;
|
|
7394
|
-
const authUrl = new URL("/auth", String(root));
|
|
7395
|
-
authUrl.searchParams.set("redirect_uri", String(loc));
|
|
7396
|
-
if (opts?.projectId) authUrl.searchParams.set("project_id", String(opts.projectId));
|
|
7397
|
-
window.location.href = authUrl.toString();
|
|
7398
|
-
} catch {
|
|
7399
|
-
const encoded = encodeURIComponent(String(loc));
|
|
7400
|
-
const pid = opts?.projectId ? `&project_id=${encodeURIComponent(String(opts.projectId))}` : "";
|
|
7401
|
-
const root = env2.baseUrl;
|
|
7402
|
-
window.location.href = `${root}/auth?redirect_uri=${encoded}${pid}`;
|
|
7403
|
-
}
|
|
7404
|
-
},
|
|
7405
|
-
logout: () => {
|
|
7406
|
-
token = null;
|
|
7407
|
-
applyToken(null);
|
|
7408
|
-
}
|
|
7556
|
+
getState: function() {
|
|
7557
|
+
return {
|
|
7558
|
+
canGoBack: navState.currentHistoryIndex > 0,
|
|
7559
|
+
canGoForward: navState.currentHistoryIndex < navState.navigationHistory.length - 1,
|
|
7560
|
+
historyLength: navState.navigationHistory.length,
|
|
7561
|
+
currentIndex: navState.currentHistoryIndex,
|
|
7562
|
+
currentPage: navState.navigationHistory[navState.currentHistoryIndex]
|
|
7563
|
+
};
|
|
7409
7564
|
},
|
|
7410
|
-
|
|
7411
|
-
if (
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
sensitiveParams: o?.sensitiveParams
|
|
7415
|
-
});
|
|
7565
|
+
updateState: function() {
|
|
7566
|
+
if (window.parent && window.parent !== window) {
|
|
7567
|
+
sendNavigationState(window.parent, "*");
|
|
7568
|
+
}
|
|
7416
7569
|
}
|
|
7417
7570
|
};
|
|
7418
7571
|
}
|
|
7419
|
-
|
|
7420
|
-
// src/hooks/use-mobile.ts
|
|
7421
|
-
var React8 = __toESM(require("react"));
|
|
7422
|
-
var MOBILE_BREAKPOINT = 768;
|
|
7423
|
-
function useIsMobile() {
|
|
7424
|
-
const [isMobile, setIsMobile] = React8.useState(void 0);
|
|
7425
|
-
React8.useEffect(() => {
|
|
7426
|
-
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
7427
|
-
const onChange = () => {
|
|
7428
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
7429
|
-
};
|
|
7430
|
-
mql.addEventListener("change", onChange);
|
|
7431
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
7432
|
-
return () => mql.removeEventListener("change", onChange);
|
|
7433
|
-
}, []);
|
|
7434
|
-
return !!isMobile;
|
|
7435
|
-
}
|
|
7436
|
-
|
|
7437
|
-
// src/hooks/use-debounce.ts
|
|
7438
|
-
var import_react14 = require("react");
|
|
7439
|
-
function useDebounce(value, delay) {
|
|
7440
|
-
const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
|
|
7441
|
-
(0, import_react14.useEffect)(() => {
|
|
7442
|
-
const handler = setTimeout(() => {
|
|
7443
|
-
setDebouncedValue(value);
|
|
7444
|
-
}, delay);
|
|
7445
|
-
return () => {
|
|
7446
|
-
clearTimeout(handler);
|
|
7447
|
-
};
|
|
7448
|
-
}, [value, delay]);
|
|
7449
|
-
return debouncedValue;
|
|
7450
|
-
}
|
|
7451
|
-
|
|
7452
|
-
// src/utils/unified-error-handler/simple.ts
|
|
7453
|
-
var SimpleErrorHandler = class {
|
|
7454
|
-
constructor() {
|
|
7455
|
-
this.initialized = false;
|
|
7456
|
-
}
|
|
7457
|
-
// 使用明确赋值断言,因为在 init() 方法中会初始化
|
|
7572
|
+
var iframeNavigation = {
|
|
7458
7573
|
/**
|
|
7459
|
-
*
|
|
7574
|
+
* Initialize the navigation system
|
|
7460
7575
|
*/
|
|
7461
|
-
init
|
|
7462
|
-
if (this.initialized) return;
|
|
7463
|
-
this.sendMessage = createSimpleSendFunction({
|
|
7464
|
-
addTimestamp: false,
|
|
7465
|
-
// 简化版自己处理时间戳
|
|
7466
|
-
enableDebugLog: false
|
|
7467
|
-
});
|
|
7468
|
-
this.setupErrorListeners();
|
|
7469
|
-
this.setupCompatibility();
|
|
7470
|
-
this.initialized = true;
|
|
7471
|
-
console.log("[\u7B80\u5316\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
7472
|
-
}
|
|
7576
|
+
init: initIframeNavigation,
|
|
7473
7577
|
/**
|
|
7474
|
-
*
|
|
7578
|
+
* Add a page to navigation history
|
|
7475
7579
|
*/
|
|
7476
|
-
|
|
7477
|
-
window
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
});
|
|
7484
|
-
});
|
|
7485
|
-
window.addEventListener("unhandledrejection", (event) => {
|
|
7486
|
-
const error = event.reason instanceof Error ? event.reason : new Error(String(event.reason));
|
|
7487
|
-
this.sendError(error, { type: "promise" });
|
|
7488
|
-
});
|
|
7489
|
-
}
|
|
7580
|
+
addPage: (url, title) => {
|
|
7581
|
+
if (typeof window === "undefined") return;
|
|
7582
|
+
addToNavigationHistory(
|
|
7583
|
+
url || window.location.href,
|
|
7584
|
+
title || (typeof document !== "undefined" ? document.title : "")
|
|
7585
|
+
);
|
|
7586
|
+
},
|
|
7490
7587
|
/**
|
|
7491
|
-
*
|
|
7588
|
+
* Get current navigation state
|
|
7492
7589
|
*/
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7590
|
+
getState: () => {
|
|
7591
|
+
const navState = getNavState();
|
|
7592
|
+
return {
|
|
7593
|
+
canGoBack: navState.currentHistoryIndex > 0,
|
|
7594
|
+
canGoForward: navState.currentHistoryIndex < navState.navigationHistory.length - 1,
|
|
7595
|
+
historyLength: navState.navigationHistory.length,
|
|
7596
|
+
currentIndex: navState.currentHistoryIndex,
|
|
7597
|
+
currentPage: navState.navigationHistory[navState.currentHistoryIndex]
|
|
7497
7598
|
};
|
|
7498
|
-
}
|
|
7599
|
+
},
|
|
7499
7600
|
/**
|
|
7500
|
-
*
|
|
7601
|
+
* Update navigation state (send to parent)
|
|
7501
7602
|
*/
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
stack: error.stack,
|
|
7506
|
-
filename: details.filename || details.file,
|
|
7507
|
-
lineno: details.lineno || details.line,
|
|
7508
|
-
colno: details.colno || details.column,
|
|
7509
|
-
timestamp: Date.now(),
|
|
7510
|
-
type: details.type || "unknown",
|
|
7511
|
-
severity: "medium",
|
|
7512
|
-
// 简化版使用默认严重性级别
|
|
7513
|
-
details
|
|
7514
|
-
};
|
|
7515
|
-
try {
|
|
7516
|
-
this.sendMessage({
|
|
7517
|
-
type: "ERROR_EVENT",
|
|
7518
|
-
payload,
|
|
7519
|
-
timestamp: Date.now()
|
|
7520
|
-
});
|
|
7521
|
-
} catch (e) {
|
|
7522
|
-
const originalConsole = window.__originalConsole;
|
|
7523
|
-
if (originalConsole?.error) {
|
|
7524
|
-
originalConsole.error("[\u7B80\u5316\u9519\u8BEF\u5904\u7406] \u53D1\u9001\u5931\u8D25:", e);
|
|
7525
|
-
}
|
|
7603
|
+
updateState: () => {
|
|
7604
|
+
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
7605
|
+
sendNavigationState(window.parent, "*");
|
|
7526
7606
|
}
|
|
7527
|
-
}
|
|
7607
|
+
},
|
|
7528
7608
|
/**
|
|
7529
|
-
*
|
|
7609
|
+
* Go back in history
|
|
7530
7610
|
*/
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7611
|
+
goBack: customGoBack,
|
|
7612
|
+
/**
|
|
7613
|
+
* Go forward in history
|
|
7614
|
+
*/
|
|
7615
|
+
goForward: customGoForward
|
|
7616
|
+
};
|
|
7617
|
+
var elementSelector = {
|
|
7618
|
+
/**
|
|
7619
|
+
* Start element selection mode
|
|
7620
|
+
*/
|
|
7621
|
+
startSelection: triggerElementSelection,
|
|
7622
|
+
/**
|
|
7623
|
+
* Cancel element selection mode
|
|
7624
|
+
*/
|
|
7625
|
+
cancel: cancelElementSelection,
|
|
7626
|
+
/**
|
|
7627
|
+
* Check if selector is active
|
|
7628
|
+
*/
|
|
7629
|
+
isActive: () => getElementSelectorState().active
|
|
7534
7630
|
};
|
|
7535
|
-
|
|
7536
|
-
// src/index.ts
|
|
7537
|
-
init_config();
|
|
7538
7631
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7539
7632
|
0 && (module.exports = {
|
|
7540
7633
|
AUTH_TOKEN_KEY,
|