@hasna/browser 0.4.3 → 0.4.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAKzD,wBAAgB,UAAU,IAAI,MAAM,CA6BnC;AAKD,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAelD;AAED,wBAAgB,aAAa,IAAI,IAAI,CAIpC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAKzD,wBAAgB,UAAU,IAAI,MAAM,CA6BnC;AAKD,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAsBlD;AAED,wBAAgB,aAAa,IAAI,IAAI,CAIpC"}
package/dist/index.js CHANGED
@@ -5,39 +5,60 @@ var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
8
13
  var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
9
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
10
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
23
  for (let key of __getOwnPropNames(mod))
12
24
  if (!__hasOwnProp.call(to, key))
13
25
  __defProp(to, key, {
14
- get: () => mod[key],
26
+ get: __accessProp.bind(mod, key),
15
27
  enumerable: true
16
28
  });
29
+ if (canCache)
30
+ cache.set(mod, to);
17
31
  return to;
18
32
  };
19
- var __moduleCache = /* @__PURE__ */ new WeakMap;
20
33
  var __toCommonJS = (from) => {
21
- var entry = __moduleCache.get(from), desc;
34
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
22
35
  if (entry)
23
36
  return entry;
24
37
  entry = __defProp({}, "__esModule", { value: true });
25
- if (from && typeof from === "object" || typeof from === "function")
26
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
27
- get: () => from[key],
28
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
- }));
38
+ if (from && typeof from === "object" || typeof from === "function") {
39
+ for (var key of __getOwnPropNames(from))
40
+ if (!__hasOwnProp.call(entry, key))
41
+ __defProp(entry, key, {
42
+ get: __accessProp.bind(from, key),
43
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
44
+ });
45
+ }
30
46
  __moduleCache.set(from, entry);
31
47
  return entry;
32
48
  };
49
+ var __moduleCache;
33
50
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
51
+ var __returnValue = (v) => v;
52
+ function __exportSetter(name, newValue) {
53
+ this[name] = __returnValue.bind(null, newValue);
54
+ }
34
55
  var __export = (target, all) => {
35
56
  for (var name in all)
36
57
  __defProp(target, name, {
37
58
  get: all[name],
38
59
  enumerable: true,
39
60
  configurable: true,
40
- set: (newValue) => all[name] = () => newValue
61
+ set: __exportSetter.bind(all, name)
41
62
  });
42
63
  };
43
64
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -138,11 +159,11 @@ import { homedir as homedir4 } from "os";
138
159
  import { join as join4 } from "path";
139
160
  import { join as join6, dirname } from "path";
140
161
  import { homedir as homedir5, platform } from "os";
