@xframes/wasm 0.0.3 → 0.1.3

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/dist/index.js CHANGED
@@ -1,830 +1,12 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/components/XFramesDemo/XFramesDemo.tsx
2
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/lib/ReactNativeWrapper.tsx
2
+ var _react = require('react');
3
3
 
4
4
 
5
5
 
6
6
 
7
7
 
8
8
  var _common = require('@xframes/common');
9
-
10
- // src/components/XFramesDemo/Tables/Tables.tsx
11
-
12
-
13
9
  var _jsxruntime = require('react/jsx-runtime');
14
- var sampleData = [
15
- { id: "1", name: "Name" },
16
- { id: "1", name: "Name" },
17
- { id: "1", name: "Name" },
18
- { id: "1", name: "Name" },
19
- { id: "1", name: "Name" }
20
- ];
21
- var styleSheet = _common.RWStyleSheet.create({
22
- primaryButton: {
23
- colors: { [_common.ImGuiCol.Button]: "#ff6e59" }
24
- // vars: { [ImGuiStyleVar.FramePadding]: [40, 3] },
25
- // width: 150,
26
- },
27
- secondaryButton: {
28
- // width: 150,
29
- }
30
- });
31
- var Tables = () => {
32
- const intervalRef = _react.useRef.call(void 0, );
33
- const counterRef = _react.useRef.call(void 0, 1);
34
- const tableRef1 = _react.useRef.call(void 0, null);
35
- const tableRef2 = _react.useRef.call(void 0, null);
36
- const tableRef3 = _react.useRef.call(void 0, null);
37
- const tableRef4 = _react.useRef.call(void 0, null);
38
- const tableColumns = _react.useMemo.call(void 0,
39
- () => [
40
- {
41
- heading: "ID",
42
- fieldId: "id"
43
- },
44
- {
45
- heading: "Name",
46
- fieldId: "name"
47
- }
48
- ],
49
- []
50
- );
51
- const handleAppendDataToTableClick = _react.useCallback.call(void 0, () => {
52
- if (tableRef1.current && tableRef2.current && tableRef3.current && tableRef4.current) {
53
- intervalRef.current = setInterval(() => {
54
- if (tableRef1.current && tableRef2.current && tableRef3.current && tableRef4.current) {
55
- const data = sampleData.map((sampleDataRow, index) => ({
56
- ...sampleDataRow,
57
- id: `${counterRef.current + index}`
58
- }));
59
- counterRef.current += sampleData.length;
60
- tableRef1.current.appendDataToTable(data);
61
- tableRef2.current.appendDataToTable(data);
62
- tableRef3.current.appendDataToTable(data);
63
- tableRef4.current.appendDataToTable(data);
64
- }
65
- }, 10);
66
- }
67
- }, [tableRef1, tableRef2, tableRef3]);
68
- const handleStopAppendingDataToTableClick = _react.useCallback.call(void 0, () => {
69
- if (intervalRef.current) {
70
- clearInterval(intervalRef.current);
71
- }
72
- }, []);
73
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
74
- XFrames.Node,
75
- {
76
- root: true,
77
- style: {
78
- width: "100%",
79
- height: "100%",
80
- flexDirection: "column",
81
- gap: { row: 5 }
82
- },
83
- children: [
84
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
85
- XFrames.Node,
86
- {
87
- style: {
88
- width: "100%",
89
- height: 200,
90
- flexDirection: "row",
91
- gap: { column: 5 }
92
- },
93
- children: [
94
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
95
- XFrames.Table,
96
- {
97
- ref: tableRef1,
98
- columns: tableColumns,
99
- clipRows: 10,
100
- style: {
101
- flex: 1,
102
- height: "100%"
103
- }
104
- }
105
- ),
106
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
107
- XFrames.Table,
108
- {
109
- ref: tableRef2,
110
- columns: tableColumns,
111
- clipRows: 10,
112
- style: {
113
- flex: 1,
114
- height: "100%"
115
- }
116
- }
117
- ),
118
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
119
- XFrames.Table,
120
- {
121
- ref: tableRef3,
122
- columns: tableColumns,
123
- clipRows: 10,
124
- style: {
125
- flex: 1,
126
- height: "100%"
127
- }
128
- }
129
- ),
130
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
131
- XFrames.Table,
132
- {
133
- ref: tableRef4,
134
- columns: tableColumns,
135
- clipRows: 10,
136
- style: {
137
- flex: 1,
138
- height: "100%"
139
- }
140
- }
141
- )
142
- ]
143
- }
144
- ),
145
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
146
- XFrames.Node,
147
- {
148
- style: {
149
- width: "100%",
150
- height: 30,
151
- flexDirection: "row",
152
- justifyContent: "flex-end",
153
- gap: { column: 5 }
154
- },
155
- children: [
156
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
157
- XFrames.Button,
158
- {
159
- onClick: handleAppendDataToTableClick,
160
- label: "Add data to table",
161
- style: styleSheet.primaryButton
162
- }
163
- ),
164
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
165
- XFrames.Button,
166
- {
167
- onClick: handleStopAppendingDataToTableClick,
168
- label: "Stop adding data",
169
- style: styleSheet.secondaryButton
170
- }
171
- )
172
- ]
173
- }
174
- )
175
- ]
176
- }
177
- );
178
- };
179
-
180
- // src/components/XFramesDemo/Maps/Maps.tsx
181
-
182
-
183
- var Maps = () => {
184
- const mapRef = _react.useRef.call(void 0, null);
185
- const [center, setCenter] = _react.useState.call(void 0, [-74.006, 40.7128]);
186
- const [zoom, setZoom] = _react.useState.call(void 0, 15);
187
- const renderMap = _react.useCallback.call(void 0, () => {
188
- if (mapRef.current) {
189
- mapRef.current.render(center[0], center[1], zoom);
190
- }
191
- }, [center, zoom]);
192
- const locate = _react.useCallback.call(void 0, () => {
193
- if ("geolocation" in navigator) {
194
- navigator.geolocation.getCurrentPosition(
195
- (position) => {
196
- setCenter([position.coords.longitude, position.coords.latitude]);
197
- },
198
- (error) => {
199
- console.error("Error getting geolocation:", error);
200
- }
201
- );
202
- }
203
- }, []);
204
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
205
- XFrames.Node,
206
- {
207
- style: {
208
- width: "100%",
209
- height: "100%",
210
- flexDirection: "column",
211
- gap: { row: 5 }
212
- },
213
- children: [
214
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
215
- XFrames.Node,
216
- {
217
- style: {
218
- width: "100%",
219
- flexDirection: "row",
220
- alignItems: "center",
221
- gap: { column: 15 }
222
- },
223
- children: [
224
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { text: `Center: ${center[0]}, ${center[1]}` }),
225
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Button, { onClick: locate, label: "Locate" }),
226
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Button, { onClick: renderMap, label: "Render" })
227
- ]
228
- }
229
- ),
230
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.MapView, { ref: mapRef, style: { flex: 1 } })
231
- ]
232
- }
233
- );
234
- };
235
-
236
- // src/components/XFramesDemo/Plots/Plots.tsx
237
-
238
-
239
- var Plots = () => {
240
- const plotRef = _react.useRef.call(void 0, null);
241
- const [axisAutoFit, setAxisAutoFit] = _react.useState.call(void 0, true);
242
- const counterRef = _react.useRef.call(void 0, 0);
243
- const appendData = _react.useCallback.call(void 0, () => {
244
- if (plotRef.current) {
245
- counterRef.current += 1;
246
- plotRef.current.appendData(counterRef.current, counterRef.current);
247
- }
248
- }, []);
249
- const resetData = _react.useCallback.call(void 0, () => {
250
- if (plotRef.current) {
251
- plotRef.current.resetData();
252
- }
253
- }, []);
254
- const toggleAxisAutoFit = _react.useCallback.call(void 0, () => {
255
- setAxisAutoFit((val) => !val);
256
- }, []);
257
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
258
- XFrames.Node,
259
- {
260
- style: {
261
- width: "100%",
262
- height: "100%",
263
- flexDirection: "column",
264
- gap: { row: 5 }
265
- },
266
- children: [
267
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
268
- XFrames.Node,
269
- {
270
- style: {
271
- width: "100%",
272
- flexDirection: "row",
273
- alignItems: "center",
274
- gap: { column: 15 }
275
- },
276
- children: [
277
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Button, { onClick: appendData, label: "Append" }),
278
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
279
- XFrames.Button,
280
- {
281
- onClick: toggleAxisAutoFit,
282
- label: "Toggle Axis Auto-Fit"
283
- }
284
- ),
285
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Button, { onClick: resetData, label: "Reset" })
286
- ]
287
- }
288
- ),
289
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
290
- XFrames.PlotLine,
291
- {
292
- ref: plotRef,
293
- style: { flex: 1 },
294
- axisAutoFit
295
- }
296
- )
297
- ]
298
- }
299
- );
300
- };
301
-
302
- // src/components/XFramesDemo/Images/Images.tsx
303
-
304
-
305
- var Images = () => {
306
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
307
- XFrames.Node,
308
- {
309
- style: {
310
- flexDirection: "row",
311
- gap: { column: 5 },
312
- alignItems: "center",
313
- border: {
314
- color: "red",
315
- thickness: 2
316
- },
317
- width: "auto"
318
- },
319
- children: [
320
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
321
- XFrames.Image,
322
- {
323
- url: "https://images.ctfassets.net/hrltx12pl8hq/28ECAQiPJZ78hxatLTa7Ts/2f695d869736ae3b0de3e56ceaca3958/free-nature-images.jpg?fit=fill&w=1200&h=630",
324
- width: 40,
325
- height: 40
326
- }
327
- ),
328
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
329
- XFrames.Node,
330
- {
331
- style: {
332
- width: 100,
333
- height: 100,
334
- backgroundColor: "#000000",
335
- border: {
336
- color: "lightgreen",
337
- thickness: 5
338
- },
339
- rounding: 5,
340
- roundCorners: ["topLeft"]
341
- },
342
- children: [
343
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
344
- XFrames.UnformattedText,
345
- {
346
- text: "Inside",
347
- style: { colors: { [_common.ImGuiCol.Text]: "#FFFFFF" } }
348
- }
349
- ),
350
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
351
- XFrames.Image,
352
- {
353
- url: "https://images.ctfassets.net/hrltx12pl8hq/28ECAQiPJZ78hxatLTa7Ts/2f695d869736ae3b0de3e56ceaca3958/free-nature-images.jpg?fit=fill&w=1200&h=630",
354
- style: {
355
- flex: 1
356
- }
357
- }
358
- )
359
- ]
360
- }
361
- )
362
- ]
363
- }
364
- );
365
- };
366
-
367
- // src/components/XFramesDemo/Icons/Icons.tsx
368
-
369
-
370
-
371
- var Icons = () => {
372
- const styleSheet2 = _react.useMemo.call(void 0,
373
- () => _common.RWStyleSheet.create({
374
- mainWrapperNode: {
375
- width: "100%",
376
- height: "auto",
377
- flexDirection: "row",
378
- flexWrap: "wrap",
379
- gap: { row: 5, column: 5 }
380
- },
381
- iconWrapperNode: {
382
- minWidth: 200,
383
- maxWidth: 240,
384
- flex: 1,
385
- height: 100,
386
- border: {
387
- color: "#000",
388
- thickness: 1
389
- },
390
- alignItems: "center"
391
- },
392
- icon: {
393
- font: { name: "roboto-regular", size: 48 }
394
- },
395
- iconKey: {
396
- font: { name: "roboto-mono-regular", size: 16 }
397
- }
398
- }),
399
- []
400
- );
401
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.mainWrapperNode, children: Object.keys(_common.faIconMap).map((key) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.iconWrapperNode, children: [
402
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
403
- XFrames.UnformattedText,
404
- {
405
- text: _common.faIconMap[key],
406
- style: styleSheet2.icon
407
- }
408
- ),
409
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { text: key, style: styleSheet2.iconKey })
410
- ] }, key)) });
411
- };
412
-
413
- // src/components/XFramesDemo/TextFields/TextFields.tsx
414
-
415
-
416
-
417
-
418
-
419
- var TextFields = () => {
420
- const [text, setText] = _react.useState.call(void 0, "Hello, world!");
421
- const handleInputTextChanged = _react.useCallback.call(void 0,
422
- (event) => {
423
- if (_optionalChain([event, 'optionalAccess', _ => _.nativeEvent])) {
424
- setText(String(_optionalChain([event, 'optionalAccess', _2 => _2.nativeEvent, 'access', _3 => _3.value])));
425
- }
426
- },
427
- []
428
- );
429
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { text: "test" }) });
430
- };
431
-
432
- // src/components/XFramesDemo/ClippedMultiLineTextRenderers/ClippedMultiLineTextRenderers.tsx
433
-
434
-
435
-
436
-
437
-
438
- var ClippedMultiLineTextRenderers = () => {
439
- const clippedMultiLineTextRendererRef = _react.useRef.call(void 0, null);
440
- const handleAppendTextToTextRenderer = _react.useCallback.call(void 0, () => {
441
- if (clippedMultiLineTextRendererRef.current) {
442
- clippedMultiLineTextRendererRef.current.appendTextToClippedMultiLineTextRenderer(
443
- `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
444
- `.repeat(
445
- 100
446
- )
447
- );
448
- }
449
- }, [clippedMultiLineTextRendererRef]);
450
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
451
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: { flexDirection: "row" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
452
- XFrames.Button,
453
- {
454
- onClick: handleAppendTextToTextRenderer,
455
- label: "Add text"
456
- }
457
- ) }),
458
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
459
- XFrames.ClippedMultiLineTextRenderer,
460
- {
461
- ref: clippedMultiLineTextRendererRef,
462
- style: { width: 400, height: 400 }
463
- }
464
- )
465
- ] });
466
- };
467
-
468
- // src/components/XFramesDemo/Sliders/Sliders.tsx
469
-
470
-
471
-
472
-
473
-
474
- var Sliders = () => {
475
- const [singleSliderValue, setSingleSliderValue] = _react.useState.call(void 0, 0);
476
- const [angleSliderValue, setAngleSliderValue] = _react.useState.call(void 0, 0);
477
- const [doubleSliderValue, setDoubleSliderValue] = _react.useState.call(void 0, [
478
- 0,
479
- 0
480
- ]);
481
- const [tripleSliderValue, setTripleSliderValue] = _react.useState.call(void 0, [0, 0, 0]);
482
- const [quadSliderValue, setQuadSliderValue] = _react.useState.call(void 0, [0, 0, 0, 0]);
483
- const handleSingleSliderValueChanged = _react.useCallback.call(void 0,
484
- (event) => {
485
- if (event.nativeEvent) {
486
- setSingleSliderValue(event.nativeEvent.value);
487
- }
488
- },
489
- []
490
- );
491
- const handleAngleSliderValueChanged = _react.useCallback.call(void 0,
492
- (event) => {
493
- if (event.nativeEvent) {
494
- setAngleSliderValue(event.nativeEvent.value);
495
- }
496
- },
497
- []
498
- );
499
- const handleDoubleSliderValueChanged = _react.useCallback.call(void 0,
500
- (event) => {
501
- if (event.nativeEvent) {
502
- setDoubleSliderValue([
503
- event.nativeEvent.values[0],
504
- event.nativeEvent.values[1]
505
- ]);
506
- }
507
- },
508
- []
509
- );
510
- const handleTripleSliderValueChanged = _react.useCallback.call(void 0,
511
- (event) => {
512
- if (event.nativeEvent) {
513
- setTripleSliderValue([
514
- event.nativeEvent.values[0],
515
- event.nativeEvent.values[1],
516
- event.nativeEvent.values[2]
517
- ]);
518
- }
519
- },
520
- []
521
- );
522
- const handleQuadSliderValueChanged = _react.useCallback.call(void 0,
523
- (event) => {
524
- if (event.nativeEvent) {
525
- setQuadSliderValue([
526
- event.nativeEvent.values[0],
527
- event.nativeEvent.values[1],
528
- event.nativeEvent.values[2],
529
- event.nativeEvent.values[3]
530
- ]);
531
- }
532
- },
533
- []
534
- );
535
- const styleSheet2 = _react.useMemo.call(void 0,
536
- () => _common.RWStyleSheet.create({
537
- wrapper: { flex: 1, gap: { row: 5 } },
538
- row: { alignItems: "center", flexDirection: "row", gap: { column: 5 } },
539
- label: {
540
- width: 150
541
- },
542
- slider: {
543
- width: 400
544
- },
545
- valueLabel: {
546
- width: 50
547
- }
548
- }),
549
- []
550
- );
551
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.wrapper, children: [
552
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.row, children: [
553
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { text: "Basic Slider", style: styleSheet2.label }),
554
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
555
- XFrames.Slider,
556
- {
557
- defaultValue: 0,
558
- min: 0,
559
- max: 10,
560
- style: styleSheet2.slider,
561
- onChange: handleSingleSliderValueChanged
562
- }
563
- ),
564
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
565
- XFrames.UnformattedText,
566
- {
567
- text: `Selected: ${singleSliderValue}`,
568
- style: styleSheet2.valueLabel
569
- }
570
- )
571
- ] }),
572
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.row, children: [
573
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
574
- XFrames.UnformattedText,
575
- {
576
- text: "Angle Slider (radians)",
577
- style: styleSheet2.label
578
- }
579
- ),
580
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
581
- XFrames.Slider,
582
- {
583
- defaultValue: 0,
584
- min: 0,
585
- max: 10,
586
- sliderType: "angle",
587
- onChange: handleAngleSliderValueChanged,
588
- style: styleSheet2.slider
589
- }
590
- ),
591
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
592
- XFrames.UnformattedText,
593
- {
594
- text: `Selected: ${angleSliderValue}`,
595
- style: styleSheet2.valueLabel
596
- }
597
- )
598
- ] }),
599
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.row, children: [
600
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
601
- XFrames.UnformattedText,
602
- {
603
- text: "Multi Slider, 2 values",
604
- style: styleSheet2.label
605
- }
606
- ),
607
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
608
- XFrames.MultiSlider,
609
- {
610
- defaultValues: [0, 0],
611
- min: 0,
612
- max: 10,
613
- numValues: 2,
614
- onChange: handleDoubleSliderValueChanged,
615
- style: styleSheet2.slider
616
- }
617
- ),
618
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
619
- XFrames.UnformattedText,
620
- {
621
- text: `Selected: ${doubleSliderValue[0]}, ${doubleSliderValue[1]}`,
622
- style: styleSheet2.valueLabel
623
- }
624
- )
625
- ] }),
626
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.row, children: [
627
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
628
- XFrames.UnformattedText,
629
- {
630
- text: "Multi Slider, 3 values",
631
- style: styleSheet2.label
632
- }
633
- ),
634
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
635
- XFrames.MultiSlider,
636
- {
637
- defaultValues: [0, 0, 0],
638
- min: 0,
639
- max: 10,
640
- numValues: 3,
641
- onChange: handleTripleSliderValueChanged,
642
- style: styleSheet2.slider
643
- }
644
- ),
645
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
646
- XFrames.UnformattedText,
647
- {
648
- text: `Selected: ${tripleSliderValue[0]}, ${tripleSliderValue[1]}, ${tripleSliderValue[2]}`,
649
- style: styleSheet2.valueLabel
650
- }
651
- )
652
- ] }),
653
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.row, children: [
654
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
655
- XFrames.UnformattedText,
656
- {
657
- text: "Multi Slider, 4 values",
658
- style: styleSheet2.label
659
- }
660
- ),
661
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
662
- XFrames.MultiSlider,
663
- {
664
- defaultValues: [0, 0, 0, 0],
665
- min: 0,
666
- max: 10,
667
- numValues: 4,
668
- onChange: handleQuadSliderValueChanged,
669
- style: styleSheet2.slider
670
- }
671
- ),
672
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
673
- XFrames.UnformattedText,
674
- {
675
- text: `Selected: ${quadSliderValue[0]}, ${quadSliderValue[1]}, ${quadSliderValue[2]}, ${quadSliderValue[3]}`,
676
- style: styleSheet2.valueLabel
677
- }
678
- )
679
- ] })
680
- ] });
681
- };
682
-
683
- // src/components/XFramesDemo/XFramesDemo.tsx
684
-
685
- var componentMap = {
686
- textField: TextFields,
687
- icons: Icons,
688
- images: Images,
689
- sliders: Sliders,
690
- maps: Maps,
691
- plots: Plots,
692
- tables: Tables,
693
- clippedMultiLineTextRenderers: ClippedMultiLineTextRenderers
694
- };
695
- var XFramesDemo = () => {
696
- const widgetRegistratonService = _common.useWidgetRegistrationService.call(void 0, );
697
- const [selectedItemIds, setSelectedItemIds] = _react.useState.call(void 0, [
698
- "plots"
699
- ]);
700
- const treeViewItems = _react.useMemo.call(void 0, () => {
701
- return [
702
- {
703
- itemId: "textField",
704
- label: "Text Field"
705
- },
706
- {
707
- itemId: "icons",
708
- label: "Icons"
709
- },
710
- {
711
- itemId: "images",
712
- label: "Images"
713
- },
714
- {
715
- itemId: "sliders",
716
- label: "Sliders"
717
- },
718
- {
719
- itemId: "maps",
720
- label: "Maps"
721
- },
722
- {
723
- itemId: "plots",
724
- label: "Plots"
725
- },
726
- {
727
- itemId: "tables",
728
- label: "Tables"
729
- },
730
- {
731
- itemId: "clippedMultiLineTextRenderers",
732
- label: "ClippedMultiLineTextRenderers"
733
- }
734
- ];
735
- }, []);
736
- const styleSheet2 = _react.useMemo.call(void 0,
737
- () => _common.RWStyleSheet.create({
738
- rootNode: {
739
- height: "100%",
740
- padding: {
741
- all: 10
742
- },
743
- gap: { row: 12 }
744
- },
745
- mainLayoutNode: {
746
- flex: 1,
747
- flexDirection: "row",
748
- gap: { column: 12 }
749
- },
750
- sidebarNode: {
751
- flexBasis: 200,
752
- height: "100%",
753
- border: {
754
- color: "#000",
755
- thickness: 1
756
- }
757
- },
758
- contentNode: {
759
- flex: 1,
760
- height: "100%",
761
- border: {
762
- color: "#000",
763
- thickness: 1
764
- },
765
- padding: { all: 5 }
766
- },
767
- title: {
768
- colors: { [_common.ImGuiCol.Text]: "#ff6e59" },
769
- font: { name: "roboto-regular", size: 24 }
770
- },
771
- debugButton: {
772
- positionType: "absolute",
773
- position: { right: 15, bottom: 15 },
774
- flexDirection: "row",
775
- gap: { column: 10 }
776
- }
777
- }),
778
- []
779
- );
780
- const debugModeBtnClicked = _react.useCallback.call(void 0, () => {
781
- widgetRegistratonService.setDebug(true);
782
- }, []);
783
- const onToggleItemSelection = _react.useCallback.call(void 0,
784
- (itemId, selected) => {
785
- setSelectedItemIds((selection) => {
786
- if (selected) {
787
- return [itemId];
788
- } else {
789
- return selection.filter((item) => item !== itemId);
790
- }
791
- });
792
- },
793
- []
794
- );
795
- const Component = componentMap[selectedItemIds[0]];
796
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { root: true, style: styleSheet2.rootNode, children: [
797
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
798
- XFrames.UnformattedText,
799
- {
800
- text: "XFrames bindings",
801
- style: styleSheet2.title
802
- }
803
- ),
804
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.mainLayoutNode, children: [
805
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.sidebarNode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
806
- XFrames.TreeView,
807
- {
808
- items: treeViewItems,
809
- selectedItemIds,
810
- onToggleItemSelection
811
- }
812
- ) }),
813
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.contentNode, cull: true, children: Component && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, {}) })
814
- ] }),
815
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.debugButton, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Button, { label: _common.faIconMap.bug, onClick: debugModeBtnClicked }) })
816
- ] });
817
- };
818
-
819
- // src/lib/ReactNativeWrapper.tsx
820
-
821
-
822
-
823
-
824
-
825
-
826
-
827
-
828
10
  var ReactFabricProd = _common.ReactFabricProdInitialiser.call(void 0, _common.ReactNativePrivateInterface);
