@framefields/node-mask-math 0.0.0-stage → 2.0.3

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.
@@ -0,0 +1,133 @@
1
+ import {
2
+ configBuilder,
3
+ ImageResultSchema,
4
+ VideoResultSchema,
5
+ } from "@framefields/node-sdk";
6
+ import { z } from "zod";
7
+
8
+ export const MAX_RADIUS = 200;
9
+
10
+ export const MaskOperationEnum = z.enum([
11
+ "Union",
12
+ "Intersect",
13
+ "Subtract",
14
+ "Difference",
15
+ "Invert",
16
+ "Dilate",
17
+ "Erode",
18
+ "Choke",
19
+ "Feather",
20
+ ]);
21
+
22
+ export type MaskOperation = z.infer<typeof MaskOperationEnum>;
23
+
24
+ export const MaskChannelEnum = z.enum([
25
+ "Alpha",
26
+ "Luminance",
27
+ "Red",
28
+ "Green",
29
+ "Blue",
30
+ ]);
31
+
32
+ export type MaskChannel = z.infer<typeof MaskChannelEnum>;
33
+
34
+ export const MaskOutputFormatEnum = z.enum([
35
+ "WhiteWithAlpha",
36
+ "GrayscaleRGB",
37
+ "AlphaOnly",
38
+ "PassthroughRGB",
39
+ ]);
40
+
41
+ export type MaskOutputFormat = z.infer<typeof MaskOutputFormatEnum>;
42
+
43
+ export const maskMathConfig = configBuilder()
44
+ .field("operation", MaskOperationEnum.default("Union"), {
45
+ label: "Operation",
46
+ description:
47
+ "Morphological or Boolean set operation applied to input alpha masks.",
48
+ })
49
+ .field("radius", z.number().min(0).max(MAX_RADIUS).default(0), {
50
+ bindable: true,
51
+ dataTypes: ["Number", "Signal"],
52
+ label: "Radius / Width (px)",
53
+ description:
54
+ "Kernel radius in pixels for Dilate, Erode, Choke, or Feather operations.",
55
+ })
56
+ .field(
57
+ "threshold",
58
+ z.number().multipleOf(0.01).min(0.0).max(1.0).default(0.5),
59
+ {
60
+ bindable: true,
61
+ dataTypes: ["Number", "Signal"],
62
+ label: "Threshold",
63
+ description:
64
+ "Cutoff threshold level (0.0–1.0) for binarization step or non-linear choke.",
65
+ },
66
+ )
67
+ .field(
68
+ "clampMin",
69
+ z.number().multipleOf(0.01).min(0.0).max(1.0).default(0.0),
70
+ {
71
+ bindable: true,
72
+ dataTypes: ["Number", "Signal"],
73
+ label: "Clamp Min",
74
+ description: "Minimum alpha matte cutoff limit (0.0–1.0).",
75
+ },
76
+ )
77
+ .field(
78
+ "clampMax",
79
+ z.number().multipleOf(0.01).min(0.0).max(1.0).default(1.0),
80
+ {
81
+ bindable: true,
82
+ dataTypes: ["Number", "Signal"],
83
+ label: "Clamp Max",
84
+ description: "Maximum alpha matte cutoff limit (0.0–1.0).",
85
+ },
86
+ )
87
+ .field("channelA", MaskChannelEnum.default("Alpha"), {
88
+ label: "Mask A Channel",
89
+ description:
90
+ "Source channel to extract mask from Mask A (Alpha, Luminance, Red, Green, Blue).",
91
+ })
92
+ .field("channelB", MaskChannelEnum.default("Alpha"), {
93
+ label: "Mask B Channel",
94
+ description:
95
+ "Source channel to extract mask from Mask B (Alpha, Luminance, Red, Green, Blue).",
96
+ })
97
+ .field("binarize", z.boolean().default(false), {
98
+ label: "Binarize",
99
+ description:
100
+ "When enabled, outputs crisp 1-bit binary matte based on threshold.",
101
+ })
102
+ .field("invertResult", z.boolean().default(false), {
103
+ label: "Invert Result",
104
+ description: "Inverts final matte output.",
105
+ })
106
+ .field("outputFormat", MaskOutputFormatEnum.default("WhiteWithAlpha"), {
107
+ label: "Output Format",
108
+ description:
109
+ "WhiteWithAlpha (rgba(1,1,1,a)), GrayscaleRGB (rgba(a,a,a,1)), AlphaOnly (rgba(0,0,0,a)), PassthroughRGB (Mask A RGB with new alpha).",
110
+ })
111
+ .build();
112
+
113
+ export const MaskMathNodeConfigSchema = maskMathConfig.schema;
114
+
115
+ export type MaskMathNodeConfig = z.infer<typeof MaskMathNodeConfigSchema>;
116
+
117
+ export const MaskMathResultSchema = z.union([
118
+ ImageResultSchema,
119
+ VideoResultSchema,
120
+ ]);
121
+
122
+ export type MaskMathResult = z.infer<typeof MaskMathResultSchema>;
123
+
124
+ export const MASK_MATH_OUTPUT_TYPE_MAP: Record<
125
+ string,
126
+ "Image" | "Video" | "GIF"
127
+ > = {
128
+ Video: "Video",
129
+ Lottie: "Video",
130
+ GIF: "GIF",
131
+ Image: "Image",
132
+ SVG: "Image",
133
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./config.js";
2
+ export * from "./types.js";
@@ -0,0 +1,24 @@
1
+ import type { SignalData } from "@framefields/core";
2
+ import type { MaskMathNodeConfig } from "./config.js";
3
+
4
+ export interface MaskMathOp extends Partial<MaskMathNodeConfig> {
5
+ op: "MaskMath";
6
+ maskBMedia?: unknown;
7
+ radiusHandleId?: string | null;
8
+ thresholdHandleId?: string | null;
9
+ clampMinHandleId?: string | null;
10
+ clampMaxHandleId?: string | null;
11
+ opacity?: number;
12
+ inputs?: Record<
13
+ string,
14
+ {
15
+ connectionValid: boolean;
16
+ outputItem: {
17
+ type: string;
18
+ data: unknown;
19
+ } | null;
20
+ }
21
+ >;
22
+ }
23
+
24
+ export type MaskMathSignalData = SignalData & { nodeId?: string };
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "@framefields/tsconfig/node-library.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "paths": {
6
+ "@/*": ["./src/*"]
7
+ },
8
+ "experimentalDecorators": true,
9
+ "emitDecoratorMetadata": true
10
+ },
11
+ "include": ["src"]
12
+ }
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ index: "src/index.ts",
6
+ renderer: "src/renderers/index.ts",
7
+ },
8
+ format: ["esm"],
9
+ dts: true,
10
+ clean: true,
11
+ sourcemap: true,
12
+ treeshake: true,
13
+ });
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.