atom.io 0.33.10 → 0.33.12

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.
@@ -1,9 +1,10 @@
1
+ import { useI, useO } from "../use-o-BrXc7Qro.js";
1
2
  import { IMPLICIT, become, createAtomFamily, createStandaloneAtom, findInStore } from "atom.io/internal";
2
3
  import { JSON_DEFAULTS, fromEntries, isJson, stringifyJson, toEntries } from "atom.io/json";
3
4
  import { getState, redo, undo } from "atom.io";
4
5
  import { Component, Fragment, createContext, forwardRef, useContext, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
5
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
- import { StoreContext, useI, useO } from "atom.io/react";
7
+ import { StoreContext, useI as useI$1, useO as useO$1 } from "atom.io/react";
7
8
  import { LayoutGroup, motion } from "motion/react";
8
9
  import { attachIntrospectionStates, discoverType, jsonRefinery, prettyJson, primitiveRefinery } from "atom.io/introspection";
9
10
  import { persistSync } from "atom.io/web";
@@ -18,11 +19,189 @@ const OpenClose = ({ isOpen, setIsOpen, disabled, testid }) => {
18
19
  setIsOpen((prev) => !prev);
19
20
  },
20
21
  disabled,
21
- children: ""
22
+ children: /* @__PURE__ */ jsx("span", {
23
+ className: "json_editor_icon json_editor_carat",
24
+ children: "▶"
25
+ })
22
26
  });
23
27
  };
24
28
  const button = { OpenClose };
25
29
 
30
+ //#endregion
31
+ //#region src/react-devtools/error-boundary/DefaultFallback.tsx
32
+ const DefaultFallback = ({ error, errorInfo }) => {
33
+ const component = errorInfo?.componentStack?.split(` `).filter(Boolean)[2];
34
+ const message = error?.toString() ?? errorInfo?.componentStack ?? `Unknown error`;
35
+ return /* @__PURE__ */ jsx("div", {
36
+ "data-testid": "error-boundary",
37
+ style: {
38
+ flex: `1`,
39
+ background: `black`,
40
+ backgroundImage: `url(./src/assets/kablooey.gif)`,
41
+ backgroundPosition: `center`,
42
+ backgroundSize: `overlay`
43
+ },
44
+ children: /* @__PURE__ */ jsx("div", {
45
+ style: {
46
+ margin: `50px`,
47
+ marginTop: `0`,
48
+ padding: `50px`,
49
+ border: `1px solid dashed`
50
+ },
51
+ children: /* @__PURE__ */ jsxs("span", {
52
+ style: {
53
+ background: `black`,
54
+ color: `white`,
55
+ padding: 10,
56
+ paddingTop: 5
57
+ },
58
+ children: [
59
+ `⚠️ `,
60
+ /* @__PURE__ */ jsx("span", {
61
+ style: {
62
+ color: `#fc0`,
63
+ fontWeight: 700
64
+ },
65
+ children: component
66
+ }),
67
+ ` ⚠️ `,
68
+ message
69
+ ]
70
+ })
71
+ })
72
+ });
73
+ };
74
+
75
+ //#endregion
76
+ //#region src/react-devtools/error-boundary/ReactErrorBoundary.tsx
77
+ var ErrorBoundary = class extends Component {
78
+ constructor(props) {
79
+ super(props);
80
+ this.state = {};
81
+ }
82
+ componentDidCatch(error, errorInfo) {
83
+ this.props.onError?.(error, errorInfo);
84
+ this.setState({
85
+ error,
86
+ errorInfo
87
+ });
88
+ }
89
+ render() {
90
+ const { error, errorInfo } = this.state;
91
+ const { children, Fallback = DefaultFallback } = this.props;
92
+ return errorInfo ? /* @__PURE__ */ jsx(Fallback, {
93
+ error,
94
+ errorInfo
95
+ }) : children;
96
+ }
97
+ };
98
+
99
+ //#endregion
100
+ //#region src/react-devtools/json-editor/default-components.tsx
101
+ const DEFAULT_JSON_EDITOR_COMPONENTS = {
102
+ ErrorBoundary: ({ children }) => /* @__PURE__ */ jsx(ErrorBoundary, { children }),
103
+ Button: ({ onClick, children, disabled, testid }) => /* @__PURE__ */ jsx("button", {
104
+ type: "button",
105
+ className: "json_editor_button",
106
+ onClick,
107
+ disabled,
108
+ "data-testid": testid,
109
+ children
110
+ }),
111
+ EditorWrapper: ({ children, className, testid }) => /* @__PURE__ */ jsx("div", {
112
+ className: `json_editor` + (className ? ` ${className}` : ``),
113
+ "data-testid": testid,
114
+ children
115
+ }),
116
+ ArrayWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", {
117
+ className: "json_editor_array",
118
+ "data-testid": testid,
119
+ children
120
+ }),
121
+ ObjectWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", {
122
+ className: "json_editor_object",
123
+ "data-testid": testid,
124
+ children
125
+ }),
126
+ StringWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
127
+ className: "json_editor_string",
128
+ "data-testid": testid,
129
+ children
130
+ }),
131
+ NumberWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
132
+ className: "json_editor_number",
133
+ "data-testid": testid,
134
+ children
135
+ }),
136
+ BooleanWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
137
+ className: "json_editor_boolean",
138
+ "data-testid": testid,
139
+ children
140
+ }),
141
+ Null: ({ testid }) => /* @__PURE__ */ jsx("span", {
142
+ className: "json_editor_null",
143
+ "data-testid": testid
144
+ }),
145
+ DeleteIcon: () => /* @__PURE__ */ jsx("span", {
146
+ className: "json_editor_icon json_editor_delete",
147
+ children: "×"
148
+ }),
149
+ AddIcon: () => /* @__PURE__ */ jsx("span", {
150
+ className: "json_editor_icon json_editor_add",
151
+ children: "+"
152
+ }),
153
+ MissingPropertyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
154
+ className: "json_editor_missing_property",
155
+ "data-testid": testid,
156
+ children
157
+ }),
158
+ KeyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
159
+ className: "json_editor_key",
160
+ "data-testid": testid,
161
+ children
162
+ })
163
+ };
164
+
165
+ //#endregion
166
+ //#region src/react-devtools/store.ts
167
+ function attachDevtoolsStates(store) {
168
+ const introspectionStates = attachIntrospectionStates(store);
169
+ const devtoolsAreOpenState = createStandaloneAtom(store, {
170
+ key: `🔍 Devtools Are Open`,
171
+ default: true,
172
+ effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `🔍 Devtools Are Open`)]
173
+ });
174
+ const devtoolsViewSelectionState = createStandaloneAtom(store, {
175
+ key: `🔍 Devtools View Selection`,
176
+ default: `atoms`,
177
+ effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `🔍 Devtools View`)]
178
+ });
179
+ const devtoolsViewOptionsState = createStandaloneAtom(store, {
180
+ key: `🔍 Devtools View Options`,
181
+ default: [
182
+ `atoms`,
183
+ `selectors`,
184
+ `transactions`,
185
+ `timelines`
186
+ ],
187
+ effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `🔍 Devtools View Options`)]
188
+ });
189
+ const viewIsOpenAtoms = createAtomFamily(store, {
190
+ key: `🔍 Devtools View Is Open`,
191
+ default: false,
192
+ effects: (key) => typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, key + `:view-is-open`)]
193
+ });
194
+ return {
195
+ ...introspectionStates,
196
+ devtoolsAreOpenState,
197
+ devtoolsViewSelectionState,
198
+ devtoolsViewOptionsState,
199
+ viewIsOpenAtoms,
200
+ store
201
+ };
202
+ }
203
+ const DevtoolsContext = createContext(attachDevtoolsStates(IMPLICIT.STORE));
204
+
26
205
  //#endregion
