@sealpixel/plugin-annotate 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/assets/Roboto-Apache-2.0.txt +201 -0
- package/assets/Roboto-Regular.ttf +0 -0
- package/dist/index.d.ts +277 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +256 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
Binary file
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import type { AssetDeclaration, Color, OperationBase, Rect, SourcePx } from '@sealpixel/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export interface Stroke {
|
|
4
|
+
color: Color;
|
|
5
|
+
width: SourcePx;
|
|
6
|
+
}
|
|
7
|
+
export type TextAlign = 'left' | 'center' | 'right';
|
|
8
|
+
export type Point = [number, number];
|
|
9
|
+
export type Shape = {
|
|
10
|
+
kind: 'rect';
|
|
11
|
+
rect: Rect;
|
|
12
|
+
stroke?: Stroke | undefined;
|
|
13
|
+
fill?: Color | undefined;
|
|
14
|
+
radius?: SourcePx | undefined;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'ellipse';
|
|
17
|
+
rect: Rect;
|
|
18
|
+
stroke?: Stroke | undefined;
|
|
19
|
+
fill?: Color | undefined;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'line';
|
|
22
|
+
from: Point;
|
|
23
|
+
to: Point;
|
|
24
|
+
stroke: Stroke;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'arrow';
|
|
27
|
+
from: Point;
|
|
28
|
+
to: Point;
|
|
29
|
+
stroke: Stroke;
|
|
30
|
+
head?: SourcePx | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'path';
|
|
33
|
+
points: Point[];
|
|
34
|
+
stroke: Stroke;
|
|
35
|
+
closed?: boolean | undefined;
|
|
36
|
+
fill?: Color | undefined;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'text';
|
|
39
|
+
rect: Rect;
|
|
40
|
+
text: string;
|
|
41
|
+
font: string;
|
|
42
|
+
size: SourcePx;
|
|
43
|
+
color: Color;
|
|
44
|
+
align?: TextAlign | undefined;
|
|
45
|
+
lineHeight?: number | undefined;
|
|
46
|
+
background?: Color | undefined;
|
|
47
|
+
padding?: SourcePx | undefined;
|
|
48
|
+
};
|
|
49
|
+
export interface Annotation {
|
|
50
|
+
id: string;
|
|
51
|
+
shape: Shape;
|
|
52
|
+
}
|
|
53
|
+
export interface AnnotateDoc {
|
|
54
|
+
/** Drawn in order: later entries are on top. */
|
|
55
|
+
shapes: Annotation[];
|
|
56
|
+
}
|
|
57
|
+
export interface AnnotateAddOp extends OperationBase<'annotate.add'> {
|
|
58
|
+
shape: Shape;
|
|
59
|
+
shapeId?: string | undefined;
|
|
60
|
+
}
|
|
61
|
+
export interface AnnotateUpdateOp extends OperationBase<'annotate.update'> {
|
|
62
|
+
shapeId: string;
|
|
63
|
+
shape: Shape;
|
|
64
|
+
}
|
|
65
|
+
export interface AnnotateRemoveOp extends OperationBase<'annotate.remove'> {
|
|
66
|
+
shapeId: string;
|
|
67
|
+
}
|
|
68
|
+
export interface AnnotateReorderOp extends OperationBase<'annotate.reorder'> {
|
|
69
|
+
/** Complete new order of shape ids. Unknown ids are ignored, missing ids keep their relative order at the end. */
|
|
70
|
+
order: string[];
|
|
71
|
+
}
|
|
72
|
+
export type AnnotateClearOp = OperationBase<'annotate.clear'>;
|
|
73
|
+
declare module '@sealpixel/core' {
|
|
74
|
+
interface OperationRegistry {
|
|
75
|
+
'annotate.add': AnnotateAddOp;
|
|
76
|
+
'annotate.update': AnnotateUpdateOp;
|
|
77
|
+
'annotate.remove': AnnotateRemoveOp;
|
|
78
|
+
'annotate.reorder': AnnotateReorderOp;
|
|
79
|
+
'annotate.clear': AnnotateClearOp;
|
|
80
|
+
}
|
|
81
|
+
interface DocumentRegistry {
|
|
82
|
+
annotate: AnnotateDoc;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** sha256 of `assets/Roboto-Regular.ttf`. */
|
|
86
|
+
export declare const DEFAULT_FONT_HASH = "56a45233d29f11b4dfb86d248e921939d115778f87325e7ae8cc108383d6664d";
|
|
87
|
+
/**
|
|
88
|
+
* Default font shipped with the plugin. The url points into this package so
|
|
89
|
+
* bundlers emit the file as an asset; hosts may override it via `createAnnotatePlugin`.
|
|
90
|
+
*/
|
|
91
|
+
export declare const DEFAULT_FONT: AssetDeclaration;
|
|
92
|
+
export declare const ShapeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
93
|
+
kind: z.ZodLiteral<"rect">;
|
|
94
|
+
rect: z.ZodObject<{
|
|
95
|
+
x: z.ZodNumber;
|
|
96
|
+
y: z.ZodNumber;
|
|
97
|
+
width: z.ZodNumber;
|
|
98
|
+
height: z.ZodNumber;
|
|
99
|
+
}, z.core.$strict>;
|
|
100
|
+
stroke: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
color: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
102
|
+
width: z.ZodNumber;
|
|
103
|
+
}, z.core.$strict>>;
|
|
104
|
+
fill: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
105
|
+
radius: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
107
|
+
kind: z.ZodLiteral<"ellipse">;
|
|
108
|
+
rect: z.ZodObject<{
|
|
109
|
+
x: z.ZodNumber;
|
|
110
|
+
y: z.ZodNumber;
|
|
111
|
+
width: z.ZodNumber;
|
|
112
|
+
height: z.ZodNumber;
|
|
113
|
+
}, z.core.$strict>;
|
|
114
|
+
stroke: z.ZodOptional<z.ZodObject<{
|
|
115
|
+
color: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
116
|
+
width: z.ZodNumber;
|
|
117
|
+
}, z.core.$strict>>;
|
|
118
|
+
fill: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
119
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
120
|
+
kind: z.ZodLiteral<"line">;
|
|
121
|
+
from: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
122
|
+
to: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
123
|
+
stroke: z.ZodObject<{
|
|
124
|
+
color: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
125
|
+
width: z.ZodNumber;
|
|
126
|
+
}, z.core.$strict>;
|
|
127
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
128
|
+
kind: z.ZodLiteral<"arrow">;
|
|
129
|
+
from: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
130
|
+
to: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
131
|
+
stroke: z.ZodObject<{
|
|
132
|
+
color: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
133
|
+
width: z.ZodNumber;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
head: z.ZodOptional<z.ZodNumber>;
|
|
136
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
137
|
+
kind: z.ZodLiteral<"path">;
|
|
138
|
+
points: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
139
|
+
stroke: z.ZodObject<{
|
|
140
|
+
color: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
141
|
+
width: z.ZodNumber;
|
|
142
|
+
}, z.core.$strict>;
|
|
143
|
+
closed: z.ZodOptional<z.ZodBoolean>;
|
|
144
|
+
fill: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
145
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
146
|
+
kind: z.ZodLiteral<"text">;
|
|
147
|
+
rect: z.ZodObject<{
|
|
148
|
+
x: z.ZodNumber;
|
|
149
|
+
y: z.ZodNumber;
|
|
150
|
+
width: z.ZodNumber;
|
|
151
|
+
height: z.ZodNumber;
|
|
152
|
+
}, z.core.$strict>;
|
|
153
|
+
text: z.ZodString;
|
|
154
|
+
font: z.ZodString;
|
|
155
|
+
size: z.ZodNumber;
|
|
156
|
+
color: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
157
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
158
|
+
left: "left";
|
|
159
|
+
center: "center";
|
|
160
|
+
right: "right";
|
|
161
|
+
}>>;
|
|
162
|
+
lineHeight: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
background: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
164
|
+
padding: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
}, z.core.$strict>], "kind">;
|
|
166
|
+
export declare const annotateAdd: import("@sealpixel/core").OperationDef<AnnotateDoc, AnnotateAddOp>;
|
|
167
|
+
export declare const annotateUpdate: import("@sealpixel/core").OperationDef<AnnotateDoc, AnnotateUpdateOp>;
|
|
168
|
+
export declare const annotateRemove: import("@sealpixel/core").OperationDef<AnnotateDoc, AnnotateRemoveOp>;
|
|
169
|
+
export declare const annotateReorder: import("@sealpixel/core").OperationDef<AnnotateDoc, AnnotateReorderOp>;
|
|
170
|
+
export declare const annotateClear: import("@sealpixel/core").OperationDef<AnnotateDoc, AnnotateClearOp>;
|
|
171
|
+
/** Font ids referenced by a document slice, for pre-loading. */
|
|
172
|
+
export declare function fontsUsed(doc: AnnotateDoc): string[];
|
|
173
|
+
export type AnnotateKind = Shape['kind'];
|
|
174
|
+
export declare const AnnotateOptionsSchema: z.ZodObject<{
|
|
175
|
+
shapes: z.ZodArray<z.ZodEnum<{
|
|
176
|
+
rect: "rect";
|
|
177
|
+
ellipse: "ellipse";
|
|
178
|
+
line: "line";
|
|
179
|
+
arrow: "arrow";
|
|
180
|
+
path: "path";
|
|
181
|
+
text: "text";
|
|
182
|
+
}>>;
|
|
183
|
+
palette: z.ZodArray<z.ZodString>;
|
|
184
|
+
defaultStroke: z.ZodObject<{
|
|
185
|
+
color: z.ZodString;
|
|
186
|
+
width: z.ZodNumber;
|
|
187
|
+
}, z.core.$strict>;
|
|
188
|
+
widthRange: z.ZodObject<{
|
|
189
|
+
min: z.ZodNumber;
|
|
190
|
+
max: z.ZodNumber;
|
|
191
|
+
step: z.ZodNumber;
|
|
192
|
+
}, z.core.$strict>;
|
|
193
|
+
fonts: z.ZodArray<z.ZodObject<{
|
|
194
|
+
id: z.ZodString;
|
|
195
|
+
hash: z.ZodString;
|
|
196
|
+
url: z.ZodOptional<z.ZodString>;
|
|
197
|
+
label: z.ZodOptional<z.ZodString>;
|
|
198
|
+
}, z.core.$strict>>;
|
|
199
|
+
defaultText: z.ZodString;
|
|
200
|
+
fill: z.ZodBoolean;
|
|
201
|
+
sizeRange: z.ZodObject<{
|
|
202
|
+
min: z.ZodNumber;
|
|
203
|
+
max: z.ZodNumber;
|
|
204
|
+
step: z.ZodNumber;
|
|
205
|
+
}, z.core.$strict>;
|
|
206
|
+
enforce: z.ZodBoolean;
|
|
207
|
+
}, z.core.$strict>;
|
|
208
|
+
/**
|
|
209
|
+
* `shapes`: tools offered, in order. `palette`: hex swatches (empty shows the
|
|
210
|
+
* free picker only). `defaultStroke`: colour and width a new shape starts
|
|
211
|
+
* with. `fonts`: font assets offered for text, the first is the default.
|
|
212
|
+
* `defaultText`: text a new text shape starts with (empty uses the locale
|
|
213
|
+
* default). `fill`: allow filled rectangles and ellipses. `sizeRange`: font
|
|
214
|
+
* size bounds in source px. `enforce`: reject shapes, fonts, sizes, widths and palette colours outside the options.
|
|
215
|
+
*/
|
|
216
|
+
export type AnnotateOptions = z.infer<typeof AnnotateOptionsSchema>;
|
|
217
|
+
export declare const ANNOTATE_DEFAULT_OPTIONS: AnnotateOptions;
|
|
218
|
+
/** `#rrggbb` or `#rrggbbaa` → 0..1 colour. */
|
|
219
|
+
export declare function colorFromHex(h: string): Color;
|
|
220
|
+
export declare const annotatePlugin: import("@sealpixel/plugin-sdk").ConfigurablePlugin<"annotate", AnnotateDoc, {
|
|
221
|
+
shapes: ("rect" | "ellipse" | "line" | "arrow" | "path" | "text")[];
|
|
222
|
+
palette: string[];
|
|
223
|
+
defaultStroke: {
|
|
224
|
+
color: string;
|
|
225
|
+
width: number;
|
|
226
|
+
};
|
|
227
|
+
widthRange: {
|
|
228
|
+
min: number;
|
|
229
|
+
max: number;
|
|
230
|
+
step: number;
|
|
231
|
+
};
|
|
232
|
+
fonts: {
|
|
233
|
+
id: string;
|
|
234
|
+
hash: string;
|
|
235
|
+
url?: string | undefined;
|
|
236
|
+
label?: string | undefined;
|
|
237
|
+
}[];
|
|
238
|
+
defaultText: string;
|
|
239
|
+
fill: boolean;
|
|
240
|
+
sizeRange: {
|
|
241
|
+
min: number;
|
|
242
|
+
max: number;
|
|
243
|
+
step: number;
|
|
244
|
+
};
|
|
245
|
+
enforce: boolean;
|
|
246
|
+
}>;
|
|
247
|
+
/** Kept for hosts written before options existed: `createAnnotatePlugin({ fonts })`. */
|
|
248
|
+
export declare function createAnnotatePlugin(options?: {
|
|
249
|
+
fonts?: AssetDeclaration[];
|
|
250
|
+
}): import("@sealpixel/plugin-sdk").ConfigurablePlugin<"annotate", AnnotateDoc, {
|
|
251
|
+
shapes: ("rect" | "ellipse" | "line" | "arrow" | "path" | "text")[];
|
|
252
|
+
palette: string[];
|
|
253
|
+
defaultStroke: {
|
|
254
|
+
color: string;
|
|
255
|
+
width: number;
|
|
256
|
+
};
|
|
257
|
+
widthRange: {
|
|
258
|
+
min: number;
|
|
259
|
+
max: number;
|
|
260
|
+
step: number;
|
|
261
|
+
};
|
|
262
|
+
fonts: {
|
|
263
|
+
id: string;
|
|
264
|
+
hash: string;
|
|
265
|
+
url?: string | undefined;
|
|
266
|
+
label?: string | undefined;
|
|
267
|
+
}[];
|
|
268
|
+
defaultText: string;
|
|
269
|
+
fill: boolean;
|
|
270
|
+
sizeRange: {
|
|
271
|
+
min: number;
|
|
272
|
+
max: number;
|
|
273
|
+
step: number;
|
|
274
|
+
};
|
|
275
|
+
enforce: boolean;
|
|
276
|
+
}>;
|
|
277
|
+
//# 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,IAAI,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE9F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,QAAQ,CAAC;CACjB;AACD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AACpD,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErC,MAAM,MAAM,KAAK,GACb;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX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AAO,MAAM,WAAW,oEActB,CAAC;AACH,eAAO,MAAM,cAAc,uEAazB,CAAC;AACH,eAAO,MAAM,cAAc,uEAMzB,CAAC;AACH,eAAO,MAAM,eAAe,wEAiB1B,CAAC;AACH,eAAO,MAAM,aAAa,sEAIxB,CAAC;AAEH,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,EAAE,CAEpD;AAED,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAezC,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAYvB,CAAC;AAEZ;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,wBAAwB,EAAE,eAUtC,CAAC;AAEF,8CAA8C;AAC9C,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,CAI7C;AAID,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;EA4DzB,CAAC;AAEH,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;GAEhF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { defineOperation, definePlugin } from '@sealpixel/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/** sha256 of `assets/Roboto-Regular.ttf`. */
|
|
4
|
+
export const DEFAULT_FONT_HASH = '56a45233d29f11b4dfb86d248e921939d115778f87325e7ae8cc108383d6664d';
|
|
5
|
+
/**
|
|
6
|
+
* Default font shipped with the plugin. The url points into this package so
|
|
7
|
+
* bundlers emit the file as an asset; hosts may override it via `createAnnotatePlugin`.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_FONT = {
|
|
10
|
+
id: 'font.roboto',
|
|
11
|
+
hash: DEFAULT_FONT_HASH,
|
|
12
|
+
url: new URL('../assets/Roboto-Regular.ttf', import.meta.url).href,
|
|
13
|
+
};
|
|
14
|
+
const unit = z.number().min(0).max(1);
|
|
15
|
+
const num = z.number().finite();
|
|
16
|
+
const px = z.number().finite().min(0).max(4096);
|
|
17
|
+
const channel = z.number().min(0).max(1);
|
|
18
|
+
const ColorSchema = z.tuple([channel, channel, channel, channel]);
|
|
19
|
+
const PointSchema = z.tuple([num, num]);
|
|
20
|
+
const RectSchema = z
|
|
21
|
+
.object({ x: num, y: num, width: z.number().min(0), height: z.number().min(0) })
|
|
22
|
+
.strict();
|
|
23
|
+
const StrokeSchema = z.object({ color: ColorSchema, width: px }).strict();
|
|
24
|
+
export const ShapeSchema = z.discriminatedUnion('kind', [
|
|
25
|
+
z
|
|
26
|
+
.object({
|
|
27
|
+
kind: z.literal('rect'),
|
|
28
|
+
rect: RectSchema,
|
|
29
|
+
stroke: StrokeSchema.optional(),
|
|
30
|
+
fill: ColorSchema.optional(),
|
|
31
|
+
radius: px.optional(),
|
|
32
|
+
})
|
|
33
|
+
.strict(),
|
|
34
|
+
z
|
|
35
|
+
.object({
|
|
36
|
+
kind: z.literal('ellipse'),
|
|
37
|
+
rect: RectSchema,
|
|
38
|
+
stroke: StrokeSchema.optional(),
|
|
39
|
+
fill: ColorSchema.optional(),
|
|
40
|
+
})
|
|
41
|
+
.strict(),
|
|
42
|
+
z
|
|
43
|
+
.object({
|
|
44
|
+
kind: z.literal('line'),
|
|
45
|
+
from: PointSchema,
|
|
46
|
+
to: PointSchema,
|
|
47
|
+
stroke: StrokeSchema.extend({ width: px.gt(0) }),
|
|
48
|
+
})
|
|
49
|
+
.strict(),
|
|
50
|
+
z
|
|
51
|
+
.object({
|
|
52
|
+
kind: z.literal('arrow'),
|
|
53
|
+
from: PointSchema,
|
|
54
|
+
to: PointSchema,
|
|
55
|
+
stroke: StrokeSchema.extend({ width: px.gt(0) }),
|
|
56
|
+
head: px.optional(),
|
|
57
|
+
})
|
|
58
|
+
.strict(),
|
|
59
|
+
z
|
|
60
|
+
.object({
|
|
61
|
+
kind: z.literal('path'),
|
|
62
|
+
points: z.array(PointSchema).min(2).max(5000),
|
|
63
|
+
stroke: StrokeSchema,
|
|
64
|
+
closed: z.boolean().optional(),
|
|
65
|
+
fill: ColorSchema.optional(),
|
|
66
|
+
})
|
|
67
|
+
.strict(),
|
|
68
|
+
z
|
|
69
|
+
.object({
|
|
70
|
+
kind: z.literal('text'),
|
|
71
|
+
rect: RectSchema,
|
|
72
|
+
text: z.string().max(10_000),
|
|
73
|
+
font: z.string().min(1),
|
|
74
|
+
size: px.gt(0),
|
|
75
|
+
color: ColorSchema,
|
|
76
|
+
align: z.enum(['left', 'center', 'right']).optional(),
|
|
77
|
+
lineHeight: z.number().gt(0).max(10).optional(),
|
|
78
|
+
background: ColorSchema.optional(),
|
|
79
|
+
padding: px.optional(),
|
|
80
|
+
})
|
|
81
|
+
.strict(),
|
|
82
|
+
]);
|
|
83
|
+
const base = { id: z.string().min(1), at: z.number().optional() };
|
|
84
|
+
export const annotateAdd = defineOperation({
|
|
85
|
+
type: 'annotate.add',
|
|
86
|
+
schema: z
|
|
87
|
+
.object({
|
|
88
|
+
type: z.literal('annotate.add'),
|
|
89
|
+
...base,
|
|
90
|
+
shape: ShapeSchema,
|
|
91
|
+
shapeId: z.string().min(1).optional(),
|
|
92
|
+
})
|
|
93
|
+
.strict(),
|
|
94
|
+
reduce: (slice, op) => {
|
|
95
|
+
const id = op.shapeId ?? op.id;
|
|
96
|
+
return { shapes: [...slice.shapes.filter((s) => s.id !== id), { id, shape: op.shape }] };
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
export const annotateUpdate = defineOperation({
|
|
100
|
+
type: 'annotate.update',
|
|
101
|
+
schema: z
|
|
102
|
+
.object({
|
|
103
|
+
type: z.literal('annotate.update'),
|
|
104
|
+
...base,
|
|
105
|
+
shapeId: z.string().min(1),
|
|
106
|
+
shape: ShapeSchema,
|
|
107
|
+
})
|
|
108
|
+
.strict(),
|
|
109
|
+
reduce: (slice, op) => ({
|
|
110
|
+
shapes: slice.shapes.map((s) => (s.id === op.shapeId ? { id: s.id, shape: op.shape } : s)),
|
|
111
|
+
}),
|
|
112
|
+
});
|
|
113
|
+
export const annotateRemove = defineOperation({
|
|
114
|
+
type: 'annotate.remove',
|
|
115
|
+
schema: z
|
|
116
|
+
.object({ type: z.literal('annotate.remove'), ...base, shapeId: z.string().min(1) })
|
|
117
|
+
.strict(),
|
|
118
|
+
reduce: (slice, op) => ({ shapes: slice.shapes.filter((s) => s.id !== op.shapeId) }),
|
|
119
|
+
});
|
|
120
|
+
export const annotateReorder = defineOperation({
|
|
121
|
+
type: 'annotate.reorder',
|
|
122
|
+
schema: z
|
|
123
|
+
.object({
|
|
124
|
+
type: z.literal('annotate.reorder'),
|
|
125
|
+
...base,
|
|
126
|
+
order: z.array(z.string().min(1)).max(10_000),
|
|
127
|
+
})
|
|
128
|
+
.strict(),
|
|
129
|
+
reduce: (slice, op) => {
|
|
130
|
+
const byId = new Map(slice.shapes.map((s) => [s.id, s]));
|
|
131
|
+
const ordered = op.order
|
|
132
|
+
.map((id) => byId.get(id))
|
|
133
|
+
.filter((s) => s !== undefined);
|
|
134
|
+
const rest = slice.shapes.filter((s) => !op.order.includes(s.id));
|
|
135
|
+
return { shapes: [...ordered, ...rest] };
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
export const annotateClear = defineOperation({
|
|
139
|
+
type: 'annotate.clear',
|
|
140
|
+
schema: z.object({ type: z.literal('annotate.clear'), ...base }).strict(),
|
|
141
|
+
reduce: () => ({ shapes: [] }),
|
|
142
|
+
});
|
|
143
|
+
/** Font ids referenced by a document slice, for pre-loading. */
|
|
144
|
+
export function fontsUsed(doc) {
|
|
145
|
+
return [...new Set(doc.shapes.flatMap((s) => (s.shape.kind === 'text' ? [s.shape.font] : [])))];
|
|
146
|
+
}
|
|
147
|
+
const hex = z.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/, 'hex colour');
|
|
148
|
+
const range = z
|
|
149
|
+
.object({ min: z.number().positive(), max: z.number().positive(), step: z.number().positive() })
|
|
150
|
+
.strict()
|
|
151
|
+
.refine((r) => r.min < r.max, 'min must be below max');
|
|
152
|
+
const FontSchema = z
|
|
153
|
+
.object({
|
|
154
|
+
id: z.string().min(1),
|
|
155
|
+
hash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
156
|
+
url: z.string().min(1).optional(),
|
|
157
|
+
label: z.string().min(1).optional(),
|
|
158
|
+
})
|
|
159
|
+
.strict();
|
|
160
|
+
export const AnnotateOptionsSchema = z
|
|
161
|
+
.object({
|
|
162
|
+
shapes: z.array(z.enum(['rect', 'ellipse', 'line', 'arrow', 'path', 'text'])).min(1),
|
|
163
|
+
palette: z.array(hex),
|
|
164
|
+
defaultStroke: z.object({ color: hex, width: z.number().positive() }).strict(),
|
|
165
|
+
widthRange: range,
|
|
166
|
+
fonts: z.array(FontSchema).min(1),
|
|
167
|
+
defaultText: z.string(),
|
|
168
|
+
fill: z.boolean(),
|
|
169
|
+
sizeRange: range,
|
|
170
|
+
enforce: z.boolean(),
|
|
171
|
+
})
|
|
172
|
+
.strict();
|
|
173
|
+
export const ANNOTATE_DEFAULT_OPTIONS = {
|
|
174
|
+
shapes: ['rect', 'ellipse', 'line', 'arrow', 'path', 'text'],
|
|
175
|
+
palette: [],
|
|
176
|
+
defaultStroke: { color: '#ff3b30', width: 4 },
|
|
177
|
+
widthRange: { min: 1, max: 64, step: 1 },
|
|
178
|
+
fonts: [{ ...DEFAULT_FONT, label: 'Roboto' }],
|
|
179
|
+
defaultText: '',
|
|
180
|
+
fill: true,
|
|
181
|
+
sizeRange: { min: 6, max: 200, step: 1 },
|
|
182
|
+
enforce: false,
|
|
183
|
+
};
|
|
184
|
+
/** `#rrggbb` or `#rrggbbaa` → 0..1 colour. */
|
|
185
|
+
export function colorFromHex(h) {
|
|
186
|
+
const n = Number.parseInt(h.slice(1, 7), 16);
|
|
187
|
+
const a = h.length === 9 ? Number.parseInt(h.slice(7, 9), 16) / 255 : 1;
|
|
188
|
+
return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255, a];
|
|
189
|
+
}
|
|
190
|
+
const closeColor = (a, b) => a.every((v, i) => Math.abs(v - b[i]) < 1.5 / 255);
|
|
191
|
+
export const annotatePlugin = definePlugin({
|
|
192
|
+
id: 'annotate',
|
|
193
|
+
version: 1,
|
|
194
|
+
operations: [annotateAdd, annotateUpdate, annotateRemove, annotateReorder, annotateClear],
|
|
195
|
+
initialDocument: { shapes: [] },
|
|
196
|
+
stage: { name: 'annotate', order: 300 },
|
|
197
|
+
toPlan: (doc) => (doc.shapes.length === 0 ? null : { shapes: doc.shapes.map((s) => s.shape) }),
|
|
198
|
+
kernel: { kind: 'core' },
|
|
199
|
+
assets: (options) => options.fonts.map(({ label: _label, ...asset }) => asset),
|
|
200
|
+
options: {
|
|
201
|
+
schema: AnnotateOptionsSchema,
|
|
202
|
+
defaults: ANNOTATE_DEFAULT_OPTIONS,
|
|
203
|
+
describe: {
|
|
204
|
+
shapes: 'Shape tools offered, in order.',
|
|
205
|
+
palette: 'Hex swatches for strokes and fills; empty shows the free picker only.',
|
|
206
|
+
defaultStroke: 'Colour and width a new shape starts with.',
|
|
207
|
+
widthRange: 'Bounds and step of the stroke width slider.',
|
|
208
|
+
fonts: 'Font assets offered for text: { id, hash, url?, label? }; the first is the default.',
|
|
209
|
+
defaultText: 'Text a new text shape starts with; empty uses the locale default.',
|
|
210
|
+
fill: 'Allow filled rectangles and ellipses.',
|
|
211
|
+
sizeRange: 'Font size bounds for text, in source px.',
|
|
212
|
+
enforce: 'Reject shapes, fonts, sizes, widths and (with a palette) colours outside the options.',
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
validate: (op, { options }) => {
|
|
216
|
+
if ((op.type !== 'annotate.add' && op.type !== 'annotate.update') || !options.enforce)
|
|
217
|
+
return null;
|
|
218
|
+
const shape = op.shape;
|
|
219
|
+
if (!options.shapes.includes(shape.kind))
|
|
220
|
+
return `shape "${shape.kind}" is not offered`;
|
|
221
|
+
if (!options.fill &&
|
|
222
|
+
(shape.kind === 'rect' || shape.kind === 'ellipse') &&
|
|
223
|
+
shape.fill !== undefined)
|
|
224
|
+
return 'filled shapes are disabled';
|
|
225
|
+
const stroke = 'stroke' in shape ? shape.stroke : undefined;
|
|
226
|
+
const w = options.widthRange;
|
|
227
|
+
if (stroke && (stroke.width < w.min - 1e-9 || stroke.width > w.max + 1e-9))
|
|
228
|
+
return `stroke width must stay within ${w.min}..${w.max}`;
|
|
229
|
+
if (shape.kind === 'text') {
|
|
230
|
+
if (!options.fonts.some((f) => f.id === shape.font))
|
|
231
|
+
return `font "${shape.font}" is not offered`;
|
|
232
|
+
const s = options.sizeRange;
|
|
233
|
+
if (shape.size < s.min - 1e-9 || shape.size > s.max + 1e-9)
|
|
234
|
+
return `font size must stay within ${s.min}..${s.max}`;
|
|
235
|
+
}
|
|
236
|
+
if (options.palette.length > 0) {
|
|
237
|
+
const allowed = options.palette.map(colorFromHex);
|
|
238
|
+
const colors = [];
|
|
239
|
+
if (stroke)
|
|
240
|
+
colors.push(stroke.color);
|
|
241
|
+
if ((shape.kind === 'rect' || shape.kind === 'ellipse') && shape.fill)
|
|
242
|
+
colors.push(shape.fill);
|
|
243
|
+
if (shape.kind === 'text')
|
|
244
|
+
colors.push(shape.color);
|
|
245
|
+
for (const c of colors)
|
|
246
|
+
if (!allowed.some((a) => closeColor(a, c)))
|
|
247
|
+
return 'colour is not in the palette';
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
/** Kept for hosts written before options existed: `createAnnotatePlugin({ fonts })`. */
|
|
253
|
+
export function createAnnotatePlugin(options = {}) {
|
|
254
|
+
return options.fonts ? annotatePlugin.configure({ fonts: options.fonts }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AAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,KAAK,CAAC,IAAI;gBACnE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC1B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;gBAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpD,KAAK,MAAM,CAAC,IAAI,MAAM;gBACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAAE,OAAO,8BAA8B,CAAC;QACtF,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC,CAAC;AAEH,wFAAwF;AACxF,MAAM,UAAU,oBAAoB,CAAC,UAA0C,EAAE;IAC/E,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;AAC7F,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sealpixel/plugin-annotate",
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
|
+
"description": "Rectangles, ellipses, lines, arrows, freehand paths and text over the image. Fonts are hashed assets so client and server rasterise identical glyphs.",
|
|
5
|
+
"license": "BUSL-1.1",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/9feet/sealpixel.git",
|
|
9
|
+
"directory": "packages/plugins/annotate"
|
|
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
|
+
"assets",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"sealpixel-plugin"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./assets/*": "./assets/*"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p tsconfig.build.json",
|
|
33
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
34
|
+
"test": "vitest run"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@sealpixel/plugin-sdk": "workspace:*"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@sealpixel/core": "workspace:*",
|
|
41
|
+
"zod": "^4.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@sealpixel/config": "workspace:*",
|
|
45
|
+
"@sealpixel/core": "workspace:*",
|
|
46
|
+
"@types/node": "^24.0.0",
|
|
47
|
+
"typescript": "^5.9.0",
|
|
48
|
+
"vitest": "^4.0.0",
|
|
49
|
+
"zod": "^4.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|