@effindomv2/fui-as 0.1.36 → 0.1.39

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.
Files changed (119) hide show
  1. package/browser/routed-app-conventions.ts +1 -1
  2. package/browser/src/common-harness.ts +1 -27
  3. package/browser/src/index.ts +19 -26
  4. package/browser/src/routed-harness.ts +1 -194
  5. package/browser/src/shared-browser.ts +6 -0
  6. package/package.json +26 -16
  7. package/scripts/build.sh +51 -47
  8. package/scripts/framework-host-services.ts +1 -1
  9. package/scripts/generate-host-events.ts +15 -241
  10. package/scripts/generate-host-services.ts +13 -261
  11. package/scripts/hostgen/assemblyscript-host-events.ts +165 -0
  12. package/scripts/hostgen/assemblyscript-host-services.ts +207 -0
  13. package/scripts/hostgen/common.ts +73 -0
  14. package/scripts/hostgen/registry.ts +159 -0
  15. package/src/Fui.ts +70 -4
  16. package/src/FuiExports.ts +13 -1
  17. package/src/bindings/ui.ts +165 -8
  18. package/src/controls/Button.ts +98 -71
  19. package/src/controls/Checkbox.ts +23 -21
  20. package/src/controls/ComboBox.ts +1201 -0
  21. package/src/controls/ContextMenu.ts +279 -165
  22. package/src/controls/Dialog.ts +91 -17
  23. package/src/controls/Dropdown.ts +101 -333
  24. package/src/controls/NavLink.ts +29 -6
  25. package/src/controls/Popup.ts +10 -5
  26. package/src/controls/ProgressBar.ts +1 -2
  27. package/src/controls/RadioButton.ts +34 -13
  28. package/src/controls/RadioGroup.ts +32 -19
  29. package/src/controls/Slider.ts +21 -23
  30. package/src/controls/Switch.ts +34 -17
  31. package/src/controls/index.ts +2 -1
  32. package/src/controls/internal/ButtonPresenter.ts +5 -2
  33. package/src/controls/internal/CheckboxIndicatorPresenter.ts +10 -10
  34. package/src/controls/internal/DropdownChevronPresenter.ts +3 -3
  35. package/src/controls/internal/DropdownFieldPresenter.ts +6 -6
  36. package/src/controls/internal/DropdownOptionRowPresenter.ts +5 -4
  37. package/src/controls/internal/PressableLabeledControl.ts +4 -7
  38. package/src/controls/internal/RadioIndicatorPresenter.ts +7 -7
  39. package/src/controls/internal/SelectablePopupList.ts +463 -0
  40. package/src/controls/internal/SliderPresenter.ts +5 -5
  41. package/src/controls/internal/SwitchIndicatorPresenter.ts +63 -17
  42. package/src/controls/internal/TextInputCore.ts +307 -41
  43. package/src/controls/internal/TextInputPresenter.ts +2 -2
  44. package/src/controls/templating.ts +10 -0
  45. package/src/core/Application.ts +19 -9
  46. package/src/core/Bitmap.ts +219 -1
  47. package/src/core/ContextMenuManager.ts +128 -44
  48. package/src/core/DebugApi.ts +17 -2
  49. package/src/core/DragGesture.ts +8 -7
  50. package/src/core/EventRouter.ts +332 -12
  51. package/src/core/Fetch.ts +15 -7
  52. package/src/core/FetchFfi.ts +1 -15
  53. package/src/core/File.ts +75 -34
  54. package/src/core/FocusAdornerManager.ts +3 -3
  55. package/src/core/FocusVisibility.ts +7 -0
  56. package/src/core/FrameScheduler.ts +126 -0
  57. package/src/core/ImageSampling.ts +43 -0
  58. package/src/core/Logger.ts +2 -0
  59. package/src/core/MobileTextSelectionToolbarManager.ts +901 -0
  60. package/src/core/Node.ts +1039 -97
  61. package/src/core/Platform.ts +16 -16
  62. package/src/core/SelectionHandleAdornerManager.ts +697 -0
  63. package/src/core/Theme.ts +34 -20
  64. package/src/core/ToolTipManager.ts +3 -3
  65. package/src/core/Typography.ts +411 -19
  66. package/src/core/Worker.ts +69 -33
  67. package/src/core/event_exports.ts +123 -5
  68. package/src/core/ffi.ts +5 -746
  69. package/src/core/generated/FetchHostAbi.ts +10 -0
  70. package/src/core/generated/FrameworkHostServices.ts +1 -1
  71. package/src/core/generated/HostAbi.ts +220 -0
  72. package/src/core/generated/UiAbi.ts +356 -0
  73. package/src/core/generated/UiEnums.ts +186 -0
  74. package/src/drawing/DrawCallback.ts +34 -0
  75. package/src/drawing/DrawContext.ts +189 -0
  76. package/src/drawing/Paint.ts +34 -0
  77. package/src/drawing/Path.ts +40 -0
  78. package/src/nodes/CustomDrawable.ts +61 -0
  79. package/src/nodes/FlexBox.ts +57 -11
  80. package/src/nodes/Grid.ts +5 -5
  81. package/src/nodes/Image.ts +20 -1
  82. package/src/nodes/RichText.ts +36 -25
  83. package/src/nodes/ScrollBar.ts +2 -1
  84. package/src/nodes/ScrollBox.ts +7 -2
  85. package/src/nodes/ScrollView.ts +17 -6
  86. package/src/nodes/Svg.ts +18 -1
  87. package/src/nodes/Text.ts +1 -1
  88. package/src/nodes/TextCore.ts +115 -20
  89. package/src/nodes/index.ts +3 -1
  90. package/src/text/DynamicTextLayout.ts +275 -0
  91. package/src/text/TextLayout.ts +308 -0
  92. package/src/worker/Worker.ts +3 -36
  93. package/src/worker/WorkerJob.ts +5 -9
  94. package/src/worker/ffi.ts +0 -6
  95. package/browser/src/common-harness/host-imports.ts +0 -447
  96. package/browser/src/common-harness/interop.ts +0 -39
  97. package/browser/src/common-harness/managed-harness-bitmap-host.ts +0 -92
  98. package/browser/src/common-harness/managed-harness-fetch-host.ts +0 -201
  99. package/browser/src/common-harness/managed-harness-file-host.ts +0 -1066
  100. package/browser/src/common-harness/managed-harness-file-payloads.ts +0 -143
  101. package/browser/src/common-harness/managed-harness-file-types.ts +0 -71
  102. package/browser/src/common-harness/managed-harness-session.ts +0 -15
  103. package/browser/src/common-harness/managed-harness.ts +0 -1451
  104. package/browser/src/common-harness/managed-history.ts +0 -168
  105. package/browser/src/common-harness/persisted-restore-policy.ts +0 -50
  106. package/browser/src/common-harness/persisted-ui-state-controller.ts +0 -309
  107. package/browser/src/common-harness/text-session-bridge.ts +0 -452
  108. package/browser/src/common-harness/types.ts +0 -205
  109. package/browser/src/common-harness/ui-chrome.ts +0 -206
  110. package/browser/src/common-harness/ui-imports.ts +0 -553
  111. package/browser/src/common-harness/wasm-module-cache.ts +0 -47
  112. package/browser/src/file-processing-worker.ts +0 -89
  113. package/browser/src/host-events.ts +0 -118
  114. package/browser/src/host-services.ts +0 -483
  115. package/browser/src/persisted-ui-state.ts +0 -206
  116. package/browser/src/routed-app-conventions.ts +0 -292
  117. package/browser/src/worker-bootstrap.ts +0 -916
  118. package/browser/src/worker-manager.ts +0 -234
  119. package/browser/src/worker-types.ts +0 -68
