jazz-tools 0.20.3 → 0.20.5
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/.turbo/turbo-build.log +50 -50
- package/CHANGELOG.md +19 -0
- package/dist/{chunk-Q5RNSSUM.js → chunk-HBWUGW37.js} +9 -3
- package/dist/chunk-HBWUGW37.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/inspector/{custom-element-WOQY2M4W.js → custom-element-TJNWN4WC.js} +4 -3
- package/dist/inspector/{custom-element-WOQY2M4W.js.map → custom-element-TJNWN4WC.js.map} +1 -1
- package/dist/inspector/in-app.d.ts +2 -1
- package/dist/inspector/in-app.d.ts.map +1 -1
- package/dist/inspector/index.d.ts.map +1 -1
- package/dist/inspector/index.js +5 -3
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools/subscribe/SubscriptionCache.d.ts.map +1 -1
- package/dist/tools/tests/testStorage.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/inspector/in-app.tsx +3 -2
- package/src/inspector/index.tsx +1 -0
- package/src/react-core/tests/useCoState.test.ts +135 -0
- package/src/tools/subscribe/SubscriptionCache.ts +10 -1
- package/src/tools/subscribe/SubscriptionScope.ts +1 -1
- package/src/tools/tests/testStorage.ts +12 -10
- package/dist/chunk-Q5RNSSUM.js.map +0 -1
|
@@ -12,6 +12,14 @@ import { SubscriptionScope } from "./SubscriptionScope.js";
|
|
|
12
12
|
import type { BranchDefinition } from "./types.js";
|
|
13
13
|
import { isEqualRefsToResolve } from "./utils.js";
|
|
14
14
|
|
|
15
|
+
function copyResolve(resolve: RefsToResolve<any>): RefsToResolve<any> {
|
|
16
|
+
if (typeof resolve !== "object" || resolve === null) {
|
|
17
|
+
return resolve;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return { ...resolve };
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
interface CacheEntry {
|
|
16
24
|
subscriptionScope: SubscriptionScope<any>;
|
|
17
25
|
schema: CoValueClassOrSchema;
|
|
@@ -233,10 +241,11 @@ export class SubscriptionCache {
|
|
|
233
241
|
};
|
|
234
242
|
|
|
235
243
|
// Create cache entry with initial subscriber count (starts at 0)
|
|
244
|
+
// Clone resolve to prevent mutation by SubscriptionScope.subscribeToKey from affecting cache lookups
|
|
236
245
|
const entry: CacheEntry = {
|
|
237
246
|
subscriptionScope,
|
|
238
247
|
schema,
|
|
239
|
-
resolve,
|
|
248
|
+
resolve: copyResolve(resolve),
|
|
240
249
|
branch,
|
|
241
250
|
subscriberCount: subscriptionScope.subscribers.size,
|
|
242
251
|
unsubscribeFromScope: subscriptionScope.onSubscriberChange(
|
|
@@ -45,26 +45,28 @@ class LibSQLSqliteAsyncDriver implements SQLiteDatabaseDriverAsync {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
function deleteDb(dbPath: string) {
|
|
49
|
+
try {
|
|
50
|
+
unlinkSync(dbPath);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
export async function createAsyncStorage({ filename }: { filename?: string }) {
|
|
57
|
+
const dbPath = getDbPath(filename);
|
|
49
58
|
const storage = await getSqliteStorageAsync(
|
|
50
|
-
new LibSQLSqliteAsyncDriver(
|
|
59
|
+
new LibSQLSqliteAsyncDriver(dbPath),
|
|
51
60
|
);
|
|
52
61
|
|
|
53
62
|
onTestFinished(async () => {
|
|
54
63
|
await storage.close();
|
|
64
|
+
deleteDb(dbPath);
|
|
55
65
|
});
|
|
56
66
|
|
|
57
67
|
return storage;
|
|
58
68
|
}
|
|
59
69
|
|
|
60
70
|
export function getDbPath(defaultDbPath?: string) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!defaultDbPath) {
|
|
64
|
-
onTestFinished(() => {
|
|
65
|
-
unlinkSync(dbPath);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return dbPath;
|
|
71
|
+
return defaultDbPath ?? join(tmpdir(), `test-${randomUUID()}.db`);
|
|
70
72
|
}
|