envio 3.13.0-rc.0 → 3.14.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.
Files changed (77) hide show
  1. package/bin.mjs +10 -1
  2. package/index.d.ts +11 -0
  3. package/package.json +8 -20
  4. package/rescript.json +1 -4
  5. package/src/BatchProcessing.res +0 -2
  6. package/src/ChainState.res +39 -25
  7. package/src/ChainState.res.mjs +26 -23
  8. package/src/ChainState.resi +1 -2
  9. package/src/Config.res +69 -100
  10. package/src/Config.res.mjs +50 -63
  11. package/src/Core.res +46 -6
  12. package/src/Core.res.mjs +41 -4
  13. package/src/CrossChainState.res +13 -6
  14. package/src/CrossChainState.res.mjs +17 -4
  15. package/src/EventConfigBuilder.res +4 -10
  16. package/src/EventConfigBuilder.res.mjs +1 -3
  17. package/src/ExitOnCaughtUp.res +5 -1
  18. package/src/ExitOnCaughtUp.res.mjs +8 -3
  19. package/src/FinalizeBackfill.res +16 -10
  20. package/src/FinalizeBackfill.res.mjs +16 -5
  21. package/src/HandlerLoader.res +74 -32
  22. package/src/HandlerLoader.res.mjs +69 -23
  23. package/src/HandlerTypeCheck.mjs +14 -0
  24. package/src/HandlerTypeCheckWorker.mjs +68 -0
  25. package/src/Internal.res +1 -1
  26. package/src/Main.res +17 -12
  27. package/src/Main.res.mjs +9 -3
  28. package/src/NodeVersion.mjs +13 -0
  29. package/src/Persistence.res +79 -38
  30. package/src/Persistence.res.mjs +41 -10
  31. package/src/PgStorage.res +62 -34
  32. package/src/PgStorage.res.mjs +65 -31
  33. package/src/ResumePlan.res +172 -0
  34. package/src/ResumePlan.res.mjs +122 -0
  35. package/src/Supervisor.res +8 -8
  36. package/src/Supervisor.res.mjs +6 -1
  37. package/src/TestIndexer.res +19 -6
  38. package/src/TestIndexer.res.mjs +5 -4
  39. package/src/TsModuleHooks.mjs +121 -0
  40. package/src/Utils.res +0 -8
  41. package/src/Worker.res +8 -0
  42. package/src/Worker.res.mjs +11 -0
  43. package/src/bindings/NodeJs.res +8 -7
  44. package/src/bindings/NodeJs.res.mjs +0 -3
  45. package/src/bindings/Pino.res +2 -2
  46. package/src/db/InternalTable.res +52 -2
  47. package/src/db/InternalTable.res.mjs +32 -3
  48. package/src/sources/FuelHyperSync.res +2 -0
  49. package/src/sources/FuelHyperSync.res.mjs +1 -0
  50. package/src/sources/FuelHyperSync.resi +1 -0
  51. package/src/sources/FuelHyperSyncClient.res +25 -8
  52. package/src/sources/FuelHyperSyncClient.res.mjs +8 -2
  53. package/src/sources/FuelHyperSyncSource.res +24 -22
  54. package/src/sources/FuelHyperSyncSource.res.mjs +18 -13
  55. package/src/tui/InitApi.res +85 -0
  56. package/src/tui/{components/CustomHooks.res.mjs → InitApi.res.mjs} +11 -64
  57. package/src/tui/Tui.res +142 -249
  58. package/src/tui/Tui.res.mjs +123 -332
  59. package/src/Js.shim.ts +0 -11
  60. package/src/bindings/DateFns.res +0 -74
  61. package/src/bindings/DateFns.res.mjs +0 -22
  62. package/src/sources/FuelSDK.res +0 -38
  63. package/src/sources/FuelSDK.res.mjs +0 -27
  64. package/src/sources/vendored-fuel-abi-coder.js +0 -1792
  65. package/src/tui/bindings/Ink.res +0 -369
  66. package/src/tui/bindings/Ink.res.mjs +0 -66
  67. package/src/tui/bindings/Style.res +0 -123
  68. package/src/tui/bindings/Style.res.mjs +0 -2
  69. package/src/tui/components/BufferedProgressBar.res +0 -40
  70. package/src/tui/components/BufferedProgressBar.res.mjs +0 -57
  71. package/src/tui/components/CustomHooks.res +0 -122
  72. package/src/tui/components/Messages.res +0 -40
  73. package/src/tui/components/Messages.res.mjs +0 -71
  74. package/src/tui/components/SyncETA.res +0 -179
  75. package/src/tui/components/SyncETA.res.mjs +0 -249
  76. package/src/tui/components/TuiData.res +0 -98
  77. package/src/tui/components/TuiData.res.mjs +0 -73
