atom.io 0.25.5 → 0.26.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 (54) hide show
  1. package/data/dist/index.js +33 -25
  2. package/data/package.json +1 -4
  3. package/data/src/join.ts +0 -1
  4. package/dist/{chunk-HYXKCFVY.js → chunk-IBTHB2PI.js} +59 -60
  5. package/dist/{chunk-MR5NETHW.js → chunk-IW6WYRS7.js} +4 -5
  6. package/dist/chunk-XWL6SNVU.js +7 -0
  7. package/dist/index.js +33 -21
  8. package/ephemeral/dist/index.js +1 -1
  9. package/ephemeral/package.json +1 -4
  10. package/eslint-plugin/dist/index.d.ts +1 -1
  11. package/eslint-plugin/dist/index.js +7 -8
  12. package/eslint-plugin/package.json +1 -4
  13. package/immortal/dist/index.js +1 -1
  14. package/immortal/package.json +1 -4
  15. package/internal/dist/index.js +173 -160
  16. package/internal/package.json +1 -4
  17. package/introspection/dist/index.js +32 -30
  18. package/introspection/package.json +1 -4
  19. package/json/dist/index.js +1 -1
  20. package/json/package.json +1 -4
  21. package/package.json +27 -58
  22. package/react/dist/index.js +2 -2
  23. package/react/package.json +1 -4
  24. package/react-devtools/dist/index.js +75 -68
  25. package/react-devtools/package.json +1 -4
  26. package/realtime/dist/index.js +8 -9
  27. package/realtime/package.json +1 -4
  28. package/realtime-client/dist/index.js +6 -6
  29. package/realtime-client/package.json +1 -4
  30. package/realtime-react/dist/index.js +9 -11
  31. package/realtime-react/package.json +1 -4
  32. package/realtime-server/dist/index.js +59 -54
  33. package/realtime-server/package.json +1 -4
  34. package/realtime-testing/dist/index.js +3 -3
  35. package/realtime-testing/package.json +1 -4
  36. package/transceivers/set-rtx/dist/index.js +11 -11
  37. package/transceivers/set-rtx/package.json +1 -4
  38. package/data/dist/index.cjs +0 -953
  39. package/dist/chunk-S4N6XNPH.js +0 -38
  40. package/dist/index.cjs +0 -215
  41. package/ephemeral/dist/index.cjs +0 -11
  42. package/eslint-plugin/dist/index.cjs +0 -388
  43. package/immortal/dist/index.cjs +0 -14
  44. package/internal/dist/index.cjs +0 -3405
  45. package/introspection/dist/index.cjs +0 -449
  46. package/json/dist/index.cjs +0 -128
  47. package/react/dist/index.cjs +0 -118
  48. package/react-devtools/dist/index.cjs +0 -2191
  49. package/realtime/dist/index.cjs +0 -120
  50. package/realtime-client/dist/index.cjs +0 -569
  51. package/realtime-react/dist/index.cjs +0 -189
  52. package/realtime-server/dist/index.cjs +0 -965
  53. package/realtime-testing/dist/index.cjs +0 -201
  54. package/transceivers/set-rtx/dist/index.cjs +0 -215
