@offscript/sdk 0.1.8 → 0.1.10
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/dist/adapters/nuxt.cjs +3 -3
- package/dist/adapters/nuxt.js +2 -2
- package/dist/adapters/vanilla.cjs +5 -5
- package/dist/adapters/vanilla.js +3 -3
- package/dist/adapters/vue.cjs +3 -3
- package/dist/adapters/vue.js +2 -2
- package/dist/{chunk-AQG5MIW5.js → chunk-3AUFYXCH.js} +3 -3
- package/dist/chunk-3AUFYXCH.js.map +1 -0
- package/dist/{chunk-IOIVKJTV.js → chunk-4F52C3KC.js} +3 -3
- package/dist/{chunk-IOIVKJTV.js.map → chunk-4F52C3KC.js.map} +1 -1
- package/dist/{chunk-ZB2LSKD2.cjs → chunk-7JIK7MZN.cjs} +3 -3
- package/dist/chunk-7JIK7MZN.cjs.map +1 -0
- package/dist/{chunk-E53R6UOC.cjs → chunk-AX3BKPZJ.cjs} +52 -19
- package/dist/chunk-AX3BKPZJ.cjs.map +1 -0
- package/dist/{chunk-YIKWNN5R.cjs → chunk-FMMJ3ZE4.cjs} +4 -4
- package/dist/{chunk-YIKWNN5R.cjs.map → chunk-FMMJ3ZE4.cjs.map} +1 -1
- package/dist/{chunk-W27UMAEC.js → chunk-GWBQSYQQ.js} +47 -14
- package/dist/chunk-GWBQSYQQ.js.map +1 -0
- package/dist/core/OffscriptSDK.d.ts +1 -1
- package/dist/index.cjs +20 -20
- package/dist/index.js +3 -3
- package/dist/playwright.cjs +13 -13
- package/dist/playwright.js +1 -1
- package/dist/recorders/RRWebRecorder.d.ts +1 -0
- package/dist/types/events.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-AQG5MIW5.js.map +0 -1
- package/dist/chunk-E53R6UOC.cjs.map +0 -1
- package/dist/chunk-W27UMAEC.js.map +0 -1
- package/dist/chunk-ZB2LSKD2.cjs.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAX3BKPZJ_cjs = require('./chunk-AX3BKPZJ.cjs');
|
|
4
4
|
|
|
5
5
|
// src/adapters/vanilla.ts
|
|
6
6
|
async function createOffscript(config) {
|
|
7
|
-
const sdk = new
|
|
7
|
+
const sdk = new chunkAX3BKPZJ_cjs.Offscript(config);
|
|
8
8
|
await sdk.init();
|
|
9
9
|
return sdk;
|
|
10
10
|
}
|
|
@@ -16,5 +16,5 @@ async function startOffscript(config) {
|
|
|
16
16
|
|
|
17
17
|
exports.createOffscript = createOffscript;
|
|
18
18
|
exports.startOffscript = startOffscript;
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-FMMJ3ZE4.cjs.map
|
|
20
|
+
//# sourceMappingURL=chunk-FMMJ3ZE4.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/vanilla.ts"],"names":["Offscript"],"mappings":";;;;;AAIA,eAAsB,gBAAgB,MAAA,EAA6C;AACjF,EAAA,MAAM,GAAA,GAAM,IAAIA,2BAAA,CAAU,MAAM,CAAA;AAChC,EAAA,MAAM,IAAI,IAAA,EAAK;AACf,EAAA,OAAO,GAAA;AACT;AAEA,eAAsB,eAAe,MAAA,EAA6C;AAChF,EAAA,MAAM,GAAA,GAAM,MAAM,eAAA,CAAgB,MAAM,CAAA;AACxC,EAAA,MAAM,IAAI,cAAA,EAAe;AACzB,EAAA,OAAO,GAAA;AACT","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/adapters/vanilla.ts"],"names":["Offscript"],"mappings":";;;;;AAIA,eAAsB,gBAAgB,MAAA,EAA6C;AACjF,EAAA,MAAM,GAAA,GAAM,IAAIA,2BAAA,CAAU,MAAM,CAAA;AAChC,EAAA,MAAM,IAAI,IAAA,EAAK;AACf,EAAA,OAAO,GAAA;AACT;AAEA,eAAsB,eAAe,MAAA,EAA6C;AAChF,EAAA,MAAM,GAAA,GAAM,MAAM,eAAA,CAAgB,MAAM,CAAA;AACxC,EAAA,MAAM,IAAI,cAAA,EAAe;AACzB,EAAA,OAAO,GAAA;AACT","file":"chunk-FMMJ3ZE4.cjs","sourcesContent":["import { Offscript } from \"../core/OffscriptSDK\";\nimport type { OffscriptConfig } from \"../types/config\";\n\n/** Atalho para aplicações JS tradicionais, Blade e MPA: inicializa a captura local. */\nexport async function createOffscript(config: OffscriptConfig): Promise<Offscript> {\n const sdk = new Offscript(config);\n await sdk.init();\n return sdk;\n}\n\nexport async function startOffscript(config: OffscriptConfig): Promise<Offscript> {\n const sdk = await createOffscript(config);\n await sdk.startRecording();\n return sdk;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildPlaywrightContract, SDK_VERSION, SelectorGenerator, ACTION_SCHEMA_VERSION } from './chunk-
|
|
1
|
+
import { buildPlaywrightContract, SDK_VERSION, SelectorGenerator, ACTION_SCHEMA_VERSION } from './chunk-3AUFYXCH.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;
|
|
@@ -1295,7 +1296,6 @@ var RRWebRecorder = class {
|
|
|
1295
1296
|
// erros internos do rrweb não propagam
|
|
1296
1297
|
};
|
|
1297
1298
|
this.stopFn = mod.record(options) ?? void 0;
|
|
1298
|
-
this.scheduleSnapshot();
|
|
1299
1299
|
}
|
|
1300
1300
|
/** Captura o DOM depois do ciclo de renderização atual (Vue, React, etc.). */
|
|
1301
1301
|
scheduleSnapshot() {
|
|
@@ -1363,7 +1363,9 @@ var RRWebRecorder = class {
|
|
|
1363
1363
|
const emitted = this.sink.emit("rrweb", event, { priority, at: event.timestamp });
|
|
1364
1364
|
if (event.type === 2) {
|
|
1365
1365
|
this.needsSnapshot = !emitted;
|
|
1366
|
-
if (emitted)
|
|
1366
|
+
if (emitted) {
|
|
1367
|
+
this.snapshotsTaken++;
|
|
1368
|
+
}
|
|
1367
1369
|
}
|
|
1368
1370
|
if (!emitted && event.type === 3) this.needsSnapshot = true;
|
|
1369
1371
|
});
|
|
@@ -1401,11 +1403,16 @@ var RRWebRecorder = class {
|
|
|
1401
1403
|
}
|
|
1402
1404
|
}
|
|
1403
1405
|
takeFullSnapshot() {
|
|
1404
|
-
if (this.stopped) return;
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
this.
|
|
1408
|
-
|
|
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
|
+
}
|
|
1409
1416
|
}
|
|
1410
1417
|
addCustomEvent(tag, payload) {
|
|
1411
1418
|
if (this.stopped) return;
|
|
@@ -1424,7 +1431,8 @@ var RRWebRecorder = class {
|
|
|
1424
1431
|
this.takeFullSnapshot();
|
|
1425
1432
|
}
|
|
1426
1433
|
stop() {
|
|
1427
|
-
|
|
1434
|
+
const snapshotPending = this.settling || this.scheduledSnapshotFrame !== void 0;
|
|
1435
|
+
if (!this.stopped && !this.paused && snapshotPending) this.takeFullSnapshot();
|
|
1428
1436
|
this.stopped = true;
|
|
1429
1437
|
this.cancelScheduledSnapshot();
|
|
1430
1438
|
safe(() => this.stopFn?.());
|
|
@@ -2293,6 +2301,24 @@ function tokenFingerprint(token) {
|
|
|
2293
2301
|
}
|
|
2294
2302
|
return `${first >>> 0}.${second >>> 0}`;
|
|
2295
2303
|
}
|
|
2304
|
+
async function encodeRecordingPayload(payload) {
|
|
2305
|
+
const json = JSON.stringify(payload);
|
|
2306
|
+
const CompressionStreamCtor = globalThis.CompressionStream;
|
|
2307
|
+
if (!CompressionStreamCtor) return { body: json };
|
|
2308
|
+
try {
|
|
2309
|
+
const stream = new CompressionStreamCtor("gzip");
|
|
2310
|
+
const writer = stream.writable.getWriter();
|
|
2311
|
+
const compressedBody = new Response(stream.readable).blob();
|
|
2312
|
+
await writer.write(new TextEncoder().encode(json));
|
|
2313
|
+
await writer.close();
|
|
2314
|
+
return {
|
|
2315
|
+
body: await compressedBody,
|
|
2316
|
+
contentEncoding: "gzip"
|
|
2317
|
+
};
|
|
2318
|
+
} catch {
|
|
2319
|
+
return { body: json };
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2296
2322
|
var Offscript = class {
|
|
2297
2323
|
constructor(config = {}) {
|
|
2298
2324
|
this.bus = new Emitter();
|
|
@@ -2502,7 +2528,7 @@ var Offscript = class {
|
|
|
2502
2528
|
this.rrweb = this.actions = this.context = void 0;
|
|
2503
2529
|
this.payload = this.buildPayload();
|
|
2504
2530
|
this.setStatus("stopped");
|
|
2505
|
-
|
|
2531
|
+
if (this.store) this.save(this.store.flush());
|
|
2506
2532
|
this.bus.emit("recordingEnd", this.payload);
|
|
2507
2533
|
return this.payload;
|
|
2508
2534
|
}
|
|
@@ -2524,10 +2550,17 @@ var Offscript = class {
|
|
|
2524
2550
|
if (!["https:", "http:"].includes(url.protocol)) throw new ConfigError("Endpoint HTTP inv\xE1lido");
|
|
2525
2551
|
const payload = await this.stopRecording();
|
|
2526
2552
|
try {
|
|
2553
|
+
const encodedPayload = await encodeRecordingPayload(payload);
|
|
2554
|
+
const headers = {
|
|
2555
|
+
"Content-Type": "application/json",
|
|
2556
|
+
Accept: "application/json",
|
|
2557
|
+
Authorization: `Bearer ${token}`
|
|
2558
|
+
};
|
|
2559
|
+
if (encodedPayload.contentEncoding) headers["Content-Encoding"] = encodedPayload.contentEncoding;
|
|
2527
2560
|
const response = await fetch(url.href, {
|
|
2528
2561
|
method: "POST",
|
|
2529
|
-
headers
|
|
2530
|
-
body:
|
|
2562
|
+
headers,
|
|
2563
|
+
body: encodedPayload.body
|
|
2531
2564
|
});
|
|
2532
2565
|
if (!response.ok) throw new OffscriptError("TRANSPORT_FAILED", `Falha ao enviar grava\xE7\xE3o: HTTP ${response.status}`, { status: response.status });
|
|
2533
2566
|
this.submitted = true;
|
|
@@ -2737,5 +2770,5 @@ var Offscript = class {
|
|
|
2737
2770
|
Offscript.version = SDK_VERSION;
|
|
2738
2771
|
|
|
2739
2772
|
export { ConfigError, DEFAULT_PRIVACY, DEFAULT_RECORDING, DataSanitizer, InvalidStateError, Offscript, OffscriptError };
|
|
2740
|
-
//# sourceMappingURL=chunk-
|
|
2741
|
-
//# sourceMappingURL=chunk-
|
|
2773
|
+
//# sourceMappingURL=chunk-GWBQSYQQ.js.map
|
|
2774
|
+
//# sourceMappingURL=chunk-GWBQSYQQ.js.map
|