@pooder/kit 5.4.0 → 6.0.1

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 (69) hide show
  1. package/.test-dist/src/coordinate.js +74 -0
  2. package/.test-dist/src/extensions/background.js +547 -0
  3. package/.test-dist/src/extensions/bridgeSelection.js +20 -0
  4. package/.test-dist/src/extensions/constraints.js +237 -0
  5. package/.test-dist/src/extensions/dieline.js +935 -0
  6. package/.test-dist/src/extensions/dielineShape.js +66 -0
  7. package/.test-dist/src/extensions/edgeScale.js +12 -0
  8. package/.test-dist/src/extensions/feature.js +910 -0
  9. package/.test-dist/src/extensions/featureComplete.js +32 -0
  10. package/.test-dist/src/extensions/film.js +226 -0
  11. package/.test-dist/src/extensions/geometry.js +609 -0
  12. package/.test-dist/src/extensions/image.js +1788 -0
  13. package/.test-dist/src/extensions/index.js +28 -0
  14. package/.test-dist/src/extensions/maskOps.js +334 -0
  15. package/.test-dist/src/extensions/mirror.js +104 -0
  16. package/.test-dist/src/extensions/ruler.js +442 -0
  17. package/.test-dist/src/extensions/sceneLayout.js +96 -0
  18. package/.test-dist/src/extensions/sceneLayoutModel.js +202 -0
  19. package/.test-dist/src/extensions/sceneVisibility.js +55 -0
  20. package/.test-dist/src/extensions/size.js +331 -0
  21. package/.test-dist/src/extensions/tracer.js +709 -0
  22. package/.test-dist/src/extensions/white-ink.js +1200 -0
  23. package/.test-dist/src/extensions/wrappedOffsets.js +33 -0
  24. package/.test-dist/src/index.js +18 -0
  25. package/.test-dist/src/services/CanvasService.js +1032 -0
  26. package/.test-dist/src/services/ViewportSystem.js +76 -0
  27. package/.test-dist/src/services/index.js +25 -0
  28. package/.test-dist/src/services/renderSpec.js +2 -0
  29. package/.test-dist/src/services/visibility.js +57 -0
  30. package/.test-dist/src/units.js +30 -0
  31. package/.test-dist/tests/run.js +150 -0
  32. package/CHANGELOG.md +12 -0
  33. package/dist/index.d.mts +164 -62
  34. package/dist/index.d.ts +164 -62
  35. package/dist/index.js +2433 -1719
  36. package/dist/index.mjs +2442 -1723
  37. package/package.json +1 -1
  38. package/src/coordinate.ts +106 -106
  39. package/src/extensions/background.ts +716 -323
  40. package/src/extensions/bridgeSelection.ts +17 -17
  41. package/src/extensions/constraints.ts +322 -322
  42. package/src/extensions/dieline.ts +1173 -1149
  43. package/src/extensions/dielineShape.ts +109 -109
  44. package/src/extensions/edgeScale.ts +19 -19
  45. package/src/extensions/feature.ts +1140 -1137
  46. package/src/extensions/featureComplete.ts +46 -46
  47. package/src/extensions/film.ts +270 -266
  48. package/src/extensions/geometry.ts +851 -885
  49. package/src/extensions/image.ts +2240 -2054
  50. package/src/extensions/index.ts +10 -11
  51. package/src/extensions/maskOps.ts +283 -283
  52. package/src/extensions/mirror.ts +128 -128
  53. package/src/extensions/ruler.ts +664 -654
  54. package/src/extensions/sceneLayout.ts +140 -140
  55. package/src/extensions/sceneLayoutModel.ts +364 -364
  56. package/src/extensions/size.ts +389 -389
  57. package/src/extensions/tracer.ts +1019 -1019
  58. package/src/extensions/white-ink.ts +1508 -1575
  59. package/src/extensions/wrappedOffsets.ts +33 -33
  60. package/src/index.ts +2 -2
  61. package/src/services/CanvasService.ts +1317 -832
  62. package/src/services/ViewportSystem.ts +95 -95
  63. package/src/services/index.ts +4 -3
  64. package/src/services/renderSpec.ts +85 -53
  65. package/src/services/visibility.ts +83 -0
  66. package/src/units.ts +27 -27
  67. package/tests/run.ts +258 -118
  68. package/tsconfig.test.json +15 -15
  69. package/src/extensions/sceneVisibility.ts +0 -64
@@ -1,109 +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
- }
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
+ }
@@ -1,19 +1,19 @@
1
- export interface BoundsLike {
2
- width: number;
3
- height: number;
4
- }
5
-
6
- export function computeDetectEdgeSize(
7
- currentMax: number,
8
- baseBounds: BoundsLike,
9
- expandedBounds: BoundsLike,
10
- ): { width: number; height: number; scale: number } {
11
- const baseMax = Math.max(baseBounds.width, baseBounds.height);
12
- const scale = baseMax > 0 ? currentMax / baseMax : 1;
13
- return {
14
- scale,
15
- width: expandedBounds.width * scale,
16
- height: expandedBounds.height * scale,
17
- };
18
- }
19
-
1
+ export interface BoundsLike {
2
+ width: number;
3
+ height: number;
4
+ }
5
+
6
+ export function computeDetectEdgeSize(
7
+ currentMax: number,
8
+ baseBounds: BoundsLike,
9
+ expandedBounds: BoundsLike,
10
+ ): { width: number; height: number; scale: number } {
11
+ const baseMax = Math.max(baseBounds.width, baseBounds.height);
12
+ const scale = baseMax > 0 ? currentMax / baseMax : 1;
13
+ return {
14
+ scale,
15
+ width: expandedBounds.width * scale,
16
+ height: expandedBounds.height * scale,
17
+ };
18
+ }
19
+