atom.io 0.31.0 → 0.32.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 (171) hide show
  1. package/data/dist/index.d.ts +867 -101
  2. package/data/dist/index.js +10 -558
  3. package/data/src/index.ts +0 -2
  4. package/data/src/struct-family.ts +1 -1
  5. package/data/src/struct.ts +1 -2
  6. package/dist/chunk-354XQWHH.js +153 -0
  7. package/dist/chunk-4LWKCEW3.js +14 -0
  8. package/dist/chunk-5F2V7S3B.js +83 -0
  9. package/dist/chunk-ECOMOMUN.js +631 -0
  10. package/dist/{chunk-42UH5F5Q.js → chunk-GY2XQYZY.js} +2051 -755
  11. package/dist/chunk-NF7FJKJD.js +107 -0
  12. package/dist/chunk-R3ZUK5EH.js +1024 -0
  13. package/dist/chunk-Z2UJW4NQ.js +523 -0
  14. package/dist/index.d.ts +855 -127
  15. package/dist/index.js +1 -143
  16. package/eslint-plugin/dist/index.d.ts +1 -30
  17. package/eslint-plugin/dist/index.js +0 -146
  18. package/eslint-plugin/src/index.ts +0 -1
  19. package/eslint-plugin/src/rules/index.ts +0 -1
  20. package/internal/dist/index.d.ts +794 -70
  21. package/internal/dist/index.js +1 -2
  22. package/internal/src/atom/create-regular-atom.ts +3 -3
  23. package/internal/src/atom/dispose-atom.ts +4 -13
  24. package/internal/src/atom/is-default.ts +3 -3
  25. package/internal/src/caching.ts +5 -5
  26. package/internal/src/capitalize.ts +3 -0
  27. package/internal/src/families/create-readonly-selector-family.ts +5 -6
  28. package/internal/src/families/create-writable-selector-family.ts +1 -4
  29. package/internal/src/families/dispose-from-store.ts +3 -13
  30. package/internal/src/families/find-in-store.ts +1 -6
  31. package/internal/src/get-state/get-from-store.ts +2 -2
  32. package/internal/src/get-state/read-or-compute-value.ts +1 -1
  33. package/internal/src/index.ts +19 -9
  34. package/internal/src/ingest-updates/ingest-creation-disposal.ts +2 -3
  35. package/internal/src/install-into-store.ts +48 -0
  36. package/internal/src/join/edit-relations-in-store.ts +32 -0
  37. package/internal/src/join/find-relations-in-store.ts +124 -0
  38. package/internal/src/join/get-internal-relations-from-store.ts +14 -0
  39. package/internal/src/join/get-join.ts +31 -0
  40. package/internal/src/join/index.ts +5 -0
  41. package/{data/src/join.ts → internal/src/join/join-internal.ts} +20 -429
  42. package/internal/src/keys.ts +7 -7
  43. package/internal/src/molecule.ts +299 -0
  44. package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
  45. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  46. package/internal/src/mutable/get-json-token.ts +1 -1
  47. package/internal/src/mutable/tracker-family.ts +19 -17
  48. package/internal/src/mutable/tracker.ts +8 -8
  49. package/internal/src/not-found-error.ts +8 -30
  50. package/internal/src/pretty-print.ts +2 -13
  51. package/internal/src/selector/create-readonly-selector.ts +3 -7
  52. package/internal/src/selector/create-writable-selector.ts +4 -4
  53. package/internal/src/selector/dispose-selector.ts +20 -11
  54. package/internal/src/selector/get-selector-dependency-keys.ts +1 -1
  55. package/internal/src/selector/register-selector.ts +7 -17
  56. package/internal/src/selector/trace-selector-atoms.ts +2 -2
  57. package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
  58. package/internal/src/set-state/emit-update.ts +1 -1
  59. package/internal/src/set-state/evict-downstream.ts +1 -1
  60. package/internal/src/set-state/set-atom-or-selector.ts +1 -1
  61. package/internal/src/set-state/set-atom.ts +10 -10
  62. package/internal/src/set-state/set-into-store.ts +2 -2
  63. package/internal/src/set-state/stow-update.ts +1 -1
  64. package/internal/src/store/deposit.ts +10 -8
  65. package/internal/src/store/store.ts +1 -1
  66. package/internal/src/store/withdraw.ts +34 -53
  67. package/internal/src/subscribe/recall-state.ts +1 -1
  68. package/internal/src/subscribe/subscribe-in-store.ts +3 -3
  69. package/internal/src/subscribe/subscribe-to-root-atoms.ts +3 -3
  70. package/internal/src/subscribe/subscribe-to-state.ts +5 -5
  71. package/internal/src/subscribe/subscribe-to-timeline.ts +3 -3
  72. package/internal/src/subscribe/subscribe-to-transaction.ts +3 -3
  73. package/internal/src/timeline/create-timeline.ts +17 -37
  74. package/internal/src/transaction/act-upon-store.ts +2 -2
  75. package/internal/src/transaction/apply-transaction.ts +5 -5
  76. package/internal/src/transaction/assign-transaction-to-continuity.ts +1 -1
  77. package/internal/src/transaction/build-transaction.ts +5 -8
  78. package/internal/src/transaction/create-transaction.ts +3 -3
  79. package/internal/src/transaction/get-epoch-number.ts +3 -3
  80. package/internal/src/transaction/set-epoch-number.ts +2 -2
  81. package/introspection/dist/index.d.ts +922 -6
  82. package/introspection/dist/index.js +2 -620
  83. package/json/dist/index.d.ts +899 -5
  84. package/json/dist/index.js +1 -81
  85. package/json/src/select-json-family.ts +3 -14
  86. package/package.json +27 -45
  87. package/react/dist/index.d.ts +921 -3
  88. package/react/dist/index.js +2 -82
  89. package/react/src/use-o.ts +1 -1
  90. package/react/src/use-tl.ts +2 -2
  91. package/react-devtools/dist/index.css +16 -14
  92. package/react-devtools/dist/index.d.ts +26 -1
  93. package/react-devtools/dist/index.js +6 -6
  94. package/react-devtools/src/devtools.scss +16 -14
  95. package/realtime/dist/index.d.ts +202 -8
  96. package/realtime/dist/index.js +2 -107
  97. package/realtime/src/realtime-continuity.ts +2 -2
  98. package/realtime/src/shared-room-store.ts +1 -2
  99. package/realtime-client/dist/index.d.ts +960 -22
  100. package/realtime-client/dist/index.js +3 -509
  101. package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +3 -3
  102. package/realtime-client/src/continuity/use-conceal-state.ts +1 -1
  103. package/realtime-client/src/pull-atom-family-member.ts +2 -2
  104. package/realtime-client/src/pull-atom.ts +2 -2
  105. package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
  106. package/realtime-client/src/pull-mutable-atom.ts +2 -2
  107. package/realtime-client/src/pull-selector-family-member.ts +4 -4
  108. package/realtime-client/src/pull-selector.ts +4 -4
  109. package/realtime-client/src/push-state.ts +5 -10
  110. package/realtime-client/src/server-action.ts +4 -4
  111. package/realtime-client/src/sync-continuity.ts +6 -6
  112. package/realtime-react/dist/index.d.ts +166 -12
  113. package/realtime-react/dist/index.js +5 -154
  114. package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
  115. package/realtime-react/src/use-pull-atom.ts +1 -1
  116. package/realtime-react/src/use-pull-mutable-atom.ts +1 -1
  117. package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
  118. package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
  119. package/realtime-react/src/use-pull-selector.ts +1 -1
  120. package/realtime-react/src/use-push.ts +1 -1
  121. package/realtime-react/src/use-server-action.ts +2 -2
  122. package/realtime-react/src/use-sync-continuity.ts +1 -1
  123. package/realtime-server/dist/index.d.ts +971 -28
  124. package/realtime-server/dist/index.js +3 -1001
  125. package/realtime-server/src/continuity/prepare-to-serve-transaction-request.ts +1 -1
  126. package/realtime-server/src/continuity/prepare-to-sync-realtime-continuity.ts +3 -3
  127. package/realtime-server/src/continuity/subscribe-to-continuity-actions.ts +2 -2
  128. package/realtime-server/src/continuity/subscribe-to-continuity-perpectives.ts +2 -2
  129. package/realtime-server/src/ipc-sockets/child-socket.ts +0 -1
  130. package/realtime-server/src/realtime-action-receiver.ts +1 -1
  131. package/realtime-server/src/realtime-family-provider.ts +2 -2
  132. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  133. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  134. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +2 -1
  135. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -1
  136. package/realtime-server/src/realtime-server-stores/server-user-store.ts +1 -2
  137. package/realtime-server/src/realtime-state-provider.ts +2 -2
  138. package/realtime-testing/dist/index.d.ts +1091 -3
  139. package/realtime-testing/dist/index.js +23 -26
  140. package/realtime-testing/src/setup-realtime-test.tsx +6 -5
  141. package/src/atom.ts +53 -29
  142. package/src/dispose-state.ts +12 -2
  143. package/{ephemeral/src → src}/find-state.ts +35 -25
  144. package/src/get-state.ts +16 -0
  145. package/src/index.ts +77 -3
  146. package/src/join.ts +218 -0
  147. package/src/realm.ts +169 -0
  148. package/src/selector.ts +20 -0
  149. package/src/set-state.ts +16 -8
  150. package/src/silo.ts +13 -7
  151. package/src/timeline.ts +1 -1
  152. package/src/transaction.ts +4 -8
  153. package/transceivers/set-rtx/dist/index.d.ts +37 -2
  154. package/transceivers/set-rtx/dist/index.js +1 -212
  155. package/transceivers/set-rtx/src/set-rtx.ts +4 -1
  156. package/web/dist/index.d.ts +30 -1
  157. package/web/dist/index.js +1 -15
  158. package/data/src/until.ts +0 -15
  159. package/dist/chunk-ICGFFQ3H.js +0 -272
  160. package/ephemeral/dist/index.d.ts +0 -57
  161. package/ephemeral/dist/index.js +0 -9
  162. package/ephemeral/package.json +0 -13
  163. package/ephemeral/src/index.ts +0 -1
  164. package/eslint-plugin/src/rules/lifespan.ts +0 -203
  165. package/immortal/dist/index.d.ts +0 -12
  166. package/immortal/dist/index.js +0 -9
  167. package/immortal/package.json +0 -13
  168. package/immortal/src/index.ts +0 -1
  169. package/immortal/src/seek-state.ts +0 -60
  170. package/src/allocate.ts +0 -443
  171. package/src/molecule.ts +0 -16
