@pooder/kit 5.3.1 → 6.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 (65) hide show
  1. package/.test-dist/src/extensions/background.js +475 -131
  2. package/.test-dist/src/extensions/dieline.js +283 -180
  3. package/.test-dist/src/extensions/dielineShape.js +66 -0
  4. package/.test-dist/src/extensions/feature.js +388 -303
  5. package/.test-dist/src/extensions/film.js +133 -74
  6. package/.test-dist/src/extensions/geometry.js +120 -56
  7. package/.test-dist/src/extensions/image.js +296 -212
  8. package/.test-dist/src/extensions/index.js +1 -3
  9. package/.test-dist/src/extensions/maskOps.js +75 -20
  10. package/.test-dist/src/extensions/ruler.js +312 -215
  11. package/.test-dist/src/extensions/sceneLayoutModel.js +9 -3
  12. package/.test-dist/src/extensions/sceneVisibility.js +3 -10
  13. package/.test-dist/src/extensions/tracer.js +229 -58
  14. package/.test-dist/src/extensions/white-ink.js +139 -129
  15. package/.test-dist/src/services/CanvasService.js +888 -126
  16. package/.test-dist/src/services/index.js +1 -0
  17. package/.test-dist/src/services/visibility.js +54 -0
  18. package/.test-dist/tests/run.js +58 -4
  19. package/CHANGELOG.md +12 -0
  20. package/dist/index.d.mts +377 -82
  21. package/dist/index.d.ts +377 -82
  22. package/dist/index.js +3920 -2178
  23. package/dist/index.mjs +3992 -2247
  24. package/package.json +1 -1
  25. package/src/extensions/background.ts +631 -145
  26. package/src/extensions/dieline.ts +280 -187
  27. package/src/extensions/dielineShape.ts +109 -0
  28. package/src/extensions/feature.ts +485 -366
  29. package/src/extensions/film.ts +152 -76
  30. package/src/extensions/geometry.ts +203 -104
  31. package/src/extensions/image.ts +319 -238
  32. package/src/extensions/index.ts +0 -1
  33. package/src/extensions/ruler.ts +481 -268
  34. package/src/extensions/sceneLayoutModel.ts +18 -6
  35. package/src/extensions/white-ink.ts +157 -171
  36. package/src/services/CanvasService.ts +1126 -140
  37. package/src/services/index.ts +1 -0
  38. package/src/services/renderSpec.ts +69 -4
  39. package/src/services/visibility.ts +78 -0
  40. package/tests/run.ts +139 -4
  41. package/.test-dist/src/CanvasService.js +0 -249
  42. package/.test-dist/src/ViewportSystem.js +0 -75
  43. package/.test-dist/src/background.js +0 -203
  44. package/.test-dist/src/bridgeSelection.js +0 -20
  45. package/.test-dist/src/constraints.js +0 -237
  46. package/.test-dist/src/dieline.js +0 -818
  47. package/.test-dist/src/edgeScale.js +0 -12
  48. package/.test-dist/src/feature.js +0 -826
  49. package/.test-dist/src/featureComplete.js +0 -32
  50. package/.test-dist/src/film.js +0 -167
  51. package/.test-dist/src/geometry.js +0 -506
  52. package/.test-dist/src/image.js +0 -1250
  53. package/.test-dist/src/maskOps.js +0 -270
  54. package/.test-dist/src/mirror.js +0 -104
  55. package/.test-dist/src/renderSpec.js +0 -2
  56. package/.test-dist/src/ruler.js +0 -343
  57. package/.test-dist/src/sceneLayout.js +0 -99
  58. package/.test-dist/src/sceneLayoutModel.js +0 -196
  59. package/.test-dist/src/sceneView.js +0 -40
  60. package/.test-dist/src/sceneVisibility.js +0 -42
  61. package/.test-dist/src/size.js +0 -332
  62. package/.test-dist/src/tracer.js +0 -544
  63. package/.test-dist/src/white-ink.js +0 -829
  64. package/.test-dist/src/wrappedOffsets.js +0 -33
  65. package/src/extensions/sceneVisibility.ts +0 -71
