@openvidstudio/capture 2.0.0 → 2.1.0

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/browser.d.ts CHANGED
@@ -60,6 +60,9 @@ export type Interaction = {
60
60
  } | {
61
61
  type: "settle";
62
62
  ms?: number;
63
+ } | {
64
+ type: "navigate";
65
+ url: string;
63
66
  };
64
67
  export declare const interactionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
65
68
  type: z.ZodLiteral<"click">;
@@ -88,6 +91,9 @@ export declare const interactionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
88
91
  }, z.core.$strip>, z.ZodObject<{
89
92
  type: z.ZodLiteral<"settle">;
90
93
  ms: z.ZodOptional<z.ZodNumber>;
94
+ }, z.core.$strip>, z.ZodObject<{
95
+ type: z.ZodLiteral<"navigate">;
96
+ url: z.ZodString;
91
97
  }, z.core.$strip>], "type">;
92
98
  /**
93
99
  * Replays a beat's interactions in array order. Shared verbatim by both capture
@@ -109,6 +115,35 @@ export interface ZoomCompensation {
109
115
  zoom: number;
110
116
  /** The last-measured `[window.innerWidth, window.innerHeight]`. */
111
117
  effective: Viewport;
118
+ /** `window.devicePixelRatio` as read before compensation. Only present when a device scale factor was given. */
119
+ devicePixelRatio?: number;
120
+ }
121
+ export interface ZoomCheckOptions {
122
+ /**
123
+ * The device scale factor the page's context was created with. When given, `window.devicePixelRatio`
124
+ * is read too and has to agree with `innerWidth` about the zoom: a page that reports a different
125
+ * zoom from its width than from its pixel ratio is not one a frame can be trusted from.
126
+ */
127
+ deviceScaleFactor?: number;
128
+ }
129
+ /**
130
+ * Thrown before anything is captured when what the page reports (`innerWidth`, `devicePixelRatio`)
131
+ * does not fit what was requested and cannot be explained as a consistent zoom. Carries the
132
+ * measurements so a caller can show them.
133
+ */
134
+ export declare class ViewportDesyncError extends Error {
135
+ readonly target: Viewport;
136
+ readonly measured: {
137
+ innerWidth: number;
138
+ innerHeight: number;
139
+ devicePixelRatio: number;
140
+ };
141
+ readonly deviceScaleFactor: number;
142
+ constructor(message: string, target: Viewport, measured: {
143
+ innerWidth: number;
144
+ innerHeight: number;
145
+ devicePixelRatio: number;
146
+ }, deviceScaleFactor: number);
112
147
  }
113
148
  /**
114
149
  * Thrown when a single compensation attempt doesn't converge -- CAPTURE.md
@@ -122,6 +157,43 @@ export declare class ZoomCompensationError extends Error {
122
157
  readonly effective: Viewport;
123
158
  constructor(target: Viewport, zoom: number, effective: Viewport);
124
159
  }
160
+ /**
161
+ * Before any compensation: `innerWidth` and `devicePixelRatio` are two independent readings of the
162
+ * same browser zoom. A real per-origin zoom of z shows as `target / innerWidth = z` and
163
+ * `devicePixelRatio / deviceScaleFactor = z` together. When they disagree the page is in a state
164
+ * compensating the viewport cannot fix (an emulated device scale that was not applied, a forced
165
+ * scale factor on the browser), and every pixel measurement after it would be wrong.
166
+ */
167
+ export declare function judgeZoomSignals(opts: {
168
+ target: Viewport;
169
+ deviceScaleFactor: number;
170
+ innerWidth: number;
171
+ innerHeight: number;
172
+ devicePixelRatio: number;
173
+ }): string | null;
174
+ /**
175
+ * After compensation, against a page that is about to be captured: the compensated viewport has
176
+ * to put `innerWidth`/`innerHeight` back on the request, and `devicePixelRatio` has to still sit at
177
+ * `deviceScaleFactor * zoom`, the zoom measured earlier. Anything else means the page the capture
178
+ * is about to run on is not the page that was probed.
179
+ */
180
+ export declare function judgeCompensatedViewport(opts: {
181
+ target: Viewport;
182
+ deviceScaleFactor: number;
183
+ zoom: number;
184
+ innerWidth: number;
185
+ innerHeight: number;
186
+ devicePixelRatio: number;
187
+ }): string | null;
188
+ /**
189
+ * Reads `innerWidth`, `innerHeight` and `devicePixelRatio` from the page that is about to be recorded
190
+ * and throws ViewportDesyncError if they do not match the compensated request. Call it after
191
+ * navigation and before the recording does anything, so a desync costs a clear error and not a clip.
192
+ */
193
+ export declare function assertViewportBeforeRecording(page: Page, target: Viewport, opts: {
194
+ deviceScaleFactor: number;
195
+ zoom: number;
196
+ }): Promise<void>;
125
197
  /**
126
198
  * CAPTURE.md's zoom-desync detection + compensation (protocol steps 1-2).
127
199
  * Assumes the caller already called `page.setViewportSize(target)` and
@@ -134,7 +206,7 @@ export declare class ZoomCompensationError extends Error {
134
206
  * `target` within `ZOOM_EPSILON`, throws `ZoomCompensationError` rather than
135
207
  * silently proceeding.
136
208
  */