@@ -1,369 +0,0 @@
1
- open Style
2
-
3
- type instance = {
4
- rerender: React.element => unit,
5
- unmount: unit => unit,
6
- waitUntilExit: unit => promise<unit>,
7
- clear: unit => unit,
8
- }
9
- type readableStream
10
- type writableStream
11
- type options = {
12
- stdout?: writableStream,
13
- stdin?: readableStream,
14
- exitOnCtrlC?: bool,
15
- patchConsole?: bool,
16
- debug?: bool,
17
- }
18
- @module("ink")
19
- external renderInternal: (React.element, ~options: option<options>) => instance = "render"
20
-
21
- let render = (~options=?, element) => {
22
- renderInternal(element, ~options)
23
- }
24
- type measurement = {width: int, height: int}
25
-
26
- @module("ink")
27
- external measureElement: React.ref<'a> => measurement = "measureElement"
28
-
29
- module Text = {
30
- type wrapOptions =
31
- | @as("wrap") Wrap
32
- | @as("truncate") Truncate
33
- | @as("truncate-start") TruncateStart
34
- | @as("truncate-middle") TruncateMiddle
35
- | @as("truncate-end") TruncateEnd
36
- @module("ink") @react.component
37
- external make: (
38
- ~children: React.element,
39
- ~color: chalkTheme=?,
40
- ~backgroundColor: chalkTheme=?,
41
- ~dimColor: bool=?,
42
- ~bold: bool=?,
43
- ~italic: bool=?,
44
- ~underline: bool=?,
45
- ~strikethrough: bool=?,
46
- ~inverse: bool=?,
47
- ~wrap: wrapOptions=?,
48
- ) => React.element = "Text"
49
- }
50
-
51
- module Box = {
52
- @module("ink") @react.component
53
- external make: (
54
- ~children: React.element=?,
55
- ~width: numOrStr=?,
56
- ~height: numOrStr=?,
57
- ~minWidth: int=?,
58
- ~minHeight: int=?,
59
- ~padding: int=?,
60
- ~paddingTop: int=?,
61
- ~paddingBottom: int=?,
62
- ~paddingLeft: int=?,
63
- ~paddingRight: int=?,
64
- ~paddingX: int=?,
65
- ~paddingY: int=?,
66
- ~margin: int=?,
67
- ~marginTop: int=?,
68
- ~marginBottom: int=?,
69
- ~marginLeft: int=?,
70
- ~marginRight: int=?,
71
- ~marginX: int=?,
72
- ~marginY: int=?,
73
- ~gap: int=?,
74
- ~rowGap: int=?,
75
- ~flexGrow: int=?,
76
- ~flexShrink: int=?,
77
- ~flexBasis: numOrStr=?,
78
- ~flexDirection: flexDirection=?,
79
- ~flexWrap: flexDirection=?,
80
- ~alignItems: alignItems=?,
81
- ~alignSelf: alignSelf=?,
82
- ~justifyContent: justifyContent=?,
83
- ~display: display=?,
84
- ~overflow: overflow=?,
85
- ~overflowX: overflow=?,
86
- ~overflowY: overflow=?,
87
- ~borderStyle: borderStyle=?,
88
- ~borderColor: chalkTheme=?,
89
- ~borderTopColor: chalkTheme=?,
90
- ~borderRightColor: chalkTheme=?,
91
- ~borderBottomColor: chalkTheme=?,
92
- ~borderLeftColor: chalkTheme=?,
93
- ~borderDimColor: bool=?,
94
- ~borderTopDimColor: bool=?,
95
- ~borderRightDimColor: bool=?,
96
- ~borderBottomDimColor: bool=?,
97
- ~borderLeftDimColor: bool=?,
98
- ~borderTop: bool=?,
99
- ~borderRight: bool=?,
100
- ~borderBottom: bool=?,
101
- ~borderLeft: bool=?,
102
- ) => React.element = "Box"
103
- }
104
-
105
- module Newline = {
106
- /**
107
- Adds one or more newline characters. Must be used within <Text> components.
108
-
109
- */
110
- @react.component
111
- let make = () => <Text> {" "->React.string} </Text>
112
- }
113
-
114
- module Spacer = {
115
- /**
116
- A flexible space that expands along the major axis of its containing layout. It's useful as a shortcut for filling all the available spaces between elements.
117
-
118
- For example, using <Spacer> in a <Box> with default flex direction (row) will position "Left" on the left side and will push "Right" to the right side.
119
- */
120
- @module("ink") @react.component
121
- external make: unit => React.element = "Spacer"
122
- }
123
-
124
- module Static = {
125
- /**
126
- <Static> component permanently renders its output above everything else. It's useful for displaying activity like completed tasks or logs - things that are not changing after they're rendered (hence the name "Static").
127
-
128
- It's preferred to use <Static> for use cases like these, when you can't know or control the amount of items that need to be rendered.
129
- */
130
- @module("ink") @react.component
131
- external make: (
132
- ~children: ('a, int) => React.element,
133
- ~items: array<'a>,
134
- ~style: styles=?,
135
- ) => React.element = "Static"
136
- }
137
-
138
- module Transform = {
139
- /**
140
- Transform a string representation of React components before they are written to output. For example, you might want to apply a gradient to text, add a clickable link or create some text effects. These use cases can't accept React nodes as input, they are expecting a string. That's what <Transform> component does, it gives you an output string of its child components and lets you transform it in any way.
141
-
142
- Note: <Transform> must be applied only to <Text> children components and shouldn't change the dimensions of the output, otherwise layout will be incorrect.
143
- */
144
- type outputLine = string
145
- type index = int
146
- @module("ink") @react.component
147
- external make: (
148
- ~children: string,
149
- ~tranform: (outputLine, index) => string,
150
- ~index: int=?,
151
- ) => React.element = "Transform"
152
- }
153
-
154
- module Hooks = {
155
- type key = {
156
- leftArrow: bool,
157
- rightArrow: bool,
158
- upArrow: bool,
159
- downArrow: bool,
160
- return: bool,
161
- escape: bool,
162
- ctrl: bool,
163
- shift: bool,
164
- tab: bool,
165
- backspace: bool,
166
- delete: bool,
167
- pageDown: bool,
168
- pageUp: bool,
169
- meta: bool,
170
- enter: bool,
171
- }
172
- type input = string
173
- type inputHandler = (input, key) => unit
174
- type options = {isActive?: bool}
175
-
176
- @module("ink") external useInput: (inputHandler, ~options: options=?) => unit = "useInput"
177
-
178
- type app = {exit: (~err: exn=?) => unit}
179
- @module("ink") external useApp: unit => app = "useApp"
180
-
181
- type stdin = {
182
- stdin: readableStream,
183
- isRawModeSupported: bool,
184
- setRawMode: bool => unit,
185
- }
186
-
187
- @module("ink") external useStdin: unit => stdin = "useStdin"
188
-
189
- type stdout = {
190
- stdout: writableStream,
191
- write: string => unit,
192
- }
193
-
194
- @module("ink") external useStdout: unit => stdout = "useStdout"
195
-
196
- type stderr = {
197
- stderr: writableStream,
198
- write: string => unit,
199
- }
200
-
201
- @module("ink") external useStderr: unit => stderr = "useStderr"
202
-
203
- type focusOptions = {autoFocus?: bool, isActive?: bool, id?: string}
204
- type focus = {isFocused: bool}
205
- @module("ink") external useFocus: (~options: focusOptions=?) => focus = "useFocus"
206
-
207
- type focusManager = {
208
- enableFocus: unit => unit,
209
- disableFocus: unit => unit,
210
- focusNext: unit => unit,
211
- focusPrevious: unit => unit,
212
- focusId: string => unit,
213
- }
214
- @module("ink")
215
- external useFocusManager: unit => focusManager = "useFocusManager"
216
-
217
- @get external getColumns: writableStream => int = "columns"
218
- @send external on: (writableStream, @as("resize") _, unit => unit) => unit = "on"
219
- @send external off: (writableStream, @as("resize") _, unit => unit) => unit = "off"
220
-
221
- let useStdoutColumns = () => {
222
- let {stdout} = useStdout()
223
- let (columns, setColumns) = React.useState(() => stdout->getColumns)
224
-
225
- React.useEffect1(() => {
226
- let handler = () => setColumns(_ => stdout->getColumns)
227
- stdout->on(handler)
228
- Some(() => stdout->off(handler))
229
- }, [stdout])
230
-
231
- columns
232
- }
233
- }
234
-
235
- module BigText = {
236
- type font =
237
- | @as("block") Block
238
- | @as("slick") Slick
239
- | @as("tiny") Tiny
240
- | @as("grid") Grid
241
- | @as("pallet") Pallet
242
- | @as("shade") Shade
243
- | @as("simple") Simple
244
- | @as("simpleBlock") SimpleBlock
245
- | @as("3d") D3
246
- | @as("simple3d") Simple3D
247
- | @as("chrome") Chrome
248
- | @as("huge") Huge
249
- type align =
250
- | @as("left") Left
251
- | @as("center") Center
252
- | @as("right") Right
253
- type backgroundColor =
254
- | @as("transparent") Transparent
255
- | @as("black") Black
256
- | @as("red") Red
257
- | @as("green") Green
258
- | @as("yellow") Yellow
259
- | @as("blue") Blue
260
- | @as("magenta") Magenta
261
- | @as("cyan") Cyan
262
- | @as("white") White
263
-
264
- type color = | ...chalkTheme | @as("system") System
265
- @module("ink-big-text") @react.component
266
- external make: (
267
- ~text: string,
268
- ~font: font=?, //default block
269
- ~align: align=?, //default left
270
- ~colors: array<color>=?, //default [system]
271
- ~backgroundColor: backgroundColor=?, //default transparent
272
- ~letterSpacing: int=?, //default 1
273
- ~lineHeight: int=?, //default 1
274
- ~space: bool=?, //default true
275
- ~maxLength: int=?,
276
- ) => React.element = "default"
277
- }
278
-
279
- module Spinner = {
280
- type typeOption =
281
- | @as("dots") Dots
282
- | @as("dots2") Dots2
283
- | @as("dots3") Dots3
284
- | @as("dots4") Dots4
285
- | @as("dots5") Dots5
286
- | @as("dots6") Dots6
287
- | @as("dots7") Dots7
288
- | @as("dots8") Dots8
289
- | @as("dots9") Dots9
290
- | @as("dots10") Dots10
291
- | @as("dots11") Dots11
292
- | @as("dots12") Dots12
293
- | @as("dots13") Dots13
294
- | @as("dots8Bit") Dots8Bit
295
- | @as("sand") Sand
296
- | @as("line") Line
297
- | @as("line2") Line2
298
- | @as("pipe") Pipe
299
- | @as("simpleDots") SimpleDots
300
- | @as("simpleDotsScrolling") SimpleDotsScrolling
301
- | @as("star") Star
302
- | @as("star2") Star2
303
- | @as("flip") Flip
304
- | @as("hamburger") Hamburger
305
- | @as("growVertical") GrowVertical
306
- | @as("growHorizontal") GrowHorizontal
307
- | @as("balloon") Balloon
308
- | @as("balloon2") Balloon2
309
- | @as("noise") Noise
310
- | @as("bounce") Bounce
311
- | @as("boxBounce") BoxBounce
312
- | @as("boxBounce2") BoxBounce2
313
- | @as("triangle") Triangle
314
- | @as("binary") Binary
315
- | @as("arc") Arc
316
- | @as("circle") Circle
317
- | @as("squareCorners") SquareCorners
318
- | @as("circleQuarters") CircleQuarters
319
- | @as("circleHalves") CircleHalves
320
- | @as("squish") Squish
321
- | @as("toggle") Toggle
322
- | @as("toggle2") Toggle2
323
- | @as("toggle3") Toggle3
324
- | @as("toggle4") Toggle4
325
- | @as("toggle5") Toggle5
326
- | @as("toggle6") Toggle6
327
- | @as("toggle7") Toggle7
328
- | @as("toggle8") Toggle8
329
- | @as("toggle9") Toggle9
330
- | @as("toggle10") Toggle10
331
- | @as("toggle11") Toggle11
332
- | @as("toggle12") Toggle12
333
- | @as("toggle13") Toggle13
334
- | @as("arrow") Arrow
335
- | @as("arrow2") Arrow2
336
- | @as("arrow3") Arrow3
337
- | @as("bouncingBar") BouncingBar
338
- | @as("bouncingBall") BouncingBall
339
- | @as("smiley") Smiley
340
- | @as("monkey") Monkey
341
- | @as("hearts") Hearts
342
- | @as("clock") Clock
343
- | @as("earth") Earth
344
- | @as("material") Material
345
- | @as("moon") Moon
346
- | @as("runner") Runner
347
- | @as("pong") Pong
348
- | @as("shark") Shark
349
- | @as("dqpb") Dqpb
350
- | @as("weather") Weather
351
- | @as("christmas") Christmas
352
- | @as("grenade") Grenade
353
- | @as("point") Point
354
- | @as("layer") Layer
355
- | @as("betaWave") BetaWave
356
- | @as("fingerDance") FingerDance
357
- | @as("fistBump") FistBump
358
- | @as("soccerHeader") SoccerHeader
359
- | @as("mindblown") Mindblown
360
- | @as("speaker") Speaker
361
- | @as("orangePulse") OrangePulse
362
- | @as("bluePulse") BluePulse
363
- | @as("orangeBluePulse") OrangeBluePulse
364
- | @as("timeTravel") TimeTravel
365
- | @as("aesthetic") Aesthetic
366
- | @as("dwarfFortress") DwarfFortress
367
- @module("ink-spinner") @react.component
368
- external make: (@as("type") ~type_: typeOption=?) => React.element = "default"
369
- }
@@ -1,66 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Ink from "ink";
4
- import * as React from "react";
5
- import * as JsxRuntime from "react/jsx-runtime";
6
-
7
- function render(options, element) {
8
- return Ink.render(element, options);
9
- }
10
-
11
- let Text = {};
12
-
13
- let Box = {};
14
-
15
- function Ink$Newline(props) {
16
- return JsxRuntime.jsx(Ink.Text, {
17
- children: " "
18
- });
19
- }
20
-
21
- let Newline = {
22
- make: Ink$Newline
23
- };
24
-
25
- let Spacer = {};
26
-
27
- let Static = {};
28
-
29
- let Transform = {};
30
-
31
- function useStdoutColumns() {
32
- let match = Ink.useStdout();
33
- let stdout = match.stdout;
34
- let match$1 = React.useState(() => stdout.columns);
35
- let setColumns = match$1[1];
36
- React.useEffect(() => {
37
- let handler = () => setColumns(param => stdout.columns);
38
- stdout.on("resize", handler);
39
- return () => {
40
- stdout.off("resize", handler);
41
- };
42
- }, [stdout]);
43
- return match$1[0];
44
- }
45
-
46
- let Hooks = {
47
- useStdoutColumns: useStdoutColumns
48
- };
49
-
50
- let BigText = {};
51
-
52
- let Spinner = {};
53
-
54
- export {
55
- render,
56
- Text,
57
- Box,
58
- Newline,
59
- Spacer,
60
- Static,
61
- Transform,
62
- Hooks,
63
- BigText,
64
- Spinner,
65
- }
66
- /* ink Not a pure module */
@@ -1,123 +0,0 @@
1
- type chalkTheme =
2
- | @as("#9860E5") Primary
3
- | @as("#FFBB2F") Secondary
4
- | @as("#6CBFEE") Info
5
- | @as("#FF8269") Danger
6
- | @as("#3B8C3D") Success
7
- | @as("white") White
8
- | @as("gray") Gray
9
-
10
- @unboxed type numOrStr = Num(int) | Str(string)
11
-
12
- type textWrap =
13
- | @as("wrap") Wrap
14
- | @as("end") End
15
- | @as("middle") Middle
16
- | @as("truncate-end") TruncateEnd
17
- | @as("truncate") Truncate
18
- | @as("truncate-middle") TruncateMiddle
19
- | @as("truncate-start") TruncateStart
20
-
21
- type position =
22
- | @as("absolute") Absolute
23
- | @as("relative") Relative
24
-
25
- type flexDirection =
26
- | @as("row") Row
27
- | @as("column") Column
28
- | @as("row-reverse") RowReverse
29
- | @as("column-reverse") ColumnReverse
30
-
31
- type flexWrap =
32
- | @as("nowrap") NoWrap
33
- | @as("wrap") Wrap
34
- | @as("wrap-reverse") WrapReverse
35
-
36
- type alignItems =
37
- | @as("flex-start") FlexStart
38
- | @as("center") Center
39
- | @as("flex-end") FlexEnd
40
- | @as("stretch") Stretch
41
-
42
- type alignSelf =
43
- | @as("flex-start") FlexStartSelf
44
- | @as("center") CenterSelf
45
- | @as("flex-end") FlexEndSelf
46
- | @as("auto") Auto
47
-
48
- type justifyContent =
49
- | @as("flex-start") JustifyFlexStart
50
- | @as("flex-end") JustifyFlexEnd
51
- | @as("space-between") SpaceBetween
52
- | @as("space-around") SpaceAround
53
- | @as("center") JustifyCenter
54
-
55
- type display =
56
- | @as("flex") Flex
57
- | @as("none") None
58
-
59
- type overflow =
60
- | @as("visible") Visible
61
- | @as("hidden") Hidden
62
-
63
- type borderStyle =
64
- | @as("single") Single
65
- | @as("double") Double
66
- | @as("round") Round
67
- | @as("bold") Bold
68
- | @as("singleDouble") SingleDouble
69
- | @as("doubleSingle") DoubleSingle
70
- | @as("classic") Classic
71
-
72
- type styles = {
73
- textWrap?: textWrap,
74
- position?: position,
75
- columnGap?: int,
76
- rowGap?: int,
77
- gap?: int,
78
- margin?: int,
79
- marginX?: int,
80
- marginY?: int,
81
- marginTop?: int,
82
- marginBottom?: int,
83
- marginLeft?: int,
84
- marginRight?: int,
85
- padding?: int,
86
- paddingX?: int,
87
- paddingY?: int,
88
- paddingTop?: int,
89
- paddingBottom?: int,
90
- paddingLeft?: int,
91
- paddingRight?: int,
92
- flexGrow?: int,
93
- flexShrink?: int,
94
- flexDirection?: flexDirection,
95
- flexBasis?: numOrStr,
96
- flexWrap?: flexWrap,
97
- alignItems?: alignItems,
98
- alignSelf?: alignSelf,
99
- justifyContent?: justifyContent,
100
- width?: numOrStr,
101
- height?: numOrStr,
102
- minWidth?: numOrStr,
103
- minHeight?: numOrStr,
104
- display?: display,
105
- borderStyle?: borderStyle,
106
- borderTop?: bool,
107
- borderBottom?: bool,
108
- borderLeft?: bool,
109
- borderRight?: bool,
110
- borderColor?: chalkTheme,
111
- borderTopColor?: chalkTheme,
112
- borderBottomColor?: chalkTheme,
113
- borderLeftColor?: chalkTheme,
114
- borderRightColor?: chalkTheme,
115
- borderDimColor?: bool,
116
- borderTopDimColor?: bool,
117
- borderBottomDimColor?: bool,
118
- borderLeftDimColor?: bool,
119
- borderRightDimColor?: bool,
120
- overflow?: overflow,
121
- overflowX?: overflow,
122
- overflowY?: overflow,
123
- }
@@ -1,2 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
- /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
@@ -1,40 +0,0 @@
1
- open Ink
2
-
3
- @react.component
4
- let make = (~loaded, ~buffered=?, ~outOf, ~barWidth=36, ~loadingColor=Style.Secondary) => {
5
- let maxCount = barWidth
6
-
7
- let loadedFraction = loaded->Int.toFloat /. outOf->Int.toFloat
8
- let loadedCount = Pervasives.min(
9
- Math.floor(maxCount->Int.toFloat *. loadedFraction)->Float.toInt,
10
- maxCount,
11
- )
12
-
13
- let bufferedCount = buffered->Option.mapOr(loadedCount, buffered => {
14
- let bufferedFraction = buffered->Int.toFloat /. outOf->Int.toFloat
15
- Pervasives.min(
16
- Math.floor(maxCount->Int.toFloat *. bufferedFraction)->Float.toInt,
17
- maxCount,
18
- )
19
- })
20
- let loadedFraction = loadedFraction > 0.0 ? loadedFraction : 0.0
21
- let loadedPercentageStr = (loadedFraction *. 100.)->Int.fromFloat->Int.toString ++ "% "
22
-
23
- let loadedPercentageStrCount = loadedPercentageStr->String.length
24
- let loadedSpaces = Pervasives.max(loadedCount - loadedPercentageStrCount, 0)
25
- let loadedCount = Pervasives.max(loadedCount, loadedPercentageStrCount)
26
- let bufferedCount = Pervasives.max(bufferedCount, loadedCount)
27
-
28
- <Box>
29
- <Text backgroundColor={loadingColor} color={Gray}>
30
- <Text> {" "->String.repeat(loadedSpaces)->React.string} </Text>
31
- <Text> {loadedPercentageStr->React.string} </Text>
32
- </Text>
33
- <Text backgroundColor={Gray}>
34
- {" "->String.repeat(bufferedCount - loadedCount)->React.string}
35
- </Text>
36
- <Text backgroundColor={White}>
37
- {" "->String.repeat(maxCount - bufferedCount)->React.string}
38
- </Text>
39
- </Box>
40
- }
@@ -1,57 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Ink from "ink";
4
- import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
5
- import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
- import * as JsxRuntime from "react/jsx-runtime";
7
-
8
- function BufferedProgressBar(props) {
9
- let __loadingColor = props.loadingColor;
10
- let __barWidth = props.barWidth;
11
- let outOf = props.outOf;
12
- let barWidth = __barWidth !== undefined ? __barWidth : 36;
13
- let loadingColor = __loadingColor !== undefined ? __loadingColor : "#FFBB2F";
14
- let loadedFraction = props.loaded / outOf;
15
- let loadedCount = Primitive_int.min(Math.floor(barWidth * loadedFraction) | 0, barWidth);
16
- let bufferedCount = Stdlib_Option.mapOr(props.buffered, loadedCount, buffered => {
17
- let bufferedFraction = buffered / outOf;
18
- return Primitive_int.min(Math.floor(barWidth * bufferedFraction) | 0, barWidth);
19
- });
20
- let loadedFraction$1 = loadedFraction > 0.0 ? loadedFraction : 0.0;
21
- let loadedPercentageStr = (loadedFraction$1 * 100 | 0).toString() + "% ";
22
- let loadedPercentageStrCount = loadedPercentageStr.length;
23
- let loadedSpaces = Primitive_int.max(loadedCount - loadedPercentageStrCount | 0, 0);
24
- let loadedCount$1 = Primitive_int.max(loadedCount, loadedPercentageStrCount);
25
- let bufferedCount$1 = Primitive_int.max(bufferedCount, loadedCount$1);
26
- return JsxRuntime.jsxs(Ink.Box, {
27
- children: [
28
- JsxRuntime.jsxs(Ink.Text, {
29
- children: [
30
- JsxRuntime.jsx(Ink.Text, {
31
- children: " ".repeat(loadedSpaces)
32
- }),
33
- JsxRuntime.jsx(Ink.Text, {
34
- children: loadedPercentageStr
35
- })
36
- ],
37
- color: "gray",
38
- backgroundColor: loadingColor
39
- }),
40
- JsxRuntime.jsx(Ink.Text, {
41
- children: " ".repeat(bufferedCount$1 - loadedCount$1 | 0),
42
- backgroundColor: "gray"
43
- }),
44
- JsxRuntime.jsx(Ink.Text, {
45
- children: " ".repeat(barWidth - bufferedCount$1 | 0),
46
- backgroundColor: "white"
47
- })
48
- ]
49
- });
50
- }
51
-
52
- let make = BufferedProgressBar;
53
-
54
- export {
55
- make,
56
- }
57
- /* ink Not a pure module */