seacloud-sdk 0.12.2 → 0.12.4
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/cli.js +20 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -114,9 +114,26 @@ async function getApiToken(providedApiKey) {
|
|
|
114
114
|
}
|
|
115
115
|
return "";
|
|
116
116
|
}
|
|
117
|
+
function checkIsDevelopmentHost(host) {
|
|
118
|
+
const devHostPatterns = ["localhost", "127.0.0.1", ":3000", ":8080", "seaverse.dev"];
|
|
119
|
+
return devHostPatterns.some((pattern) => host.includes(pattern));
|
|
120
|
+
}
|
|
117
121
|
function createConfig(options = {}) {
|
|
118
122
|
const apiKey = options.apiKey;
|
|
119
|
-
|
|
123
|
+
let baseUrl;
|
|
124
|
+
if (options.baseUrl) {
|
|
125
|
+
baseUrl = options.baseUrl;
|
|
126
|
+
} else if (typeof process !== "undefined" && process.env?.SEACLOUD_BASE_URL) {
|
|
127
|
+
baseUrl = process.env.SEACLOUD_BASE_URL;
|
|
128
|
+
} else {
|
|
129
|
+
const currentHost = typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined" ? globalThis.window.location.host : "";
|
|
130
|
+
if (checkIsDevelopmentHost(currentHost)) {
|
|
131
|
+
baseUrl = "https://proxy-rs.sg.seaverse.dev";
|
|
132
|
+
console.log("[SeaCloud SDK] \u68C0\u6D4B\u5230\u5F00\u53D1\u73AF\u5883\uFF08currentHost\uFF09\uFF0C\u4F7F\u7528\u5F00\u53D1 baseUrl:", baseUrl);
|
|
133
|
+
} else {
|
|
134
|
+
baseUrl = "https://proxy-rs.seaverse.ai";
|
|
135
|
+
}
|
|
136
|
+
}
|
|
120
137
|
const fetchImpl = options.fetch || (globalThis.fetch ? globalThis.fetch.bind(globalThis) : void 0);
|
|
121
138
|
if (!fetchImpl) {
|
|
122
139
|
throw new Error("fetch is not available. Please provide a fetch implementation in config or upgrade to Node.js 18+");
|
|
@@ -288,7 +305,8 @@ async function initSeacloud(apiKeyOrConfig, options) {
|
|
|
288
305
|
try {
|
|
289
306
|
const parentHost = await getHostFromParent(3e3);
|
|
290
307
|
if (parentHost) {
|
|
291
|
-
const
|
|
308
|
+
const currentHost = typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined" ? globalThis.window.location.host : "";
|
|
309
|
+
const isDevelopment = checkIsDevelopmentHost(currentHost) || checkIsDevelopmentHost(parentHost);
|
|
292
310
|
if (isDevelopment) {
|
|
293
311
|
config.baseUrl = "https://proxy-rs.sg.seaverse.dev";
|
|
294
312
|
console.log("[SeaCloud SDK] \u68C0\u6D4B\u5230\u5F00\u53D1\u73AF\u5883\uFF0C\u4F7F\u7528\u5F00\u53D1 baseUrl:", config.baseUrl);
|