@player-tools/devtools-basic-web-plugin 0.5.3--canary.90.2515

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 (40) hide show
  1. package/dist/cjs/index.cjs +919 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/index.legacy-esm.js +884 -0
  4. package/dist/index.mjs +884 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/package.json +41 -0
  7. package/src/WrapperComponent.tsx +169 -0
  8. package/src/constants/index.ts +27 -0
  9. package/src/content/common/Screen.tsx +35 -0
  10. package/src/content/common/index.ts +1 -0
  11. package/src/content/index.ts +18 -0
  12. package/src/content/navigation/index.ts +27 -0
  13. package/src/content/schema/index.ts +39 -0
  14. package/src/content/views/ConfigView.tsx +16 -0
  15. package/src/content/views/ConsoleView.tsx +20 -0
  16. package/src/content/views/FlowView.tsx +23 -0
  17. package/src/content/views/LogsView.tsx +9 -0
  18. package/src/content/views/index.ts +6 -0
  19. package/src/helpers/genDataChangeTransaction.ts +29 -0
  20. package/src/helpers/getEvaluateExpression.ts +50 -0
  21. package/src/helpers/index.ts +2 -0
  22. package/src/index.tsx +96 -0
  23. package/src/types.ts +35 -0
  24. package/types/WrapperComponent.d.ts +4 -0
  25. package/types/constants/index.d.ts +16 -0
  26. package/types/content/common/Screen.d.ts +7 -0
  27. package/types/content/common/index.d.ts +2 -0
  28. package/types/content/index.d.ts +33 -0
  29. package/types/content/navigation/index.d.ts +7 -0
  30. package/types/content/schema/index.d.ts +29 -0
  31. package/types/content/views/ConfigView.d.ts +3 -0
  32. package/types/content/views/ConsoleView.d.ts +3 -0
  33. package/types/content/views/FlowView.d.ts +3 -0
  34. package/types/content/views/LogsView.d.ts +3 -0
  35. package/types/content/views/index.d.ts +3 -0
  36. package/types/helpers/genDataChangeTransaction.d.ts +8 -0
  37. package/types/helpers/getEvaluateExpression.d.ts +4 -0
  38. package/types/helpers/index.d.ts +3 -0
  39. package/types/index.d.ts +18 -0
  40. package/types/types.d.ts +35 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,884 @@
