graphics-debug 0.0.83 → 0.0.84

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.
Files changed (43) hide show
  1. package/dist/{chunk-NYENUFOW.js → chunk-7236NVI2.js} +5 -1
  2. package/dist/chunk-7236NVI2.js.map +1 -0
  3. package/dist/{chunk-PPB7D4OE.js → chunk-AKONCUCE.js} +47 -8
  4. package/dist/chunk-AKONCUCE.js.map +1 -0
  5. package/dist/chunk-FLFF6QXL.js +89 -0
  6. package/dist/chunk-FLFF6QXL.js.map +1 -0
  7. package/dist/{chunk-HU5LL4ZE.js → chunk-HPNVGPHJ.js} +2 -2
  8. package/dist/chunk-HPNVGPHJ.js.map +1 -0
  9. package/dist/{chunk-BQ3ZHEQO.js → chunk-K37Y2KHE.js} +5 -1
  10. package/dist/chunk-K37Y2KHE.js.map +1 -0
  11. package/dist/{chunk-MXOATGTD.js → chunk-MYMDOAQN.js} +4 -4
  12. package/dist/{chunk-GZRUE2GP.js → chunk-OB4CGOL3.js} +6 -1
  13. package/dist/chunk-OB4CGOL3.js.map +1 -0
  14. package/dist/{chunk-7NMLOZRC.js → chunk-ZWAXHWX2.js} +56 -4
  15. package/dist/chunk-ZWAXHWX2.js.map +1 -0
  16. package/dist/cli/cli.js +8 -7
  17. package/dist/cli/cli.js.map +1 -1
  18. package/dist/lib/drawGraphicsToCanvas.js +2 -1
  19. package/dist/lib/getSvgFromGraphicsObject.d.ts +1 -1
  20. package/dist/lib/getSvgFromGraphicsObject.js +2 -1
  21. package/dist/lib/index.d.ts +1 -1
  22. package/dist/lib/index.js +8 -7
  23. package/dist/lib/infiniteLineHelpers.d.ts +7 -0
  24. package/dist/lib/infiniteLineHelpers.js +9 -0
  25. package/dist/lib/infiniteLineHelpers.js.map +1 -0
  26. package/dist/lib/matcher.js +2 -1
  27. package/dist/lib/matcher.js.map +1 -1
  28. package/dist/lib/mergeGraphics.js +1 -1
  29. package/dist/lib/react.d.ts +1 -1
  30. package/dist/lib/react.js +194 -99
  31. package/dist/lib/react.js.map +1 -1
  32. package/dist/lib/setStepOfAllObjects.js +1 -1
  33. package/dist/lib/stackGraphics.js +5 -4
  34. package/dist/lib/translateGraphics.js +1 -1
  35. package/dist/lib/types.d.ts +18 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-7NMLOZRC.js.map +0 -1
  38. package/dist/chunk-BQ3ZHEQO.js.map +0 -1
  39. package/dist/chunk-GZRUE2GP.js.map +0 -1
  40. package/dist/chunk-HU5LL4ZE.js.map +0 -1
  41. package/dist/chunk-NYENUFOW.js.map +0 -1
  42. package/dist/chunk-PPB7D4OE.js.map +0 -1
  43. /package/dist/{chunk-MXOATGTD.js.map → chunk-MYMDOAQN.js.map} +0 -0
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  getSvgFromGraphicsObject
3
- } from "../chunk-7NMLOZRC.js";
3
+ } from "../chunk-ZWAXHWX2.js";
4
4
  import "../chunk-IOVKI3ZO.js";
5
5
  import "../chunk-ZGI74PYD.js";
6
+ import "../chunk-FLFF6QXL.js";
6
7
  export {
7
8
  getSvgFromGraphicsObject
8
9
  };
