findweb 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +34 -27
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -43,6 +43,7 @@ findweb login
43
43
  - If the profile is already prepared, search runs immediately.
44
44
  - If the profile has not been prepared yet, `findweb` automatically opens the login flow first.
45
45
  - After you sign in and close the browser window, `findweb` writes a local prepared-profile marker so future searches can start immediately.
46
+ - By default, the profile directory is `${XDG_DATA_HOME:-~/.local/share}/findweb/chrome-profile` unless you pass `--userDataDir` or set `GOOGLE_SEARCH_USER_DATA_DIR`.
46
47
 
47
48
  In practice, the first search on a fresh profile behaves like this:
48
49
 
package/dist/index.js CHANGED
@@ -66932,9 +66932,10 @@ async function runMain(cmd, opts = {}) {
66932
66932
  }
66933
66933
 
66934
66934
  // src/search/browser.ts
66935
- import { existsSync as existsSync3 } from "fs";
66936
66935
  import { spawn as spawn3 } from "child_process";
66937
66936
  import http2 from "http";
66937
+ import os9 from "os";
66938
+ import path12 from "path";
66938
66939
 
66939
66940
  // node_modules/puppeteer-core/lib/esm/puppeteer/api/api.js
66940
66941
  init_Browser();
@@ -76307,13 +76308,19 @@ async function closeSearchBrowser(activeBrowser) {
76307
76308
  activeBrowser.chromeProcess.kill("SIGTERM");
76308
76309
  }
76309
76310
  }
76311
+ function defaultXdgDataHome() {
76312
+ const configured = process.env.XDG_DATA_HOME;
76313
+ if (configured && path12.isAbsolute(configured)) {
76314
+ return configured;
76315
+ }
76316
+ return path12.join(os9.homedir(), ".local", "share");
76317
+ }
76310
76318
  function defaultUserDataDir() {
76311
76319
  const configured = process.env.GOOGLE_SEARCH_USER_DATA_DIR;
76312
76320
  if (configured) {
76313
76321
  return configured;
76314
76322
  }
76315
- const legacyProfile = "/tmp/gsearch-manual-login-profile";
76316
- return ["/tmp/google-search-profile", legacyProfile].find((candidate) => existsSync3(candidate)) ?? "/tmp/google-search-profile";
76323
+ return path12.join(defaultXdgDataHome(), "findweb", "chrome-profile");
76317
76324
  }
76318
76325
 
76319
76326
  // src/search/page.ts