137
- export declare function detectAndCompensateZoom(page: Page, target: Viewport): Promise<ZoomCompensation>;
209
+ export declare function detectAndCompensateZoom(page: Page, target: Viewport, opts?: ZoomCheckOptions): Promise<ZoomCompensation>;
138
210
  /**
139
211
  * Playwright's bundled browser binary is not installed by a plain `npm
140
212
  * install`/`pnpm install` (it needs a separate `npx playwright install
package/dist/browser.js CHANGED
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.chromium = exports.ZoomCompensationError = exports.ZOOM_EPSILON = exports.interactionSchema = exports.viewportSchema = exports.DEFAULT_DEVICE_SCALE = exports.DEFAULT_VIEWPORT = void 0;
3
+ exports.chromium = exports.ZoomCompensationError = exports.ViewportDesyncError = exports.ZOOM_EPSILON = exports.interactionSchema = exports.viewportSchema = exports.DEFAULT_DEVICE_SCALE = exports.DEFAULT_VIEWPORT = void 0;
4
4
  exports.replayInteractions = replayInteractions;
5
+ exports.judgeZoomSignals = judgeZoomSignals;
6
+ exports.judgeCompensatedViewport = judgeCompensatedViewport;
7
+ exports.assertViewportBeforeRecording = assertViewportBeforeRecording;
5
8
  exports.detectAndCompensateZoom = detectAndCompensateZoom;
6
9
  exports.launchChromium = launchChromium;
7
10
  exports.resolvedPlaywrightVersion = resolvedPlaywrightVersion;
@@ -52,6 +55,8 @@ exports.interactionSchema = zod_1.z.discriminatedUnion("type", [
52
55
  // transition, a route change, a lazily loaded image) to completion before the next step
53
56
  // runs, which is what stops a capture landing halfway through a fade.
54
57
  zod_1.z.object({ type: zod_1.z.literal("settle"), ms: zod_1.z.number().optional() }),
58
+ // Go to another page mid-path. A relative url resolves against the page the replay is on.
59
+ zod_1.z.object({ type: zod_1.z.literal("navigate"), url: zod_1.z.string().min(1) }),
55
60
  ]);
56
61
  /**
57
62
  * Runs in the page against a scrollable element. `behavior: "smooth"` was rejected on
@@ -199,12 +204,30 @@ async function replayInteractions(page, interactions) {
199
204
  case "settle":
200
205
  await (0, settle_1.settlePage)(page, { timeoutMs: interaction.ms });
201
206
  break;
207
+ case "navigate":
208
+ await page.goto(new URL(interaction.url, page.url()).toString(), { waitUntil: "load" });
209
+ break;
202
210
  }
203
211
  index++;
204
212
  }
205
213
  return points;
206
214
  }
207
215
  exports.ZOOM_EPSILON = 0.01;
216
+ /**
217
+ * Thrown before anything is captured when what the page reports (`innerWidth`, `devicePixelRatio`)
218
+ * does not fit what was requested and cannot be explained as a consistent zoom. Carries the
219
+ * measurements so a caller can show them.
220
+ */
221
+ class ViewportDesyncError extends Error {
222
+ constructor(message, target, measured, deviceScaleFactor) {
223
+ super(message);
224
+ this.target = target;
225
+ this.measured = measured;
226
+ this.deviceScaleFactor = deviceScaleFactor;
227
+ this.name = "ViewportDesyncError";
228
+ }
229
+ }
230
+ exports.ViewportDesyncError = ViewportDesyncError;
208
231
  /**
209
232
  * Thrown when a single compensation attempt doesn't converge -- CAPTURE.md
210
233
  * doesn't explicitly cover this case (it assumes the desync ratio is
@@ -229,6 +252,69 @@ async function measureEffectiveViewport(page) {
229
252
  const [width, height] = await page.evaluate(() => [window.innerWidth, window.innerHeight]);
230
253
  return { width, height };
231
254
  }
255
+ async function readDevicePixelRatio(page) {
256
+ return page.evaluate(() => window.devicePixelRatio);
257
+ }
258
+ function describeReading(target, deviceScaleFactor, m) {
259
+ return (`requested ${target.width}x${target.height} at device scale ${deviceScaleFactor}, but the page reports ` +
260
+ `innerWidth ${m.innerWidth}, innerHeight ${m.innerHeight} and devicePixelRatio ${m.devicePixelRatio}`);
261
+ }
262
+ /**
263
+ * Before any compensation: `innerWidth` and `devicePixelRatio` are two independent readings of the
264
+ * same browser zoom. A real per-origin zoom of z shows as `target / innerWidth = z` and
265
+ * `devicePixelRatio / deviceScaleFactor = z` together. When they disagree the page is in a state
266
+ * compensating the viewport cannot fix (an emulated device scale that was not applied, a forced
267
+ * scale factor on the browser), and every pixel measurement after it would be wrong.
268
+ */
269
+ function judgeZoomSignals(opts) {
270
+ const zoomByWidth = opts.target.width / opts.innerWidth;
271
+ const zoomByDpr = opts.devicePixelRatio / opts.deviceScaleFactor;
272
+ if (Math.abs(zoomByWidth - zoomByDpr) <= exports.ZOOM_EPSILON * Math.max(zoomByWidth, zoomByDpr))
273
+ return null;
274
+ const m = { innerWidth: opts.innerWidth, innerHeight: opts.innerHeight, devicePixelRatio: opts.devicePixelRatio };
275
+ return (`Viewport desync before capture: ${describeReading(opts.target, opts.deviceScaleFactor, m)}. innerWidth ` +
276
+ `implies a zoom of ${zoomByWidth.toFixed(3)} but devicePixelRatio implies ${zoomByDpr.toFixed(3)}. A ` +
277
+ `browser zoom moves both by the same factor, so this is something else (a device scale factor that was ` +
278
+ `not applied, or a scale factor forced on the browser) and shrinking or growing the viewport cannot ` +
279
+ `correct it. Frames from this page would not be the size the request asked for -- see ` +
280
+ `packages/docs/CAPTURE.md, "The zoom-desync bug".`);
281
+ }
282
+ /**
283
+ * After compensation, against a page that is about to be captured: the compensated viewport has
284
+ * to put `innerWidth`/`innerHeight` back on the request, and `devicePixelRatio` has to still sit at
285
+ * `deviceScaleFactor * zoom`, the zoom measured earlier. Anything else means the page the capture
286
+ * is about to run on is not the page that was probed.
287
+ */
288
+ function judgeCompensatedViewport(opts) {
289
+ const m = { innerWidth: opts.innerWidth, innerHeight: opts.innerHeight, devicePixelRatio: opts.devicePixelRatio };
290
+ const problems = [];
291
+ if (relativeDiff(opts.innerWidth, opts.target.width) > exports.ZOOM_EPSILON ||
292
+ relativeDiff(opts.innerHeight, opts.target.height) > exports.ZOOM_EPSILON) {
293
+ problems.push(`innerWidth x innerHeight is ${opts.innerWidth}x${opts.innerHeight}, not the requested ${opts.target.width}x${opts.target.height}`);
294
+ }
295
+ const expectedDpr = opts.deviceScaleFactor * opts.zoom;
296
+ if (Math.abs(opts.devicePixelRatio - expectedDpr) > exports.ZOOM_EPSILON * expectedDpr) {
297
+ problems.push(`devicePixelRatio is ${opts.devicePixelRatio}, but device scale ${opts.deviceScaleFactor} at the measured zoom ` +
298
+ `${opts.zoom.toFixed(3)} should give ${expectedDpr.toFixed(3)}`);
299
+ }
300
+ if (problems.length === 0)
301
+ return null;
302
+ return (`Viewport desync at the start of recording: ${describeReading(opts.target, opts.deviceScaleFactor, m)}. ` +
303
+ `${problems.join("; ")}. The recording would not be the size the request asked for, so it was not started -- ` +
304
+ `see packages/docs/CAPTURE.md, "The zoom-desync bug".`);
305
+ }
306
+ /**
307
+ * Reads `innerWidth`, `innerHeight` and `devicePixelRatio` from the page that is about to be recorded
308
+ * and throws ViewportDesyncError if they do not match the compensated request. Call it after
309
+ * navigation and before the recording does anything, so a desync costs a clear error and not a clip.
310
+ */
311
+ async function assertViewportBeforeRecording(page, target, opts) {
312
+ const [innerWidth, innerHeight] = await page.evaluate(() => [window.innerWidth, window.innerHeight]);
313
+ const devicePixelRatio = await readDevicePixelRatio(page);
314
+ const problem = judgeCompensatedViewport({ target, ...opts, innerWidth, innerHeight, devicePixelRatio });
315
+ if (problem)
316
+ throw new ViewportDesyncError(problem, target, { innerWidth, innerHeight, devicePixelRatio }, opts.deviceScaleFactor);
317
+ }
232
318
  function relativeDiff(actual, target) {
233
319
  return Math.abs(actual - target) / target;
234
320
  }