package/src/Fui.ts CHANGED
@@ -30,11 +30,22 @@ export {
30
30
  loadSvg,
31
31
  loadTexture,
32
32
  } from "./core/Assets";
33
- export { Bitmap } from "./core/Bitmap";
34
- export { Fetch, FetchRequest, FetchResponse } from "./core/Fetch";
33
+ export { Bitmap, BitmapTextReadyEventArgs, BitmapTextReadyHandler } from "./core/Bitmap";
34
+ export { ImageSampling } from "./core/ImageSampling";
35
+ export { DrawContext } from "./drawing/DrawContext";
36
+ export { Paint } from "./drawing/Paint";
37
+ export { Path } from "./drawing/Path";
38
+ export { TextLayout, TextLayoutReadyEventArgs, TextLayoutReadyHandler, TextMetrics } from "./text/TextLayout";
39
+ export {
40
+ DynamicTextLayout,
41
+ DynamicTextLayoutReadyHandler,
42
+ DynamicTextOverflow,
43
+ } from "./text/DynamicTextLayout";
44
+ export { Fetch, FetchErrorEventArgs, FetchRequest, FetchResponse } from "./core/Fetch";
35
45
  export { log } from "./core/Logger";
36
46
  export { disposeAll, Disposable } from "./core/Disposable";