829
11
  var ReactNativeWrapper = ({ wasmModule, children }) => {
830
12
  const widgetRegistrationServiceRef = _react.useRef.call(void 0,
@@ -936,7 +118,7 @@ var MainComponent = ({
936
118
  }, [canvasId, canvasRef, fonts, wasmModule, defaultFont, styleOverrides]);
937
119
  _react.useEffect.call(void 0, () => {
938
120
  if (wasmModule) {
939
- if (_optionalChain([containerRef, 'optionalAccess', _4 => _4.current])) {
121
+ if (_optionalChain([containerRef, 'optionalAccess', _ => _.current])) {
940
122
  try {
941
123
  wasmModule.resizeWindow(
942
124
  containerRef.current.clientWidth,
@@ -949,7 +131,7 @@ var MainComponent = ({
949
131
  }
950
132
  }, [wasmModule]);
951
133
  _react.useEffect.call(void 0, () => {
952
- if (wasmModule && _optionalChain([containerRef, 'optionalAccess', _5 => _5.current])) {
134
+ if (wasmModule && _optionalChain([containerRef, 'optionalAccess', _2 => _2.current])) {
953
135
  const resizeObserver = new ResizeObserver(
954
136
  _lodashdebounce2.default.call(void 0, () => {
955
137
  if (containerRef.current) {
@@ -982,1355 +164,7 @@ var XFrames = _common.attachSubComponents.call(void 0,
982
164
  _common.components
983
165
  );
984
166
 
985
- // src/components/TradingGuiDemo/TradingGuiDemo.tsx
986
-
987
-
988
-
989
-
990
-
991
-
992
-
993
- var _datefns = require('date-fns');
994
-
995
-
996
-
997
-
998
-
999
-
1000
-
1001
-
1002
- // node_modules/zustand/esm/vanilla.mjs
1003
- var createStoreImpl = (createState) => {
1004
- let state;
1005
- const listeners = /* @__PURE__ */ new Set();
1006
- const setState = (partial, replace) => {
1007
- const nextState = typeof partial === "function" ? partial(state) : partial;
1008
- if (!Object.is(nextState, state)) {
1009
- const previousState = state;
1010
- state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
1011
- listeners.forEach((listener) => listener(state, previousState));
1012
- }
1013
- };
1014
- const getState = () => state;
1015
- const getInitialState = () => initialState;
1016
- const subscribe = (listener) => {
1017
- listeners.add(listener);
1018
- return () => listeners.delete(listener);
1019
- };
1020
- const api = { setState, getState, getInitialState, subscribe };
1021
- const initialState = state = createState(setState, getState, api);
1022
- return api;
1023
- };
1024
- var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
1025
-
1026
- // node_modules/zustand/esm/react.mjs
1027
-
1028
- var identity = (arg) => arg;
1029
- function useStore(api, selector = identity) {
1030
- const slice = _react2.default.useSyncExternalStore(
1031
- api.subscribe,
1032
- () => selector(api.getState()),
1033
- () => selector(api.getInitialState())
1034
- );
1035
- _react2.default.useDebugValue(slice);
1036
- return slice;
1037
- }
1038
- var createImpl = (createState) => {
1039
- const api = createStore(createState);
1040
- const useBoundStore = (selector) => useStore(api, selector);
1041
- Object.assign(useBoundStore, api);
1042
- return useBoundStore;
1043
- };
1044
- var create = (createState) => createState ? createImpl(createState) : createImpl;
1045
-
1046
- // src/components/TradingGuiDemo/store.ts
1047
- var _rxjs = require('rxjs');
1048
-
1049
- // src/components/TradingGuiDemo/cryptoSymbols.ts
1050
- var cryptoSymbols = [
1051
- "SUSHI/USD",
1052
- "YFI/USD",
1053
- "LTC/USD",
1054
- "DOGE/USD",
1055
- "BCH/USDT",
1056
- "BAT/USDC",
1057
- "BAT/USD",
1058
- "CRV/USDC",
1059
- "SHIB/USDT",
1060
- "BCH/USDC",
1061
- "LINK/USDT",
1062
- "LINK/USDC",
1063
- "BCH/USD",
1064
- "CRV/USD",
1065
- "AVAX/USDT",
1066
- "LTC/USDT",
1067
- "XTZ/USDC",
1068
- "BTC/USDT",
1069
- "AVAX/USDC",
1070
- "XTZ/USD"
1071
- // "AVAX/USD",
1072
- // "LTC/USDC",
1073
- // "LINK/USD",
1074
- // "LINK/BTC",
1075
- // "SHIB/USDC",
1076
- // "SOL/USDC",
1077
- // "GRT/USDC",
1078
- // "USDT/USDC",
1079
- // "SOL/USD",
1080
- // "SOL/USDT",
1081
- // "SHIB/USD",
1082
- // "DOGE/USDC",
1083
- // "GRT/USD",
1084
- // "ETH/USDT",
1085
- // "USDT/USD",
1086
- // "ETH/USDC",
1087
- // "LTC/BTC",
1088
- // "AAVE/USDT",
1089
- // "ETH/USD",
1090
- // "UNI/USDT",
1091
- // "ETH/BTC",
1092
- // "BCH/BTC",
1093
- // "USDC/USD",
1094
- // "YFI/USDT",
1095
- // "UNI/USDC",
1096
- // "DOT/USDC",
1097
- // "DOT/USD",
1098
- // "AAVE/USD",
1099
- // "MKR/USDC",
1100
- // "UNI/USD",
1101
- // "AAVE/USDC",
1102
- // "UNI/BTC",
1103
- // "SUSHI/USDT",
1104
- // "BTC/USDC",
1105
- // "BTC/USD",
1106
- // "SUSHI/USDC",
1107
- // "YFI/USDC",
1108
- // "MKR/USD",
1109
- // "DOGE/USDT",
1110
- ];
1111
-
1112
- // src/components/TradingGuiDemo/store.ts
1113
- var cryptoQuoteSubjectMap$ = new (0, _rxjs.BehaviorSubject)(/* @__PURE__ */ new Map());
1114
- var emptyCryptoQuote = Object.freeze({
1115
- Timestamp: "",
1116
- BidPrice: 0,
1117
- BidSize: 0,
1118
- AskPrice: 0,
1119
- AskSize: 0
1120
- });
1121
- var useStore2 = create((set) => ({
1122
- cryptoAssets: [],
1123
- symbols: cryptoSymbols,
1124
- selectedTabIndex: 0,
1125
- setCryptoAssets: (cryptoAssets) => set(() => ({ cryptoAssets })),
1126
- setSelectedTabIndex: (index) => set(() => ({ selectedTabIndex: index }))
1127
- }));
1128
-
1129
- // src/components/TradingGuiDemo/CryptoPlots/CryptoLinePlot.tsx
1130
-
1131
-
1132
-
1133
-
1134
-
1135
-
1136
-
1137
- // src/components/TradingGuiDemo/dataServiceContext.tsx
1138
-
1139
- var DataServiceContext = _react.createContext.call(void 0, null);
1140
- var useDataService = () => {
1141
- const context = _react.useContext.call(void 0, DataServiceContext);
1142
- if (context) {
1143
- return context;
1144
- }
1145
- throw new Error("DataServiceContext initialisation failed");
1146
- };
1147
-
1148
- // src/components/TradingGuiDemo/CryptoPlots/CryptoLinePlot.tsx
1149
-
1150
- var CryptoLinePlot = ({ symbol }) => {
1151
- const dataService2 = useDataService();
1152
- const plotRef = _react.useRef.call(void 0, null);
1153
- _react.useEffect.call(void 0, () => {
1154
- const subscription = dataService2.getCryptoQuotes().pipe(_rxjs.filter.call(void 0, (cryptoQuote) => cryptoQuote.S === symbol)).subscribe((quote) => {
1155
- if (plotRef.current) {
1156
- const date = new Date(quote.Timestamp);
1157
- plotRef.current.appendData(Number(date) / 1e3, quote.BidPrice);
1158
- }
1159
- });
1160
- return () => {
1161
- subscription.unsubscribe();
1162
- };
1163
- }, [dataService2]);
1164
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1165
- XFrames.PlotLine,
1166
- {
1167
- xAxisScale: _common.ImPlotScale.Time,
1168
- ref: plotRef,
1169
- style: { width: "100%", height: 400 }
1170
- }
1171
- );
1172
- };
1173
-
1174
- // src/components/TradingGuiDemo/CryptoPlots/CryptoLinePlots.tsx
1175
-
1176
- var CryptoLinePlots = ({}) => {
1177
- const symbols = useStore2((state) => state.symbols);
1178
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1179
- XFrames.Node,
1180
- {
1181
- style: {
1182
- width: "100%",
1183
- height: "100%",
1184
- flexDirection: "column",
1185
- gap: { row: 5 }
1186
- },
1187
- children: symbols.map((sym) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CryptoLinePlot, { symbol: sym }, sym))
1188
- }
1189
- );
1190
- };
1191
-
1192
- // src/components/TradingGuiDemo/CryptoAssetsList/CryptoAssetsList.tsx
1193
-
1194
-
1195
- var CryptoAssetsList = ({}) => {
1196
- const dataService2 = useDataService();
1197
- const tableRef = _react.useRef.call(void 0, null);
1198
- const tableColumns = _react.useMemo.call(void 0,
1199
- () => [
1200
- {
1201
- heading: "Symbol",
1202
- fieldId: "symbol"
1203
- },
1204
- {
1205
- heading: "ASK",
1206
- fieldId: "askPrice"
1207
- },
1208
- {
1209
- heading: "Change",
1210
- fieldId: "askChange"
1211
- },
1212
- {
1213
- heading: "BID",
1214
- fieldId: "bidPrice"
1215
- },
1216
- {
1217
- heading: "Change",
1218
- fieldId: "bidChange"
1219
- }
1220
- ],
1221
- []
1222
- );
1223
- _react.useEffect.call(void 0, () => {
1224
- const subscription = dataService2.getCryptoSnapshots().subscribe((snapshots) => {
1225
- const data = Object.entries(snapshots).map(([symbol, snapshot]) => ({
1226
- symbol,
1227
- askPrice: snapshot.LatestQuote.AskPrice.toFixed(6),
1228
- bidPrice: snapshot.LatestQuote.BidPrice.toFixed(6),
1229
- // todo: totally unsure here
1230
- askChange: (snapshot.LatestQuote.AskPrice - snapshot.DailyBar.Open).toFixed(6),
1231
- bidChange: (snapshot.LatestQuote.BidPrice - snapshot.DailyBar.Open).toFixed(6)
1232
- }));
1233
- data.sort((a, b) => {
1234
- if (a.symbol < b.symbol) {
1235
- return -1;
1236
- } else if (a.symbol > b.symbol) {
1237
- return 1;
1238
- }
1239
- return 0;
1240
- });
1241
- _optionalChain([tableRef, 'access', _6 => _6.current, 'optionalAccess', _7 => _7.setTableData, 'call', _8 => _8(data)]);
1242
- });
1243
- return () => {
1244
- subscription.unsubscribe();
1245
- };
1246
- }, [dataService2]);
1247
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Table, { ref: tableRef, columns: tableColumns });
1248
- };
1249
-
1250
- // src/components/TradingGuiDemo/dataService.ts
1251
-
1252
- var DataService = class {
1253
-
1254
-
1255
-
1256
- constructor() {
1257
- this.cryptoQuotes = new (0, _rxjs.ReplaySubject)(1e5);
1258
- this.cryptoSnapshots = new (0, _rxjs.ReplaySubject)(1e5);
1259
- this.cryptoBarDatasets = new (0, _rxjs.ReplaySubject)(1e5);
1260
- }
1261
- addCryptoQuote(cryptoQuote) {
1262
- this.cryptoQuotes.next(cryptoQuote);
1263
- }
1264
- addCryptoSnapshots(cryptoSnapshots) {
1265
- this.cryptoSnapshots.next(cryptoSnapshots);
1266
- }
1267
- addCryptoBars(cryptoBarDataset) {
1268
- this.cryptoBarDatasets.next(cryptoBarDataset);
1269
- }
1270
- getCryptoQuotes() {
1271
- return this.cryptoQuotes.asObservable();
1272
- }
1273
- getCryptoSnapshots() {
1274
- return this.cryptoSnapshots.asObservable();
1275
- }
1276
- getCryptoBarDatasets() {
1277
- return this.cryptoBarDatasets.asObservable();
1278
- }
1279
- };
1280
-
1281
- // src/components/TradingGuiDemo/CryptoAssetPanels/CryptoAssetPanels.tsx
1282
-
1283
-
1284
-
1285
- // src/components/TradingGuiDemo/CryptoQuotePrice/CryptoQuotePrice.tsx
1286
-
1287
-
1288
-
1289
-
1290
- // src/themes.ts
1291
-
1292
- var theme1Colors = {
1293
- black: "#1a1a1a",
1294
- darkGrey: "#5a5a5a",
1295
- grey: "#9a9a9a",
1296
- lightGrey: "#bebebe",
1297
- veryLightGrey: "#e5e5e5",
1298
- superLightGrey: "#f7f7f7",
1299
- white: "#fff",
1300
- hero: "#ff6e59",
1301
- hoverHero: "#ff4a30"
1302
- };
1303
- var theme1 = {
1304
- // frameBorderSize: 1,
1305
- // framePadding: [0, 0],
1306
- colors: {
1307
- [_common.ImGuiCol.Text]: [theme1Colors.black, 1],
1308
- [_common.ImGuiCol.TextDisabled]: [theme1Colors.darkGrey, 1],
1309
- [_common.ImGuiCol.WindowBg]: [theme1Colors.white, 1],
1310
- [_common.ImGuiCol.ChildBg]: [theme1Colors.white, 1],
1311
- [_common.ImGuiCol.PopupBg]: [theme1Colors.white, 1],
1312
- [_common.ImGuiCol.Border]: [theme1Colors.darkGrey, 1],
1313
- [_common.ImGuiCol.BorderShadow]: [theme1Colors.black, 1],
1314
- [_common.ImGuiCol.FrameBg]: [theme1Colors.veryLightGrey, 1],
1315
- [_common.ImGuiCol.FrameBgHovered]: [theme1Colors.lightGrey, 1],
1316
- [_common.ImGuiCol.FrameBgActive]: [theme1Colors.grey, 1],
1317
- [_common.ImGuiCol.TitleBg]: [theme1Colors.lightGrey, 1],
1318
- [_common.ImGuiCol.TitleBgActive]: [theme1Colors.grey, 1],
1319
- [_common.ImGuiCol.TitleBgCollapsed]: [theme1Colors.veryLightGrey, 1],
1320
- [_common.ImGuiCol.MenuBarBg]: [theme1Colors.grey, 1],
1321
- [_common.ImGuiCol.ScrollbarBg]: [theme1Colors.veryLightGrey, 1],
1322
- [_common.ImGuiCol.ScrollbarGrab]: [theme1Colors.grey, 1],
1323
- [_common.ImGuiCol.ScrollbarGrabHovered]: [theme1Colors.darkGrey, 1],
1324
- [_common.ImGuiCol.ScrollbarGrabActive]: [theme1Colors.black, 1],
1325
- [_common.ImGuiCol.CheckMark]: [theme1Colors.black, 1],
1326
- [_common.ImGuiCol.SliderGrab]: [theme1Colors.grey, 1],
1327
- [_common.ImGuiCol.SliderGrabActive]: [theme1Colors.darkGrey, 1],
1328
- [_common.ImGuiCol.Button]: [theme1Colors.lightGrey, 1],
1329
- [_common.ImGuiCol.ButtonHovered]: [theme1Colors.grey, 1],
1330
- [_common.ImGuiCol.ButtonActive]: [theme1Colors.darkGrey, 1],
1331
- [_common.ImGuiCol.Header]: [theme1Colors.veryLightGrey, 1],
1332
- [_common.ImGuiCol.HeaderHovered]: [theme1Colors.lightGrey, 1],
1333
- [_common.ImGuiCol.HeaderActive]: [theme1Colors.grey, 1],
1334
- [_common.ImGuiCol.Separator]: [theme1Colors.black, 1],
1335
- [_common.ImGuiCol.SeparatorHovered]: [theme1Colors.veryLightGrey, 1],
1336
- [_common.ImGuiCol.SeparatorActive]: [theme1Colors.lightGrey, 1],
1337
- [_common.ImGuiCol.ResizeGrip]: [theme1Colors.veryLightGrey, 1],
1338
- [_common.ImGuiCol.ResizeGripHovered]: [theme1Colors.lightGrey, 1],
1339
- [_common.ImGuiCol.ResizeGripActive]: [theme1Colors.grey, 1],
1340
- [_common.ImGuiCol.Tab]: [theme1Colors.veryLightGrey, 1],
1341
- [_common.ImGuiCol.TabHovered]: [theme1Colors.lightGrey, 1],
1342
- [_common.ImGuiCol.TabActive]: [theme1Colors.grey, 1],
1343
- [_common.ImGuiCol.TabUnfocused]: [theme1Colors.veryLightGrey, 1],
1344
- [_common.ImGuiCol.TabUnfocusedActive]: [theme1Colors.lightGrey, 1],
1345
- [_common.ImGuiCol.PlotLines]: [theme1Colors.grey, 1],
1346
- [_common.ImGuiCol.PlotLinesHovered]: [theme1Colors.darkGrey, 1],
1347
- [_common.ImGuiCol.PlotHistogram]: [theme1Colors.grey, 1],
1348
- [_common.ImGuiCol.PlotHistogramHovered]: [theme1Colors.darkGrey, 1],
1349
- [_common.ImGuiCol.TableHeaderBg]: [theme1Colors.grey, 1],
1350
- [_common.ImGuiCol.TableBorderStrong]: [theme1Colors.darkGrey, 1],
1351
- [_common.ImGuiCol.TableBorderLight]: [theme1Colors.lightGrey, 1],
1352
- [_common.ImGuiCol.TableRowBg]: [theme1Colors.veryLightGrey, 1],
1353
- [_common.ImGuiCol.TableRowBgAlt]: [theme1Colors.white, 1],
1354
- [_common.ImGuiCol.TextSelectedBg]: [theme1Colors.grey, 1],
1355
- [_common.ImGuiCol.DragDropTarget]: [theme1Colors.grey, 1],
1356
- [_common.ImGuiCol.NavHighlight]: [theme1Colors.grey, 1],
1357
- [_common.ImGuiCol.NavWindowingHighlight]: [theme1Colors.grey, 1],
1358
- [_common.ImGuiCol.NavWindowingDimBg]: [theme1Colors.grey, 1],
1359
- [_common.ImGuiCol.ModalWindowDimBg]: [theme1Colors.grey, 1]
1360
- }
1361
- };
1362
- var theme2Colors = {
1363
- darkestGrey: "#141f2c",
1364
- darkerGrey: "#2a2e39",
1365
- darkGrey: "#363b4a",
1366
- lightGrey: "#5a5a5a",
1367
- lighterGrey: "#7A818C",
1368
- evenLighterGrey: "#8491a3",
1369
- black: "#0A0B0D",
1370
- green: "#75f986",
1371
- red: "#ff0062",
1372
- white: "#fff"
1373
- };
1374
- var theme2 = {
1375
- // frameBorderSize: 1,
1376
- // framePadding: [0, 0],
1377
- colors: {
1378
- [_common.ImGuiCol.Text]: [theme2Colors.white, 1],
1379
- [_common.ImGuiCol.TextDisabled]: [theme2Colors.lighterGrey, 1],
1380
- [_common.ImGuiCol.WindowBg]: [theme2Colors.black, 1],
1381
- [_common.ImGuiCol.ChildBg]: [theme2Colors.black, 1],
1382
- [_common.ImGuiCol.PopupBg]: [theme2Colors.white, 1],
1383
- [_common.ImGuiCol.Border]: [theme2Colors.lightGrey, 1],
1384
- [_common.ImGuiCol.BorderShadow]: [theme2Colors.darkestGrey, 1],
1385
- [_common.ImGuiCol.FrameBg]: [theme2Colors.black, 1],
1386
- [_common.ImGuiCol.FrameBgHovered]: [theme2Colors.darkerGrey, 1],
1387
- //
1388
- [_common.ImGuiCol.FrameBgActive]: [theme2Colors.lightGrey, 1],
1389
- [_common.ImGuiCol.TitleBg]: [theme2Colors.lightGrey, 1],
1390
- [_common.ImGuiCol.TitleBgActive]: [theme2Colors.darkerGrey, 1],
1391
- //
1392
- [_common.ImGuiCol.TitleBgCollapsed]: [theme2Colors.lightGrey, 1],
1393
- [_common.ImGuiCol.MenuBarBg]: [theme2Colors.lightGrey, 1],
1394
- [_common.ImGuiCol.ScrollbarBg]: [theme2Colors.darkerGrey, 1],
1395
- //
1396
- [_common.ImGuiCol.ScrollbarGrab]: [theme2Colors.darkerGrey, 1],
1397
- //
1398
- [_common.ImGuiCol.ScrollbarGrabHovered]: [theme2Colors.lightGrey, 1],
1399
- [_common.ImGuiCol.ScrollbarGrabActive]: [theme2Colors.darkestGrey, 1],
1400
- [_common.ImGuiCol.CheckMark]: [theme2Colors.darkestGrey, 1],
1401
- [_common.ImGuiCol.SliderGrab]: [theme2Colors.darkerGrey, 1],
1402
- //
1403
- [_common.ImGuiCol.SliderGrabActive]: [theme2Colors.lightGrey, 1],
1404
- [_common.ImGuiCol.Button]: [theme2Colors.black, 1],
1405
- [_common.ImGuiCol.ButtonHovered]: [theme2Colors.darkerGrey, 1],
1406
- //
1407
- [_common.ImGuiCol.ButtonActive]: [theme2Colors.black, 1],
1408
- [_common.ImGuiCol.Header]: [theme2Colors.black, 1],
1409
- [_common.ImGuiCol.HeaderHovered]: [theme2Colors.black, 1],
1410
- [_common.ImGuiCol.HeaderActive]: [theme2Colors.lightGrey, 1],
1411
- [_common.ImGuiCol.Separator]: [theme2Colors.darkestGrey, 1],
1412
- [_common.ImGuiCol.SeparatorHovered]: [theme2Colors.lightGrey, 1],
1413
- [_common.ImGuiCol.SeparatorActive]: [theme2Colors.lightGrey, 1],
1414
- [_common.ImGuiCol.ResizeGrip]: [theme2Colors.black, 1],
1415
- [_common.ImGuiCol.ResizeGripHovered]: [theme2Colors.lightGrey, 1],
1416
- [_common.ImGuiCol.ResizeGripActive]: [theme2Colors.darkerGrey, 1],
1417
- //
1418
- [_common.ImGuiCol.Tab]: [theme2Colors.black, 1],
1419
- [_common.ImGuiCol.TabHovered]: [theme2Colors.darkerGrey, 1],
1420
- //
1421
- [_common.ImGuiCol.TabActive]: [theme2Colors.lightGrey, 1],
1422
- [_common.ImGuiCol.TabUnfocused]: [theme2Colors.black, 1],
1423
- [_common.ImGuiCol.TabUnfocusedActive]: [theme2Colors.lightGrey, 1],
1424
- [_common.ImGuiCol.PlotLines]: [theme2Colors.darkerGrey, 1],
1425
- //
1426
- [_common.ImGuiCol.PlotLinesHovered]: [theme2Colors.lightGrey, 1],
1427
- [_common.ImGuiCol.PlotHistogram]: [theme2Colors.darkerGrey, 1],
1428
- //
1429
- [_common.ImGuiCol.PlotHistogramHovered]: [theme2Colors.lightGrey, 1],
1430
- [_common.ImGuiCol.TableHeaderBg]: [theme2Colors.black, 1],
1431
- [_common.ImGuiCol.TableBorderStrong]: [theme2Colors.lightGrey, 1],
1432
- [_common.ImGuiCol.TableBorderLight]: [theme2Colors.darkerGrey, 1],
1433
- [_common.ImGuiCol.TableRowBg]: [theme2Colors.darkGrey, 1],
1434
- [_common.ImGuiCol.TableRowBgAlt]: [theme2Colors.darkerGrey, 1],
1435
- [_common.ImGuiCol.TextSelectedBg]: [theme2Colors.darkerGrey, 1],
1436
- //
1437
- [_common.ImGuiCol.DragDropTarget]: [theme2Colors.darkerGrey, 1],
1438
- //
1439
- [_common.ImGuiCol.NavHighlight]: [theme2Colors.darkerGrey, 1],
1440
- //
1441
- [_common.ImGuiCol.NavWindowingHighlight]: [theme2Colors.darkerGrey, 1],
1442
- //
1443
- [_common.ImGuiCol.NavWindowingDimBg]: [theme2Colors.darkerGrey, 1],
1444
- //
1445
- [_common.ImGuiCol.ModalWindowDimBg]: [theme2Colors.darkerGrey, 1]
1446
- //
1447
- }
1448
- };
1449
-
1450
- // src/components/TradingGuiDemo/CryptoQuotePrice/CryptoQuotePrice.tsx
1451
-
1452
- var CryptoQuotePrice = ({ symbol }) => {
1453
- const [data, setData] = _react.useState.call(void 0, {
1454
- lastUpdated: "n/a"
1455
- });
1456
- const dataService2 = useDataService();
1457
- _react.useEffect.call(void 0, () => {
1458
- const subscription = dataService2.getCryptoQuotes().pipe(_rxjs.filter.call(void 0, (cryptoQuote) => cryptoQuote.S === symbol)).subscribe((quote) => {
1459
- const newData = {
1460
- quote,
1461
- lastUpdated: "n/a"
1462
- };
1463
- setData((oldData) => {
1464
- return newData;
1465
- });
1466
- });
1467
- return () => {
1468
- subscription.unsubscribe();
1469
- };
1470
- }, [dataService2]);
1471
- const styleSheet2 = _react.useMemo.call(void 0,
1472
- () => _common.RWStyleSheet.create({
1473
- pricesWrapper: {
1474
- alignSelf: "center",
1475
- flexDirection: "row",
1476
- gap: { column: 5 }
1477
- },
1478
- price: {
1479
- width: 100,
1480
- height: "auto",
1481
- // borderColor: "#000",
1482
- // borderThickness: 1,
1483
- alignItems: "center"
1484
- },
1485
- ask: {
1486
- colors: {
1487
- [_common.ImGuiCol.Text]: theme2Colors.red
1488
- }
1489
- },
1490
- bid: {
1491
- colors: {
1492
- [_common.ImGuiCol.Text]: theme2Colors.green
1493
- }
1494
- }
1495
- }),
1496
- []
1497
- );
1498
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.pricesWrapper, children: [
1499
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.price, children: [
1500
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { text: "ASK", style: styleSheet2.ask }),
1501
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1502
- XFrames.UnformattedText,
1503
- {
1504
- text: typeof _optionalChain([data, 'optionalAccess', _9 => _9.quote, 'optionalAccess', _10 => _10.AskPrice]) === "number" ? _optionalChain([data, 'optionalAccess', _11 => _11.quote, 'optionalAccess', _12 => _12.AskPrice, 'access', _13 => _13.toFixed, 'call', _14 => _14(6)]) : "n/a",
1505
- style: styleSheet2.ask
1506
- }
1507
- )
1508
- ] }),
1509
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.price, children: [
1510
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { text: "BID", style: styleSheet2.bid }),
1511
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1512
- XFrames.UnformattedText,
1513
- {
1514
- text: typeof _optionalChain([data, 'optionalAccess', _15 => _15.quote, 'optionalAccess', _16 => _16.BidPrice]) === "number" ? _optionalChain([data, 'optionalAccess', _17 => _17.quote, 'optionalAccess', _18 => _18.BidPrice, 'access', _19 => _19.toFixed, 'call', _20 => _20(6)]) : "n/a",
1515
- style: styleSheet2.bid
1516
- }
1517
- )
1518
- ] })
1519
- ] }) });
1520
- };
1521
-
1522
- // src/components/TradingGuiDemo/CryptoAssetPanels/CryptoAssetPanels.tsx
1523
-
1524
- var CryptoAssetPanels = ({}) => {
1525
- const cryptoAssets = useStore2(
1526
- (state) => state.cryptoAssets.sort((a, b) => {
1527
- if (a.symbol < b.symbol) {
1528
- return -1;
1529
- } else if (a.symbol > b.symbol) {
1530
- return 1;
1531
- }
1532
- return 0;
1533
- })
1534
- );
1535
- const styleSheet2 = _react.useMemo.call(void 0,
1536
- () => _common.RWStyleSheet.create({
1537
- mainWrapperNode: {
1538
- width: "100%",
1539
- height: "auto",
1540
- flexDirection: "row",
1541
- flexWrap: "wrap",
1542
- gap: { row: 5, column: 5 }
1543
- },
1544
- asset: {
1545
- minWidth: 200,
1546
- maxWidth: 240,
1547
- flex: 1,
1548
- height: "auto",
1549
- border: {
1550
- color: "#000",
1551
- thickness: 1
1552
- },
1553
- alignItems: "center",
1554
- padding: { vertical: 5 },
1555
- gap: { row: 5 }
1556
- },
1557
- symbol: {
1558
- font: { name: "roboto-regular", size: 24 }
1559
- }
1560
- }),
1561
- []
1562
- );
1563
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.mainWrapperNode, children: cryptoAssets.map((asset) => {
1564
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.asset, children: [
1565
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1566
- XFrames.UnformattedText,
1567
- {
1568
- style: styleSheet2.symbol,
1569
- text: asset.symbol
1570
- }
1571
- ),
1572
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CryptoQuotePrice, { symbol: asset.symbol })
1573
- ] }, asset.id);
1574
- }) });
1575
- };
1576
-
1577
- // src/components/TradingGuiDemo/CryptoPlots/CryptoCandlestickPlot.tsx
1578
-
1579
-
1580
-
1581
- var CryptoCandlestickPlot = ({ symbol }) => {
1582
- const dataService2 = useDataService();
1583
- const plotRef = _react.useRef.call(void 0, null);
1584
- _react.useEffect.call(void 0, () => {
1585
- const subscription = dataService2.getCryptoBarDatasets().pipe(_rxjs.map.call(void 0, (cryptoBars) => cryptoBars[symbol])).subscribe((cryptoBarsForSymbol) => {
1586
- if (plotRef.current) {
1587
- const data = cryptoBarsForSymbol.map(
1588
- (cryptoBar) => ({
1589
- date: Number(new Date(cryptoBar.Timestamp)) / 1e3,
1590
- open: cryptoBar.Open,
1591
- close: cryptoBar.Close,
1592
- high: cryptoBar.High,
1593
- low: cryptoBar.Low
1594
- })
1595
- );
1596
- plotRef.current.setData(data);
1597
- }
1598
- });
1599
- return () => {
1600
- subscription.unsubscribe();
1601
- };
1602
- }, [dataService2]);
1603
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1604
- XFrames.PlotCandlestick,
1605
- {
1606
- ref: plotRef,
1607
- style: { width: "100%", height: 400 }
1608
- }
1609
- );
1610
- };
1611
-
1612
- // src/components/TradingGuiDemo/CryptoPlots/CryptoCandlestickPlots.tsx
1613
-
1614
- var CryptoCandlestickPlots = ({}) => {
1615
- const symbols = useStore2((state) => state.symbols);
1616
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1617
- XFrames.Node,
1618
- {
1619
- style: {
1620
- width: "100%",
1621
- height: "100%",
1622
- flexDirection: "column",
1623
- gap: { row: 5 }
1624
- },
1625
- children: symbols.map((sym) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CryptoCandlestickPlot, { symbol: sym }, sym))
1626
- }
1627
- );
1628
- };
1629
-
1630
- // src/components/TradingGuiDemo/Sidebar/Sidebar.tsx
1631
-
1632
-
1633
-
1634
-
1635
-
1636
-
1637
-
1638
-
1639
-
1640
-
1641
- var Sidebar = () => {
1642
- const styleSheet2 = _react.useMemo.call(void 0,
1643
- () => _common.RWStyleSheet.create({
1644
- sidebarNode: {
1645
- flexBasis: 60,
1646
- height: "100%",
1647
- border: {
1648
- color: "#1B1D20",
1649
- thickness: 1
1650
- }
1651
- },
1652
- sideBarItem: {
1653
- width: 58,
1654
- height: 58,
1655
- justifyContent: "center",
1656
- alignItems: "center"
1657
- },
1658
- logo: {
1659
- font: { name: "roboto-regular", size: 36 }
1660
- },
1661
- icon: {
1662
- width: 48,
1663
- height: 48,
1664
- font: { name: "roboto-regular", size: 36 },
1665
- colors: {
1666
- [_common.ImGuiCol.ButtonHovered]: "#001033",
1667
- [_common.ImGuiCol.ButtonActive]: "#001033"
1668
- },
1669
- vars: { [_common.ImGuiStyleVar.FrameRounding]: 24 }
1670
- },
1671
- iconActive: {
1672
- width: 48,
1673
- height: 48,
1674
- font: { name: "roboto-regular", size: 36 },
1675
- vars: { [_common.ImGuiStyleVar.FrameRounding]: 24 },
1676
- colors: {
1677
- [_common.ImGuiCol.Text]: "#588AF5",
1678
- [_common.ImGuiCol.Button]: "#001033",
1679
- [_common.ImGuiCol.ButtonHovered]: "#001033",
1680
- [_common.ImGuiCol.ButtonActive]: "#001033"
1681
- }
1682
- }
1683
- }),
1684
- []
1685
- );
1686
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.sidebarNode, children: [
1687
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.sideBarItem, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1688
- XFrames.UnformattedText,
1689
- {
1690
- text: _common.faIconMap.otter,
1691
- style: styleSheet2.logo
1692
- }
1693
- ) }),
1694
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.sideBarItem, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1695
- XFrames.Button,
1696
- {
1697
- label: _common.faIconMap["arrow-trend-up"],
1698
- style: styleSheet2.iconActive,
1699
- hoverStyle: styleSheet2.iconActive
1700
- }
1701
- ) }),
1702
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.sideBarItem, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1703
- XFrames.Button,
1704
- {
1705
- label: _common.faIconMap["wallet"],
1706
- style: styleSheet2.icon,
1707
- hoverStyle: styleSheet2.iconActive
1708
- }
1709
- ) }),
1710
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.sideBarItem, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1711
- XFrames.Button,
1712
- {
1713
- label: _common.faIconMap["chart-pie"],
1714
- style: styleSheet2.icon,
1715
- hoverStyle: styleSheet2.iconActive
1716
- }
1717
- ) })
1718
- ] });
1719
- };
1720
-
1721
- // src/components/TradingGuiDemo/CryptoSymbolBlock/CryptoSymbolBlock.tsx
1722
-
1723
-
1724
-
1725
- // src/components/TradingGuiDemo/CryptoSymbolPairs/CryptoSymbolPair.tsx
1726
-
1727
-
1728
-
1729
- var CryptoSymbolPair = ({ symbol }) => {
1730
- const styleSheet2 = _react.useMemo.call(void 0,
1731
- () => _common.RWStyleSheet.create({
1732
- symbolLogoPair: {
1733
- flexDirection: "row"
1734
- },
1735
- symbolLogoLeft: {
1736
- width: 24,
1737
- height: 24
1738
- },
1739
- symbolLogoRight: {
1740
- width: 24,
1741
- height: 24,
1742
- position: { left: -5 }
1743
- // todo: doesn't this need absolute positioning?
1744
- }
1745
- }),
1746
- []
1747
- );
1748
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.symbolLogoPair, children: [
1749
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1750
- XFrames.Image,
1751
- {
1752
- url: "https://res.cloudinary.com/dep2io067/image/upload/c_thumb,w_24,g_face/v1728466838/bitcoin-btc-logo_gqud0f.png",
1753
- style: styleSheet2.symbolLogoLeft
1754
- }
1755
- ),
1756
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1757
- XFrames.Image,
1758
- {
1759
- url: "https://res.cloudinary.com/dep2io067/image/upload/c_thumb,w_200,g_face/v1728468387/77-771550_dollar-currency-money-finance-usd-us-dollar-dollar_apzzg2.png",
1760
- style: styleSheet2.symbolLogoRight
1761
- }
1762
- )
1763
- ] });
1764
- };
1765
-
1766
- // src/components/TradingGuiDemo/CryptoSymbolBlock/CryptoSymbolBlock.tsx
1767
-
1768
- var CryptoSymbolBlock = ({ symbol }) => {
1769
- const price = "40,730.00";
1770
- const currency = "USD";
1771
- const trend = "(+2.50%)";
1772
- const styleSheet2 = _react.useMemo.call(void 0,
1773
- () => _common.RWStyleSheet.create({
1774
- block: {
1775
- flexDirection: "row",
1776
- padding: {
1777
- // horizontal: 2,
1778
- vertical: 8
1779
- },
1780
- gap: { column: 5 }
1781
- // borderColor: "#fff",
1782
- // borderThickness: 1,
1783
- },
1784
- symbolLogos: {
1785
- width: 60,
1786
- height: 40,
1787
- alignItems: "center",
1788
- justifyContent: "center"
1789
- },
1790
- info: {
1791
- gap: { row: 5 }
1792
- },
1793
- priceRow: {
1794
- flexDirection: "row",
1795
- gap: { column: 2 }
1796
- },
1797
- symbol: {
1798
- font: { name: "roboto-bold", size: 16 },
1799
- colors: { [_common.ImGuiCol.Text]: "#A9B5C0" }
1800
- },
1801
- price: {
1802
- font: { name: "roboto-bold", size: 20 },
1803
- colors: { [_common.ImGuiCol.Text]: "#D9D9D9" }
1804
- },
1805
- currency: {
1806
- font: { name: "roboto-bold", size: 20 },
1807
- colors: { [_common.ImGuiCol.Text]: "#A9B5C0" }
1808
- },
1809
- trend: {
1810
- font: { name: "roboto-bold", size: 20 },
1811
- colors: { [_common.ImGuiCol.Text]: "#239465" }
1812
- }
1813
- }),
1814
- []
1815
- );
1816
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.block, children: [
1817
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.symbolLogos, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CryptoSymbolPair, { symbol }) }),
1818
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.info, children: [
1819
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { style: styleSheet2.symbol, text: symbol }),
1820
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.priceRow, children: [
1821
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { style: styleSheet2.price, text: price }),
1822
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1823
- XFrames.UnformattedText,
1824
- {
1825
- style: styleSheet2.currency,
1826
- text: currency
1827
- }
1828
- ),
1829
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { style: styleSheet2.trend, text: trend })
1830
- ] })
1831
- ] })
1832
- ] });
1833
- };
1834
-
1835
- // src/components/TradingGuiDemo/Tabs/Tabs.tsx
1836
-
1837
-
1838
-
1839
-
1840
-
1841
- var Tabs = ({
1842
- tabs,
1843
- selectedTabIndex,
1844
- onSelectedTabChange
1845
- }) => {
1846
- const styleSheet2 = _react.useMemo.call(void 0,
1847
- () => _common.RWStyleSheet.create({
1848
- tabs: {
1849
- flexDirection: "row",
1850
- borderLeft: {
1851
- color: "#1C1E22",
1852
- thickness: 1
1853
- },
1854
- borderBottom: {
1855
- color: "#1C1E22",
1856
- thickness: 1
1857
- }
1858
- },
1859
- tab: {
1860
- padding: { vertical: 10, horizontal: 20 },
1861
- borderTop: {
1862
- color: "#1C1E22",
1863
- thickness: 1
1864
- },
1865
- borderRight: {
1866
- color: "#1C1E22",
1867
- thickness: 1
1868
- }
1869
- },
1870
- hoveredTab: {
1871
- padding: { vertical: 10, horizontal: 20 },
1872
- borderTop: {
1873
- // todo: not currently working for hover/active/disabled states
1874
- color: "#fff",
1875
- thickness: 1
1876
- },
1877
- borderRight: {
1878
- color: "#1C1E22",
1879
- thickness: 1
1880
- },
1881
- position: {
1882
- top: 1
1883
- // todo: hack
1884
- }
1885
- },
1886
- activeTab: {
1887
- padding: { vertical: 10, horizontal: 20 },
1888
- borderTop: {
1889
- // todo: not currently working for hover/active/disabled states
1890
- color: "#fff",
1891
- thickness: 1
1892
- },
1893
- borderRight: {
1894
- color: "#1C1E22",
1895
- thickness: 1
1896
- },
1897
- position: {
1898
- top: 1
1899
- // todo: hack
1900
- }
1901
- },
1902
- selectedTab: {
1903
- padding: { vertical: 10, horizontal: 20 },
1904
- borderTop: {
1905
- color: "#fff",
1906
- thickness: 1
1907
- },
1908
- borderBottom: {
1909
- color: theme2Colors.black,
1910
- thickness: 1
1911
- },
1912
- borderRight: {
1913
- color: "#1C1E22",
1914
- thickness: 1
1915
- },
1916
- position: {
1917
- top: 1
1918
- // todo: hack
1919
- }
1920
- },
1921
- tabText: {
1922
- font: { name: "roboto-bold", size: 18 }
1923
- }
1924
- }),
1925
- []
1926
- );
1927
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.tabs, children: tabs.map((tab, index) => {
1928
- const isSelected = selectedTabIndex === index;
1929
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1930
- XFrames.Node,
1931
- {
1932
- style: isSelected ? styleSheet2.selectedTab : styleSheet2.tab,
1933
- hoverStyle: isSelected ? styleSheet2.selectedTab : styleSheet2.hoveredTab,
1934
- activeStyle: isSelected ? styleSheet2.selectedTab : styleSheet2.activeTab,
1935
- onClick: () => {
1936
- onSelectedTabChange(index);
1937
- },
1938
- trackMouseClickEvents: true,
1939
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.UnformattedText, { text: tab, style: styleSheet2.tabText })
1940
- },
1941
- tab
1942
- );
1943
- }) });
1944
- };
1945
-
1946
- // src/components/TradingGuiDemo/TradingGuiDemo.tsx
1947
-
1948
- var componentMap2 = {
1949
- cryptoAssetPanels: CryptoAssetPanels,
1950
- cryptoAssetList: CryptoAssetsList,
1951
- cryptoLinePlots: CryptoLinePlots,
1952
- cryptoCandlestickPlots: CryptoCandlestickPlots
1953
- };
1954
- var dataService = new DataService();
1955
- var TradingGuiDemo = () => {
1956
- const symbols = useStore2((state) => state.symbols);
1957
- const selectedTabIndex = useStore2((state) => state.selectedTabIndex);
1958
- const setSelectedTabIndex = useStore2((state) => state.setSelectedTabIndex);
1959
- const setCryptoAssets = useStore2((state) => state.setCryptoAssets);
1960
- const socketRef = _react.useRef.call(void 0, );
1961
- const widgetRegistratonService = _common.useWidgetRegistrationService.call(void 0, );
1962
- const [selectedItemIds, setSelectedItemIds] = _react.useState.call(void 0, [
1963
- "cryptoAssetPanels"
1964
- ]);
1965
- const styleSheet2 = _react.useMemo.call(void 0,
1966
- () => _common.RWStyleSheet.create({
1967
- rootNode: {
1968
- height: "100%"
1969
- },
1970
- mainLayoutNode: {
1971
- flex: 1,
1972
- flexDirection: "row"
1973
- },
1974
- title: {
1975
- colors: { [_common.ImGuiCol.Text]: theme2Colors.green },
1976
- font: { name: "roboto-regular", size: 24 }
1977
- },
1978
- debugButton: {
1979
- positionType: "absolute",
1980
- position: { right: 15, bottom: 15 },
1981
- flexDirection: "row",
1982
- gap: { column: 10 }
1983
- },
1984
- button: {
1985
- colors: {
1986
- [_common.ImGuiCol.Text]: theme2Colors.green,
1987
- [_common.ImGuiCol.Border]: theme2Colors.green
1988
- },
1989
- padding: { all: 8 },
1990
- vars: {
1991
- [_common.ImGuiStyleVar.FrameBorderSize]: 1,
1992
- [_common.ImGuiStyleVar.FrameRounding]: 5
1993
- }
1994
- },
1995
- mainNode: {
1996
- flex: 1
1997
- },
1998
- mainTitleNode: {
1999
- flexDirection: "row",
2000
- borderBottom: {
2001
- color: "#1B1D20",
2002
- // todo: remove double border
2003
- thickness: 1
2004
- },
2005
- borderRight: {
2006
- color: "#1B1D20",
2007
- // todo: remove double border
2008
- thickness: 1
2009
- },
2010
- padding: { all: 20 }
2011
- },
2012
- mainTitle: {
2013
- font: { name: "roboto-bold", size: 32 }
2014
- },
2015
- contentNode: {
2016
- padding: {
2017
- left: 8
2018
- }
2019
- },
2020
- tabContent: {
2021
- height: "100%",
2022
- width: 350,
2023
- gap: { row: 10 },
2024
- padding: {
2025
- horizontal: 8,
2026
- vertical: 16
2027
- },
2028
- borderLeft: {
2029
- color: "#1C1E22",
2030
- thickness: 1
2031
- }
2032
- },
2033
- marketSearchInput: {
2034
- vars: {
2035
- [_common.ImGuiStyleVar.FrameBorderSize]: 1,
2036
- [_common.ImGuiStyleVar.FramePadding]: [10, 10]
2037
- },
2038
- colors: {
2039
- [_common.ImGuiCol.Border]: "#1C1E22"
2040
- }
2041
- },
2042
- marketSearchInputHover: {
2043
- vars: {
2044
- [_common.ImGuiStyleVar.FrameBorderSize]: 1,
2045
- [_common.ImGuiStyleVar.FramePadding]: [10, 10]
2046
- },
2047
- colors: {
2048
- [_common.ImGuiCol.Border]: "#fff",
2049
- [_common.ImGuiCol.TextDisabled]: "#fff"
2050
- }
2051
- },
2052
- marketSearchFilterWrapper: {
2053
- flexDirection: "row",
2054
- gap: { all: 8 },
2055
- flexWrap: "wrap"
2056
- },
2057
- marketSearchFilter: {
2058
- width: 60,
2059
- colors: {
2060
- [_common.ImGuiCol.Button]: "#1E2025",
2061
- [_common.ImGuiCol.ButtonHovered]: "#1E2025",
2062
- [_common.ImGuiCol.ButtonActive]: "#1E2025",
2063
- [_common.ImGuiCol.Text]: "#777B84"
2064
- },
2065
- vars: {
2066
- [_common.ImGuiStyleVar.FrameRounding]: 5
2067
- }
2068
- },
2069
- marketSearchFilterActive: {
2070
- width: 60,
2071
- colors: {
2072
- [_common.ImGuiCol.Button]: "#fff",
2073
- [_common.ImGuiCol.ButtonHovered]: "#fff",
2074
- [_common.ImGuiCol.ButtonActive]: "#fff",
2075
- [_common.ImGuiCol.Text]: "#292A2C"
2076
- },
2077
- vars: {
2078
- [_common.ImGuiStyleVar.FrameRounding]: 5
2079
- }
2080
- }
2081
- }),
2082
- []
2083
- );
2084
- const connect = _react.useCallback.call(void 0, () => {
2085
- socketRef.current = new WebSocket("ws://localhost:4000");
2086
- socketRef.current.addEventListener("error", () => {
2087
- console.log("Connected to server");
2088
- });
2089
- socketRef.current.addEventListener("open", () => {
2090
- console.log("Connected to server");
2091
- });
2092
- socketRef.current.addEventListener("close", (ev) => {
2093
- try {
2094
- const reason = JSON.parse(ev.reason);
2095
- console.log(`Disconnected from server: ${reason.message}`);
2096
- } catch (error) {
2097
- console.log("Disconnected from server");
2098
- }
2099
- });
2100
- socketRef.current.addEventListener("message", (event) => {
2101
- const data = JSON.parse(event.data);
2102
- if (data.cryptoAssets) {
2103
- setCryptoAssets(
2104
- data.cryptoAssets.filter(
2105
- (asset) => cryptoSymbols.includes(asset.symbol)
2106
- )
2107
- );
2108
- } else if (data.cryptoQuote) {
2109
- dataService.addCryptoQuote(data.cryptoQuote);
2110
- } else if (data.latestCryptoQuotes) {
2111
- Object.entries(data.latestCryptoQuotes).forEach(
2112
- ([symbol, cryptoQuote]) => dataService.addCryptoQuote({ ...cryptoQuote, S: symbol })
2113
- );
2114
- } else if (data.cryptoSnapshots) {
2115
- dataService.addCryptoSnapshots(data.cryptoSnapshots);
2116
- } else if (data.latestCryptoBars) {
2117
- console.log(data.latestCryptoBars);
2118
- } else if (data.cryptoBars) {
2119
- dataService.addCryptoBars(data.cryptoBars);
2120
- }
2121
- });
2122
- }, [setCryptoAssets]);
2123
- const sendMessage = _react.useCallback.call(void 0, (message) => {
2124
- if (socketRef.current) {
2125
- socketRef.current.send(JSON.stringify(message));
2126
- }
2127
- }, []);
2128
- const subscribeToLiveData = _react.useCallback.call(void 0,
2129
- () => sendMessage({
2130
- passkey: "",
2131
- action: "subscribeForCryptoQuotes",
2132
- symbols
2133
- }),
2134
- [sendMessage, symbols]
2135
- );
2136
- const getLatestQuotes = _react.useCallback.call(void 0, () => {
2137
- const currentDate = /* @__PURE__ */ new Date();
2138
- const end = currentDate.toISOString();
2139
- const start = _datefns.subMinutes.call(void 0, currentDate, 1);
2140
- sendMessage({
2141
- action: "getQuotes",
2142
- symbols,
2143
- options: { start, end }
2144
- });
2145
- }, [symbols]);
2146
- const getCryptoQuotes = _react.useCallback.call(void 0, () => {
2147
- const currentDate = /* @__PURE__ */ new Date();
2148
- const end = currentDate.toISOString();
2149
- const start = _datefns.subMinutes.call(void 0, currentDate, 1).toISOString();
2150
- const options = {
2151
- start,
2152
- end
2153
- };
2154
- sendMessage({
2155
- action: "getCryptoQuotes",
2156
- symbols,
2157
- options
2158
- });
2159
- }, [symbols]);
2160
- const getCryptoBars = _react.useCallback.call(void 0, () => {
2161
- const currentDate = /* @__PURE__ */ new Date();
2162
- const end = currentDate.toISOString();
2163
- const start = _datefns.subDays.call(void 0, currentDate, 30).toISOString();
2164
- const options = { start, end, timeframe: "1D" };
2165
- sendMessage({
2166
- action: "getCryptoBars",
2167
- symbols,
2168
- options
2169
- });
2170
- }, [symbols]);
2171
- const getCryptoSnapshots = _react.useCallback.call(void 0,
2172
- () => sendMessage({
2173
- action: "getCryptoSnapshots",
2174
- symbols
2175
- }),
2176
- [symbols]
2177
- );
2178
- const getLatestCryptoQuotes = _react.useCallback.call(void 0,
2179
- () => sendMessage({
2180
- action: "getLatestCryptoQuotes",
2181
- symbols
2182
- }),
2183
- [symbols]
2184
- );
2185
- const getLatestCryptoBars = _react.useCallback.call(void 0,
2186
- () => sendMessage({
2187
- action: "getLatestCryptoBars",
2188
- symbols
2189
- }),
2190
- [symbols]
2191
- );
2192
- const getCryptoAssets = _react.useCallback.call(void 0,
2193
- () => sendMessage({
2194
- action: "getCryptoAssets",
2195
- symbols
2196
- }),
2197
- [symbols]
2198
- );
2199
- const debugModeBtnClicked = _react.useCallback.call(void 0, () => {
2200
- widgetRegistratonService.setDebug(true);
2201
- }, []);
2202
- const onToggleItemSelection = _react.useCallback.call(void 0,
2203
- (itemId, selected) => {
2204
- setSelectedItemIds((selection) => {
2205
- if (selected) {
2206
- return [itemId];
2207
- } else {
2208
- return selection.filter((item) => item !== itemId);
2209
- }
2210
- });
2211
- },
2212
- []
2213
- );
2214
- _react.useEffect.call(void 0, () => {
2215
- }, [connect, getCryptoAssets]);
2216
- const tabs = _react.useMemo.call(void 0, () => ["Markets", "History"], []);
2217
- const Component = componentMap2[selectedItemIds[0]];
2218
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { root: true, style: styleSheet2.rootNode, children: [
2219
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.mainLayoutNode, children: [
2220
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Sidebar, {}),
2221
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.mainNode, children: [
2222
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.mainTitleNode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2223
- XFrames.UnformattedText,
2224
- {
2225
- text: "Trade",
2226
- style: styleSheet2.mainTitle
2227
- }
2228
- ) }),
2229
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.contentNode, children: [
2230
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CryptoSymbolBlock, { symbol: "BTC/USD" }),
2231
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2232
- Tabs,
2233
- {
2234
- tabs,
2235
- selectedTabIndex,
2236
- onSelectedTabChange: setSelectedTabIndex
2237
- }
2238
- ),
2239
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.tabContent, children: [
2240
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2241
- XFrames.InputText,
2242
- {
2243
- hint: `${_common.faIconMap["magnifying-glass"]} SEARCH MARKETS`,
2244
- style: styleSheet2.marketSearchInput,
2245
- hoverStyle: styleSheet2.marketSearchInputHover
2246
- }
2247
- ),
2248
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, XFrames.Node, { style: styleSheet2.marketSearchFilterWrapper, children: [
2249
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2250
- XFrames.Button,
2251
- {
2252
- label: _common.faIconMap["star"],
2253
- style: styleSheet2.marketSearchFilter,
2254
- hoverStyle: styleSheet2.marketSearchFilterActive
2255
- }
2256
- ),
2257
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2258
- XFrames.Button,
2259
- {
2260
- label: "ALL",
2261
- style: styleSheet2.marketSearchFilterActive,
2262
- hoverStyle: styleSheet2.marketSearchFilterActive
2263
- }
2264
- ),
2265
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2266
- XFrames.Button,
2267
- {
2268
- label: "TOP",
2269
- style: styleSheet2.marketSearchFilter,
2270
- hoverStyle: styleSheet2.marketSearchFilterActive
2271
- }
2272
- ),
2273
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2274
- XFrames.Button,
2275
- {
2276
- label: "BTC",
2277
- style: styleSheet2.marketSearchFilter,
2278
- hoverStyle: styleSheet2.marketSearchFilterActive
2279
- }
2280
- ),
2281
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2282
- XFrames.Button,
2283
- {
2284
- label: "ETH",
2285
- style: styleSheet2.marketSearchFilter,
2286
- hoverStyle: styleSheet2.marketSearchFilterActive
2287
- }
2288
- ),
2289
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2290
- XFrames.Button,
2291
- {
2292
- label: "USD",
2293
- style: styleSheet2.marketSearchFilter,
2294
- hoverStyle: styleSheet2.marketSearchFilterActive
2295
- }
2296
- ),
2297
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2298
- XFrames.Button,
2299
- {
2300
- label: "USDC",
2301
- style: styleSheet2.marketSearchFilter,
2302
- hoverStyle: styleSheet2.marketSearchFilterActive
2303
- }
2304
- ),
2305
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2306
- XFrames.Button,
2307
- {
2308
- label: "DAI",
2309
- style: styleSheet2.marketSearchFilter,
2310
- hoverStyle: styleSheet2.marketSearchFilterActive
2311
- }
2312
- ),
2313
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2314
- XFrames.Button,
2315
- {
2316
- label: "MKR",
2317
- style: styleSheet2.marketSearchFilter,
2318
- hoverStyle: styleSheet2.marketSearchFilterActive
2319
- }
2320
- )
2321
- ] })
2322
- ] })
2323
- ] })
2324
- ] })
2325
- ] }),
2326
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.sidebarNode }),
2327
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Node, { style: styleSheet2.debugButton, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XFrames.Button, { label: _common.faIconMap.bug, onClick: debugModeBtnClicked }) })
2328
- ] });
2329
- };
2330
-
2331
-
2332
-
2333
167
 
2334
168
 
2335
- exports.ReactNativeWrapper = ReactNativeWrapper; exports.TradingGuiDemo = TradingGuiDemo; exports.XFrames = XFrames; exports.XFramesDemo = XFramesDemo;
169
+ exports.ReactNativeWrapper = ReactNativeWrapper; exports.XFrames = XFrames;
2336
170
  //# sourceMappingURL=index.js.map