@@ -244,11 +330,25 @@ function relativeDiff(actual, target) {
244
330
  * `target` within `ZOOM_EPSILON`, throws `ZoomCompensationError` rather than
245
331
  * silently proceeding.
246
332
  */
247
- async function detectAndCompensateZoom(page, target) {
333
+ async function detectAndCompensateZoom(page, target, opts = {}) {
248
334
  const firstMeasurement = await measureEffectiveViewport(page);
249
335
  const zoom = target.width / firstMeasurement.width;
336
+ let devicePixelRatio;
337
+ if (opts.deviceScaleFactor !== undefined) {
338
+ devicePixelRatio = await readDevicePixelRatio(page);
339
+ const problem = judgeZoomSignals({
340
+ target,
341
+ deviceScaleFactor: opts.deviceScaleFactor,
342
+ innerWidth: firstMeasurement.width,
343
+ innerHeight: firstMeasurement.height,
344
+ devicePixelRatio,
345
+ });
346
+ if (problem) {
347
+ throw new ViewportDesyncError(problem, target, { innerWidth: firstMeasurement.width, innerHeight: firstMeasurement.height, devicePixelRatio }, opts.deviceScaleFactor);
348
+ }
349
+ }
250
350
  if (Math.abs(zoom - 1) <= exports.ZOOM_EPSILON) {
251
- return { viewport: target, zoom, effective: firstMeasurement };
351
+ return { viewport: target, zoom, effective: firstMeasurement, ...(devicePixelRatio !== undefined ? { devicePixelRatio } : {}) };
252
352
  }
253
353
  const compensated = {
254
354
  width: Math.round(target.width * zoom),
@@ -261,7 +361,7 @@ async function detectAndCompensateZoom(page, target) {
261
361
  if (!converged) {
262
362
  throw new ZoomCompensationError(target, zoom, secondMeasurement);
263
363
  }
264
- return { viewport: compensated, zoom, effective: secondMeasurement };
364
+ return { viewport: compensated, zoom, effective: secondMeasurement, ...(devicePixelRatio !== undefined ? { devicePixelRatio } : {}) };
265
365
  }
266
366
  const BROWSER_NOT_INSTALLED_RE = /Executable doesn't exist at/;
267
367
  /**
package/dist/index.d.ts CHANGED
@@ -11,6 +11,8 @@
11
11
  */
12
12
  export * from "./process";
13
13
  export * from "./browser";
14
+ export * from "./scenario";
15
+ export * from "./viewports";
14
16
  export * from "./determinism";
15
17
  export * from "./settle";
16
18
  export * from "./cursor";
package/dist/index.js CHANGED
@@ -27,6 +27,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
27
27
  */
28
28
  __exportStar(require("./process"), exports);
29
29
  __exportStar(require("./browser"), exports);
30
+ __exportStar(require("./scenario"), exports);
31
+ __exportStar(require("./viewports"), exports);
30
32
  __exportStar(require("./determinism"), exports);
31
33
  __exportStar(require("./settle"), exports);
32
34
  __exportStar(require("./cursor"), exports);
@@ -0,0 +1,100 @@
1
+ import { z } from "zod";
2
+ import type { Interaction } from "./browser";
3
+ export declare const scenarioStepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
+ action: z.ZodLiteral<"navigate">;
5
+ url: z.ZodString;
6
+ settleMs: z.ZodOptional<z.ZodNumber>;
7
+ }, z.core.$strip>, z.ZodObject<{
8
+ action: z.ZodLiteral<"click">;
9
+ selector: z.ZodString;
10
+ settleMs: z.ZodOptional<z.ZodNumber>;
11
+ }, z.core.$strip>, z.ZodObject<{
12
+ action: z.ZodLiteral<"hover">;
13
+ selector: z.ZodString;
14
+ settleMs: z.ZodOptional<z.ZodNumber>;
15
+ }, z.core.$strip>, z.ZodObject<{
16
+ action: z.ZodLiteral<"type">;
17
+ selector: z.ZodString;
18
+ text: z.ZodString;
19
+ settleMs: z.ZodOptional<z.ZodNumber>;
20
+ }, z.core.$strip>, z.ZodObject<{
21
+ action: z.ZodLiteral<"select">;
22
+ selector: z.ZodString;
23
+ value: z.ZodString;
24
+ settleMs: z.ZodOptional<z.ZodNumber>;
25
+ }, z.core.$strip>, z.ZodObject<{
26
+ action: z.ZodLiteral<"scroll">;
27
+ selector: z.ZodOptional<z.ZodString>;
28
+ x: z.ZodOptional<z.ZodNumber>;
29
+ y: z.ZodOptional<z.ZodNumber>;
30
+ durationMs: z.ZodOptional<z.ZodNumber>;
31
+ settleMs: z.ZodOptional<z.ZodNumber>;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ action: z.ZodLiteral<"wait">;
34
+ ms: z.ZodOptional<z.ZodNumber>;
35
+ selector: z.ZodOptional<z.ZodString>;
36
+ settleMs: z.ZodOptional<z.ZodNumber>;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ action: z.ZodLiteral<"settle">;
39
+ ms: z.ZodOptional<z.ZodNumber>;
40
+ }, z.core.$strip>], "action">;
41
+ export type ScenarioStep = z.infer<typeof scenarioStepSchema>;
42
+ export declare const scenarioSchema: z.ZodObject<{
43
+ name: z.ZodOptional<z.ZodString>;
44
+ url: z.ZodOptional<z.ZodString>;
45
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
46
+ action: z.ZodLiteral<"navigate">;
47
+ url: z.ZodString;
48
+ settleMs: z.ZodOptional<z.ZodNumber>;
49
+ }, z.core.$strip>, z.ZodObject<{
50
+ action: z.ZodLiteral<"click">;
51
+ selector: z.ZodString;
52
+ settleMs: z.ZodOptional<z.ZodNumber>;
53
+ }, z.core.$strip>, z.ZodObject<{
54
+ action: z.ZodLiteral<"hover">;
55
+ selector: z.ZodString;
56
+ settleMs: z.ZodOptional<z.ZodNumber>;
57
+ }, z.core.$strip>, z.ZodObject<{
58
+ action: z.ZodLiteral<"type">;
59
+ selector: z.ZodString;
60
+ text: z.ZodString;
61
+ settleMs: z.ZodOptional<z.ZodNumber>;
62
+ }, z.core.$strip>, z.ZodObject<{
63
+ action: z.ZodLiteral<"select">;
64
+ selector: z.ZodString;
65
+ value: z.ZodString;
66
+ settleMs: z.ZodOptional<z.ZodNumber>;
67
+ }, z.core.$strip>, z.ZodObject<{
68
+ action: z.ZodLiteral<"scroll">;
69
+ selector: z.ZodOptional<z.ZodString>;
70
+ x: z.ZodOptional<z.ZodNumber>;
71
+ y: z.ZodOptional<z.ZodNumber>;
72
+ durationMs: z.ZodOptional<z.ZodNumber>;
73
+ settleMs: z.ZodOptional<z.ZodNumber>;
74
+ }, z.core.$strip>, z.ZodObject<{
75
+ action: z.ZodLiteral<"wait">;
76
+ ms: z.ZodOptional<z.ZodNumber>;
77
+ selector: z.ZodOptional<z.ZodString>;
78
+ settleMs: z.ZodOptional<z.ZodNumber>;
79
+ }, z.core.$strip>, z.ZodObject<{
80
+ action: z.ZodLiteral<"settle">;
81
+ ms: z.ZodOptional<z.ZodNumber>;
82
+ }, z.core.$strip>], "action">>;
83
+ }, z.core.$strip>;
84
+ export type Scenario = z.infer<typeof scenarioSchema>;
85
+ export type ScenarioFormat = "json" | "yaml";
86
+ /** Parses scenario text, naming the step and field of any mistake. `filePath` only picks the format and names the file in errors. */
87
+ export declare function parseScenario(text: string, filePath?: string): Scenario;
88
+ export declare function loadScenarioFile(file: string): Scenario;
89
+ export interface CompiledScenario {
90
+ url?: string;
91
+ interactions: Interaction[];
92
+ }
93
+ /** The interactions array (and starting url) a scenario stands for. */
94
+ export declare function compileScenario(scenario: Scenario): CompiledScenario;
95
+ /**
96
+ * The reverse, for moving an existing beat to a file: every interaction becomes a step, and a settle
97
+ * that directly follows a step folds into that step's settleMs. compileScenario(scenarioFromInteractions(x))
98
+ * gives x back for every array this package can run.
99
+ */
100
+ export declare function scenarioFromInteractions(interactions: Interaction[], url?: string): Scenario;
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.scenarioSchema = exports.scenarioStepSchema = void 0;
37
+ exports.parseScenario = parseScenario;
38
+ exports.loadScenarioFile = loadScenarioFile;
39
+ exports.compileScenario = compileScenario;
40
+ exports.scenarioFromInteractions = scenarioFromInteractions;
41
+ const fs = __importStar(require("node:fs"));
42
+ const path = __importStar(require("node:path"));
43
+ const zod_1 = require("zod");
44
+ const yaml = __importStar(require("js-yaml"));
45
+ /**
46
+ * A capture scenario: the click path to a beat's state as a file, instead of an `interactions`
47
+ * array pasted into a tool call or a beats.json.
48
+ *
49
+ * # scenarios/checkout.yaml
50
+ * url: http://localhost:3000
51
+ * steps:
52
+ * - action: click
53
+ * selector: "#buy"
54
+ * settleMs: 1500 # optional: let this step finish before the next one
55
+ * - action: type
56
+ * selector: "#email"
57
+ * text: a@b.co
58
+ * - action: scroll
59
+ * y: 800
60
+ * durationMs: 600
61
+ *
62
+ * JSON and YAML read the same. The scenario compiles to the `interactions` array every capture
63
+ * tool already runs (compileScenario), so nothing downstream learned a second format, and an
64
+ * existing array converts the other way (scenarioFromInteractions) so a beat that works today
65
+ * keeps working when it moves to a file.
66
+ */
67
+ const selector = zod_1.z.string().min(1);
68
+ /** Optional on any step: how long to let the page settle after the step, in ms. Compiles to a settle step. */
69
+ const settleMs = zod_1.z.number().positive().optional();
70
+ exports.scenarioStepSchema = zod_1.z.discriminatedUnion("action", [
71
+ zod_1.z.object({ action: zod_1.z.literal("navigate"), url: zod_1.z.string().min(1), settleMs }),
72
+ zod_1.z.object({ action: zod_1.z.literal("click"), selector, settleMs }),
73
+ zod_1.z.object({ action: zod_1.z.literal("hover"), selector, settleMs }),
74
+ zod_1.z.object({ action: zod_1.z.literal("type"), selector, text: zod_1.z.string(), settleMs }),
75
+ zod_1.z.object({ action: zod_1.z.literal("select"), selector, value: zod_1.z.string(), settleMs }),
76
+ zod_1.z.object({
77
+ action: zod_1.z.literal("scroll"),
78
+ selector: selector.optional(),
79
+ x: zod_1.z.number().optional(),
80
+ y: zod_1.z.number().optional(),
81
+ durationMs: zod_1.z.number().positive().optional(),
82
+ settleMs,
83
+ }),
84
+ zod_1.z.object({ action: zod_1.z.literal("wait"), ms: zod_1.z.number().nonnegative().optional(), selector: selector.optional(), settleMs }),
85
+ // Drive whatever the previous step started to completion, as its own step. settleMs on a step is the
86
+ // shorthand for this directly after it.
87
+ zod_1.z.object({ action: zod_1.z.literal("settle"), ms: zod_1.z.number().positive().optional() }),
88
+ ]);
89
+ exports.scenarioSchema = zod_1.z.object({
90
+ /** Free text, for the person reading the file. */
91
+ name: zod_1.z.string().optional(),
92
+ /** Where the capture starts. Optional when the tool call gives a url. */
93
+ url: zod_1.z.string().min(1).optional(),
94
+ steps: zod_1.z.array(exports.scenarioStepSchema),
95
+ });
96
+ function formatOf(text, filePath) {
97
+ const ext = filePath ? path.extname(filePath).toLowerCase() : "";
98
+ if (ext === ".json")
99
+ return "json";
100
+ if (ext === ".yaml" || ext === ".yml")
101
+ return "yaml";
102
+ return text.trimStart().startsWith("{") ? "json" : "yaml";
103
+ }
104
+ /** Parses scenario text, naming the step and field of any mistake. `filePath` only picks the format and names the file in errors. */
105
+ function parseScenario(text, filePath) {
106
+ const label = filePath ?? "scenario";
107
+ const format = formatOf(text, filePath);
108
+ let raw;
109
+ try {
110
+ raw = format === "json" ? JSON.parse(text) : yaml.load(text);
111
+ }
112
+ catch (err) {
113
+ throw new Error(`${label} is not valid ${format.toUpperCase()}: ${err instanceof Error ? err.message : String(err)}`);
114
+ }
115
+ const parsed = exports.scenarioSchema.safeParse(raw);
116
+ if (!parsed.success) {
117
+ const issues = parsed.error.issues.map((i) => `${i.path.length ? i.path.join(".") : "(root)"}: ${i.message}`);
118
+ throw new Error(`${label} is not a valid scenario:\n ${issues.join("\n ")}`);
119
+ }
120
+ return parsed.data;
121
+ }
122
+ function loadScenarioFile(file) {
123
+ return parseScenario(fs.readFileSync(file, "utf8"), file);
124
+ }
125
+ /** One step as the interaction every capture tool runs. A step's settleMs follows as its own settle step. */
126
+ function compileStep(step) {
127
+ const out = [];
128
+ switch (step.action) {
129
+ case "navigate":
130
+ out.push({ type: "navigate", url: step.url });
131
+ break;
132
+ case "click":
133
+ out.push({ type: "click", selector: step.selector });
134
+ break;
135
+ case "hover":
136
+ out.push({ type: "hover", selector: step.selector });
137
+ break;
138
+ case "type":
139
+ out.push({ type: "fill", selector: step.selector, value: step.text });
140
+ break;
141
+ case "select":
142
+ out.push({ type: "select", selector: step.selector, value: step.value });
143
+ break;
144
+ case "scroll":
145
+ out.push({
146
+ type: "scroll",
147
+ ...(step.selector !== undefined ? { selector: step.selector } : {}),
148
+ ...(step.x !== undefined ? { x: step.x } : {}),
149
+ ...(step.y !== undefined ? { y: step.y } : {}),
150
+ ...(step.durationMs !== undefined ? { durationMs: step.durationMs } : {}),
151
+ });
152
+ break;
153
+ case "wait":
154
+ out.push({
155
+ type: "wait",
156
+ ...(step.ms !== undefined ? { ms: step.ms } : {}),
157
+ ...(step.selector !== undefined ? { selector: step.selector } : {}),
158
+ });
159
+ break;
160
+ case "settle":
161
+ out.push({ type: "settle", ...(step.ms !== undefined ? { ms: step.ms } : {}) });
162
+ return out;
163
+ }
164
+ if (step.settleMs !== undefined)
165
+ out.push({ type: "settle", ms: step.settleMs });
166
+ return out;
167
+ }
168
+ /** The interactions array (and starting url) a scenario stands for. */
169
+ function compileScenario(scenario) {
170
+ return {
171
+ ...(scenario.url !== undefined ? { url: scenario.url } : {}),
172
+ interactions: scenario.steps.flatMap(compileStep),
173
+ };
174
+ }
175
+ /**
176
+ * The reverse, for moving an existing beat to a file: every interaction becomes a step, and a settle
177
+ * that directly follows a step folds into that step's settleMs. compileScenario(scenarioFromInteractions(x))
178
+ * gives x back for every array this package can run.
179
+ */
180
+ function scenarioFromInteractions(interactions, url) {
181
+ const steps = [];
182
+ for (const i of interactions) {
183
+ const last = steps[steps.length - 1];
184
+ switch (i.type) {
185
+ case "navigate":
186
+ steps.push({ action: "navigate", url: i.url });
187
+ break;
188
+ case "click":
189
+ steps.push({ action: "click", selector: i.selector });
190
+ break;
191
+ case "hover":
192
+ steps.push({ action: "hover", selector: i.selector });
193
+ break;
194
+ case "fill":
195
+ steps.push({ action: "type", selector: i.selector, text: i.value });
196
+ break;
197
+ case "select":
198
+ steps.push({ action: "select", selector: i.selector, value: i.value });
199
+ break;
200
+ case "scroll":
201
+ steps.push({
202
+ action: "scroll",
203
+ ...(i.selector !== undefined ? { selector: i.selector } : {}),
204
+ ...(i.x !== undefined ? { x: i.x } : {}),
205
+ ...(i.y !== undefined ? { y: i.y } : {}),
206
+ ...(i.durationMs !== undefined ? { durationMs: i.durationMs } : {}),
207
+ });
208
+ break;
209
+ case "wait":
210
+ steps.push({
211
+ action: "wait",
212
+ ...(i.ms !== undefined ? { ms: i.ms } : {}),
213
+ ...(i.selector !== undefined ? { selector: i.selector } : {}),
214
+ });
215
+ break;
216
+ case "settle":
217
+ // A settle with a budget right after a step is that step's settleMs; any other is its own step.
218
+ if (last && last.action !== "settle" && last.settleMs === undefined && i.ms !== undefined && i.ms > 0)
219
+ last.settleMs = i.ms;
220
+ else
221
+ steps.push({ action: "settle", ...(i.ms !== undefined ? { ms: i.ms } : {}) });
222
+ break;
223
+ }
224
+ }
225
+ return { ...(url !== undefined ? { url } : {}), steps };
226
+ }
@@ -0,0 +1,75 @@
1
+ import { z } from "zod";
2
+ import { type Viewport } from "./browser";
3
+ /**
4
+ * Several viewports in one capture call.
5
+ *
6
+ * One page is usually three pages: a desktop layout, a tablet one and a phone one, and a demo
7
+ * that shows the responsive layout needs all of them from the same URL and the same state. Each
8
+ * viewport gets its own browser context, so its own viewport and its own device pixel ratio (a
9
+ * phone is 3x, a desktop 1x or 2x, and a context cannot change that after it is created), and its
10
+ * own output file named for it.
11
+ */
12
+ export interface ViewportSpec {
13
+ /** File-name suffix for this viewport (hook-phone.png). Defaults to the size, e.g. "1920x1080". */
14
+ name?: string;
15
+ width: number;
16
+ height: number;
17
+ /** Pixels per CSS pixel for this viewport. Defaults to the call's deviceScaleFactor. */
18
+ deviceScaleFactor?: number;
19
+ }
20
+ export interface ResolvedViewport {
21
+ name: string;
22
+ viewport: Viewport;
23
+ deviceScaleFactor: number;
24
+ }
25
+ /** Named sizes a caller can ask for by name. The pixel ratios are what real devices of that class report. */
26
+ export declare const VIEWPORT_PRESETS: {
27
+ readonly desktop: {
28
+ readonly width: 1920;
29
+ readonly height: 1080;
30
+ readonly deviceScaleFactor: 1;
31
+ };
32
+ readonly laptop: {
33
+ readonly width: 1440;
34
+ readonly height: 900;
35
+ readonly deviceScaleFactor: 2;
36
+ };
37
+ readonly tablet: {
38
+ readonly width: 834;
39
+ readonly height: 1194;
40
+ readonly deviceScaleFactor: 2;
41
+ };
42
+ readonly phone: {
43
+ readonly width: 390;
44
+ readonly height: 844;
45
+ readonly deviceScaleFactor: 3;
46
+ };
47
+ };
48
+ export type ViewportPresetName = keyof typeof VIEWPORT_PRESETS;
49
+ export declare const viewportSpecSchema: z.ZodObject<{
50
+ name: z.ZodOptional<z.ZodString>;
51
+ width: z.ZodNumber;
52
+ height: z.ZodNumber;
53
+ deviceScaleFactor: z.ZodOptional<z.ZodNumber>;
54
+ }, z.core.$strip>;
55
+ /** A request entry: a preset name ("phone") or an explicit { width, height, ... }. */
56
+ export declare const viewportRequestSchema: z.ZodUnion<readonly [z.ZodEnum<{
57
+ desktop: "desktop";
58
+ laptop: "laptop";
59
+ phone: "phone";
60
+ tablet: "tablet";
61
+ }>, z.ZodObject<{
62
+ name: z.ZodOptional<z.ZodString>;
63
+ width: z.ZodNumber;
64
+ height: z.ZodNumber;
65
+ deviceScaleFactor: z.ZodOptional<z.ZodNumber>;
66
+ }, z.core.$strip>]>;
67
+ export type ViewportRequest = ViewportPresetName | ViewportSpec;
68
+ /**
69
+ * Turns a request list into one entry per viewport with a name and a pixel ratio, or throws
70
+ * before any browser opens. Names have to be unique and safe to put in a file name; two entries
71
+ * that would write the same file are an error, never a silent overwrite.
72
+ */
73
+ export declare function resolveViewports(requests: ViewportRequest[], defaultDeviceScaleFactor?: number): ResolvedViewport[];
74
+ /** `public/images/hook.png` -> `public/images/hook-phone.png`: the viewport's name goes before the extension. */
75
+ export declare function viewportOutPath(outPath: string, name: string): string;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.viewportRequestSchema = exports.viewportSpecSchema = exports.VIEWPORT_PRESETS = void 0;
37
+ exports.resolveViewports = resolveViewports;
38
+ exports.viewportOutPath = viewportOutPath;
39
+ const path = __importStar(require("node:path"));
40
+ const zod_1 = require("zod");
41
+ const browser_1 = require("./browser");
42
+ /** Named sizes a caller can ask for by name. The pixel ratios are what real devices of that class report. */
43
+ exports.VIEWPORT_PRESETS = {
44
+ desktop: { width: 1920, height: 1080, deviceScaleFactor: 1 },
45
+ laptop: { width: 1440, height: 900, deviceScaleFactor: 2 },
46
+ tablet: { width: 834, height: 1194, deviceScaleFactor: 2 },
47
+ phone: { width: 390, height: 844, deviceScaleFactor: 3 },
48
+ };
49
+ exports.viewportSpecSchema = zod_1.z.object({
50
+ name: zod_1.z.string().min(1).optional(),
51
+ width: zod_1.z.number().int().positive(),
52
+ height: zod_1.z.number().int().positive(),
53
+ deviceScaleFactor: zod_1.z.number().positive().optional(),
54
+ });
55
+ /** A request entry: a preset name ("phone") or an explicit { width, height, ... }. */
56
+ exports.viewportRequestSchema = zod_1.z.union([zod_1.z.enum(Object.keys(exports.VIEWPORT_PRESETS)), exports.viewportSpecSchema]);
57
+ const SAFE_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
58
+ /**
59
+ * Turns a request list into one entry per viewport with a name and a pixel ratio, or throws
60
+ * before any browser opens. Names have to be unique and safe to put in a file name; two entries
61
+ * that would write the same file are an error, never a silent overwrite.
62
+ */
63
+ function resolveViewports(requests, defaultDeviceScaleFactor = browser_1.DEFAULT_DEVICE_SCALE) {
64
+ if (requests.length === 0)
65
+ throw new Error("viewports is empty. Pass at least one viewport, or omit it for the single default.");
66
+ const out = [];
67
+ const seen = new Set();
68
+ requests.forEach((req, i) => {
69
+ const spec = typeof req === "string" ? { ...exports.VIEWPORT_PRESETS[req], name: req } : req;
70
+ if (typeof req === "string" && !(req in exports.VIEWPORT_PRESETS)) {
71
+ throw new Error(`viewports[${i}]: "${req}" is not a preset. Presets: ${Object.keys(exports.VIEWPORT_PRESETS).join(", ")}.`);
72
+ }
73
+ if (!(spec.width > 0) || !(spec.height > 0))
74
+ throw new Error(`viewports[${i}]: width and height must be positive.`);
75
+ const name = spec.name ?? `${spec.width}x${spec.height}`;
76
+ if (!SAFE_NAME.test(name)) {
77
+ throw new Error(`viewports[${i}].name "${name}" must be letters, digits, "-" or "_" (it becomes part of a file name).`);
78
+ }
79
+ if (seen.has(name)) {
80
+ throw new Error(`viewports[${i}].name "${name}" is used twice, so two captures would write the same file. Give each viewport its own name.`);
81
+ }
82
+ seen.add(name);
83
+ out.push({
84
+ name,
85
+ viewport: { width: spec.width, height: spec.height },
86
+ deviceScaleFactor: spec.deviceScaleFactor ?? defaultDeviceScaleFactor,
87
+ });
88
+ });
89
+ return out;
90
+ }
91
+ /** `public/images/hook.png` -> `public/images/hook-phone.png`: the viewport's name goes before the extension. */
92
+ function viewportOutPath(outPath, name) {
93
+ const ext = path.extname(outPath);
94
+ return `${outPath.slice(0, outPath.length - ext.length)}-${name}${ext}`;
95
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openvidstudio/capture",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Zoom-compensated browser capture plus desktop, mobile, and terminal recording backends. No Remotion, no React, no video pipeline.",
5
5
  "license": "Apache-2.0",
6
6
  "engines": {
@@ -13,7 +13,8 @@
13
13
  "dist"
14
14
  ],
15
15
  "dependencies": {
16
- "playwright": "^1.64.0",
16
+ "js-yaml": "4.3.2",
17
+ "playwright": "^1.65.1",
17
18
  "zod": "^4.6.6"
18
19
  },
19
20
  "devDependencies": {
package/LICENSE DELETED
@@ -1,202 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the
45
- purposes of this License, Derivative Works shall not include works
46
- that remain separable from, or merely link (or bind by name) to the
47
- interfaces of, the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including the
50
- original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright 2026 Anay Dhawan
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.