@sealpixel/plugin-watermark 1.0.0-rc.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.
- package/README.md +3 -0
- package/dist/index.d.ts +222 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { AssetDeclaration, Color, OperationBase, SourcePx } from '@sealpixel/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export type Anchor = 'tl' | 'tc' | 'tr' | 'cl' | 'c' | 'cr' | 'bl' | 'bc' | 'br';
|
|
4
|
+
export type WatermarkSource = {
|
|
5
|
+
kind: 'asset';
|
|
6
|
+
asset: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'text';
|
|
9
|
+
text: string;
|
|
10
|
+
font: string;
|
|
11
|
+
color: Color;
|
|
12
|
+
};
|
|
13
|
+
export interface Tile {
|
|
14
|
+
gapX: SourcePx;
|
|
15
|
+
gapY: SourcePx;
|
|
16
|
+
rotation: number;
|
|
17
|
+
}
|
|
18
|
+
export interface Watermark {
|
|
19
|
+
source: WatermarkSource;
|
|
20
|
+
anchor: Anchor;
|
|
21
|
+
margin: SourcePx;
|
|
22
|
+
/** Stamp width (image) or font size (text) as a fraction of the image width. */
|
|
23
|
+
scale: number;
|
|
24
|
+
opacity: number;
|
|
25
|
+
tile: Tile | null;
|
|
26
|
+
}
|
|
27
|
+
export interface WatermarkDoc {
|
|
28
|
+
watermark: Watermark | null;
|
|
29
|
+
}
|
|
30
|
+
export interface WatermarkSetOp extends OperationBase<'watermark.set'> {
|
|
31
|
+
source?: WatermarkSource | undefined;
|
|
32
|
+
anchor?: Anchor | undefined;
|
|
33
|
+
margin?: SourcePx | undefined;
|
|
34
|
+
scale?: number | undefined;
|
|
35
|
+
opacity?: number | undefined;
|
|
36
|
+
tile?: Tile | null | undefined;
|
|
37
|
+
}
|
|
38
|
+
export type WatermarkClearOp = OperationBase<'watermark.clear'>;
|
|
39
|
+
declare module '@sealpixel/core' {
|
|
40
|
+
interface OperationRegistry {
|
|
41
|
+
'watermark.set': WatermarkSetOp;
|
|
42
|
+
'watermark.clear': WatermarkClearOp;
|
|
43
|
+
}
|
|
44
|
+
interface DocumentRegistry {
|
|
45
|
+
watermark: WatermarkDoc;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export declare const SourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
49
|
+
kind: z.ZodLiteral<"asset">;
|
|
50
|
+
asset: z.ZodString;
|
|
51
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
52
|
+
kind: z.ZodLiteral<"text">;
|
|
53
|
+
text: z.ZodString;
|
|
54
|
+
font: z.ZodString;
|
|
55
|
+
color: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
56
|
+
}, z.core.$strict>], "kind">;
|
|
57
|
+
export declare const DEFAULT_WATERMARK: Omit<Watermark, 'source'>;
|
|
58
|
+
export declare const watermarkSet: import("@sealpixel/core").OperationDef<WatermarkDoc, WatermarkSetOp>;
|
|
59
|
+
export declare const watermarkClear: import("@sealpixel/core").OperationDef<WatermarkDoc, WatermarkClearOp>;
|
|
60
|
+
export declare const WatermarkOptionsSchema: z.ZodObject<{
|
|
61
|
+
defaults: z.ZodObject<{
|
|
62
|
+
source: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
63
|
+
kind: z.ZodLiteral<"asset">;
|
|
64
|
+
asset: z.ZodString;
|
|
65
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
66
|
+
kind: z.ZodLiteral<"text">;
|
|
67
|
+
text: z.ZodString;
|
|
68
|
+
font: z.ZodString;
|
|
69
|
+
color: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
70
|
+
}, z.core.$strict>], "kind">>;
|
|
71
|
+
anchor: z.ZodOptional<z.ZodEnum<{
|
|
72
|
+
tl: "tl";
|
|
73
|
+
tc: "tc";
|
|
74
|
+
tr: "tr";
|
|
75
|
+
cl: "cl";
|
|
76
|
+
c: "c";
|
|
77
|
+
cr: "cr";
|
|
78
|
+
bl: "bl";
|
|
79
|
+
bc: "bc";
|
|
80
|
+
br: "br";
|
|
81
|
+
}>>;
|
|
82
|
+
margin: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
scale: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
tile: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
86
|
+
gapX: z.ZodNumber;
|
|
87
|
+
gapY: z.ZodNumber;
|
|
88
|
+
rotation: z.ZodNumber;
|
|
89
|
+
}, z.core.$strict>>>;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
lock: z.ZodBoolean;
|
|
92
|
+
anchors: z.ZodArray<z.ZodEnum<{
|
|
93
|
+
tl: "tl";
|
|
94
|
+
tc: "tc";
|
|
95
|
+
tr: "tr";
|
|
96
|
+
cl: "cl";
|
|
97
|
+
c: "c";
|
|
98
|
+
cr: "cr";
|
|
99
|
+
bl: "bl";
|
|
100
|
+
bc: "bc";
|
|
101
|
+
br: "br";
|
|
102
|
+
}>>;
|
|
103
|
+
text: z.ZodBoolean;
|
|
104
|
+
image: z.ZodBoolean;
|
|
105
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
106
|
+
id: z.ZodString;
|
|
107
|
+
hash: z.ZodString;
|
|
108
|
+
url: z.ZodOptional<z.ZodString>;
|
|
109
|
+
label: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, z.core.$strict>>;
|
|
111
|
+
scaleRange: z.ZodObject<{
|
|
112
|
+
min: z.ZodNumber;
|
|
113
|
+
max: z.ZodNumber;
|
|
114
|
+
step: z.ZodNumber;
|
|
115
|
+
}, z.core.$strict>;
|
|
116
|
+
opacityRange: z.ZodObject<{
|
|
117
|
+
min: z.ZodNumber;
|
|
118
|
+
max: z.ZodNumber;
|
|
119
|
+
step: z.ZodNumber;
|
|
120
|
+
}, z.core.$strict>;
|
|
121
|
+
}, z.core.$strict>;
|
|
122
|
+
/**
|
|
123
|
+
* `defaults`: values a new watermark starts with; with `source` the tool
|
|
124
|
+
* starts with that watermark applied. `lock`: the watermark is fixed:
|
|
125
|
+
* deviating sets and clears are rejected and export or server render fail
|
|
126
|
+
* while it is missing (requires `defaults.source`). `anchors`: anchors
|
|
127
|
+
* offered. `text` / `image`: allow text or image watermarks. `assets`: image
|
|
128
|
+
* assets offered. `scaleRange`: slider bounds; `opacityRange`: accepted opacities
|
|
129
|
+
* (the opacity itself comes from `defaults.opacity`, there is no slider).
|
|
130
|
+
*/
|
|
131
|
+
export type WatermarkOptions = z.infer<typeof WatermarkOptionsSchema>;
|
|
132
|
+
export declare const WATERMARK_DEFAULT_OPTIONS: WatermarkOptions;
|
|
133
|
+
/** The full watermark a locked or defaulted editor applies, or null without `defaults.source`. */
|
|
134
|
+
export declare function watermarkFromOptions(options: WatermarkOptions): Watermark | null;
|
|
135
|
+
export declare const watermarkPlugin: import("@sealpixel/plugin-sdk").ConfigurablePlugin<"watermark", WatermarkDoc, {
|
|
136
|
+
defaults: {
|
|
137
|
+
source?: {
|
|
138
|
+
kind: "asset";
|
|
139
|
+
asset: string;
|
|
140
|
+
} | {
|
|
141
|
+
kind: "text";
|
|
142
|
+
text: string;
|
|
143
|
+
font: string;
|
|
144
|
+
color: [number, number, number, number];
|
|
145
|
+
} | undefined;
|
|
146
|
+
anchor?: "tl" | "tc" | "tr" | "cl" | "c" | "cr" | "bl" | "bc" | "br" | undefined;
|
|
147
|
+
margin?: number | undefined;
|
|
148
|
+
scale?: number | undefined;
|
|
149
|
+
opacity?: number | undefined;
|
|
150
|
+
tile?: {
|
|
151
|
+
gapX: number;
|
|
152
|
+
gapY: number;
|
|
153
|
+
rotation: number;
|
|
154
|
+
} | null | undefined;
|
|
155
|
+
};
|
|
156
|
+
lock: boolean;
|
|
157
|
+
anchors: ("tl" | "tc" | "tr" | "cl" | "c" | "cr" | "bl" | "bc" | "br")[];
|
|
158
|
+
text: boolean;
|
|
159
|
+
image: boolean;
|
|
160
|
+
assets: {
|
|
161
|
+
id: string;
|
|
162
|
+
hash: string;
|
|
163
|
+
url?: string | undefined;
|
|
164
|
+
label?: string | undefined;
|
|
165
|
+
}[];
|
|
166
|
+
scaleRange: {
|
|
167
|
+
min: number;
|
|
168
|
+
max: number;
|
|
169
|
+
step: number;
|
|
170
|
+
};
|
|
171
|
+
opacityRange: {
|
|
172
|
+
min: number;
|
|
173
|
+
max: number;
|
|
174
|
+
step: number;
|
|
175
|
+
};
|
|
176
|
+
}>;
|
|
177
|
+
/** Kept for hosts written before options existed: `createWatermarkPlugin({ assets })`. */
|
|
178
|
+
export declare function createWatermarkPlugin(options?: {
|
|
179
|
+
assets?: AssetDeclaration[];
|
|
180
|
+
}): import("@sealpixel/plugin-sdk").ConfigurablePlugin<"watermark", WatermarkDoc, {
|
|
181
|
+
defaults: {
|
|
182
|
+
source?: {
|
|
183
|
+
kind: "asset";
|
|
184
|
+
asset: string;
|
|
185
|
+
} | {
|
|
186
|
+
kind: "text";
|
|
187
|
+
text: string;
|
|
188
|
+
font: string;
|
|
189
|
+
color: [number, number, number, number];
|
|
190
|
+
} | undefined;
|
|
191
|
+
anchor?: "tl" | "tc" | "tr" | "cl" | "c" | "cr" | "bl" | "bc" | "br" | undefined;
|
|
192
|
+
margin?: number | undefined;
|
|
193
|
+
scale?: number | undefined;
|
|
194
|
+
opacity?: number | undefined;
|
|
195
|
+
tile?: {
|
|
196
|
+
gapX: number;
|
|
197
|
+
gapY: number;
|
|
198
|
+
rotation: number;
|
|
199
|
+
} | null | undefined;
|
|
200
|
+
};
|
|
201
|
+
lock: boolean;
|
|
202
|
+
anchors: ("tl" | "tc" | "tr" | "cl" | "c" | "cr" | "bl" | "bc" | "br")[];
|
|
203
|
+
text: boolean;
|
|
204
|
+
image: boolean;
|
|
205
|
+
assets: {
|
|
206
|
+
id: string;
|
|
207
|
+
hash: string;
|
|
208
|
+
url?: string | undefined;
|
|
209
|
+
label?: string | undefined;
|
|
210
|
+
}[];
|
|
211
|
+
scaleRange: {
|
|
212
|
+
min: number;
|
|
213
|
+
max: number;
|
|
214
|
+
step: number;
|
|
215
|
+
};
|
|
216
|
+
opacityRange: {
|
|
217
|
+
min: number;
|
|
218
|
+
max: number;
|
|
219
|
+
step: number;
|
|
220
|
+
};
|
|
221
|
+
}>;
|
|
222
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACjF,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAC/D,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;I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C,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,yBAAyB,EAAE,gBASvC,CAAC;AAEF,kGAAkG;AAClG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI,CAIhF;AAiBD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqE1B,CAAC;AAEH,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAElF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { defineOperation, definePlugin } from '@sealpixel/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
const channel = z.number().min(0).max(1);
|
|
4
|
+
const px = z.number().finite().min(0).max(4096);
|
|
5
|
+
const ColorSchema = z.tuple([channel, channel, channel, channel]);
|
|
6
|
+
export const SourceSchema = z.discriminatedUnion('kind', [
|
|
7
|
+
z.object({ kind: z.literal('asset'), asset: z.string().min(1) }).strict(),
|
|
8
|
+
z
|
|
9
|
+
.object({
|
|
10
|
+
kind: z.literal('text'),
|
|
11
|
+
text: z.string().min(1).max(500),
|
|
12
|
+
font: z.string().min(1),
|
|
13
|
+
color: ColorSchema,
|
|
14
|
+
})
|
|
15
|
+
.strict(),
|
|
16
|
+
]);
|
|
17
|
+
const TileSchema = z.object({ gapX: px, gapY: px, rotation: z.number().finite() }).strict();
|
|
18
|
+
const base = { id: z.string().min(1), at: z.number().optional() };
|
|
19
|
+
export const DEFAULT_WATERMARK = {
|
|
20
|
+
anchor: 'br',
|
|
21
|
+
margin: 16,
|
|
22
|
+
scale: 0.2,
|
|
23
|
+
opacity: 0.6,
|
|
24
|
+
tile: null,
|
|
25
|
+
};
|
|
26
|
+
export const watermarkSet = defineOperation({
|
|
27
|
+
type: 'watermark.set',
|
|
28
|
+
schema: z
|
|
29
|
+
.object({
|
|
30
|
+
type: z.literal('watermark.set'),
|
|
31
|
+
...base,
|
|
32
|
+
source: SourceSchema.optional(),
|
|
33
|
+
anchor: z.enum(['tl', 'tc', 'tr', 'cl', 'c', 'cr', 'bl', 'bc', 'br']).optional(),
|
|
34
|
+
margin: px.optional(),
|
|
35
|
+
scale: z.number().gt(0).max(4).optional(),
|
|
36
|
+
opacity: channel.optional(),
|
|
37
|
+
tile: TileSchema.nullable().optional(),
|
|
38
|
+
})
|
|
39
|
+
.strict()
|
|
40
|
+
.refine((op) => op.source !== undefined || true, 'ok'),
|
|
41
|
+
reduce: (slice, op) => {
|
|
42
|
+
const source = op.source ?? slice.watermark?.source;
|
|
43
|
+
if (!source)
|
|
44
|
+
return slice;
|
|
45
|
+
const prev = slice.watermark ?? { source, ...DEFAULT_WATERMARK };
|
|
46
|
+
return {
|
|
47
|
+
watermark: {
|
|
48
|
+
source,
|
|
49
|
+
anchor: op.anchor ?? prev.anchor,
|
|
50
|
+
margin: op.margin ?? prev.margin,
|
|
51
|
+
scale: op.scale ?? prev.scale,
|
|
52
|
+
opacity: op.opacity ?? prev.opacity,
|
|
53
|
+
tile: op.tile === undefined ? prev.tile : op.tile,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
export const watermarkClear = defineOperation({
|
|
59
|
+
type: 'watermark.clear',
|
|
60
|
+
schema: z.object({ type: z.literal('watermark.clear'), ...base }).strict(),
|
|
61
|
+
reduce: () => ({ watermark: null }),
|
|
62
|
+
});
|
|
63
|
+
const ANCHORS = ['tl', 'tc', 'tr', 'cl', 'c', 'cr', 'bl', 'bc', 'br'];
|
|
64
|
+
const unitRange = z
|
|
65
|
+
.object({
|
|
66
|
+
min: z.number().min(0).max(1),
|
|
67
|
+
max: z.number().min(0).max(1),
|
|
68
|
+
step: z.number().positive(),
|
|
69
|
+
})
|
|
70
|
+
.strict()
|
|
71
|
+
.refine((r) => r.min < r.max, 'min must be below max');
|
|
72
|
+
const AssetOptionSchema = z
|
|
73
|
+
.object({
|
|
74
|
+
id: z.string().min(1),
|
|
75
|
+
hash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
76
|
+
url: z.string().min(1).optional(),
|
|
77
|
+
label: z.string().min(1).optional(),
|
|
78
|
+
})
|
|
79
|
+
.strict();
|
|
80
|
+
export const WatermarkOptionsSchema = z
|
|
81
|
+
.object({
|
|
82
|
+
defaults: z
|
|
83
|
+
.object({
|
|
84
|
+
source: SourceSchema.optional(),
|
|
85
|
+
anchor: z.enum(ANCHORS).optional(),
|
|
86
|
+
margin: px.optional(),
|
|
87
|
+
scale: z.number().gt(0).max(1).optional(),
|
|
88
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
89
|
+
tile: TileSchema.nullable().optional(),
|
|
90
|
+
})
|
|
91
|
+
.strict(),
|
|
92
|
+
lock: z.boolean(),
|
|
93
|
+
anchors: z.array(z.enum(ANCHORS)).min(1),
|
|
94
|
+
text: z.boolean(),
|
|
95
|
+
image: z.boolean(),
|
|
96
|
+
/** Image assets offered as watermarks. */
|
|
97
|
+
assets: z.array(AssetOptionSchema),
|
|
98
|
+
scaleRange: unitRange,
|
|
99
|
+
opacityRange: unitRange,
|
|
100
|
+
})
|
|
101
|
+
.strict()
|
|
102
|
+
.refine((o) => !o.lock || o.defaults.source !== undefined, 'lock requires defaults.source')
|
|
103
|
+
.refine((o) => o.text || o.image, 'at least one of text or image must be allowed');
|
|
104
|
+
export const WATERMARK_DEFAULT_OPTIONS = {
|
|
105
|
+
defaults: {},
|
|
106
|
+
lock: false,
|
|
107
|
+
anchors: [...ANCHORS],
|
|
108
|
+
text: true,
|
|
109
|
+
image: true,
|
|
110
|
+
assets: [],
|
|
111
|
+
scaleRange: { min: 0.02, max: 1, step: 0.01 },
|
|
112
|
+
opacityRange: { min: 0, max: 1, step: 0.01 },
|
|
113
|
+
};
|
|
114
|
+
/** The full watermark a locked or defaulted editor applies, or null without `defaults.source`. */
|
|
115
|
+
export function watermarkFromOptions(options) {
|
|
116
|
+
const { source, ...rest } = options.defaults;
|
|
117
|
+
if (!source)
|
|
118
|
+
return null;
|
|
119
|
+
return { ...DEFAULT_WATERMARK, ...stripUndefinedKeys(rest), source };
|
|
120
|
+
}
|
|
121
|
+
function stripUndefinedKeys(v) {
|
|
122
|
+
return Object.fromEntries(Object.entries(v).filter(([, x]) => x !== undefined));
|
|
123
|
+
}
|
|
124
|
+
/** Structural equality with sorted keys, so reducer and options object key order do not matter. */
|
|
125
|
+
const canonical = (v) => Array.isArray(v)
|
|
126
|
+
? `[${v.map(canonical).join(',')}]`
|
|
127
|
+
: v !== null && typeof v === 'object'
|
|
128
|
+
? `{${Object.keys(v)
|
|
129
|
+
.sort()
|
|
130
|
+
.filter((k) => v[k] !== undefined)
|
|
131
|
+
.map((k) => `${JSON.stringify(k)}:${canonical(v[k])}`)
|
|
132
|
+
.join(',')}}`
|
|
133
|
+
: JSON.stringify(v);
|
|
134
|
+
const sameJson = (a, b) => canonical(a) === canonical(b);
|
|
135
|
+
export const watermarkPlugin = definePlugin({
|
|
136
|
+
id: 'watermark',
|
|
137
|
+
version: 1,
|
|
138
|
+
operations: [watermarkSet, watermarkClear],
|
|
139
|
+
initialDocument: { watermark: null },
|
|
140
|
+
stage: { name: 'watermark', order: 700 },
|
|
141
|
+
toPlan: (doc) => {
|
|
142
|
+
const w = doc.watermark;
|
|
143
|
+
if (!w)
|
|
144
|
+
return null;
|
|
145
|
+
return {
|
|
146
|
+
source: w.source,
|
|
147
|
+
anchor: w.anchor,
|
|
148
|
+
margin: w.margin,
|
|
149
|
+
scale: w.scale,
|
|
150
|
+
opacity: w.opacity,
|
|
151
|
+
...(w.tile ? { tile: w.tile } : {}),
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
kernel: { kind: 'core' },
|
|
155
|
+
assets: (options) => options.assets.map(({ label: _label, ...asset }) => asset),
|
|
156
|
+
options: {
|
|
157
|
+
schema: WatermarkOptionsSchema,
|
|
158
|
+
defaults: WATERMARK_DEFAULT_OPTIONS,
|
|
159
|
+
describe: {
|
|
160
|
+
defaults: 'Values a new watermark starts with; with `source` the tool starts with it applied.',
|
|
161
|
+
lock: 'Fix the watermark: deviating sets and clears are rejected, export needs it present.',
|
|
162
|
+
anchors: 'Anchors offered.',
|
|
163
|
+
text: 'Allow text watermarks.',
|
|
164
|
+
image: 'Allow image watermarks.',
|
|
165
|
+
assets: 'Image assets offered as watermarks: { id, hash, url?, label? }.',
|
|
166
|
+
scaleRange: 'Bounds and step of the scale slider (fraction of the image width).',
|
|
167
|
+
opacityRange: 'Opacities accepted with enforce; the UI has no slider, defaults.opacity applies.',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
initialOps: ({ options }) => {
|
|
171
|
+
const w = watermarkFromOptions(options);
|
|
172
|
+
return w ? [{ type: 'watermark.set', ...w }] : [];
|
|
173
|
+
},
|
|
174
|
+
validate: (op, { options, slice }) => {
|
|
175
|
+
if (op.type === 'watermark.clear')
|
|
176
|
+
return options.lock ? 'the watermark is locked' : null;
|
|
177
|
+
if (op.type !== 'watermark.set')
|
|
178
|
+
return null;
|
|
179
|
+
const o = op;
|
|
180
|
+
if (options.lock) {
|
|
181
|
+
const locked = watermarkFromOptions(options);
|
|
182
|
+
const { type: _t, id: _i, at: _a, ...patch } = o;
|
|
183
|
+
const next = { ...(slice.watermark ?? locked), ...stripUndefinedKeys(patch) };
|
|
184
|
+
return sameJson(next, locked) ? null : 'the watermark is locked';
|
|
185
|
+
}
|
|
186
|
+
if (o.source?.kind === 'text' && !options.text)
|
|
187
|
+
return 'text watermarks are disabled';
|
|
188
|
+
if (o.source?.kind === 'asset' && !options.image)
|
|
189
|
+
return 'image watermarks are disabled';
|
|
190
|
+
if (o.anchor !== undefined && !options.anchors.includes(o.anchor))
|
|
191
|
+
return `anchor "${o.anchor}" is not offered`;
|
|
192
|
+
const s = options.scaleRange;
|
|
193
|
+
if (o.scale !== undefined && (o.scale < s.min - 1e-9 || o.scale > s.max + 1e-9))
|
|
194
|
+
return `scale must stay within ${s.min}..${s.max}`;
|
|
195
|
+
const a = options.opacityRange;
|
|
196
|
+
if (o.opacity !== undefined && (o.opacity < a.min - 1e-9 || o.opacity > a.max + 1e-9))
|
|
197
|
+
return `opacity must stay within ${a.min}..${a.max}`;
|
|
198
|
+
return null;
|
|
199
|
+
},
|
|
200
|
+
validateDocument: (slice, { options }) => {
|
|
201
|
+
if (!options.lock)
|
|
202
|
+
return null;
|
|
203
|
+
return sameJson(slice.watermark, watermarkFromOptions(options))
|
|
204
|
+
? null
|
|
205
|
+
: 'the locked watermark is missing or altered';
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
/** Kept for hosts written before options existed: `createWatermarkPlugin({ assets })`. */
|
|
209
|
+
export function createWatermarkPlugin(options = {}) {
|
|
210
|
+
return options.assets ? watermarkPlugin.configure({ assets: options.assets }) : watermarkPlugin;
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA4CxB,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACzC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChD,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACl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AAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC;YAC7E,OAAO,0BAA0B,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;QACrD,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;QAC/B,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC;YACnF,OAAO,4BAA4B,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAC/B,OAAO,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAC7D,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,4CAA4C,CAAC;IACnD,CAAC;CACF,CAAC,CAAC;AAEH,0FAA0F;AAC1F,MAAM,UAAU,qBAAqB,CAAC,UAA2C,EAAE;IACjF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC;AAClG,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sealpixel/plugin-watermark",
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
|
+
"description": "Image or text watermark at an anchor or tiled across the image.",
|
|
5
|
+
"license": "BUSL-1.1",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/9feet/sealpixel.git",
|
|
9
|
+
"directory": "packages/plugins/watermark"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://docs.sealpixel.dev",
|
|
12
|
+
"bugs": "https://github.com/9feet/sealpixel/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"sealpixel-plugin"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.build.json",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"test": "vitest run"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@sealpixel/plugin-sdk": "workspace:*"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@sealpixel/core": "workspace:*",
|
|
39
|
+
"zod": "^4.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@sealpixel/config": "workspace:*",
|
|
43
|
+
"@sealpixel/core": "workspace:*",
|
|
44
|
+
"@types/node": "^24.0.0",
|
|
45
|
+
"typescript": "^5.9.0",
|
|
46
|
+
"vitest": "^4.0.0",
|
|
47
|
+
"zod": "^4.0.0"
|
|
48
|
+
}
|
|
49
|
+
}
|