@offscript/sdk 0.1.9 → 0.1.11

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,4 +1,4 @@
1
- import { buildPlaywrightContract, SDK_VERSION, SelectorGenerator, ACTION_SCHEMA_VERSION } from './chunk-KKEYBVTX.js';
1
+ import { buildPlaywrightContract, SDK_VERSION, SelectorGenerator, ACTION_SCHEMA_VERSION } from './chunk-6MFPECOC.js';
2
2
 
3
3
  // src/types/config.ts
4
4
  var DEFAULT_RECORDING = {
@@ -1264,6 +1264,7 @@ var RRWebRecorder = class {
1264
1264
  this.needsSnapshot = false;
1265
1265
  this.snapshotsTaken = 0;
1266
1266
  this.settling = false;
1267
+ this.recoveringSnapshot = false;
1267
1268
  }
1268
1269
  async start() {
1269
1270
  this.stopped = false;
@@ -1402,11 +1403,16 @@ var RRWebRecorder = class {
1402
1403
  }
1403
1404
  }
1404
1405
  takeFullSnapshot() {
1405
- if (this.stopped) return;
1406
- guard(this.sink, this.name, () => {
1407
- if (!this.mod?.record) return;
1408
- this.mod.record.takeFullSnapshot(true);
1409
- });
1406
+ if (this.stopped || this.recoveringSnapshot) return;
1407
+ this.recoveringSnapshot = true;
1408
+ try {
1409
+ guard(this.sink, this.name, () => {
1410
+ if (!this.mod?.record) return;
1411
+ this.mod.record.takeFullSnapshot(true);
1412
+ });
1413
+ } finally {
1414
+ this.recoveringSnapshot = false;
1415
+ }
1410
1416
  }
1411
1417
  addCustomEvent(tag, payload) {
1412
1418
  if (this.stopped) return;
@@ -2302,10 +2308,11 @@ async function encodeRecordingPayload(payload) {
2302
2308
  try {
2303
2309
  const stream = new CompressionStreamCtor("gzip");
2304
2310
  const writer = stream.writable.getWriter();
2311
+ const compressedBody = new Response(stream.readable).blob();
2305
2312
  await writer.write(new TextEncoder().encode(json));
2306
2313
  await writer.close();
2307
2314
  return {
2308
- body: await new Response(stream.readable).blob(),
2315
+ body: await compressedBody,
2309
2316
  contentEncoding: "gzip"
2310
2317
  };
2311
2318
  } catch {
@@ -2521,7 +2528,7 @@ var Offscript = class {
2521
2528
  this.rrweb = this.actions = this.context = void 0;
2522
2529
  this.payload = this.buildPayload();
2523
2530
  this.setStatus("stopped");
2524
- await this.store?.flush();
2531
+ if (this.store) this.save(this.store.flush());
2525
2532
  this.bus.emit("recordingEnd", this.payload);
2526
2533
  return this.payload;
2527
2534
  }
@@ -2763,5 +2770,5 @@ var Offscript = class {
2763
2770
  Offscript.version = SDK_VERSION;
2764
2771
 
2765
2772
  export { ConfigError, DEFAULT_PRIVACY, DEFAULT_RECORDING, DataSanitizer, InvalidStateError, Offscript, OffscriptError };
2766
- //# sourceMappingURL=chunk-5F637PDG.js.map
2767
- //# sourceMappingURL=chunk-5F637PDG.js.map
2773
+ //# sourceMappingURL=chunk-OKTRTFLH.js.map
2774
+ //# sourceMappingURL=chunk-OKTRTFLH.js.map