notte-sdk 0.0.6 → 0.0.7
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/README.md +2 -1
- package/dist/index.d.mts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +53 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1303,6 +1303,7 @@ var scrapeFromHtml = (options) => (options.client ?? client).post({
|
|
|
1303
1303
|
});
|
|
1304
1304
|
|
|
1305
1305
|
// src/utils.ts
|
|
1306
|
+
import { spawn } from "child_process";
|
|
1306
1307
|
function formatError(error) {
|
|
1307
1308
|
if (typeof error === "object" && error !== null) {
|
|
1308
1309
|
if ("message" in error && typeof error.message === "string") {
|
|
@@ -1319,6 +1320,28 @@ function formatError(error) {
|
|
|
1319
1320
|
}
|
|
1320
1321
|
return String(error);
|
|
1321
1322
|
}
|
|
1323
|
+
function openBrowser(url) {
|
|
1324
|
+
const platform = process.platform;
|
|
1325
|
+
let command;
|
|
1326
|
+
let args;
|
|
1327
|
+
if (platform === "darwin") {
|
|
1328
|
+
command = "open";
|
|
1329
|
+
args = [url];
|
|
1330
|
+
} else if (platform === "win32") {
|
|
1331
|
+
command = "rundll32";
|
|
1332
|
+
args = ["url.dll,FileProtocolHandler", url];
|
|
1333
|
+
} else {
|
|
1334
|
+
command = "xdg-open";
|
|
1335
|
+
args = [url];
|
|
1336
|
+
}
|
|
1337
|
+
const child = spawn(command, args, {
|
|
1338
|
+
detached: true,
|
|
1339
|
+
stdio: "ignore"
|
|
1340
|
+
});
|
|
1341
|
+
child.on("error", () => {
|
|
1342
|
+
});
|
|
1343
|
+
child.unref();
|
|
1344
|
+
}
|
|
1322
1345
|
|
|
1323
1346
|
// src/session.ts
|
|
1324
1347
|
import { z } from "zod";
|
|
@@ -1363,7 +1386,9 @@ var Session = class {
|
|
|
1363
1386
|
this.isActive = false;
|
|
1364
1387
|
this.response = null;
|
|
1365
1388
|
this.client = client2;
|
|
1366
|
-
|
|
1389
|
+
const { open_viewer = false, ...sessionOptions } = options;
|
|
1390
|
+
this.options = sessionOptions;
|
|
1391
|
+
this.openViewer = open_viewer;
|
|
1367
1392
|
}
|
|
1368
1393
|
/**
|
|
1369
1394
|
* Start the session - creates a new session on the server
|
|
@@ -1372,6 +1397,7 @@ var Session = class {
|
|
|
1372
1397
|
if (this.isActive) {
|
|
1373
1398
|
throw new Error("Session is already active");
|
|
1374
1399
|
}
|
|
1400
|
+
let shouldOpenViewer = false;
|
|
1375
1401
|
try {
|
|
1376
1402
|
const response = await sessionStart({
|
|
1377
1403
|
client: this.client.getClient(),
|
|
@@ -1384,9 +1410,13 @@ var Session = class {
|
|
|
1384
1410
|
this.sessionId = sessionData.session_id;
|
|
1385
1411
|
this.isActive = true;
|
|
1386
1412
|
this.response = sessionData;
|
|
1413
|
+
shouldOpenViewer = this.openViewer;
|
|
1387
1414
|
} catch (error) {
|
|
1388
1415
|
throw new Error(`Failed to start session: ${error instanceof Error ? error.message : String(error)}`);
|
|
1389
1416
|
}
|
|
1417
|
+
if (shouldOpenViewer) {
|
|
1418
|
+
this.openViewerInBrowser();
|
|
1419
|
+
}
|
|
1390
1420
|
}
|
|
1391
1421
|
/**
|
|
1392
1422
|
* Stop the session - terminates the session on the server
|
|
@@ -1444,6 +1474,27 @@ var Session = class {
|
|
|
1444
1474
|
getResponse() {
|
|
1445
1475
|
return this.response;
|
|
1446
1476
|
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Open the live viewer for this session in the local default browser.
|
|
1479
|
+
*/
|
|
1480
|
+
viewer() {
|
|
1481
|
+
if (!this.sessionId) {
|
|
1482
|
+
throw new Error("Session not started");
|
|
1483
|
+
}
|
|
1484
|
+
const viewerUrl = this.response?.viewer_url;
|
|
1485
|
+
if (!viewerUrl) {
|
|
1486
|
+
throw new Error("No viewer URL available for this session");
|
|
1487
|
+
}
|
|
1488
|
+
openBrowser(viewerUrl);
|
|
1489
|
+
}
|
|
1490
|
+
openViewerInBrowser() {
|
|
1491
|
+
const viewerUrl = this.response?.viewer_url;
|
|
1492
|
+
if (!viewerUrl) {
|
|
1493
|
+
console.warn("[Session] No viewer URL available; session started without opening a viewer.");
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1496
|
+
openBrowser(viewerUrl);
|
|
1497
|
+
}
|
|
1447
1498
|
/**
|
|
1448
1499
|
* Set cookies for the session
|
|
1449
1500
|
*/
|
|
@@ -2524,7 +2575,7 @@ var NottePersona = class {
|
|
|
2524
2575
|
};
|
|
2525
2576
|
|
|
2526
2577
|
// src/version.ts
|
|
2527
|
-
var SDK_VERSION = true ? "0.0.
|
|
2578
|
+
var SDK_VERSION = true ? "0.0.7" : "dev";
|
|
2528
2579
|
|
|
2529
2580
|
// src/functions.ts
|
|
2530
2581
|
var NotteFunction = class {
|