@pooder/kit 4.3.1 → 5.0.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.
Files changed (60) hide show
  1. package/.test-dist/src/CanvasService.js +249 -0
  2. package/.test-dist/src/ViewportSystem.js +75 -0
  3. package/.test-dist/src/background.js +203 -0
  4. package/.test-dist/src/bridgeSelection.js +20 -0
  5. package/.test-dist/src/constraints.js +237 -0
  6. package/.test-dist/src/coordinate.js +74 -0
  7. package/.test-dist/src/dieline.js +723 -0
  8. package/.test-dist/src/edgeScale.js +12 -0
  9. package/.test-dist/src/feature.js +752 -0
  10. package/.test-dist/src/featureComplete.js +32 -0
  11. package/.test-dist/src/film.js +167 -0
  12. package/.test-dist/src/geometry.js +506 -0
  13. package/.test-dist/src/image.js +1234 -0
  14. package/.test-dist/src/index.js +35 -0
  15. package/.test-dist/src/maskOps.js +270 -0
  16. package/.test-dist/src/mirror.js +104 -0
  17. package/.test-dist/src/renderSpec.js +2 -0
  18. package/.test-dist/src/ruler.js +343 -0
  19. package/.test-dist/src/sceneLayout.js +99 -0
  20. package/.test-dist/src/sceneLayoutModel.js +196 -0
  21. package/.test-dist/src/sceneView.js +40 -0
  22. package/.test-dist/src/sceneVisibility.js +42 -0
  23. package/.test-dist/src/size.js +332 -0
  24. package/.test-dist/src/tracer.js +544 -0
  25. package/.test-dist/src/units.js +30 -0
  26. package/.test-dist/src/white-ink.js +829 -0
  27. package/.test-dist/src/wrappedOffsets.js +33 -0
  28. package/.test-dist/tests/run.js +94 -0
  29. package/CHANGELOG.md +11 -0
  30. package/dist/index.d.mts +339 -36
  31. package/dist/index.d.ts +339 -36
  32. package/dist/index.js +3572 -850
  33. package/dist/index.mjs +3565 -852
  34. package/package.json +2 -2
  35. package/src/CanvasService.ts +300 -96
  36. package/src/ViewportSystem.ts +92 -92
  37. package/src/background.ts +230 -230
  38. package/src/bridgeSelection.ts +17 -0
  39. package/src/coordinate.ts +106 -106
  40. package/src/dieline.ts +897 -973
  41. package/src/edgeScale.ts +19 -0
  42. package/src/feature.ts +83 -30
  43. package/src/film.ts +194 -194
  44. package/src/geometry.ts +242 -84
  45. package/src/image.ts +1582 -512
  46. package/src/index.ts +14 -10
  47. package/src/maskOps.ts +326 -0
  48. package/src/mirror.ts +128 -128
  49. package/src/renderSpec.ts +18 -0
  50. package/src/ruler.ts +449 -508
  51. package/src/sceneLayout.ts +121 -0
  52. package/src/sceneLayoutModel.ts +335 -0
  53. package/src/sceneVisibility.ts +49 -0
  54. package/src/size.ts +379 -0
  55. package/src/tracer.ts +719 -570
  56. package/src/units.ts +27 -27
  57. package/src/white-ink.ts +1018 -373
  58. package/src/wrappedOffsets.ts +33 -0
  59. package/tests/run.ts +118 -0
  60. package/tsconfig.test.json +15 -15
package/src/units.ts CHANGED
@@ -1,27 +1,27 @@
1
- import { Coordinate, Unit } from "./coordinate";
2
-
3
- export function parseLengthToMm(input: number | string, defaultUnit: Unit): number {
4
- if (typeof input === "number") {
5
- if (!Number.isFinite(input)) return 0;
6
- return Coordinate.convertUnit(input, defaultUnit, "mm");
7
- }
8
-
9
- const raw = input.trim();
10
- if (!raw) return 0;
11
-
12
- const match = raw.match(/^([+-]?\d+(?:\.\d+)?)\s*(px|mm|cm|in)?$/i);
13
- if (!match) return 0;
14
-
15
- const value = Number(match[1]);
16
- if (!Number.isFinite(value)) return 0;
17
-
18
- const unit = (match[2]?.toLowerCase() as Unit | undefined) ?? defaultUnit;
19
- return Coordinate.convertUnit(value, unit, "mm");
20
- }
21
-
22
- export function formatMm(valueMm: number, displayUnit: Unit, fractionDigits: number = 2): string {
23
- if (!Number.isFinite(valueMm)) return "0";
24
- const value = Coordinate.convertUnit(valueMm, "mm", displayUnit);
25
- const rounded = Number(value.toFixed(fractionDigits));
26
- return rounded.toString();
27
- }
1
+ import { Coordinate, Unit } from "./coordinate";
2
+
3
+ export function parseLengthToMm(input: number | string, defaultUnit: Unit): number {
4
+ if (typeof input === "number") {
5
+ if (!Number.isFinite(input)) return 0;
6
+ return Coordinate.convertUnit(input, defaultUnit, "mm");
7
+ }
8
+
9
+ const raw = input.trim();
10
+ if (!raw) return 0;
11
+
12
+ const match = raw.match(/^([+-]?\d+(?:\.\d+)?)\s*(px|mm|cm|in)?$/i);
13
+ if (!match) return 0;
14
+
15
+ const value = Number(match[1]);
16
+ if (!Number.isFinite(value)) return 0;
17
+
18
+ const unit = (match[2]?.toLowerCase() as Unit | undefined) ?? defaultUnit;
19
+ return Coordinate.convertUnit(value, unit, "mm");
20
+ }
21
+
22
+ export function formatMm(valueMm: number, displayUnit: Unit, fractionDigits: number = 2): string {
23
+ if (!Number.isFinite(valueMm)) return "0";
24
+ const value = Coordinate.convertUnit(valueMm, "mm", displayUnit);
25
+ const rounded = Number(value.toFixed(fractionDigits));
26
+ return rounded.toString();
27
+ }