@@ -1,203 +0,0 @@
1
- import type { Rule } from "eslint"
2
- import type * as ESTree from "estree"
3
-
4
- import { walk } from "../walk"
5
-
6
- export const lifespan = {
7
- meta: {
8
- type: `problem`,
9
- docs: {
10
- description: `atom.io provides tools for short-lived (ephemeral) and long-lived (immortal) stores. This rule allows you to guard against unsafe usage of tools for the other type of store.`,
11
- category: `Possible Errors`,
12
- recommended: false,
13
- url: ``, // URL to documentation page for this rule
14
- },
15
- schema: [
16
- {
17
- type: `string`,
18
- enum: [`ephemeral`, `immortal`],
19
- default: `ephemeral`,
20
- },
21
- ],
22
- },
23
- create(context) {
24
- const storeLifespan = (context.options[0] ?? `ephemeral`) as
25
- | `ephemeral`
26
- | `immortal`
27
- return {
28
- ImportDeclaration(node) {
29
- const importSource = node.source.value as string
30
- if (!importSource.startsWith(`atom.io/`)) {
31
- return
32
- }
33
- const [_, subPackageName] = importSource.split(`/`)
34
- if (storeLifespan === `immortal` && subPackageName === `ephemeral`) {
35
- context.report({
36
- node,
37
- message: `do not import from "${importSource}" in an ${storeLifespan} store`,
38
- })
39
- }
40
- },
41
-
42
- CallExpression(node) {
43
- if (storeLifespan === `ephemeral`) {
44
- return
45
- }
46
-
47
- const functionCallee =
48
- node.callee.type === `Identifier` ? node.callee : undefined
49
- const methodCallee =
50
- node.callee.type === `MemberExpression` &&
51
- node.callee.property.type === `Identifier`
52
- ? node.callee.property
53
- : undefined
54
- const callee = functionCallee ?? methodCallee
55
-
56
- if (callee === undefined) {
57
- return
58
- }
59
-
60
- if (callee.name === `findState`) {
61
- context.report({
62
- node,
63
- message: `do not use findState in an ${storeLifespan} store`,
64
- })
65
- }
66
-
67
- const storeProcedures: (
68
- | ESTree.ArrowFunctionExpression
69
- | ESTree.FunctionExpression
70
- )[] = []
71
- if (
72
- callee.name === `selector` ||
73
- callee.name === `selectorFamily` ||
74
- callee.name === `transaction`
75
- ) {
76
- if (node.arguments[0].type === `ObjectExpression`) {
77
- const argProperties = node.arguments[0].properties
78
- switch (callee.name) {
79
- case `selector`:
80
- case `selectorFamily`:
81
- {
82
- const getAndSetProps = argProperties.filter(
83
- (prop): prop is ESTree.Property => {
84
- return (
85
- `key` in prop &&
86
- `name` in prop.key &&
87
- (prop.key.name === `get` || prop.key.name === `set`)
88
- )
89
- },
90
- )
91
- switch (callee.name) {
92
- case `selector`:
93
- {
94
- for (const prop of getAndSetProps) {
95
- if (
96
- prop.value.type === `FunctionExpression` ||
97
- prop.value.type === `ArrowFunctionExpression`
98
- ) {
99
- storeProcedures.push(prop.value)
100
- }
101
- }
102
- }
103
- break
104
- case `selectorFamily`:
105
- {
106
- for (const prop of getAndSetProps) {
107
- const { value } = prop
108
- if (
109
- value.type === `FunctionExpression` ||
110
- value.type === `ArrowFunctionExpression`
111
- ) {
112
- if (value.body.type === `BlockStatement`) {
113
- for (const statement of value.body.body) {
114
- if (
115
- statement.type === `ReturnStatement` &&
116
- statement.argument &&
117
- (statement.argument.type ===
118
- `FunctionExpression` ||
119
- statement.argument.type ===
120
- `ArrowFunctionExpression`)
121
- ) {
122
- storeProcedures.push(statement.argument)
123
- }
124
- }
125
- } else if (
126
- value.body.type === `FunctionExpression` ||
127
- value.body.type === `ArrowFunctionExpression`
128
- ) {
129
- storeProcedures.push(value.body)
130
- }
131
- }
132
- }
133
- }
134
- break
135
- }
136
- }
137
- break
138
-
139
- case `transaction`:
140
- {
141
- const doProp = argProperties.find(
142
- (prop): prop is ESTree.Property => {
143
- return (
144
- `key` in prop &&
145
- `name` in prop.key &&
146
- prop.key.name === `do`
147
- )
148
- },
149
- )
150
- if (doProp) {
151
- if (
152
- doProp.value.type === `FunctionExpression` ||
153
- doProp.value.type === `ArrowFunctionExpression`
154
- ) {
155
- storeProcedures.push(doProp.value)
156
- }
157
- }
158
- }
159
- break
160
- }
161
- }
162
- }
163
-
164
- for (const storeProcedure of storeProcedures) {
165
- const transactorsParam = storeProcedure.params[0]
166
- const nonDestructuredTransactorsName =
167
- transactorsParam && `name` in transactorsParam
168
- ? transactorsParam.name
169
- : undefined
170
- walk(storeProcedure.body, (n) => {
171
- // console.log(`${`\t`.repeat(depth)}${n.type} ${n.name ?? ``}`)
172
- if (n.type === `CallExpression`) {
173
- let willReport = false
174
- switch (n.callee.type) {
175
- case `MemberExpression`:
176
- if (
177
- n.callee.object.type === `Identifier` &&
178
- n.callee.object.name === nonDestructuredTransactorsName &&
179
- n.callee.property.type === `Identifier` &&
180
- n.callee.property.name === `find`
181
- ) {
182
- willReport = true
183
- }
184
- break
185
- case `Identifier`:
186
- if (n.callee.name === `find`) {
187
- willReport = true
188
- }
189
- break
190
- }
191
- if (willReport) {
192
- context.report({
193
- node: n,
194
- message: `Using find in a transactor is not allowed in an immortal store.`,
195
- })
196
- }
197
- }
198
- })
199
- }
200
- },
201
- }
202
- },
203
- } satisfies Rule.RuleModule
@@ -1,12 +0,0 @@
1
- import { MutableAtomFamilyToken, MutableAtomToken, RegularAtomFamilyToken, RegularAtomToken, WritableSelectorFamilyToken, WritableSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, WritableFamilyToken, WritableToken, ReadableFamilyToken, ReadableToken } from 'atom.io';
2
- import { Transceiver } from 'atom.io/internal';
3
- import { Json, Canonical } from 'atom.io/json';
4
-
5
- declare function seekState<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical, Key extends K>(token: MutableAtomFamilyToken<T, J, K>, key: Key): MutableAtomToken<T, J, K> | undefined;
6
- declare function seekState<T, K extends Canonical, Key extends K>(token: RegularAtomFamilyToken<T, K>, key: Key): RegularAtomToken<T, K> | undefined;
7
- declare function seekState<T, K extends Canonical, Key extends K>(token: WritableSelectorFamilyToken<T, K>, key: Key): WritableSelectorToken<T, K> | undefined;
8
- declare function seekState<T, K extends Canonical, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key): ReadonlySelectorToken<T, K> | undefined;
9
- declare function seekState<T, K extends Canonical, Key extends K>(token: WritableFamilyToken<T, K>, key: Key): WritableToken<T, K> | undefined;
10
- declare function seekState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T, K> | undefined;
11
-
12
- export { seekState };
@@ -1,9 +0,0 @@
1
- import '../../dist/chunk-XWL6SNVU.js';
2
- import { seekInStore, IMPLICIT } from 'atom.io/internal';
3
-
4
- function seekState(token, key) {
5
- const state = seekInStore(IMPLICIT.STORE, token, key);
6
- return state;
7
- }
8
-
9
- export { seekState };
@@ -1,13 +0,0 @@
1
- {
2
- "name": "atom.io-immortal",
3
- "type": "module",
4
- "private": true,
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "import": "./dist/index.js",
10
- "types": "./dist/index.d.ts"
11
- }
12
- }
13
- }
@@ -1 +0,0 @@
1
- export * from "./seek-state"
@@ -1,60 +0,0 @@
1
- import type {
2
- MutableAtomFamilyToken,
3
- MutableAtomToken,
4
- ReadableFamilyToken,
5
- ReadableToken,
6
- ReadonlySelectorFamilyToken,
7
- ReadonlySelectorToken,
8
- RegularAtomFamilyToken,
9
- RegularAtomToken,
10
- WritableFamilyToken,
11
- WritableSelectorFamilyToken,
12
- WritableSelectorToken,
13
- WritableToken,
14
- } from "atom.io"
15
- import type { Transceiver } from "atom.io/internal"
16
- import { IMPLICIT, seekInStore } from "atom.io/internal"
17
- import type { Canonical, Json } from "atom.io/json"
18
-
19
- export function seekState<
20
- T extends Transceiver<any>,
21
- J extends Json.Serializable,
22
- K extends Canonical,
23
- Key extends K,
24
- >(
25
- token: MutableAtomFamilyToken<T, J, K>,
26
- key: Key,
27
- ): MutableAtomToken<T, J, K> | undefined
28
-
29
- export function seekState<T, K extends Canonical, Key extends K>(
30
- token: RegularAtomFamilyToken<T, K>,
31
- key: Key,
32
- ): RegularAtomToken<T, K> | undefined
33
-
34
- export function seekState<T, K extends Canonical, Key extends K>(
35
- token: WritableSelectorFamilyToken<T, K>,
36
- key: Key,
37
- ): WritableSelectorToken<T, K> | undefined
38
-
39
- export function seekState<T, K extends Canonical, Key extends K>(
40
- token: ReadonlySelectorFamilyToken<T, K>,
41
- key: Key,
42
- ): ReadonlySelectorToken<T, K> | undefined
43
-
44
- export function seekState<T, K extends Canonical, Key extends K>(
45
- token: WritableFamilyToken<T, K>,
46
- key: Key,
47
- ): WritableToken<T, K> | undefined
48
-
49
- export function seekState<T, K extends Canonical, Key extends K>(
50
- token: ReadableFamilyToken<T, K>,
51
- key: Key,
52
- ): ReadableToken<T, K> | undefined
53
-
54
- export function seekState(
55
- token: ReadableFamilyToken<any, any>,
56
- key: Canonical,
57
- ): ReadableToken<any> | undefined {
58
- const state = seekInStore(IMPLICIT.STORE, token, key)
59
- return state
60
- }