@@ -1,4 +1,4 @@
1
- export { Arrow, CenterViewbox, Circle, GraphicsObject, Line, NinePointAnchor, Point, Polygon, Rect, Text, TransformOptions, Viewbox } from './types.js';
1
+ export { Arrow, CenterViewbox, Circle, GraphicsObject, InfiniteLine, Line, NinePointAnchor, Point, Polygon, Rect, Text, TransformOptions, Viewbox } from './types.js';
2
2
  export { getGraphicsObjectsFromLogString } from './getGraphicsObjectsFromLogString.js';
3
3
  export { getSvgFromGraphicsObject } from './getSvgFromGraphicsObject.js';
4
4
  export { computeTransformFromViewbox, drawGraphicsToCanvas, getBounds } from './drawGraphicsToCanvas.js';
package/dist/lib/index.js CHANGED
@@ -2,37 +2,38 @@ import {
2
2
  getHtmlFromLogString,
3
3
  getSvgFromLogString,
4
4
  getSvgsFromLogString
5
- } from "../chunk-HU5LL4ZE.js";
5
+ } from "../chunk-HPNVGPHJ.js";
6
6
  import {
7
7
  setStepOfAllObjects
8
- } from "../chunk-GZRUE2GP.js";
8
+ } from "../chunk-OB4CGOL3.js";
9
9
  import {
10
10
  createGraphicsGrid,
11
11
  stackGraphicsHorizontally,
12
12
  stackGraphicsVertically
13
- } from "../chunk-MXOATGTD.js";
13
+ } from "../chunk-MYMDOAQN.js";
14
14
  import {
15
15
  mergeGraphics
16
- } from "../chunk-BQ3ZHEQO.js";
16
+ } from "../chunk-K37Y2KHE.js";
17
17
  import {
18
18
  translateGraphics
19
- } from "../chunk-NYENUFOW.js";
19
+ } from "../chunk-7236NVI2.js";
20
20
  import {
21
21
  computeTransformFromViewbox,
22
22
  drawGraphicsToCanvas,
23
23
  getBounds
24
- } from "../chunk-PPB7D4OE.js";
24
+ } from "../chunk-AKONCUCE.js";
25
25
  import {
26
26
  getGraphicsObjectsFromLogString
27
27
  } from "../chunk-NG6H63SM.js";
28
28
  import {
29
29
  getSvgFromGraphicsObject
30
- } from "../chunk-7NMLOZRC.js";
30
+ } from "../chunk-ZWAXHWX2.js";
31
31
  import "../chunk-IOVKI3ZO.js";
32
32
  import {
33
33
  FONT_SIZE_HEIGHT_RATIO,
34
34
  FONT_SIZE_WIDTH_RATIO
35
35
  } from "../chunk-ZGI74PYD.js";
36
+ import "../chunk-FLFF6QXL.js";
36
37
  export {
37
38
  FONT_SIZE_HEIGHT_RATIO,
38
39
  FONT_SIZE_WIDTH_RATIO,
@@ -0,0 +1,7 @@
1
+ import { Matrix } from 'transformation-matrix';
2
+ import { InfiniteLine, Viewbox, Point } from './types.js';
3
+
4
+ declare function clipInfiniteLineToBounds(infiniteLine: InfiniteLine, bounds: Viewbox): [Point, Point] | null;
5
+ declare function getViewportBoundsFromMatrix(matrix: Matrix, width: number, height: number): Viewbox;
6
+
7
+ export { clipInfiniteLineToBounds, getViewportBoundsFromMatrix };
@@ -0,0 +1,9 @@
1
+ import {
2
+ clipInfiniteLineToBounds,
3
+ getViewportBoundsFromMatrix
4
+ } from "../chunk-FLFF6QXL.js";
5
+ export {
6
+ clipInfiniteLineToBounds,
7
+ getViewportBoundsFromMatrix
8
+ };
9
+ //# sourceMappingURL=infiniteLineHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  getSvgFromGraphicsObject
3
- } from "../chunk-7NMLOZRC.js";
3
+ } from "../chunk-ZWAXHWX2.js";
4
4
  import "../chunk-IOVKI3ZO.js";