@@ -76556,13 +76563,13 @@ async function runLoginSession(options) {
76556
76563
 
76557
76564
  // src/cli/profile.ts
76558
76565
  import fs7 from "fs/promises";
76559
- import path12 from "path";
76566
+ import path13 from "path";
76560
76567
  var PROFILE_READY_MARKER = ".findweb-profile-ready";
76561
76568
  async function ensureProfileDir(dirPath) {
76562
76569
  await fs7.mkdir(dirPath, { recursive: true });
76563
76570
  }
76564
76571
  function readyMarkerPath(userDataDir) {
76565
- return path12.join(userDataDir, PROFILE_READY_MARKER);
76572
+ return path13.join(userDataDir, PROFILE_READY_MARKER);
76566
76573
  }
76567
76574
  async function hasPreparedProfile(userDataDir) {
76568
76575
  try {
@@ -76615,7 +76622,7 @@ async function ensureInteractiveLogin(options) {
76615
76622
  }
76616
76623
 
76617
76624
  // src/cli/schema.ts
76618
- import path13 from "path";
76625
+ import path14 from "path";
76619
76626
 
76620
76627
  // node_modules/zod/v4/classic/external.js
76621
76628
  var exports_external = {};
@@ -77382,10 +77389,10 @@ function mergeDefs(...defs) {
77382
77389
  function cloneDef(schema) {
77383
77390
  return mergeDefs(schema._zod.def);
77384
77391
  }
77385
- function getElementAtPath(obj, path13) {
77386
- if (!path13)
77392
+ function getElementAtPath(obj, path14) {
77393
+ if (!path14)
77387
77394
  return obj;
77388
- return path13.reduce((acc, key) => acc?.[key], obj);
77395
+ return path14.reduce((acc, key) => acc?.[key], obj);
77389
77396
  }
77390
77397
  function promiseAllObject(promisesObj) {
77391
77398
  const keys = Object.keys(promisesObj);
@@ -77766,11 +77773,11 @@ function aborted(x, startIndex = 0) {
77766
77773
  }
77767
77774
  return false;
77768
77775
  }
77769
- function prefixIssues(path13, issues) {
77776
+ function prefixIssues(path14, issues) {
77770
77777
  return issues.map((iss) => {
77771
77778
  var _a4;
77772
77779
  (_a4 = iss).path ?? (_a4.path = []);
77773
- iss.path.unshift(path13);
77780
+ iss.path.unshift(path14);
77774
77781
  return iss;
77775
77782
  });
77776
77783
  }
@@ -77953,7 +77960,7 @@ function formatError(error, mapper = (issue2) => issue2.message) {
77953
77960
  }
77954
77961
  function treeifyError(error, mapper = (issue2) => issue2.message) {
77955
77962
  const result = { errors: [] };
77956
- const processError = (error2, path13 = []) => {
77963
+ const processError = (error2, path14 = []) => {
77957
77964
  var _a4, _b2;
77958
77965
  for (const issue2 of error2.issues) {
77959
77966
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -77963,7 +77970,7 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
77963
77970
  } else if (issue2.code === "invalid_element") {
77964
77971
  processError({ issues: issue2.issues }, issue2.path);
77965
77972
  } else {
77966
- const fullpath = [...path13, ...issue2.path];
77973
+ const fullpath = [...path14, ...issue2.path];
77967
77974
  if (fullpath.length === 0) {
77968
77975
  result.errors.push(mapper(issue2));
77969
77976
  continue;
@@ -77995,8 +78002,8 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
77995
78002
  }
77996
78003
  function toDotPath(_path) {
77997
78004
  const segs = [];
77998
- const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
77999
- for (const seg of path13) {
78005
+ const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
78006
+ for (const seg of path14) {
78000
78007
  if (typeof seg === "number")
78001
78008
  segs.push(`[${seg}]`);
78002
78009
  else if (typeof seg === "symbol")
@@ -89743,13 +89750,13 @@ function resolveRef(ref, ctx) {
89743
89750
  if (!ref.startsWith("#")) {
89744
89751
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
89745
89752
  }
89746
- const path13 = ref.slice(1).split("/").filter(Boolean);
89747
- if (path13.length === 0) {
89753
+ const path14 = ref.slice(1).split("/").filter(Boolean);
89754
+ if (path14.length === 0) {
89748
89755
  return ctx.rootSchema;
89749
89756
  }
89750
89757
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
89751
- if (path13[0] === defsKey) {
89752
- const key = path13[1];
89758
+ if (path14[0] === defsKey) {
89759
+ const key = path14[1];
89753
89760
  if (!key || !ctx.defs[key]) {
89754
89761
  throw new Error(`Reference not found: ${ref}`);
89755
89762
  }
@@ -90158,7 +90165,7 @@ var sharedSchema = exports_external.object({
90158
90165
  headed: exports_external.boolean().default(false),
90159
90166
  json: exports_external.boolean().default(false),
90160
90167
  lang: defaultedString("lang", "en"),
90161
- userDataDir: defaultedString("userDataDir", defaultUserDataDir()).transform((value) => path13.resolve(value))
90168
+ userDataDir: defaultedString("userDataDir", defaultUserDataDir()).transform((value) => path14.resolve(value))
90162
90169
  });
90163
90170
  var searchSchema = sharedSchema.extend({
90164
90171
  num: positiveInteger("num").default(3),
@@ -90249,8 +90256,8 @@ import process4 from "process";
90249
90256
 
90250
90257
  // src/search/blocker.ts
90251
90258
  import fs8 from "fs/promises";
90252
- import os9 from "os";
90253
- import path14 from "path";
90259
+ import os10 from "os";
90260
+ import path15 from "path";
90254
90261
 
90255
90262
  // node_modules/tldts-core/dist/es6/src/domain.js
90256
90263
  function shareSameDomainSuffix(hostname3, vhost) {
@@ -99514,8 +99521,8 @@ class FilterEngine extends EventEmitter5 {
99514
99521
  if (caching === undefined) {
99515
99522
  return init();
99516
99523
  }
99517
- const { path: path14, read, write } = caching;
99518
- return read(path14).then((buffer) => this.deserialize(buffer)).catch(() => init().then((engine) => write(path14, engine.serialize()).then(() => engine)));
99524
+ const { path: path15, read, write } = caching;
99525
+ return read(path15).then((buffer) => this.deserialize(buffer)).catch(() => init().then((engine) => write(path15, engine.serialize()).then(() => engine)));
99519
99526
  }
99520
99527
  static empty(config3 = {}) {
99521
99528
  return new this({ config: config3 });
@@ -101307,13 +101314,13 @@ class PuppeteerBlocker extends FilterEngine {
101307
101314
  // src/search/blocker.ts
101308
101315
  var blockerPromise;
101309
101316
  function defaultCacheDir() {
101310
- return process.env.GOOGLE_SEARCH_CACHE_DIR ?? path14.join(os9.homedir(), ".cache", "google-search");
101317
+ return process.env.GOOGLE_SEARCH_CACHE_DIR ?? path15.join(os10.homedir(), ".cache", "google-search");
101311
101318
  }
101312
101319
  async function readCache(filePath) {
101313
101320
  return fs8.readFile(filePath);
101314
101321
  }
101315
101322
  async function writeCache(filePath, buffer) {
101316
- await fs8.mkdir(path14.dirname(filePath), { recursive: true });
101323
+ await fs8.mkdir(path15.dirname(filePath), { recursive: true });
101317
101324
  await fs8.writeFile(filePath, buffer);
101318
101325
  }
101319
101326
  async function loadBlocker() {
@@ -101322,7 +101329,7 @@ async function loadBlocker() {
101322
101329
  const cacheDir = defaultCacheDir();
101323
101330
  await fs8.mkdir(cacheDir, { recursive: true });
101324
101331
  return PuppeteerBlocker.fromPrebuiltAdsAndTracking(globalThis.fetch.bind(globalThis), {
101325
- path: path14.join(cacheDir, "ghostery-engine.bin"),
101332
+ path: path15.join(cacheDir, "ghostery-engine.bin"),
101326
101333
  read: readCache,
101327
101334
  write: writeCache
101328
101335
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "findweb",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Google search CLI powered by system Chrome",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.3.11",