atom.io 0.19.0 → 0.19.1

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 (43) hide show
  1. package/data/src/join.ts +24 -24
  2. package/dist/{chunk-CVBEVTM5.js → chunk-7VCCW45K.js} +1 -39
  3. package/dist/index.cjs +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +1 -0
  6. package/internal/dist/index.cjs +1 -1
  7. package/internal/dist/index.d.ts +1 -1
  8. package/internal/dist/index.js +1 -1
  9. package/internal/src/mutable/tracker.ts +1 -1
  10. package/internal/src/set-state/become.ts +1 -1
  11. package/internal/src/subscribe/subscribe-to-state.ts +2 -2
  12. package/internal/src/timeline/add-atom-to-timeline.ts +3 -3
  13. package/internal/src/transaction/build-transaction.ts +1 -1
  14. package/introspection/dist/index.cjs +3 -2
  15. package/introspection/dist/index.d.ts +4 -4
  16. package/introspection/dist/index.js +3 -2
  17. package/introspection/src/attach-atom-index.ts +5 -4
  18. package/introspection/src/index.ts +3 -3
  19. package/json/dist/index.d.ts +1 -1
  20. package/json/dist/index.js +2 -2
  21. package/package.json +18 -19
  22. package/react-devtools/dist/index.cjs +218 -927
  23. package/react-devtools/dist/index.css +0 -18
  24. package/react-devtools/dist/index.d.ts +4 -4
  25. package/react-devtools/dist/index.js +181 -833
  26. package/react-devtools/src/AtomIODevtools.tsx +2 -1
  27. package/react-devtools/src/Button.tsx +3 -1
  28. package/react-devtools/src/StateEditor.tsx +13 -16
  29. package/react-devtools/src/StateIndex.tsx +22 -19
  30. package/react-devtools/src/TimelineIndex.tsx +11 -4
  31. package/react-devtools/src/TransactionIndex.tsx +10 -3
  32. package/react-devtools/src/Updates.tsx +10 -3
  33. package/realtime-react/dist/index.cjs +1 -1
  34. package/realtime-react/dist/index.js +1 -1
  35. package/realtime-react/src/use-single-effect.ts +1 -1
  36. package/realtime-server/dist/index.d.ts +1 -1
  37. package/realtime-server/src/ipc-sockets/child-socket.ts +1 -1
  38. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +2 -2
  39. package/realtime-testing/dist/index.js +1 -1
  40. package/realtime-testing/src/setup-realtime-test.tsx +1 -1
  41. package/src/silo.ts +4 -0
  42. package/src/validators.ts +2 -2
  43. /package/dist/{chunk-VAE5OCKN.js → chunk-BF4MVQF6.js} +0 -0
@@ -53,7 +53,7 @@ export const AtomIODevtools = (): JSX.Element => {
53
53
  borderColor: `#0000`,
54
54
  maxHeight: 28,
55
55
  maxWidth: 33,
56
- }
56
+ }
57
57
  }
58
58
  >
