atom.io 0.28.1 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{chunk-6WL4RQMQ.js → chunk-XPYU2HY2.js} +22 -57
  2. package/eslint-plugin/dist/index.js +0 -1
  3. package/eslint-plugin/src/walk.ts +0 -1
  4. package/internal/dist/index.d.ts +4 -4
  5. package/internal/dist/index.js +1 -1
  6. package/internal/src/atom/dispose-atom.ts +0 -11
  7. package/internal/src/ingest-updates/ingest-creation-disposal.ts +16 -25
  8. package/internal/src/operation.ts +7 -7
  9. package/internal/src/selector/create-writable-selector.ts +1 -1
  10. package/internal/src/selector/dispose-selector.ts +0 -13
  11. package/internal/src/set-state/become.ts +1 -3
  12. package/internal/src/set-state/evict-downstream.ts +2 -2
  13. package/internal/src/set-state/set-atom.ts +1 -1
  14. package/internal/src/set-state/set-into-store.ts +1 -1
  15. package/internal/src/set-state/stow-update.ts +2 -2
  16. package/internal/src/store/store.ts +1 -1
  17. package/introspection/dist/index.d.ts +15 -6
  18. package/introspection/dist/index.js +620 -1
  19. package/introspection/src/attach-atom-index.ts +5 -6
  20. package/introspection/src/attach-introspection-states.ts +5 -6
  21. package/introspection/src/attach-selector-index.ts +6 -7
  22. package/introspection/src/attach-timeline-family.ts +3 -4
  23. package/introspection/src/attach-timeline-index.ts +4 -8
  24. package/introspection/src/attach-transaction-index.ts +4 -8
  25. package/introspection/src/attach-transaction-logs.ts +4 -8
  26. package/introspection/src/attach-type-selectors.ts +13 -6
  27. package/introspection/src/differ.ts +1 -1
  28. package/introspection/src/index.ts +1 -0
  29. package/introspection/src/refinery.ts +9 -7
  30. package/introspection/src/sprawl.ts +42 -0
  31. package/json/dist/index.d.ts +12 -1
  32. package/json/dist/index.js +111 -2
  33. package/json/src/index.ts +29 -0
  34. package/package.json +12 -12
  35. package/react-devtools/dist/index.d.ts +159 -2
  36. package/react-devtools/dist/index.js +260 -663
  37. package/react-devtools/src/AtomIODevtools.tsx +24 -13
  38. package/react-devtools/src/StateEditor.tsx +5 -47
  39. package/react-devtools/src/StateIndex.tsx +15 -9
  40. package/react-devtools/src/TimelineIndex.tsx +9 -6
  41. package/react-devtools/src/TransactionIndex.tsx +9 -11
  42. package/react-devtools/src/elastic-input/ElasticInput.tsx +86 -0
  43. package/react-devtools/src/elastic-input/NumberInput.tsx +199 -0
  44. package/react-devtools/src/elastic-input/TextInput.tsx +47 -0
  45. package/react-devtools/src/elastic-input/index.ts +3 -0
  46. package/react-devtools/src/error-boundary/DefaultFallback.tsx +49 -0
  47. package/react-devtools/src/error-boundary/ReactErrorBoundary.tsx +56 -0
  48. package/react-devtools/src/error-boundary/index.ts +2 -0
  49. package/react-devtools/src/index.ts +3 -0
  50. package/react-devtools/src/json-editor/assets/Untitled-1.ai +1436 -2
  51. package/react-devtools/src/json-editor/assets/data-vis.ai +1548 -1
  52. package/react-devtools/src/json-editor/comp/json-editor-sketches.ai +1451 -3
  53. package/react-devtools/src/json-editor/default-components.tsx +101 -0
  54. package/react-devtools/src/json-editor/developer-interface.tsx +81 -0
  55. package/react-devtools/src/json-editor/editors-by-type/array-editor.tsx +38 -0
  56. package/react-devtools/src/json-editor/editors-by-type/non-json.tsx +23 -0
  57. package/react-devtools/src/json-editor/editors-by-type/object-editor.tsx +128 -0
  58. package/react-devtools/src/json-editor/editors-by-type/primitive-editors.tsx +73 -0
  59. package/react-devtools/src/json-editor/editors-by-type/utilities/array-elements.ts +16 -0
  60. package/react-devtools/src/json-editor/editors-by-type/utilities/cast-json.ts +57 -0
  61. package/react-devtools/src/json-editor/editors-by-type/utilities/cast-to-json.ts +156 -0
  62. package/react-devtools/src/json-editor/editors-by-type/utilities/object-properties.ts +106 -0
  63. package/react-devtools/src/json-editor/index.ts +32 -0
  64. package/react-devtools/src/json-editor/json-editor-internal.tsx +128 -0
  65. package/react-devtools/src/json-editor/todo.md +7 -0
  66. package/react-devtools/src/store.ts +70 -46
  67. package/dist/chunk-D52JNVER.js +0 -721
  68. package/dist/chunk-YQ46F5O2.js +0 -95
@@ -1,16 +1,12 @@
1
- import { pipe, ifDefined, isArray, isRecord, doesExtend, jsonRefinery, doNothing, isPlainObject, become, mapObject, delve } from '../../dist/chunk-D52JNVER.js';
2
- import { isJson as isJson$1 } from '../../dist/chunk-YQ46F5O2.js';
3
- import '../../dist/chunk-6WL4RQMQ.js';
4
- import '../../dist/chunk-IBTHB2PI.js';
5
1
  import '../../dist/chunk-XWL6SNVU.js';
6
- import { useI, useO } from 'atom.io/react';
2
+ import { StoreContext, useI, useO } from 'atom.io/react';
7
3
  import { motion, spring, LayoutGroup } from 'framer-motion';
8
- import { forwardRef, useRef, useState, useImperativeHandle, useLayoutEffect, Fragment as Fragment$1, Component, useId } from 'react';
9
- import { atom, atomFamily, undo, redo, getState } from 'atom.io';
10
- import { findState } from 'atom.io/ephemeral';
11
- import { attachIntrospectionStates, primitiveRefinery, prettyJson, discoverType } from 'atom.io/introspection';
4
+ import { forwardRef, useRef, useState, useImperativeHandle, useLayoutEffect, createContext, useId, Component, useContext, Fragment as Fragment$1 } from 'react';
5
+ import { undo, redo, getState } from 'atom.io';
6
+ import { IMPLICIT, createStandaloneAtom, createAtomFamily, findInStore, become } from 'atom.io/internal';
7
+ import { jsonRefinery, attachIntrospectionStates, primitiveRefinery, prettyJson, discoverType } from 'atom.io/introspection';
12
8
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
- import { isJson } from 'atom.io/json';
9
+ import { isJson, fromEntries, toEntries, JSON_DEFAULTS } from 'atom.io/json';
14
10
  import { persistSync } from 'atom.io/web';
15
11
 
16
12
  var OpenClose = ({ isOpen, setIsOpen, disabled, testid }) => {
@@ -92,9 +88,9 @@ var ElasticInput = forwardRef(function ElasticInputFC(props, ref) {
92
88
  )
93
89
  ] });
94
90
  });
95
-
96
- // ../anvl/src/number/clamp.ts
97
- var clampInto = (min, max) => (value) => value < min ? min : value > max ? max : value;
91
+ function clampInto(min, max) {
92
+ return (value) => value < min ? min : value > max ? max : value;
93
+ }
98
94
  function round(value, decimalPlaces) {
99
95
  if (decimalPlaces === void 0) return value;
100
96
  const factor = 10 ** decimalPlaces;
@@ -127,11 +123,10 @@ var initRefinery = (constraints) => (input) => {
127
123
  ...DEFAULT_NUMBER_CONSTRAINTS,
128
124
  ...constraints
129
125
  };
130
- const constrained = pipe(
131
- input ?? 0,
132
- clampInto(min, max),
133
- (n) => decimalPlaces ? round(n, decimalPlaces) : n
134
- );
126
+ let constrained = clampInto(min, max)(input ?? 0);
127
+ if (decimalPlaces) {
128
+ constrained = round(constrained, decimalPlaces);
129
+ }
135
130
  return constrained;
136
131
  };