37
47
  export { cancelAllTimers, cancelTimer, hasTimer, scheduleTimer } from "./core/Timers";
48
+ export { LoadedEventArgs, LoadedHandler, onLoaded, onLoadedWith } from "./core/FrameScheduler";
38
49
  export { SetBackgroundAction, SetTextAction } from "./core/Actions";
39
50
  export { hslToColor, mixColor, rgb, rgba } from "./color";
40
51
  export {
@@ -56,6 +67,13 @@ export {
56
67
  } from "./core/Animation";
57
68
  export { NodeTransitions } from "./core/Transitions";
58
69
  export {
70
+ CheckboxChangedEventArgs,
71
+ ClickEventArgs,
72
+ ComboBoxChangedEventArgs,
73
+ ContextMenuEventArgs,
74
+ DragCompletedEventArgs,
75
+ DropdownChangedEventArgs,
76
+ PointerClickEventArgs,
59
77
  DragDataObject,
60
78
  DragDropEffects,
61
79
  DragEventArgs,
@@ -64,16 +82,43 @@ export {
64
82
  ExternalDropEventArgs,
65
83
  ExternalDropItemInfo,
66
84
  ExternalDropItemKind,
85
+ DEFAULT_LONG_PRESS_MINIMUM_DURATION_MS,
86
+ DEFAULT_LONG_PRESS_MOVEMENT_TOLERANCE,
87
+ FocusChangedEventArgs,
88
+ GestureEventArgs,
89
+ GestureEventKind,
90
+ GestureEventPhase,
91
+ HoverChangedEventArgs,
92
+ KeyEventArgs,
93
+ LongPressGesture,
94
+ LongPressEventArgs,
67
95
  Node,
96
+ PointerButton,
97
+ PointerButtons,
98
+ PanGestureEventArgs,
99
+ PinchGestureEventArgs,
100
+ PointerEventArgs,
101
+ PointerType,
102
+ RadioButtonChangedEventArgs,
103
+ RadioGroupChangedEventArgs,
104
+ SelectionChangedEventArgs,
105
+ SliderChangedEventArgs,
106
+ SwitchChangedEventArgs,
107
+ TextChangedEventArgs,
108
+ VisibilityChangedEventArgs,
109
+ WheelDeltaMode,
110
+ WheelEventArgs,
68
111
  } from "./core/Node";
69
112
  export { DragCompletedEvent, DragDeltaEvent, DragGesture, DragGestureHost, DragStartedEvent } from "./core/DragGesture";
70
113
  export { ContextMenuManager } from "./core/ContextMenuManager";
114
+ export { NavigateEventArgs } from "./controls/NavLink";
71
115
  export {
72
116
  AlignSelf,
73
117
  AlignItems,
74
118
  BorderStyle,
75
119
  CursorStyle,
76
120
  FlexDirection,
121
+ FlexWrap,
77
122
  GridUnit,
78
123
  HandleValue,
79
124
  JustifyContent,
@@ -95,12 +140,26 @@ export {
95
140
  export { Signal } from "./core/Signal";
96
141
  export { showKeyboardFocusForKeyEvent } from "./core/FocusVisibility";
97
142
  export { ToolTip, PopupPlacement } from "./core/ToolTip";
98
- export { FontFace, FontFamily, FontStack, FontStyle, FontWeight } from "./core/Typography";
143
+ export {
144
+ FontFace,
145
+ FontFaceLoadedEventArgs,
146
+ FontFamily,
147
+ FontLoadedHandler,
148
+ FontReadyHandler,
149
+ FontsLoadedEventArgs,
150
+ FontStack,
151
+ FontStackLoadedEventArgs,
152
+ FontStackLoadedHandler,
153
+ FontStyle,
154
+ FontWeight,
155
+ } from "./core/Typography";
99
156
  export {
100
157
  BrowserFile,
101
158
  BrowserFileWriter,
102
159
  File,
103
160
  FileCapabilities,
161
+ FileErrorEventArgs,
162
+ FileOpenEventArgs,
104
163
  FileReadChunk,
105
164
  FileWorkerProcessProgress,
106
165
  FileWorkerProcessRequest,
@@ -110,7 +169,7 @@ export {
110
169
  FileSaveResult,
111
170
  FileWriteProgress,
112
171
  } from "./core/File";
113
- export { Worker } from "./core/Worker";
172
+ export { Worker, WorkerCompletedEventArgs, WorkerErrorEventArgs, WorkerProgressEventArgs } from "./core/Worker";
114
173
  export { Worker as WorkerRuntime } from "./worker/Worker";
115
174
  export { WorkerJob } from "./worker/WorkerJob";
116
175
  export { currentRoute, navigateTo } from "./core/Navigation";
@@ -135,6 +194,7 @@ export {
135
194
  useSystemTheme,
136
195
  } from "./core/Theme";
137
196
  export { frameTimeSignal, viewportHeightSignal, viewportWidthSignal } from "./core/event_exports";
197
+ export { getDevicePixelRatio as devicePixelRatio } from "./bindings/ui";
138
198
  export {
139
199
  AntiSelectionArea,
140
200
  Button,
@@ -147,6 +207,10 @@ export {
147
207
  CheckboxIndicatorVisualState,
148
208
  Checkbox,
149
209
  clearControlTemplates,
210
+ ComboBox,
211
+ ComboBoxCommitMode,
212
+ ComboBoxFilterMode,
213
+ ComboBoxItem,
150
214
  ControlTemplateSet,
151
215
  ContextMenu,
152
216
  Dialog,
@@ -199,8 +263,10 @@ export {
199
263
  useControlTemplates,
200
264
  } from "./controls";
201
265
  export {
266
+ Border,
202
267
  FlexBox,
203
268
  FlexBoxProps,
269
+ CustomDrawable,
204
270
  GradientStop,
205
271
  Grid,
206
272
  Image,
package/src/FuiExports.ts CHANGED
@@ -7,6 +7,7 @@ export {
7
7
  } from "./core/Application";
8
8
  export {
9
9
  __fui_on_external_drag_event,
10
+ __fui_can_show_context_menu,
10
11
  __fui_on_fetch_complete,
11
12
  __fui_on_fetch_error,
12
13
  __fui_on_file_finish_result,
@@ -25,15 +26,25 @@ export {
25
26
  __fui_on_cross_selection_changed,
26
27
  __fui_on_focus_changed,
27
28
  __fui_on_frame,
29
+ __fui_get_gesture_intent,
30
+ __fui_get_long_press_minimum_duration_ms,
31
+ __fui_get_long_press_movement_tolerance,
32
+ __fui_on_gesture_event,
33
+ __fui_on_long_press_event,
28
34
  __fui_on_key_event,
29
- __fui_on_pointer_event,
35
+ __fui_on_pointer_event_with_metadata,
30
36
  __fui_on_route_changed,
31
37
  __fui_on_scroll,
32
38
  __fui_on_selection_changed,
39
+ __fui_on_system_accent_color_changed,
33
40
  __fui_on_system_dark_mode_changed,
34
41
  __fui_on_text_changed,
35
42
  __fui_on_text_replaced,
36
43
  __fui_on_timer,
44
+ __fui_on_wheel_event,
45
+ __fui_resolve_gesture_owner,
46
+ __fui_resolve_long_press_owner,
47
+ __fui_on_font_loaded,
37
48
  __fui_on_viewport_changed,
38
49
  __fui_on_worker_complete,
39
50
  __fui_on_worker_error,
@@ -53,3 +64,4 @@ export {
53
64
  __fui_on_texture_failed,
54
65
  __fui_on_texture_loaded,
55
66
  } from "./core/Assets";
67
+ export { fui_dispatch_custom_draw } from "./drawing/DrawCallback";
@@ -172,6 +172,50 @@ export function setIsSharedSizeScope(handle: u64, isScope: bool): void {
172
172
  ffi.ui_set_is_shared_size_scope(handle, isScope);
173
173
  }
174
174
 
175
+ export function setCustomDrawable(handle: u64, flag: bool): void {
176
+ ffi.ui_set_custom_drawable(handle, flag);
177
+ }
178
+
179
+ export function setFlexWrap(handle: u64, wrap: u32): void {
180
+ ffi.ui_set_flex_wrap(handle, wrap);
181
+ }
182
+
183
+ export function prepareNode(handle: u64): u32 {
184
+ return ffi.ui_prepare_node(handle);
185
+ }
186
+
187
+ export function setDynamicTextCharset(handle: u64, charset: string): void {
188
+ const bytes = encodeUtf8(charset);
189
+ ffi.ui_set_dynamic_text_charset(handle, bytes.length > 0 ? bytes.dataStart : 0, <u32>bytes.length);
190
+ }
191
+
192
+ export function registerTextInputMetadata(handle: u64, isPassword: bool, hostAutofillHint: string | null): void {
193
+ if (hostAutofillHint === null || hostAutofillHint.length == 0) {
194
+ ffi.fui_register_text_input_metadata(handle, isPassword, 0, 0);
195
+ return;
196
+ }
197
+ const bytes = encodeUtf8(hostAutofillHint);
198
+ ffi.fui_register_text_input_metadata(handle, isPassword, bytes.dataStart, <u32>bytes.length);
199
+ }
200
+
201
+ export function tryGetTextMetrics(handle: u64): Float32Array | null {
202
+ const values = new Float32Array(5);
203
+ const lineCount = new Uint32Array(1);
204
+ const found = ffi.ui_get_text_metrics(
205
+ handle,
206
+ values.dataStart,
207
+ values.dataStart + sizeof<f32>(),
208
+ values.dataStart + (sizeof<f32>() * 2),
209
+ lineCount.dataStart,
210
+ values.dataStart + (sizeof<f32>() * 4),
211
+ );
212
+ if (!found) {
213
+ return null;
214
+ }
215
+ unchecked(values[3] = <f32>unchecked(lineCount[0]));
216
+ return values;
217
+ }
218
+
175
219
  export function gridSetColumns(handle: u64, values: Float32Array, types: Uint8Array): void {
176
220
  ffi.ui_grid_set_columns(
177
221
  handle,
@@ -255,8 +299,8 @@ export function setBackgroundBlur(handle: u64, blurSigma: f32): void {
255
299
  ffi.ui_set_background_blur(handle, blurSigma);
256
300
  }
257
301
 
258
- export function setImage(handle: u64, textureId: u32, objectFit: u32): void {
259
- ffi.ui_set_image(handle, textureId, objectFit);
302
+ export function setImage(handle: u64, textureId: u32, objectFit: u32, samplingKind: u32, maxAniso: u32): void {
303
+ ffi.ui_set_image(handle, textureId, objectFit, samplingKind, maxAniso);
260
304
  }
261
305
 
262
306
  export function setImageNine(
@@ -266,12 +310,14 @@ export function setImageNine(
266
310
  insetTop: f32,
267
311
  insetRight: f32,
268
312
  insetBottom: f32,
313
+ samplingKind: u32,
314
+ maxAniso: u32,
269
315
  ): void {
270
- ffi.ui_set_image_nine(handle, textureId, insetLeft, insetTop, insetRight, insetBottom);
316
+ ffi.ui_set_image_nine(handle, textureId, insetLeft, insetTop, insetRight, insetBottom, samplingKind, maxAniso);
271
317
  }
272
318
 
273
- export function setSvg(handle: u64, svgId: u32, tintColor: u32): void {
274
- ffi.ui_set_svg(handle, svgId, tintColor);
319
+ export function setSvg(handle: u64, svgId: u32, tintColor: u32, samplingKind: u32, maxAniso: u32): void {
320
+ ffi.ui_set_svg(handle, svgId, tintColor, samplingKind, maxAniso);
275
321
  }
276
322
 
277
323
  export function setLinearGradient(
@@ -293,10 +339,9 @@ export function setLinearGradient(
293
339
  endX,
294
340
  endY,
295
341
  <u32>offsets.length,
342
+ offsets.length > 0 ? offsets.dataStart : 0,
343
+ colors.length > 0 ? colors.dataStart : 0,
296
344
  );
297
- for (let i = 0; i < offsets.length; ++i) {
298
- ffi.ui_push_linear_gradient_stop(handle, unchecked(offsets[i]), unchecked(colors[i]));
299
- }
300
345
  }
301
346
 
302
347
  export function setClipToBounds(handle: u64, clip: bool): void {
@@ -307,6 +352,10 @@ export function setInteractive(handle: u64, flag: bool): void {
307
352
  ffi.ui_set_interactive(handle, flag);
308
353
  }
309
354
 
355
+ export function setPreserveSelectionOnPointerDown(handle: u64, preserve: bool): void {
356
+ ffi.ui_set_preserve_selection_on_pointer_down(handle, preserve);
357
+ }
358
+
310
359
  export function setScrollProxyTarget(handle: u64, scrollHandle: u64): void {
311
360
  ffi.ui_set_scroll_proxy_target(handle, scrollHandle);
312
361
  }
@@ -323,6 +372,10 @@ export function setScrollFriction(handle: u64, friction: f32): void {
323
372
  ffi.ui_set_scroll_friction(handle, friction);
324
373
  }
325
374
 
375
+ export function setSmoothScrolling(handle: u64, smoothScrolling: bool): void {
376
+ ffi.ui_set_smooth_scrolling(handle, smoothScrolling);
377
+ }
378
+
326
379
  export function setFocusable(handle: u64, flag: bool, tabIndex: i32): void {
327
380
  ffi.ui_set_focusable(handle, flag, tabIndex);
328
381
  }
@@ -372,6 +425,10 @@ export function bitmapRelease(textureId: u32): void {
372
425
  ffi.fui_bitmap_release(textureId);
373
426
  }
374
427
 
428
+ export function renderNodeToRgba(handle: u64, width: u32, height: u32, outPtr: usize, capacity: u32, scale: f32, x: f32, y: f32): u32 {
429
+ return ffi.fui_render_node_to_rgba(handle, width, height, outPtr, capacity, scale, x, y);
430
+ }
431
+
375
432
  export function loadFont(fontId: u32, url: string): void {
376
433
  const bytes = encodeUtf8(url);
377
434
  ffi.fui_load_font(fontId, bytes.length > 0 ? bytes.dataStart : 0, <u32>bytes.length);
@@ -437,6 +494,14 @@ export function setEditable(handle: u64, editable: bool): void {
437
494
  ffi.ui_set_editable(handle, editable);
438
495
  }
439
496
 
497
+ export function setEditorCommandKeys(handle: u64, enabled: bool): void {
498
+ ffi.ui_set_editor_command_keys(handle, enabled);
499
+ }
500
+
501
+ export function setEditorAcceptsTab(handle: u64, enabled: bool): void {
502
+ ffi.ui_set_editor_accepts_tab(handle, enabled);
503
+ }
504
+
440
505
  export function setCaretColor(handle: u64, color: u32): void {
441
506
  ffi.ui_set_caret_color(handle, color);
442
507
  }
@@ -481,6 +546,82 @@ export function setTextSelectionRange(handle: u64, selectionStart: u32, selectio
481
546
  ffi.ui_set_text_selection_range(handle, selectionStart, selectionEnd);
482
547
  }
483
548
 
549
+ export function selectWordAt(handle: u64, x: f32, y: f32): bool {
550
+ return ffi.ui_select_word_at(handle, x, y);
551
+ }
552
+
553
+ export function beginSelectionEndpointDrag(handle: u64, endpoint: u32): bool {
554
+ return ffi.ui_begin_selection_endpoint_drag(handle, endpoint);
555
+ }
556
+
557
+ export class TextRangeRect {
558
+ readonly x: f32;
559
+ readonly y: f32;
560
+ readonly width: f32;
561
+ readonly height: f32;
562
+
563
+ constructor(x: f32, y: f32, width: f32, height: f32) {
564
+ this.x = x;
565
+ this.y = y;
566
+ this.width = width;
567
+ this.height = height;
568
+ }
569
+ }
570
+
571
+ export function getTextRangeRects(handle: u64, start: u32, end: u32): Array<TextRangeRect> {
572
+ const rectCount = ffi.ui_get_text_range_rect_count(handle, start, end);
573
+ if (rectCount == 0) {
574
+ return new Array<TextRangeRect>();
575
+ }
576
+ const rectWords = new StaticArray<f32>(<i32>rectCount * 4);
577
+ const copiedCount = ffi.ui_copy_text_range_rects(handle, start, end, changetype<usize>(rectWords), rectCount);
578
+ if (copiedCount == 0) {
579
+ return new Array<TextRangeRect>();
580
+ }
581
+ const rects = new Array<TextRangeRect>(copiedCount);
582
+ for (let index: u32 = 0; index < copiedCount; ++index) {
583
+ const base = <i32>index * 4;
584
+ unchecked(rects[<i32>index] = new TextRangeRect(
585
+ unchecked(rectWords[base]),
586
+ unchecked(rectWords[base + 1]),
587
+ unchecked(rectWords[base + 2]),
588
+ unchecked(rectWords[base + 3]),
589
+ ));
590
+ }
591
+ return rects;
592
+ }
593
+
594
+ export class TextSelectionEndpointRects {
595
+ readonly start: TextRangeRect;
596
+ readonly end: TextRangeRect;
597
+
598
+ constructor(start: TextRangeRect, end: TextRangeRect) {
599
+ this.start = start;
600
+ this.end = end;
601
+ }
602
+ }
603
+
604
+ export function getCrossSelectionEndpointRects(areaHandle: u64): TextSelectionEndpointRects | null {
605
+ const rectWords = new StaticArray<f32>(8);
606
+ if (!ffi.ui_copy_cross_selection_endpoint_rects(areaHandle, changetype<usize>(rectWords))) {
607
+ return null;
608
+ }
609
+ return new TextSelectionEndpointRects(
610
+ new TextRangeRect(
611
+ unchecked(rectWords[0]),
612
+ unchecked(rectWords[1]),
613
+ unchecked(rectWords[2]),
614
+ unchecked(rectWords[3]),
615
+ ),
616
+ new TextRangeRect(
617
+ unchecked(rectWords[4]),
618
+ unchecked(rectWords[5]),
619
+ unchecked(rectWords[6]),
620
+ unchecked(rectWords[7]),
621
+ ),
622
+ );
623
+ }
624
+
484
625
  export function clearCurrentSelection(): void {
485
626
  ffi.ui_clear_current_selection();
486
627
  }
@@ -546,6 +687,18 @@ export function tryGetBounds(handle: u64): Float32Array | null {
546
687
  return found ? values : null;
547
688
  }
548
689
 
690
+ export function tryGetVisibleBounds(handle: u64): Float32Array | null {
691
+ const values = new Float32Array(4);
692
+ const found = ffi.ui_get_visible_bounds(
693
+ handle,
694
+ values.dataStart,
695
+ values.dataStart + sizeof<f32>(),
696
+ values.dataStart + (sizeof<f32>() * 2),
697
+ values.dataStart + (sizeof<f32>() * 3),
698
+ );
699
+ return found ? values : null;
700
+ }
701
+
549
702
  export function resizeWindow(width: f32, height: f32): void {
550
703
  ffi.ui_resize_window(width, height);
551
704
  }
@@ -561,3 +714,7 @@ export function getViewportWidth(): f32 {
561
714
  export function getViewportHeight(): f32 {
562
715
  return ffi.get_viewport_height();
563
716
  }
717
+
718
+ export function getDevicePixelRatio(): f32 {
719
+ return ffi.get_device_pixel_ratio();
720
+ }