5
5
  import "../chunk-ZGI74PYD.js";
6
+ import "../chunk-FLFF6QXL.js";
6
7
 
7
8
  // lib/matcher.ts
8
9
  import { expect } from "bun:test";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/matcher.ts"],"sourcesContent":["import { expect, type MatcherResult } from \"bun:test\"\nimport * as fs from \"node:fs\"\nimport * as path from \"node:path\"\nimport looksSame from \"looks-same\"\nimport { GraphicsObject } from \"./types\"\nimport { getSvgFromGraphicsObject } from \"./getSvgFromGraphicsObject\"\n\n/**\n * Custom matcher for Bun tests to compare GraphicsObjects as SVGs\n *\n * @param this Matcher context\n * @param receivedMaybePromise GraphicsObject or Promise<GraphicsObject> to test\n * @param testPathOriginal Path to the test file\n * @param svgName Optional name for the snapshot\n * @returns Matcher result\n */\nasync function toMatchGraphicsSvg(\n // biome-ignore lint/suspicious/noExplicitAny: bun doesn't expose matcher type\n this: any,\n receivedMaybePromise: GraphicsObject | Promise<GraphicsObject>,\n testPathOriginal: string,\n opts: { backgroundColor?: string; svgName?: string } = {},\n): Promise<MatcherResult> {\n const received = await receivedMaybePromise\n const testPath = testPathOriginal.replace(/\\.test\\.tsx?$/, \"\")\n const snapshotDir = path.join(path.dirname(testPath), \"__snapshots__\")\n const snapshotName = opts.svgName\n ? `${opts.svgName}.snap.svg`\n : `${path.basename(testPath)}.snap.svg`\n const filePath = path.join(snapshotDir, snapshotName)\n\n if (!fs.existsSync(snapshotDir)) {\n fs.mkdirSync(snapshotDir, { recursive: true })\n }\n\n // Convert GraphicsObject to SVG\n const receivedSvg = getSvgFromGraphicsObject(received, {\n backgroundColor: opts.backgroundColor,\n })\n\n const updateSnapshot =\n process.argv.includes(\"--update-snapshots\") ||\n process.argv.includes(\"-u\") ||\n Boolean(process.env[\"BUN_UPDATE_SNAPSHOTS\"])\n\n if (!fs.existsSync(filePath) || updateSnapshot) {\n console.log(\"Writing snapshot to\", filePath)\n fs.writeFileSync(filePath, receivedSvg)\n return {\n message: () => `Snapshot created at ${filePath}`,\n pass: true,\n }\n }\n\n const existingSnapshot = fs.readFileSync(filePath, \"utf-8\")\n\n const result: any = await looksSame(\n Buffer.from(receivedSvg),\n Buffer.from(existingSnapshot),\n {\n strict: false,\n tolerance: 2,\n },\n )\n\n if (result.equal) {\n return {\n message: () => \"Snapshot matches\",\n pass: true,\n }\n }\n\n const diffPath = filePath.replace(\".snap.svg\", \".diff.png\")\n await looksSame.createDiff({\n reference: Buffer.from(existingSnapshot),\n current: Buffer.from(receivedSvg),\n diff: diffPath,\n highlightColor: \"#ff00ff\",\n })\n\n return {\n message: () => `Snapshot does not match. Diff saved at ${diffPath}`,\n pass: false,\n }\n}\n\n// Add the custom matcher to the expect object\nexpect.extend({\n // biome-ignore lint/suspicious/noExplicitAny: bun's types don't expose matcher type\n toMatchGraphicsSvg: toMatchGraphicsSvg as any,\n})\n\n// Extend the TypeScript interface for the matcher\ndeclare module \"bun:test\" {\n interface Matchers<T = unknown> {\n toMatchGraphicsSvg(\n testPath: string,\n opts?: { backgroundColor?: string; svgName?: string },\n ): Promise<MatcherResult>\n }\n}\n"],"mappings":";;;;;;;AAAA,SAAS,cAAkC;AAC3C,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,OAAO,eAAe;AAatB,eAAe,mBAGb,sBACA,kBACA,OAAuD,CAAC,GAChC;AACxB,QAAM,WAAW,MAAM;AACvB,QAAM,WAAW,iBAAiB,QAAQ,iBAAiB,EAAE;AAC7D,QAAM,cAAmB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AAGA,OAAO,OAAO;AAAA;AAAA,EAEZ;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../lib/matcher.ts"],"sourcesContent":["import { expect, type MatcherResult } from \"bun:test\"\nimport * as fs from \"node:fs\"\nimport * as path from \"node:path\"\nimport looksSame from \"looks-same\"\nimport { GraphicsObject } from \"./types\"\nimport { getSvgFromGraphicsObject } from \"./getSvgFromGraphicsObject\"\n\n/**\n * Custom matcher for Bun tests to compare GraphicsObjects as SVGs\n *\n * @param this Matcher context\n * @param receivedMaybePromise GraphicsObject or Promise<GraphicsObject> to test\n * @param testPathOriginal Path to the test file\n * @param svgName Optional name for the snapshot\n * @returns Matcher result\n */\nasync function toMatchGraphicsSvg(\n // biome-ignore lint/suspicious/noExplicitAny: bun doesn't expose matcher type\n this: any,\n receivedMaybePromise: GraphicsObject | Promise<GraphicsObject>,\n testPathOriginal: string,\n opts: { backgroundColor?: string; svgName?: string } = {},\n): Promise<MatcherResult> {\n const received = await receivedMaybePromise\n const testPath = testPathOriginal.replace(/\\.test\\.tsx?$/, \"\")\n const snapshotDir = path.join(path.dirname(testPath), \"__snapshots__\")\n const snapshotName = opts.svgName\n ? `${opts.svgName}.snap.svg`\n : `${path.basename(testPath)}.snap.svg`\n const filePath = path.join(snapshotDir, snapshotName)\n\n if (!fs.existsSync(snapshotDir)) {\n fs.mkdirSync(snapshotDir, { recursive: true })\n }\n\n // Convert GraphicsObject to SVG\n const receivedSvg = getSvgFromGraphicsObject(received, {\n backgroundColor: opts.backgroundColor,\n })\n\n const updateSnapshot =\n process.argv.includes(\"--update-snapshots\") ||\n process.argv.includes(\"-u\") ||\n Boolean(process.env[\"BUN_UPDATE_SNAPSHOTS\"])\n\n if (!fs.existsSync(filePath) || updateSnapshot) {\n console.log(\"Writing snapshot to\", filePath)\n fs.writeFileSync(filePath, receivedSvg)\n return {\n message: () => `Snapshot created at ${filePath}`,\n pass: true,\n }\n }\n\n const existingSnapshot = fs.readFileSync(filePath, \"utf-8\")\n\n const result: any = await looksSame(\n Buffer.from(receivedSvg),\n Buffer.from(existingSnapshot),\n {\n strict: false,\n tolerance: 2,\n },\n )\n\n if (result.equal) {\n return {\n message: () => \"Snapshot matches\",\n pass: true,\n }\n }\n\n const diffPath = filePath.replace(\".snap.svg\", \".diff.png\")\n await looksSame.createDiff({\n reference: Buffer.from(existingSnapshot),\n current: Buffer.from(receivedSvg),\n diff: diffPath,\n highlightColor: \"#ff00ff\",\n })\n\n return {\n message: () => `Snapshot does not match. Diff saved at ${diffPath}`,\n pass: false,\n }\n}\n\n// Add the custom matcher to the expect object\nexpect.extend({\n // biome-ignore lint/suspicious/noExplicitAny: bun's types don't expose matcher type\n toMatchGraphicsSvg: toMatchGraphicsSvg as any,\n})\n\n// Extend the TypeScript interface for the matcher\ndeclare module \"bun:test\" {\n interface Matchers<T = unknown> {\n toMatchGraphicsSvg(\n testPath: string,\n opts?: { backgroundColor?: string; svgName?: string },\n ): Promise<MatcherResult>\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,cAAkC;AAC3C,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,OAAO,eAAe;AAatB,eAAe,mBAGb,sBACA,kBACA,OAAuD,CAAC,GAChC;AACxB,QAAM,WAAW,MAAM;AACvB,QAAM,WAAW,iBAAiB,QAAQ,iBAAiB,EAAE;AAC7D,QAAM,cAAmB,UAAU,aAAQ,QAAQ,GAAG,eAAe;AACrE,QAAM,eAAe,KAAK,UACtB,GAAG,KAAK,OAAO,cACf,GAAQ,cAAS,QAAQ,CAAC;AAC9B,QAAM,WAAgB,UAAK,aAAa,YAAY;AAEpD,MAAI,CAAI,cAAW,WAAW,GAAG;AAC/B,IAAG,aAAU,aAAa,EAAE,WAAW,KAAK,CAAC;AAAA,EAC/C;AAGA,QAAM,cAAc,yBAAyB,UAAU;AAAA,IACrD,iBAAiB,KAAK;AAAA,EACxB,CAAC;AAED,QAAM,iBACJ,QAAQ,KAAK,SAAS,oBAAoB,KAC1C,QAAQ,KAAK,SAAS,IAAI,KAC1B,QAAQ,QAAQ,IAAI,sBAAsB,CAAC;AAE7C,MAAI,CAAI,cAAW,QAAQ,KAAK,gBAAgB;AAC9C,YAAQ,IAAI,uBAAuB,QAAQ;AAC3C,IAAG,iBAAc,UAAU,WAAW;AACtC,WAAO;AAAA,MACL,SAAS,MAAM,uBAAuB,QAAQ;AAAA,MAC9C,MAAM;AAAA,IACR;AAAA,EACF;AAEA,QAAM,mBAAsB,gBAAa,UAAU,OAAO;AAE1D,QAAM,SAAc,MAAM;AAAA,IACxB,OAAO,KAAK,WAAW;AAAA,IACvB,OAAO,KAAK,gBAAgB;AAAA,IAC5B;AAAA,MACE,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,EACF;AAEA,MAAI,OAAO,OAAO;AAChB,WAAO;AAAA,MACL,SAAS,MAAM;AAAA,MACf,MAAM;AAAA,IACR;AAAA,EACF;AAEA,QAAM,WAAW,SAAS,QAAQ,aAAa,WAAW;AAC1D,QAAM,UAAU,WAAW;AAAA,IACzB,WAAW,OAAO,KAAK,gBAAgB;AAAA,IACvC,SAAS,OAAO,KAAK,WAAW;AAAA,IAChC,MAAM;AAAA,IACN,gBAAgB;AAAA,EAClB,CAAC;AAED,SAAO;AAAA,IACL,SAAS,MAAM,0CAA0C,QAAQ;AAAA,IACjE,MAAM;AAAA,EACR;AACF;AAGA,OAAO,OAAO;AAAA;AAAA,EAEZ;AACF,CAAC;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mergeGraphics
3
- } from "../chunk-BQ3ZHEQO.js";
3
+ } from "../chunk-K37Y2KHE.js";
4
4
  export {
5
5
  mergeGraphics
6
6
  };
@@ -3,7 +3,7 @@ import { GraphicsObject } from './types.js';
3
3
  import { Matrix } from 'transformation-matrix';
4
4
 
5
5
  type GraphicsObjectClickEvent = {
6
- type: "point" | "line" | "rect" | "circle" | "text" | "arrow" | "polygon";
6
+ type: "point" | "line" | "infinite-line" | "rect" | "circle" | "text" | "arrow" | "polygon";
7
7
  index: number;
8
8
  object: any;
9
9
  };