@@ -1,2191 +0,0 @@
1
- 'use strict';
2
-
3
- var atom_io = require('atom.io');
4
- var introspection = require('atom.io/introspection');
5
- var react$1 = require('atom.io/react');
6
- var framerMotion = require('framer-motion');
7
- var react = require('react');
8
- var ephemeral = require('atom.io/ephemeral');
9
- var jsxRuntime = require('react/jsx-runtime');
10
-
11
- var __defProp = Object.defineProperty;
12
- var __defProps = Object.defineProperties;
13
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
14
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
17
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
18
- var __spreadValues = (a, b) => {
19
- for (var prop in b || (b = {}))
20
- if (__hasOwnProp.call(b, prop))
21
- __defNormalProp(a, prop, b[prop]);
22
- if (__getOwnPropSymbols)
23
- for (var prop of __getOwnPropSymbols(b)) {
24
- if (__propIsEnum.call(b, prop))
25
- __defNormalProp(a, prop, b[prop]);
26
- }
27
- return a;
28
- };
29
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
30
- var __restKey = (key) => typeof key === "symbol" ? key : key + "";
31
- var __objRest = (source, exclude) => {
32
- var target = {};
33
- for (var prop in source)
34
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
35
- target[prop] = source[prop];
36
- if (source != null && __getOwnPropSymbols)
37
- for (var prop of __getOwnPropSymbols(source)) {
38
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
39
- target[prop] = source[prop];
40
- }
41
- return target;
42
- };
43
-
44
- // ../anvl/src/array/index.ts
45
- var isArray = (isType) => (input) => Array.isArray(input) && input.every((item) => isType(item));
46
- var map = (f) => (a) => a.map(f);
47
- var every = (f = Boolean) => (a) => a.every(f);
48
- var allTrue = every((x) => x === true);
49
-
50
- // ../anvl/src/function/pipe.ts
51
- function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
52
- switch (arguments.length) {
53
- case 1:
54
- return a;
55
- case 2:
56
- return ab(a);
57
- case 3:
58
- return bc(ab(a));
59
- case 4:
60
- return cd(bc(ab(a)));
61
- case 5:
62
- return de(cd(bc(ab(a))));
63
- case 6:
64
- return ef(de(cd(bc(ab(a)))));
65
- case 7:
66
- return fg(ef(de(cd(bc(ab(a))))));
67
- case 8:
68
- return gh(fg(ef(de(cd(bc(ab(a)))))));
69
- case 9:
70
- return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
71
- default: {
72
- let ret = arguments[0];
73
- for (let i = 1; i < arguments.length; i++) {
74
- ret = arguments[i](ret);
75
- }
76
- return ret;
77
- }
78
- }
79
- }
80
-
81
- // ../anvl/src/function/index.ts
82
- var doNothing = () => void 0;
83
- var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
84
- originalThing instanceof Function ? originalThing() : originalThing
85
- ) : nextVersionOfThing;
86
- var pass = (...params) => (fn) => fn(...params);
87
- var raiseError = (message) => {
88
- throw new Error(message);
89
- };
90
- var fallback = (fn, fallbackValue) => {
91
- try {
92
- return fn();
93
- } catch (_) {
94
- return fallbackValue;
95
- }
96
- };
97
-
98
- // ../anvl/src/nullish/index.ts
99
- var isUndefined = (input) => input === void 0;
100
- var ifDefined = (validate) => (input) => isUndefined(input) || validate(input);
101
- var ifNullish = (alt) => (input) => input != null ? input : alt;
102
-
103
- // ../anvl/src/object/access.ts
104
- var access = (k) => Object.assign((obj) => obj[k], {
105
- in: (obj) => obj[k]
106
- });
107
-
108
- // ../anvl/src/object/entries.ts
109
- var recordToEntries = (obj) => Object.entries(obj);
110
- var entriesToRecord = (entries) => Object.fromEntries(entries);
111
-
112
- // ../anvl/src/object/mapObject.ts
113
- var mapObject = (obj, fn) => pipe(
114
- obj,
115
- recordToEntries,
116
- map(([key, val]) => [key, fn(val, key)]),
117
- entriesToRecord
118
- );
119
- var mob = (fn) => (obj) => mapObject(obj, fn);
120
-
121
- // ../anvl/src/object/refinement.ts
122
- var isNonNullObject = (input) => typeof input === `object` && input !== null;
123
- var isPlainObject = (input) => isNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype;
124
- var isRecord = (isKey, isValue) => (input) => isPlainObject(input) && Object.entries(input).every(([k, v]) => isKey(k) && isValue(v));
125
- var hasProperties = (isValue, options = { allowExtraProperties: false }) => {
126
- const name = `{${recordToEntries(
127
- isValue
128
- ).map(([k, v]) => String(k) + `:` + v.name).join(`,`)}}`;
129
- const _ = {
130
- [name]: (input) => isPlainObject(input) && pipe(
131
- isValue,
132
- Object.entries,
133
- every(([key, val]) => key in input || val(void 0))
134
- ) && pipe(
135
- input,
136
- mob(
137
- (val, key) => pipe(
138
- isValue,
139
- access(key),
140
- ifNullish(() => options.allowExtraProperties),
141
- pass(val)
142
- )
143
- ),
144
- Object.values,
145
- allTrue
146
- )
147
- };
148
- return _[name];
149
- };
150
- var ALLOW_EXTENSION = { allowExtraProperties: true };
151
- var doesExtend = (isValue) => hasProperties(isValue, ALLOW_EXTENSION);
152
-
153
- // ../anvl/src/object/sprawl.ts
154
- var sprawl = (tree, inspector) => {
155
- const walk = (path, node) => {
156
- var _a2;
157
- const inspect = (p, n) => {
158
- const result2 = inspector(p, n);
159
- if (result2) return result2;
160
- return null;
161
- };
162
- const result = inspect(path, node);
163
- if ((_a2 = result == null ? void 0 : result.jobComplete) != null ? _a2 : result == null ? void 0 : result.pathComplete) {
164
- return result;
165
- }
166
- const childEntries = Array.isArray(node) ? node.map((v, i) => [i, v]) : isPlainObject(node) ? Object.entries(node) : [];
167
- for (const [k, v] of childEntries) {
168
- const subResult = walk([...path, k], v);
169
- if (subResult == null ? void 0 : subResult.jobComplete) {
170
- return subResult;
171
- }
172
- }
173
- return {};
174
- };
175
- walk([], tree);
176
- };
177
-
178
- // ../anvl/src/object/index.ts
179
- var delve = (obj, path) => {
180
- const found = path.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
181
- return found === void 0 ? new Error(`Not found`) : { found };
182
- };
183
-
184
- // ../anvl/src/refinement/can-exist.ts
185
- var canExist = (_) => true;
186
-
187
- // ../anvl/src/refinement/cannot-exist.ts
188
- var cannotExist = (_) => false;
189
-
190
- // ../anvl/src/refinement/is-intersection.ts
191
- function mustSatisfyAllOfTheFollowing(isTypeA, logging = false, refinements = [isTypeA]) {
192
- const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` & `)})`;
193
- const _ = {
194
- [name]: (input) => refinements.every(
195
- (refinement) => (logging && console.log(
196
- refinements.map((r) => r.name || `anon`).join(` & `),
197
- `>`,
198
- refinement.name || `anon`,
199
- `:`,
200
- refinement(input)
201
- ), refinement(input))
202
- )
203
- };
204
- const checkTypes = Object.assign(_[name], {
205
- and: (isTypeB) => mustSatisfyAllOfTheFollowing(isTypeB, logging, [
206
- ...refinements,
207
- isTypeB
208
- ])
209
- });
210
- return checkTypes;
211
- }
212
- var isIntersection = mustSatisfyAllOfTheFollowing(canExist);
213
-
214
- // ../anvl/src/refinement/is-union.ts
215
- var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isTypeA]) => {
216
- const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` | `)})`;
217
- const _ = {
218
- [name]: (input) => refinements.some(
219
- (refinement) => {
220
- var _a2;
221
- return logging && console.log(
222
- refinements.map((r) => r.name || `anon`).join(` | `),
223
- `>`,
224
- (_a2 = refinement.name) != null ? _a2 : `anon`,
225
- `:`,
226
- refinement(input)
227
- ), refinement(input);
228
- }
229
- )
230
- };
231
- const checkTypes = Object.assign(_[name], {
232
- or: (isTypeB) => mustSatisfyOneOfTheFollowing(isTypeB, logging, [...refinements, isTypeB])
233
- });
234
- return checkTypes;
235
- };
236
- var isUnion = mustSatisfyOneOfTheFollowing(cannotExist);
237
-
238
- // ../anvl/src/json/index.ts
239
- var stringifyJson = (json) => JSON.stringify(json);
240
- var JSON_TYPE_NAMES = [
241
- `array`,
242
- `boolean`,
243
- `null`,
244
- `number`,
245
- `object`,
246
- `string`
247
- ];
248
- var JSON_DEFAULTS = {
249
- array: [],
250
- boolean: false,
251
- null: null,
252
- number: 0,
253
- object: {},
254
- string: ``
255
- };
256
-
257
- // ../anvl/src/primitive/index.ts
258
- var isString = (input) => {
259
- return typeof input === `string`;
260
- };
261
- var isNumber = (input) => {
262
- return typeof input === `number`;
263
- };
264
- var isBoolean = (input) => {
265
- return typeof input === `boolean`;
266
- };
267
-
268
- // ../anvl/src/refinement/refine-json.ts
269
- var JSON_PROTOTYPES = [
270
- `Array`,
271
- `Boolean`,
272
- `Number`,
273
- `Object`,
274
- `String`
275
- ];
276
- var refineJsonType = (data) => data === null ? { type: `null`, data: null } : isBoolean(data) ? { type: `boolean`, data } : isNumber(data) ? { type: `number`, data } : isString(data) ? { type: `string`, data } : Array.isArray(data) ? { type: `array`, data } : isPlainObject(data) ? { type: `object`, data } : raiseError(
277
- data === void 0 ? `undefined passed to refineJsonType. This is not valid JSON.` : `${stringifyJson(data)} with prototype "${Object.getPrototypeOf(data).constructor.name}" passed to refineJsonType. This is not valid JSON.`
278
- );
279
- var isJson = (input) => {
280
- var _a2;
281
- if (input === null) return true;
282
- if (input === void 0) return false;
283
- const prototype = (_a2 = Object.getPrototypeOf(input)) == null ? void 0 : _a2.constructor.name;
284
- const refine = JSON_PROTOTYPES.includes(prototype);
285
- return refine;
286
- };
287
-
288
- // ../anvl/src/refinement/refinery.ts
289
- var Refinery = class {
290
- constructor(supported) {
291
- this.supported = supported;
292
- }
293
- refine(input) {
294
- for (const [key, refiner] of Object.entries(this.supported)) {
295
- try {
296
- if (
297
- // @ts-expect-error that's the point
298
- refiner(input) === true && refiner !== Boolean
299
- ) {
300
- return { type: key, data: input };
301
- }
302
- } catch (e) {
303
- try {
304
- if (input instanceof refiner) {
305
- return { type: key, data: input };
306
- }
307
- } catch (_) {
308
- }
309
- }
310
- }
311
- return null;
312
- }
313
- };
314
- var jsonRefinery = new Refinery({
315
- number: (input) => typeof input === `number`,
316
- string: (input) => typeof input === `string`,
317
- boolean: (input) => typeof input === `boolean`,
318
- object: isPlainObject,
319
- array: (input) => Array.isArray(input),
320
- null: (input) => input === null
321
- });
322
- var discoverType = (input) => {
323
- if (input === void 0) {
324
- return `undefined`;
325
- }
326
- const refined = jsonRefinery.refine(input);
327
- if (refined) {
328
- return refined.type;
329
- }
330
- return Object.getPrototypeOf(input).constructor.name;
331
- };
332
-
333
- // ../anvl/src/refinement/index.ts
334
- var isLiteral = (value) => (input) => input === value;
335
- var isWithin = (args) => (input) => args.includes(input);
336
-
337
- // ../anvl/src/tree/differ.ts
338
- function diffNumber(a, b) {
339
- const sign = a < b ? `+` : `-`;
340
- return {
341
- summary: `${sign}${Math.abs(a - b)} (${a} \u2192 ${b})`
342
- };
343
- }
344
- function diffString(a, b) {
345
- const sign = a.length < b.length ? `+` : `-`;
346
- return {
347
- summary: `${sign}${Math.abs(a.length - b.length)} ("${a}" \u2192 "${b}")`
348
- };
349
- }
350
- function diffBoolean(a, b) {
351
- return {
352
- summary: `${a} \u2192 ${b}`
353
- };
354
- }
355
- function diffObject(a, b, recurse) {
356
- let summary = ``;
357
- const added = [];
358
- const removed = [];
359
- const changed = [];
360
- sprawl(a, (path, nodeA) => {
361
- let key;
362
- for (key of path) {
363
- const nodeB = b[key];
364
- if (nodeB === void 0) {
365
- removed.push([key, JSON.stringify(nodeA)]);
366
- } else {
367
- const delta = recurse(nodeA, nodeB);
368
- if (delta.summary !== `No Change`) {
369
- changed.push([key, delta]);
370
- }
371
- }
372
- }
373
- });
374
- sprawl(b, (path, nodeB) => {
375
- let key;
376
- for (key of path) {
377
- const nodeA = a[key];
378
- if (nodeA === void 0) {
379
- added.push([key, JSON.stringify(nodeB)]);
380
- }
381
- }
382
- });
383
- summary = `\uFF5E${changed.length} \uFF0B${added.length} \uFF0D${removed.length}`;
384
- return {
385
- summary,
386
- added,
387
- removed,
388
- changed
389
- };
390
- }
391
- function diffArray(a, b, recurse) {
392
- return diffObject(a, b, recurse);
393
- }
394
- var Differ = class {
395
- constructor(leafRefinery, treeRefinery, diffFunctions) {
396
- this.leafRefinery = leafRefinery;
397
- this.treeRefinery = treeRefinery;
398
- this.leafDiffers = {};
399
- this.treeDiffers = {};
400
- for (const key of Object.keys(leafRefinery.supported)) {
401
- const diffFunction = diffFunctions[key];
402
- this.leafDiffers[key] = diffFunction;
403
- }
404
- for (const key of Object.keys(treeRefinery.supported)) {
405
- const diffFunction = diffFunctions[key];
406
- this.treeDiffers[key] = diffFunction;
407
- }
408
- }
409
- diff(a, b) {
410
- var _a2, _b2;
411
- if (a === b) {
412
- return { summary: `No Change` };
413
- }
414
- try {
415
- if (JSON.stringify(a) === JSON.stringify(b)) {
416
- return { summary: `No Change` };
417
- }
418
- } catch (thrown) {
419
- console.error(`Error stringifying`, a, b);
420
- }
421
- const aRefined = (_a2 = this.leafRefinery.refine(a)) != null ? _a2 : this.treeRefinery.refine(a);
422
- const bRefined = (_b2 = this.leafRefinery.refine(b)) != null ? _b2 : this.treeRefinery.refine(b);
423
- if (aRefined !== null && bRefined !== null) {
424
- if (aRefined.type === bRefined.type) {
425
- if (aRefined.type in this.leafDiffers) {
426
- const delta = this.leafDiffers[aRefined.type](
427
- aRefined.data,
428
- bRefined.data
429
- );
430
- return delta;
431
- }
432
- if (aRefined.type in this.treeDiffers) {
433
- const delta = this.treeDiffers[aRefined.type](
434
- aRefined.data,
435
- bRefined.data,
436
- (x, y) => this.diff(x, y)
437
- );
438
- return delta;
439
- }
440
- }
441
- }
442
- const typeA = discoverType(a);
443
- const typeB = discoverType(b);
444
- if (typeA === typeB) {
445
- return {
446
- summary: `${typeA} \u2192 ${typeB}`
447
- };
448
- }
449
- return {
450
- summary: `Type change: ${typeA} \u2192 ${typeB}`
451
- };
452
- }
453
- };
454
-
455
- // __unstable__/web-effects/src/storage.ts
456
- var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, onSet }) => {
457
- const savedValue = storage.getItem(key);
458
- if (savedValue != null) setSelf(parse(savedValue));
459
- onSet(({ newValue }) => {
460
- if (newValue == null) {
461
- storage.removeItem(key);
462
- return;
463
- }
464
- storage.setItem(key, stringify(newValue));
465
- });
466
- };
467
- var lazyLocalStorageEffect = persistAtom(window.localStorage)(JSON);
468
- var OpenClose = ({ isOpen, setIsOpen, disabled, testid }) => {
469
- return /* @__PURE__ */ jsxRuntime.jsx(
470
- "button",
471
- {
472
- type: "button",
473
- "data-testid": testid,
474
- className: `carat ${isOpen ? `open` : `closed`}`,
475
- onClick: () => {
476
- setIsOpen((prev) => !prev);
477
- },
478
- disabled,
479
- children: "\u25B6"
480
- }
481
- );
482
- };
483
- var button = {
484
- OpenClose
485
- };
486
- var ElasticInput = react.forwardRef(function ElasticInputFC(props, ref) {
487
- var _a2, _b2, _c, _d, _e, _f;
488
- const inputRef = react.useRef(null);
489
- const spanRef = react.useRef(null);
490
- const [inputWidth, setInputWidth] = react.useState(`auto`);
491
- react.useImperativeHandle(
492
- ref,
493
- () => ({
494
- focus: () => {
495
- var _a3;
496
- (_a3 = inputRef.current) == null ? void 0 : _a3.focus();
497
- }
498
- })
499
- );
500
- const extraWidth = props.type === `number` ? 15 : 0;
501
- react.useLayoutEffect(() => {
502
- if (spanRef.current) {
503
- setInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`);
504
- const interval = setInterval(() => {
505
- if (spanRef.current) {
506
- setInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`);
507
- }
508
- }, 1e3);
509
- return () => {
510
- clearInterval(interval);
511
- };
512
- }
513
- }, [(_a2 = inputRef.current) == null ? void 0 : _a2.value, props.value]);
514
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: `inline-block`, position: `relative` }, children: [
515
- /* @__PURE__ */ jsxRuntime.jsx(
516
- "input",
517
- __spreadProps(__spreadValues({}, props), {
518
- ref: inputRef,
519
- style: __spreadValues({
520
- padding: 0,
521
- borderRadius: 0,
522
- border: `none`,
523
- fontFamily: `inherit`,
524
- fontSize: `inherit`,
525
- width: inputWidth
526
- }, props.style)
527
- })
528
- ),
529
- /* @__PURE__ */ jsxRuntime.jsx(
530
- "span",
531
- {
532
- ref: spanRef,
533
- style: {
534
- padding: (_b2 = props.style) == null ? void 0 : _b2.padding,
535
- position: `absolute`,
536
- visibility: `hidden`,
537
- // color: `red`,
538
- whiteSpace: `pre`,
539
- fontFamily: (_d = (_c = props.style) == null ? void 0 : _c.fontFamily) != null ? _d : `inherit`,
540
- fontSize: (_f = (_e = props.style) == null ? void 0 : _e.fontSize) != null ? _f : `inherit`
541
- },
542
- children: props.value
543
- }
544
- )
545
- ] });
546
- });
547
-
548
- // ../anvl/src/number/clamp.ts
549
- var clampInto = (min, max) => (value) => value < min ? min : value > max ? max : value;
550
- function round(value, decimalPlaces) {
551
- if (decimalPlaces === void 0) return value;
552
- const factor = 10 ** decimalPlaces;
553
- return Math.round(value * factor) / factor;
554
- }
555
- var VALID_NON_NUMBERS = [``, `-`, `.`, `-.`];
556
- var isValidNonNumber = (input) => VALID_NON_NUMBERS.includes(input);
557
- var VALID_NON_NUMBER_INTERPRETATIONS = {
558
- "": null,
559
- "-": 0,
560
- ".": 0,
561
- "-.": 0
562
- };
563
- var isDecimalInProgress = (input) => input === `0` || !Number.isNaN(Number(input)) && input.includes(`.`);
564
- var textToValue = (input, allowDecimal) => {
565
- if (isValidNonNumber(input)) return VALID_NON_NUMBER_INTERPRETATIONS[input];
566
- return allowDecimal ? Number.parseFloat(input) : Math.round(Number.parseFloat(input));
567
- };
568
- var DEFAULT_NUMBER_CONSTRAINTS = {
569
- max: Number.POSITIVE_INFINITY,
570
- min: Number.NEGATIVE_INFINITY,
571
- decimalPlaces: 100,
572
- nullable: true
573
- };
574
- var initRefinery = (constraints) => (input) => {
575
- if (input === null && constraints.nullable === true) {
576
- return null;
577
- }
578
- const { max, min, decimalPlaces } = __spreadValues(__spreadValues({}, DEFAULT_NUMBER_CONSTRAINTS), constraints);
579
- const constrained = pipe(
580
- input != null ? input : 0,
581
- clampInto(min, max),
582
- (n) => decimalPlaces ? round(n, decimalPlaces) : n
583
- );
584
- return constrained;
585
- };
586
- var valueToText = (numericValue) => {
587
- if (numericValue === null || numericValue === void 0) {
588
- return ``;
589
- }
590
- return numericValue.toString();
591
- };
592
- var NumberInput = ({
593
- autoSize = false,
594
- decimalPlaces,
595
- disabled = false,
596
- label,
597
- max,
598
- min,
599
- name,
600
- onChange,
601
- onClick,
602
- placeholder = ``,
603
- set = () => null,
604
- testId,
605
- value = null
606
- }) => {
607
- const id = react.useId();
608
- const [temporaryEntry, setTemporaryEntry] = react.useState(null);
609
- const userHasMadeDeliberateChange = react.useRef(false);
610
- const refine = initRefinery({ max, min, decimalPlaces, nullable: true });
611
- const allowDecimal = decimalPlaces === void 0 || decimalPlaces > 0;
612
- const handleBlur = () => {
613
- if (userHasMadeDeliberateChange.current) {
614
- set(refine(value != null ? value : null));
615
- setTemporaryEntry(null);
616
- }
617
- userHasMadeDeliberateChange.current = false;
618
- };
619
- const handleChange = (event) => {
620
- var _a2;
621
- if (onChange) onChange(event);
622
- if (set === void 0) return;
623
- userHasMadeDeliberateChange.current = true;
624
- const input = event.target.value;
625
- if (isValidNonNumber(input) || isDecimalInProgress(input)) {
626
- setTemporaryEntry(input);
627
- const textInterpretation = isDecimalInProgress(input) ? input : (_a2 = min == null ? void 0 : min.toString()) != null ? _a2 : `0`;
628
- const newValue = textToValue(textInterpretation, allowDecimal);
629
- set(refine(newValue));
630
- return;
631
- }
632
- setTemporaryEntry(null);
633
- const inputIsNumeric = !Number.isNaN(Number(input)) && !input.includes(` `) || allowDecimal && input === `.` || allowDecimal && input === `-.` || input === `` || input === `-`;
634
- const numericValue = textToValue(input, allowDecimal);
635
- if (inputIsNumeric) {
636
- set(refine(numericValue));
637
- }
638
- };
639
- const displayValue = temporaryEntry != null ? temporaryEntry : valueToText(value ? refine(value) : value);
640
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
641
- label && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, children: label }),
642
- autoSize ? /* @__PURE__ */ jsxRuntime.jsx(
643
- ElasticInput,
644
- {
645
- type: "text",
646
- value: displayValue,
647
- placeholder: placeholder != null ? placeholder : `-`,
648
- onChange: handleChange,
649
- onBlur: handleBlur,
650
- disabled,
651
- name: name != null ? name : id,
652
- id,
653
- onClick,
654
- "data-testid": `number-input-${testId != null ? testId : id}`
655
- }
656
- ) : /* @__PURE__ */ jsxRuntime.jsx(
657
- "input",
658
- {
659
- type: "text",
660
- value: displayValue,
661
- placeholder: placeholder != null ? placeholder : `-`,
662
- onChange: handleChange,
663
- onBlur: handleBlur,
664
- disabled,
665
- name: name != null ? name : id,
666
- id,
667
- onClick,
668
- "data-testid": `number-input-${testId != null ? testId : id}`
669
- }
670
- )
671
- ] });
672
- };
673
- var TextInput = ({
674
- value,
675
- set,
676
- label,
677
- placeholder,
678
- autoSize = false
679
- }) => {
680
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
681
- /* @__PURE__ */ jsxRuntime.jsx("label", { children: label }),
682
- autoSize ? /* @__PURE__ */ jsxRuntime.jsx(
683
- ElasticInput,
684
- {
685
- type: "text",
686
- value,
687
- onChange: (e) => set == null ? void 0 : set(e.target.value),
688
- disabled: set === void 0,
689
- placeholder
690
- }
691
- ) : /* @__PURE__ */ jsxRuntime.jsx(
692
- "input",
693
- {
694
- type: "text",
695
- value,
696
- onChange: (e) => set == null ? void 0 : set(e.target.value),
697
- disabled: set === void 0,
698
- placeholder
699
- }
700
- )
701
- ] });
702
- };
703
- var NonJsonEditor = ({ data }) => {
704
- return data === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(ElasticInput, { disabled: true, value: "undefined" }) : /* @__PURE__ */ jsxRuntime.jsx(
705
- ElasticInput,
706
- {
707
- disabled: true,
708
- value: Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data)
709
- }
710
- );
711
- };
712
- var JsonEditor_INTERNAL = ({
713
- data,
714
- set,
715
- schema,
716
- name,
717
- rename,
718
- remove,
719
- recast,
720
- path = [],
721
- isReadonly = () => false,
722
- isHidden = () => false,
723
- className,
724
- style,
725
- Header: HeaderDisplay,
726
- Components
727
- }) => {
728
- const dataIsJson = isJson(data);
729
- const refined = dataIsJson ? refineJsonType(data) : { type: `non-json`, data };
730
- const SubEditor = dataIsJson ? SubEditors[refined.type] : NonJsonEditor;
731
- const disabled = isReadonly(path);
732
- return isHidden(path) ? null : /* @__PURE__ */ jsxRuntime.jsx(Components.ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsxs(Components.EditorWrapper, { className, style, children: [
733
- remove && /* @__PURE__ */ jsxRuntime.jsx(
734
- Components.Button,
735
- {
736
- onClick: disabled ? doNothing : remove,
737
- disabled,
738
- children: /* @__PURE__ */ jsxRuntime.jsx(Components.DeleteIcon, {})
739
- }
740
- ),
741
- HeaderDisplay && /* @__PURE__ */ jsxRuntime.jsx(HeaderDisplay, { data, schema }),
742
- rename && /* @__PURE__ */ jsxRuntime.jsx(Components.KeyWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
743
- ElasticInput,
744
- {
745
- value: name,
746
- onChange: disabled ? doNothing : (e) => {
747
- rename(e.target.value);
748
- },
749
- disabled
750
- }
751
- ) }),
752
- /* @__PURE__ */ jsxRuntime.jsx(
753
- SubEditor,
754
- {
755
- data: refined.data,
756
- set,
757
- schema,
758
- remove,
759
- rename,
760
- path,
761
- isReadonly,
762
- isHidden,
763
- Components
764
- }
765
- ),
766
- recast && dataIsJson ? /* @__PURE__ */ jsxRuntime.jsx(
767
- "select",
768
- {
769
- onChange: disabled ? doNothing : (e) => {
770
- recast(e.target.value);
771
- },
772
- value: refined.type,
773
- disabled,
774
- children: Object.keys(SubEditors).map((type) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: type, children: type }, type))
775
- }
776
- ) : null
777
- ] }) });
778
- };
779
-
780
- // ../hamr/react-json-editor/src/editors-by-type/utilities/array-elements.ts
781
- var makeElementSetters = (data, set) => data.map((value, index) => (newValue) => {
782
- set(() => {
783
- const newData = [...data];
784
- newData[index] = become(newValue)(value);
785
- return newData;
786
- });
787
- });
788
- var ArrayEditor = ({
789
- path = [],
790
- isReadonly = () => false,
791
- isHidden = () => false,
792
- data,
793
- set,
794
- Components
795
- }) => {
796
- const setElement = makeElementSetters(data, set);
797
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: data.map((element, index) => {
798
- const newPath = [...path, index];
799
- return /* @__PURE__ */ jsxRuntime.jsx(
800
- JsonEditor_INTERNAL,
801
- {
802
- path: newPath,
803
- isReadonly,
804
- isHidden,
805
- data: element,
806
- set: setElement[index],
807
- Components
808
- },
809
- newPath.join(``)
810
- );
811
- }) });
812
- };
813
-
814
- // ../anvl/src/json-schema/integer.ts
815
- var isInteger = (input) => Number.isInteger(input);
816
- var parseInteger = (input) => {
817
- if (isInteger(input)) return input;
818
- throw new IntegerParseError(input);
819
- };
820
- var IntegerParseError = class extends Error {
821
- constructor(value) {
822
- super(`Could not parse integer from ${JSON.stringify(value)}`);
823
- }
824
- };
825
- var Int = Object.assign((input) => parseInteger(input), {
826
- from: (input) => pipe(
827
- input,
828
- String,
829
- Number.parseFloat,
830
- (num) => isInteger(num) ? {
831
- value: num,
832
- error: null,
833
- round: null,
834
- upper: null,
835
- lower: null,
836
- ratio: null
837
- } : {
838
- value: null,
839
- error: new IntegerParseError(input),
840
- round: Math.round(num),
841
- upper: Math.ceil(num),
842
- lower: Math.floor(num),
843
- ratio: null
844
- }
845
- ),
846
- formula: (fm) => {
847
- return (input) => {
848
- return fm(
849
- input
850
- );
851
- };
852
- }
853
- });
854
-
855
- // ../anvl/src/json-schema/refs.ts
856
- function isJsonSchemaRef(input) {
857
- return doesExtend({
858
- $ref: isString
859
- })(input);
860
- }
861
- ({
862
- $defs: {
863
- colorChannel: {
864
- type: `integer`,
865
- minimum: Int(0),
866
- maximum: Int(255)
867
- },
868
- color: {
869
- type: `object`,
870
- properties: {
871
- red: { $ref: `#/$defs/colorChannel` },
872
- green: { $ref: `#/$defs/colorChannel` },
873
- blue: { $ref: `#/$defs/colorChannel` }
874
- }
875
- }
876
- },
877
- type: `array`,
878
- items: {
879
- $ref: `#/$defs/color`
880
- }
881
- });
882
- var retrieveRef = ({
883
- refNode: { $ref },
884
- refMap = {},
885
- root
886
- }) => {
887
- if (typeof root === `boolean`) {
888
- throw new TypeError(`The root is a boolean and cannot be indexed`);
889
- }
890
- if ($ref in refMap) return { node: refMap[$ref], refMap };
891
- const [_, ...refPath] = $ref.split(`/`);
892
- const discovery = delve(root, refPath);
893
- if (discovery instanceof Error) throw discovery;
894
- let node = discovery.found;
895
- while (isJsonSchemaRef(node)) {
896
- const result = retrieveRef({ refNode: node, refMap, root });
897
- node = result.node;
898
- refMap = result.refMap;
899
- }
900
- if (isJsonSchema(node)) {
901
- return { node, refMap: __spreadProps(__spreadValues({}, refMap), { [$ref]: node }) };
902
- }
903
- throw new TypeError(`The refNode is not a JsonSchema`);
904
- };
905
-
906
- // ../anvl/src/json-schema/string-formats.ts
907
- var JSON_SCHEMA_STRING_FORMATS = [
908
- `date-time`,
909
- `date`,
910
- `email`,
911
- `hostname`,
912
- `ipv4`,
913
- `ipv6`,
914
- `regex`,
915
- `time`,
916
- `uri-reference`,
917
- `uri-template`,
918
- `uri`,
919
- `uuid`
920
- ];
921
-
922
- // ../anvl/src/json-schema/json-schema.ts
923
- var JSON_SCHEMA_TYPE_NAMES = [...JSON_TYPE_NAMES, `integer`];
924
- [
925
- ...JSON_SCHEMA_TYPE_NAMES,
926
- `any`,
927
- `never`
928
- ];
929
- var stringSchemaStructure = {
930
- type: isLiteral(`string`),
931
- enum: ifDefined(isArray(isString)),
932
- minLength: ifDefined(isInteger),
933
- maxLength: ifDefined(isInteger),
934
- pattern: ifDefined(isString),
935
- format: ifDefined(isWithin(JSON_SCHEMA_STRING_FORMATS))
936
- };
937
- function isStringSchema(input) {
938
- return doesExtend(stringSchemaStructure)(input);
939
- }
940
- var numberSchemaStructure = {
941
- type: isLiteral(`number`),
942
- enum: ifDefined(isArray(isNumber)),
943
- minimum: ifDefined(isNumber),
944
- maximum: ifDefined(isNumber),
945
- exclusiveMinimum: ifDefined(isNumber),
946
- exclusiveMaximum: ifDefined(isNumber),
947
- multipleOf: ifDefined(isNumber)
948
- };
949
- function isNumberSchema(input) {
950
- return doesExtend(numberSchemaStructure)(input);
951
- }
952
- var integerSchemaStructure = {
953
- type: isLiteral(`integer`),
954
- enum: ifDefined(isArray(isInteger)),
955
- minimum: ifDefined(isInteger),
956
- maximum: ifDefined(isInteger),
957
- exclusiveMinimum: ifDefined(isInteger),
958
- exclusiveMaximum: ifDefined(isInteger),
959
- multipleOf: ifDefined(isInteger)
960
- };
961
- function isIntegerSchema(input) {
962
- return doesExtend(integerSchemaStructure)(input);
963
- }
964
- var booleanSchemaStructure = {
965
- type: isLiteral(`boolean`),
966
- enum: ifDefined(isArray(isBoolean))
967
- };
968
- function isBooleanSchema(input) {
969
- return doesExtend(booleanSchemaStructure)(input);
970
- }
971
- var nullSchemaStructure = {
972
- type: isLiteral(`null`)
973
- };
974
- function isNullSchema(input) {
975
- return doesExtend(nullSchemaStructure)(input);
976
- }
977
- var objectSchemaStructure = {
978
- type: isLiteral(`object`),
979
- properties: ifDefined(isRecord(isString, isJsonSchema)),
980
- required: ifDefined(isArray(isString)),
981
- additionalProperties: ifDefined(isJsonSchema),
982
- propertyNames: ifDefined(isStringSchema),
983
- minProperties: ifDefined(isInteger),
984
- maxProperties: ifDefined(isInteger),
985
- dependentSchemas: ifDefined(isRecord(isString, isJsonSchema))
986
- };
987
- function isObjectSchema(input) {
988
- return doesExtend(objectSchemaStructure)(input);
989
- }
990
- var arraySchemaStructure = {
991
- type: isLiteral(`array`),
992
- items: ifDefined(
993
- mustSatisfyOneOfTheFollowing(isJsonSchema).or(isArray(isJsonSchema))
994
- ),
995
- minItems: ifDefined(isInteger),
996
- maxItems: ifDefined(isInteger),
997
- uniqueItems: ifDefined(isBoolean)
998
- };
999
- function isArraySchema(input) {
1000
- return doesExtend(arraySchemaStructure)(input);
1001
- }
1002
- var unionSchemaStructure = { anyOf: isArray(isJsonSchema) };
1003
- function isUnionSchema(input) {
1004
- return doesExtend(unionSchemaStructure)(input);
1005
- }
1006
- var exclusiveSchemaStructure = { oneOf: isArray(isJsonSchema) };
1007
- function isExclusiveSchema(input) {
1008
- return doesExtend(exclusiveSchemaStructure)(input);
1009
- }
1010
- var intersectionSchemaStructure = { allOf: isArray(isJsonSchema) };
1011
- function isIntersectionSchema(input) {
1012
- return doesExtend(intersectionSchemaStructure)(input);
1013
- }
1014
- var conditionalSchemaStructure = {
1015
- if: isJsonSchema,
1016
- then: ifDefined(isJsonSchema),
1017
- else: ifDefined(isJsonSchema)
1018
- };
1019
- function isConditionalSchema(input) {
1020
- return doesExtend(conditionalSchemaStructure)(input);
1021
- }
1022
- var negationSchemaStructure = { not: isJsonSchema };
1023
- function isNegationSchema(input) {
1024
- return doesExtend(negationSchemaStructure)(input);
1025
- }
1026
- var mixedSchemaStructure = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, arraySchemaStructure), booleanSchemaStructure), integerSchemaStructure), nullSchemaStructure), numberSchemaStructure), objectSchemaStructure), stringSchemaStructure), {
1027
- type: isArray(isWithin(JSON_SCHEMA_TYPE_NAMES)),
1028
- enum: ifDefined(
1029
- isArray(isUnion.or(isInteger).or(isBoolean).or(isNumber).or(isString))
1030
- )
1031
- });
1032
- function isMixedSchema(input) {
1033
- return doesExtend(mixedSchemaStructure)(input);
1034
- }
1035
- 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);
1036
- var isJsonSchemaRoot = doesExtend({
1037
- $id: ifDefined(isString),
1038
- $schema: ifDefined(isString)
1039
- });
1040
- var isJsonSchemaObject = isIntersection.and(isJsonSchemaCore).and(isJsonSchemaRoot);
1041
- function isJsonSchema(input) {
1042
- return mustSatisfyOneOfTheFollowing(isBoolean).or(isJsonSchemaObject).or(isJsonSchemaRef)(input);
1043
- }
1044
-
1045
- // ../anvl/src/json-schema/path-into.ts
1046
- var expandPathForSchema = (path) => {
1047
- try {
1048
- return path.flatMap((key) => {
1049
- switch (typeof key) {
1050
- case `string`:
1051
- return [`properties`, key];
1052
- case `number`:
1053
- return [`items`, key];
1054
- case `symbol`:
1055
- throw new TypeError(
1056
- `The key ${String(
1057
- key
1058
- )} is not a valid JSON key; expected string or number, got symbol`
1059
- );
1060
- default:
1061
- throw new TypeError(
1062
- `The key ${JSON.stringify(
1063
- key
1064
- )} is not a valid JSON key; expected string or number, got ${typeof key}`
1065
- );
1066
- }
1067
- });
1068
- } catch (caught) {
1069
- if (caught instanceof TypeError) return caught;
1070
- throw caught;
1071
- }
1072
- };
1073
-
1074
- // ../anvl/src/json-schema/find-sub-schema.ts
1075
- var findSubSchema = (schema) => {
1076
- if (typeof schema === `boolean`) {
1077
- throw new Error(`The schema does not contain subSchemas`);
1078
- }
1079
- return (path) => {
1080
- const pathIntoSchema = expandPathForSchema(path);
1081
- if (pathIntoSchema instanceof Error) return pathIntoSchema;
1082
- if (typeof schema === `boolean`) {
1083
- return new TypeError(`The schema is not a JsonSchema`);
1084
- }
1085
- const reduction = pathIntoSchema.reduce(
1086
- ({ 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 }),
1087
- { node: schema, refMap: void 0 }
1088
- );
1089
- const { node, refMap } = reduction;
1090
- if (node instanceof Error) throw node;
1091
- let subSchema = node;
1092
- while (isJsonSchemaRef(subSchema)) {
1093
- console.log({ subSchema });
1094
- subSchema = retrieveRef({ refNode: subSchema, root: schema, refMap }).node;
1095
- }
1096
- console.log({ subSchema });
1097
- if (isJsonSchema(subSchema)) {
1098
- return subSchema;
1099
- }
1100
- throw new TypeError(`The subSchema is not a JsonSchema`);
1101
- };
1102
- };
1103
-
1104
- // ../anvl/src/json/cast-json.ts
1105
- var stringToBoolean = (str) => str === `true`;
1106
- var stringToNumber = (str) => Number(str);
1107
- var stringToArray = (str) => str.split(`,`);
1108
- var stringToObject = (str) => {
1109
- try {
1110
- return JSON.parse(str);
1111
- } catch (e) {
1112
- return { [str]: str };
1113
- }
1114
- };
1115
- var objectToString = (obj) => JSON.stringify(obj);
1116
- var objectToBoolean = (obj) => obj.true === true;
1117
- var objectToNumber = (obj) => {
1118
- var _a2, _b2, _c;
1119
- return Number((_c = (_b2 = (_a2 = obj.number) != null ? _a2 : obj.size) != null ? _b2 : obj.count) != null ? _c : 0);
1120
- };
1121
- var objectToArray = (obj) => Object.entries(obj);
1122
- var booleanToString = (bool) => bool.toString();
1123
- var booleanToNumber = (bool) => +bool;
1124
- var booleanToObject = (bool) => ({
1125
- [bool.toString()]: bool
1126
- });
1127
- var booleanToArray = (bool) => [bool];
1128
- var numberToString = (num) => num.toString();
1129
- var numberToBoolean = (num) => num === 1;
1130
- var numberToObject = (num) => ({
1131
- number: num
1132
- });
1133
- var numberToArray = (num) => Array(num).fill(null);
1134
- var arrayToString = (arr) => arr.join(`,`);
1135
- var arrayToNumber = (arr) => arr.length;
1136
- var arrayToBoolean = (arr) => typeof arr[0] === `boolean` ? arr[0] : arr.length > 0;
1137
- var arrayToObject = (arr) => arr.reduce(
1138
- (acc, cur, idx) => {
1139
- acc[`${idx}`] = cur;
1140
- return acc;
1141
- },
1142
- {}
1143
- );
1144
- var nullToString = () => ``;
1145
- var nullToNumber = () => 0;
1146
- var nullToBoolean = () => false;
1147
- var nullToArray = () => [];
1148
- var nullToObject = () => ({});
1149
-
1150
- // ../anvl/src/refinement/smart-cast-json.ts
1151
- var castToJson = (input) => {
1152
- const json = refineJsonType(input);
1153
- return {
1154
- to: {
1155
- array: () => {
1156
- switch (json.type) {
1157
- case `array`:
1158
- return json.data;
1159
- case `object`:
1160
- return objectToArray(json.data);
1161
- case `string`:
1162
- return stringToArray(json.data);
1163
- case `boolean`:
1164
- return booleanToArray(json.data);
1165
- case `number`:
1166
- return numberToArray(json.data);
1167
- case `null`:
1168
- return nullToArray();
1169
- }
1170
- },
1171
- boolean: () => {
1172
- switch (json.type) {
1173
- case `array`:
1174
- return arrayToBoolean(json.data);
1175
- case `object`:
1176
- return objectToBoolean(json.data);
1177
- case `string`:
1178
- return stringToBoolean(json.data);
1179
- case `boolean`:
1180
- return json.data;
1181
- case `number`:
1182
- return numberToBoolean(json.data);
1183
- case `null`:
1184
- return nullToBoolean();
1185
- }
1186
- },
1187
- number: () => {
1188
- switch (json.type) {
1189
- case `array`:
1190
- return arrayToNumber(json.data);
1191
- case `object`:
1192
- return objectToNumber(json.data);
1193
- case `string`:
1194
- return stringToNumber(json.data);
1195
- case `boolean`:
1196
- return booleanToNumber(json.data);
1197
- case `number`:
1198
- return json.data;
1199
- case `null`:
1200
- return nullToNumber();
1201
- }
1202
- },
1203
- object: () => {
1204
- switch (json.type) {
1205
- case `array`:
1206
- return arrayToObject(json.data);
1207
- case `object`:
1208
- return json.data;
1209
- case `string`:
1210
- return stringToObject(json.data);
1211
- case `boolean`:
1212
- return booleanToObject(json.data);
1213
- case `number`:
1214
- return numberToObject(json.data);
1215
- case `null`:
1216
- return nullToObject();
1217
- }
1218
- },
1219
- string: () => {
1220
- switch (json.type) {
1221
- case `array`:
1222
- return arrayToString(json.data);
1223
- case `object`:
1224
- return objectToString(json.data);
1225
- case `string`:
1226
- return json.data;
1227
- case `boolean`:
1228
- return booleanToString(json.data);
1229
- case `number`:
1230
- return numberToString(json.data);
1231
- case `null`:
1232
- return nullToString();
1233
- }
1234
- },
1235
- null: () => null
1236
- }
1237
- };
1238
- };
1239
-
1240
- // ../hamr/react-json-editor/src/editors-by-type/utilities/object-properties.ts
1241
- var makePropertySetters = (data, set) => mapObject(
1242
- data,
1243
- (value, key) => (newValue) => {
1244
- set(__spreadProps(__spreadValues({}, data), { [key]: become(newValue)(value[key]) }));
1245
- }
1246
- );
1247
- var makePropertyRenamers = (data, set, stableKeyMapRef) => mapObject(
1248
- data,
1249
- (value, key) => (newKey) => {
1250
- if (!Object.hasOwn(data, newKey)) {
1251
- set(() => {
1252
- const entries = Object.entries(data);
1253
- const index = entries.findIndex(([k]) => k === key);
1254
- entries[index] = [newKey, value];
1255
- const stableKeyMap = stableKeyMapRef.current;
1256
- stableKeyMapRef.current = __spreadProps(__spreadValues({}, stableKeyMap), {
1257
- [newKey]: stableKeyMap[key]
1258
- });
1259
- return Object.fromEntries(entries);
1260
- });
1261
- }
1262
- }
1263
- );
1264
- var makePropertyRemovers = (data, set) => mapObject(data, (_, key) => () => {
1265
- set(() => {
1266
- const _a2 = data, rest = __objRest(_a2, [__restKey(key)]);
1267
- return rest;
1268
- });
1269
- });
1270
- var makePropertyRecasters = (data, set) => mapObject(
1271
- data,
1272
- (value, key) => (newType) => {
1273
- set(() => __spreadProps(__spreadValues({}, data), {
1274
- [key]: castToJson(value).to[newType]()
1275
- }));
1276
- }
1277
- );
1278
- var makePropertyCreationInterface = (data, set) => (key, type) => (value) => {
1279
- set(__spreadProps(__spreadValues({}, data), { [key]: value != null ? value : JSON_DEFAULTS[type] }));
1280
- };
1281
- var makePropertySorter = (data, set, sortFn) => () => {
1282
- const sortedKeys = Object.keys(data).sort(sortFn);
1283
- const sortedObj = {};
1284
- for (const key of sortedKeys) {
1285
- sortedObj[key] = data[key];
1286
- }
1287
- set(sortedObj);
1288
- };
1289
- var PropertyAdder = ({
1290
- addProperty,
1291
- disabled,
1292
- propertyKey,
1293
- Components
1294
- }) => /* @__PURE__ */ jsxRuntime.jsxs(Components.MissingPropertyWrapper, { children: [
1295
- /* @__PURE__ */ jsxRuntime.jsx(ElasticInput, { disabled: true, defaultValue: propertyKey }),
1296
- ` `,
1297
- /* @__PURE__ */ jsxRuntime.jsx(ElasticInput, { disabled: true, defaultValue: "is missing" }),
1298
- /* @__PURE__ */ jsxRuntime.jsx(
1299
- Components.Button,
1300
- {
1301
- onClick: () => {
1302
- addProperty();
1303
- },
1304
- disabled,
1305
- children: "+"
1306
- }
1307
- )
1308
- ] });
1309
- var ObjectEditor = ({
1310
- schema,
1311
- path = [],
1312
- isReadonly = () => false,
1313
- isHidden = () => false,
1314
- data,
1315
- set,
1316
- Components
1317
- }) => {
1318
- var _a2;
1319
- const disabled = isReadonly(path);
1320
- const stableKeyMap = react.useRef(
1321
- Object.keys(data).reduce(
1322
- (acc, key) => {
1323
- acc[key] = key;
1324
- return acc;
1325
- },
1326
- {}
1327
- )
1328
- );
1329
- const setProperty = makePropertySetters(data, set);
1330
- const renameProperty = makePropertyRenamers(data, set, stableKeyMap);
1331
- const removeProperty = makePropertyRemovers(data, set);
1332
- const recastProperty = makePropertyRecasters(data, set);
1333
- const sortProperties = makePropertySorter(data, set);
1334
- const makePropertyAdder = makePropertyCreationInterface(data, set);
1335
- const subSchema = isPlainObject(schema) ? findSubSchema(schema)(path) : true;
1336
- const schemaKeys = isLiteral(true)(subSchema) ? true : isObjectSchema(subSchema) ? Object.keys((_a2 = subSchema.properties) != null ? _a2 : {}) : [];
1337
- const dataKeys = Object.keys(data);
1338
- const [unofficialKeys, officialKeys] = dataKeys.reduce(
1339
- ([unofficial, official], key) => {
1340
- const isOfficial = schemaKeys === true || schemaKeys.includes(key);
1341
- return isOfficial ? [unofficial, [...official, key]] : [[...unofficial, key], official];
1342
- },
1343
- [[], []]
1344
- );
1345
- const missingKeys = schemaKeys === true ? [] : schemaKeys.filter((key) => !dataKeys.includes(key));
1346
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1347
- /* @__PURE__ */ jsxRuntime.jsx(
1348
- Components.Button,
1349
- {
1350
- onClick: () => {
1351
- sortProperties();
1352
- },
1353
- disabled,
1354
- children: "Sort"
1355
- }
1356
- ),
1357
- /* @__PURE__ */ jsxRuntime.jsxs(Components.ObjectWrapper, { children: [
1358
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "json_editor_properties", children: [...missingKeys, ...officialKeys, ...unofficialKeys].map((key) => {
1359
- const originalKey = stableKeyMap.current[key];
1360
- const newPath = [...path, key];
1361
- const originalPath = [...path, originalKey];
1362
- const isOfficial = schemaKeys === true || schemaKeys.includes(key);
1363
- const isMissing = missingKeys.includes(key);
1364
- if (isMissing) {
1365
- return /* @__PURE__ */ jsxRuntime.jsx(
1366
- PropertyAdder,
1367
- {
1368
- propertyKey: key,
1369
- addProperty: makePropertyAdder(key, `string`),
1370
- disabled,
1371
- Components
1372
- },
1373
- key + `IsMissing`
1374
- );
1375
- }
1376
- return /* @__PURE__ */ jsxRuntime.jsx(
1377
- JsonEditor_INTERNAL,
1378
- {
1379
- schema,
1380
- path: newPath,
1381
- name: key,
1382
- isReadonly,
1383
- isHidden,
1384
- data: data[key],
1385
- set: setProperty[key],
1386
- rename: renameProperty[key],
1387
- remove: removeProperty[key],
1388
- recast: recastProperty[key],
1389
- className: `json_editor_property ${isOfficial ? `json_editor_official` : `json_editor_unofficial`}`,
1390
- Components
1391
- },
1392
- originalPath.join(`.`)
1393
- );
1394
- }) }),
1395
- /* @__PURE__ */ jsxRuntime.jsx(
1396
- Components.Button,
1397
- {
1398
- onClick: disabled ? doNothing : () => {
1399
- makePropertyAdder(`new_property`, `string`)();
1400
- },
1401
- disabled,
1402
- children: "+"
1403
- }
1404
- )
1405
- ] })
1406
- ] });
1407
- };
1408
- var BooleanEditor = ({
1409
- data,
1410
- set,
1411
- Components
1412
- }) => /* @__PURE__ */ jsxRuntime.jsx(Components.BooleanWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
1413
- "input",
1414
- {
1415
- type: "checkbox",
1416
- checked: data,
1417
- onChange: (event) => {
1418
- set(event.target.checked);
1419
- }
1420
- }
1421
- ) });
1422
- var NullEditor = ({
1423
- Components
1424
- }) => /* @__PURE__ */ jsxRuntime.jsx(Components.NullWrapper, { children: '" "' });
1425
- var NumberEditor = ({
1426
- path = [],
1427
- isReadonly = () => false,
1428
- data,
1429
- set,
1430
- Components
1431
- }) => /* @__PURE__ */ jsxRuntime.jsx(Components.NumberWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
1432
- NumberInput,
1433
- {
1434
- value: data,
1435
- set: isReadonly(path) ? void 0 : (newValue) => {
1436
- set(Number(newValue));
1437
- },
1438
- autoSize: true
1439
- }
1440
- ) });
1441
- var StringEditor = ({
1442
- path = [],
1443
- isReadonly = () => false,
1444
- data,
1445
- set,
1446
- Components
1447
- }) => {
1448
- return /* @__PURE__ */ jsxRuntime.jsx(Components.StringWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
1449
- TextInput,
1450
- {
1451
- value: data,
1452
- set: isReadonly(path) ? void 0 : set,
1453
- autoSize: true
1454
- }
1455
- ) });
1456
- };
1457
- var DefaultFallback = ({ error, errorInfo }) => {
1458
- var _a2, _b2, _c;
1459
- const component = (_a2 = errorInfo == null ? void 0 : errorInfo.componentStack) == null ? void 0 : _a2.split(` `).filter(Boolean)[2];
1460
- const message = (_c = (_b2 = error == null ? void 0 : error.toString()) != null ? _b2 : errorInfo == null ? void 0 : errorInfo.componentStack) != null ? _c : `Unknown error`;
1461
- return /* @__PURE__ */ jsxRuntime.jsx(
1462
- "div",
1463
- {
1464
- "data-testid": "error-boundary",
1465
- style: {
1466
- flex: `1`,
1467
- background: `black`,
1468
- backgroundImage: `url(./src/assets/kablooey.gif)`,
1469
- backgroundPosition: `center`,
1470
- // backgroundRepeat: `no-repeat`,
1471
- backgroundSize: `overlay`
1472
- },
1473
- children: /* @__PURE__ */ jsxRuntime.jsx(
1474
- "div",
1475
- {
1476
- style: {
1477
- margin: `50px`,
1478
- marginTop: `0`,
1479
- padding: `50px`,
1480
- border: `1px solid dashed`
1481
- },
1482
- children: /* @__PURE__ */ jsxRuntime.jsxs(
1483
- "span",
1484
- {
1485
- style: {
1486
- background: `black`,
1487
- color: `white`,
1488
- padding: 10,
1489
- paddingTop: 5
1490
- },
1491
- children: [
1492
- `\u26A0\uFE0F `,
1493
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: `#fc0`, fontWeight: 700 }, children: component }),
1494
- ` \u26A0\uFE0F `,
1495
- message
1496
- ]
1497
- }
1498
- )
1499
- }
1500
- )
1501
- }
1502
- );
1503
- };
1504
- var ErrorBoundary = class extends react.Component {
1505
- constructor(props) {
1506
- super(props);
1507
- this.state = {};
1508
- }
1509
- componentDidCatch(error, errorInfo) {
1510
- var _a2, _b2;
1511
- (_b2 = (_a2 = this.props).onError) == null ? void 0 : _b2.call(_a2, error, errorInfo);
1512
- this.setState({
1513
- error,
1514
- errorInfo
1515
- });
1516
- }
1517
- render() {
1518
- const { error, errorInfo } = this.state;
1519
- const { children, Fallback = DefaultFallback } = this.props;
1520
- return errorInfo ? /* @__PURE__ */ jsxRuntime.jsx(Fallback, { error, errorInfo }) : children;
1521
- }
1522
- };
1523
- var DEFAULT_JSON_EDITOR_COMPONENTS = {
1524
- ErrorBoundary: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children }),
1525
- Button: ({ onClick, children, disabled }) => /* @__PURE__ */ jsxRuntime.jsx(
1526
- "button",
1527
- {
1528
- type: "button",
1529
- className: "json_editor_button",
1530
- onClick,
1531
- disabled,
1532
- children
1533
- }
1534
- ),
1535
- EditorWrapper: ({ children, className }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: `json_editor ` + className, children }),
1536
- EditorLayout: ({
1537
- DeleteButton,
1538
- Header,
1539
- KeyInput,
1540
- TypeSelect,
1541
- ValueEditor,
1542
- Wrapper
1543
- }) => {
1544
- return /* @__PURE__ */ jsxRuntime.jsxs(Wrapper, { children: [
1545
- DeleteButton && /* @__PURE__ */ jsxRuntime.jsx(DeleteButton, {}),
1546
- Header && /* @__PURE__ */ jsxRuntime.jsx(Header, {}),
1547
- KeyInput && /* @__PURE__ */ jsxRuntime.jsx(KeyInput, {}),
1548
- TypeSelect && /* @__PURE__ */ jsxRuntime.jsx(TypeSelect, {}),
1549
- /* @__PURE__ */ jsxRuntime.jsx(ValueEditor, {})
1550
- ] });
1551
- },
1552
- ArrayWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "json_editor_array", children }),
1553
- ObjectWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "json_editor_object", children }),
1554
- StringWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "json_editor_string", children }),
1555
- NumberWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "json_editor_number", children }),
1556
- BooleanWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "json_editor_boolean", children }),
1557
- NullWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "json_editor_null", children }),
1558
- MissingPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "json_editor_property json_editor_missing", children }),
1559
- MiscastPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "json_editor_property json_editor_miscast", children }),
1560
- IllegalPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "json_editor_property json_editor_illegal", children }),
1561
- OfficialPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "json_editor_property json_editor_official", children }),
1562
- UnofficialPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "json_editor_property json_editor_unofficial", children }),
1563
- DeleteIcon: () => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "json_editor_icon json_editor_delete", children: "x" }),
1564
- KeyWrapper: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "json_editor_key", children })
1565
- };
1566
- var JsonEditor = ({
1567
- data,
1568
- set,
1569
- schema = true,
1570
- name,
1571
- rename,
1572
- remove,
1573
- isReadonly = () => false,
1574
- isHidden = () => false,
1575
- // isIllegal = () => false,
1576
- className,
1577
- Header,
1578
- style,
1579
- Components: CustomComponents = {}
1580
- }) => {
1581
- const Components = __spreadValues(__spreadValues({}, DEFAULT_JSON_EDITOR_COMPONENTS), CustomComponents);
1582
- return /* @__PURE__ */ jsxRuntime.jsx(
1583
- JsonEditor_INTERNAL,
1584
- {
1585
- data,
1586
- set,
1587
- name,
1588
- schema,
1589
- rename,
1590
- remove,
1591
- path: [],
1592
- isReadonly,
1593
- isHidden,
1594
- className,
1595
- Header,
1596
- style,
1597
- Components
1598
- }
1599
- );
1600
- };
1601
-
1602
- // ../hamr/react-json-editor/src/index.ts
1603
- var SubEditors = {
1604
- array: ArrayEditor,
1605
- boolean: BooleanEditor,
1606
- null: NullEditor,
1607
- number: NumberEditor,
1608
- object: ObjectEditor,
1609
- string: StringEditor
1610
- };
1611
- var StateEditor = ({ token }) => {
1612
- const set = react$1.useI(token);
1613
- const data = react$1.useO(token);
1614
- return isJson(data) ? /* @__PURE__ */ jsxRuntime.jsx(JsonEditor, { data, set, schema: true }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "json_editor", children: /* @__PURE__ */ jsxRuntime.jsx(
1615
- ElasticInput,
1616
- {
1617
- value: 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), `?`),
1618
- disabled: true
1619
- }
1620
- ) });
1621
- };
1622
- var ReadonlySelectorViewer = ({ token }) => {
1623
- const data = react$1.useO(token);
1624
- return isJson(data) ? /* @__PURE__ */ jsxRuntime.jsx(
1625
- JsonEditor,
1626
- {
1627
- data,
1628
- set: () => null,
1629
- schema: true,
1630
- isReadonly: () => true
1631
- }
1632
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "json_editor", children: /* @__PURE__ */ jsxRuntime.jsx(
1633
- ElasticInput,
1634
- {
1635
- value: data instanceof Set ? `Set ` + JSON.stringify([...data]) : Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data),
1636
- disabled: true
1637
- }
1638
- ) });
1639
- };
1640
- var StoreEditor = ({ token }) => {
1641
- if (token.type === `readonly_selector`) {
1642
- return /* @__PURE__ */ jsxRuntime.jsx(ReadonlySelectorViewer, { token });
1643
- }
1644
- return /* @__PURE__ */ jsxRuntime.jsx(StateEditor, { token });
1645
- };
1646
- var findStateTypeState = atom_io.selectorFamily({
1647
- key: `\u{1F441}\u200D\u{1F5E8} State Type`,
1648
- get: (token) => ({ get }) => {
1649
- let state;
1650
- try {
1651
- state = get(token);
1652
- } catch (error) {
1653
- return `error`;
1654
- }
1655
- if (state === void 0) return `undefined`;
1656
- if (isJson(state)) return refineJsonType(state).type;
1657
- return Object.getPrototypeOf(state).constructor.name;
1658
- }
1659
- });
1660
- var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
1661
- var _a2, _b2;
1662
- const setIsOpen = react$1.useI(isOpenState);
1663
- const isOpen = react$1.useO(isOpenState);
1664
- const state = react$1.useO(node);
1665
- const stateType = react$1.useO(typeState);
1666
- const isPrimitive = Boolean(primitiveRefinery.refine(state));
1667
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1668
- /* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
1669
- /* @__PURE__ */ jsxRuntime.jsx(
1670
- button.OpenClose,
1671
- {
1672
- isOpen: isOpen && !isPrimitive,
1673
- testid: `open-close-state-${node.key}`,
1674
- setIsOpen,
1675
- disabled: isPrimitive
1676
- }
1677
- ),
1678
- /* @__PURE__ */ jsxRuntime.jsxs(
1679
- "label",
1680
- {
1681
- onClick: () => {
1682
- console.log(node, atom_io.getState(node));
1683
- },
1684
- onKeyUp: () => {
1685
- console.log(node, atom_io.getState(node));
1686
- },
1687
- children: [
1688
- /* @__PURE__ */ jsxRuntime.jsx("h2", { children: (_b2 = (_a2 = node.family) == null ? void 0 : _a2.subKey) != null ? _b2 : node.key }),
1689
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "type detail", children: [
1690
- "(",
1691
- stateType,
1692
- ")"
1693
- ] })
1694
- ]
1695
- }
1696
- ),
1697
- /* @__PURE__ */ jsxRuntime.jsx(StoreEditor, { token: node })
1698
- ] }),
1699
- isOpen && !isPrimitive ? /* @__PURE__ */ jsxRuntime.jsx("main", { children: /* @__PURE__ */ jsxRuntime.jsx(StoreEditor, { token: node }) }) : null
1700
- ] });
1701
- };
1702
- var StateIndexTreeNode = ({ node, isOpenState }) => {
1703
- const setIsOpen = react$1.useI(isOpenState);
1704
- const isOpen = react$1.useO(isOpenState);
1705
- for (const [key, childNode] of node.familyMembers) {
1706
- ephemeral.findState(findViewIsOpenState, key);
1707
- ephemeral.findState(findStateTypeState, childNode);
1708
- }
1709
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1710
- /* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
1711
- /* @__PURE__ */ jsxRuntime.jsx(
1712
- button.OpenClose,
1713
- {
1714
- isOpen,
1715
- testid: `open-close-state-family-${node.key}`,
1716
- setIsOpen
1717
- }
1718
- ),
1719
- /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
1720
- /* @__PURE__ */ jsxRuntime.jsx("h2", { children: node.key }),
1721
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "type detail", children: " (family)" })
1722
- ] })
1723
- ] }),
1724
- isOpen ? [...node.familyMembers.entries()].map(([key, childNode]) => /* @__PURE__ */ jsxRuntime.jsx(
1725
- StateIndexNode,
1726
- {
1727
- node: childNode,
1728
- isOpenState: ephemeral.findState(findViewIsOpenState, childNode.key),
1729
- typeState: ephemeral.findState(findStateTypeState, childNode)
1730
- },
1731
- key
1732
- )) : null
1733
- ] });
1734
- };
1735
- var StateIndexNode = ({ node, isOpenState, typeState }) => {
1736
- return /* @__PURE__ */ jsxRuntime.jsx("section", { className: "node state", "data-testid": `state-${node.key}`, children: `type` in node ? /* @__PURE__ */ jsxRuntime.jsx(
1737
- StateIndexLeafNode,
1738
- {
1739
- node,
1740
- isOpenState,
1741
- typeState
1742
- }
1743
- ) : /* @__PURE__ */ jsxRuntime.jsx(StateIndexTreeNode, { node, isOpenState }) });
1744
- };
1745
- var StateIndex = ({ tokenIndex }) => {
1746
- const tokenIds = react$1.useO(tokenIndex);
1747
- return /* @__PURE__ */ jsxRuntime.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]) => {
1748
- return /* @__PURE__ */ jsxRuntime.jsx(
1749
- StateIndexNode,
1750
- {
1751
- node,
1752
- isOpenState: ephemeral.findState(findViewIsOpenState, node.key),
1753
- typeState: ephemeral.findState(findStateTypeState, node)
1754
- },
1755
- key
1756
- );
1757
- }) });
1758
- };
1759
- var AtomUpdateFC = ({ atomUpdate }) => {
1760
- return /* @__PURE__ */ jsxRuntime.jsxs(
1761
- "article",
1762
- {
1763
- className: "node atom_update",
1764
- onClick: () => {
1765
- console.log(atomUpdate);
1766
- },
1767
- onKeyUp: () => {
1768
- console.log(atomUpdate);
1769
- },
1770
- children: [
1771
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "detail", children: [
1772
- atomUpdate.key,
1773
- ": "
1774
- ] }),
1775
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "summary", children: prettyJson.diff(atomUpdate.oldValue, atomUpdate.newValue).summary }) })
1776
- ]
1777
- },
1778
- atomUpdate.key
1779
- );
1780
- };
1781
- var TransactionUpdateFC = ({ serialNumber, transactionUpdate }) => {
1782
- return /* @__PURE__ */ jsxRuntime.jsxs(
1783
- "article",
1784
- {
1785
- className: "node transaction_update",
1786
- "data-testid": `transaction-update-${transactionUpdate.key}-${serialNumber}`,
1787
- children: [
1788
- /* @__PURE__ */ jsxRuntime.jsx("header", { children: /* @__PURE__ */ jsxRuntime.jsx("h4", { children: serialNumber }) }),
1789
- /* @__PURE__ */ jsxRuntime.jsxs("main", { children: [
1790
- /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "transaction_params", children: [
1791
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "detail", children: "params: " }),
1792
- transactionUpdate.params.map((param, index) => {
1793
- return /* @__PURE__ */ jsxRuntime.jsxs(
1794
- "article",
1795
- {
1796
- className: "node transaction_param",
1797
- onClick: () => {
1798
- console.log(transactionUpdate);
1799
- },
1800
- onKeyUp: () => {
1801
- console.log(transactionUpdate);
1802
- },
1803
- children: [
1804
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "detail", children: [
1805
- discoverType(param),
1806
- ": "
1807
- ] }),
1808
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "summary", children: typeof param === `object` && param !== null && `type` in param && `target` in param ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: JSON.stringify(param.type) }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: JSON.stringify(param) }) })
1809
- ]
1810
- },
1811
- `param` + index
1812
- );
1813
- })
1814
- ] }),
1815
- /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "node transaction_output", children: [
1816
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "detail", children: "output: " }),
1817
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "detail", children: discoverType(transactionUpdate.output) }),
1818
- transactionUpdate.output ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "summary", children: [
1819
- ": ",
1820
- JSON.stringify(transactionUpdate.output)
1821
- ] }) : null
1822
- ] }),
1823
- /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "transaction_impact", children: [
1824
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "detail", children: "impact: " }),
1825
- transactionUpdate.updates.filter((token) => `key` in token && !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((update, index) => {
1826
- switch (update.type) {
1827
- case `atom_update`:
1828
- case `selector_update`:
1829
- return /* @__PURE__ */ jsxRuntime.jsx(
1830
- article.AtomUpdate,
1831
- {
1832
- serialNumber: index,
1833
- atomUpdate: update
1834
- },
1835
- `${transactionUpdate.key}:${index}:${update.key}`
1836
- );
1837
- case `transaction_update`:
1838
- return /* @__PURE__ */ jsxRuntime.jsx(
1839
- TransactionUpdateFC,
1840
- {
1841
- serialNumber: index,
1842
- transactionUpdate: update
1843
- },
1844
- `${transactionUpdate.key}:${index}:${update.key}`
1845
- );
1846
- }
1847
- })
1848
- ] })
1849
- ] })
1850
- ]
1851
- }
1852
- );
1853
- };
1854
- var TimelineUpdateFC = ({ timelineUpdate, serialNumber }) => {
1855
- return `key` in timelineUpdate ? /* @__PURE__ */ jsxRuntime.jsxs(
1856
- "article",
1857
- {
1858
- className: "node timeline_update",
1859
- "data-testid": `timeline-update-${timelineUpdate.key}-${serialNumber}`,
1860
- children: [
1861
- /* @__PURE__ */ jsxRuntime.jsx("header", { children: /* @__PURE__ */ jsxRuntime.jsxs("h4", { children: [
1862
- timelineUpdate.timestamp,
1863
- ": ",
1864
- timelineUpdate.type,
1865
- " (",
1866
- timelineUpdate.key,
1867
- ")"
1868
- ] }) }),
1869
- /* @__PURE__ */ jsxRuntime.jsx("main", { children: timelineUpdate.type === `transaction_update` ? timelineUpdate.updates.filter((token) => `key` in token && !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((update, index) => {
1870
- switch (update.type) {
1871
- case `atom_update`:
1872
- case `selector_update`:
1873
- return /* @__PURE__ */ jsxRuntime.jsx(
1874
- article.AtomUpdate,
1875
- {
1876
- serialNumber: index,
1877
- atomUpdate: update
1878
- },
1879
- `${timelineUpdate.key}:${index}:${update.key}`
1880
- );
1881
- case `transaction_update`:
1882
- return /* @__PURE__ */ jsxRuntime.jsx(
1883
- TransactionUpdateFC,
1884
- {
1885
- serialNumber: index,
1886
- transactionUpdate: update
1887
- },
1888
- `${timelineUpdate.key}:${index}:${update.key}`
1889
- );
1890
- }
1891
- }) : timelineUpdate.type === `selector_update` ? timelineUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
1892
- return /* @__PURE__ */ jsxRuntime.jsx(
1893
- article.AtomUpdate,
1894
- {
1895
- serialNumber: index,
1896
- atomUpdate
1897
- },
1898
- `${timelineUpdate.key}:${index}:${atomUpdate.key}`
1899
- );
1900
- }) : timelineUpdate.type === `atom_update` ? /* @__PURE__ */ jsxRuntime.jsx(
1901
- article.AtomUpdate,
1902
- {
1903
- serialNumber: timelineUpdate.timestamp,
1904
- atomUpdate: timelineUpdate
1905
- }
1906
- ) : null })
1907
- ]
1908
- }
1909
- ) : null;
1910
- };
1911
- var article = {
1912
- AtomUpdate: AtomUpdateFC,
1913
- TransactionUpdate: TransactionUpdateFC,
1914
- TimelineUpdate: TimelineUpdateFC
1915
- };
1916
- var YouAreHere = () => {
1917
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "you_are_here", children: "you are here" });
1918
- };
1919
- var TimelineLog = ({ token, isOpenState, timelineState }) => {
1920
- const timeline = react$1.useO(timelineState);
1921
- const isOpen = react$1.useO(isOpenState);
1922
- const setIsOpen = react$1.useI(isOpenState);
1923
- return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "node timeline_log", "data-testid": `timeline-${token.key}`, children: [
1924
- /* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
1925
- /* @__PURE__ */ jsxRuntime.jsx(
1926
- button.OpenClose,
1927
- {
1928
- isOpen,
1929
- testid: `open-close-timeline-${token.key}`,
1930
- setIsOpen
1931
- }
1932
- ),
1933
- /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
1934
- /* @__PURE__ */ jsxRuntime.jsx("h2", { children: token.key }),
1935
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "detail length", children: [
1936
- "(",
1937
- timeline.at,
1938
- "/",
1939
- timeline.history.length,
1940
- ")"
1941
- ] }),
1942
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "gap" }),
1943
- /* @__PURE__ */ jsxRuntime.jsxs("nav", { children: [
1944
- /* @__PURE__ */ jsxRuntime.jsx(
1945
- "button",
1946
- {
1947
- type: "button",
1948
- onClick: () => {
1949
- atom_io.undo(token);
1950
- },
1951
- disabled: timeline.at === 0,
1952
- children: "undo"
1953
- }
1954
- ),
1955
- /* @__PURE__ */ jsxRuntime.jsx(
1956
- "button",
1957
- {
1958
- type: "button",
1959
- onClick: () => {
1960
- atom_io.redo(token);
1961
- },
1962
- disabled: timeline.at === timeline.history.length,
1963
- children: "redo"
1964
- }
1965
- )
1966
- ] })
1967
- ] })
1968
- ] }),
1969
- isOpen ? /* @__PURE__ */ jsxRuntime.jsx("main", { children: timeline.history.map(
1970
- (update, index) => `key` in update ? /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
1971
- index === timeline.at ? /* @__PURE__ */ jsxRuntime.jsx(YouAreHere, {}) : null,
1972
- /* @__PURE__ */ jsxRuntime.jsx(
1973
- article.TimelineUpdate,
1974
- {
1975
- timelineUpdate: update,
1976
- serialNumber: index
1977
- }
1978
- ),
1979
- index === timeline.history.length - 1 && timeline.at === timeline.history.length ? /* @__PURE__ */ jsxRuntime.jsx(YouAreHere, {}) : null
1980
- ] }, update.key + index + timeline.at) : null
1981
- ) }) : null
1982
- ] });
1983
- };
1984
- var TimelineIndex = () => {
1985
- const tokenIds = react$1.useO(timelineIndex);
1986
- return /* @__PURE__ */ jsxRuntime.jsx("article", { className: "index timeline_index", "data-testid": "timeline-index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
1987
- return /* @__PURE__ */ jsxRuntime.jsx(
1988
- TimelineLog,
1989
- {
1990
- token,
1991
- isOpenState: ephemeral.findState(findViewIsOpenState, token.key),
1992
- timelineState: ephemeral.findState(findTimelineState, token.key)
1993
- },
1994
- token.key
1995
- );
1996
- }) });
1997
- };
1998
- var TransactionLog = ({ token, isOpenState, logState }) => {
1999
- const log = react$1.useO(logState);
2000
- const isOpen = react$1.useO(isOpenState);
2001
- const setIsOpen = react$1.useI(isOpenState);
2002
- return /* @__PURE__ */ jsxRuntime.jsxs(
2003
- "section",
2004
- {
2005
- className: "node transaction_log",
2006
- "data-testid": `transaction-${token.key}`,
2007
- children: [
2008
- /* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
2009
- /* @__PURE__ */ jsxRuntime.jsx(
2010
- button.OpenClose,
2011
- {
2012
- isOpen,
2013
- testid: `open-close-transaction-${token.key}`,
2014
- setIsOpen
2015
- }
2016
- ),
2017
- /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
2018
- /* @__PURE__ */ jsxRuntime.jsx("h2", { children: token.key }),
2019
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "detail length", children: [
2020
- "(",
2021
- log.length,
2022
- ")"
2023
- ] })
2024
- ] })
2025
- ] }),
2026
- isOpen ? /* @__PURE__ */ jsxRuntime.jsx("main", { children: log.map((update, index) => /* @__PURE__ */ jsxRuntime.jsx(
2027
- article.TransactionUpdate,
2028
- {
2029
- serialNumber: index,
2030
- transactionUpdate: update
2031
- },
2032
- update.key + index
2033
- )) }) : null
2034
- ]
2035
- }
2036
- );
2037
- };
2038
- var TransactionIndex = () => {
2039
- const tokenIds = react$1.useO(transactionIndex);
2040
- return /* @__PURE__ */ jsxRuntime.jsx("article", { className: "index transaction_index", "data-testid": "transaction-index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
2041
- return /* @__PURE__ */ jsxRuntime.jsx(
2042
- TransactionLog,
2043
- {
2044
- token,
2045
- isOpenState: ephemeral.findState(findViewIsOpenState, token.key),
2046
- logState: ephemeral.findState(findTransactionLogState, token.key)
2047
- },
2048
- token.key
2049
- );
2050
- }) });
2051
- };
2052
- var AtomIODevtools = () => {
2053
- const constraintsRef = react.useRef(null);
2054
- const setDevtoolsAreOpen = react$1.useI(devtoolsAreOpenState);
2055
- const devtoolsAreOpen = react$1.useO(devtoolsAreOpenState);
2056
- const setDevtoolsView = react$1.useI(devtoolsViewSelectionState);
2057
- const devtoolsView = react$1.useO(devtoolsViewSelectionState);
2058
- const devtoolsViewOptions = react$1.useO(devtoolsViewOptionsState);
2059
- const mouseHasMoved = react.useRef(false);
2060
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2061
- /* @__PURE__ */ jsxRuntime.jsx(
2062
- framerMotion.motion.span,
2063
- {
2064
- ref: constraintsRef,
2065
- className: "atom_io_devtools_zone",
2066
- style: {
2067
- position: `fixed`,
2068
- top: 0,
2069
- left: 0,
2070
- right: 0,
2071
- bottom: 0,
2072
- pointerEvents: `none`
2073
- }
2074
- }
2075
- ),
2076
- /* @__PURE__ */ jsxRuntime.jsxs(
2077
- framerMotion.motion.main,
2078
- {
2079
- drag: true,
2080
- dragConstraints: constraintsRef,
2081
- className: "atom_io_devtools",
2082
- transition: framerMotion.spring,
2083
- style: devtoolsAreOpen ? {} : {
2084
- backgroundColor: `#0000`,
2085
- borderColor: `#0000`,
2086
- maxHeight: 28,
2087
- maxWidth: 33
2088
- },
2089
- children: [
2090
- devtoolsAreOpen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2091
- /* @__PURE__ */ jsxRuntime.jsxs(framerMotion.motion.header, { children: [
2092
- /* @__PURE__ */ jsxRuntime.jsx("h1", { children: "atom.io" }),
2093
- /* @__PURE__ */ jsxRuntime.jsx("nav", { children: devtoolsViewOptions.map((viewOption) => /* @__PURE__ */ jsxRuntime.jsx(
2094
- "button",
2095
- {
2096
- type: "button",
2097
- "data-testid": `view-${viewOption}`,
2098
- className: viewOption === devtoolsView ? `active` : ``,
2099
- onClick: () => {
2100
- setDevtoolsView(viewOption);
2101
- },
2102
- disabled: viewOption === devtoolsView,
2103
- children: viewOption
2104
- },
2105
- viewOption
2106
- )) })
2107
- ] }),
2108
- /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.main, { children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.LayoutGroup, { children: devtoolsView === `atoms` ? /* @__PURE__ */ jsxRuntime.jsx(StateIndex, { tokenIndex: atomIndex }) : devtoolsView === `selectors` ? /* @__PURE__ */ jsxRuntime.jsx(StateIndex, { tokenIndex: selectorIndex }) : devtoolsView === `transactions` ? /* @__PURE__ */ jsxRuntime.jsx(TransactionIndex, {}) : devtoolsView === `timelines` ? /* @__PURE__ */ jsxRuntime.jsx(TimelineIndex, {}) : null }) })
2109
- ] }) : null,
2110
- /* @__PURE__ */ jsxRuntime.jsx("footer", { children: /* @__PURE__ */ jsxRuntime.jsx(
2111
- "button",
2112
- {
2113
- type: "button",
2114
- onMouseDown: () => mouseHasMoved.current = false,
2115
- onMouseMove: () => mouseHasMoved.current = true,
2116
- onMouseUp: () => {
2117
- if (!mouseHasMoved.current) {
2118
- setDevtoolsAreOpen((open) => !open);
2119
- }
2120
- },
2121
- children: "\u{1F441}\u200D\u{1F5E8}"
2122
- }
2123
- ) })
2124
- ]
2125
- }
2126
- )
2127
- ] });
2128
- };
2129
-
2130
- // react-devtools/src/index.ts
2131
- var {
2132
- atomIndex,
2133
- selectorIndex,
2134
- transactionIndex,
2135
- findTransactionLogState,
2136
- timelineIndex,
2137
- findTimelineState
2138
- } = introspection.attachIntrospectionStates();
2139
- var devtoolsAreOpenState = atom_io.atom({
2140
- key: `\u{1F441}\u200D\u{1F5E8} Devtools Are Open`,
2141
- default: true,
2142
- effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools Are Open`)]
2143
- });
2144
- var devtoolsViewSelectionState = atom_io.atom({
2145
- key: `\u{1F441}\u200D\u{1F5E8} Devtools View Selection`,
2146
- default: `atoms`,
2147
- effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View`)]
2148
- });
2149
- var devtoolsViewOptionsState = atom_io.atom({
2150
- key: `\u{1F441}\u200D\u{1F5E8} Devtools View Options`,
2151
- default: [`atoms`, `selectors`, `transactions`, `timelines`],
2152
- effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View Options`)]
2153
- });
2154
- var findViewIsOpenState = atom_io.atomFamily({
2155
- key: `\u{1F441}\u200D\u{1F5E8} Devtools View Is Open`,
2156
- default: false,
2157
- effects: (key) => [lazyLocalStorageEffect(key + `:view-is-open`)]
2158
- });
2159
- var primitiveRefinery = new Refinery({
2160
- number: (input) => typeof input === `number`,
2161
- string: (input) => typeof input === `string`,
2162
- boolean: (input) => typeof input === `boolean`,
2163
- null: (input) => input === null
2164
- });
2165
- var jsonTreeRefinery = new Refinery({
2166
- object: isPlainObject,
2167
- array: (input) => Array.isArray(input)
2168
- });
2169
- var prettyJson = new Differ(primitiveRefinery, jsonTreeRefinery, {
2170
- number: diffNumber,
2171
- string: diffString,
2172
- boolean: diffBoolean,
2173
- null: () => ({ summary: `No Change` }),
2174
- object: diffObject,
2175
- array: diffArray
2176
- });
2177
-
2178
- exports.AtomIODevtools = AtomIODevtools;
2179
- exports.atomIndex = atomIndex;
2180
- exports.devtoolsAreOpenState = devtoolsAreOpenState;
2181
- exports.devtoolsViewOptionsState = devtoolsViewOptionsState;
2182
- exports.devtoolsViewSelectionState = devtoolsViewSelectionState;
2183
- exports.findTimelineState = findTimelineState;
2184
- exports.findTransactionLogState = findTransactionLogState;
2185
- exports.findViewIsOpenState = findViewIsOpenState;
2186
- exports.jsonTreeRefinery = jsonTreeRefinery;
2187
- exports.prettyJson = prettyJson;
2188
- exports.primitiveRefinery = primitiveRefinery;
2189
- exports.selectorIndex = selectorIndex;
2190
- exports.timelineIndex = timelineIndex;
2191
- exports.transactionIndex = transactionIndex;