@geekybones/editor-kit 2.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/README.md +104 -0
- package/dist/editor-kit.js +8382 -0
- package/dist/editor-kit.js.map +1 -0
- package/dist/index.d.ts +742 -0
- package/package.json +88 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { Graphics } from 'pixi.js';
|
|
3
|
+
import { Mesh } from 'pixi.js';
|
|
4
|
+
import { MeshGeometry } from 'pixi.js';
|
|
5
|
+
import { Shader } from 'pixi.js';
|
|
6
|
+
import { Text as Text_3 } from 'pixi.js';
|
|
7
|
+
|
|
8
|
+
export declare type AlignmentAccessor = {
|
|
9
|
+
align(mode: AlignmentMode, ids?: readonly string[]): Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export declare type AlignmentMode = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom';
|
|
13
|
+
|
|
14
|
+
declare abstract class BaseElement<TOptions extends BaseOptions> {
|
|
15
|
+
protected options: TOptions;
|
|
16
|
+
protected displayObject: Container;
|
|
17
|
+
constructor(options: TOptions);
|
|
18
|
+
abstract init(): void | Promise<void>;
|
|
19
|
+
abstract update(next: Partial<TOptions>): void | Promise<void>;
|
|
20
|
+
abstract destroy(): void;
|
|
21
|
+
applyDefaultPosition(x: number, y: number): void;
|
|
22
|
+
getId(): string;
|
|
23
|
+
getType(): string;
|
|
24
|
+
getOptions(): TOptions;
|
|
25
|
+
getDisplayObject(): Container;
|
|
26
|
+
setZIndex(zIndex: number): void;
|
|
27
|
+
protected applyBaseTransform(): void;
|
|
28
|
+
protected centerPivot(): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare interface BaseOptions {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
type: string;
|
|
35
|
+
visible?: boolean;
|
|
36
|
+
selectable?: boolean;
|
|
37
|
+
x?: number;
|
|
38
|
+
y?: number;
|
|
39
|
+
rotationDeg?: number;
|
|
40
|
+
scaleX?: number;
|
|
41
|
+
scaleY?: number;
|
|
42
|
+
zIndex?: number;
|
|
43
|
+
custom?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare abstract class BaseTextElement<TOptions extends BaseTextOptions> extends BaseElement<TOptions> {
|
|
47
|
+
protected vectorState: VectorTextState | null;
|
|
48
|
+
protected standardTextNode: Text_3 | null;
|
|
49
|
+
protected backgroundNode: Graphics | null;
|
|
50
|
+
protected decorationNode: Graphics | null;
|
|
51
|
+
protected renderVersion: number;
|
|
52
|
+
protected destroyed: boolean;
|
|
53
|
+
protected initTextElement(): Promise<void>;
|
|
54
|
+
destroy(): void;
|
|
55
|
+
protected beforeDestroy(): void;
|
|
56
|
+
protected beforeInitialRender(): Promise<void>;
|
|
57
|
+
protected clearContent(): void;
|
|
58
|
+
protected refreshTextResolution(scaleX?: number, scaleY?: number): void;
|
|
59
|
+
protected dispatchUpdate(next: Partial<TOptions>): Promise<void>;
|
|
60
|
+
protected getResolvedFontSize(): number;
|
|
61
|
+
protected handleSpecializedUpdate(_next: Partial<TOptions>, _keys: string[]): Promise<boolean>;
|
|
62
|
+
protected afterOptionsAssigned(_next: Partial<TOptions>, _prevFontSize: number): void;
|
|
63
|
+
protected renderContent(): Promise<void>;
|
|
64
|
+
protected setStandardTextNode(textNode: Text_3): void;
|
|
65
|
+
protected renderDecorations(): void;
|
|
66
|
+
protected renderBackground(): void;
|
|
67
|
+
private clearBackgroundNode;
|
|
68
|
+
protected getContentBounds(): {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
width: number;
|
|
72
|
+
height: number;
|
|
73
|
+
};
|
|
74
|
+
protected getDecorationSegments(): Array<{
|
|
75
|
+
x: number;
|
|
76
|
+
width: number;
|
|
77
|
+
underlineY: number;
|
|
78
|
+
strikethroughY: number;
|
|
79
|
+
}>;
|
|
80
|
+
protected getDecorationThickness(fontSize?: number): number;
|
|
81
|
+
protected abstract renderStandardContent(): void;
|
|
82
|
+
protected abstract getVectorRenderOptions(): VectorTextRenderOptions | null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare interface BaseTextOptions extends BaseOptions, TextStyleOptions {
|
|
86
|
+
/**
|
|
87
|
+
* Used for vector text rendering (glyph outlines). Optional for standard raster text.
|
|
88
|
+
* If you enable vector effects and omit this, we fall back to a default font URL.
|
|
89
|
+
*/
|
|
90
|
+
fontUrl?: string;
|
|
91
|
+
effect?: TextEffectOptions;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export declare type CameraAccessor = {
|
|
95
|
+
getState(): CameraState;
|
|
96
|
+
setState(next: Partial<CameraState>): void;
|
|
97
|
+
setZoom(zoom: number, anchorX?: number, anchorY?: number): void;
|
|
98
|
+
screenToWorld(screenX: number, screenY: number): CameraPoint;
|
|
99
|
+
worldToScreen(worldX: number, worldY: number): CameraPoint;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export declare interface CameraConfig {
|
|
103
|
+
zoom?: number;
|
|
104
|
+
minZoom?: number;
|
|
105
|
+
maxZoom?: number;
|
|
106
|
+
zoomStep?: number;
|
|
107
|
+
wheelZoom?: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export declare type CameraPoint = {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
declare type CameraState = {
|
|
116
|
+
zoom: number;
|
|
117
|
+
x: number;
|
|
118
|
+
y: number;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
declare const Circle: "shape:circle";
|
|
122
|
+
|
|
123
|
+
export declare interface CircleOptions extends BaseOptions {
|
|
124
|
+
readonly type: 'shape:circle';
|
|
125
|
+
radius?: number;
|
|
126
|
+
width?: number;
|
|
127
|
+
height?: number;
|
|
128
|
+
fill?: number;
|
|
129
|
+
fillAlpha?: number;
|
|
130
|
+
stroke?: number;
|
|
131
|
+
strokeWidth?: number;
|
|
132
|
+
strokeAlpha?: number;
|
|
133
|
+
strokeAlign?: StrokeAlign;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare class CircleShape extends BaseElement<CircleOptions> {
|
|
137
|
+
private graphics;
|
|
138
|
+
init(): void;
|
|
139
|
+
update(next: Partial<CircleOptions>): void;
|
|
140
|
+
destroy(): void;
|
|
141
|
+
private draw;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare function clearVectorTemplateCache(): void;
|
|
145
|
+
|
|
146
|
+
export declare type ContextMenuAccessor = {
|
|
147
|
+
open(id: string, options: ContextMenuOpenOptions): void;
|
|
148
|
+
close(): void;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export declare interface ContextMenuAction {
|
|
152
|
+
delete: () => void;
|
|
153
|
+
duplicate: () => void;
|
|
154
|
+
bringToFront: () => void;
|
|
155
|
+
sendToBack: () => void;
|
|
156
|
+
bringForward: () => void;
|
|
157
|
+
sendBackward: () => void;
|
|
158
|
+
normalizeZIndex: () => void;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export declare interface ContextMenuConfig {
|
|
162
|
+
onElement?: (ctx: ContextMenuEvent) => void;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export declare interface ContextMenuEvent {
|
|
166
|
+
selected: SerializedElement[];
|
|
167
|
+
position: ContextMenuPosition;
|
|
168
|
+
originalEvent: MouseEvent;
|
|
169
|
+
actions: ContextMenuAction;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export declare interface ContextMenuOpenOptions {
|
|
173
|
+
position: ContextMenuPosition;
|
|
174
|
+
originalEvent?: MouseEvent;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export declare interface ContextMenuPosition {
|
|
178
|
+
x: number;
|
|
179
|
+
y: number;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export declare interface ControlConfig {
|
|
183
|
+
icon?: string;
|
|
184
|
+
handler: HandlerType;
|
|
185
|
+
size?: number;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare function create(options: ImageOptions): ImageElement;
|
|
189
|
+
|
|
190
|
+
declare function create_2(type: typeof Rectangle, options: RectangleOptions): RectangleShape;
|
|
191
|
+
|
|
192
|
+
declare function create_2(type: typeof Circle, options: CircleOptions): CircleShape;
|
|
193
|
+
|
|
194
|
+
declare function create_2(type: typeof Star, options: StarOptions): StarShape;
|
|
195
|
+
|
|
196
|
+
declare function create_2(type: typeof Line, options: LineOptions): LineShape;
|
|
197
|
+
|
|
198
|
+
export declare type EditorEvent = {
|
|
199
|
+
'element:added': [id: string];
|
|
200
|
+
'element:removed': [id: string];
|
|
201
|
+
'element:updated': [id: string];
|
|
202
|
+
'element:selected': [ids: string | readonly string[] | null];
|
|
203
|
+
'history:changed': [];
|
|
204
|
+
'layer:changed': [];
|
|
205
|
+
'camera:changed': [state: CameraState];
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export declare class EditorKit {
|
|
209
|
+
readonly ready: Promise<void>;
|
|
210
|
+
readonly history: HistoryAccessor;
|
|
211
|
+
readonly alignment: AlignmentAccessor;
|
|
212
|
+
readonly layer: LayeringAccessor;
|
|
213
|
+
readonly interaction: InteractionAccessor;
|
|
214
|
+
readonly camera: CameraAccessor;
|
|
215
|
+
readonly contextMenu: ContextMenuAccessor;
|
|
216
|
+
readonly export: ExportAccessor;
|
|
217
|
+
readonly fonts: FontsAccessor;
|
|
218
|
+
readonly grid: GridAccessor;
|
|
219
|
+
readonly performance: PerformanceAccessor;
|
|
220
|
+
readonly serializer: SerializerAccessor;
|
|
221
|
+
readonly snap: SnapAccessor;
|
|
222
|
+
private readonly app;
|
|
223
|
+
private readonly registry;
|
|
224
|
+
private readonly events;
|
|
225
|
+
private readonly editorOptions;
|
|
226
|
+
private readonly extensions;
|
|
227
|
+
private ctx;
|
|
228
|
+
private destroyed;
|
|
229
|
+
constructor(container: HTMLElement, options?: EditorKitOptions);
|
|
230
|
+
private initExtensions;
|
|
231
|
+
private buildContext;
|
|
232
|
+
private addElement;
|
|
233
|
+
private removeElement;
|
|
234
|
+
private updateElement;
|
|
235
|
+
private shouldConstrainAfterUpdate;
|
|
236
|
+
private getUpdateKind;
|
|
237
|
+
private getHistoryManager;
|
|
238
|
+
private getSerializationManager;
|
|
239
|
+
private getActionsContext;
|
|
240
|
+
add(element: BaseElement<BaseOptions>): Promise<void>;
|
|
241
|
+
remove(id: string): Promise<void>;
|
|
242
|
+
update(id: string, next: Partial<BaseOptions>): Promise<void>;
|
|
243
|
+
clear(): void;
|
|
244
|
+
get(id: string, raw?: false): SerializedElement | undefined;
|
|
245
|
+
get(id: string, raw: true): BaseElement<BaseOptions> | undefined;
|
|
246
|
+
getExtension<T>(name: string): T | undefined;
|
|
247
|
+
on<K extends keyof EditorEvent>(event: K, listener: (...args: EditorEvent[K]) => void): this;
|
|
248
|
+
off<K extends keyof EditorEvent>(event: K, listener: (...args: EditorEvent[K]) => void): this;
|
|
249
|
+
destroy(): void;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export declare interface EditorKitOptions {
|
|
253
|
+
width?: number;
|
|
254
|
+
height?: number;
|
|
255
|
+
backgroundColor?: string;
|
|
256
|
+
constrainToCanvas?: boolean;
|
|
257
|
+
extensions?: ExtensionsConfig;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
declare type ElementFactory = (options: BaseOptions) => BaseElement<BaseOptions>;
|
|
261
|
+
|
|
262
|
+
export declare type ElementOptions = TextOptions | ImageOptions | ShapeOptions | SVGOptions;
|
|
263
|
+
|
|
264
|
+
export declare type ElementPatch = Partial<ElementOptions>;
|
|
265
|
+
|
|
266
|
+
export declare type ElementType = ElementOptions['type'];
|
|
267
|
+
|
|
268
|
+
export declare type ExportAccessor = {
|
|
269
|
+
render(format: 'png' | 'base64', options?: ExportOptions): Promise<Blob | string>;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export declare type ExportMode = 'content' | 'viewport';
|
|
273
|
+
|
|
274
|
+
export declare type ExportOptions = {
|
|
275
|
+
mode?: ExportMode;
|
|
276
|
+
margin?: number;
|
|
277
|
+
quality?: ExportQuality;
|
|
278
|
+
resolution?: number;
|
|
279
|
+
antialias?: boolean;
|
|
280
|
+
backgroundColor?: string;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export declare type ExportQuality = 'standard' | 'hd' | 'ultra';
|
|
284
|
+
|
|
285
|
+
export declare interface ExtensionsConfig {
|
|
286
|
+
alignment?: boolean;
|
|
287
|
+
history?: boolean | HistoryConfig;
|
|
288
|
+
interaction?: boolean | InteractionConfig;
|
|
289
|
+
layering?: boolean;
|
|
290
|
+
serialization?: boolean;
|
|
291
|
+
export?: boolean;
|
|
292
|
+
fonts?: boolean;
|
|
293
|
+
performance?: boolean;
|
|
294
|
+
contextMenu?: boolean | ContextMenuConfig;
|
|
295
|
+
grid?: boolean | GridConfig;
|
|
296
|
+
snap?: boolean | SnapConfig;
|
|
297
|
+
camera?: boolean | CameraConfig;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export declare type FontsAccessor = {
|
|
301
|
+
load(family: string, url: string): Promise<void>;
|
|
302
|
+
isLoaded(family: string): boolean;
|
|
303
|
+
getLoadedFonts(): readonly string[];
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
declare function getMeshEffect(name: string): MeshEffectEntry | undefined;
|
|
307
|
+
|
|
308
|
+
export declare type GridAccessor = {
|
|
309
|
+
setVisible(visible: boolean): void;
|
|
310
|
+
isVisible(): boolean;
|
|
311
|
+
getState(): GridState;
|
|
312
|
+
setCellSize(size: number): void;
|
|
313
|
+
setMajorInterval(interval: number): void;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export declare interface GridConfig {
|
|
317
|
+
cellSize?: number;
|
|
318
|
+
majorInterval?: number;
|
|
319
|
+
visible?: boolean;
|
|
320
|
+
minorLineColor?: number;
|
|
321
|
+
minorLineAlpha?: number;
|
|
322
|
+
majorLineColor?: number;
|
|
323
|
+
majorLineAlpha?: number;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export declare type GridState = {
|
|
327
|
+
cellSize: number;
|
|
328
|
+
majorInterval: number;
|
|
329
|
+
visible: boolean;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
export declare interface Guide {
|
|
333
|
+
id: string;
|
|
334
|
+
orientation: 'vertical' | 'horizontal';
|
|
335
|
+
position: number;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
declare type HandlePosition = 'tl' | 'tc' | 'tr' | 'lc' | 'rc' | 'bl' | 'bc' | 'br' | 'top' | 'btop';
|
|
339
|
+
|
|
340
|
+
export declare type HandlerType = 'transform' | 'rotate' | 'delete' | 'duplicate' | ((ctx: InteractionHandlerContext) => void);
|
|
341
|
+
|
|
342
|
+
export declare type HistoryAccessor = {
|
|
343
|
+
undo(): Promise<void>;
|
|
344
|
+
redo(): Promise<void>;
|
|
345
|
+
canUndo(): boolean;
|
|
346
|
+
canRedo(): boolean;
|
|
347
|
+
setClipboard(items: BaseOptions[]): void;
|
|
348
|
+
getClipboard(): BaseOptions[];
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
export declare interface HistoryConfig {
|
|
352
|
+
max?: number;
|
|
353
|
+
track?: HistoryTrack[];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export declare type HistoryTrack = 'move' | 'resize' | 'rotate' | 'add' | 'remove' | 'zOrder' | 'align' | 'text';
|
|
357
|
+
|
|
358
|
+
declare const Image_2: {
|
|
359
|
+
readonly create: typeof create;
|
|
360
|
+
readonly factories: Record<string, ElementFactory>;
|
|
361
|
+
};
|
|
362
|
+
export { Image_2 as Image }
|
|
363
|
+
|
|
364
|
+
declare class ImageElement extends BaseElement<ImageOptions> {
|
|
365
|
+
private sprite;
|
|
366
|
+
init(): Promise<void>;
|
|
367
|
+
update(next: Partial<ImageOptions>): Promise<void>;
|
|
368
|
+
destroy(): void;
|
|
369
|
+
private loadSprite;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export declare interface ImageOptions extends BaseOptions {
|
|
373
|
+
readonly type: 'image';
|
|
374
|
+
src: string;
|
|
375
|
+
width?: number;
|
|
376
|
+
height?: number;
|
|
377
|
+
tint?: number | string;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export declare type InteractionAccessor = {
|
|
381
|
+
select(idOrIds: string | readonly string[] | null): void;
|
|
382
|
+
duplicate(): Promise<void>;
|
|
383
|
+
getSelectedIds(): string[];
|
|
384
|
+
getSelectedOptions(): BaseOptions[];
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
export declare interface InteractionConfig {
|
|
388
|
+
controls?: Partial<Record<HandlePosition, ControlConfig>>;
|
|
389
|
+
theme?: InteractionTheme;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export declare interface InteractionHandlerContext {
|
|
393
|
+
selectedIds: readonly string[];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export declare interface InteractionTheme {
|
|
397
|
+
boundingBox?: {
|
|
398
|
+
lineColor?: number | string;
|
|
399
|
+
lineThickness?: number;
|
|
400
|
+
lineType?: 'solid' | 'dotted';
|
|
401
|
+
padding?: number;
|
|
402
|
+
};
|
|
403
|
+
handle?: {
|
|
404
|
+
size?: number;
|
|
405
|
+
color?: number | string;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export declare type LayeringAccessor = {
|
|
410
|
+
bringToFront(id: string | readonly string[]): void;
|
|
411
|
+
sendToBack(id: string | readonly string[]): void;
|
|
412
|
+
bringForward(id: string): void;
|
|
413
|
+
sendBackward(id: string): void;
|
|
414
|
+
normalizeZIndex(): void;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
declare const Line: "shape:line";
|
|
418
|
+
|
|
419
|
+
export declare interface LineOptions extends BaseOptions {
|
|
420
|
+
readonly type: 'shape:line';
|
|
421
|
+
width: number;
|
|
422
|
+
stroke?: number;
|
|
423
|
+
strokeWidth?: number;
|
|
424
|
+
strokeAlpha?: number;
|
|
425
|
+
strokeAlign?: StrokeAlign;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
declare class LineShape extends BaseElement<LineOptions> {
|
|
429
|
+
private graphics;
|
|
430
|
+
init(): void;
|
|
431
|
+
update(next: Partial<LineOptions>): void;
|
|
432
|
+
destroy(): void;
|
|
433
|
+
private draw;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
declare function listMeshEffects(): string[];
|
|
437
|
+
|
|
438
|
+
declare interface MeshEffectColumn {
|
|
439
|
+
dy: number;
|
|
440
|
+
scaleY?: number;
|
|
441
|
+
anchorY?: number;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
declare interface MeshEffectEntry {
|
|
445
|
+
fn: MeshEffectFunction;
|
|
446
|
+
columns: number;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
declare interface MeshEffectFnContext {
|
|
450
|
+
textureWidth: number;
|
|
451
|
+
textureHeight: number;
|
|
452
|
+
fontSize: number;
|
|
453
|
+
radius: number;
|
|
454
|
+
intensity: number;
|
|
455
|
+
direction: 'up' | 'down';
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
declare type MeshEffectFunction = (t: number, ctx: MeshEffectFnContext) => MeshEffectColumn;
|
|
459
|
+
|
|
460
|
+
export declare type PerformanceAccessor = {
|
|
461
|
+
markDirty(id: string): void;
|
|
462
|
+
isDirty(id: string): boolean;
|
|
463
|
+
flushDirty(): readonly string[];
|
|
464
|
+
clearDirty(): void;
|
|
465
|
+
retainAsset(url: string): void;
|
|
466
|
+
releaseAsset(url: string): Promise<void>;
|
|
467
|
+
clearAssets(): Promise<void>;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
declare const Rectangle: "shape:rectangle";
|
|
471
|
+
|
|
472
|
+
export declare interface RectangleOptions extends BaseOptions {
|
|
473
|
+
readonly type: 'shape:rectangle';
|
|
474
|
+
width: number;
|
|
475
|
+
height: number;
|
|
476
|
+
fill?: number;
|
|
477
|
+
fillAlpha?: number;
|
|
478
|
+
stroke?: number;
|
|
479
|
+
strokeWidth?: number;
|
|
480
|
+
strokeAlpha?: number;
|
|
481
|
+
strokeAlign?: StrokeAlign;
|
|
482
|
+
borderRadius?: number;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
declare class RectangleShape extends BaseElement<RectangleOptions> {
|
|
486
|
+
private graphics;
|
|
487
|
+
init(): void;
|
|
488
|
+
update(next: Partial<RectangleOptions>): void;
|
|
489
|
+
destroy(): void;
|
|
490
|
+
private draw;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
declare function register(type: string, factory: ElementFactory): void;
|
|
494
|
+
|
|
495
|
+
declare interface RegisterMeshEffectOptions {
|
|
496
|
+
columns?: number;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
declare interface ResolveOptions {
|
|
500
|
+
width?: number;
|
|
501
|
+
height?: number;
|
|
502
|
+
exclude?: string[];
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export declare interface SerializationAdapter<T extends BaseOptions = BaseOptions> {
|
|
506
|
+
readonly type: string;
|
|
507
|
+
serialize(element: BaseElement<T>): T;
|
|
508
|
+
deserialize(data: T): BaseElement<T>;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export declare type SerializedElement = Record<string, unknown> & {
|
|
512
|
+
id: string;
|
|
513
|
+
type: string;
|
|
514
|
+
} & ElementPatch;
|
|
515
|
+
|
|
516
|
+
export declare type SerializerAccessor = {
|
|
517
|
+
serialize(): SerializedElement[];
|
|
518
|
+
append(data: SerializedElement[]): Promise<void>;
|
|
519
|
+
replace(data: SerializedElement[]): Promise<void>;
|
|
520
|
+
serializeElement(element: BaseElement<BaseOptions>): SerializedElement;
|
|
521
|
+
registerAdapter<T extends BaseOptions>(adapter: SerializationAdapter<T>): void;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
export declare const Shape: {
|
|
525
|
+
readonly Rectangle: "shape:rectangle";
|
|
526
|
+
readonly Circle: "shape:circle";
|
|
527
|
+
readonly Star: "shape:star";
|
|
528
|
+
readonly Line: "shape:line";
|
|
529
|
+
readonly create: typeof create_2;
|
|
530
|
+
readonly register: typeof register;
|
|
531
|
+
readonly factories: ReadonlyMap<string, ElementFactory>;
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
export declare type ShapeOptions = RectangleOptions | CircleOptions | StarOptions | LineOptions;
|
|
535
|
+
|
|
536
|
+
export declare type SnapAccessor = {
|
|
537
|
+
resolve(x: number, y: number, opts?: ResolveOptions): SnapResult;
|
|
538
|
+
showLines(result: SnapResult): void;
|
|
539
|
+
hideLines(): void;
|
|
540
|
+
addGuide(guide: Guide): void;
|
|
541
|
+
removeGuide(id: string): void;
|
|
542
|
+
clearGuides(): void;
|
|
543
|
+
configure(patch: Partial<SnapConfig>): void;
|
|
544
|
+
getState(): SnapState;
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
export declare interface SnapConfig {
|
|
548
|
+
grid?: boolean;
|
|
549
|
+
objects?: boolean;
|
|
550
|
+
edges?: boolean;
|
|
551
|
+
guides?: boolean;
|
|
552
|
+
threshold?: number;
|
|
553
|
+
lineColor?: number | string;
|
|
554
|
+
lineAlpha?: number;
|
|
555
|
+
lineWidth?: number;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export declare interface SnapLineStyle {
|
|
559
|
+
color: number | string;
|
|
560
|
+
alpha: number;
|
|
561
|
+
width: number;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
export declare interface SnapResult {
|
|
565
|
+
x: number;
|
|
566
|
+
y: number;
|
|
567
|
+
snapped: boolean;
|
|
568
|
+
xSnapped: boolean;
|
|
569
|
+
ySnapped: boolean;
|
|
570
|
+
lineX?: number;
|
|
571
|
+
lineY?: number;
|
|
572
|
+
xTarget?: SnapTarget;
|
|
573
|
+
yTarget?: SnapTarget;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export declare interface SnapState {
|
|
577
|
+
config: Required<SnapConfig>;
|
|
578
|
+
guides: Guide[];
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export declare interface SnapTarget {
|
|
582
|
+
type: 'grid' | 'object' | 'edge' | 'guide';
|
|
583
|
+
reference?: string;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
declare type StandardTextOptions = BaseTextOptions & {
|
|
587
|
+
renderMode?: 'standard';
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
declare const Star: "shape:star";
|
|
591
|
+
|
|
592
|
+
export declare interface StarOptions extends BaseOptions {
|
|
593
|
+
readonly type: 'shape:star';
|
|
594
|
+
points: number;
|
|
595
|
+
width: number;
|
|
596
|
+
height: number;
|
|
597
|
+
fill?: number;
|
|
598
|
+
fillAlpha?: number;
|
|
599
|
+
stroke?: number;
|
|
600
|
+
strokeWidth?: number;
|
|
601
|
+
strokeAlpha?: number;
|
|
602
|
+
strokeAlign?: StrokeAlign;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
declare class StarShape extends BaseElement<StarOptions> {
|
|
606
|
+
private graphics;
|
|
607
|
+
init(): void;
|
|
608
|
+
update(next: Partial<StarOptions>): void;
|
|
609
|
+
destroy(): void;
|
|
610
|
+
private draw;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
declare type StrokeAlign = 'inside' | 'center' | 'outside';
|
|
614
|
+
|
|
615
|
+
declare class SVGElement_2 extends BaseElement<SVGOptions> {
|
|
616
|
+
private sprite;
|
|
617
|
+
private blobUrl;
|
|
618
|
+
init(): Promise<void>;
|
|
619
|
+
update(next: Partial<SVGOptions>): Promise<void>;
|
|
620
|
+
destroy(): void;
|
|
621
|
+
private loadSVG;
|
|
622
|
+
private svgStringToUrl;
|
|
623
|
+
private loadImage;
|
|
624
|
+
}
|
|
625
|
+
export { SVGElement_2 as SVGElement }
|
|
626
|
+
|
|
627
|
+
export declare interface SVGOptions extends BaseOptions {
|
|
628
|
+
readonly type: 'svg';
|
|
629
|
+
src: string;
|
|
630
|
+
width?: number;
|
|
631
|
+
height?: number;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
declare namespace Text_2 {
|
|
635
|
+
const Type: "text";
|
|
636
|
+
function create(options: TextOptions): TextElement;
|
|
637
|
+
function create(type: string, options: BaseOptions): BaseElement<BaseOptions>;
|
|
638
|
+
function registerEffect(name: string, fn: MeshEffectFunction, options?: RegisterMeshEffectOptions): void;
|
|
639
|
+
const getEffect: typeof getMeshEffect;
|
|
640
|
+
const listEffects: typeof listMeshEffects;
|
|
641
|
+
const clearEffectCache: typeof clearVectorTemplateCache;
|
|
642
|
+
const factories: Record<string, ElementFactory>;
|
|
643
|
+
}
|
|
644
|
+
export { Text_2 as Text }
|
|
645
|
+
|
|
646
|
+
declare type TextAlign = 'left' | 'center' | 'right' | 'justify';
|
|
647
|
+
|
|
648
|
+
declare interface TextDecorationSegment {
|
|
649
|
+
x: number;
|
|
650
|
+
width: number;
|
|
651
|
+
underlineY: number;
|
|
652
|
+
strikethroughY: number;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
declare type TextEffect = 'Normal' | 'Curved' | 'Arch' | 'Bridge' | 'Valley' | 'Pinch' | 'Perspective' | 'Pointed' | 'Bulge' | 'Downward' | 'Upward' | 'Cone';
|
|
656
|
+
|
|
657
|
+
declare interface TextEffectOptions {
|
|
658
|
+
type: TextEffect;
|
|
659
|
+
intensity?: number;
|
|
660
|
+
direction?: 'up' | 'down';
|
|
661
|
+
radius?: number;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
declare class TextElement extends BaseTextElement<TextOptions> {
|
|
665
|
+
init(): Promise<void>;
|
|
666
|
+
update(next: Partial<TextOptions>): Promise<void>;
|
|
667
|
+
protected renderStandardContent(): void;
|
|
668
|
+
protected getVectorRenderOptions(): VectorTextRenderOptions | null;
|
|
669
|
+
protected getDecorationSegments(): Array<{
|
|
670
|
+
x: number;
|
|
671
|
+
width: number;
|
|
672
|
+
underlineY: number;
|
|
673
|
+
strikethroughY: number;
|
|
674
|
+
}>;
|
|
675
|
+
private getAlignedOffsetX;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
export declare type TextOptions = (StandardTextOptions | VectorTextOptions) & {
|
|
679
|
+
readonly type: 'text';
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
declare type TextStrokeAlign = 'inside' | 'center' | 'outside';
|
|
683
|
+
|
|
684
|
+
declare interface TextStyleOptions {
|
|
685
|
+
text: string;
|
|
686
|
+
fontFamily?: string;
|
|
687
|
+
fontSize?: number;
|
|
688
|
+
fill?: number | string;
|
|
689
|
+
background?: number | string;
|
|
690
|
+
backgroundAlpha?: number;
|
|
691
|
+
backgroundPadding?: number;
|
|
692
|
+
stroke?: number | string;
|
|
693
|
+
strokeWidth?: number;
|
|
694
|
+
strokeAlpha?: number;
|
|
695
|
+
strokeAlign?: TextStrokeAlign;
|
|
696
|
+
fontWeight?: string;
|
|
697
|
+
fontStyle?: string;
|
|
698
|
+
underline?: boolean;
|
|
699
|
+
strikethrough?: boolean;
|
|
700
|
+
letterSpacing?: number;
|
|
701
|
+
align?: TextAlign;
|
|
702
|
+
lineHeight?: number;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
declare interface VectorTextLayer {
|
|
706
|
+
geometry: MeshGeometry;
|
|
707
|
+
mesh: Mesh;
|
|
708
|
+
shader: Shader;
|
|
709
|
+
originalPositions: Float32Array;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
declare type VectorTextOptions = BaseTextOptions & {
|
|
713
|
+
renderMode: 'vector';
|
|
714
|
+
fontUrl: string;
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
declare interface VectorTextRenderOptions extends Omit<TextStyleOptions, 'fontSize' | 'fill' | 'letterSpacing'> {
|
|
718
|
+
fontUrl: string;
|
|
719
|
+
fontSize: number;
|
|
720
|
+
fill: number | string;
|
|
721
|
+
letterSpacing: number;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
declare interface VectorTextState {
|
|
725
|
+
template: VectorTextTemplate;
|
|
726
|
+
fillLayer: VectorTextLayer;
|
|
727
|
+
strokeLayers: VectorTextLayer[];
|
|
728
|
+
decorationLayers: VectorTextLayer[];
|
|
729
|
+
columns: number;
|
|
730
|
+
textureWidth: number;
|
|
731
|
+
textureHeight: number;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
declare interface VectorTextTemplate {
|
|
735
|
+
positions: Float32Array;
|
|
736
|
+
indices: Uint32Array;
|
|
737
|
+
decorationSegments: TextDecorationSegment[];
|
|
738
|
+
textureWidth: number;
|
|
739
|
+
textureHeight: number;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
export { }
|