@ai-ecoverse/sliccy-browser 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/sliccy-browser",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
4
4
  "description": "sliccy:browser for jsh, over CDP",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/src/browser.js CHANGED
@@ -2,6 +2,9 @@ import { appendFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { connect } from './connect.js';
4
4
  import { buildBrowserFetchScript } from './fetch-script.js';
5
+ import { version } from './version.js';
6
+
7
+ export { version };
5
8
 
6
9
  const LOAD_TIMEOUT_MS = 15000;
7
10
  const HELD_FRAMES = 100;
@@ -362,11 +365,11 @@ function evalSourceAsync(tab, source) {
362
365
 
363
366
  export { evalSource as eval, evalSourceAsync as evalAsync };
364
367
 
365
- function evaluate(tab, source, awaitPromise) {
366
- return using(() => evaluateNow(tab, source, awaitPromise));
368
+ function evaluate(tab, source, awaitPromise, decodeJson = true) {
369
+ return using(() => evaluateNow(tab, source, awaitPromise, decodeJson));
367
370
  }
368
371
 
369
- async function evaluateNow(tab, source, awaitPromise) {
372
+ async function evaluateNow(tab, source, awaitPromise, decodeJson) {
370
373
  const { client, sessionId } = await sessionFor(targetIdOf(tab));
371
374
  const result = await client.send(
372
375
  'Runtime.evaluate',
@@ -380,7 +383,8 @@ async function evaluateNow(tab, source, awaitPromise) {
380
383
  if (result?.exceptionDetails) {
381
384
  throw new Error(exceptionMessage(result.exceptionDetails));
382
385
  }
383
- return unwrapEvalResult(result?.result?.value);
386
+ const value = result?.result?.value;
387
+ return decodeJson ? unwrapEvalResult(value) : value;
384
388
  }
385
389
 
386
390
  export async function cookie(tab, name) {
@@ -401,6 +405,7 @@ export async function localStorage(tab, key) {
401
405
  const raw = await evaluate(
402
406
  tab,
403
407
  `(function(){try{var v=window.localStorage.getItem(${JSON.stringify(key)});return v===null?null:String(v);}catch(e){return null;}})()`,
408
+ false,
404
409
  false
405
410
  );
406
411
  if (raw === null || raw === undefined) return null;
@@ -671,6 +676,7 @@ export const websocket = {
671
676
  };
672
677
 
673
678
  const browser = {
679
+ version,
674
680
  findTab,
675
681
  ensureTab,
676
682
  eval: evalSource,
package/src/version.js ADDED
@@ -0,0 +1 @@
1
+ export const version = '0.1.38';