141
- function __accessProp(key) {
162
+ function __accessProp2(key) {
142
163
  return this[key];
143
164
  }
144
- function __exportSetter(name, newValue) {
145
- this[name] = __returnValue.bind(null, newValue);
165
+ function __exportSetter2(name, newValue) {
166
+ this[name] = __returnValue2.bind(null, newValue);
146
167
  }
147
168
  function translateSql(sql, dialect) {
148
169
  if (dialect === "sqlite")
@@ -1172,10 +1193,10 @@ class SyncProgressTracker {
1172
1193
  }
1173
1194
  }
1174
1195
  }
1175
- var __create2, __getProtoOf2, __defProp2, __getOwnPropNames2, __hasOwnProp2, __toESMCache_node, __toESMCache_esm, __toESM2 = (mod, isNodeMode, target) => {
1196
+ var __create2, __getProtoOf2, __defProp2, __getOwnPropNames2, __hasOwnProp2, __toESMCache_node2, __toESMCache_esm2, __toESM2 = (mod, isNodeMode, target) => {
1176
1197
  var canCache = mod != null && typeof mod === "object";
1177
1198
  if (canCache) {
1178
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
1199
+ var cache = isNodeMode ? __toESMCache_node2 ??= new WeakMap : __toESMCache_esm2 ??= new WeakMap;
1179
1200
  var cached = cache.get(mod);
1180
1201
  if (cached)
1181
1202
  return cached;
@@ -1185,19 +1206,19 @@ var __create2, __getProtoOf2, __defProp2, __getOwnPropNames2, __hasOwnProp2, __t
1185
1206
  for (let key of __getOwnPropNames2(mod))
1186
1207
  if (!__hasOwnProp2.call(to, key))
1187
1208
  __defProp2(to, key, {
1188
- get: __accessProp.bind(mod, key),
1209
+ get: __accessProp2.bind(mod, key),
1189
1210
  enumerable: true
1190
1211
  });
1191
1212
  if (canCache)
1192
1213
  cache.set(mod, to);
1193
1214
  return to;
1194
- }, __commonJS2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports), __returnValue = (v) => v, __export2 = (target, all) => {
1215
+ }, __commonJS2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports), __returnValue2 = (v) => v, __export2 = (target, all) => {
1195
1216
  for (var name in all)
1196
1217
  __defProp2(target, name, {
1197
1218
  get: all[name],
1198
1219
  enumerable: true,
1199
1220
  configurable: true,
1200
- set: __exportSetter.bind(all, name)
1221
+ set: __exportSetter2.bind(all, name)
1201
1222
  });
1202
1223
  }, __esm2 = (fn, res) => () => (fn && (res = fn(fn = 0)), res), __require2, require_postgres_array, require_arrayParser, require_postgres_date, require_mutable, require_postgres_interval, require_postgres_bytea, require_textParsers, require_pg_int8, require_binaryParsers, require_builtins, require_pg_types, require_defaults, require_utils, require_utils_legacy, require_utils_webcrypto, require_utils2, require_cert_signatures, require_sasl, require_type_overrides, require_pg_connection_string, require_connection_parameters, require_result, require_query, require_messages, require_buffer_writer, require_serializer, require_buffer_reader, require_parser, require_dist, require_empty, require_stream, require_connection, require_split2, require_helper, require_lib, require_client, require_pg_pool, require_query2, require_client2, require_lib2, import_lib, Client, Pool, Connection, types, Query, DatabaseError, escapeIdentifier, escapeLiteral, Result, TypeOverrides, defaults, esm_default, init_esm, init_adapter, util, objectUtil, ZodParsedType, getParsedType = (data) => {
1203
1224
  const t = typeof data;
@@ -9549,6 +9570,12 @@ function getDatabase(path) {
9549
9570
  _db.exec("PRAGMA journal_mode=WAL;");
9550
9571
  _db.exec("PRAGMA foreign_keys=ON;");
9551
9572
  runMigrations(_db);
9573
+ try {
9574
+ const cols = _db.query("PRAGMA table_info(feedback)").all().map((c) => c.name);
9575
+ if (cols.length > 0 && !cols.includes("service")) {
9576
+ _db.exec("ALTER TABLE feedback ADD COLUMN service TEXT NOT NULL DEFAULT 'browser'");
9577
+ }
9578
+ } catch {}
9552
9579
  return _db;
9553
9580
  }
9554
9581
  function resetDatabase() {
@@ -9854,12 +9881,12 @@ function runMigrations(db) {
9854
9881
  version: 10,
9855
9882
  sql: `
9856
9883
  CREATE TABLE IF NOT EXISTS feedback (
9857
- id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
9884
+ id TEXT PRIMARY KEY,
9885
+ service TEXT NOT NULL DEFAULT 'browser',
9886
+ version TEXT DEFAULT '',
9858
9887
  message TEXT NOT NULL,
9859
- email TEXT,
9860
- category TEXT DEFAULT 'general',
9861
- version TEXT,
9862
- machine_id TEXT,
9888
+ email TEXT DEFAULT '',
9889
+ machine_id TEXT DEFAULT '',
9863
9890
  created_at TEXT NOT NULL DEFAULT (datetime('now'))
9864
9891
  );
9865
9892
  `
@@ -19517,8 +19544,8 @@ async function takeScreenshot(page, opts) {
19517
19544
  const timestamp = Date.now();
19518
19545
  const format = opts?.format ?? "webp";
19519
19546
  const compress = opts?.compress ?? true;
19520
- const maxWidth = opts?.maxWidth ?? 1280;
19521
- const quality = opts?.quality ?? (format === "webp" ? 82 : format === "jpeg" ? 85 : undefined);
19547
+ const maxWidth = opts?.maxWidth ?? 1200;
19548
+ const quality = opts?.quality ?? (format === "webp" ? 80 : format === "jpeg" ? 70 : undefined);
19522
19549
  const stem = String(timestamp);
19523
19550
  const rawOpts = {
19524
19551
  fullPage: opts?.fullPage ?? false,
@@ -19543,12 +19570,23 @@ async function takeScreenshot(page, opts) {
19543
19570
  rawBuffer = await page.screenshot(rawOpts);
19544
19571
  }
19545
19572
  const originalSizeBytes = rawBuffer.length;
19573
+ const MAX_SIZE_BYTES = 500 * 1024;
19546
19574
  let finalBuffer;
19547
19575
  let compressed = true;
19548
19576
  let fallback = false;
19549
19577
  try {
19550
19578
  if (compress && format !== "png") {
19551
- finalBuffer = await compressBuffer(rawBuffer, format, quality ?? 82, maxWidth);
19579
+ finalBuffer = await compressBuffer(rawBuffer, format, quality ?? 70, maxWidth);
19580
+ if (finalBuffer.length > MAX_SIZE_BYTES) {
19581
+ const reducedFormat = format === "webp" ? "webp" : "jpeg";
19582
+ for (const q of [60, 50, 40, 30]) {
19583
+ const attempt = await compressBuffer(rawBuffer, reducedFormat, q, maxWidth);
19584
+ if (attempt.length <= MAX_SIZE_BYTES) {
19585
+ finalBuffer = attempt;
19586
+ break;
19587
+ }
19588
+ }
19589
+ }
19552
19590
  } else if (compress && format === "png") {
19553
19591
  finalBuffer = await compressBuffer(rawBuffer, "png", quality ?? 9, maxWidth);
19554
19592
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/lib/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AA6CpG,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE,iBAAiB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACrF,OAAO,CAAC,gBAAgB,CAAC,CAqI3B;AAID,wBAAsB,WAAW,CAC/B,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE,UAAU,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,OAAO,CAAC,SAAS,CAAC,CA6BpB"}
1
+ {"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/lib/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AA6CpG,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE,iBAAiB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACrF,OAAO,CAAC,gBAAgB,CAAC,CA+I3B;AAID,wBAAsB,WAAW,CAC/B,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE,UAAU,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,OAAO,CAAC,SAAS,CAAC,CA6BpB"}