@pooder/kit 5.3.0 → 5.4.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 (73) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.d.mts +249 -36
  3. package/dist/index.d.ts +249 -36
  4. package/dist/index.js +2374 -1049
  5. package/dist/index.mjs +2375 -1050
  6. package/package.json +1 -1
  7. package/src/extensions/background.ts +178 -85
  8. package/src/extensions/dieline.ts +1149 -1030
  9. package/src/extensions/dielineShape.ts +109 -0
  10. package/src/extensions/feature.ts +482 -366
  11. package/src/extensions/film.ts +148 -76
  12. package/src/extensions/geometry.ts +210 -44
  13. package/src/extensions/image.ts +244 -114
  14. package/src/extensions/ruler.ts +471 -268
  15. package/src/extensions/sceneLayoutModel.ts +28 -6
  16. package/src/extensions/sceneVisibility.ts +3 -10
  17. package/src/extensions/tracer.ts +1019 -980
  18. package/src/extensions/white-ink.ts +284 -231
  19. package/src/services/CanvasService.ts +543 -11
  20. package/src/services/renderSpec.ts +37 -2
  21. package/.test-dist/src/CanvasService.js +0 -249
  22. package/.test-dist/src/ViewportSystem.js +0 -75
  23. package/.test-dist/src/background.js +0 -203
  24. package/.test-dist/src/bridgeSelection.js +0 -20
  25. package/.test-dist/src/constraints.js +0 -237
  26. package/.test-dist/src/coordinate.js +0 -74
  27. package/.test-dist/src/dieline.js +0 -818
  28. package/.test-dist/src/edgeScale.js +0 -12
  29. package/.test-dist/src/extensions/background.js +0 -203
  30. package/.test-dist/src/extensions/bridgeSelection.js +0 -20
  31. package/.test-dist/src/extensions/constraints.js +0 -237
  32. package/.test-dist/src/extensions/dieline.js +0 -828
  33. package/.test-dist/src/extensions/edgeScale.js +0 -12
  34. package/.test-dist/src/extensions/feature.js +0 -825
  35. package/.test-dist/src/extensions/featureComplete.js +0 -32
  36. package/.test-dist/src/extensions/film.js +0 -167
  37. package/.test-dist/src/extensions/geometry.js +0 -545
  38. package/.test-dist/src/extensions/image.js +0 -1529
  39. package/.test-dist/src/extensions/index.js +0 -30
  40. package/.test-dist/src/extensions/maskOps.js +0 -279
  41. package/.test-dist/src/extensions/mirror.js +0 -104
  42. package/.test-dist/src/extensions/ruler.js +0 -345
  43. package/.test-dist/src/extensions/sceneLayout.js +0 -96
  44. package/.test-dist/src/extensions/sceneLayoutModel.js +0 -196
  45. package/.test-dist/src/extensions/sceneVisibility.js +0 -62
  46. package/.test-dist/src/extensions/size.js +0 -331
  47. package/.test-dist/src/extensions/tracer.js +0 -538
  48. package/.test-dist/src/extensions/white-ink.js +0 -1190
  49. package/.test-dist/src/extensions/wrappedOffsets.js +0 -33
  50. package/.test-dist/src/feature.js +0 -826
  51. package/.test-dist/src/featureComplete.js +0 -32
  52. package/.test-dist/src/film.js +0 -167
  53. package/.test-dist/src/geometry.js +0 -506
  54. package/.test-dist/src/image.js +0 -1250
  55. package/.test-dist/src/index.js +0 -18
  56. package/.test-dist/src/maskOps.js +0 -270
  57. package/.test-dist/src/mirror.js +0 -104
  58. package/.test-dist/src/renderSpec.js +0 -2
  59. package/.test-dist/src/ruler.js +0 -343
  60. package/.test-dist/src/sceneLayout.js +0 -99
  61. package/.test-dist/src/sceneLayoutModel.js +0 -196
  62. package/.test-dist/src/sceneView.js +0 -40
  63. package/.test-dist/src/sceneVisibility.js +0 -42
  64. package/.test-dist/src/services/CanvasService.js +0 -249
  65. package/.test-dist/src/services/ViewportSystem.js +0 -76
  66. package/.test-dist/src/services/index.js +0 -24
  67. package/.test-dist/src/services/renderSpec.js +0 -2
  68. package/.test-dist/src/size.js +0 -332
  69. package/.test-dist/src/tracer.js +0 -544
  70. package/.test-dist/src/units.js +0 -30
  71. package/.test-dist/src/white-ink.js +0 -829
  72. package/.test-dist/src/wrappedOffsets.js +0 -33
  73. package/.test-dist/tests/run.js +0 -94
@@ -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: "contain",
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
+ }