-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.d.ts
More file actions
563 lines (500 loc) · 14.2 KB
/
Copy pathindex.d.ts
File metadata and controls
563 lines (500 loc) · 14.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
import type {
ContourId,
PointId,
AnchorId,
AxisId,
AxisLabelId,
AxisMappingId,
ComponentId,
GuidelineId,
GlyphId,
GlyphName,
LayerId,
NamedInstanceId,
SourceId,
Unicode,
} from "@shift/types";
export declare class Bridge {
constructor()
createUntitledWorkspace(storePath: string, options?: NapiNewWorkspace | undefined | null): void
exportWorkspace(request: NapiFontExportRequest): Promise<NapiFontExportResult>
documentState(): NapiDocumentState
inspectPackage(path: string): NapiPackageIdentity
inspectPackageDraft(storePath: string): NapiPackageDraft
closeWorkspace(): void
openWorkspace(path: string, storePath: string): void
resumeWorkspaceForSource(storePath: string, sourcePath: string): void
setDocumentId(documentId: string): NapiDocumentState
saveWorkspace(): NapiDocumentState
saveWorkspaceAs(path: string): NapiDocumentState
getMetadata(): NapiFontMetadata
getMetrics(): NapiFontMetrics
getGlyphs(): Array<NapiGlyphRecord>
/**
* Applies one intent set as a single atomic workspace apply: every kind
* — editing and create alike — decodes through `map_intent` into one
* `FontWorkspace::apply` call. One call = one SQLite transaction = one
* undo step, however many intents the set batches.
*/
apply(intents: Array<NapiFontIntent>, label?: string | undefined | null): NapiAppliedChange
/**
* Replays the most recent ledger entry's pre states; `null` when the
* undo stack is empty.
*/
undo(): NapiAppliedChange | null
/**
* Replays the most recent undone entry's post states; `null` when the
* redo stack is empty.
*/
redo(): NapiAppliedChange | null
/** Glyph-addressed snapshots for renderer-local synchronous font state. */
getGlyphSnapshots(requests: Array<NapiGlyphSnapshotRequest>): Array<NapiGlyphSnapshot>
isVariable(): boolean
getAxes(): Array<NapiAxis>
getAxisMappings(): Array<NapiAxisMapping>
getNamedInstances(): Array<NapiNamedInstance>
mapLocation(location: NapiLocation): NapiLocation
getSources(): Array<NapiSource>
}
export interface NapiDocumentState {
sourceKind: string
saveTarget?: string
dirty: boolean
needsSaveAs: boolean
}
export interface NapiFontExportRequest {
path: string
format: string
}
export interface NapiFontExportResult {
path: string
format: string
}
export interface NapiNewWorkspace {
familyName?: string
unitsPerEm?: number
}
export interface NapiPackageDraft {
documentId?: string
packageId: string
sourcePath: string
baseFingerprint: string
dirty: boolean
}
export interface NapiPackageIdentity {
packageId: string
canonicalPath: string
fingerprint: string
}
export interface NapiAddAnchorsIntent {
layerId: LayerId
anchors: Array<NapiAnchorSeed>
}
export interface NapiAddContourIntent {
layerId: LayerId
contourId: ContourId
closed: boolean
}
export interface NapiAddPointsIntent {
layerId: LayerId
/** Absent when `before` carries the anchor; Rust derives the contour. */
contourId?: ContourId
/** Insert before this point; append when absent. */
before?: PointId
points: Array<NapiPointSeed>
}
export interface NapiAnchorData {
id: AnchorId
name?: string
}
/**
* An anchor to create, carrying its caller-minted id (decision 6: ids are
* client-minted so verbs return identity synchronously).
*/
export interface NapiAnchorSeed {
id: AnchorId
name?: string
x: number
y: number
}
/** Pure-state response to `apply`: no change records cross to the renderer. */
export interface NapiAppliedChange {
layers: Array<NapiLayerReplaced>
/** Present when the apply produced any font-level replacement collections. */
next?: NapiFontReplacement
/** Stable ids: references survive renames without re-indexing. */
dependents: Array<GlyphId>
}
export interface NapiAxis {
id: AxisId
tag: string
name: string
role: NapiAxisRole
axisType: NapiAxisType
minimum?: number
default: number
maximum?: number
values?: Array<number>
labels: Array<NapiAxisLabel>
hidden: boolean
}
export interface NapiAxisLabel {
id: AxisLabelId
name: string
value: number
minimum?: number
maximum?: number
linkedValue?: number
elidable: boolean
}
export interface NapiAxisMapping {
id: AxisMappingId
name: string
description?: string
inputs: Array<AxisId>
outputs: Array<AxisId>
points: Array<NapiAxisMappingPoint>
}
export interface NapiAxisMappingPoint {
description?: string
input: NapiLocation
output: NapiLocation
}
export declare const enum NapiAxisRole {
External = 'external',
Internal = 'internal'
}
export interface NapiAxisTent {
axisTag: string
lower: number
peak: number
upper: number
}
export declare const enum NapiAxisType {
Continuous = 'continuous',
Discrete = 'discrete'
}
export interface NapiBooleanOpIntent {
layerId: LayerId
contourIdA: ContourId
contourIdB: ContourId
/** "union" | "subtract" | "intersect" | "difference" */
operation: string
}
/** Creates one glyph layer by copying another layer's shape with fresh internal ids. */
export interface NapiCloneGlyphLayerIntent {
layerId: LayerId
glyphId: GlyphId
sourceId: SourceId
fromLayerId: LayerId
}
export interface NapiComponentData {
id: ComponentId
baseGlyphId: GlyphId
baseGlyphName: GlyphName
}
export interface NapiContourData {
id: ContourId
points: Array<NapiPointData>
closed: boolean
}
/**
* Font-level axis creation. The axis id is client-minted; the tag is an
* OpenType label and must be unique within the font.
*/
export interface NapiCreateAxisIntent {
axis: NapiAxis
}
/**
* Font-level glyph creation. The glyph id is client-minted (decision 6:
* verbs return identity synchronously); Rust honors it and rejects
* duplicates.
*/
export interface NapiCreateGlyphIntent {
glyphId: GlyphId
name: GlyphName
unicodes: Array<Unicode>
}
/** Creates one sparse glyph layer at an existing source for an existing glyph. */
export interface NapiCreateGlyphLayerIntent {
layerId: LayerId
glyphId: GlyphId
sourceId: SourceId
}
/** Creates an authored named instance with client-minted stable identity. */
export interface NapiCreateNamedInstanceIntent {
instance: NapiNamedInstance
}
/**
* Font-level source creation. The source id is client-minted so verbs can
* return identity synchronously; Rust honors it and rejects duplicates.
*/
export interface NapiCreateSourceIntent {
sourceId: SourceId
name: string
/** Axis id → design-space value for the new source. */
location: NapiLocation
}
/** Font-level axis deletion. Removing an axis also reshapes source locations. */
export interface NapiDeleteAxisIntent {
axisId: AxisId
}
/** Deletes an authored named instance without changing sources or geometry. */
export interface NapiDeleteNamedInstanceIntent {
instanceId: NamedInstanceId
}
/** Font-level source deletion. Removing a source also removes its glyph layers. */
export interface NapiDeleteSourceIntent {
sourceId: SourceId
}
/**
* CS0 walking-skeleton intent. A stringly union covering exactly the two
* skeleton kinds; CS1 replaces this with per-variant intent structs.
*/
export interface NapiFontIntent {
/**
* Discriminator naming the populated payload field. Editing kinds:
* "addPoints" | "addContour" | "setContourClosed" | "movePoints" |
* "setPointSmooth" | "removePoints" | "addAnchors" | "moveAnchors" |
* "removeAnchors" | "reverseContour" | "translatePoints" |
* "setXAdvance" | "applyBooleanOp".
* Font-level kinds additionally include "createAxis", "updateAxis",
* "deleteAxis", "setAxisMappings", named-instance create/update/delete,
* source create/delete, and glyph or layer creation. Every kind shares the
* same apply path; one set is one undo step.
*/
kind: string
addPoints?: NapiAddPointsIntent
addContour?: NapiAddContourIntent
setContourClosed?: NapiSetContourClosedIntent
movePoints?: NapiMovePointsIntent
setPointSmooth?: NapiSetPointSmoothIntent
removePoints?: NapiRemovePointsIntent
addAnchors?: NapiAddAnchorsIntent
moveAnchors?: NapiMoveAnchorsIntent
removeAnchors?: NapiRemoveAnchorsIntent
reverseContour?: NapiReverseContourIntent
translatePoints?: NapiTranslatePointsIntent
setXAdvance?: NapiSetXAdvanceIntent
applyBooleanOp?: NapiBooleanOpIntent
createGlyph?: NapiCreateGlyphIntent
updateGlyph?: NapiUpdateGlyphIntent
createAxis?: NapiCreateAxisIntent
updateAxis?: NapiUpdateAxisIntent
deleteAxis?: NapiDeleteAxisIntent
setAxisMappings?: NapiSetAxisMappingsIntent
createNamedInstance?: NapiCreateNamedInstanceIntent
updateNamedInstance?: NapiUpdateNamedInstanceIntent
deleteNamedInstance?: NapiDeleteNamedInstanceIntent
createSource?: NapiCreateSourceIntent
deleteSource?: NapiDeleteSourceIntent
createGlyphLayer?: NapiCreateGlyphLayerIntent
cloneGlyphLayer?: NapiCloneGlyphLayerIntent
}
export interface NapiFontMetadata {
familyName?: string
styleName?: string
versionMajor?: number
versionMinor?: number
copyright?: string
trademark?: string
designer?: string
designerUrl?: string
manufacturer?: string
manufacturerUrl?: string
license?: string
licenseUrl?: string
description?: string
note?: string
}
export interface NapiFontMetrics {
unitsPerEm: number
ascender: number
descender: number
capHeight?: number
xHeight?: number
lineGap?: number
italicAngle?: number
underlinePosition?: number
underlineThickness?: number
}
/**
* Selective replacement-grade font collections produced by one apply.
*
* Every present collection is complete. An absent collection was untouched;
* it must be retained from the renderer's current workspace snapshot.
*/
export interface NapiFontReplacement {
/** Full records list when glyph identity changed; absent when untouched. */
glyphs?: Array<NapiGlyphRecord>
/** Full axes list when font-level axis structure changed; absent otherwise. */
axes?: Array<NapiAxis>
/** Full mapping list when font-level axis mappings changed; absent otherwise. */
axisMappings?: Array<NapiAxisMapping>
/** Full authored product-preset list when named instances changed. */
namedInstances?: Array<NapiNamedInstance>
/**
* Full sources list when font-level source structure changed (createAxis
* reshapes locations, createSource adds one); absent otherwise.
*/
sources?: Array<NapiSource>
}
export interface NapiGlyphChangedEntities {
pointIds: Array<PointId>
contourIds: Array<ContourId>
anchorIds: Array<AnchorId>
guidelineIds: Array<GuidelineId>
componentIds: Array<ComponentId>
}
export interface NapiGlyphLayerRecord {
id: LayerId
sourceId: SourceId
}
export interface NapiGlyphLayerSnapshot {
glyphId: GlyphId
sourceId: SourceId
state: NapiGlyphState
}
export interface NapiGlyphRecord {
id: GlyphId
name: GlyphName
unicodes: Array<Unicode>
componentBaseGlyphIds: Array<GlyphId>
layers: Array<NapiGlyphLayerRecord>
}
export interface NapiGlyphSnapshot {
glyphId: GlyphId
variationData?: NapiGlyphVariationData
layers: Array<NapiGlyphLayerSnapshot>
}
export interface NapiGlyphSnapshotRequest {
glyphId: GlyphId
}
export interface NapiGlyphState {
layerId: LayerId
structure: NapiGlyphStructure
/** Numeric glyph state ordered to match `GlyphStructure`. */
values: Float64Array
}
export interface NapiGlyphStructure {
contours: Array<NapiContourData>
anchors: Array<NapiAnchorData>
components: Array<NapiComponentData>
}
export interface NapiGlyphVariationData {
/** One entry per region. Inner = tents on the axes the region depends on. */
regions: Array<Array<NapiAxisTent>>
/** Deltas are flattened in `GlyphState::values` order. */
deltas: Array<Float64Array>
}
/**
* Replace-grade state for one touched layer; the renderer folds by
* substitution, never by interpreting changes.
*/
export interface NapiLayerReplaced {
layerId: LayerId
/** Present only when the layer's structure changed. */
structure?: NapiGlyphStructure
values: Float64Array
changed: NapiGlyphChangedEntities
}
export interface NapiLocation {
values: Record<AxisId, number>
}
export interface NapiMoveAnchorsIntent {
layerId: LayerId
anchorIds: Array<AnchorId>
/** Interleaved absolute coordinates: x0, y0, x1, y1, … */
coords: Array<number>
}
export interface NapiMovePointsIntent {
layerId: LayerId
pointIds: Array<PointId>
/** Interleaved absolute coordinates: x0, y0, x1, y1, … */
coords: Array<number>
}
/** NAPI projection of one explicit named product preset. */
export interface NapiNamedInstance {
id: NamedInstanceId
name: string
location: NapiLocation
postscriptName?: string
}
export interface NapiPointData {
id: PointId
pointType: NapiPointType
smooth: boolean
}
/**
* A point to create, carrying its caller-minted id (decision 6: ids are
* client-minted so verbs return identity synchronously).
*/
export interface NapiPointSeed {
id: PointId
x: number
y: number
pointType: NapiPointType
smooth: boolean
}
export declare const enum NapiPointType {
OnCurve = 'onCurve',
OffCurve = 'offCurve'
}
export interface NapiRemoveAnchorsIntent {
layerId: LayerId
anchorIds: Array<AnchorId>
}
export interface NapiRemovePointsIntent {
layerId: LayerId
pointIds: Array<PointId>
}
export interface NapiReverseContourIntent {
layerId: LayerId
contourId: ContourId
}
export interface NapiSetAxisMappingsIntent {
mappings: Array<NapiAxisMapping>
}
export interface NapiSetContourClosedIntent {
layerId: LayerId
contourId: ContourId
closed: boolean
}
export interface NapiSetPointSmoothIntent {
layerId: LayerId
pointId: PointId
smooth: boolean
}
export interface NapiSetXAdvanceIntent {
layerId: LayerId
width: number
}
export interface NapiSource {
id: SourceId
name: string
location: NapiLocation
filename?: string
}
/** Affine move: O(selection-ids) wire instead of O(N) coords. */
export interface NapiTranslatePointsIntent {
layerId: LayerId
pointIds: Array<PointId>
dx: number
dy: number
}
export interface NapiUpdateAxisIntent {
axis: NapiAxis
}
/**
* Font-level glyph update. The glyph id targets an existing committed glyph;
* names are user-editable labels and are not stable identity.
*/
export interface NapiUpdateGlyphIntent {
glyphId: GlyphId
newName: GlyphName
newUnicodes: Array<Unicode>
}
/** Replaces an authored named instance while retaining its identity. */
export interface NapiUpdateNamedInstanceIntent {
instance: NapiNamedInstance
}