atom.io 0.28.1 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-6WL4RQMQ.js → chunk-XPYU2HY2.js} +22 -57
- package/eslint-plugin/dist/index.js +0 -1
- package/eslint-plugin/src/walk.ts +0 -1
- package/internal/dist/index.d.ts +4 -4
- package/internal/dist/index.js +1 -1
- package/internal/src/atom/dispose-atom.ts +0 -11
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +16 -25
- package/internal/src/operation.ts +7 -7
- package/internal/src/selector/create-writable-selector.ts +1 -1
- package/internal/src/selector/dispose-selector.ts +0 -13
- package/internal/src/set-state/become.ts +1 -3
- package/internal/src/set-state/evict-downstream.ts +2 -2
- package/internal/src/set-state/set-atom.ts +1 -1
- package/internal/src/set-state/set-into-store.ts +1 -1
- package/internal/src/set-state/stow-update.ts +2 -2
- package/internal/src/store/store.ts +1 -1
- package/introspection/dist/index.d.ts +15 -6
- package/introspection/dist/index.js +620 -1
- package/introspection/src/attach-atom-index.ts +5 -6
- package/introspection/src/attach-introspection-states.ts +5 -6
- package/introspection/src/attach-selector-index.ts +6 -7
- package/introspection/src/attach-timeline-family.ts +3 -4
- package/introspection/src/attach-timeline-index.ts +4 -8
- package/introspection/src/attach-transaction-index.ts +4 -8
- package/introspection/src/attach-transaction-logs.ts +4 -8
- package/introspection/src/attach-type-selectors.ts +13 -6
- package/introspection/src/differ.ts +1 -1
- package/introspection/src/index.ts +1 -0
- package/introspection/src/refinery.ts +9 -7
- package/introspection/src/sprawl.ts +42 -0
- package/json/dist/index.d.ts +12 -1
- package/json/dist/index.js +111 -2
- package/json/src/index.ts +29 -0
- package/package.json +12 -12
- package/react-devtools/dist/index.d.ts +159 -2
- package/react-devtools/dist/index.js +260 -663
- package/react-devtools/src/AtomIODevtools.tsx +24 -13
- package/react-devtools/src/StateEditor.tsx +5 -47
- package/react-devtools/src/StateIndex.tsx +15 -9
- package/react-devtools/src/TimelineIndex.tsx +9 -6
- package/react-devtools/src/TransactionIndex.tsx +9 -11
- package/react-devtools/src/elastic-input/ElasticInput.tsx +86 -0
- package/react-devtools/src/elastic-input/NumberInput.tsx +199 -0
- package/react-devtools/src/elastic-input/TextInput.tsx +47 -0
- package/react-devtools/src/elastic-input/index.ts +3 -0
- package/react-devtools/src/error-boundary/DefaultFallback.tsx +49 -0
- package/react-devtools/src/error-boundary/ReactErrorBoundary.tsx +56 -0
- package/react-devtools/src/error-boundary/index.ts +2 -0
- package/react-devtools/src/index.ts +3 -0
- package/react-devtools/src/json-editor/assets/Untitled-1.ai +1436 -2
- package/react-devtools/src/json-editor/assets/data-vis.ai +1548 -1
- package/react-devtools/src/json-editor/comp/json-editor-sketches.ai +1451 -3
- package/react-devtools/src/json-editor/default-components.tsx +101 -0
- package/react-devtools/src/json-editor/developer-interface.tsx +81 -0
- package/react-devtools/src/json-editor/editors-by-type/array-editor.tsx +38 -0
- package/react-devtools/src/json-editor/editors-by-type/non-json.tsx +23 -0
- package/react-devtools/src/json-editor/editors-by-type/object-editor.tsx +128 -0
- package/react-devtools/src/json-editor/editors-by-type/primitive-editors.tsx +73 -0
- package/react-devtools/src/json-editor/editors-by-type/utilities/array-elements.ts +16 -0
- package/react-devtools/src/json-editor/editors-by-type/utilities/cast-json.ts +57 -0
- package/react-devtools/src/json-editor/editors-by-type/utilities/cast-to-json.ts +156 -0
- package/react-devtools/src/json-editor/editors-by-type/utilities/object-properties.ts +106 -0
- package/react-devtools/src/json-editor/index.ts +32 -0
- package/react-devtools/src/json-editor/json-editor-internal.tsx +128 -0
- package/react-devtools/src/json-editor/todo.md +7 -0
- package/react-devtools/src/store.ts +70 -46
- package/dist/chunk-D52JNVER.js +0 -721
- package/dist/chunk-YQ46F5O2.js +0 -95
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
createRegularAtom,
|
|
5
5
|
createStandaloneSelector,
|
|
6
6
|
deposit,
|
|
7
|
-
IMPLICIT,
|
|
8
7
|
} from "atom.io/internal"
|
|
9
8
|
|
|
10
9
|
import type { WritableTokenIndex } from "."
|
|
@@ -12,19 +11,19 @@ import type { WritableTokenIndex } from "."
|
|
|
12
11
|
export type SelectorTokenIndex = WritableTokenIndex<SelectorToken<unknown>>
|
|
13
12
|
|
|
14
13
|
export const attachSelectorIndex = (
|
|
15
|
-
store: Store
|
|
14
|
+
store: Store,
|
|
16
15
|
): ReadonlySelectorToken<SelectorTokenIndex> => {
|
|
17
16
|
const readonlySelectorTokenIndexState__INTERNAL =
|
|
18
17
|
createRegularAtom<SelectorTokenIndex>(
|
|
19
18
|
store,
|
|
20
19
|
|
|
21
20
|
{
|
|
22
|
-
key:
|
|
21
|
+
key: `🔍 Selector Token Index (Internal)`,
|
|
23
22
|
default: () => {
|
|
24
23
|
const base: SelectorTokenIndex = new Map()
|
|
25
24
|
for (const map of [store.readonlySelectors, store.selectors]) {
|
|
26
25
|
for (const [key, val] of map) {
|
|
27
|
-
if (!key.includes(
|
|
26
|
+
if (!key.includes(`🔍`)) {
|
|
28
27
|
const token = deposit(val)
|
|
29
28
|
if (val.family) {
|
|
30
29
|
let familyNode = base.get(val.family.key)
|
|
@@ -49,7 +48,7 @@ export const attachSelectorIndex = (
|
|
|
49
48
|
store.on.selectorCreation.subscribe(
|
|
50
49
|
`introspection`,
|
|
51
50
|
(selectorToken) => {
|
|
52
|
-
if (selectorToken.key.includes(
|
|
51
|
+
if (selectorToken.key.includes(`🔍`)) {
|
|
53
52
|
return
|
|
54
53
|
}
|
|
55
54
|
|
|
@@ -101,8 +100,8 @@ export const attachSelectorIndex = (
|
|
|
101
100
|
},
|
|
102
101
|
undefined,
|
|
103
102
|
)
|
|
104
|
-
return createStandaloneSelector(
|
|
105
|
-
key:
|
|
103
|
+
return createStandaloneSelector(store, {
|
|
104
|
+
key: `🔍 Selector Token Index`,
|
|
106
105
|
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),
|
|
107
106
|
})
|
|
108
107
|
}
|
|
@@ -3,18 +3,17 @@ import type { Store, Timeline } from "atom.io/internal"
|
|
|
3
3
|
import {
|
|
4
4
|
createRegularAtomFamily,
|
|
5
5
|
createSelectorFamily,
|
|
6
|
-
IMPLICIT,
|
|
7
6
|
Subject,
|
|
8
7
|
} from "atom.io/internal"
|
|
9
8
|
|
|
10
9
|
export const attachTimelineFamily = (
|
|
11
|
-
store: Store
|
|
10
|
+
store: Store,
|
|
12
11
|
): ReadonlySelectorFamilyToken<Timeline<any>, string> => {
|
|
13
12
|
const findTimelineLogState__INTERNAL = createRegularAtomFamily<
|
|
14
13
|
Timeline<any>,
|
|
15
14
|
string
|
|
16
15
|
>(store, {
|
|
17
|
-
key:
|
|
16
|
+
key: `🔍 Timeline Update Log (Internal)`,
|
|
18
17
|
default: (key) =>
|
|
19
18
|
store.timelines.get(key) ?? {
|
|
20
19
|
type: `timeline`,
|
|
@@ -40,7 +39,7 @@ export const attachTimelineFamily = (
|
|
|
40
39
|
const findTimelineLogState = createSelectorFamily<Timeline<any>, string>(
|
|
41
40
|
store,
|
|
42
41
|
{
|
|
43
|
-
key:
|
|
42
|
+
key: `🔍 Timeline Update Log`,
|
|
44
43
|
get:
|
|
45
44
|
(key) =>
|
|
46
45
|
({ get }) =>
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import type { ReadonlySelectorToken, TimelineToken } from "atom.io"
|
|
2
2
|
import type { Store } from "atom.io/internal"
|
|
3
|
-
import {
|
|
4
|
-
createRegularAtom,
|
|
5
|
-
createStandaloneSelector,
|
|
6
|
-
IMPLICIT,
|
|
7
|
-
} from "atom.io/internal"
|
|
3
|
+
import { createRegularAtom, createStandaloneSelector } from "atom.io/internal"
|
|
8
4
|
|
|
9
5
|
export const attachTimelineIndex = (
|
|
10
|
-
store: Store
|
|
6
|
+
store: Store,
|
|
11
7
|
): ReadonlySelectorToken<TimelineToken<any>[]> => {
|
|
12
8
|
const timelineTokenIndexState__INTERNAL = createRegularAtom<
|
|
13
9
|
TimelineToken<any>[]
|
|
14
10
|
>(
|
|
15
11
|
store,
|
|
16
12
|
{
|
|
17
|
-
key:
|
|
13
|
+
key: `🔍 Timeline Token Index (Internal)`,
|
|
18
14
|
default: () =>
|
|
19
15
|
[...store.timelines].map(([key]): TimelineToken<any> => {
|
|
20
16
|
return { key, type: `timeline` }
|
|
@@ -33,7 +29,7 @@ export const attachTimelineIndex = (
|
|
|
33
29
|
undefined,
|
|
34
30
|
)
|
|
35
31
|
const timelineTokenIndex = createStandaloneSelector(store, {
|
|
36
|
-
key:
|
|
32
|
+
key: `🔍 Timeline Token Index`,
|
|
37
33
|
get: ({ get }) => get(timelineTokenIndexState__INTERNAL),
|
|
38
34
|
})
|
|
39
35
|
return timelineTokenIndex
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import type { ReadonlySelectorToken, TransactionToken } from "atom.io"
|
|
2
2
|
import type { Func, Store } from "atom.io/internal"
|
|
3
|
-
import {
|
|
4
|
-
createRegularAtom,
|
|
5
|
-
createStandaloneSelector,
|
|
6
|
-
IMPLICIT,
|
|
7
|
-
} from "atom.io/internal"
|
|
3
|
+
import { createRegularAtom, createStandaloneSelector } from "atom.io/internal"
|
|
8
4
|
|
|
9
5
|
export const attachTransactionIndex = (
|
|
10
|
-
store: Store
|
|
6
|
+
store: Store,
|
|
11
7
|
): ReadonlySelectorToken<TransactionToken<Func>[]> => {
|
|
12
8
|
const transactionTokenIndexState__INTERNAL = createRegularAtom<
|
|
13
9
|
TransactionToken<Func>[]
|
|
14
10
|
>(
|
|
15
11
|
store,
|
|
16
12
|
{
|
|
17
|
-
key:
|
|
13
|
+
key: `🔍 Transaction Token Index (Internal)`,
|
|
18
14
|
default: () =>
|
|
19
15
|
[...store.transactions].map(([key]): TransactionToken<Func> => {
|
|
20
16
|
return { key, type: `transaction` }
|
|
@@ -33,7 +29,7 @@ export const attachTransactionIndex = (
|
|
|
33
29
|
undefined,
|
|
34
30
|
)
|
|
35
31
|
const transactionTokenIndex = createStandaloneSelector(store, {
|
|
36
|
-
key:
|
|
32
|
+
key: `🔍 Transaction Token Index`,
|
|
37
33
|
get: ({ get }) => get(transactionTokenIndexState__INTERNAL),
|
|
38
34
|
})
|
|
39
35
|
return transactionTokenIndex
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import type { ReadonlySelectorFamilyToken, TransactionUpdate } from "atom.io"
|
|
2
2
|
import type { Func, Store } from "atom.io/internal"
|
|
3
|
-
import {
|
|
4
|
-
createRegularAtomFamily,
|
|
5
|
-
createSelectorFamily,
|
|
6
|
-
IMPLICIT,
|
|
7
|
-
} from "atom.io/internal"
|
|
3
|
+
import { createRegularAtomFamily, createSelectorFamily } from "atom.io/internal"
|
|
8
4
|
|
|
9
5
|
export const attachTransactionLogs = (
|
|
10
|
-
store: Store
|
|
6
|
+
store: Store,
|
|
11
7
|
): ReadonlySelectorFamilyToken<TransactionUpdate<Func>[], string> => {
|
|
12
8
|
const transactionUpdateLogAtoms = createRegularAtomFamily<
|
|
13
9
|
TransactionUpdate<Func>[],
|
|
14
10
|
string
|
|
15
11
|
>(store, {
|
|
16
|
-
key:
|
|
12
|
+
key: `🔍 Transaction Update Log (Internal)`,
|
|
17
13
|
default: () => [],
|
|
18
14
|
effects: (key) => [
|
|
19
15
|
({ setSelf }) => {
|
|
@@ -30,7 +26,7 @@ export const attachTransactionLogs = (
|
|
|
30
26
|
TransactionUpdate<Func>[],
|
|
31
27
|
string
|
|
32
28
|
>(store, {
|
|
33
|
-
key:
|
|
29
|
+
key: `🔍 Transaction Update Log`,
|
|
34
30
|
get:
|
|
35
31
|
(key) =>
|
|
36
32
|
({ get }) =>
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import type { ReadonlySelectorFamilyToken } from "atom.io"
|
|
2
2
|
import type { Store } from "atom.io/internal"
|
|
3
|
-
import { createReadonlySelectorFamily
|
|
3
|
+
import { createReadonlySelectorFamily } from "atom.io/internal"
|
|
4
4
|
|
|
5
5
|
import { discoverType } from "./refinery"
|
|
6
6
|
|
|
7
7
|
export const attachTypeSelectors = (
|
|
8
|
-
store: Store
|
|
8
|
+
store: Store,
|
|
9
9
|
): ReadonlySelectorFamilyToken<string, string> => {
|
|
10
10
|
const typeSelectors = createReadonlySelectorFamily<string, string>(store, {
|
|
11
|
-
key:
|
|
11
|
+
key: `🔍 State Type`,
|
|
12
12
|
get:
|
|
13
|
-
(
|
|
13
|
+
(key) =>
|
|
14
14
|
({ get }) => {
|
|
15
15
|
let state: unknown
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const token =
|
|
18
|
+
store.atoms.get(key) ??
|
|
19
|
+
store.selectors.get(key) ??
|
|
20
|
+
store.readonlySelectors.get(key)
|
|
21
|
+
if (token === undefined) {
|
|
22
|
+
throw new Error(`Could not find state with key "${key}"`)
|
|
23
|
+
}
|
|
24
|
+
state = get(token)
|
|
25
|
+
} catch (thrown) {
|
|
19
26
|
return `error`
|
|
20
27
|
}
|
|
21
28
|
const typeOfState = discoverType(state)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { sprawl } from "anvl/object"
|
|
2
1
|
import type { Json } from "atom.io/json"
|
|
3
2
|
|
|
4
3
|
import type { Refinery, Supported } from "./refinery"
|
|
5
4
|
import { discoverType, jsonTreeRefinery, primitiveRefinery } from "./refinery"
|
|
5
|
+
import { sprawl } from "./sprawl"
|
|
6
6
|
|
|
7
7
|
export function diffNumber(a: number, b: number): Delta {
|
|
8
8
|
const sign = a < b ? `+` : `-`
|
|
@@ -68,14 +68,16 @@ export const primitiveRefinery = new Refinery({
|
|
|
68
68
|
null: (input: unknown): input is null => input === null,
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
+
export function isPlainObject(input: unknown): input is Json.Tree.Object {
|
|
72
|
+
if (!input) {
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
const prototype = Object.getPrototypeOf(input)
|
|
76
|
+
return prototype === Object.prototype
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
export const jsonTreeRefinery = new Refinery({
|
|
72
|
-
object:
|
|
73
|
-
if (!input) {
|
|
74
|
-
return false
|
|
75
|
-
}
|
|
76
|
-
const prototype = Object.getPrototypeOf(input)
|
|
77
|
-
return prototype === Object.prototype
|
|
78
|
-
},
|
|
80
|
+
object: isPlainObject,
|
|
79
81
|
array: (input: unknown): input is Json.Tree.Array => Array.isArray(input),
|
|
80
82
|
})
|
|
81
83
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { isPlainObject } from "./refinery"
|
|
2
|
+
|
|
3
|
+
// if you found what you were looking for, return true and break
|
|
4
|
+
export type InspectionResult = Partial<{
|
|
5
|
+
pathComplete: true
|
|
6
|
+
jobComplete: true
|
|
7
|
+
}>
|
|
8
|
+
export type InspectNode = (
|
|
9
|
+
path: string[],
|
|
10
|
+
node: unknown,
|
|
11
|
+
) => InspectionResult | void
|
|
12
|
+
|
|
13
|
+
export const sprawl = (
|
|
14
|
+
tree: Array<unknown> | object,
|
|
15
|
+
inspector: InspectNode,
|
|
16
|
+
): void => {
|
|
17
|
+
const walk = (path: string[], node: unknown): InspectionResult => {
|
|
18
|
+
const inspect = (p: string[], n: unknown): InspectionResult | null => {
|
|
19
|
+
// console.log(parent)
|
|
20
|
+
const result = inspector(p, n)
|
|
21
|
+
if (result) return result
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
const result = inspect(path, node)
|
|
25
|
+
if (result?.jobComplete ?? result?.pathComplete) {
|
|
26
|
+
return result
|
|
27
|
+
}
|
|
28
|
+
const childEntries = Array.isArray(node)
|
|
29
|
+
? node.map((v, i) => [i, v])
|
|
30
|
+
: isPlainObject(node)
|
|
31
|
+
? Object.entries(node)
|
|
32
|
+
: []
|
|
33
|
+
for (const [k, v] of childEntries) {
|
|
34
|
+
const subResult = walk([...path, k], v)
|
|
35
|
+
if (subResult?.jobComplete) {
|
|
36
|
+
return subResult
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {}
|
|
40
|
+
}
|
|
41
|
+
walk([], tree)
|
|
42
|
+
}
|
package/json/dist/index.d.ts
CHANGED
|
@@ -44,5 +44,16 @@ type JsonInterface<T, J extends Json.Serializable = Json.Serializable> = {
|
|
|
44
44
|
fromJson: (json: J) => T;
|
|
45
45
|
};
|
|
46
46
|
declare const isJson: (input: unknown) => input is Json.Tree.Node;
|
|
47
|
+
declare const JSON_TYPE_NAMES: readonly ["array", "boolean", "null", "number", "object", "string"];
|
|
48
|
+
type JsonTypeName = (typeof JSON_TYPE_NAMES)[number];
|
|
49
|
+
interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {
|
|
50
|
+
array: Json.Array;
|
|
51
|
+
boolean: boolean;
|
|
52
|
+
null: null;
|
|
53
|
+
number: number;
|
|
54
|
+
object: Json.Object;
|
|
55
|
+
string: string;
|
|
56
|
+
}
|
|
57
|
+
declare const JSON_DEFAULTS: JsonTypes;
|
|
47
58
|
|
|
48
|
-
export { type Canonical, type Entries, type FromEntries, Json, type JsonIO, type JsonInterface, type KeyOfEntries, type ValueOfEntry, fromEntries, isJson, parseJson, type primitive, selectJson, selectJsonFamily, type stringified, stringifyJson, toEntries };
|
|
59
|
+
export { type Canonical, type Entries, type FromEntries, JSON_DEFAULTS, JSON_TYPE_NAMES, Json, type JsonIO, type JsonInterface, type JsonTypeName, type JsonTypes, type KeyOfEntries, type ValueOfEntry, fromEntries, isJson, parseJson, type primitive, selectJson, selectJsonFamily, type stringified, stringifyJson, toEntries };
|
package/json/dist/index.js
CHANGED
|
@@ -1,4 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
import '../../dist/chunk-6WL4RQMQ.js';
|
|
1
|
+
import { createWritableSelectorFamily } from '../../dist/chunk-XPYU2HY2.js';
|
|
3
2
|
import '../../dist/chunk-IBTHB2PI.js';
|
|
4
3
|
import '../../dist/chunk-XWL6SNVU.js';
|
|
4
|
+
import { createStandaloneSelector, IMPLICIT, growMoleculeInStore, initFamilyMemberInStore, withdraw, seekInStore } from 'atom.io/internal';
|
|
5
|
+
|
|
6
|
+
// json/src/entries.ts
|
|
7
|
+
function fromEntries(entries) {
|
|
8
|
+
return Object.fromEntries(entries);
|
|
9
|
+
}
|
|
10
|
+
function toEntries(obj) {
|
|
11
|
+
return Object.entries(obj);
|
|
12
|
+
}
|
|
13
|
+
var selectJson = (atom, transform, store = IMPLICIT.STORE) => {
|
|
14
|
+
return createStandaloneSelector(store, {
|
|
15
|
+
key: `${atom.key}:JSON`,
|
|
16
|
+
get: ({ get }) => transform.toJson(get(atom)),
|
|
17
|
+
set: ({ set }, newValue) => {
|
|
18
|
+
set(atom, transform.fromJson(newValue));
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
function selectJsonFamily(atomFamilyToken, transform, store = IMPLICIT.STORE) {
|
|
23
|
+
const jsonFamily = createWritableSelectorFamily(
|
|
24
|
+
store,
|
|
25
|
+
{
|
|
26
|
+
key: `${atomFamilyToken.key}:JSON`,
|
|
27
|
+
get: (key) => ({ seek, get }) => {
|
|
28
|
+
const existingState = seek(atomFamilyToken, key);
|
|
29
|
+
if (existingState) {
|
|
30
|
+
return transform.toJson(get(existingState));
|
|
31
|
+
}
|
|
32
|
+
const stringKey = stringifyJson(key);
|
|
33
|
+
const molecule = store.molecules.get(stringKey);
|
|
34
|
+
if (molecule) {
|
|
35
|
+
const atom = growMoleculeInStore(molecule, atomFamilyToken, store);
|
|
36
|
+
return transform.toJson(get(atom));
|
|
37
|
+
}
|
|
38
|
+
if (store.config.lifespan === `immortal`) {
|
|
39
|
+
throw new Error(`No molecule found for key "${stringKey}"`);
|
|
40
|
+
}
|
|
41
|
+
const newToken = initFamilyMemberInStore(store, atomFamilyToken, key);
|
|
42
|
+
return transform.toJson(get(newToken));
|
|
43
|
+
},
|
|
44
|
+
set: (key) => ({ seek, set }, newValue) => {
|
|
45
|
+
const existingState = seek(atomFamilyToken, key);
|
|
46
|
+
if (existingState) {
|
|
47
|
+
set(existingState, transform.fromJson(newValue));
|
|
48
|
+
} else {
|
|
49
|
+
const stringKey = stringifyJson(key);
|
|
50
|
+
const molecule = store.molecules.get(stringKey);
|
|
51
|
+
if (molecule) {
|
|
52
|
+
const atom = growMoleculeInStore(molecule, atomFamilyToken, store);
|
|
53
|
+
set(atom, transform.fromJson(newValue));
|
|
54
|
+
} else {
|
|
55
|
+
if (store.config.lifespan === `immortal`) {
|
|
56
|
+
throw new Error(`No molecule found for key "${stringKey}"`);
|
|
57
|
+
}
|
|
58
|
+
set(
|
|
59
|
+
initFamilyMemberInStore(store, atomFamilyToken, key),
|
|
60
|
+
transform.fromJson(newValue)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
[`mutable`, `json`]
|
|
67
|
+
);
|
|
68
|
+
const atomFamily = withdraw(atomFamilyToken, store);
|
|
69
|
+
atomFamily.subject.subscribe(
|
|
70
|
+
`store=${store.config.name}::json-selector-family`,
|
|
71
|
+
(event) => {
|
|
72
|
+
if (event.token.family) {
|
|
73
|
+
seekInStore(store, jsonFamily, parseJson(event.token.family.subKey));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
return jsonFamily;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// json/src/index.ts
|
|
81
|
+
var parseJson = (str) => JSON.parse(str);
|
|
82
|
+
var stringifyJson = (json) => JSON.stringify(json);
|
|
83
|
+
var JSON_PROTOTYPES = [
|
|
84
|
+
Array.prototype,
|
|
85
|
+
Boolean.prototype,
|
|
86
|
+
Number.prototype,
|
|
87
|
+
Object.prototype,
|
|
88
|
+
String.prototype
|
|
89
|
+
];
|
|
90
|
+
var isJson = (input) => {
|
|
91
|
+
if (input === null) return true;
|
|
92
|
+
if (input === void 0) return false;
|
|
93
|
+
const prototype = Object.getPrototypeOf(input);
|
|
94
|
+
return JSON_PROTOTYPES.includes(prototype);
|
|
95
|
+
};
|
|
96
|
+
var JSON_TYPE_NAMES = [
|
|
97
|
+
`array`,
|
|
98
|
+
`boolean`,
|
|
99
|
+
`null`,
|
|
100
|
+
`number`,
|
|
101
|
+
`object`,
|
|
102
|
+
`string`
|
|
103
|
+
];
|
|
104
|
+
var JSON_DEFAULTS = {
|
|
105
|
+
array: [],
|
|
106
|
+
boolean: false,
|
|
107
|
+
null: null,
|
|
108
|
+
number: 0,
|
|
109
|
+
object: {},
|
|
110
|
+
string: ``
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export { JSON_DEFAULTS, JSON_TYPE_NAMES, fromEntries, isJson, parseJson, selectJson, selectJsonFamily, stringifyJson, toEntries };
|
package/json/src/index.ts
CHANGED
|
@@ -59,3 +59,32 @@ export const isJson = (input: unknown): input is Json.Tree.Node => {
|
|
|
59
59
|
const prototype = Object.getPrototypeOf(input)
|
|
60
60
|
return JSON_PROTOTYPES.includes(prototype)
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
export const JSON_TYPE_NAMES = [
|
|
64
|
+
`array`,
|
|
65
|
+
`boolean`,
|
|
66
|
+
`null`,
|
|
67
|
+
`number`,
|
|
68
|
+
`object`,
|
|
69
|
+
`string`,
|
|
70
|
+
] as const
|
|
71
|
+
|
|
72
|
+
export type JsonTypeName = (typeof JSON_TYPE_NAMES)[number]
|
|
73
|
+
|
|
74
|
+
export interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {
|
|
75
|
+
array: Json.Array
|
|
76
|
+
boolean: boolean
|
|
77
|
+
null: null
|
|
78
|
+
number: number
|
|
79
|
+
object: Json.Object
|
|
80
|
+
string: string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const JSON_DEFAULTS: JsonTypes = {
|
|
84
|
+
array: [],
|
|
85
|
+
boolean: false,
|
|
86
|
+
null: null,
|
|
87
|
+
number: 0,
|
|
88
|
+
object: {},
|
|
89
|
+
string: ``,
|
|
90
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atom.io",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "Composable and testable reactive data library.",
|
|
5
5
|
"homepage": "https://atom.io.fyi",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -52,23 +52,23 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@testing-library/react": "16.0.
|
|
56
|
-
"@types/eslint": "9.6.
|
|
55
|
+
"@testing-library/react": "16.0.1",
|
|
56
|
+
"@types/eslint": "9.6.1",
|
|
57
57
|
"@types/estree": "1.0.5",
|
|
58
58
|
"@types/http-proxy": "1.17.15",
|
|
59
59
|
"@types/npmlog": "7.0.0",
|
|
60
|
-
"@types/react": "18.3.
|
|
60
|
+
"@types/react": "18.3.5",
|
|
61
61
|
"@types/tmp": "0.2.6",
|
|
62
|
-
"@typescript-eslint/parser": "8.
|
|
63
|
-
"@typescript-eslint/rule-tester": "8.
|
|
62
|
+
"@typescript-eslint/parser": "8.4.0",
|
|
63
|
+
"@typescript-eslint/rule-tester": "8.4.0",
|
|
64
64
|
"@vitest/coverage-v8": "2.0.5",
|
|
65
65
|
"@vitest/ui": "2.0.5",
|
|
66
66
|
"concurrently": "8.2.2",
|
|
67
|
-
"drizzle-kit": "0.24.
|
|
67
|
+
"drizzle-kit": "0.24.2",
|
|
68
68
|
"drizzle-orm": "0.33.0",
|
|
69
|
-
"eslint": "9.9.
|
|
70
|
-
"framer-motion": "11.
|
|
71
|
-
"happy-dom": "15.
|
|
69
|
+
"eslint": "9.9.1",
|
|
70
|
+
"framer-motion": "11.5.2",
|
|
71
|
+
"happy-dom": "15.7.3",
|
|
72
72
|
"http-proxy": "1.18.1",
|
|
73
73
|
"npmlog": "7.0.1",
|
|
74
74
|
"postgres": "3.4.4",
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
"socket.io-client": "4.7.5",
|
|
81
81
|
"tmp": "0.2.3",
|
|
82
82
|
"tsup": "8.2.4",
|
|
83
|
-
"tsx": "4.
|
|
83
|
+
"tsx": "4.19.0",
|
|
84
84
|
"typescript": "5.5.4",
|
|
85
|
-
"vite": "5.4.
|
|
85
|
+
"vite": "5.4.3",
|
|
86
86
|
"vite-tsconfig-paths": "5.0.1",
|
|
87
87
|
"vitest": "2.0.5"
|
|
88
88
|
},
|