@inditextech/weave-sdk 5.7.0 → 5.8.0-SNAPSHOT.613.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.
package/dist/lab.d.ts ADDED
@@ -0,0 +1,289 @@
1
+ import Konva from "konva";
2
+ import { WeavePlugin } from "@inditextech/weave-sdk";
3
+ //#region src/actions/brush-tool/constants.d.ts
4
+ /** Name under which the lab plugin registers itself. */
5
+ declare const BRUSH_LAB_PLUGIN_NAME = "brushLab";
6
+ //#endregion
7
+ //#region src/actions/brush-tool/types.d.ts
8
+ /** Input profile keys resolved for every stroke. */
9
+ type WeaveBrushInputProfileKey = 'mouse' | 'touch' | 'pen.applePencil' | 'pen.desktop';
10
+ type WeaveBrushCaptureConfig = {
11
+ /** `legacy`: one position per event. `coalesced`: every batched sample. */
12
+ source: 'legacy' | 'coalesced';
13
+ /** Time base for time-dependent filters. */
14
+ clock: 'now' | 'event';
15
+ /** Samples closer than this (screen px) to the last one are skipped. */
16
+ minMovePx: number;
17
+ /** Whether the speculative predicted tail is drawn. */
18
+ predicted: 'off' | 'tail';
19
+ /** Event used to read samples. */
20
+ event: 'pointermove' | 'pointerrawupdate';
21
+ };
22
+ type WeaveBrushPressureConfig = {
23
+ /** How a reported pen pressure of 0 is treated. */
24
+ zero: 'legacy' | 'keep' | 'holdLast';
25
+ filter: 'legacy' | 'timeEma' | 'oneEuro' | 'none';
26
+ /** Time constant (ms) of the `timeEma` filter. */
27
+ timeConstantMs: number;
28
+ /** `oneEuro` filter parameters. */
29
+ oneEuro: {
30
+ minCutoff: number;
31
+ beta: number;
32
+ };
33
+ /** Lowest pressure that is recorded. */
34
+ floor: number;
35
+ /** How the first point's pressure is chosen. */
36
+ start: 'backfill' | 'average' | 'none';
37
+ /** Number of readings averaged by the `average` start policy. */
38
+ startSamples: number;
39
+ /** How the last point's pressure is chosen. */
40
+ end: 'backfill' | 'none';
41
+ };
42
+ type WeaveBrushStabilizerConfig = {
43
+ type: 'none' | 'oneEuro' | 'pulledString' | 'streamline';
44
+ /** `oneEuro` minimum cutoff (Hz) and speed coefficient. */
45
+ minCutoff: number;
46
+ beta: number;
47
+ /** `pulledString` leash radius, in screen px. */
48
+ radiusPx: number;
49
+ /** `streamline` amount, 0 (none) to 1 (strongest). */
50
+ amount: number;
51
+ /** Distances are screen pixels (same effect at any zoom); otherwise canvas units. */
52
+ zoomAware: boolean;
53
+ /** Complete the stroke at the release position. */
54
+ catchUpOnEnd: boolean;
55
+ };
56
+ type WeaveBrushFinalizeConfig = {
57
+ mode: 'dp' | 'dpPressure' | 'bezierFit' | 'none';
58
+ /** Tolerance; undefined uses the tool-level `simplifyTolerance`. */
59
+ tolerance?: number;
60
+ /** `canvas`: canvas units. `screen`: pixels, converted with the zoom. */
61
+ toleranceUnit: 'canvas' | 'screen';
62
+ /** Distance units per pressure unit for `dpPressure`. */
63
+ pressureWeight: number;
64
+ /** Spacing (screen px) used to resample a fitted curve to points. */
65
+ resampleSpacingPx: number;
66
+ };
67
+ type WeaveBrushTouchGuardConfig = {
68
+ /** Wait before a finger stroke is committed. */
69
+ waitMs: number;
70
+ /** Movement (screen px) that commits the stroke before the wait ends. */
71
+ movePx: number;
72
+ /** Cancel the stroke when a second touch lands during the wait. */
73
+ cancelOnSecondTouch: boolean;
74
+ /** Finger input does not draw once a pen has been used. */
75
+ ignoreAfterPen: boolean;
76
+ };
77
+ type WeaveBrushInputProfile = {
78
+ capture: WeaveBrushCaptureConfig;
79
+ pressure: WeaveBrushPressureConfig;
80
+ stabilizer: WeaveBrushStabilizerConfig;
81
+ finalize: WeaveBrushFinalizeConfig;
82
+ touchGuard: WeaveBrushTouchGuardConfig;
83
+ };
84
+ /**
85
+ * What the brush tool reports to the lab plugin while it is active. Nothing
86
+ * here is stored by the tool: the plugin keeps it in memory only.
87
+ */
88
+ type WeaveBrushTraceSink = {
89
+ isEnabled?: () => boolean;
90
+ onStrokeStart(info: {
91
+ profile: WeaveBrushInputProfileKey;
92
+ preset: string;
93
+ scenario?: string;
94
+ profileConfig: WeaveBrushInputProfile;
95
+ strokeWidth: number;
96
+ zoom: number;
97
+ }): void;
98
+ onSample(sample: {
99
+ raw: {
100
+ x: number;
101
+ y: number;
102
+ };
103
+ stabilized: {
104
+ x: number;
105
+ y: number;
106
+ };
107
+ pressure: number;
108
+ time: number;
109
+ predicted: boolean;
110
+ }): void;
111
+ onBatch(info: {
112
+ ms: number;
113
+ samples: number;
114
+ }): void;
115
+ onStrokeEnd(info: {
116
+ beforeFinalize: {
117
+ x: number;
118
+ y: number;
119
+ pressure: number;
120
+ }[];
121
+ finalPoints: {
122
+ x: number;
123
+ y: number;
124
+ pressure: number;
125
+ }[];
126
+ strokeWidth: number;
127
+ finalizeMs: number;
128
+ }): void;
129
+ };
130
+ //#endregion
131
+ //#region src/plugins/brush-lab/types.d.ts
132
+ type LabPoint = {
133
+ x: number;
134
+ y: number;
135
+ };
136
+ type LabPressurePoint = LabPoint & {
137
+ pressure: number;
138
+ /** Time of this sample's own event, in ms, when it has one. */
139
+ time?: number;
140
+ };
141
+ /** One sample the brush tool reported, as it was recorded. */
142
+ type LabRecordedSample = {
143
+ raw: LabPoint;
144
+ stabilized: LabPoint;
145
+ pressure: number;
146
+ /** Time reported for the sample, in ms. */
147
+ time: number;
148
+ predicted: boolean;
149
+ };
150
+ /** Measurements of one finished stroke. */
151
+ type WeaveBrushLabMetrics = {
152
+ profile: WeaveBrushInputProfileKey;
153
+ preset: string;
154
+ scenario?: string;
155
+ /** Samples the device reported (predicted ones left out). */
156
+ samples: number;
157
+ /** Points kept after finishing. */
158
+ points: number;
159
+ /** Consecutive samples at the same position. */
160
+ droppedDuplicates: number;
161
+ /** Samples per second over the stroke. */
162
+ effectiveRateHz: number;
163
+ /** Mean distance of a raw sample from the line through its neighbours. */
164
+ jitter: number;
165
+ /** Mean distance between each raw sample and where it was recorded. */
166
+ lag: number;
167
+ /** Largest distance a point moved by finishing the stroke. */
168
+ movedOnFinish: number;
169
+ /** Mean change of width between neighbouring points, in canvas units. */
170
+ widthRoughness: number;
171
+ /** Time spent processing and finishing the stroke, in ms. */
172
+ drawMs: number;
173
+ };
174
+ /** What the lab knows about the pointer devices it has seen. */
175
+ type WeaveBrushLabDeviceReport = {
176
+ pointerType: string | null;
177
+ resolvedProfile: WeaveBrushInputProfileKey | null;
178
+ /** Pointer events per second. */
179
+ sampleRateHz: number;
180
+ /** Mean samples per event, coalesced ones included. */
181
+ samplesPerEvent: number;
182
+ pressure: {
183
+ min: number;
184
+ max: number;
185
+ } | null;
186
+ tilt: boolean;
187
+ predictedAvailable: boolean;
188
+ zoom: number;
189
+ fps: number;
190
+ warnings: WeaveBrushLabWarning[];
191
+ };
192
+ type WeaveBrushLabWarning = 'penReportsAsMouse';
193
+ type WeaveBrushLabOverlays = {
194
+ raw: boolean;
195
+ stabilized: boolean;
196
+ final: boolean;
197
+ pressure: boolean;
198
+ };
199
+ /** One pointer event with every sample it carried (coalesced ones included). */
200
+ type LabGestureEvent = {
201
+ /** Event time, in ms. */
202
+ time: number;
203
+ samples: LabPressurePoint[];
204
+ };
205
+ /** What the pointer did during one gesture, in container coordinates. */
206
+ type LabGesture = {
207
+ events: LabGestureEvent[];
208
+ };
209
+ /** A stroke kept in memory for comparison. Never stored or sent anywhere. */
210
+ type LabRecording = {
211
+ profileKey: WeaveBrushInputProfileKey;
212
+ gesture: LabGesture;
213
+ strokeWidth: number;
214
+ zoom: number;
215
+ };
216
+ /** What `compareLast` drew, or why it drew nothing. */
217
+ type WeaveBrushLabCompareResult = {
218
+ lines: number;
219
+ events?: number;
220
+ reason?: string;
221
+ };
222
+ //#endregion
223
+ //#region src/plugins/brush-lab/brush-lab.d.ts
224
+ /**
225
+ * Lab for tuning the brush on real devices. It listens to the brush tool and
226
+ * draws overlays on a layer of its own. It never changes the document, and it
227
+ * keeps everything it records in memory only: nothing is stored, sent or
228
+ * written anywhere.
229
+ */
230
+ declare class WeaveBrushLabPlugin extends WeavePlugin implements WeaveBrushTraceSink {
231
+ private overlays;
232
+ private reporter;
233
+ private recordings;
234
+ private current;
235
+ private last;
236
+ private lastMetrics;
237
+ private compareScenario;
238
+ private recorder;
239
+ private listeners;
240
+ private frameHandle;
241
+ constructor(params?: {
242
+ maxGhosts?: number;
243
+ });
244
+ initialize(): void;
245
+ getName(): string;
246
+ getLayerName(): string;
247
+ getLayer(): Konva.Layer | undefined;
248
+ onInit(): void;
249
+ onRender(): void;
250
+ enable(): void;
251
+ disable(): void;
252
+ /** Pointer event position in the stage's drawing coordinates. */
253
+ private toStagePoint;
254
+ private recorderEvent;
255
+ private attach;
256
+ private detach;
257
+ private countFrames;
258
+ getDeviceReport(): WeaveBrushLabDeviceReport;
259
+ getLastMetrics(): WeaveBrushLabMetrics | null;
260
+ getOverlays(): WeaveBrushLabOverlays;
261
+ getRecordingCount(): number;
262
+ setOverlay(name: keyof WeaveBrushLabOverlays, on: boolean): void;
263
+ setMaxGhosts(max: number): void;
264
+ /**
265
+ * Draws the last stroke again through each named brush (every one when none
266
+ * are given), so the same handwriting can be compared across them.
267
+ */
268
+ compareLast(scenarioId: string): WeaveBrushLabCompareResult;
269
+ /** Forgets every kept stroke and removes the ghosts. */
270
+ clearGhosts(): void;
271
+ onStrokeStart(info: Parameters<WeaveBrushTraceSink['onStrokeStart']>[0]): void;
272
+ onSample(sample: LabRecordedSample): void;
273
+ onBatch(info: {
274
+ ms: number;
275
+ samples: number;
276
+ }): void;
277
+ onStrokeEnd(info: Parameters<WeaveBrushTraceSink['onStrokeEnd']>[0]): void;
278
+ private markerRadius;
279
+ private redraw;
280
+ }
281
+ //#endregion
282
+ //#region src/plugins/brush-lab/constants.d.ts
283
+ declare const BRUSH_LAB_LAYER_ID = "brushLabLayer";
284
+ declare const BRUSH_LAB_METRICS_EVENT = "onBrushLabMetrics";
285
+ /** Strokes kept in memory for ghost comparison. */
286
+ declare const BRUSH_LAB_DEFAULT_MAX_GHOSTS = 5;
287
+ //#endregion
288
+ export { BRUSH_LAB_DEFAULT_MAX_GHOSTS, BRUSH_LAB_LAYER_ID, BRUSH_LAB_METRICS_EVENT, BRUSH_LAB_PLUGIN_NAME, type LabGesture, type LabGestureEvent, type LabPoint, type LabPressurePoint, type LabRecordedSample, type LabRecording, type WeaveBrushLabCompareResult, type WeaveBrushLabDeviceReport, type WeaveBrushLabMetrics, type WeaveBrushLabOverlays, WeaveBrushLabPlugin, type WeaveBrushLabWarning };
289
+ //# sourceMappingURL=lab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lab.d.ts","names":[],"sources":["../src/actions/brush-tool/constants.ts","../src/actions/brush-tool/types.ts","../src/plugins/brush-lab/types.ts","../src/plugins/brush-lab/brush-lab.ts","../src/plugins/brush-lab/constants.ts"],"mappings":";;;;cASa;;;;KCKD;KAMA;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;KAGU;;EAEV;EACA;;EAEA;;EAEA;IAAW;IAAmB;;;EAE9B;;EAEA;;EAEA;;EAEA;;KAGU;EACV;;EAEA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;KAGU;EACV;;EAEA;;EAEA;;EAEA;;EAEA;;KAGU;;EAEV;;EAEA;;EAEA;;EAEA;;KAGU;EACV,SAAS;EACT,UAAU;EACV,YAAY;EACZ,UAAU;EACV,YAAY;;;;;;KAkEF;EACV;EACA,cAAc;IACZ,SAAS;IACT;IACA;IACA,eAAe;IACf;IACA;;EAEF,SAAS;IACP;MAAO;MAAW;;IAClB;MAAc;MAAW;;IACzB;IACA;IACA;;EAEF,QAAQ;IAAQ;IAAY;;EAC5B,YAAY;IACV;MAAkB;MAAW;MAAW;;IACxC;MAAe;MAAW;MAAW;;IACrC;IACA;;;;;KChLQ;EAAa;EAAW;;KACxB,mBAAmB;EAC7B;;EAEA;;;KAIU;EACV,KAAK;EACL,YAAY;EACZ;;EAEA;EACA;;;KAIU;EACV,SAAS;EACT;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;KAIU;EACV;EACA,iBAAiB;;EAEjB;;EAEA;EACA;IAAY;IAAa;;EACzB;EACA;EACA;EACA;EACA,UAAU;;KAGA;KAEA;EACV;EACA;EACA;EACA;;;KAIU;;EAEV;EACA,SAAS;;;KAIC;EAAe,QAAQ;;;KAGvB;EACV,YAAY;EACZ,SAAS;EACT;EACA;;;KAIU;EACV;EACA;EACA;;;;;;;;;;cCpCW,4BACH,uBACG;UAEH;UAMA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;EAEI,YAAA;IAAW;;EAMvB;EAIA;EAIA;EAIA,YAAY,MAAM;EAMlB;EAYA;EAIA;EAMA;;UAOQ;UAUA;UAoBA;UAsCA;UAcA;EAiBR,mBAAmB;EAInB,kBAAkB;EAIlB,eAAe;EAIf;EAMA,WAAW,YAAY,uBAAuB;EAO9C,aAAa;;;;;EASb,YAAY,qBAAqB;;EAwBjC;EAQA,cACE,MAAM,WAAW;EAkBnB,SAAS,QAAQ;EAiCjB,QAAQ;IAAQ;IAAY;;EAI5B,YAAY,MAAM,WAAW;UAsCrB;UAKA;;;;cCrYG;cACA;;cAEA"}