instruckt 0.4.23 → 0.4.25

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.
@@ -2417,14 +2417,20 @@ function captureRectFromStream(stream, rect) {
2417
2417
  return canvas.toDataURL("image/png");
2418
2418
  });
2419
2419
  }
2420
+ var preferScreenCapture = false;
2421
+ function setPreferScreenCapture(value) {
2422
+ preferScreenCapture = value;
2423
+ }
2420
2424
  async function captureElement(el) {
2421
- try {
2422
- const dataUrl = await domToPng(el, {
2423
- scale: 2,
2424
- filter: nodeFilter
2425
- });
2426
- if (dataUrl) return dataUrl;
2427
- } catch (e) {
2425
+ if (!preferScreenCapture) {
2426
+ try {
2427
+ const dataUrl = await domToPng(el, {
2428
+ scale: 2,
2429
+ filter: nodeFilter
2430
+ });
2431
+ if (dataUrl) return dataUrl;
2432
+ } catch (e) {
2433
+ }
2428
2434
  }
2429
2435
  try {
2430
2436
  const stream = await getStream();
@@ -2435,13 +2441,15 @@ async function captureElement(el) {
2435
2441
  }
2436
2442
  }
2437
2443
  async function captureRegion(rect) {
2438
- try {
2439
- const full = await domToPng(document.body, {
2440
- scale: 2,
2441
- filter: nodeFilter
2442
- });
2443
- if (full) return await cropImage(full, rect);
2444
- } catch (e) {
2444
+ if (!preferScreenCapture) {
2445
+ try {
2446
+ const full = await domToPng(document.body, {
2447
+ scale: 2,
2448
+ filter: nodeFilter
2449
+ });
2450
+ if (full) return await cropImage(full, rect);
2451
+ } catch (e) {
2452
+ }
2445
2453
  }
2446
2454
  try {
2447
2455
  const stream = await getStream();
@@ -3176,6 +3184,7 @@ var _Instruckt = class _Instruckt {
3176
3184
  this.pendingMouseTarget = null;
3177
3185
  this.highlightLocked = false;
3178
3186
  this.pollTimer = null;
3187
+ this.initialLoadDone = false;
3179
3188
  this.boundReposition = () => {
3180
3189
  var _a2;
3181
3190
  (_a2 = this.markers) == null ? void 0 : _a2.reposition(this.annotations);
@@ -3274,7 +3283,12 @@ var _Instruckt = class _Instruckt {
3274
3283
  this.init();
3275
3284
  }
3276
3285
  init() {
3286
+ var _a2;
3277
3287
  injectGlobalStyles(this.config.colors);
3288
+ const adapters = (_a2 = this.config.adapters) != null ? _a2 : [];
3289
+ if (adapters.includes("livewire") && isAvailable()) {
3290
+ setPreferScreenCapture(true);
3291
+ }
3278
3292
  if (this.config.theme !== "auto") {
3279
3293
  document.documentElement.setAttribute("data-instruckt-theme", this.config.theme);
3280
3294
  }
@@ -3364,6 +3378,7 @@ var _Instruckt = class _Instruckt {
3364
3378
  this.saveToStorage();
3365
3379
  } catch (e) {
3366
3380
  }
3381
+ this.initialLoadDone = true;
3367
3382
  this.syncMarkers();
3368
3383
  }
3369
3384
  saveToStorage() {
@@ -3381,6 +3396,7 @@ var _Instruckt = class _Instruckt {
3381
3396
  }
3382
3397
  /** Start or stop polling based on whether there are active annotations */
3383
3398
  updatePolling() {
3399
+ if (!this.initialLoadDone) return;
3384
3400
  const hasActive = this.totalActiveCount() > 0;
3385
3401
  if (hasActive && !this.pollTimer) {
3386
3402
  this.pollTimer = setInterval(() => this.pollForChanges(), 3e3);
@@ -3882,7 +3898,7 @@ No open annotations.`;
3882
3898
  }
3883
3899
  };
3884
3900
  // ── Persistence ─────────────────────────────────────────────────
3885
- _Instruckt.STORAGE_KEY = "instruckt:annotations";
3901
+ _Instruckt.STORAGE_KEY = `instruckt:${window.location.origin}:annotations`;
3886
3902
  var Instruckt = _Instruckt;
3887
3903
 
3888
3904
  // src/index.ts