27
206
  //#region src/react-devtools/elastic-input/ElasticInput.tsx
28
207
  const ElasticInput = forwardRef(function ElasticInputFC(props, ref) {
@@ -230,7 +409,7 @@ const NonJsonEditor = ({ data, testid }) => {
230
409
 
231
410
  //#endregion
232
411
  //#region src/react-devtools/json-editor/json-editor-internal.tsx
233
- const JsonEditor_INTERNAL = ({ data, set, name, rename, remove, recast, path = [], isReadonly = () => false, isHidden = () => false, className, style, Header: HeaderDisplay, Components, testid }) => {
412
+ const JsonEditor_INTERNAL = ({ data, set, name, rename, remove, recast, path = [], isReadonly = () => false, isHidden = () => false, className, style, Components, isOpen, setIsOpen, testid }) => {
234
413
  const dataIsJson = isJson(data);
235
414
  const refined = jsonRefinery.refine(data) ?? {
236
415
  type: `non-json`,
@@ -238,32 +417,48 @@ const JsonEditor_INTERNAL = ({ data, set, name, rename, remove, recast, path = [
238
417
  };
239
418
  const SubEditor = dataIsJson ? SubEditors[refined.type] : NonJsonEditor;
240
419
  const disabled = isReadonly(path);
420
+ const dataIsTree = refined.type === `array` || refined.type === `object`;
241
421
  return isHidden(path) ? null : /* @__PURE__ */ jsx(Components.ErrorBoundary, { children: /* @__PURE__ */ jsxs(Components.EditorWrapper, {
242
422
  className,
243
423
  style,
244
424
  testid,
245
- children: [
246
- remove ? disabled ? /* @__PURE__ */ jsx(Components.Button, {
247
- disabled: true,
248
- testid: `${testid}-delete`,
249
- children: /* @__PURE__ */ jsx(Components.DeleteIcon, {})
250
- }) : /* @__PURE__ */ jsx(Components.Button, {
251
- testid: `${testid}-delete`,
425
+ children: [/* @__PURE__ */ jsxs("header", { children: [
426
+ remove ? /* @__PURE__ */ jsx(Components.Button, {
427
+ disabled,
252
428
  onClick: () => {
253
429
  remove();
254
430
  },
431
+ testid: `${testid}-delete`,
255
432
  children: /* @__PURE__ */ jsx(Components.DeleteIcon, {})
256
433
  }) : null,
257
- HeaderDisplay && /* @__PURE__ */ jsx(HeaderDisplay, { data }),
434
+ dataIsTree && isOpen !== void 0 && setIsOpen ? /* @__PURE__ */ jsx(button.OpenClose, {
435
+ isOpen,
436
+ testid: `${testid}-open-close`,
437
+ setIsOpen
438
+ }) : null,
258
439
  rename && /* @__PURE__ */ jsx(Components.KeyWrapper, { children: /* @__PURE__ */ jsx(ElasticInput, {
259
440
  value: name,
260
- onChange: disabled ? void 0 : (e) => {
441
+ onChange: (e) => {
261
442
  rename(e.target.value);
262
443
  },
263
444
  disabled,
264
445
  "data-testid": `${testid}-rename`
265
446
  }) }),
266
- /* @__PURE__ */ jsx(SubEditor, {
447
+ dataIsTree ? /* @__PURE__ */ jsxs(Fragment$1, { children: [recast ? /* @__PURE__ */ jsx("select", {
448
+ onChange: (e) => {
449
+ recast(e.target.value);
450
+ },
451
+ value: refined.type,
452
+ disabled,
453
+ "data-testid": `${testid}-recast`,
454
+ children: Object.keys(SubEditors).map((type) => /* @__PURE__ */ jsx("option", {
455
+ value: type,
456
+ children: type
457
+ }, type))
458
+ }) : null, isOpen !== void 0 && setIsOpen ? /* @__PURE__ */ jsx("span", {
459
+ className: "json_viewer",
460
+ children: JSON.stringify(data)
461
+ }) : null] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SubEditor, {
267
462
  data: refined.data,
268
463
  set,
269
464
  remove,
@@ -273,8 +468,7 @@ const JsonEditor_INTERNAL = ({ data, set, name, rename, remove, recast, path = [
273
468
  isHidden,
274
469
  Components,
275
470
  testid
276
- }),
277
- recast && dataIsJson ? /* @__PURE__ */ jsx("select", {
471
+ }), recast && dataIsJson ? /* @__PURE__ */ jsx("select", {
278
472
  onChange: disabled ? void 0 : (e) => {
279
473
  recast(e.target.value);
280
474
  },
@@ -285,8 +479,18 @@ const JsonEditor_INTERNAL = ({ data, set, name, rename, remove, recast, path = [
285
479
  value: type,
286
480
  children: type
287
481
  }, type))
288
- }) : null
289
- ]
482
+ }) : null] })
483
+ ] }), dataIsTree && isOpen !== false ? /* @__PURE__ */ jsx(SubEditor, {
484
+ data: refined.data,
485
+ set,
486
+ remove,
487
+ rename,
488
+ path,
489
+ isReadonly,
490
+ isHidden,
491
+ Components,
492
+ testid
493
+ }) : null]
290
494
  }) });
291
495
  };
292
496
 
@@ -300,25 +504,6 @@ const makeElementSetters = (data, set) => data.map((value, index) => (newValue)
300
504
  });
301
505
  });
302
506
 
303
- //#endregion
304
- //#region src/react-devtools/json-editor/editors-by-type/array-editor.tsx
305
- const ArrayEditor = ({ path = [], isReadonly = () => false, isHidden = () => false, data, set, Components, testid }) => {
306
- const setElement = makeElementSetters(data, set);
307
- return /* @__PURE__ */ jsx(Fragment$1, { children: data.map((element, index) => {
308
- const newPath = [...path, index];
309
- return /* @__PURE__ */ jsx(JsonEditor_INTERNAL, {
310
- path: newPath,
311
- isReadonly,
312
- isHidden,
313
- data: element,
314
- set: setElement[index],
315
- Components,
316
- className: "json_editor_element",
317
- testid: `${testid}-element-${index}`
318
- }, newPath.join(``));
319
- }) });
320
- };
321
-
322
507
  //#endregion
323
508
  //#region src/react-devtools/json-editor/editors-by-type/utilities/cast-json.ts
324
509
  const stringToBoolean = (str) => str === `true`;
@@ -523,15 +708,31 @@ const makePropertyRenamers = (data, set, stableKeyMapRef) => fromEntries(toEntri
523
708
  }]));
524
709
  const makePropertyRemovers = (data, set) => fromEntries(toEntries(data).map(([key]) => [key, () => {
525
710
  set(() => {
526
- const { [key]: _,...rest } = data;
527
- return rest;
711
+ let next;
712
+ if (Array.isArray(data)) {
713
+ const copy = [...data];
714
+ copy.splice(key, 1);
715
+ next = copy;
716
+ } else {
717
+ const { [key]: _,...rest } = data;
718
+ next = rest;
719
+ }
720
+ return next;
528
721
  });
529
722
  }]));
530
723
  const makePropertyRecasters = (data, set) => fromEntries(toEntries(data).map(([key, value]) => [key, (newType) => {
531
- set(() => ({
532
- ...data,
533
- [key]: castToJson(value)[newType]
534
- }));
724
+ set(() => {
725
+ let next;
726
+ if (Array.isArray(data)) {
727
+ const copy = [...data];
728
+ copy[key] = castToJson(value)[newType];
729
+ next = copy;
730
+ } else next = {
731
+ ...data,
732
+ [key]: castToJson(value)[newType]
733
+ };
734
+ return next;
735
+ });
535
736
  }]));
536
737
  const makePropertyCreationInterface = (data, set) => (key, type) => (value) => {
537
738
  set({
@@ -546,9 +747,91 @@ const makePropertySorter = (data, set, sortFn) => () => {
546
747
  set(sortedObj);
547
748
  };
548
749
 
750
+ //#endregion
751
+ //#region src/react-devtools/json-editor/editors-by-type/array-editor.tsx
752
+ const ArrayElement = ({ path, isReadonly, isHidden, data, set, remove, recast, Components, testid, viewIsOpenAtom }) => {
753
+ const index = path[path.length - 1];
754
+ const viewIsOpen = useO$1(viewIsOpenAtom);
755
+ const setViewIsOpen = useI$1(viewIsOpenAtom);
756
+ return /* @__PURE__ */ jsx(JsonEditor_INTERNAL, {
757
+ path,
758
+ name: `${index}`,
759
+ isReadonly,
760
+ isHidden,
761
+ data,
762
+ set,
763
+ remove,
764
+ recast,
765
+ className: "json_editor_element",
766
+ Components,
767
+ isOpen: viewIsOpen,
768
+ setIsOpen: setViewIsOpen,
769
+ testid: `${testid}-element-${index}`
770
+ });
771
+ };
772
+ const ArrayEditor = ({ path = [], isReadonly = () => false, isHidden = () => false, data, set, Components, testid }) => {
773
+ const { viewIsOpenAtoms, store } = useContext(DevtoolsContext);
774
+ const disabled = isReadonly(path);
775
+ const setElement = makeElementSetters(data, set);
776
+ const removeElement = makePropertyRemovers(data, set);
777
+ const recastElement = makePropertyRecasters(data, set);
778
+ return /* @__PURE__ */ jsxs(Components.ArrayWrapper, { children: [/* @__PURE__ */ jsx("div", {
779
+ className: `json_editor_elements${disabled ? ` readonly` : ``}`,
780
+ children: data.map((element, index) => {
781
+ const elementPath = [...path, index];
782
+ const pathKey = elementPath.join(`,`);
783
+ const viewIsOpenAtom = findInStore(store, viewIsOpenAtoms, `${testid}__${pathKey}`);
784
+ return /* @__PURE__ */ jsx(ArrayElement, {
785
+ path: elementPath,
786
+ isReadonly,
787
+ isHidden,
788
+ data: element,
789
+ set: setElement[index],
790
+ remove: removeElement[index],
791
+ recast: recastElement[index],
792
+ Components,
793
+ testid,
794
+ viewIsOpenAtom
795
+ }, pathKey);
796
+ })
797
+ }), /* @__PURE__ */ jsx(Components.Button, {
798
+ testid: `${testid}-add-element`,
799
+ disabled,
800
+ onClick: () => {
801
+ set((current) => {
802
+ const newData = [...current, JSON_DEFAULTS.string];
803
+ return newData;
804
+ });
805
+ },
806
+ children: /* @__PURE__ */ jsx(Components.AddIcon, {})
807
+ })] });
808
+ };
809
+
549
810
  //#endregion
550
811
  //#region src/react-devtools/json-editor/editors-by-type/object-editor.tsx
812
+ const ObjectProperty = ({ path, isReadonly, isHidden, data, set, rename, remove, recast, Components, testid, viewIsOpenAtom }) => {
813
+ const key = path[path.length - 1];
814
+ const viewIsOpen = useO(viewIsOpenAtom);
815
+ const setViewIsOpen = useI(viewIsOpenAtom);
816
+ return /* @__PURE__ */ jsx(JsonEditor_INTERNAL, {
817
+ path,
818
+ name: `${key}`,
819
+ isReadonly,
820
+ isHidden,
821
+ data,
822
+ set,
823
+ rename,
824
+ remove,
825
+ recast,
826
+ className: "json_editor_property",
827
+ Components,
828
+ isOpen: viewIsOpen,
829
+ setIsOpen: setViewIsOpen,
830
+ testid: `${testid}-property-${key}`
831
+ });
832
+ };
551
833
  const ObjectEditor = ({ path = [], isReadonly = () => false, isHidden = () => false, data, set, Components, testid }) => {
834
+ const { viewIsOpenAtoms, store } = useContext(DevtoolsContext);
552
835
  const disabled = isReadonly(path);
553
836
  const stableKeyMap = useRef(Object.keys(data).reduce((acc, key) => {
554
837
  acc[key] = key;
@@ -560,22 +843,16 @@ const ObjectEditor = ({ path = [], isReadonly = () => false, isHidden = () => fa
560
843
  const recastProperty = makePropertyRecasters(data, set);
561
844
  const sortProperties = makePropertySorter(data, set);
562
845
  const makePropertyAdder = makePropertyCreationInterface(data, set);
563
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Components.Button, {
564
- testid: `${testid}-sort-properties`,
565
- onClick: () => {
566
- sortProperties();
567
- },
568
- disabled,
569
- children: "Sort"
570
- }), /* @__PURE__ */ jsxs(Components.ObjectWrapper, { children: [/* @__PURE__ */ jsx("div", {
571
- className: "json_editor_properties",
846
+ return /* @__PURE__ */ jsxs(Components.ObjectWrapper, { children: [/* @__PURE__ */ jsx("div", {
847
+ className: `json_editor_properties${disabled ? ` readonly` : ``}`,
572
848
  children: Object.keys(data).map((key) => {
573
849
  const originalKey = stableKeyMap.current[key];
574
- const newPath = [...path, key];
575
- const originalPath = [...path, originalKey];
576
- return /* @__PURE__ */ jsx(JsonEditor_INTERNAL, {
577
- path: newPath,
578
- name: key,
850
+ const propertyPath = [...path, key];
851
+ const originalPropertyPath = [...path, originalKey];
852
+ const stablePathKey = originalPropertyPath.join(`.`);
853
+ const viewIsOpenAtom = findInStore(store, viewIsOpenAtoms, `${testid}__${stablePathKey}`);
854
+ return /* @__PURE__ */ jsx(ObjectProperty, {
855
+ path: propertyPath,
579
856
  isReadonly,
580
857
  isHidden,
581
858
  data: data[key],
@@ -583,27 +860,32 @@ const ObjectEditor = ({ path = [], isReadonly = () => false, isHidden = () => fa
583
860
  rename: renameProperty[key],
584
861
  remove: removeProperty[key],
585
862
  recast: recastProperty[key],
586
- className: "json_editor_property",
587
863
  Components,
588
- testid: `${testid}-property-${key}`
589
- }, originalPath.join(`.`));
864
+ testid,
865
+ viewIsOpenAtom
866
+ }, stablePathKey);
590
867
  })
591
- }), disabled ? /* @__PURE__ */ jsx(Components.Button, {
592
- disabled: true,
593
- testid: `${testid}-add-property`,
594
- children: "+"
595
- }) : /* @__PURE__ */ jsx(Components.Button, {
868
+ }), disabled ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Components.Button, {
869
+ disabled,
596
870
  testid: `${testid}-add-property`,
597
871
  onClick: () => {
598
872
  makePropertyAdder(`new_property`, `string`)();
599
873
  },
600
- children: "+"
874
+ children: /* @__PURE__ */ jsx(Components.AddIcon, {})
875
+ }), /* @__PURE__ */ jsx(Components.Button, {
876
+ testid: `${testid}-sort-properties`,
877
+ onClick: () => {
878
+ sortProperties();
879
+ },
880
+ disabled,
881
+ children: "Sort"
601
882
  })] })] });
602
883
  };
603
884
 
604
885
  //#endregion
605
886
  //#region src/react-devtools/json-editor/editors-by-type/primitive-editors.tsx
606
- const BooleanEditor = ({ data, set, Components, testid }) => /* @__PURE__ */ jsx(Components.BooleanWrapper, { children: /* @__PURE__ */ jsx("input", {
887
+ const BooleanEditor = ({ path = [], isReadonly = () => false, data, set, Components, testid }) => /* @__PURE__ */ jsx(Components.BooleanWrapper, { children: /* @__PURE__ */ jsx("input", {
888
+ disabled: isReadonly(path),
607
889
  "data-testid": `${testid}-boolean-input`,
608
890
  type: "checkbox",
609
891
  checked: data,
@@ -613,6 +895,7 @@ const BooleanEditor = ({ data, set, Components, testid }) => /* @__PURE__ */ jsx
613
895
  }) });
614
896
  const NullEditor = ({ Components, testid }) => /* @__PURE__ */ jsx(Components.Null, { testid: `${testid}-null` });
615
897
  const NumberEditor = ({ path = [], isReadonly = () => false, data, set, Components, testid }) => /* @__PURE__ */ jsx(Components.NumberWrapper, { children: /* @__PURE__ */ jsx(NumberInput, {
898
+ disabled: isReadonly(path),
616
899
  testid: `${testid}-number-input`,
617
900
  value: data,
618
901
  set: isReadonly(path) ? void 0 : (newValue) => {
@@ -622,6 +905,7 @@ const NumberEditor = ({ path = [], isReadonly = () => false, data, set, Componen
622
905
  }) });
623
906
  const StringEditor = ({ path = [], isReadonly = () => false, data, set, Components, testid }) => {
624
907
  return /* @__PURE__ */ jsx(Components.StringWrapper, { children: /* @__PURE__ */ jsx(TextInput, {
908
+ readOnly: isReadonly(path),
625
909
  testid: `${testid}-string-input`,
626
910
  value: data,
627
911
  set: isReadonly(path) ? void 0 : set,
@@ -629,139 +913,16 @@ const StringEditor = ({ path = [], isReadonly = () => false, data, set, Componen
629
913
  }) });
630
914
  };
631
915
 
632
- //#endregion
633
- //#region src/react-devtools/error-boundary/DefaultFallback.tsx
634
- const DefaultFallback = ({ error, errorInfo }) => {
635
- const component = errorInfo?.componentStack?.split(` `).filter(Boolean)[2];
636
- const message = error?.toString() ?? errorInfo?.componentStack ?? `Unknown error`;
637
- return /* @__PURE__ */ jsx("div", {
638
- "data-testid": "error-boundary",
639
- style: {
640
- flex: `1`,
641
- background: `black`,
642
- backgroundImage: `url(./src/assets/kablooey.gif)`,
643
- backgroundPosition: `center`,
644
- backgroundSize: `overlay`
645
- },
646
- children: /* @__PURE__ */ jsx("div", {
647
- style: {
648
- margin: `50px`,
649
- marginTop: `0`,
650
- padding: `50px`,
651
- border: `1px solid dashed`
652
- },
653
- children: /* @__PURE__ */ jsxs("span", {
654
- style: {
655
- background: `black`,
656
- color: `white`,
657
- padding: 10,
658
- paddingTop: 5
659
- },
660
- children: [
661
- `⚠️ `,
662
- /* @__PURE__ */ jsx("span", {
663
- style: {
664
- color: `#fc0`,
665
- fontWeight: 700
666
- },
667
- children: component
668
- }),
669
- ` ⚠️ `,
670
- message
671
- ]
672
- })
673
- })
674
- });
675
- };
676
-
677
- //#endregion
678
- //#region src/react-devtools/error-boundary/ReactErrorBoundary.tsx
679
- var ErrorBoundary = class extends Component {
680
- constructor(props) {
681
- super(props);
682
- this.state = {};
683
- }
684
- componentDidCatch(error, errorInfo) {
685
- this.props.onError?.(error, errorInfo);
686
- this.setState({
687
- error,
688
- errorInfo
689
- });
690
- }
691
- render() {
692
- const { error, errorInfo } = this.state;
693
- const { children, Fallback = DefaultFallback } = this.props;
694
- return errorInfo ? /* @__PURE__ */ jsx(Fallback, {
695
- error,
696
- errorInfo
697
- }) : children;
698
- }
699
- };
700
-
701
- //#endregion
702
- //#region src/react-devtools/json-editor/default-components.tsx
703
- const DEFAULT_JSON_EDITOR_COMPONENTS = {
704
- ErrorBoundary: ({ children }) => /* @__PURE__ */ jsx(ErrorBoundary, { children }),
705
- Button: ({ onClick, children, disabled, testid }) => /* @__PURE__ */ jsx("button", {
706
- type: "button",
707
- className: "json_editor_button",
708
- onClick,
709
- disabled,
710
- "data-testid": testid,
711
- children
712
- }),
713
- EditorWrapper: ({ children, className, testid }) => /* @__PURE__ */ jsx("div", {
714
- className: `json_editor` + (className ? ` ${className}` : ``),
715
- "data-testid": testid,
716
- children
717
- }),
718
- ArrayWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", {
719
- className: "json_editor_array",
720
- "data-testid": testid,
721
- children
722
- }),
723
- ObjectWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", {
724
- className: "json_editor_object",
725
- "data-testid": testid,
726
- children
727
- }),
728
- StringWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
729
- className: "json_editor_string",
730
- "data-testid": testid,
731
- children
732
- }),
733
- NumberWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
734
- className: "json_editor_number",
735
- "data-testid": testid,
736
- children
737
- }),
738
- BooleanWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
739
- className: "json_editor_boolean",
740
- "data-testid": testid,
741
- children
742
- }),
743
- Null: ({ testid }) => /* @__PURE__ */ jsx("span", {
744
- className: "json_editor_null",
745
- "data-testid": testid
746
- }),
747
- DeleteIcon: () => /* @__PURE__ */ jsx("span", {
748
- className: "json_editor_icon json_editor_delete",
749
- children: "x"
750
- }),
751
- MissingPropertyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
752
- className: "json_editor_missing_property",
753
- "data-testid": testid,
754
- children
755
- }),
756
- KeyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
757
- className: "json_editor_key",
758
- "data-testid": testid,
759
- children
760
- })
761
- };
762
-
763
916
  //#endregion
764
917
  //#region src/react-devtools/json-editor/developer-interface.tsx
918
+ const SubEditors = {
919
+ array: ArrayEditor,
920
+ boolean: BooleanEditor,
921
+ null: NullEditor,
922
+ number: NumberEditor,
923
+ object: ObjectEditor,
924
+ string: StringEditor
925
+ };
765
926
  const JsonEditor = ({ data, set, name, rename, remove, isReadonly = () => false, isHidden = () => false, className, Header, style, Components: CustomComponents = {}, testid }) => {
766
927
  const Components = {
767
928
  ...DEFAULT_JSON_EDITOR_COMPONENTS,
@@ -784,22 +945,11 @@ const JsonEditor = ({ data, set, name, rename, remove, isReadonly = () => false,
784
945
  });
785
946
  };
786
947
 
787
- //#endregion
788
- //#region src/react-devtools/json-editor/index.ts
789
- const SubEditors = {
790
- array: ArrayEditor,
791
- boolean: BooleanEditor,
792
- null: NullEditor,
793
- number: NumberEditor,
794
- object: ObjectEditor,
795
- string: StringEditor
796
- };
797
-
798
948
  //#endregion
799
949
  //#region src/react-devtools/StateEditor.tsx
800
950
  const StateEditor = ({ token }) => {
801
- const set = useI(token);
802
- const data = useO(token);
951
+ const set = useI$1(token);
952
+ const data = useO$1(token);
803
953
  return /* @__PURE__ */ jsx(JsonEditor, {
804
954
  testid: `${token.key}-state-editor`,
805
955
  data,
@@ -807,7 +957,7 @@ const StateEditor = ({ token }) => {
807
957
  });
808
958
  };
809
959
  const ReadonlySelectorViewer = ({ token }) => {
810
- const data = useO(token);
960
+ const data = useO$1(token);
811
961
  return /* @__PURE__ */ jsx(JsonEditor, {
812
962
  testid: `${token.key}-state-editor`,
813
963
  data,
@@ -826,53 +976,13 @@ const StoreEditor = ({ token }) => {
826
976
  }
827
977
  };
828
978
 
829
- //#endregion
830
- //#region src/react-devtools/store.ts
831
- function attachDevtoolsStates(store) {
832
- const introspectionStates = attachIntrospectionStates(store);
833
- const devtoolsAreOpenState = createStandaloneAtom(store, {
834
- key: `🔍 Devtools Are Open`,
835
- default: true,
836
- effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `🔍 Devtools Are Open`)]
837
- });
838
- const devtoolsViewSelectionState = createStandaloneAtom(store, {
839
- key: `🔍 Devtools View Selection`,
840
- default: `atoms`,
841
- effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `🔍 Devtools View`)]
842
- });
843
- const devtoolsViewOptionsState = createStandaloneAtom(store, {
844
- key: `🔍 Devtools View Options`,
845
- default: [
846
- `atoms`,
847
- `selectors`,
848
- `transactions`,
849
- `timelines`
850
- ],
851
- effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `🔍 Devtools View Options`)]
852
- });
853
- const viewIsOpenAtoms = createAtomFamily(store, {
854
- key: `🔍 Devtools View Is Open`,
855
- default: false,
856
- effects: (key) => typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, key + `:view-is-open`)]
857
- });
858
- return {
859
- ...introspectionStates,
860
- devtoolsAreOpenState,
861
- devtoolsViewSelectionState,
862
- devtoolsViewOptionsState,
863
- viewIsOpenAtoms,
864
- store
865
- };
866
- }
867
- const DevtoolsContext = createContext(attachDevtoolsStates(IMPLICIT.STORE));
868
-
869
979
  //#endregion
870
980
  //#region src/react-devtools/StateIndex.tsx
871
981
  const StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
872
- const setIsOpen = useI(isOpenState);
873
- const isOpen = useO(isOpenState);
874
- const state = useO(node);
875
- const stateTypeLoadable = useO(typeState);
982
+ const setIsOpen = useI$1(isOpenState);
983
+ const isOpen = useO$1(isOpenState);
984
+ const state = useO$1(node);
985
+ const stateTypeLoadable = useO$1(typeState);
876
986
  const stateType = stateTypeLoadable instanceof Promise ? `Promise` : stateTypeLoadable;
877
987
  const isPrimitive = Boolean(primitiveRefinery.refine(state));
878
988
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("header", { children: [
@@ -905,8 +1015,8 @@ const StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
905
1015
  ] }), isOpen && !isPrimitive ? /* @__PURE__ */ jsx("main", { children: /* @__PURE__ */ jsx(StoreEditor, { token: node }) }) : null] });
906
1016
  };
907
1017
  const StateIndexTreeNode = ({ node, isOpenState }) => {
908
- const setIsOpen = useI(isOpenState);
909
- const isOpen = useO(isOpenState);
1018
+ const setIsOpen = useI$1(isOpenState);
1019
+ const isOpen = useO$1(isOpenState);
910
1020
  const { typeSelectors, viewIsOpenAtoms, store } = useContext(DevtoolsContext);
911
1021
  for (const [key, childNode] of node.familyMembers) {
912
1022
  findInStore(store, viewIsOpenAtoms, key);
@@ -940,7 +1050,7 @@ const StateIndexNode = ({ node, isOpenState, typeState }) => {
940
1050
  });
941
1051
  };
942
1052
  const StateIndex = ({ tokenIndex }) => {
943
- const tokenIds = useO(tokenIndex);
1053
+ const tokenIds = useO$1(tokenIndex);
944
1054
  const { typeSelectors, viewIsOpenAtoms, store } = useContext(DevtoolsContext);
945
1055
  console.log(tokenIds);
946
1056
  return /* @__PURE__ */ jsx("article", {
@@ -1103,9 +1213,9 @@ const YouAreHere = () => {
1103
1213
  });
1104
1214
  };
1105
1215
  const TimelineLog = ({ token, isOpenState, timelineState }) => {
1106
- const timeline = useO(timelineState);
1107
- const isOpen = useO(isOpenState);
1108
- const setIsOpen = useI(isOpenState);
1216
+ const timeline = useO$1(timelineState);
1217
+ const isOpen = useO$1(isOpenState);
1218
+ const setIsOpen = useI$1(isOpenState);
1109
1219
  return /* @__PURE__ */ jsxs("section", {
1110
1220
  className: "node timeline_log",
1111
1221
  "data-testid": `timeline-${token.key}`,
@@ -1153,7 +1263,7 @@ const TimelineLog = ({ token, isOpenState, timelineState }) => {
1153
1263
  };
1154
1264
  const TimelineIndex = () => {
1155
1265
  const { timelineIndex, timelineSelectors, viewIsOpenAtoms, store } = useContext(DevtoolsContext);
1156
- const tokenIds = useO(timelineIndex);
1266
+ const tokenIds = useO$1(timelineIndex);
1157
1267
  return /* @__PURE__ */ jsx("article", {
1158
1268
  className: "index timeline_index",
1159
1269
  "data-testid": "timeline-index",
@@ -1170,9 +1280,9 @@ const TimelineIndex = () => {
1170
1280
  //#endregion
1171
1281
  //#region src/react-devtools/TransactionIndex.tsx
1172
1282
  const TransactionLog = ({ token, isOpenState, logState }) => {
1173
- const log = useO(logState);
1174
- const isOpen = useO(isOpenState);
1175
- const setIsOpen = useI(isOpenState);
1283
+ const log = useO$1(logState);
1284
+ const isOpen = useO$1(isOpenState);
1285
+ const setIsOpen = useI$1(isOpenState);
1176
1286
  return /* @__PURE__ */ jsxs("section", {
1177
1287
  className: "node transaction_log",
1178
1288
  "data-testid": `transaction-${token.key}`,
@@ -1195,7 +1305,7 @@ const TransactionLog = ({ token, isOpenState, logState }) => {
1195
1305
  };
1196
1306
  const TransactionIndex = () => {
1197
1307
  const { transactionIndex, transactionLogSelectors, viewIsOpenAtoms, store } = useContext(DevtoolsContext);
1198
- const tokenIds = useO(transactionIndex);
1308
+ const tokenIds = useO$1(transactionIndex);
1199
1309
  return /* @__PURE__ */ jsx("article", {
1200
1310
  className: "index transaction_index",
1201
1311
  "data-testid": "transaction-index",
@@ -1221,11 +1331,11 @@ const AtomIODevtools = () => {
1221
1331
  const AtomIODevtoolsInternal = () => {
1222
1332
  const constraintsRef = useRef(null);
1223
1333
  const { atomIndex, selectorIndex, devtoolsAreOpenState, devtoolsViewSelectionState, devtoolsViewOptionsState } = useContext(DevtoolsContext);
1224
- const setDevtoolsAreOpen = useI(devtoolsAreOpenState);
1225
- const devtoolsAreOpen = useO(devtoolsAreOpenState);
1226
- const setDevtoolsView = useI(devtoolsViewSelectionState);
1227
- const devtoolsView = useO(devtoolsViewSelectionState);
1228
- const devtoolsViewOptions = useO(devtoolsViewOptionsState);
1334
+ const setDevtoolsAreOpen = useI$1(devtoolsAreOpenState);
1335
+ const devtoolsAreOpen = useO$1(devtoolsAreOpenState);
1336
+ const setDevtoolsView = useI$1(devtoolsViewSelectionState);
1337
+ const devtoolsView = useO$1(devtoolsViewSelectionState);
1338
+ const devtoolsViewOptions = useO$1(devtoolsViewOptionsState);
1229
1339
  const mouseHasMoved = useRef(false);
1230
1340
  return /* @__PURE__ */ jsxs("span", {
1231
1341
  style: {