leafer-x-watermark 1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 XiaDeYu <https://github.com/Xdy1579883916>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,208 @@
1
+ # leafer-x-watermark
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![bundle][bundle-src]][bundle-href]
6
+ [![License][license-src]][license-href]
7
+
8
+ Leafer UI 水印插件,支持任意 LeaferJS 元素平铺水印
9
+
10
+ ## ✨ 特性
11
+
12
+ - 🎨 **任意图形** - 支持任意 LeaferJS 元素作为水印内容
13
+ - 🔄 **平铺模式** - 支持平铺(repeat)和拉伸(stretch)两种模式
14
+ - 📐 **灵活缩放** - 支持自定义水印尺寸比例
15
+ - 🔲 **间距控制** - 支持自定义水印间距
16
+ - 🎯 **错位排列** - 支持水印错位(stagger)效果
17
+ - 🔃 **旋转支持** - 支持水印旋转角度设置
18
+ - ⚡ **性能优化** - 智能缓存,仅在必要时重新生成图片
19
+
20
+ ## 📦 安装
21
+
22
+ ```bash
23
+ # pnpm
24
+ pnpm add leafer-x-watermark
25
+
26
+ # npm
27
+ npm install leafer-x-watermark
28
+
29
+ # yarn
30
+ yarn add leafer-x-watermark
31
+ ```
32
+
33
+ ## 🚀 快速开始
34
+
35
+ ### 基础使用
36
+
37
+ ```typescript
38
+ import { App } from 'leafer-ui'
39
+ import { Watermark } from 'leafer-x-watermark'
40
+
41
+ const app = new App({ view: 'app' })
42
+
43
+ const watermark = new Watermark({
44
+ tileContent: JSON.stringify({
45
+ tag: 'Text',
46
+ text: '水印文字',
47
+ fill: 'rgba(0, 0, 0, 0.1)',
48
+ fontSize: 16,
49
+ }),
50
+ width: 800,
51
+ height: 600,
52
+ })
53
+
54
+ app.tree.add(watermark)
55
+ ```
56
+
57
+ ### 平铺模式
58
+
59
+ ```typescript
60
+ const watermark = new Watermark({
61
+ tileContent: JSON.stringify({
62
+ tag: 'Text',
63
+ text: 'CONFIDENTIAL',
64
+ fill: 'rgba(255, 0, 0, 0.1)',
65
+ fontSize: 20,
66
+ }),
67
+ tileMode: true, // 开启平铺
68
+ tileSize: 100, // 100% 原始大小
69
+ tileGap: 20, // 20% 间距
70
+ tileRotation: -30, // 旋转 -30 度
71
+ width: 800,
72
+ height: 600,
73
+ })
74
+ ```
75
+
76
+ ### 错位排列
77
+
78
+ ```typescript
79
+ const watermark = new Watermark({
80
+ tileContent: JSON.stringify({
81
+ tag: 'Text',
82
+ text: '机密文件',
83
+ fill: 'rgba(0, 0, 0, 0.1)',
84
+ fontSize: 14,
85
+ }),
86
+ tileMode: true,
87
+ tileStagger: 50, // 50% 错位偏移
88
+ tileGap: 10,
89
+ width: 800,
90
+ height: 600,
91
+ })
92
+ ```
93
+
94
+ ### 图形水印
95
+
96
+ ```typescript
97
+ const watermark = new Watermark({
98
+ tileContent: JSON.stringify({
99
+ tag: 'Group',
100
+ children: [
101
+ { tag: 'Ellipse', width: 20, height: 20, fill: 'rgba(0, 100, 255, 0.2)' },
102
+ { tag: 'Text', text: 'LOGO', x: 25, y: 3, fill: 'rgba(0, 100, 255, 0.2)', fontSize: 12 },
103
+ ],
104
+ }),
105
+ tileMode: true,
106
+ tileSize: 80,
107
+ tileGap: 30,
108
+ width: 800,
109
+ height: 600,
110
+ })
111
+ ```
112
+
113
+ ## 📖 API 文档
114
+
115
+ ### Watermark 属性
116
+
117
+ 继承自 Leafer UI 的 [Rect](https://www.leaferjs.com/ui/display/Rect.html) 组件,拥有所有 Rect 属性,并额外支持:
118
+
119
+ | 属性 | 类型 | 默认值 | 说明 |
120
+ |------|------|--------|------|
121
+ | `tileContent` | string | - | 水印内容,LeaferJS 元素的 JSON 字符串 |
122
+ | `tileMode` | boolean | `true` | 平铺模式:`true` 平铺,`false` 拉伸 |
123
+ | `tileSize` | number | `100` | 显示比例(%),100 为原始大小 |
124
+ | `tileGap` | number | `0` | 间距比例(%),基于显示尺寸计算 |
125
+ | `tileStagger` | number | `0` | 错位偏移比例(0-100),控制相邻行的水平偏移 |
126
+ | `tileRotation` | number | `0` | 水印旋转角度(度) |
127
+
128
+ ### 属性说明
129
+
130
+ #### tileContent
131
+
132
+ 水印内容为 LeaferJS 元素的 JSON 字符串,支持所有 LeaferJS 图形类型:
133
+
134
+ ```typescript
135
+ // 文本
136
+ JSON.stringify({ tag: 'Text', text: '水印', fill: '#000', fontSize: 16 })
137
+
138
+ // 图片
139
+ JSON.stringify({ tag: 'Image', url: 'logo.png', width: 50, height: 50 })
140
+
141
+ // 组合图形
142
+ JSON.stringify({
143
+ tag: 'Group',
144
+ children: [
145
+ { tag: 'Rect', width: 30, height: 30, fill: '#f00' },
146
+ { tag: 'Text', text: 'A', x: 10, y: 5, fill: '#fff' },
147
+ ],
148
+ })
149
+ ```
150
+
151
+ #### tileSize
152
+
153
+ 控制水印显示大小的比例:
154
+ - `100` = 原始大小
155
+ - `50` = 缩小 50%
156
+ - `200` = 放大 200%
157
+ - `0` 或负数 = 不显示水印
158
+
159
+ #### tileGap
160
+
161
+ 间距基于显示尺寸的百分比计算:
162
+ - `tileGap: 10` 表示间距为水印宽/高的 10%
163
+
164
+ #### tileStagger
165
+
166
+ 错位排列效果,值为 0-100:
167
+ - `0` = 无错位
168
+ - `50` = 相邻行偏移 50%
169
+ - `100` = 相邻行偏移 100%(等于一个完整水印宽度)
170
+
171
+ ## 💡 使用场景
172
+
173
+ - 📄 文档版权保护
174
+ - 🖼️ 图片水印
175
+ - 🔒 机密文件标识
176
+ - 🏢 企业 Logo 背景
177
+ - 📑 证书防伪
178
+
179
+ ## 🔗 相关链接
180
+
181
+ - [在线演示](https://leafer-x-watermark.vercel.app/)
182
+ - [Leafer UI 文档](https://www.leaferjs.com/ui/guide/)
183
+
184
+ ## 🤝 贡献
185
+
186
+ 欢迎提交 Issue 和 Pull Request!
187
+
188
+ ## License
189
+
190
+ [MIT](./LICENSE) License © 2024-PRESENT [XiaDeYu](https://github.com/Xdy1579883916)
191
+
192
+ <!-- Badges -->
193
+
194
+ [npm-version-src]: https://img.shields.io/npm/v/leafer-x-watermark?style=flat&colorA=080f12&colorB=1fa669
195
+
196
+ [npm-version-href]: https://npmjs.com/package/leafer-x-watermark
197
+
198
+ [npm-downloads-src]: https://img.shields.io/npm/dm/leafer-x-watermark?style=flat&colorA=080f12&colorB=1fa669
199
+
200
+ [npm-downloads-href]: https://npmjs.com/package/leafer-x-watermark
201
+
202
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/leafer-x-watermark?style=flat&colorA=080f12&colorB=1fa669&label=minzip
203
+
204
+ [bundle-href]: https://bundlephobia.com/result?p=leafer-x-watermark
205
+
206
+ [license-src]: https://img.shields.io/github/license/Xdy1579883916/leafer-x-watermark.svg?style=flat&colorA=080f12&colorB=1fa669
207
+
208
+ [license-href]: https://github.com/Xdy1579883916/leafer-x-watermark/blob/master/LICENSE
@@ -0,0 +1,90 @@
1
+ import { IRectData, IUI, IRectInputData, IJSONOptions, IUIJSONData, IObject } from '@leafer-ui/interface';
2
+ import { RectData, Rect } from '@leafer-ui/core';
3
+
4
+ type IStaggerType = 'x' | 'y';
5
+ interface IStaggerData {
6
+ type?: IStaggerType;
7
+ offset: number;
8
+ }
9
+ type IStagger = number | IStaggerData;
10
+ interface INormalizedStagger {
11
+ type: IStaggerType;
12
+ offset: number;
13
+ }
14
+ declare module '@leafer-ui/interface' {
15
+ interface IImagePaint {
16
+ stagger?: IStagger;
17
+ }
18
+ }
19
+
20
+ interface ITileGap {
21
+ x?: number;
22
+ y?: number;
23
+ }
24
+ interface IWatermarkAttrData {
25
+ tileContent?: string;
26
+ tileMode?: boolean;
27
+ tileSize?: number;
28
+ tileGap?: number | ITileGap;
29
+ tileStagger?: IStagger;
30
+ tileRotation?: number;
31
+ }
32
+ interface IProcessDataType extends IRectData {
33
+ _tileContent?: string;
34
+ _tileMode?: boolean;
35
+ _tileSize?: number;
36
+ _tileGap?: number;
37
+ _tileStagger?: number;
38
+ _tileRotation?: number;
39
+ }
40
+ interface IWatermark extends IWatermarkAttrData, IUI {
41
+ __: IProcessDataType;
42
+ }
43
+ interface IWatermarkInputData extends IWatermarkAttrData, IRectInputData {
44
+ }
45
+ declare class ProcessorData extends RectData implements IProcessDataType {
46
+ __leaf: Watermark;
47
+ _tileContent?: string;
48
+ setTileContent(value: string): void;
49
+ _tileMode?: boolean;
50
+ setTileMode(value: boolean): void;
51
+ _tileSize?: number;
52
+ setTileSize(value: number): void;
53
+ _tileGap?: number;
54
+ setTileGap(value: number): void;
55
+ _tileStagger?: number;
56
+ setTileStagger(value: number): void;
57
+ _tileRotation?: number;
58
+ setTileRotation(value: number): void;
59
+ __getData(): IObject;
60
+ __getInputData(names?: string[] | IObject, options?: IJSONOptions): IObject;
61
+ }
62
+ declare class Watermark<TConstructorData = IWatermarkInputData> extends Rect<TConstructorData> implements IWatermark {
63
+ get __tag(): string;
64
+ __: IProcessDataType;
65
+ tileContent?: string;
66
+ tileMode: boolean;
67
+ tileSize: number;
68
+ tileGap: number | {
69
+ x?: number;
70
+ y?: number;
71
+ };
72
+ tileStagger: IStagger;
73
+ tileRotation: number;
74
+ width: number;
75
+ height: number;
76
+ private _cachedUrl?;
77
+ private _cachedBounds?;
78
+ constructor(data?: TConstructorData);
79
+ private createTileItem;
80
+ regenerateImage(): void;
81
+ updateFill(): void;
82
+ toJSON(options?: IJSONOptions): IUIJSONData;
83
+ }
84
+
85
+ declare function normalizeStagger(stagger: IStagger): INormalizedStagger;
86
+ declare function installStaggerPattern(): void;
87
+ declare function processStaggerData(paint: any): INormalizedStagger | null;
88
+
89
+ export { ProcessorData, Watermark, installStaggerPattern, normalizeStagger, processStaggerData };
90
+ export type { INormalizedStagger, IProcessDataType, IStagger, IStaggerData, IStaggerType, IWatermark, IWatermarkAttrData, IWatermarkInputData };
package/dist/index.mjs ADDED
@@ -0,0 +1,308 @@
1
+ import { MatrixHelper, MathHelper, PaintImage, Platform, Debug, dataProcessor, boundsType, registerUI, Plugin, RectData, Rect, UICreator, isObject } from '@leafer-ui/core';
2
+
3
+ const { get, scale, copy } = MatrixHelper;
4
+ const { getFloorScale } = MathHelper;
5
+ const { abs } = Math;
6
+ const originalCreatePattern = PaintImage.createPattern.bind(PaintImage);
7
+ function normalizeStagger(stagger) {
8
+ if (typeof stagger === "number") {
9
+ return { type: "x", offset: stagger };
10
+ }
11
+ return { type: stagger.type || "x", offset: stagger.offset || 0 };
12
+ }
13
+ function createStaggerCanvas(image, imgWidth, imgHeight, xGap, yGap, stagger, opacity, smooth) {
14
+ const unitWidth = imgWidth + xGap;
15
+ const unitHeight = imgHeight + yGap;
16
+ const isXStagger = stagger.type === "x";
17
+ const patternWidth = isXStagger ? unitWidth : unitWidth * 2;
18
+ const patternHeight = isXStagger ? unitHeight * 2 : unitHeight;
19
+ const canvas = Platform.origin.createCanvas(
20
+ Math.max(Math.floor(patternWidth), 1),
21
+ Math.max(Math.floor(patternHeight), 1)
22
+ );
23
+ const ctx = canvas.getContext("2d");
24
+ if (opacity && opacity < 1)
25
+ ctx.globalAlpha = opacity;
26
+ ctx.imageSmoothingEnabled = smooth !== false;
27
+ const imgView = image.view;
28
+ const drawImg = (x, y) => {
29
+ ctx.drawImage(imgView, 0, 0, image.width, image.height, x, y, imgWidth, imgHeight);
30
+ };
31
+ const offset = stagger.offset / 100 * (isXStagger ? unitWidth : unitHeight);
32
+ if (isXStagger) {
33
+ drawImg(0, 0);
34
+ drawImg(offset, unitHeight);
35
+ if (offset + imgWidth > unitWidth) {
36
+ drawImg(offset - unitWidth, unitHeight);
37
+ }
38
+ } else {
39
+ drawImg(0, 0);
40
+ drawImg(unitWidth, offset);
41
+ if (offset + imgHeight > unitHeight) {
42
+ drawImg(unitWidth, offset - unitHeight);
43
+ }
44
+ }
45
+ return canvas;
46
+ }
47
+ function createPatternWithStagger(paint, ui, canvas, renderOptions) {
48
+ const originPaint = paint.originPaint;
49
+ const rawStagger = originPaint?.stagger;
50
+ if (rawStagger === void 0 || rawStagger === 0) {
51
+ originalCreatePattern(paint, ui, canvas, renderOptions);
52
+ return;
53
+ }
54
+ const stagger = normalizeStagger(rawStagger);
55
+ if (stagger.offset === 0) {
56
+ originalCreatePattern(paint, ui, canvas, renderOptions);
57
+ return;
58
+ }
59
+ let { scaleX, scaleY } = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
60
+ const id = `${scaleX}-${scaleY}-stagger-${stagger.type}-${stagger.offset}`;
61
+ if (paint.patternId !== id && !ui.destroyed) {
62
+ const { image, data } = paint;
63
+ const { transform, gap } = data;
64
+ const fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
65
+ let imageMatrix;
66
+ let xGap = 0;
67
+ let yGap = 0;
68
+ let { width, height } = image;
69
+ if (fixScale) {
70
+ scaleX *= fixScale;
71
+ scaleY *= fixScale;
72
+ }
73
+ width *= scaleX;
74
+ height *= scaleY;
75
+ if (gap) {
76
+ xGap = gap.x * scaleX / abs(data.scaleX || 1);
77
+ yGap = gap.y * scaleY / abs(data.scaleY || 1);
78
+ }
79
+ const unitWidth = width + xGap;
80
+ const unitHeight = height + yGap;
81
+ const isXStagger = stagger.type === "x";
82
+ const patternWidth = isXStagger ? unitWidth : unitWidth * 2;
83
+ const patternHeight = isXStagger ? unitHeight * 2 : unitHeight;
84
+ if (transform || scaleX !== 1 || scaleY !== 1) {
85
+ const matrixScaleX = scaleX * getFloorScale(patternWidth);
86
+ const matrixScaleY = scaleY * getFloorScale(patternHeight);
87
+ imageMatrix = get();
88
+ if (transform)
89
+ copy(imageMatrix, transform);
90
+ scale(imageMatrix, 1 / matrixScaleX, 1 / matrixScaleY);
91
+ }
92
+ const imageCanvas = createStaggerCanvas(
93
+ image,
94
+ width,
95
+ height,
96
+ xGap,
97
+ yGap,
98
+ stagger,
99
+ data.opacity,
100
+ ui.leafer?.config.smooth
101
+ );
102
+ const pattern = image.getPattern(
103
+ imageCanvas,
104
+ data.repeat || "repeat",
105
+ imageMatrix,
106
+ paint
107
+ );
108
+ paint.style = pattern;
109
+ paint.patternId = id;
110
+ }
111
+ }
112
+ function installStaggerPattern() {
113
+ PaintImage.createPattern = createPatternWithStagger;
114
+ }
115
+ function processStaggerData(paint) {
116
+ if (paint.stagger !== void 0) {
117
+ return normalizeStagger(paint.stagger);
118
+ }
119
+ return null;
120
+ }
121
+
122
+ var __defProp = Object.defineProperty;
123
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
124
+ var __decorateClass = (decorators, target, key, kind) => {
125
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
126
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
127
+ if (decorator = decorators[i])
128
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
129
+ if (kind && result) __defProp(target, key, result);
130
+ return result;
131
+ };
132
+ installStaggerPattern();
133
+ const debug = Debug.get("leafer-x-watermark");
134
+ class ProcessorData extends RectData {
135
+ __leaf;
136
+ _tileContent;
137
+ setTileContent(value) {
138
+ this._tileContent = value;
139
+ this.__leaf.regenerateImage();
140
+ }
141
+ _tileMode;
142
+ setTileMode(value) {
143
+ this._tileMode = value;
144
+ this.__leaf.updateFill();
145
+ }
146
+ _tileSize;
147
+ setTileSize(value) {
148
+ this._tileSize = value;
149
+ this.__leaf.updateFill();
150
+ }
151
+ _tileGap;
152
+ setTileGap(value) {
153
+ this._tileGap = value;
154
+ this.__leaf.updateFill();
155
+ }
156
+ _tileStagger;
157
+ setTileStagger(value) {
158
+ this._tileStagger = value;
159
+ this.__leaf.updateFill();
160
+ }
161
+ _tileRotation;
162
+ setTileRotation(value) {
163
+ this._tileRotation = value;
164
+ this.__leaf.updateFill();
165
+ }
166
+ __getData() {
167
+ const data = super.__getData();
168
+ if (data.url)
169
+ delete data.fill;
170
+ return data;
171
+ }
172
+ __getInputData(names, options) {
173
+ const data = super.__getInputData(names, options);
174
+ if (data.url)
175
+ delete data.fill;
176
+ return data;
177
+ }
178
+ }
179
+ let Watermark = class extends Rect {
180
+ get __tag() {
181
+ return "Watermark";
182
+ }
183
+ // 缓存导出的图片和尺寸信息
184
+ _cachedUrl;
185
+ _cachedBounds;
186
+ constructor(data) {
187
+ super(data);
188
+ this.regenerateImage();
189
+ }
190
+ createTileItem(itemData) {
191
+ return UICreator.get("Group", {
192
+ children: [itemData],
193
+ // rotation: this.tileRotation,
194
+ around: "center"
195
+ });
196
+ }
197
+ regenerateImage() {
198
+ Platform.requestRender(async () => {
199
+ const { tileContent, width, height } = this;
200
+ if (!tileContent) {
201
+ this._cachedUrl = void 0;
202
+ this._cachedBounds = void 0;
203
+ this.fill = void 0;
204
+ return;
205
+ }
206
+ let itemData;
207
+ try {
208
+ itemData = JSON.parse(tileContent);
209
+ } catch (e) {
210
+ debug.error("Invalid tileContent JSON:", e);
211
+ return;
212
+ }
213
+ const tempItem = this.createTileItem(itemData);
214
+ const bounds = tempItem.getBounds("box", "local");
215
+ if (!width || !height) {
216
+ this.width = bounds.width;
217
+ this.height = bounds.height;
218
+ }
219
+ const exportWidth = 1e3;
220
+ const { data: url } = await tempItem.export("png", {
221
+ blob: false,
222
+ size: { width: exportWidth }
223
+ });
224
+ this._cachedUrl = url;
225
+ this._cachedBounds = { width: bounds.width, height: bounds.height };
226
+ tempItem.destroy();
227
+ this.updateFill();
228
+ });
229
+ }
230
+ updateFill() {
231
+ Platform.requestRender(() => {
232
+ const { tileMode, tileSize, tileGap, tileStagger } = this;
233
+ if (!this._cachedUrl || !this._cachedBounds || tileSize <= 0) {
234
+ this.fill = void 0;
235
+ return;
236
+ }
237
+ const { width: boundsWidth, height: boundsHeight } = this._cachedBounds;
238
+ if (!tileMode) {
239
+ this.fill = {
240
+ type: "image",
241
+ url: this._cachedUrl,
242
+ mode: "stretch"
243
+ };
244
+ } else {
245
+ const scale = tileSize / 100;
246
+ const sizeWidth = boundsWidth * scale;
247
+ const sizeHeight = boundsHeight * scale;
248
+ let xGap, yGap;
249
+ if (isObject(tileGap)) {
250
+ xGap = tileGap.x;
251
+ yGap = tileGap.y;
252
+ } else {
253
+ xGap = yGap = tileGap;
254
+ }
255
+ const gapX = xGap / 100 * sizeWidth;
256
+ const gapY = yGap / 100 * sizeHeight;
257
+ this.fill = {
258
+ type: "image",
259
+ url: this._cachedUrl,
260
+ mode: "repeat",
261
+ gap: { x: gapX, y: gapY },
262
+ size: { width: sizeWidth, height: sizeHeight },
263
+ stagger: tileStagger,
264
+ rotation: this.tileRotation,
265
+ align: "center"
266
+ };
267
+ }
268
+ });
269
+ }
270
+ toJSON(options) {
271
+ const data = super.toJSON(options);
272
+ const { fill, ...cleanData } = data;
273
+ return cleanData;
274
+ }
275
+ };
276
+ __decorateClass([
277
+ dataProcessor(ProcessorData)
278
+ ], Watermark.prototype, "__", 2);
279
+ __decorateClass([
280
+ boundsType()
281
+ ], Watermark.prototype, "tileContent", 2);
282
+ __decorateClass([
283
+ boundsType(true)
284
+ ], Watermark.prototype, "tileMode", 2);
285
+ __decorateClass([
286
+ boundsType(100)
287
+ ], Watermark.prototype, "tileSize", 2);
288
+ __decorateClass([
289
+ boundsType(0)
290
+ ], Watermark.prototype, "tileGap", 2);
291
+ __decorateClass([
292
+ boundsType(0)
293
+ ], Watermark.prototype, "tileStagger", 2);
294
+ __decorateClass([
295
+ boundsType(0)
296
+ ], Watermark.prototype, "tileRotation", 2);
297
+ __decorateClass([
298
+ boundsType(0)
299
+ ], Watermark.prototype, "width", 2);
300
+ __decorateClass([
301
+ boundsType(0)
302
+ ], Watermark.prototype, "height", 2);
303
+ Watermark = __decorateClass([
304
+ registerUI()
305
+ ], Watermark);
306
+ Plugin.add("leafer-x-watermark");
307
+
308
+ export { ProcessorData, Watermark, installStaggerPattern, normalizeStagger, processStaggerData };
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "leafer-x-watermark",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "packageManager": "pnpm@10.14.0",
6
+ "description": "Leafer 水印插件",
7
+ "author": "XiaDeYu <1579883916@qq.com>",
8
+ "license": "MIT",
9
+ "homepage": "https://github.com/Xdy1579883916/leafer-x-watermark#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/Xdy1579883916/leafer-x-watermark.git"
13
+ },
14
+ "bugs": "https://github.com/Xdy1579883916/leafer-x-watermark/issues",
15
+ "keywords": [
16
+ "leafer",
17
+ "水印",
18
+ "插件"
19
+ ],
20
+ "sideEffects": false,
21
+ "exports": {
22
+ ".": "./dist/index.mjs",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "main": "./dist/index.mjs",
26
+ "module": "./dist/index.mjs",
27
+ "types": "./dist/index.d.mts",
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "scripts": {
32
+ "build": "unbuild",
33
+ "dev": "pnpm run -C playground dev",
34
+ "doc": "pnpm run -C playground build",
35
+ "lint": "eslint",
36
+ "prepublishOnly": "nr build",
37
+ "release": "bumpp && npm publish",
38
+ "test": "vitest",
39
+ "prepare": "simple-git-hooks"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "registry": "https://registry.npmjs.org/"
44
+ },
45
+ "devDependencies": {
46
+ "@antfu/eslint-config": "^5.4.1",
47
+ "@antfu/ni": "^25.0.0",
48
+ "@antfu/utils": "^9.3.0",
49
+ "@lx/watermark": "workspace:*",
50
+ "@types/node": "^24.10.4",
51
+ "bumpp": "^10.3.2",
52
+ "eslint": "^9.39.2",
53
+ "lint-staged": "^16.2.7",
54
+ "simple-git-hooks": "^2.13.1",
55
+ "tinyexec": "^1.0.2",
56
+ "tsx": "^4.21.0",
57
+ "typescript": "^5.9.3",
58
+ "unbuild": "^3.6.1",
59
+ "vite": "^7.3.0",
60
+ "vitest": "^3.2.4",
61
+ "vitest-package-exports": "^0.1.1",
62
+ "yaml": "^2.8.2"
63
+ },
64
+ "simple-git-hooks": {
65
+ "pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
66
+ },
67
+ "lint-staged": {
68
+ "*": "eslint --fix"
69
+ }
70
+ }