tevrocsdk 0.1.36 → 0.1.38
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/package.json
CHANGED
package/tevroc-sdk.esm.js
CHANGED
|
@@ -26282,7 +26282,7 @@ function subscribeGoogleLogin(cb) {
|
|
|
26282
26282
|
if (i4 !== -1) googleListeners.splice(i4, 1);
|
|
26283
26283
|
};
|
|
26284
26284
|
}
|
|
26285
|
-
var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
|
|
26285
|
+
var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, closeAllTauriWebviews, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
|
|
26286
26286
|
var init_useGoogleAuth = __esm({
|
|
26287
26287
|
"src/services/useGoogleAuth.js"() {
|
|
26288
26288
|
init_esm3();
|
|
@@ -26294,6 +26294,33 @@ var init_useGoogleAuth = __esm({
|
|
|
26294
26294
|
authWindowRef = null;
|
|
26295
26295
|
authCleanupTimer = null;
|
|
26296
26296
|
authMessageListener = null;
|
|
26297
|
+
closeAllTauriWebviews = async () => {
|
|
26298
|
+
if (!isTauri) return;
|
|
26299
|
+
try {
|
|
26300
|
+
if (typeof WebviewWindow.getAll === "function") {
|
|
26301
|
+
const windows = await WebviewWindow.getAll();
|
|
26302
|
+
for (const webview of windows || []) {
|
|
26303
|
+
try {
|
|
26304
|
+
if (webview?.label && webview.label !== "main") {
|
|
26305
|
+
await webview.close();
|
|
26306
|
+
}
|
|
26307
|
+
} catch (e2) {
|
|
26308
|
+
console.warn("Error closing Tauri webview:", e2);
|
|
26309
|
+
}
|
|
26310
|
+
}
|
|
26311
|
+
}
|
|
26312
|
+
} catch (e2) {
|
|
26313
|
+
console.warn("Error listing Tauri webviews:", e2);
|
|
26314
|
+
}
|
|
26315
|
+
try {
|
|
26316
|
+
const tauriAuthWindow = await WebviewWindow.getByLabel("auth");
|
|
26317
|
+
if (tauriAuthWindow) {
|
|
26318
|
+
await tauriAuthWindow.close();
|
|
26319
|
+
}
|
|
26320
|
+
} catch (e2) {
|
|
26321
|
+
console.warn("Error closing Tauri auth window by label:", e2);
|
|
26322
|
+
}
|
|
26323
|
+
};
|
|
26297
26324
|
cleanupAuthWindow = async () => {
|
|
26298
26325
|
if (authCleanupTimer) {
|
|
26299
26326
|
clearInterval(authCleanupTimer);
|
|
@@ -26315,14 +26342,7 @@ var init_useGoogleAuth = __esm({
|
|
|
26315
26342
|
}
|
|
26316
26343
|
}
|
|
26317
26344
|
if (isTauri) {
|
|
26318
|
-
|
|
26319
|
-
const tauriAuthWindow = await WebviewWindow.getByLabel("auth");
|
|
26320
|
-
if (tauriAuthWindow && tauriAuthWindow !== authWindowRef) {
|
|
26321
|
-
await tauriAuthWindow.close();
|
|
26322
|
-
}
|
|
26323
|
-
} catch (e2) {
|
|
26324
|
-
console.warn("Error closing Tauri auth window by label:", e2);
|
|
26325
|
-
}
|
|
26345
|
+
await closeAllTauriWebviews();
|
|
26326
26346
|
}
|
|
26327
26347
|
if (isCapacitor) {
|
|
26328
26348
|
try {
|
|
@@ -26407,6 +26427,7 @@ var init_useGoogleAuth = __esm({
|
|
|
26407
26427
|
return;
|
|
26408
26428
|
}
|
|
26409
26429
|
if (isTauri) {
|
|
26430
|
+
await closeAllTauriWebviews();
|
|
26410
26431
|
const url = `${serviceUrl}/login?mode=desktop&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
26411
26432
|
const win = new WebviewWindow("auth", {
|
|
26412
26433
|
url,
|
|
@@ -41237,6 +41258,9 @@ var TevrocClient = class {
|
|
|
41237
41258
|
};
|
|
41238
41259
|
this.offline = createOfflineManager(this);
|
|
41239
41260
|
this.payments = createPaymentApi(this);
|
|
41261
|
+
this.commerce = createCommerceApi(this);
|
|
41262
|
+
this.realtime = createRealtimeApi(this);
|
|
41263
|
+
this.shiplogic = createShiplogicApi(this);
|
|
41240
41264
|
this.platform = createPlatformApi(this);
|
|
41241
41265
|
this.pdf = createPdfApi(this);
|
|
41242
41266
|
}
|
|
@@ -41299,6 +41323,68 @@ var TevrocClient = class {
|
|
|
41299
41323
|
}
|
|
41300
41324
|
}
|
|
41301
41325
|
};
|
|
41326
|
+
function createShiplogicApi(client) {
|
|
41327
|
+
return {
|
|
41328
|
+
getRates: (payload = {}) => client.request("/shiplogic/rates", { method: "POST", body: payload }),
|
|
41329
|
+
createShipment: (payload = {}) => client.request("/shiplogic/shipments", { method: "POST", body: payload }),
|
|
41330
|
+
cancelShipment: (shipmentId) => client.request(`/shiplogic/shipments/${encodeURIComponent(shipmentId)}`, { method: "DELETE" }),
|
|
41331
|
+
trackShipment: (trackingNumber) => client.request(`/shiplogic/track/${encodeURIComponent(trackingNumber)}`),
|
|
41332
|
+
printLabel: (shipmentId) => client.request(`/shiplogic/labels/${encodeURIComponent(shipmentId)}`, { parseAs: "response" }),
|
|
41333
|
+
validateAddress: (payload = {}) => client.request("/shiplogic/address/validate", { method: "POST", body: payload }),
|
|
41334
|
+
getBranches: (query = {}) => client.request("/shiplogic/branches", { query }),
|
|
41335
|
+
getCollectionSlots: (payload = {}) => client.request("/shiplogic/collections/slots", { method: "POST", body: payload }),
|
|
41336
|
+
bookCollection: (payload = {}) => client.request("/shiplogic/collections", { method: "POST", body: payload })
|
|
41337
|
+
};
|
|
41338
|
+
}
|
|
41339
|
+
function createRealtimeApi(client) {
|
|
41340
|
+
const toWebSocketUrl = (baseUrl) => baseUrl.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
|
|
41341
|
+
return {
|
|
41342
|
+
connect: (room, handlers = {}) => {
|
|
41343
|
+
const url = `${toWebSocketUrl(client.baseUrl)}/realtime/${encodeURIComponent(room || "default")}`;
|
|
41344
|
+
const socket = new WebSocket(url);
|
|
41345
|
+
socket.addEventListener("open", (event) => handlers.open?.(event));
|
|
41346
|
+
socket.addEventListener("message", (event) => {
|
|
41347
|
+
let data = event.data;
|
|
41348
|
+
try {
|
|
41349
|
+
data = JSON.parse(event.data);
|
|
41350
|
+
} catch {
|
|
41351
|
+
}
|
|
41352
|
+
handlers.message?.(data, event);
|
|
41353
|
+
});
|
|
41354
|
+
socket.addEventListener("close", (event) => handlers.close?.(event));
|
|
41355
|
+
socket.addEventListener("error", (event) => handlers.error?.(event));
|
|
41356
|
+
return {
|
|
41357
|
+
socket,
|
|
41358
|
+
send: (payload) => socket.readyState === WebSocket.OPEN && socket.send(typeof payload === "string" ? payload : JSON.stringify(payload)),
|
|
41359
|
+
close: () => socket.close()
|
|
41360
|
+
};
|
|
41361
|
+
},
|
|
41362
|
+
iceServers: (config = {}) => {
|
|
41363
|
+
const servers = [];
|
|
41364
|
+
const stunUrls = String(config.stun_urls || config.stunUrls || "stun:stun.l.google.com:19302").split(",").map((url) => url.trim()).filter(Boolean);
|
|
41365
|
+
if (stunUrls.length) servers.push({ urls: stunUrls });
|
|
41366
|
+
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 });
|
|
41367
|
+
return servers;
|
|
41368
|
+
}
|
|
41369
|
+
};
|
|
41370
|
+
}
|
|
41371
|
+
function createCommerceApi(client) {
|
|
41372
|
+
const wrap = (entity) => ({
|
|
41373
|
+
list: (options = {}) => client.request(`/commerce/${encodeURIComponent(entity)}`, { query: options }),
|
|
41374
|
+
query: (input = {}) => client.request(`/commerce/${encodeURIComponent(entity)}/query`, { method: "POST", body: input }),
|
|
41375
|
+
create: (record = {}) => client.request(`/commerce/${encodeURIComponent(entity)}`, { method: "POST", body: record }),
|
|
41376
|
+
update: (id, patch = {}) => client.request(`/commerce/${encodeURIComponent(entity)}/${encodeURIComponent(id)}`, { method: "PATCH", body: patch })
|
|
41377
|
+
});
|
|
41378
|
+
return {
|
|
41379
|
+
orders: wrap("CustomerOrder"),
|
|
41380
|
+
deliveries: wrap("Delivery"),
|
|
41381
|
+
deliveryMessages: wrap("DeliveryMessage"),
|
|
41382
|
+
availability: wrap("AvailabilitySlot"),
|
|
41383
|
+
bookings: wrap("Booking"),
|
|
41384
|
+
appointmentMessages: wrap("AppointmentMessage"),
|
|
41385
|
+
appointmentSignals: wrap("AppointmentSignal")
|
|
41386
|
+
};
|
|
41387
|
+
}
|
|
41302
41388
|
function createPlatformApi(client) {
|
|
41303
41389
|
return (async function() {
|
|
41304
41390
|
const { isNative: isNative2, isCapacitor: isCapacitor2, isTauri: isTauri2, platform: platform2 } = await getPlatformModule();
|