59
59
  {devtoolsAreOpen ? (
@@ -65,6 +65,7 @@ export const AtomIODevtools = (): JSX.Element => {
65
65
  <button
66
66
  key={viewOption}
67
67
  type="button"
68
+ data-testid={`view-${viewOption}`}
68
69
  className={viewOption === devtoolsView ? `active` : ``}
69
70
  onClick={() => setDevtoolsView(viewOption)}
70
71
  disabled={viewOption === devtoolsView}
@@ -5,10 +5,12 @@ export const OpenClose: FC<{
5
5
  isOpen: boolean
6
6
  setIsOpen: (next: Modify<boolean> | boolean) => void
7
7
  disabled?: boolean
8
- }> = ({ isOpen, setIsOpen, disabled }) => {
8
+ testid: string
9
+ }> = ({ isOpen, setIsOpen, disabled, testid }) => {
9
10
  return (
10
11
  <button
11
12
  type="button"
13
+ data-testid={testid}
12
14
  className={`carat ${isOpen ? `open` : `closed`}`}
13
15
  onClick={() => setIsOpen((isOpen) => !isOpen)}
14
16
  disabled={disabled}
@@ -3,9 +3,7 @@ import { useI, useO } from "atom.io/react"
3
3
  import type { FC } from "react"
4
4
 
5
5
  import { fallback } from "~/packages/anvl/src/function"
6
- import { Join } from "~/packages/anvl/src/join"
7
6
  import { isJson } from "~/packages/anvl/src/refinement"
8
- import { RelationEditor } from "~/packages/hamr/react-data-designer/src"
9
7
  import { ElasticInput } from "~/packages/hamr/react-elastic-input/src"
10
8
  import { JsonEditor } from "~/packages/hamr/react-json-editor/src"
11
9
 
@@ -16,19 +14,20 @@ export const StateEditor: FC<{
16
14
  const data = useO(token)
17
15
  return isJson(data) ? (
18
16
  <JsonEditor data={data} set={set} schema={true} />
19
- ) : data instanceof Join ? (
20
- <RelationEditor data={data} set={set} />
21
17
  ) : (
22
18
  <div className="json_editor">
23
19
  <ElasticInput
24
20
  value={
25
- data instanceof Set
26
- ? `Set { ${JSON.stringify([...data]).slice(1, -1)} }`
27
- : data instanceof Map
28
- ? `Map ` + JSON.stringify([...data])
29
- : Object.getPrototypeOf(data).constructor.name +
30
- ` ` +
31
- fallback(() => JSON.stringify(data), `?`)
21
+ data !== null &&
22
+ typeof data === `object` &&
23
+ `toJson` in data &&
24
+ typeof data.toJson === `function`
25
+ ? JSON.stringify(data.toJson())
26
+ : data instanceof Set
27
+ ? `Set { ${JSON.stringify([...data]).slice(1, -1)} }`
28
+ : Object.getPrototypeOf(data).constructor.name +
29
+ ` ` +
30
+ fallback(() => JSON.stringify(data), `?`)
32
31
  }
33
32
  disabled={true}
34
33
  />
@@ -53,11 +52,9 @@ export const ReadonlySelectorViewer: FC<{
53
52
  value={
54
53
  data instanceof Set
55
54
  ? `Set ` + JSON.stringify([...data])
56
- : data instanceof Map
57
- ? `Map ` + JSON.stringify([...data])
58
- : Object.getPrototypeOf(data).constructor.name +
59
- ` ` +
60
- JSON.stringify(data)
55
+ : Object.getPrototypeOf(data).constructor.name +
56
+ ` ` +
57
+ JSON.stringify(data)
61
58
  }
62
59
  disabled={true}
63
60
  />
@@ -1,9 +1,10 @@
1
1
  import type {
2
+ AtomToken,
2
3
  ReadonlySelectorToken,
3
4
  RegularAtomToken,
4
5
  WritableSelectorToken,
5
6
  } from "atom.io"
6
- import { getState, selectorFamily } from "atom.io"
7
+ import { findState, getState, selectorFamily } from "atom.io"
7
8
  import type { FamilyNode, WritableTokenIndex } from "atom.io/introspection"
8
9
  import { useI, useO } from "atom.io/react"
9
10
  import type { FC } from "react"
@@ -34,8 +35,8 @@ const findStateTypeState = selectorFamily<string, { key: string }>({
34
35
 
35
36
  export const StateIndexLeafNode: FC<{
36
37
  node:
38
+ | AtomToken<unknown>
37
39
  | ReadonlySelectorToken<unknown>
38
- | RegularAtomToken<unknown>
39
40
  | WritableSelectorToken<unknown>
40
41
  isOpenState: RegularAtomToken<boolean>
41
42
  typeState: ReadonlySelectorToken<string>
@@ -53,6 +54,7 @@ export const StateIndexLeafNode: FC<{
53
54
  <header>
54
55
  <button.OpenClose
55
56
  isOpen={isOpen && !isPrimitive}
57
+ testid={`open-close-state-${node.key}`}
56
58
  setIsOpen={setIsOpen}
57
59
  disabled={isPrimitive}
58
60
  />
@@ -63,7 +65,7 @@ export const StateIndexLeafNode: FC<{
63
65
  <h2>{node.family?.subKey ?? node.key}</h2>
64
66
  <span className="type detail">({stateType})</span>
65
67
  </label>
66
- {isPrimitive ? <StoreEditor token={node} /> : null}
68
+ <StoreEditor token={node} />
67
69
  </header>
68
70
  {isOpen && !isPrimitive ? (
69
71
  <main>
@@ -75,8 +77,8 @@ export const StateIndexLeafNode: FC<{
75
77
  }
76
78
  export const StateIndexTreeNode: FC<{
77
79
  node: FamilyNode<
80
+ | AtomToken<unknown>
78
81
  | ReadonlySelectorToken<unknown>
79
- | RegularAtomToken<unknown>
80
82
  | WritableSelectorToken<unknown>
81
83
  >
82
84
  isOpenState: RegularAtomToken<boolean>
@@ -84,13 +86,17 @@ export const StateIndexTreeNode: FC<{
84
86
  const setIsOpen = useI(isOpenState)
85
87
  const isOpen = useO(isOpenState)
86
88
  for (const [key, childNode] of recordToEntries(node.familyMembers)) {
87
- findViewIsOpenState(key)
88
- findStateTypeState(childNode)
89
+ findState(findViewIsOpenState, key)
90
+ findState(findStateTypeState, childNode)
89
91
  }
90
92
  return (
91
93
  <>
92
94
  <header>
93
- <button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />
95
+ <button.OpenClose
96
+ isOpen={isOpen}
97
+ testid={`open-close-state-family-${node.key}`}
98
+ setIsOpen={setIsOpen}
99
+ />
94
100
  <label>
95
101
  <h2>{node.key}</h2>
96
102
  <span className="type detail"> (family)</span>
@@ -101,10 +107,10 @@ export const StateIndexTreeNode: FC<{
101
107
  <StateIndexNode
102
108
  key={key}
103
109
  node={childNode}
104
- isOpenState={findViewIsOpenState(childNode.key)}
105
- typeState={findStateTypeState(childNode)}
110
+ isOpenState={findState(findViewIsOpenState, childNode.key)}
111
+ typeState={findState(findStateTypeState, childNode)}
106
112
  />
107
- ))
113
+ ))
108
114
  : null}
109
115
  </>
110
116
  )
@@ -112,18 +118,15 @@ export const StateIndexTreeNode: FC<{
112
118
 
113
119
  export const StateIndexNode: FC<{
114
120
  node: WritableTokenIndex<
121
+ | AtomToken<unknown>
115
122
  | ReadonlySelectorToken<unknown>
116
- | RegularAtomToken<unknown>
117
123
  | WritableSelectorToken<unknown>
118
124
  >[string]
119
125
  isOpenState: RegularAtomToken<boolean>
120
126
  typeState: ReadonlySelectorToken<string>
121
127
  }> = ({ node, isOpenState, typeState }) => {
122
- if (node.key.startsWith(`👁‍🗨`)) {
123
- return null
124
- }
125
128
  return (
126
- <section className="node state">
129
+ <section className="node state" data-testid={`state-${node.key}`}>
127
130
  {`type` in node ? (
128
131
  <StateIndexLeafNode
129
132
  node={node}
@@ -140,15 +143,15 @@ export const StateIndexNode: FC<{
140
143
  export const StateIndex: FC<{
141
144
  tokenIndex: ReadonlySelectorToken<
142
145
  WritableTokenIndex<
146
+ | AtomToken<unknown>
143
147
  | ReadonlySelectorToken<unknown>
144
- | RegularAtomToken<unknown>
145
148
  | WritableSelectorToken<unknown>
146
149
  >
147
150
  >
148
151
  }> = ({ tokenIndex }) => {
149
152
  const tokenIds = useO(tokenIndex)
150
153
  return (
151
- <article className="index state_index">
154
+ <article className="index state_index" data-testid="state-index">
152
155
  {Object.entries(tokenIds)
153
156
  .filter(([key]) => !key.startsWith(`👁‍🗨`))
154
157
  .sort()
@@ -157,8 +160,8 @@ export const StateIndex: FC<{
157
160
  <StateIndexNode
158
161
  key={key}
159
162
  node={node}
160
- isOpenState={findViewIsOpenState(node.key)}
161
- typeState={findStateTypeState(node)}
163
+ isOpenState={findState(findViewIsOpenState, node.key)}
164
+ typeState={findState(findStateTypeState, node)}
162
165
  />
163
166
  )
164
167
  })}
@@ -26,9 +26,13 @@ export const TimelineLog: FC<{
26
26
  const setIsOpen = useI(isOpenState)
27
27
 
28
28
  return (
29
- <section className="node timeline_log">
29
+ <section className="node timeline_log" data-testid={`timeline-${token.key}`}>
30
30
  <header>
31
- <button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />
31
+ <button.OpenClose
32
+ isOpen={isOpen}
33
+ testid={`open-close-timeline-${token.key}`}
34
+ setIsOpen={setIsOpen}
35
+ />
32
36
  <label>
33
37
  <h2>{token.key}</h2>
34
38
  <span className="detail length">
@@ -58,7 +62,10 @@ export const TimelineLog: FC<{
58
62
  {timeline.history.map((update, index) => (
59
63
  <Fragment key={update.key + index + timeline.at}>
60
64
  {index === timeline.at ? <YouAreHere /> : null}
61
- <article.TimelineUpdate timelineUpdate={update} />
65
+ <article.TimelineUpdate
66
+ timelineUpdate={update}
67
+ serialNumber={index}
68
+ />
62
69
  {index === timeline.history.length - 1 &&
63
70
  timeline.at === timeline.history.length ? (
64
71
  <YouAreHere />
@@ -74,7 +81,7 @@ export const TimelineLog: FC<{
74
81
  export const TimelineIndex: FC = () => {
75
82
  const tokenIds = useO(timelineIndex)
76
83
  return (
77
- <article className="index timeline_index">
84
+ <article className="index timeline_index" data-testid="timeline-index">
78
85
  {tokenIds
79
86
  .filter((token) => !token.key.startsWith(`👁‍🗨`))
80
87
  .map((token) => {
@@ -27,9 +27,16 @@ export const TransactionLog: FC<{
27
27
  const setIsOpen = useI(isOpenState)
28
28
 
29
29
  return (
30
- <section className="node transaction_log">
30
+ <section
31
+ className="node transaction_log"
32
+ data-testid={`transaction-${token.key}`}
33
+ >
31
34
  <header>
32
- <button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />
35
+ <button.OpenClose
36
+ isOpen={isOpen}
37
+ testid={`open-close-transaction-${token.key}`}
38
+ setIsOpen={setIsOpen}
39
+ />
33
40
  <label>
34
41
  <h2>{token.key}</h2>
35
42
  <span className="detail length">({log.length})</span>
@@ -53,7 +60,7 @@ export const TransactionLog: FC<{
53
60
  export const TransactionIndex: FC = () => {
54
61
  const tokenIds = useO(transactionIndex)
55
62
  return (
56
- <article className="index transaction_index">
63
+ <article className="index transaction_index" data-testid="transaction-index">
57
64
  {tokenIds
58
65
  .filter((token) => !token.key.startsWith(`👁‍🗨`))
59
66
  .map((token) => {
@@ -36,7 +36,10 @@ const TransactionUpdateFC: React.FC<{
36
36
  transactionUpdate: TransactionUpdate<ƒn>
37
37
  }> = ({ serialNumber, transactionUpdate }) => {
38
38
  return (
39
- <article className="node transaction_update">
39
+ <article
40
+ className="node transaction_update"
41
+ data-testid={`transaction-update-${transactionUpdate.key}-${serialNumber}`}
42
+ >
40
43
  <header>
41
44
  <h4>{serialNumber}</h4>
42
45
  </header>
@@ -104,9 +107,13 @@ const TransactionUpdateFC: React.FC<{
104
107
 
105
108
  export const TimelineUpdateFC: React.FC<{
106
109
  timelineUpdate: TimelineUpdate<any>
107
- }> = ({ timelineUpdate }) => {
110
+ serialNumber: number
111
+ }> = ({ timelineUpdate, serialNumber }) => {
108
112
  return (
109
- <article className="node timeline_update">
113
+ <article
114
+ className="node timeline_update"
115
+ data-testid={`timeline-update-${timelineUpdate.key}-${serialNumber}`}
116
+ >
110
117
  <header>
111
118
  <h4>
112
119
  {timelineUpdate.timestamp}: {timelineUpdate.type} ({timelineUpdate.key}
@@ -47,7 +47,7 @@ var RealtimeProvider = ({ children, socket }) => {
47
47
  return /* @__PURE__ */ jsxRuntime.jsx(RealtimeContext.Provider, { value: { socket, services }, children });
48
48
  };
49
49
  var { NODE_ENV } = process.env;
50
- var IN_DEV = NODE_ENV === `development` || NODE_ENV === `test`;
50
+ var IN_DEV = NODE_ENV === `development`;
51
51
  function noop() {
52
52
  }
53
53
  function useSingleEffect(effect, deps) {
@@ -25,7 +25,7 @@ var RealtimeProvider = ({ children, socket }) => {
25
25
  return /* @__PURE__ */ jsx(RealtimeContext.Provider, { value: { socket, services }, children });
26
26
  };
27
27
  var { NODE_ENV } = process.env;
28
- var IN_DEV = NODE_ENV === `development` || NODE_ENV === `test`;
28
+ var IN_DEV = NODE_ENV === `development`;
29
29
  function noop() {
30
30
  }
31
31
  function useSingleEffect(effect, deps) {
@@ -1,7 +1,7 @@
1
1
  import * as React from "react"
2
2
 
3
3
  const { NODE_ENV } = process.env
4
- const IN_DEV = NODE_ENV === `development` || NODE_ENV === `test`
4
+ const IN_DEV = NODE_ENV === `development`
5
5
 
6
6
  function noop() {}
7
7
 
@@ -1,6 +1,6 @@
1
1
  import { Subject, Transceiver, Store } from 'atom.io/internal';
2
2
  import { Json, Stringified, JsonIO } from 'atom.io/json';
3
- import { ChildProcessWithoutNullStreams } from 'child_process';
3
+ import { ChildProcessWithoutNullStreams } from 'node:child_process';
4
4
  import { ContinuityToken, UserInRoomMeta } from 'atom.io/realtime';
5
5
  import * as AtomIO from 'atom.io';
6
6
  import { TransactionUpdateContent, TransactionUpdate, WritableToken } from 'atom.io';
@@ -1,4 +1,4 @@
1
- import type { ChildProcessWithoutNullStreams } from "child_process"
1
+ import type { ChildProcessWithoutNullStreams } from "node:child_process"
2
2
 
3
3
  import type { Json } from "atom.io/json"
4
4
  import { parseJson } from "atom.io/json"
@@ -1,5 +1,5 @@
1
- import type { ChildProcessWithoutNullStreams } from "child_process"
2
- import { spawn } from "child_process"
1
+ import type { ChildProcessWithoutNullStreams } from "node:child_process"
2
+ import { spawn } from "node:child_process"
3
3
 
4
4
  import { atomFamily, selectorFamily } from "atom.io"
5
5
  import type { Loadable } from "atom.io/data"
@@ -1,7 +1,7 @@
1
1
  import { myUsernameState } from '../../dist/chunk-O47EQUM6.js';
2
2
  import { editRelationsInStore } from '../../dist/chunk-7ZR244C2.js';
3
3
  import '../../dist/chunk-WX2NCOZR.js';
4
- import { recordToEntries } from '../../dist/chunk-CVBEVTM5.js';
4
+ import { recordToEntries } from '../../dist/chunk-7VCCW45K.js';
5
5
  import '../../dist/chunk-BWWVY5O5.js';
6
6
  import { __spreadProps, __spreadValues } from '../../dist/chunk-U2IICNHQ.js';
7
7
  import * as http from 'http';
@@ -1,4 +1,4 @@
1
- import * as http from "http"
1
+ import * as http from "node:http"
2
2
 
3
3
  import { prettyDOM, render } from "@testing-library/react"
4
4
  import type { RenderResult } from "@testing-library/react"
package/src/silo.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  createStandaloneSelector,
8
8
  createTimeline,
9
9
  createTransaction,
10
+ findInStore,
10
11
  getFromStore,
11
12
  setIntoStore,
12
13
  timeTravel,
@@ -23,6 +24,7 @@ import type {
23
24
  RegularAtomFamilyOptions,
24
25
  RegularAtomOptions,
25
26
  RegularAtomToken,
27
+ findState,
26
28
  getState,
27
29
  redo,
28
30
  setState,
@@ -42,6 +44,7 @@ export class Silo {
42
44
  public selectorFamily: typeof selectorFamily
43
45
  public transaction: typeof transaction
44
46
  public timeline: typeof timeline
47
+ public findState: typeof findState
45
48
  public getState: typeof getState
46
49
  public setState: typeof setState
47
50
  public subscribe: typeof subscribe
@@ -80,6 +83,7 @@ export class Silo {
80
83
  this.selectorFamily = (options) => createSelectorFamily(options, s) as any
81
84
  this.transaction = (options) => createTransaction(options, s)
82
85
  this.timeline = (options) => createTimeline(options, s)
86
+ this.findState = (token, key) => findInStore(token, key, s) as any
83
87
  this.getState = (token) => getFromStore(token, s)
84
88
  this.setState = (token, newValue) => setIntoStore(token, newValue, s)
85
89
  this.subscribe = (token, handler, key) => subscribe(token, handler, key, s)
package/src/validators.ts CHANGED
@@ -24,8 +24,8 @@ export type TokenType<
24
24
  > = Comparison extends ReadableToken<infer RepresentedValue>
25
25
  ? RepresentedValue
26
26
  : Comparison extends ReadableFamilyToken<infer RepresentedValue, any>
27
- ? RepresentedValue
28
- : never
27
+ ? RepresentedValue
28
+ : never
29
29
 
30
30
  export function isToken<KnownToken extends RegularAtomToken<any>>(
31
31
  knownToken: KnownToken,
File without changes