tevrocsdk 0.1.36 → 0.1.37
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/package.json +1 -1
- package/tevroc-sdk.esm.js +95 -9
- package/tevroc-sdk.min.js +39 -39
- package/tevroc-sdk.umd.js +95 -9
package/tevroc-sdk.umd.js
CHANGED
|
@@ -26284,7 +26284,7 @@ var Tevroc = (() => {
|
|
|
26284
26284
|
if (i4 !== -1) googleListeners.splice(i4, 1);
|
|
26285
26285
|
};
|
|
26286
26286
|
}
|
|
26287
|
-
var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
|
|
26287
|
+
var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, closeAllTauriWebviews, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
|
|
26288
26288
|
var init_useGoogleAuth = __esm({
|
|
26289
26289
|
"src/services/useGoogleAuth.js"() {
|
|
26290
26290
|
init_esm3();
|
|
@@ -26296,6 +26296,33 @@ var Tevroc = (() => {
|
|
|
26296
26296
|
authWindowRef = null;
|
|
26297
26297
|
authCleanupTimer = null;
|
|
26298
26298
|
authMessageListener = null;
|
|
26299
|
+
closeAllTauriWebviews = async () => {
|
|
26300
|
+
if (!isTauri) return;
|
|
26301
|
+
try {
|
|
26302
|
+
if (typeof WebviewWindow.getAll === "function") {
|
|
26303
|
+
const windows = await WebviewWindow.getAll();
|
|
26304
|
+
for (const webview of windows || []) {
|
|
26305
|
+
try {
|
|
26306
|
+
if (webview?.label && webview.label !== "main") {
|
|
26307
|
+
await webview.close();
|
|
26308
|
+
}
|
|
26309
|
+
} catch (e2) {
|
|
26310
|
+
console.warn("Error closing Tauri webview:", e2);
|
|
26311
|
+
}
|
|
26312
|
+
}
|
|
26313
|
+
}
|
|
26314
|
+
} catch (e2) {
|
|
26315
|
+
console.warn("Error listing Tauri webviews:", e2);
|
|
26316
|
+
}
|
|
26317
|
+
try {
|
|
26318
|
+
const tauriAuthWindow = await WebviewWindow.getByLabel("auth");
|
|
26319
|
+
if (tauriAuthWindow) {
|
|
26320
|
+
await tauriAuthWindow.close();
|
|
26321
|
+
}
|
|
26322
|
+
} catch (e2) {
|
|
26323
|
+
console.warn("Error closing Tauri auth window by label:", e2);
|
|
26324
|
+
}
|
|
26325
|
+
};
|
|
26299
26326
|
cleanupAuthWindow = async () => {
|
|
26300
26327
|
if (authCleanupTimer) {
|
|
26301
26328
|
clearInterval(authCleanupTimer);
|
|
@@ -26317,14 +26344,7 @@ var Tevroc = (() => {
|
|
|
26317
26344
|
}
|
|
26318
26345
|
}
|
|
26319
26346
|
if (isTauri) {
|
|
26320
|
-
|
|
26321
|
-
const tauriAuthWindow = await WebviewWindow.getByLabel("auth");
|
|
26322
|
-
if (tauriAuthWindow && tauriAuthWindow !== authWindowRef) {
|
|
26323
|
-
await tauriAuthWindow.close();
|
|
26324
|
-
}
|
|
26325
|
-
} catch (e2) {
|
|
26326
|
-
console.warn("Error closing Tauri auth window by label:", e2);
|
|
26327
|
-
}
|
|
26347
|
+
await closeAllTauriWebviews();
|
|
26328
26348
|
}
|
|
26329
26349
|
if (isCapacitor) {
|
|
26330
26350
|
try {
|
|
@@ -26409,6 +26429,7 @@ var Tevroc = (() => {
|
|
|
26409
26429
|
return;
|
|
26410
26430
|
}
|
|
26411
26431
|
if (isTauri) {
|
|
26432
|
+
await closeAllTauriWebviews();
|
|
26412
26433
|
const url = `${serviceUrl}/login?mode=desktop&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
26413
26434
|
const win = new WebviewWindow("auth", {
|
|
26414
26435
|
url,
|
|
@@ -41247,6 +41268,9 @@ var Tevroc = (() => {
|
|
|
41247
41268
|
};
|
|
41248
41269
|
this.offline = createOfflineManager(this);
|
|
41249
41270
|
this.payments = createPaymentApi(this);
|
|
41271
|
+
this.commerce = createCommerceApi(this);
|
|
41272
|
+
this.realtime = createRealtimeApi(this);
|
|
41273
|
+
this.shiplogic = createShiplogicApi(this);
|
|
41250
41274
|
this.platform = createPlatformApi(this);
|
|
41251
41275
|
this.pdf = createPdfApi(this);
|
|
41252
41276
|
}
|
|
@@ -41309,6 +41333,68 @@ var Tevroc = (() => {
|
|
|
41309
41333
|
}
|
|
41310
41334
|
}
|
|
41311
41335
|
};
|
|
41336
|
+
function createShiplogicApi(client) {
|
|
41337
|
+
return {
|
|
41338
|
+
getRates: (payload = {}) => client.request("/shiplogic/rates", { method: "POST", body: payload }),
|
|
41339
|
+
createShipment: (payload = {}) => client.request("/shiplogic/shipments", { method: "POST", body: payload }),
|
|
41340
|
+
cancelShipment: (shipmentId) => client.request(`/shiplogic/shipments/${encodeURIComponent(shipmentId)}`, { method: "DELETE" }),
|
|
41341
|
+
trackShipment: (trackingNumber) => client.request(`/shiplogic/track/${encodeURIComponent(trackingNumber)}`),
|
|
41342
|
+
printLabel: (shipmentId) => client.request(`/shiplogic/labels/${encodeURIComponent(shipmentId)}`, { parseAs: "response" }),
|
|
41343
|
+
validateAddress: (payload = {}) => client.request("/shiplogic/address/validate", { method: "POST", body: payload }),
|
|
41344
|
+
getBranches: (query = {}) => client.request("/shiplogic/branches", { query }),
|
|
41345
|
+
getCollectionSlots: (payload = {}) => client.request("/shiplogic/collections/slots", { method: "POST", body: payload }),
|
|
41346
|
+
bookCollection: (payload = {}) => client.request("/shiplogic/collections", { method: "POST", body: payload })
|
|
41347
|
+
};
|
|
41348
|
+
}
|
|
41349
|
+
function createRealtimeApi(client) {
|
|
41350
|
+
const toWebSocketUrl = (baseUrl) => baseUrl.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
|
|
41351
|
+
return {
|
|
41352
|
+
connect: (room, handlers = {}) => {
|
|
41353
|
+
const url = `${toWebSocketUrl(client.baseUrl)}/realtime/${encodeURIComponent(room || "default")}`;
|
|
41354
|
+
const socket = new WebSocket(url);
|
|
41355
|
+
socket.addEventListener("open", (event) => handlers.open?.(event));
|
|
41356
|
+
socket.addEventListener("message", (event) => {
|
|
41357
|
+
let data = event.data;
|
|
41358
|
+
try {
|
|
41359
|
+
data = JSON.parse(event.data);
|
|
41360
|
+
} catch {
|
|
41361
|
+
}
|
|
41362
|
+
handlers.message?.(data, event);
|
|
41363
|
+
});
|
|
41364
|
+
socket.addEventListener("close", (event) => handlers.close?.(event));
|
|
41365
|
+
socket.addEventListener("error", (event) => handlers.error?.(event));
|
|
41366
|
+
return {
|
|
41367
|
+
socket,
|
|
41368
|
+
send: (payload) => socket.readyState === WebSocket.OPEN && socket.send(typeof payload === "string" ? payload : JSON.stringify(payload)),
|
|
41369
|
+
close: () => socket.close()
|
|
41370
|
+
};
|
|
41371
|
+
},
|
|
41372
|
+
iceServers: (config = {}) => {
|
|
41373
|
+
const servers = [];
|
|
41374
|
+
const stunUrls = String(config.stun_urls || config.stunUrls || "stun:stun.l.google.com:19302").split(",").map((url) => url.trim()).filter(Boolean);
|
|
41375
|
+
if (stunUrls.length) servers.push({ urls: stunUrls });
|
|
41376
|
+
if (config.turn_url || config.turnUrl) servers.push({ urls: config.turn_url || config.turnUrl, username: config.turn_username || config.turnUsername, credential: config.turn_credential || config.turnCredential });
|
|
41377
|
+
return servers;
|
|
41378
|
+
}
|
|
41379
|
+
};
|
|
41380
|
+
}
|
|
41381
|
+
function createCommerceApi(client) {
|
|
41382
|
+
const wrap = (entity) => ({
|
|
41383
|
+
list: (options = {}) => client.request(`/commerce/${encodeURIComponent(entity)}`, { query: options }),
|
|
41384
|
+
query: (input = {}) => client.request(`/commerce/${encodeURIComponent(entity)}/query`, { method: "POST", body: input }),
|
|
41385
|
+
create: (record = {}) => client.request(`/commerce/${encodeURIComponent(entity)}`, { method: "POST", body: record }),
|
|
41386
|
+
update: (id, patch = {}) => client.request(`/commerce/${encodeURIComponent(entity)}/${encodeURIComponent(id)}`, { method: "PATCH", body: patch })
|
|
41387
|
+
});
|
|
41388
|
+
return {
|
|
41389
|
+
orders: wrap("CustomerOrder"),
|
|
41390
|
+
deliveries: wrap("Delivery"),
|
|
41391
|
+
deliveryMessages: wrap("DeliveryMessage"),
|
|
41392
|
+
availability: wrap("AvailabilitySlot"),
|
|
41393
|
+
bookings: wrap("Booking"),
|
|
41394
|
+
appointmentMessages: wrap("AppointmentMessage"),
|
|
41395
|
+
appointmentSignals: wrap("AppointmentSignal")
|
|
41396
|
+
};
|
|
41397
|
+
}
|
|
41312
41398
|
function createPlatformApi(client) {
|
|
41313
41399
|
return (async function() {
|
|
41314
41400
|
const { isNative: isNative2, isCapacitor: isCapacitor2, isTauri: isTauri2, platform: platform2 } = await getPlatformModule();
|