@rickcedwhat/playwright-smart-vision 0.1.0-next.3ca5c04 → 0.1.0-next.6eeb196

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/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- export { test, expect } from './ocr-test.js';
2
- export type { OcrScreen } from './ocr-test.js';
3
1
  export { configure, saveScreen } from './configure.js';
4
2
  export { defineScreen, screenAssetsDir } from './screen-config.js';
5
3
  export type { ScreenConfig } from './screen-config.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACnE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE3F,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACnE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE3F,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { test, expect } from './ocr-test.js';
2
1
  export { configure, saveScreen } from './configure.js';
3
2
  export { defineScreen, screenAssetsDir } from './screen-config.js';
4
3
  export { defineTypedScreen, TypedScreenResult } from './typed-screen.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,15 +1,9 @@
1
- /**
2
- * Wrap OCR actions so they appear as named steps in the Playwright report and trace.
3
- * Falls back to running the body when called outside a test.
4
- */
5
1
  export declare function ocrStep<T>(title: string, body: () => Promise<T>): Promise<T>;
6
- /** Attach a PNG to the current Playwright test so it shows in the report and trace. */
7
2
  export declare function attachOcrImage(name: string, buffer: Buffer): Promise<void>;
8
3
  /**
9
4
  * Resolve the assertion timeout: explicit override → 5 000 ms default → 0 outside a test.
10
- * 5 000 ms matches Playwright's built-in expect.timeout default. Pass options.timeout to
11
- * override per-call, or pass 0 to assert once without retrying.
12
- * Returns 0 when called outside a Playwright test (no retry in unit/script contexts).
5
+ * Uses the cached test reference — will be populated after the first ocrStep call in a
6
+ * Playwright context. Returns 0 (no retry) when called outside a Playwright test.
13
7
  */
14
8
  export declare function expectTimeout(override?: number): number;
15
9
  //# sourceMappingURL=ocr-step.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ocr-step.d.ts","sourceRoot":"","sources":["../src/ocr-step.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOlF;AAED,uFAAuF;AACvF,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAQvD"}
1
+ {"version":3,"file":"ocr-step.d.ts","sourceRoot":"","sources":["../src/ocr-step.ts"],"names":[],"mappings":"AAcA,wBAAsB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAKlF;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhF;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAIvD"}
package/dist/ocr-step.js CHANGED
@@ -1,9 +1,19 @@
1
- import { test } from '@playwright/test';
2
- /**
3
- * Wrap OCR actions so they appear as named steps in the Playwright report and trace.
4
- * Falls back to running the body when called outside a test.
5
- */
1
+ let _test; // undefined=not yet loaded, null=unavailable
2
+ async function getTest() {
3
+ if (_test !== undefined)
4
+ return _test;
5
+ try {
6
+ _test = (await import('@playwright/test')).test;
7
+ }
8
+ catch {
9
+ _test = null;
10
+ }
11
+ return _test;
12
+ }
6
13
  export async function ocrStep(title, body) {
14
+ const test = await getTest();
15
+ if (!test)
16
+ return body();
7
17
  try {
8
18
  test.info();
9
19
  }
@@ -12,26 +22,27 @@ export async function ocrStep(title, body) {
12
22
  }
13
23
  return test.step(title, body, { box: true });
14
24
  }
15
- /** Attach a PNG to the current Playwright test so it shows in the report and trace. */
16
25
  export async function attachOcrImage(name, buffer) {
26
+ const test = await getTest();
27
+ if (!test)
28
+ return;
17
29
  try {
18
30
  await test.info().attach(name, { body: buffer, contentType: 'image/png' });
19
31
  }
20
- catch {
21
- // Not running inside a Playwright test.
22
- }
32
+ catch { }
23
33
  }
24
34
  /**
25
35
  * Resolve the assertion timeout: explicit override → 5 000 ms default → 0 outside a test.
26
- * 5 000 ms matches Playwright's built-in expect.timeout default. Pass options.timeout to
27
- * override per-call, or pass 0 to assert once without retrying.
28
- * Returns 0 when called outside a Playwright test (no retry in unit/script contexts).
36
+ * Uses the cached test reference — will be populated after the first ocrStep call in a
37
+ * Playwright context. Returns 0 (no retry) when called outside a Playwright test.
29
38
  */
30
39
  export function expectTimeout(override) {
31
40
  if (override !== undefined)
32
41
  return override;
42
+ if (!_test)
43
+ return 0;
33
44
  try {
34
- test.info();
45
+ _test.info();
35
46
  return 5_000;
36
47
  }
37
48
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"ocr-step.js","sourceRoot":"","sources":["../src/ocr-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAa,EAAE,IAAsB;IACpE,IAAI,CAAC;QACH,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,IAAI,GAAG,MAAM,OAAO,EAAE,CAAC;IAC7B,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,EAAE,CAAC;IACzB,IAAI,CAAC;QAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,IAAI,EAAE,CAAC;IAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,MAAc;IAC/D,MAAM,IAAI,GAAG,MAAM,OAAO,EAAE,CAAC;IAC7B,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC;IAC7E,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAAiB;IAC7C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC5C,IAAI,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC;IACrB,IAAI,CAAC;QAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAAC,OAAO,KAAK,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,CAAC,CAAC;IAAC,CAAC;AACzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rickcedwhat/playwright-smart-vision",
3
- "version": "0.1.0-next.3ca5c04",
3
+ "version": "0.1.0-next.6eeb196",
4
4
  "description": "Computer-vision and OCR-based element assertions for Playwright — local, fast, no GPT Vision required",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,14 @@
10
10
  "import": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts"
12
12
  },
13
+ "./test": {
14
+ "import": "./dist/ocr-test.js",
15
+ "types": "./dist/ocr-test.d.ts"
16
+ },
17
+ "./configure": {
18
+ "import": "./dist/configure.js",
19
+ "types": "./dist/configure.d.ts"
20
+ },
13
21
  "./utils/ocr": {
14
22
  "import": "./dist/utils/ocr.js",
15
23
  "types": "./dist/utils/ocr.d.ts"