@@ -0,0 +1,109 @@
1
+ export const BUILTIN_DIELINE_SHAPES = [
2
+ "rect",
3
+ "circle",
4
+ "ellipse",
5
+ "heart",
6
+ ] as const;
7
+
8
+ export type BuiltinDielineShape = (typeof BUILTIN_DIELINE_SHAPES)[number];
9
+
10
+ export const DIELINE_SHAPES = [...BUILTIN_DIELINE_SHAPES, "custom"] as const;
11
+
12
+ export type DielineShape = (typeof DIELINE_SHAPES)[number];
13
+
14
+ export const DEFAULT_DIELINE_SHAPE: BuiltinDielineShape = "rect";
15
+
16
+ export type ShapeFitMode = "contain" | "stretch";
17
+
18
+ export interface DielineShapeStyle {
19
+ fitMode: ShapeFitMode;
20
+ [key: string]: unknown;
21
+ }
22
+
23
+ export interface HeartShapeParams {
24
+ lobeSpread: number;
25
+ notchDepth: number;
26
+ tipSharpness: number;
27
+ }
28
+
29
+ const DEFAULT_HEART_SHAPE_PARAMS: HeartShapeParams = {
30
+ lobeSpread: 0.46,
31
+ notchDepth: 0.24,
32
+ tipSharpness: 0,
33
+ };
34
+
35
+ export const DEFAULT_DIELINE_SHAPE_STYLE: DielineShapeStyle = {
36
+ fitMode: "stretch",
37
+ ...DEFAULT_HEART_SHAPE_PARAMS,
38
+ };
39
+
40
+ export function isDielineShape(value: unknown): value is DielineShape {
41
+ return (
42
+ typeof value === "string" &&
43
+ (DIELINE_SHAPES as readonly string[]).includes(value)
44
+ );
45
+ }
46
+
47
+ function normalizeFitMode(
48
+ value: unknown,
49
+ fallback: ShapeFitMode,
50
+ ): ShapeFitMode {
51
+ if (value === "contain" || value === "stretch") return value;
52
+ return fallback;
53
+ }
54
+
55
+ function normalizeUnitInterval(value: unknown, fallback: number): number {
56
+ const num = Number(value);
57
+ if (!Number.isFinite(num)) return fallback;
58
+ return Math.max(0, Math.min(1, num));
59
+ }
60
+
61
+ export function normalizeDielineShape(
62
+ value: unknown,
63
+ fallback: DielineShape = DEFAULT_DIELINE_SHAPE,
64
+ ): DielineShape {
65
+ return isDielineShape(value) ? value : fallback;
66
+ }
67
+
68
+ export function normalizeShapeStyle(
69
+ value: unknown,
70
+ fallback: DielineShapeStyle = DEFAULT_DIELINE_SHAPE_STYLE,
71
+ ): DielineShapeStyle {
72
+ const raw =
73
+ value && typeof value === "object"
74
+ ? (value as Record<string, unknown>)
75
+ : {};
76
+ return {
77
+ ...fallback,
78
+ fitMode: normalizeFitMode(raw.fitMode, fallback.fitMode),
79
+ lobeSpread: normalizeUnitInterval(
80
+ raw.lobeSpread,
81
+ Number(fallback.lobeSpread ?? DEFAULT_HEART_SHAPE_PARAMS.lobeSpread),
82
+ ),
83
+ notchDepth: normalizeUnitInterval(
84
+ raw.notchDepth,
85
+ Number(fallback.notchDepth ?? DEFAULT_HEART_SHAPE_PARAMS.notchDepth),
86
+ ),
87
+ tipSharpness: normalizeUnitInterval(
88
+ raw.tipSharpness,
89
+ Number(fallback.tipSharpness ?? DEFAULT_HEART_SHAPE_PARAMS.tipSharpness),
90
+ ),
91
+ };
92
+ }
93
+
94
+ export function getShapeFitMode(
95
+ style: DielineShapeStyle | undefined,
96
+ ): ShapeFitMode {
97
+ return normalizeShapeStyle(style).fitMode;
98
+ }
99
+
100
+ export function getHeartShapeParams(
101
+ style: DielineShapeStyle | undefined,
102
+ ): HeartShapeParams {
103
+ const normalized = normalizeShapeStyle(style);
104
+ return {
105
+ lobeSpread: Number(normalized.lobeSpread),
106
+ notchDepth: Number(normalized.notchDepth),
107
+ tipSharpness: Number(normalized.tipSharpness),
108
+ };
109
+ }