atom.io 0.23.2 → 0.23.4

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.
@@ -169,7 +169,19 @@ function makeMoleculeInStore(store, context, family, key, ...params) {
169
169
  family
170
170
  };
171
171
  const contextArray = Array.isArray(context) ? context : [context];
172
- const owners = contextArray.map((ctx) => store.molecules.get(json.stringifyJson(ctx.key))).filter((m) => m !== void 0);
172
+ const owners = contextArray.map((ctx) => {
173
+ if (ctx instanceof Molecule) {
174
+ return ctx;
175
+ }
176
+ const stringKey = json.stringifyJson(ctx.key);
177
+ const molecule2 = store.molecules.get(stringKey);
178
+ if (!molecule2) {
179
+ throw new Error(
180
+ `Molecule ${stringKey} not found in store "${store.config.name}"`
181
+ );
182
+ }
183
+ return molecule2;
184
+ });
173
185
  const Formula = Internal__namespace.withdraw(family, store);
174
186
  const molecule = new Formula(owners, token, ...params);
175
187
  target.molecules.set(json.stringifyJson(key), molecule);
@@ -28,7 +28,7 @@ declare class Molecule<Key extends Json.Serializable> {
28
28
  claim(child: Molecule<any>): void;
29
29
  clear(): void;
30
30
  join(token: JoinToken<any, any, any, any>): void;
31
- private [Symbol.dispose];
31
+ protected [Symbol.dispose](): void;
32
32
  dispose: () => void;
33
33
  }
34
34
 
@@ -130,7 +130,19 @@ function makeMoleculeInStore(store, context, family, key, ...params) {
130
130
  family
131
131
  };
132
132
  const contextArray = Array.isArray(context) ? context : [context];
133
- const owners = contextArray.map((ctx) => store.molecules.get(stringifyJson(ctx.key))).filter((m) => m !== void 0);
133
+ const owners = contextArray.map((ctx) => {
134
+ if (ctx instanceof Molecule) {
135
+ return ctx;
136
+ }
137
+ const stringKey = stringifyJson(ctx.key);
138
+ const molecule2 = store.molecules.get(stringKey);
139
+ if (!molecule2) {
140
+ throw new Error(
141
+ `Molecule ${stringKey} not found in store "${store.config.name}"`
142
+ );
143
+ }
144
+ return molecule2;
145
+ });
134
146
  const Formula = Internal.withdraw(family, store);
135
147
  const molecule = new Formula(owners, token, ...params);
136
148
  target.molecules.set(stringifyJson(key), molecule);
@@ -107,9 +107,21 @@ export function makeMoleculeInStore<
107
107
  } as const satisfies MoleculeToken<Key, Struct, Params>
108
108
 
109
109
  const contextArray = Array.isArray(context) ? context : [context]
110
- const owners = contextArray
111
- .map((ctx) => store.molecules.get(stringifyJson(ctx.key)))
112
- .filter((m): m is Molecule<Key> => m !== undefined)
110
+ const owners = contextArray.map<Molecule<any>>((ctx) => {
111
+ if (ctx instanceof Molecule) {
112
+ return ctx
113
+ }
114
+ const stringKey = stringifyJson(ctx.key)
115
+ const molecule = store.molecules.get(stringKey)
116
+
117
+ if (!molecule) {
118
+ throw new Error(
119
+ `Molecule ${stringKey} not found in store "${store.config.name}"`,
120
+ )
121
+ }
122
+ return molecule
123
+ })
124
+
113
125
  const Formula = Internal.withdraw(family, store)
114
126
  const molecule = new Formula(owners, token, ...params)
115
127
  target.molecules.set(stringifyJson(key), molecule)
@@ -155,7 +155,7 @@ export class Molecule<Key extends Json.Serializable> {
155
155
  this.joins.push(join)
156
156
  }
157
157
 
158
- private [Symbol.dispose](): void {
158
+ protected [Symbol.dispose](): void {
159
159
  this.clear()
160
160
  const target = newest(this.store)
161
161
  target.molecules.delete(stringifyJson(this.token.key))
@@ -183,7 +183,7 @@ declare class Molecule<Key extends Json.Serializable> {
183
183
  claim(child: Molecule<any>): void;
184
184
  clear(): void;
185
185
  join(token: JoinToken<any, any, any, any>): void;
186
- private [Symbol.dispose];
186
+ protected [Symbol.dispose](): void;
187
187
  dispose: () => void;
188
188
  }
189
189
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.23.2",
3
+ "version": "0.23.4",
4
4
  "description": "Composable and testable reactive data library.",
5
5
  "homepage": "https://atom.io.fyi",
6
6
  "sideEffects": false,
@@ -61,7 +61,7 @@
61
61
  "@vitest/coverage-v8": "1.6.0",
62
62
  "@vitest/ui": "1.6.0",
63
63
  "concurrently": "8.2.2",
64
- "drizzle-kit": "0.21.3",
64
+ "drizzle-kit": "0.21.4",
65
65
  "drizzle-orm": "0.30.10",
66
66
  "eslint": "npm:eslint@8.57.0",
67
67
  "eslint-v9": "npm:eslint@9.3.0",