expo-pretext 0.2.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/src/types.ts ADDED
@@ -0,0 +1,104 @@
1
+ // src/types.ts
2
+ // All shared types for expo-pretext.
3
+ // TextStyle uses RN conventions (object, not CSS string).
4
+ // Prepared types are opaque — consumers use them as handles.
5
+
6
+ export type TextStyle = {
7
+ fontFamily: string
8
+ fontSize: number
9
+ lineHeight?: number
10
+ fontWeight?: '400' | '500' | '600' | '700' | 'bold' | 'normal'
11
+ fontStyle?: 'normal' | 'italic'
12
+ }
13
+
14
+ export type WhiteSpaceMode = 'normal' | 'pre-wrap'
15
+
16
+ export type PrepareOptions = {
17
+ whiteSpace?: WhiteSpaceMode
18
+ locale?: string
19
+ accuracy?: 'fast' | 'exact'
20
+ }
21
+
22
+ export type LayoutResult = {
23
+ height: number
24
+ lineCount: number
25
+ }
26
+
27
+ export type LayoutCursor = {
28
+ segmentIndex: number
29
+ graphemeIndex: number
30
+ }
31
+
32
+ export type LayoutLine = {
33
+ text: string
34
+ width: number
35
+ start: LayoutCursor
36
+ end: LayoutCursor
37
+ }
38
+
39
+ export type LayoutLineRange = {
40
+ width: number
41
+ start: LayoutCursor
42
+ end: LayoutCursor
43
+ }
44
+
45
+ export type LayoutWithLinesResult = LayoutResult & {
46
+ lines: LayoutLine[]
47
+ }
48
+
49
+ // Opaque prepared handles
50
+ declare const preparedTextBrand: unique symbol
51
+ export type PreparedText = { readonly [preparedTextBrand]: true }
52
+
53
+ declare const preparedTextWithSegmentsBrand: unique symbol
54
+ export type PreparedTextWithSegments = {
55
+ readonly [preparedTextWithSegmentsBrand]: true
56
+ }
57
+
58
+ // Inline flow types
59
+ export type InlineFlowItem = {
60
+ text: string
61
+ style: TextStyle
62
+ atomic?: boolean
63
+ extraWidth?: number
64
+ }
65
+
66
+ declare const preparedInlineFlowBrand: unique symbol
67
+ export type PreparedInlineFlow = {
68
+ readonly [preparedInlineFlowBrand]: true
69
+ }
70
+
71
+ export type InlineFlowCursor = {
72
+ itemIndex: number
73
+ segmentIndex: number
74
+ graphemeIndex: number
75
+ }
76
+
77
+ export type InlineFlowFragment = {
78
+ itemIndex: number
79
+ text: string
80
+ gapBefore: number
81
+ occupiedWidth: number
82
+ start: LayoutCursor
83
+ end: LayoutCursor
84
+ }
85
+
86
+ export type InlineFlowLine = {
87
+ fragments: InlineFlowFragment[]
88
+ width: number
89
+ end: InlineFlowCursor
90
+ }
91
+
92
+ // Native module types (internal)
93
+ export type FontDescriptor = {
94
+ fontFamily: string
95
+ fontSize: number
96
+ fontWeight?: string
97
+ fontStyle?: string
98
+ }
99
+
100
+ export type NativeSegmentResult = {
101
+ segments: string[]
102
+ isWordLike: boolean[]
103
+ widths: number[]
104
+ }