137
132
  var valueToText = (numericValue) => {
@@ -152,7 +147,7 @@ var NumberInput = ({
152
147
  onClick,
153
148
  placeholder = ``,
154
149
  set = () => null,
155
- testId,
150
+ testid,
156
151
  value = null
157
152
  }) => {
158
153
  const id = useId();
@@ -201,7 +196,7 @@ var NumberInput = ({
201
196
  name: name ?? id,
202
197
  id,
203
198
  onClick,
204
- "data-testid": `number-input-${testId ?? id}`
199
+ "data-testid": testid
205
200
  }
206
201
  ) : /* @__PURE__ */ jsx(
207
202
  "input",
@@ -215,7 +210,7 @@ var NumberInput = ({
215
210
  name: name ?? id,
216
211
  id,
217
212
  onClick,
218
- "data-testid": `number-input-${testId ?? id}`
213
+ "data-testid": testid
219
214
  }
220
215
  )
221
216
  ] });
@@ -225,7 +220,8 @@ var TextInput = ({
225
220
  set,
226
221
  label,
227
222
  placeholder,
228
- autoSize = false
223
+ autoSize = false,
224
+ testid
229
225
  }) => {
230
226
  return /* @__PURE__ */ jsxs("span", { children: [
231
227
  /* @__PURE__ */ jsx("label", { children: label }),
@@ -236,7 +232,8 @@ var TextInput = ({
236
232
  value,
237
233
  onChange: (e) => set?.(e.target.value),
238
234
  disabled: set === void 0,
239
- placeholder
235
+ placeholder,
236
+ "data-testid": testid
240
237
  }
241
238
  ) : /* @__PURE__ */ jsx(
242
239
  "input",
@@ -245,24 +242,35 @@ var TextInput = ({
245
242
  value,
246
243
  onChange: (e) => set?.(e.target.value),
247
244
  disabled: set === void 0,
248
- placeholder
245
+ placeholder,
246
+ "data-testid": testid
249
247
  }
250
248
  )
251
249
  ] });
252
250
  };
253
- var NonJsonEditor = ({ data }) => {
254
- return data === void 0 ? /* @__PURE__ */ jsx(ElasticInput, { disabled: true, value: "undefined" }) : /* @__PURE__ */ jsx(
251
+ var NonJsonEditor = ({
252
+ data,
253
+ testid
254
+ }) => {
255
+ return data === void 0 ? /* @__PURE__ */ jsx(
255
256
  ElasticInput,
256
257
  {
257
258
  disabled: true,
258
- value: Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data)
259
+ value: "undefined",
260
+ "data-testid": `${testid}-undefined`
261
+ }
262
+ ) : /* @__PURE__ */ jsx(
263
+ ElasticInput,
264
+ {
265
+ disabled: true,
266
+ value: Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data),
267
+ "data-testid": `${testid}-non-json-${Object.getPrototypeOf(data).constructor.name}`
259
268
  }
260
269
  );
261
270
  };
262
271
  var JsonEditor_INTERNAL = ({
263
272
  data,
264
273
  set,
265
- schema,
266
274
  name,
267
275
  rename,
268
276
  remove,
@@ -273,64 +281,75 @@ var JsonEditor_INTERNAL = ({
273
281
  className,
274
282
  style,
275
283
  Header: HeaderDisplay,
276
- Components
284
+ Components,
285
+ testid
277
286
  }) => {
278
- const dataIsJson = isJson$1(data);
287
+ const dataIsJson = isJson(data);
279
288
  const refined = jsonRefinery.refine(data) ?? {
280
289
  type: `non-json`,
281
290
  data
282
291
  };
283
292
  const SubEditor = dataIsJson ? SubEditors[refined.type] : NonJsonEditor;
284
293
  const disabled = isReadonly(path);
285
- return isHidden(path) ? null : /* @__PURE__ */ jsx(Components.ErrorBoundary, { children: /* @__PURE__ */ jsxs(Components.EditorWrapper, { className, style, children: [
286
- remove && /* @__PURE__ */ jsx(
287
- Components.Button,
288
- {
289
- onClick: disabled ? doNothing : remove,
290
- disabled,
291
- children: /* @__PURE__ */ jsx(Components.DeleteIcon, {})
292
- }
293
- ),
294
- HeaderDisplay && /* @__PURE__ */ jsx(HeaderDisplay, { data, schema }),
295
- rename && /* @__PURE__ */ jsx(Components.KeyWrapper, { children: /* @__PURE__ */ jsx(
296
- ElasticInput,
297
- {
298
- value: name,
299
- onChange: disabled ? doNothing : (e) => {
300
- rename(e.target.value);
301
- },
302
- disabled
303
- }
304
- ) }),
305
- /* @__PURE__ */ jsx(
306
- SubEditor,
307
- {
308
- data: refined.data,
309
- set,
310
- schema,
311
- remove,
312
- rename,
313
- path,
314
- isReadonly,
315
- isHidden,
316
- Components
317
- }
318
- ),
319
- recast && dataIsJson ? /* @__PURE__ */ jsx(
320
- "select",
321
- {
322
- onChange: disabled ? doNothing : (e) => {
323
- recast(e.target.value);
324
- },
325
- value: refined.type,
326
- disabled,
327
- children: Object.keys(SubEditors).map((type) => /* @__PURE__ */ jsx("option", { value: type, children: type }, type))
328
- }
329
- ) : null
330
- ] }) });
294
+ return isHidden(path) ? null : /* @__PURE__ */ jsx(Components.ErrorBoundary, { children: /* @__PURE__ */ jsxs(
295
+ Components.EditorWrapper,
296
+ {
297
+ className,
298
+ style,
299
+ testid,
300
+ children: [
301
+ remove ? disabled ? /* @__PURE__ */ jsx(Components.Button, { disabled: true, testid: `${testid}-delete`, children: /* @__PURE__ */ jsx(Components.DeleteIcon, {}) }) : /* @__PURE__ */ jsx(
302
+ Components.Button,
303
+ {
304
+ testid: `${testid}-delete`,
305
+ onClick: () => {
306
+ remove();
307
+ },
308
+ children: /* @__PURE__ */ jsx(Components.DeleteIcon, {})
309
+ }
310
+ ) : null,
311
+ HeaderDisplay && /* @__PURE__ */ jsx(HeaderDisplay, { data }),
312
+ rename && /* @__PURE__ */ jsx(Components.KeyWrapper, { children: /* @__PURE__ */ jsx(
313
+ ElasticInput,
314
+ {
315
+ value: name,
316
+ onChange: disabled ? void 0 : (e) => {
317
+ rename(e.target.value);
318
+ },
319
+ disabled,
320
+ "data-testid": `${testid}-rename`
321
+ }
322
+ ) }),
323
+ /* @__PURE__ */ jsx(
324
+ SubEditor,
325
+ {
326
+ data: refined.data,
327
+ set,
328
+ remove,
329
+ rename,
330
+ path,
331
+ isReadonly,
332
+ isHidden,
333
+ Components,
334
+ testid
335
+ }
336
+ ),
337
+ recast && dataIsJson ? /* @__PURE__ */ jsx(
338
+ "select",
339
+ {
340
+ onChange: disabled ? void 0 : (e) => {
341
+ recast(e.target.value);
342
+ },
343
+ value: refined.type,
344
+ disabled,
345
+ "data-testid": `${testid}-recast`,
346
+ children: Object.keys(SubEditors).map((type) => /* @__PURE__ */ jsx("option", { value: type, children: type }, type))
347
+ }
348
+ ) : null
349
+ ]
350
+ }
351
+ ) });
331
352
  };
332
-
333
- // ../hamr/react-json-editor/src/editors-by-type/utilities/array-elements.ts
334
353
  var makeElementSetters = (data, set) => data.map((value, index) => (newValue) => {
335
354
  set(() => {
336
355
  const newData = [...data];
@@ -344,7 +363,8 @@ var ArrayEditor = ({
344
363
  isHidden = () => false,
345
364
  data,
346
365
  set,
347
- Components
366
+ Components,
367
+ testid
348
368
  }) => {
349
369
  const setElement = makeElementSetters(data, set);
350
370
  return /* @__PURE__ */ jsx(Fragment, { children: data.map((element, index) => {
@@ -357,395 +377,16 @@ var ArrayEditor = ({
357
377
  isHidden,
358
378
  data: element,
359
379
  set: setElement[index],
360
- Components
380
+ Components,
381
+ className: "json_editor_element",
382
+ testid: `${testid}-element-${index}`
361
383
  },
362
384
  newPath.join(``)
363
385
  );
364
386
  }) });
365
387
  };
366
388
 
367
- // ../anvl/src/json/index.ts
368
- var JSON_TYPE_NAMES = [
369
- `array`,
370
- `boolean`,
371
- `null`,
372
- `number`,
373
- `object`,
374
- `string`
375
- ];
376
- var JSON_DEFAULTS = {
377
- array: [],
378
- boolean: false,
379
- null: null,
380
- number: 0,
381
- object: {},
382
- string: ``
383
- };
384
-
385
- // ../anvl/src/primitive/index.ts
386
- var isString = (input) => {
387
- return typeof input === `string`;
388
- };
389
- var isNumber = (input) => {
390
- return typeof input === `number`;
391
- };
392
- var isBoolean = (input) => {
393
- return typeof input === `boolean`;
394
- };
395
-
396
- // ../anvl/src/refinement/can-exist.ts
397
- var canExist = (_) => true;
398
-
399
- // ../anvl/src/refinement/cannot-exist.ts
400
- var cannotExist = (_) => false;
401
-
402
- // ../anvl/src/refinement/is-intersection.ts
403
- function mustSatisfyAllOfTheFollowing(isTypeA, logging = false, refinements = [isTypeA]) {
404
- const name = `(${refinements.map((r) => r?.name || `anon`).join(` & `)})`;
405
- const _ = {
406
- [name]: (input) => refinements.every(
407
- (refinement) => (logging && console.log(
408
- refinements.map((r) => r.name || `anon`).join(` & `),
409
- `>`,
410
- refinement.name || `anon`,
411
- `:`,
412
- refinement(input)
413
- ), refinement(input))
414
- )
415
- };
416
- const checkTypes = Object.assign(_[name], {
417
- and: (isTypeB) => mustSatisfyAllOfTheFollowing(isTypeB, logging, [
418
- ...refinements,
419
- isTypeB
420
- ])
421
- });
422
- return checkTypes;
423
- }
424
- var isIntersection = mustSatisfyAllOfTheFollowing(canExist);
425
-
426
- // ../anvl/src/refinement/is-union.ts
427
- var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isTypeA]) => {
428
- const name = `(${refinements.map((r) => r?.name || `anon`).join(` | `)})`;
429
- const _ = {
430
- [name]: (input) => refinements.some(
431
- (refinement) => (logging && console.log(
432
- refinements.map((r) => r.name || `anon`).join(` | `),
433
- `>`,
434
- refinement.name ?? `anon`,
435
- `:`,
436
- refinement(input)
437
- ), refinement(input))
438
- )
439
- };
440
- const checkTypes = Object.assign(_[name], {
441
- or: (isTypeB) => mustSatisfyOneOfTheFollowing(isTypeB, logging, [...refinements, isTypeB])
442
- });
443
- return checkTypes;
444
- };
445
- var isUnion = mustSatisfyOneOfTheFollowing(cannotExist);
446
-
447
- // ../anvl/src/refinement/index.ts
448
- var isLiteral = (value) => (input) => input === value;
449
- var isWithin = (args) => (input) => args.includes(input);
450
-
451
- // ../anvl/src/json-schema/integer.ts
452
- var isInteger = (input) => Number.isInteger(input);
453
- var parseInteger = (input) => {
454
- if (isInteger(input)) return input;
455
- throw new IntegerParseError(input);
456
- };
457
- var IntegerParseError = class extends Error {
458
- constructor(value) {
459
- super(`Could not parse integer from ${JSON.stringify(value)}`);
460
- }
461
- };
462
- var Int = Object.assign((input) => parseInteger(input), {
463
- from: (input) => pipe(
464
- input,
465
- String,
466
- Number.parseFloat,
467
- (num) => isInteger(num) ? {
468
- value: num,
469
- error: null,
470
- round: null,
471
- upper: null,
472
- lower: null,
473
- ratio: null
474
- } : {
475
- value: null,
476
- error: new IntegerParseError(input),
477
- round: Math.round(num),
478
- upper: Math.ceil(num),
479
- lower: Math.floor(num),
480
- ratio: null
481
- }
482
- ),
483
- formula: (fm) => {
484
- return (input) => {
485
- return fm(
486
- input
487
- );
488
- };
489
- }
490
- });
491
-
492
- // ../anvl/src/json-schema/refs.ts
493
- function isJsonSchemaRef(input) {
494
- return doesExtend({
495
- $ref: isString
496
- })(input);
497
- }
498
- ({
499
- $defs: {
500
- colorChannel: {
501
- type: `integer`,
502
- minimum: Int(0),
503
- maximum: Int(255)
504
- },
505
- color: {
506
- type: `object`,
507
- properties: {
508
- red: { $ref: `#/$defs/colorChannel` },
509
- green: { $ref: `#/$defs/colorChannel` },
510
- blue: { $ref: `#/$defs/colorChannel` }
511
- }
512
- }
513
- },
514
- type: `array`,
515
- items: {
516
- $ref: `#/$defs/color`
517
- }
518
- });
519
- var retrieveRef = ({
520
- refNode: { $ref },
521
- refMap = {},
522
- root
523
- }) => {
524
- if (typeof root === `boolean`) {
525
- throw new TypeError(`The root is a boolean and cannot be indexed`);
526
- }
527
- if ($ref in refMap) return { node: refMap[$ref], refMap };
528
- const [_, ...refPath] = $ref.split(`/`);
529
- const discovery = delve(root, refPath);
530
- if (discovery instanceof Error) throw discovery;
531
- let node = discovery.found;
532
- while (isJsonSchemaRef(node)) {
533
- const result = retrieveRef({ refNode: node, refMap, root });
534
- node = result.node;
535
- refMap = result.refMap;
536
- }
537
- if (isJsonSchema(node)) {
538
- return { node, refMap: { ...refMap, [$ref]: node } };
539
- }
540
- throw new TypeError(`The refNode is not a JsonSchema`);
541
- };
542
-
543
- // ../anvl/src/json-schema/string-formats.ts
544
- var JSON_SCHEMA_STRING_FORMATS = [
545
- `date-time`,
546
- `date`,
547
- `email`,
548
- `hostname`,
549
- `ipv4`,
550
- `ipv6`,
551
- `regex`,
552
- `time`,
553
- `uri-reference`,
554
- `uri-template`,
555
- `uri`,
556
- `uuid`
557
- ];
558
-
559
- // ../anvl/src/json-schema/json-schema.ts
560
- var JSON_SCHEMA_TYPE_NAMES = [...JSON_TYPE_NAMES, `integer`];
561
- [
562
- ...JSON_SCHEMA_TYPE_NAMES,
563
- `any`,
564
- `never`
565
- ];
566
- var stringSchemaStructure = {
567
- type: isLiteral(`string`),
568
- enum: ifDefined(isArray(isString)),
569
- minLength: ifDefined(isInteger),
570
- maxLength: ifDefined(isInteger),
571
- pattern: ifDefined(isString),
572
- format: ifDefined(isWithin(JSON_SCHEMA_STRING_FORMATS))
573
- };
574
- function isStringSchema(input) {
575
- return doesExtend(stringSchemaStructure)(input);
576
- }
577
- var numberSchemaStructure = {
578
- type: isLiteral(`number`),
579
- enum: ifDefined(isArray(isNumber)),
580
- minimum: ifDefined(isNumber),
581
- maximum: ifDefined(isNumber),
582
- exclusiveMinimum: ifDefined(isNumber),
583
- exclusiveMaximum: ifDefined(isNumber),
584
- multipleOf: ifDefined(isNumber)
585
- };
586
- function isNumberSchema(input) {
587
- return doesExtend(numberSchemaStructure)(input);
588
- }
589
- var integerSchemaStructure = {
590
- type: isLiteral(`integer`),
591
- enum: ifDefined(isArray(isInteger)),
592
- minimum: ifDefined(isInteger),
593
- maximum: ifDefined(isInteger),
594
- exclusiveMinimum: ifDefined(isInteger),
595
- exclusiveMaximum: ifDefined(isInteger),
596
- multipleOf: ifDefined(isInteger)
597
- };
598
- function isIntegerSchema(input) {
599
- return doesExtend(integerSchemaStructure)(input);
600
- }
601
- var booleanSchemaStructure = {
602
- type: isLiteral(`boolean`),
603
- enum: ifDefined(isArray(isBoolean))
604
- };
605
- function isBooleanSchema(input) {
606
- return doesExtend(booleanSchemaStructure)(input);
607
- }
608
- var nullSchemaStructure = {
609
- type: isLiteral(`null`)
610
- };
611
- function isNullSchema(input) {
612
- return doesExtend(nullSchemaStructure)(input);
613
- }
614
- var objectSchemaStructure = {
615
- type: isLiteral(`object`),
616
- properties: ifDefined(isRecord(isString, isJsonSchema)),
617
- required: ifDefined(isArray(isString)),
618
- additionalProperties: ifDefined(isJsonSchema),
619
- propertyNames: ifDefined(isStringSchema),
620
- minProperties: ifDefined(isInteger),
621
- maxProperties: ifDefined(isInteger),
622
- dependentSchemas: ifDefined(isRecord(isString, isJsonSchema))
623
- };
624
- function isObjectSchema(input) {
625
- return doesExtend(objectSchemaStructure)(input);
626
- }
627
- var arraySchemaStructure = {
628
- type: isLiteral(`array`),
629
- items: ifDefined(
630
- mustSatisfyOneOfTheFollowing(isJsonSchema).or(isArray(isJsonSchema))
631
- ),
632
- minItems: ifDefined(isInteger),
633
- maxItems: ifDefined(isInteger),
634
- uniqueItems: ifDefined(isBoolean)
635
- };
636
- function isArraySchema(input) {
637
- return doesExtend(arraySchemaStructure)(input);
638
- }
639
- var unionSchemaStructure = { anyOf: isArray(isJsonSchema) };
640
- function isUnionSchema(input) {
641
- return doesExtend(unionSchemaStructure)(input);
642
- }
643
- var exclusiveSchemaStructure = { oneOf: isArray(isJsonSchema) };
644
- function isExclusiveSchema(input) {
645
- return doesExtend(exclusiveSchemaStructure)(input);
646
- }
647
- var intersectionSchemaStructure = { allOf: isArray(isJsonSchema) };
648
- function isIntersectionSchema(input) {
649
- return doesExtend(intersectionSchemaStructure)(input);
650
- }
651
- var conditionalSchemaStructure = {
652
- if: isJsonSchema,
653
- then: ifDefined(isJsonSchema),
654
- else: ifDefined(isJsonSchema)
655
- };
656
- function isConditionalSchema(input) {
657
- return doesExtend(conditionalSchemaStructure)(input);
658
- }
659
- var negationSchemaStructure = { not: isJsonSchema };
660
- function isNegationSchema(input) {
661
- return doesExtend(negationSchemaStructure)(input);
662
- }
663
- var mixedSchemaStructure = {
664
- ...arraySchemaStructure,
665
- ...booleanSchemaStructure,
666
- ...integerSchemaStructure,
667
- ...nullSchemaStructure,
668
- ...numberSchemaStructure,
669
- ...objectSchemaStructure,
670
- ...stringSchemaStructure,
671
- type: isArray(isWithin(JSON_SCHEMA_TYPE_NAMES)),
672
- enum: ifDefined(
673
- isArray(isUnion.or(isInteger).or(isBoolean).or(isNumber).or(isString))
674
- )
675
- };
676
- function isMixedSchema(input) {
677
- return doesExtend(mixedSchemaStructure)(input);
678
- }
679
- var isJsonSchemaCore = isUnion.or(isArraySchema).or(isBooleanSchema).or(isConditionalSchema).or(isExclusiveSchema).or(isIntegerSchema).or(isIntersectionSchema).or(isMixedSchema).or(isNegationSchema).or(isNullSchema).or(isNumberSchema).or(isObjectSchema).or(isStringSchema).or(isUnionSchema);
680
- var isJsonSchemaRoot = doesExtend({
681
- $id: ifDefined(isString),
682
- $schema: ifDefined(isString)
683
- });
684
- var isJsonSchemaObject = isIntersection.and(isJsonSchemaCore).and(isJsonSchemaRoot);
685
- function isJsonSchema(input) {
686
- return mustSatisfyOneOfTheFollowing(isBoolean).or(isJsonSchemaObject).or(isJsonSchemaRef)(input);
687
- }
688
-
689
- // ../anvl/src/json-schema/path-into.ts
690
- var expandPathForSchema = (path) => {
691
- try {
692
- return path.flatMap((key) => {
693
- switch (typeof key) {
694
- case `string`:
695
- return [`properties`, key];
696
- case `number`:
697
- return [`items`, key];
698
- case `symbol`:
699
- throw new TypeError(
700
- `The key ${String(
701
- key
702
- )} is not a valid JSON key; expected string or number, got symbol`
703
- );
704
- default:
705
- throw new TypeError(
706
- `The key ${JSON.stringify(
707
- key
708
- )} is not a valid JSON key; expected string or number, got ${typeof key}`
709
- );
710
- }
711
- });
712
- } catch (caught) {
713
- if (caught instanceof TypeError) return caught;
714
- throw caught;
715
- }
716
- };
717
-
718
- // ../anvl/src/json-schema/find-sub-schema.ts
719
- var findSubSchema = (schema) => {
720
- if (typeof schema === `boolean`) {
721
- throw new Error(`The schema does not contain subSchemas`);
722
- }
723
- return (path) => {
724
- const pathIntoSchema = expandPathForSchema(path);
725
- if (pathIntoSchema instanceof Error) return pathIntoSchema;
726
- if (typeof schema === `boolean`) {
727
- return new TypeError(`The schema is not a JsonSchema`);
728
- }
729
- const reduction = pathIntoSchema.reduce(
730
- ({ node: node2, refMap: refMap2 = void 0 }, key) => (console.log({ node: node2, key }), isJsonSchemaRef(node2) ? retrieveRef({ refNode: node2, root: schema, refMap: refMap2 }) : { node: node2[key], refMap: refMap2 }),
731
- { node: schema, refMap: void 0 }
732
- );
733
- const { node, refMap } = reduction;
734
- if (node instanceof Error) throw node;
735
- let subSchema = node;
736
- while (isJsonSchemaRef(subSchema)) {
737
- console.log({ subSchema });
738
- subSchema = retrieveRef({ refNode: subSchema, root: schema, refMap }).node;
739
- }
740
- console.log({ subSchema });
741
- if (isJsonSchema(subSchema)) {
742
- return subSchema;
743
- }
744
- throw new TypeError(`The subSchema is not a JsonSchema`);
745
- };
746
- };
747
-
748
- // ../anvl/src/json/cast-json.ts
389
+ // react-devtools/src/json-editor/editors-by-type/utilities/cast-json.ts
749
390
  var stringToBoolean = (str) => str === `true`;
750
391
  var stringToNumber = (str) => Number(str);
751
392
  var stringToArray = (str) => str.split(`,`);
@@ -788,7 +429,7 @@ var nullToBoolean = () => false;
788
429
  var nullToArray = () => [];
789
430
  var nullToObject = () => ({});
790
431
 
791
- // ../anvl/src/refinement/smart-cast-json.ts
432
+ // react-devtools/src/json-editor/editors-by-type/utilities/cast-to-json.ts
792
433
  var castToJson = (input) => {
793
434
  const refined = jsonRefinery.refine(input);
794
435
  switch (refined?.type) {
@@ -907,8 +548,7 @@ var castToJson = (input) => {
907
548
  }
908
549
  };
909
550
  }
910
- case `null`: {
911
- refined.data;
551
+ default: {
912
552
  return {
913
553
  get array() {
914
554
  return nullToArray();
@@ -930,51 +570,59 @@ var castToJson = (input) => {
930
570
  }
931
571
  };
932
572
  }
933
- default:
934
- console.error(`Could not handle input given to castToJson`);
935
- throw new Error(`Could not handle input given to castToJson`);
936
573
  }
937
574
  };
938
575
 
939
- // ../hamr/react-json-editor/src/editors-by-type/utilities/object-properties.ts
940
- var makePropertySetters = (data, set) => mapObject(
941
- data,
942
- (value, key) => (newValue) => {
943
- set({ ...data, [key]: become(newValue)(value[key]) });
944
- }
576
+ // react-devtools/src/json-editor/editors-by-type/utilities/object-properties.ts
577
+ var makePropertySetters = (data, set) => fromEntries(
578
+ toEntries(data).map(([key, value]) => [
579
+ key,
580
+ (newValue) => {
581
+ set({ ...data, [key]: become(newValue)(value) });
582
+ }
583
+ ])
945
584
  );
946
- var makePropertyRenamers = (data, set, stableKeyMapRef) => mapObject(
947
- data,
948
- (value, key) => (newKey) => {
949
- if (!Object.hasOwn(data, newKey)) {
585
+ var makePropertyRenamers = (data, set, stableKeyMapRef) => fromEntries(
586
+ toEntries(data).map(([key, value]) => [
587
+ key,
588
+ (newKey) => {
589
+ if (!Object.hasOwn(data, newKey)) {
590
+ set(() => {
591
+ const entries = Object.entries(data);
592
+ const index = entries.findIndex(([k]) => k === key);
593
+ entries[index] = [newKey, value];
594
+ const stableKeyMap = stableKeyMapRef.current;
595
+ stableKeyMapRef.current = {
596
+ ...stableKeyMap,
597
+ [newKey]: stableKeyMap[key]
598
+ };
599
+ return Object.fromEntries(entries);
600
+ });
601
+ }
602
+ }
603
+ ])
604
+ );
605
+ var makePropertyRemovers = (data, set) => fromEntries(
606
+ toEntries(data).map(([key]) => [
607
+ key,
608
+ () => {
950
609
  set(() => {
951
- const entries = Object.entries(data);
952
- const index = entries.findIndex(([k]) => k === key);
953
- entries[index] = [newKey, value];
954
- const stableKeyMap = stableKeyMapRef.current;
955
- stableKeyMapRef.current = {
956
- ...stableKeyMap,
957
- [newKey]: stableKeyMap[key]
958
- };
959
- return Object.fromEntries(entries);
610
+ const { [key]: _, ...rest } = data;
611
+ return rest;
960
612
  });
961
613
  }
962
- }
614
+ ])
963
615
  );
964
- var makePropertyRemovers = (data, set) => mapObject(data, (_, key) => () => {
965
- set(() => {
966
- const { [key]: __, ...rest } = data;
967
- return rest;
968
- });
969
- });
970
- var makePropertyRecasters = (data, set) => mapObject(
971
- data,
972
- (value, key) => (newType) => {
973
- set(() => ({
974
- ...data,
975
- [key]: castToJson(value)[newType]
976
- }));
977
- }
616
+ var makePropertyRecasters = (data, set) => fromEntries(
617
+ toEntries(data).map(([key, value]) => [
618
+ key,
619
+ (newType) => {
620
+ set(() => ({
621
+ ...data,
622
+ [key]: castToJson(value)[newType]
623
+ }));
624
+ }
625
+ ])
978
626
  );
979
627
  var makePropertyCreationInterface = (data, set) => (key, type) => (value) => {
980
628
  set({ ...data, [key]: value ?? JSON_DEFAULTS[type] });
@@ -987,34 +635,14 @@ var makePropertySorter = (data, set, sortFn) => () => {
987
635
  }
988
636
  set(sortedObj);
989
637
  };
990
- var PropertyAdder = ({
991
- addProperty,
992
- disabled,
993
- propertyKey,
994
- Components
995
- }) => /* @__PURE__ */ jsxs(Components.MissingPropertyWrapper, { children: [
996
- /* @__PURE__ */ jsx(ElasticInput, { disabled: true, defaultValue: propertyKey }),
997
- ` `,
998
- /* @__PURE__ */ jsx(ElasticInput, { disabled: true, defaultValue: "is missing" }),
999
- /* @__PURE__ */ jsx(
1000
- Components.Button,
1001
- {
1002
- onClick: () => {
1003
- addProperty();
1004
- },
1005
- disabled,
1006
- children: "+"
1007
- }
1008
- )
1009
- ] });
1010
638
  var ObjectEditor = ({
1011
- schema,
1012
639
  path = [],
1013
640
  isReadonly = () => false,
1014
641
  isHidden = () => false,
1015
642
  data,
1016
643
  set,
1017
- Components
644
+ Components,
645
+ testid
1018
646
  }) => {
1019
647
  const disabled = isReadonly(path);
1020
648
  const stableKeyMap = useRef(
@@ -1032,21 +660,11 @@ var ObjectEditor = ({
1032
660
  const recastProperty = makePropertyRecasters(data, set);
1033
661
  const sortProperties = makePropertySorter(data, set);
1034
662
  const makePropertyAdder = makePropertyCreationInterface(data, set);
1035
- const subSchema = isPlainObject(schema) ? findSubSchema(schema)(path) : true;
1036
- const schemaKeys = isLiteral(true)(subSchema) ? true : isObjectSchema(subSchema) ? Object.keys(subSchema.properties ?? {}) : [];
1037
- const dataKeys = Object.keys(data);
1038
- const [unofficialKeys, officialKeys] = dataKeys.reduce(
1039
- ([unofficial, official], key) => {
1040
- const isOfficial = schemaKeys === true || schemaKeys.includes(key);
1041
- return isOfficial ? [unofficial, [...official, key]] : [[...unofficial, key], official];
1042
- },
1043
- [[], []]
1044
- );
1045
- const missingKeys = schemaKeys === true ? [] : schemaKeys.filter((key) => !dataKeys.includes(key));
1046
663
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1047
664
  /* @__PURE__ */ jsx(
1048
665
  Components.Button,
1049
666
  {
667
+ testid: `${testid}-sort-properties`,
1050
668
  onClick: () => {
1051
669
  sortProperties();
1052
670
  },
@@ -1055,28 +673,13 @@ var ObjectEditor = ({
1055
673
  }
1056
674
  ),
1057
675
  /* @__PURE__ */ jsxs(Components.ObjectWrapper, { children: [
1058
- /* @__PURE__ */ jsx("div", { className: "json_editor_properties", children: [...missingKeys, ...officialKeys, ...unofficialKeys].map((key) => {
676
+ /* @__PURE__ */ jsx("div", { className: "json_editor_properties", children: Object.keys(data).map((key) => {
1059
677
  const originalKey = stableKeyMap.current[key];
1060
678
  const newPath = [...path, key];
1061
679
  const originalPath = [...path, originalKey];
1062
- const isOfficial = schemaKeys === true || schemaKeys.includes(key);
1063
- const isMissing = missingKeys.includes(key);
1064
- if (isMissing) {
1065
- return /* @__PURE__ */ jsx(
1066
- PropertyAdder,
1067
- {
1068
- propertyKey: key,
1069
- addProperty: makePropertyAdder(key, `string`),
1070
- disabled,
1071
- Components
1072
- },
1073
- key + `IsMissing`
1074
- );
1075
- }
1076
680
  return /* @__PURE__ */ jsx(
1077
681
  JsonEditor_INTERNAL,
1078
682
  {
1079
- schema,
1080
683
  path: newPath,
1081
684
  name: key,
1082
685
  isReadonly,
@@ -1086,19 +689,20 @@ var ObjectEditor = ({
1086
689
  rename: renameProperty[key],
1087
690
  remove: removeProperty[key],
1088
691
  recast: recastProperty[key],
1089
- className: `json_editor_property ${isOfficial ? `json_editor_official` : `json_editor_unofficial`}`,
1090
- Components
692
+ className: "json_editor_property",
693
+ Components,
694
+ testid: `${testid}-property-${key}`
1091
695
  },
1092
696
  originalPath.join(`.`)
1093
697
  );
1094
698
  }) }),
1095
- /* @__PURE__ */ jsx(
699
+ disabled ? /* @__PURE__ */ jsx(Components.Button, { disabled: true, testid: `${testid}-add-property`, children: "+" }) : /* @__PURE__ */ jsx(
1096
700
  Components.Button,
1097
701
  {
1098
- onClick: disabled ? doNothing : () => {
702
+ testid: `${testid}-add-property`,
703
+ onClick: () => {
1099
704
  makePropertyAdder(`new_property`, `string`)();
1100
705
  },
1101
- disabled,
1102
706
  children: "+"
1103
707
  }
1104
708
  )
@@ -1108,10 +712,12 @@ var ObjectEditor = ({
1108
712
  var BooleanEditor = ({
1109
713
  data,
1110
714
  set,
1111
- Components
715
+ Components,
716
+ testid
1112
717
  }) => /* @__PURE__ */ jsx(Components.BooleanWrapper, { children: /* @__PURE__ */ jsx(
1113
718
  "input",
1114
719
  {
720
+ "data-testid": `${testid}-boolean-input`,
1115
721
  type: "checkbox",
1116
722
  checked: data,
1117
723
  onChange: (event) => {
@@ -1120,17 +726,20 @@ var BooleanEditor = ({
1120
726
  }
1121
727
  ) });
1122
728
  var NullEditor = ({
1123
- Components
1124
- }) => /* @__PURE__ */ jsx(Components.NullWrapper, { children: " " });
729
+ Components,
730
+ testid
731
+ }) => /* @__PURE__ */ jsx(Components.Null, { testid: `${testid}-null` });
1125
732
  var NumberEditor = ({
1126
733
  path = [],
1127
734
  isReadonly = () => false,
1128
735
  data,
1129
736
  set,
1130
- Components
737
+ Components,
738
+ testid
1131
739
  }) => /* @__PURE__ */ jsx(Components.NumberWrapper, { children: /* @__PURE__ */ jsx(
1132
740
  NumberInput,
1133
741
  {
742
+ testid: `${testid}-number-input`,
1134
743
  value: data,
1135
744
  set: isReadonly(path) ? void 0 : (newValue) => {
1136
745
  set(Number(newValue));
@@ -1143,11 +752,13 @@ var StringEditor = ({
1143
752
  isReadonly = () => false,
1144
753
  data,
1145
754
  set,
1146
- Components
755
+ Components,
756
+ testid
1147
757
  }) => {
1148
758
  return /* @__PURE__ */ jsx(Components.StringWrapper, { children: /* @__PURE__ */ jsx(
1149
759
  TextInput,
1150
760
  {
761
+ testid: `${testid}-string-input`,
1151
762
  value: data,
1152
763
  set: isReadonly(path) ? void 0 : set,
1153
764
  autoSize: true
@@ -1220,61 +831,48 @@ var ErrorBoundary = class extends Component {
1220
831
  };
1221
832
  var DEFAULT_JSON_EDITOR_COMPONENTS = {
1222
833
  ErrorBoundary: ({ children }) => /* @__PURE__ */ jsx(ErrorBoundary, { children }),
1223
- Button: ({ onClick, children, disabled }) => /* @__PURE__ */ jsx(
834
+ Button: ({ onClick, children, disabled, testid }) => /* @__PURE__ */ jsx(
1224
835
  "button",
1225
836
  {
1226
837
  type: "button",
1227
838
  className: "json_editor_button",
1228
839
  onClick,
1229
840
  disabled,
841
+ "data-testid": testid,
1230
842
  children
1231
843
  }
1232
844
  ),
1233
- EditorWrapper: ({ children, className }) => /* @__PURE__ */ jsx("div", { className: `json_editor` + (className ? ` ${className}` : ``), children }),
1234
- EditorLayout: ({
1235
- DeleteButton,
1236
- Header,
1237
- KeyInput,
1238
- TypeSelect,
1239
- ValueEditor,
1240
- Wrapper
1241
- }) => {
1242
- return /* @__PURE__ */ jsxs(Wrapper, { children: [
1243
- DeleteButton && /* @__PURE__ */ jsx(DeleteButton, {}),
1244
- Header && /* @__PURE__ */ jsx(Header, {}),
1245
- KeyInput && /* @__PURE__ */ jsx(KeyInput, {}),
1246
- TypeSelect && /* @__PURE__ */ jsx(TypeSelect, {}),
1247
- /* @__PURE__ */ jsx(ValueEditor, {})
1248
- ] });
1249
- },
1250
- ArrayWrapper: ({ children }) => /* @__PURE__ */ jsx("div", { className: "json_editor_array", children }),
1251
- ObjectWrapper: ({ children }) => /* @__PURE__ */ jsx("div", { className: "json_editor_object", children }),
1252
- StringWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_string", children }),
1253
- NumberWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_number", children }),
1254
- BooleanWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_boolean", children }),
1255
- NullWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_null", children }),
1256
- MissingPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("div", { className: "json_editor_property json_editor_missing", children }),
1257
- MiscastPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("div", { className: "json_editor_property json_editor_miscast", children }),
1258
- IllegalPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_property json_editor_illegal", children }),
1259
- OfficialPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_property json_editor_official", children }),
1260
- UnofficialPropertyWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_property json_editor_unofficial", children }),
845
+ EditorWrapper: ({ children, className, testid }) => /* @__PURE__ */ jsx(
846
+ "div",
847
+ {
848
+ className: `json_editor` + (className ? ` ${className}` : ``),
849
+ "data-testid": testid,
850
+ children
851
+ }
852
+ ),
853
+ ArrayWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", { className: "json_editor_array", "data-testid": testid, children }),
854
+ ObjectWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", { className: "json_editor_object", "data-testid": testid, children }),
855
+ StringWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", { className: "json_editor_string", "data-testid": testid, children }),
856
+ NumberWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", { className: "json_editor_number", "data-testid": testid, children }),
857
+ BooleanWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", { className: "json_editor_boolean", "data-testid": testid, children }),
858
+ Null: ({ testid }) => /* @__PURE__ */ jsx("span", { className: "json_editor_null", "data-testid": testid }),
1261
859
  DeleteIcon: () => /* @__PURE__ */ jsx("span", { className: "json_editor_icon json_editor_delete", children: "x" }),
1262
- KeyWrapper: ({ children }) => /* @__PURE__ */ jsx("span", { className: "json_editor_key", children })
860
+ MissingPropertyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", { className: "json_editor_missing_property", "data-testid": testid, children }),
861
+ KeyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", { className: "json_editor_key", "data-testid": testid, children })
1263
862
  };
1264
863
  var JsonEditor = ({
1265
864
  data,
1266
865
  set,
1267
- schema = true,
1268
866
  name,
1269
867
  rename,
1270
868
  remove,
1271
869
  isReadonly = () => false,
1272
870
  isHidden = () => false,
1273
- // isIllegal = () => false,
1274
871
  className,
1275
872
  Header,
1276
873
  style,
1277
- Components: CustomComponents = {}
874
+ Components: CustomComponents = {},
875
+ testid
1278
876
  }) => {
1279
877
  const Components = {
1280
878
  ...DEFAULT_JSON_EDITOR_COMPONENTS,
@@ -1286,7 +884,6 @@ var JsonEditor = ({
1286
884
  data,
1287
885
  set,
1288
886
  name,
1289
- schema,
1290
887
  rename,
1291
888
  remove,
1292
889
  path: [],
@@ -1295,12 +892,13 @@ var JsonEditor = ({
1295
892
  className,
1296
893
  Header,
1297
894
  style,
1298
- Components
895
+ Components,
896
+ testid
1299
897
  }
1300
898
  );
1301
899
  };
1302
900
 
1303
- // ../hamr/react-json-editor/src/index.ts
901
+ // react-devtools/src/json-editor/index.ts
1304
902
  var SubEditors = {
1305
903
  array: ArrayEditor,
1306
904
  boolean: BooleanEditor,
@@ -1309,41 +907,22 @@ var SubEditors = {
1309
907
  object: ObjectEditor,
1310
908
  string: StringEditor
1311
909
  };
1312
- var fallback = (fn, fallbackValue) => {
1313
- try {
1314
- return fn();
1315
- } catch (_) {
1316
- return fallbackValue;
1317
- }
1318
- };
1319
910
  var StateEditor = ({ token }) => {
1320
911
  const set = useI(token);
1321
912
  const data = useO(token);
1322
- return isJson(data) ? /* @__PURE__ */ jsx(JsonEditor, { data, set, schema: true }) : /* @__PURE__ */ jsx("div", { className: "json_editor", children: /* @__PURE__ */ jsx(
1323
- ElasticInput,
1324
- {
1325
- value: data === void 0 || data === null ? `` : typeof data === `object` && `toJson` in data && typeof data.toJson === `function` ? JSON.stringify(data.toJson()) : data instanceof Set ? `Set { ${JSON.stringify([...data]).slice(1, -1)} }` : Object.getPrototypeOf(data).constructor.name + ` ` + fallback(() => JSON.stringify(data), `?`),
1326
- disabled: true
1327
- }
1328
- ) });
913
+ return /* @__PURE__ */ jsx(JsonEditor, { testid: `${token.key}-state-editor`, data, set });
1329
914
  };
1330
915
  var ReadonlySelectorViewer = ({ token }) => {
1331
916
  const data = useO(token);
1332
- return isJson(data) ? /* @__PURE__ */ jsx(
917
+ return /* @__PURE__ */ jsx(
1333
918
  JsonEditor,
1334
919
  {
920
+ testid: `${token.key}-state-editor`,
1335
921
  data,
1336
922
  set: () => null,
1337
- schema: true,
1338
923
  isReadonly: () => true
1339
924
  }
1340
- ) : /* @__PURE__ */ jsx("div", { className: "json_editor", children: /* @__PURE__ */ jsx(
1341
- ElasticInput,
1342
- {
1343
- value: data instanceof Set ? `Set ` + JSON.stringify([...data]) : Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data),
1344
- disabled: true
1345
- }
1346
- ) });
925
+ );
1347
926
  };
1348
927
  var StoreEditor = ({ token }) => {
1349
928
  if (token.type === `readonly_selector`) {
@@ -1351,35 +930,38 @@ var StoreEditor = ({ token }) => {
1351
930
  }
1352
931
  return /* @__PURE__ */ jsx(StateEditor, { token });
1353
932
  };
1354
- var {
1355
- atomIndex,
1356
- selectorIndex,
1357
- transactionIndex,
1358
- transactionLogSelectors,
1359
- timelineIndex,
1360
- timelineSelectors,
1361
- typeSelectors
1362
- } = attachIntrospectionStates();
1363
- var devtoolsAreOpenState = atom({
1364
- key: `\u{1F441}\u200D\u{1F5E8} Devtools Are Open`,
1365
- default: true,
1366
- effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `\u{1F441}\u200D\u{1F5E8} Devtools Are Open`)]
1367
- });
1368
- var devtoolsViewSelectionState = atom({
1369
- key: `\u{1F441}\u200D\u{1F5E8} Devtools View Selection`,
1370
- default: `atoms`,
1371
- effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `\u{1F441}\u200D\u{1F5E8} Devtools View`)]
1372
- });
1373
- var devtoolsViewOptionsState = atom({
1374
- key: `\u{1F441}\u200D\u{1F5E8} Devtools View Options`,
1375
- default: [`atoms`, `selectors`, `transactions`, `timelines`],
1376
- effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `\u{1F441}\u200D\u{1F5E8} Devtools View Options`)]
1377
- });
1378
- var viewIsOpenAtoms = atomFamily({
1379
- key: `\u{1F441}\u200D\u{1F5E8} Devtools View Is Open`,
1380
- default: false,
1381
- effects: (key) => typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, key + `:view-is-open`)]
1382
- });
933
+ function attachDevtoolsStates(store) {
934
+ const introspectionStates = attachIntrospectionStates(store);
935
+ const devtoolsAreOpenState = createStandaloneAtom(store, {
936
+ key: `\u{1F50D} Devtools Are Open`,
937
+ default: true,
938
+ effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `\u{1F50D} Devtools Are Open`)]
939
+ });
940
+ const devtoolsViewSelectionState = createStandaloneAtom(store, {
941
+ key: `\u{1F50D} Devtools View Selection`,
942
+ default: `atoms`,
943
+ effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `\u{1F50D} Devtools View`)]
944
+ });
945
+ const devtoolsViewOptionsState = createStandaloneAtom(store, {
946
+ key: `\u{1F50D} Devtools View Options`,
947
+ default: [`atoms`, `selectors`, `transactions`, `timelines`],
948
+ effects: typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, `\u{1F50D} Devtools View Options`)]
949
+ });
950
+ const viewIsOpenAtoms = createAtomFamily(store, {
951
+ key: `\u{1F50D} Devtools View Is Open`,
952
+ default: false,
953
+ effects: (key) => typeof window === `undefined` ? [] : [persistSync(window.localStorage, JSON, key + `:view-is-open`)]
954
+ });
955
+ return {
956
+ ...introspectionStates,
957
+ devtoolsAreOpenState,
958
+ devtoolsViewSelectionState,
959
+ devtoolsViewOptionsState,
960
+ viewIsOpenAtoms,
961
+ store
962
+ };
963
+ }
964
+ var DevtoolsContext = createContext(attachDevtoolsStates(IMPLICIT.STORE));
1383
965
  var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
1384
966
  const setIsOpen = useI(isOpenState);
1385
967
  const isOpen = useO(isOpenState);
@@ -1424,9 +1006,10 @@ var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
1424
1006
  var StateIndexTreeNode = ({ node, isOpenState }) => {
1425
1007
  const setIsOpen = useI(isOpenState);
1426
1008
  const isOpen = useO(isOpenState);
1009
+ const { typeSelectors, viewIsOpenAtoms, store } = useContext(DevtoolsContext);
1427
1010
  for (const [key, childNode] of node.familyMembers) {
1428
- findState(viewIsOpenAtoms, key);
1429
- findState(typeSelectors, childNode.key);
1011
+ findInStore(store, viewIsOpenAtoms, key);
1012
+ findInStore(store, typeSelectors, childNode.key);
1430
1013
  }
1431
1014
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1432
1015
  /* @__PURE__ */ jsxs("header", { children: [
@@ -1447,8 +1030,8 @@ var StateIndexTreeNode = ({ node, isOpenState }) => {
1447
1030
  StateIndexNode,
1448
1031
  {
1449
1032
  node: childNode,
1450
- isOpenState: findState(viewIsOpenAtoms, childNode.key),
1451
- typeState: findState(typeSelectors, childNode.key)
1033
+ isOpenState: findInStore(store, viewIsOpenAtoms, childNode.key),
1034
+ typeState: findInStore(store, typeSelectors, childNode.key)
1452
1035
  },
1453
1036
  key
1454
1037
  )) : null
@@ -1466,13 +1049,14 @@ var StateIndexNode = ({ node, isOpenState, typeState }) => {
1466
1049
  };
1467
1050
  var StateIndex = ({ tokenIndex }) => {
1468
1051
  const tokenIds = useO(tokenIndex);
1052
+ const { typeSelectors, viewIsOpenAtoms, store } = useContext(DevtoolsContext);
1469
1053
  return /* @__PURE__ */ jsx("article", { className: "index state_index", "data-testid": "state-index", children: [...tokenIds.entries()].filter(([key]) => !key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).sort().map(([key, node]) => {
1470
1054
  return /* @__PURE__ */ jsx(
1471
1055
  StateIndexNode,
1472
1056
  {
1473
1057
  node,
1474
- isOpenState: findState(viewIsOpenAtoms, node.key),
1475
- typeState: findState(typeSelectors, node.key)
1058
+ isOpenState: findInStore(store, viewIsOpenAtoms, node.key),
1059
+ typeState: findInStore(store, typeSelectors, node.key)
1476
1060
  },
1477
1061
  key
1478
1062
  );
@@ -1704,14 +1288,15 @@ var TimelineLog = ({ token, isOpenState, timelineState }) => {
1704
1288
  ] });
1705
1289
  };
1706
1290
  var TimelineIndex = () => {
1291
+ const { timelineIndex, timelineSelectors, viewIsOpenAtoms, store } = useContext(DevtoolsContext);
1707
1292
  const tokenIds = useO(timelineIndex);
1708
1293
  return /* @__PURE__ */ jsx("article", { className: "index timeline_index", "data-testid": "timeline-index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
1709
1294
  return /* @__PURE__ */ jsx(
1710
1295
  TimelineLog,
1711
1296
  {
1712
1297
  token,
1713
- isOpenState: findState(viewIsOpenAtoms, token.key),
1714
- timelineState: findState(timelineSelectors, token.key)
1298
+ isOpenState: findInStore(store, viewIsOpenAtoms, token.key),
1299
+ timelineState: findInStore(store, timelineSelectors, token.key)
1715
1300
  },
1716
1301
  token.key
1717
1302
  );
@@ -1758,21 +1343,33 @@ var TransactionLog = ({ token, isOpenState, logState }) => {
1758
1343
  );
1759
1344
  };
1760
1345
  var TransactionIndex = () => {
1346
+ const { transactionIndex, transactionLogSelectors, viewIsOpenAtoms, store } = useContext(DevtoolsContext);
1761
1347
  const tokenIds = useO(transactionIndex);
1762
- return /* @__PURE__ */ jsx("article", { className: "index transaction_index", "data-testid": "transaction-index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
1348
+ return /* @__PURE__ */ jsx("article", { className: "index transaction_index", "data-testid": "transaction-index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F50D}`)).map((token) => {
1763
1349
  return /* @__PURE__ */ jsx(
1764
1350
  TransactionLog,
1765
1351
  {
1766
1352
  token,
1767
- isOpenState: findState(viewIsOpenAtoms, token.key),
1768
- logState: findState(transactionLogSelectors, token.key)
1353
+ isOpenState: findInStore(store, viewIsOpenAtoms, token.key),
1354
+ logState: findInStore(store, transactionLogSelectors, token.key)
1769
1355
  },
1770
1356
  token.key
1771
1357
  );
1772
1358
  }) });
1773
1359
  };
1774
1360
  var AtomIODevtools = () => {
1361
+ const store = useContext(StoreContext);
1362
+ return /* @__PURE__ */ jsx(DevtoolsContext.Provider, { value: attachDevtoolsStates(store), children: /* @__PURE__ */ jsx(AtomIODevtoolsInternal, {}) });
1363
+ };
1364
+ var AtomIODevtoolsInternal = () => {
1775
1365
  const constraintsRef = useRef(null);
1366
+ const {
1367
+ atomIndex,
1368
+ selectorIndex,
1369
+ devtoolsAreOpenState,
1370
+ devtoolsViewSelectionState,
1371
+ devtoolsViewOptionsState
1372
+ } = useContext(DevtoolsContext);
1776
1373
  const setDevtoolsAreOpen = useI(devtoolsAreOpenState);
1777
1374
  const devtoolsAreOpen = useO(devtoolsAreOpenState);
1778
1375
  const setDevtoolsView = useI(devtoolsViewSelectionState);
@@ -1827,7 +1424,7 @@ var AtomIODevtools = () => {
1827
1424
  viewOption
1828
1425
  )) })
1829
1426
  ] }),
1830
- /* @__PURE__ */ jsx(motion.main, { children: /* @__PURE__ */ jsx(LayoutGroup, { children: devtoolsView === `atoms` ? /* @__PURE__ */ jsx(StateIndex, { tokenIndex: atomIndex }) : devtoolsView === `selectors` ? /* @__PURE__ */ jsx(StateIndex, { tokenIndex: selectorIndex }) : devtoolsView === `transactions` ? /* @__PURE__ */ jsx(TransactionIndex, {}) : devtoolsView === `timelines` ? /* @__PURE__ */ jsx(TimelineIndex, {}) : null }) })
1427
+ /* @__PURE__ */ jsx(motion.main, { children: /* @__PURE__ */ jsx(LayoutGroup, { children: devtoolsView === `atoms` ? /* @__PURE__ */ jsx(StateIndex, { tokenIndex: atomIndex }) : devtoolsView === `selectors` ? /* @__PURE__ */ jsx(StateIndex, { tokenIndex: selectorIndex }) : devtoolsView === `transactions` ? /* @__PURE__ */ jsx(TransactionIndex, {}) : /* @__PURE__ */ jsx(TimelineIndex, {}) }) })
1831
1428
  ] }) : null,
1832
1429
  /* @__PURE__ */ jsx("footer", { children: /* @__PURE__ */ jsx(
1833
1430
  "button",
@@ -1840,7 +1437,7 @@ var AtomIODevtools = () => {
1840
1437
  setDevtoolsAreOpen((open) => !open);
1841
1438
  }
1842
1439
  },
1843
- children: "\u{1F441}\u200D\u{1F5E8}"
1440
+ children: "\u{1F50D}"
1844
1441
  }
1845
1442
  ) })
1846
1443
  ]
@@ -1849,4 +1446,4 @@ var AtomIODevtools = () => {
1849
1446
  ] });
1850
1447
  };
1851
1448
 
1852
- export { AtomIODevtools };
1449
+ export { AtomIODevtools, DEFAULT_JSON_EDITOR_COMPONENTS, DEFAULT_NUMBER_CONSTRAINTS, DefaultFallback, ElasticInput, ErrorBoundary, JsonEditor, NumberInput, SubEditors, TextInput, VALID_NON_NUMBERS, VALID_NON_NUMBER_INTERPRETATIONS, castToJson, clampInto, isDecimalInProgress, isValidNonNumber };