1
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/index.tsx
2
+ import { dset as dset2 } from "dset/merge";
3
+ import { produce as produce2 } from "immer";
4
+ import React2 from "react";
5
+
6
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/WrapperComponent.tsx
7
+ import { usePluginState } from "@player-tools/devtools-desktop-plugins-common";
8
+ import { dequal } from "dequal";
9
+ import { dset } from "dset/merge";
10
+ import { produce } from "immer";
11
+ import React, { useCallback, useEffect } from "react";
12
+
13
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/constants/index.ts
14
+ var PLUGIN_ID = "player-ui-basic-devtools-plugin";
15
+ var PLUGIN_NAME = "Standard Devtools";
16
+ var PLUGIN_DESCRIPTION = "Standard Player UI Devtools";
17
+ var PLUGIN_VERSION = "0.0.1";
18
+ var INTERACTIONS = {
19
+ EVALUATE_EXPRESSION: "evaluate-expression"
20
+ };
21
+ var BASE_PLUGIN_DATA = {
22
+ id: PLUGIN_ID,
23
+ name: PLUGIN_NAME,
24
+ description: PLUGIN_DESCRIPTION,
25
+ version: PLUGIN_VERSION
26
+ };
27
+
28
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/helpers/getEvaluateExpression.ts
29
+ import { v4 as uuid } from "uuid";
30
+ var getEvaluateExpression = (expressionEvaluator) => (expression) => {
31
+ if (!expressionEvaluator) {
32
+ return {
33
+ id: uuid(),
34
+ severity: "error",
35
+ result: "Expression evaluator not available",
36
+ expression
37
+ };
38
+ }
39
+ let result = {
40
+ id: uuid(),
41
+ severity: "error",
42
+ result: "Something went wrong",
43
+ expression
44
+ };
45
+ try {
46
+ expressionEvaluator.deref()?.hooks.onError.intercept({
47
+ call: (error) => {
48
+ throw error;
49
+ }
50
+ });
51
+ const evaluatorResult = expressionEvaluator.deref()?.evaluate(expression);
52
+ result = {
53
+ id: uuid(),
54
+ result: evaluatorResult,
55
+ expression
56
+ };
57
+ } catch (error) {
58
+ if (error instanceof Error) {
59
+ result = {
60
+ id: uuid(),
61
+ severity: "error",
62
+ result: error.message,
63
+ expression
64
+ };
65
+ }
66
+ }
67
+ return result;
68
+ };
69
+
70
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/helpers/genDataChangeTransaction.ts
71
+ var genDataChangeTransaction = ({
72
+ playerID,
73
+ data,
74
+ pluginID
75
+ }) => {
76
+ return {
77
+ id: -1,
78
+ type: "PLAYER_DEVTOOLS_PLUGIN_DATA_CHANGE",
79
+ payload: {
80
+ pluginID,
81
+ data
82
+ },
83
+ sender: playerID,
84
+ context: "player",
85
+ target: "player",
86
+ timestamp: Date.now(),
87
+ _messenger_: true
88
+ };
89
+ };
90
+
91
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/_generated/index.json
92
+ var generated_default = {
93
+ id: "player-ui-basic-devtools-plugin",
94
+ views: [
95
+ {
96
+ id: "Config",
97
+ type: "stacked-view",
98
+ header: {
99
+ asset: {
100
+ id: "Config-header",
101
+ type: "navigation",
102
+ values: [
103
+ {
104
+ asset: {
105
+ id: "Config-header-values-0",
106
+ type: "action",
107
+ value: "Config",
108
+ label: {
109
+ asset: {
110
+ id: "Config-header-values-0-label",
111
+ type: "text",
112
+ value: "Config"
113
+ }
114
+ }
115
+ }
116
+ },
117
+ {
118
+ asset: {
119
+ id: "Config-header-values-1",
120
+ type: "action",
121
+ value: "Flow",
122
+ label: {
123
+ asset: {
124
+ id: "Config-header-values-1-label",
125
+ type: "text",
126
+ value: "Flow"
127
+ }
128
+ }
129
+ }
130
+ },
131
+ {
132
+ asset: {
133
+ id: "Config-header-values-2",
134
+ type: "action",
135
+ value: "Logs",
136
+ label: {
137
+ asset: {
138
+ id: "Config-header-values-2-label",
139
+ type: "text",
140
+ value: "Logs"
141
+ }
142
+ }
143
+ }
144
+ },
145
+ {
146
+ asset: {
147
+ id: "Config-header-values-3",
148
+ type: "action",
149
+ value: "Console",
150
+ label: {
151
+ asset: {
152
+ id: "Config-header-values-3-label",
153
+ type: "text",
154
+ value: "Console"
155
+ }
156
+ }
157
+ }
158
+ }
159
+ ]
160
+ }
161
+ },
162
+ main: {
163
+ asset: {
164
+ id: "Config-main",
165
+ type: "object-inspector",
166
+ binding: "playerConfig",
167
+ label: {
168
+ asset: {
169
+ id: "Config-main-label",
170
+ type: "text",
171
+ value: "Config"
172
+ }
173
+ }
174
+ }
175
+ }
176
+ },
177
+ {
178
+ id: "Flow",
179
+ type: "stacked-view",
180
+ header: {
181
+ asset: {
182
+ id: "Flow-header",
183
+ type: "navigation",
184
+ values: [
185
+ {
186
+ asset: {
187
+ id: "Flow-header-values-0",
188
+ type: "action",
189
+ value: "Config",
190
+ label: {
191
+ asset: {
192
+ id: "Flow-header-values-0-label",
193
+ type: "text",
194
+ value: "Config"
195
+ }
196
+ }
197
+ }
198
+ },
199
+ {
200
+ asset: {
201
+ id: "Flow-header-values-1",
202
+ type: "action",
203
+ value: "Flow",
204
+ label: {
205
+ asset: {
206
+ id: "Flow-header-values-1-label",
207
+ type: "text",
208
+ value: "Flow"
209
+ }
210
+ }
211
+ }
212
+ },
213
+ {
214
+ asset: {
215
+ id: "Flow-header-values-2",
216
+ type: "action",
217
+ value: "Logs",
218
+ label: {
219
+ asset: {
220
+ id: "Flow-header-values-2-label",
221
+ type: "text",
222
+ value: "Logs"
223
+ }
224
+ }
225
+ }
226
+ },
227
+ {
228
+ asset: {
229
+ id: "Flow-header-values-3",
230
+ type: "action",
231
+ value: "Console",
232
+ label: {
233
+ asset: {
234
+ id: "Flow-header-values-3-label",
235
+ type: "text",
236
+ value: "Console"
237
+ }
238
+ }
239
+ }
240
+ }
241
+ ]
242
+ }
243
+ },
244
+ main: {
245
+ asset: {
246
+ id: "Flow-main",
247
+ type: "object-inspector",
248
+ binding: "flow",
249
+ label: {
250
+ asset: {
251
+ id: "Flow-main-label",
252
+ type: "text",
253
+ value: "Flow"
254
+ }
255
+ }
256
+ }
257
+ },
258
+ footer: {
259
+ asset: {
260
+ id: "Flow-footer",
261
+ type: "copy-to-clipboard",
262
+ binding: "flow",
263
+ label: {
264
+ asset: {
265
+ id: "Flow-footer-label",
266
+ type: "text",
267
+ value: "Copy flow to the clipboard"
268
+ }
269
+ }
270
+ }
271
+ }
272
+ },
273
+ {
274
+ id: "Logs",
275
+ type: "stacked-view",
276
+ header: {
277
+ asset: {
278
+ id: "Logs-header",
279
+ type: "navigation",
280
+ values: [
281
+ {
282
+ asset: {
283
+ id: "Logs-header-values-0",
284
+ type: "action",
285
+ value: "Config",
286
+ label: {
287
+ asset: {
288
+ id: "Logs-header-values-0-label",
289
+ type: "text",
290
+ value: "Config"
291
+ }
292
+ }
293
+ }
294
+ },
295
+ {
296
+ asset: {
297
+ id: "Logs-header-values-1",
298
+ type: "action",
299
+ value: "Flow",
300
+ label: {
301
+ asset: {
302
+ id: "Logs-header-values-1-label",
303
+ type: "text",
304
+ value: "Flow"
305
+ }
306
+ }
307
+ }
308
+ },
309
+ {
310
+ asset: {
311
+ id: "Logs-header-values-2",
312
+ type: "action",
313
+ value: "Logs",
314
+ label: {
315
+ asset: {
316
+ id: "Logs-header-values-2-label",
317
+ type: "text",
318
+ value: "Logs"
319
+ }
320
+ }
321
+ }
322
+ },
323
+ {
324
+ asset: {
325
+ id: "Logs-header-values-3",
326
+ type: "action",
327
+ value: "Console",
328
+ label: {
329
+ asset: {
330
+ id: "Logs-header-values-3-label",
331
+ type: "text",
332
+ value: "Console"
333
+ }
334
+ }
335
+ }
336
+ }
337
+ ]
338
+ }
339
+ },
340
+ main: {
341
+ asset: {
342
+ id: "Logs-main",
343
+ type: "table",
344
+ binding: "logs"
345
+ }
346
+ }
347
+ },
348
+ {
349
+ id: "Console",
350
+ type: "stacked-view",
351
+ header: {
352
+ asset: {
353
+ id: "Console-header",
354
+ type: "navigation",
355
+ values: [
356
+ {
357
+ asset: {
358
+ id: "Console-header-values-0",
359
+ type: "action",
360
+ value: "Config",
361
+ label: {
362
+ asset: {
363
+ id: "Console-header-values-0-label",
364
+ type: "text",
365
+ value: "Config"
366
+ }
367
+ }
368
+ }
369
+ },
370
+ {
371
+ asset: {
372
+ id: "Console-header-values-1",
373
+ type: "action",
374
+ value: "Flow",
375
+ label: {
376
+ asset: {
377
+ id: "Console-header-values-1-label",
378
+ type: "text",
379
+ value: "Flow"
380
+ }
381
+ }
382
+ }
383
+ },
384
+ {
385
+ asset: {
386
+ id: "Console-header-values-2",
387
+ type: "action",
388
+ value: "Logs",
389
+ label: {
390
+ asset: {
391
+ id: "Console-header-values-2-label",
392
+ type: "text",
393
+ value: "Logs"
394
+ }
395
+ }
396
+ }
397
+ },
398
+ {
399
+ asset: {
400
+ id: "Console-header-values-3",
401
+ type: "action",
402
+ value: "Console",
403
+ label: {
404
+ asset: {
405
+ id: "Console-header-values-3-label",
406
+ type: "text",
407
+ value: "Console"
408
+ }
409
+ }
410
+ }
411
+ }
412
+ ]
413
+ }
414
+ },
415
+ main: {
416
+ asset: {
417
+ id: "Console-main",
418
+ type: "console",
419
+ exp: " publish('evaluate-expression', {{expression}}) ",
420
+ binding: "history"
421
+ }
422
+ }
423
+ }
424
+ ],
425
+ navigation: {
426
+ BEGIN: "Plugin",
427
+ Plugin: {
428
+ startState: "CONFIG",
429
+ CONFIG: {
430
+ state_type: "VIEW",
431
+ ref: "Config",
432
+ transitions: {
433
+ Config: "CONFIG",
434
+ Flow: "FLOW",
435
+ Logs: "LOGS",
436
+ Console: "CONSOLE"
437
+ }
438
+ },
439
+ FLOW: {
440
+ state_type: "VIEW",
441
+ ref: "Flow",
442
+ transitions: {
443
+ Config: "CONFIG",
444
+ Flow: "FLOW",
445
+ Logs: "LOGS",
446
+ Console: "CONSOLE"
447
+ }
448
+ },
449
+ LOGS: {
450
+ state_type: "VIEW",
451
+ ref: "Logs",
452
+ transitions: {
453
+ Config: "CONFIG",
454
+ Flow: "FLOW",
455
+ Logs: "LOGS",
456
+ Console: "CONSOLE"
457
+ }
458
+ },
459
+ CONSOLE: {
460
+ state_type: "VIEW",
461
+ ref: "Console",
462
+ transitions: {
463
+ Config: "CONFIG",
464
+ Flow: "FLOW",
465
+ Logs: "LOGS",
466
+ Console: "CONSOLE"
467
+ }
468
+ }
469
+ }
470
+ },
471
+ schema: {
472
+ ROOT: {
473
+ playerConfig: {
474
+ type: "RecordType"
475
+ },
476
+ flow: {
477
+ type: "RecordType"
478
+ },
479
+ expression: {
480
+ type: "StringType",
481
+ default: "",
482
+ validation: [
483
+ {
484
+ type: "string"
485
+ }
486
+ ],
487
+ format: {
488
+ type: "string"
489
+ }
490
+ },
491
+ history: {
492
+ type: "historyType",
493
+ isArray: true
494
+ },
495
+ logs: {
496
+ type: "logsType",
497
+ isArray: true
498
+ }
499
+ },
500
+ logsType: {
501
+ id: {
502
+ type: "StringType",
503
+ default: "",
504
+ validation: [
505
+ {
506
+ type: "string"
507
+ }
508
+ ],
509
+ format: {
510
+ type: "string"
511
+ }
512
+ },
513
+ time: {
514
+ type: "StringType",
515
+ default: "",
516
+ validation: [
517
+ {
518
+ type: "string"
519
+ }
520
+ ],
521
+ format: {
522
+ type: "string"
523
+ }
524
+ },
525
+ type: {
526
+ type: "StringType",
527
+ default: "",
528
+ validation: [
529
+ {
530
+ type: "string"
531
+ }
532
+ ],
533
+ format: {
534
+ type: "string"
535
+ }
536
+ },
537
+ message: {
538
+ type: "StringType",
539
+ default: "",
540
+ validation: [
541
+ {
542
+ type: "string"
543
+ }
544
+ ],
545
+ format: {
546
+ type: "string"
547
+ }
548
+ },
549
+ severity: {
550
+ type: "StringType",
551
+ default: "",
552
+ validation: [
553
+ {
554
+ type: "string"
555
+ }
556
+ ],
557
+ format: {
558
+ type: "string"
559
+ }
560
+ },
561
+ binding: {
562
+ type: "StringType",
563
+ default: "",
564
+ validation: [
565
+ {
566
+ type: "string"
567
+ }
568
+ ],
569
+ format: {
570
+ type: "string"
571
+ }
572
+ },
573
+ from: {
574
+ type: "StringType",
575
+ default: "",
576
+ validation: [
577
+ {
578
+ type: "string"
579
+ }
580
+ ],
581
+ format: {
582
+ type: "string"
583
+ }
584
+ },
585
+ to: {
586
+ type: "StringType",
587
+ default: "",
588
+ validation: [
589
+ {
590
+ type: "string"
591
+ }
592
+ ],
593
+ format: {
594
+ type: "string"
595
+ }
596
+ },
597
+ state: {
598
+ type: "StringType",
599
+ default: "",
600
+ validation: [
601
+ {
602
+ type: "string"
603
+ }
604
+ ],
605
+ format: {
606
+ type: "string"
607
+ }
608
+ },
609
+ error: {
610
+ type: "StringType",
611
+ default: "",
612
+ validation: [
613
+ {
614
+ type: "string"
615
+ }
616
+ ],
617
+ format: {
618
+ type: "string"
619
+ }
620
+ },
621
+ outcome: {
622
+ type: "StringType",
623
+ default: "",
624
+ validation: [
625
+ {
626
+ type: "string"
627
+ }
628
+ ],
629
+ format: {
630
+ type: "string"
631
+ }
632
+ },
633
+ metricType: {
634
+ type: "StringType",
635
+ default: "",
636
+ validation: [
637
+ {
638
+ type: "string"
639
+ }
640
+ ],
641
+ format: {
642
+ type: "string"
643
+ }
644
+ }
645
+ },
646
+ historyType: {
647
+ id: {
648
+ type: "StringType",
649
+ default: "",
650
+ validation: [
651
+ {
652
+ type: "string"
653
+ }
654
+ ],
655
+ format: {
656
+ type: "string"
657
+ }
658
+ },
659
+ expression: {
660
+ type: "StringType",
661
+ default: "",
662
+ validation: [
663
+ {
664
+ type: "string"
665
+ }
666
+ ],
667
+ format: {
668
+ type: "string"
669
+ }
670
+ },
671
+ result: {
672
+ type: "StringType",
673
+ default: "",
674
+ validation: [
675
+ {
676
+ type: "string"
677
+ }
678
+ ],
679
+ format: {
680
+ type: "string"
681
+ }
682
+ },
683
+ severity: {
684
+ type: "StringType",
685
+ default: "",
686
+ validation: [
687
+ {
688
+ type: "string"
689
+ }
690
+ ],
691
+ format: {
692
+ type: "string"
693
+ }
694
+ }
695
+ }
696
+ },
697
+ data: {
698
+ expression: "",
699
+ flow: {},
700
+ history: [],
701
+ logs: [],
702
+ playerConfig: {}
703
+ }
704
+ };
705
+
706
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/WrapperComponent.tsx
707
+ var pluginData = {
708
+ ...BASE_PLUGIN_DATA,
709
+ flow: generated_default
710
+ };
711
+ var WrapperComponent = ({
712
+ children,
713
+ data,
714
+ playerConfig,
715
+ logs,
716
+ flow,
717
+ expressionEvaluator
718
+ }) => {
719
+ const [state, playerID, dispatch] = usePluginState();
720
+ const lastProcessedInteraction = React.useRef(0);
721
+ const expEvaluator = useCallback(getEvaluateExpression(expressionEvaluator), [
722
+ expressionEvaluator
723
+ ]);
724
+ const id = pluginData.id;
725
+ const processInteraction = useCallback(
726
+ (interaction) => {
727
+ const {
728
+ payload: { type, payload }
729
+ } = interaction;
730
+ if (type === INTERACTIONS.EVALUATE_EXPRESSION && expressionEvaluator && payload) {
731
+ const result = expEvaluator(payload);
732
+ const newState = produce(state, (draft) => {
733
+ const current = state?.plugins?.[id]?.flow?.data?.history || [];
734
+ dset(
735
+ draft,
736
+ ["plugins", id, "flow", "data", "history"],
737
+ [...current, result]
738
+ );
739
+ });
740
+ dispatch({
741
+ id: -1,
742
+ type: "PLAYER_DEVTOOLS_PLUGIN_DATA_CHANGE",
743
+ payload: {
744
+ pluginID: id,
745
+ data: newState.plugins[id].flow.data
746
+ },
747
+ sender: playerID,
748
+ context: "player",
749
+ target: "player",
750
+ timestamp: Date.now(),
751
+ _messenger_: true
752
+ });
753
+ lastProcessedInteraction.current += 1;
754
+ }
755
+ },
756
+ [dispatch, expressionEvaluator, id, state]
757
+ );
758
+ const pluginDataWithPlayerConfig = produce(pluginData, (draft) => {
759
+ dset(draft, ["flow", "data", "playerConfig"], playerConfig);
760
+ });
761
+ useEffect(() => {
762
+ const transaction = {
763
+ id: -1,
764
+ type: "PLAYER_DEVTOOLS_PLAYER_INIT",
765
+ payload: {
766
+ plugins: {
767
+ [id]: pluginDataWithPlayerConfig
768
+ }
769
+ },
770
+ sender: playerID,
771
+ context: "player",
772
+ target: "player",
773
+ timestamp: Date.now(),
774
+ _messenger_: true
775
+ };
776
+ dispatch(transaction);
777
+ }, []);
778
+ useEffect(() => {
779
+ if (lastProcessedInteraction.current < (state.interactions.length ?? 0)) {
780
+ state.interactions.slice(lastProcessedInteraction.current).forEach(processInteraction);
781
+ }
782
+ }, [state.interactions.length]);
783
+ useEffect(() => {
784
+ if (dequal(state.plugins[id]?.flow?.data?.data, data))
785
+ return;
786
+ const newState = produce(state, (draft) => {
787
+ dset(draft, ["plugins", id, "flow", "data", "data"], data);
788
+ });
789
+ const transaction = genDataChangeTransaction({
790
+ playerID,
791
+ data: newState.plugins[id].flow.data,
792
+ pluginID: id
793
+ });
794
+ dispatch(transaction);
795
+ }, [data]);
796
+ useEffect(() => {
797
+ if (dequal(state.plugins[id]?.flow?.data?.logs, logs))
798
+ return;
799
+ const newState = produce(state, (draft) => {
800
+ dset(draft, ["plugins", id, "flow", "data", "logs"], logs);
801
+ });
802
+ const transaction = genDataChangeTransaction({
803
+ playerID,
804
+ data: newState.plugins[id].flow.data,
805
+ pluginID: id
806
+ });
807
+ dispatch(transaction);
808
+ }, [logs]);
809
+ useEffect(() => {
810
+ if (dequal(state.plugins[id]?.flow?.data?.flow, flow))
811
+ return;
812
+ const newState = produce(state, (draft) => {
813
+ dset(draft, ["plugins", id, "flow", "data", "flow"], flow);
814
+ });
815
+ const transaction = genDataChangeTransaction({
816
+ playerID,
817
+ data: newState.plugins[id].flow.data,
818
+ pluginID: id
819
+ });
820
+ dispatch(transaction);
821
+ }, [flow]);
822
+ return children;
823
+ };
824
+
825
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/basic/src/index.tsx
826
+ var BasicWevDevtoolsPlugin = class {
827
+ name = "player_ui_basic_devtools_plugin";
828
+ data = {};
829
+ playerConfig = {};
830
+ logs = [];
831
+ flow;
832
+ expressionEvaluator;
833
+ view;
834
+ dataController;
835
+ apply(player) {
836
+ this.playerConfig = {
837
+ version: player.getVersion(),
838
+ plugins: player.getPlugins().map((plugin) => plugin.name)
839
+ };
840
+ player.hooks.dataController.tap(this.name, (dataController) => {
841
+ dataController.hooks.onUpdate.tap(this.name, (updates) => {
842
+ const newPlayerState = produce2(this.data, (draft) => {
843
+ updates.forEach(({ binding, newValue }) => {
844
+ dset2(draft, ["data", ...binding.asArray()], newValue);
845
+ });
846
+ });
847
+ this.data = newPlayerState;
848
+ });
849
+ });
850
+ player.logger.hooks.log.tap(this.name, (severity, message) => {
851
+ this.logs = [...this.logs, { severity, message }];
852
+ });
853
+ player.hooks.onStart.tap(this.name, (f) => {
854
+ this.flow = f;
855
+ });
856
+ player.hooks.view.tap(this.name, (view) => {
857
+ this.view = new WeakRef(view);
858
+ });
859
+ player.hooks.expressionEvaluator.tap(this.name, (evaluator) => {
860
+ this.expressionEvaluator = new WeakRef(evaluator);
861
+ });
862
+ }
863
+ applyReact(reactPlayer) {
864
+ reactPlayer.hooks.webComponent.tap(this.name, (Comp) => () => {
865
+ const Component = Comp;
866
+ return /* @__PURE__ */ React2.createElement(
867
+ WrapperComponent,
868
+ {
869
+ playerConfig: this.playerConfig,
870
+ data: this.data,
871
+ logs: this.logs,
872
+ flow: this.flow,
873
+ view: this.view,
874
+ expressionEvaluator: this.expressionEvaluator
875
+ },
876
+ /* @__PURE__ */ React2.createElement(Component, null)
877
+ );
878
+ });
879
+ }
880
+ };
881
+ export {
882
+ BasicWevDevtoolsPlugin
883
+ };
884
+ //# sourceMappingURL=index.mjs.map