jazz-tools 0.18.6 → 0.18.8
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 +55 -55
- package/CHANGELOG.md +28 -0
- package/dist/better-auth/auth/server.d.ts.map +1 -1
- package/dist/better-auth/auth/server.js +8 -4
- package/dist/better-auth/auth/server.js.map +1 -1
- package/dist/{chunk-45VKEOXG.js → chunk-QF3R3C4N.js} +75 -22
- package/dist/chunk-QF3R3C4N.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/inspector/{custom-element-IBHKHN27.js → custom-element-G6SPZEBR.js} +292 -31
- package/dist/inspector/custom-element-G6SPZEBR.js.map +1 -0
- package/dist/inspector/index.d.ts +1 -1
- package/dist/inspector/index.js +302 -41
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/inspector/ui/button.d.ts +1 -1
- package/dist/inspector/ui/button.d.ts.map +1 -1
- package/dist/inspector/ui/heading.d.ts +2 -1
- package/dist/inspector/ui/heading.d.ts.map +1 -1
- package/dist/inspector/ui/input.d.ts.map +1 -1
- package/dist/inspector/ui/modal.d.ts +16 -0
- package/dist/inspector/ui/modal.d.ts.map +1 -0
- package/dist/inspector/viewer/delete-local-data.d.ts +2 -0
- package/dist/inspector/viewer/delete-local-data.d.ts.map +1 -0
- package/dist/inspector/viewer/{inpsector-button.d.ts → inspector-button.d.ts} +1 -1
- package/dist/inspector/viewer/{inpsector-button.d.ts.map → inspector-button.d.ts.map} +1 -1
- package/dist/inspector/viewer/new-app.d.ts +1 -1
- package/dist/inspector/viewer/new-app.d.ts.map +1 -1
- package/dist/react/hooks.d.ts +1 -1
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +3 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-core/hooks.d.ts +133 -0
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +85 -17
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/tests/useCoStateWithSelector.test.d.ts +2 -0
- package/dist/react-core/tests/useCoStateWithSelector.test.d.ts.map +1 -0
- package/dist/react-native-core/hooks.d.ts +1 -1
- package/dist/react-native-core/hooks.d.ts.map +1 -1
- package/dist/react-native-core/index.js +3 -1
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools/coValues/CoFieldInit.d.ts +5 -5
- package/dist/tools/coValues/CoFieldInit.d.ts.map +1 -1
- package/dist/tools/coValues/CoValueBase.d.ts +14 -0
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +0 -12
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/implementation/createContext.d.ts +2 -1
- package/dist/tools/implementation/createContext.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +5 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/tests/utils.d.ts.map +1 -1
- package/dist/worker/index.d.ts +4 -0
- package/dist/worker/index.d.ts.map +1 -1
- package/dist/worker/index.js +4 -2
- package/dist/worker/index.js.map +1 -1
- package/package.json +6 -4
- package/src/better-auth/auth/server.ts +8 -4
- package/src/better-auth/auth/tests/server.test.ts +2 -2
- package/src/inspector/index.tsx +1 -1
- package/src/inspector/ui/button.tsx +15 -1
- package/src/inspector/ui/heading.tsx +7 -2
- package/src/inspector/ui/input.tsx +6 -2
- package/src/inspector/ui/modal.tsx +158 -0
- package/src/inspector/viewer/delete-local-data.tsx +101 -0
- package/src/inspector/viewer/new-app.tsx +3 -1
- package/src/react/hooks.tsx +1 -0
- package/src/react/index.ts +1 -0
- package/src/react-core/hooks.ts +162 -0
- package/src/react-core/tests/useCoStateWithSelector.test.ts +149 -0
- package/src/react-native-core/hooks.tsx +1 -0
- package/src/tools/coValues/CoFieldInit.ts +5 -5
- package/src/tools/coValues/CoValueBase.ts +32 -0
- package/src/tools/coValues/coList.ts +35 -0
- package/src/tools/coValues/coMap.ts +0 -18
- package/src/tools/implementation/createContext.ts +9 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +22 -8
- package/src/tools/tests/coList.test.ts +41 -0
- package/src/tools/tests/coMap.test.ts +37 -0
- package/src/tools/tests/coPlainText.test.ts +24 -0
- package/src/tools/tests/createContext.test.ts +24 -0
- package/src/tools/tests/deepLoading.test.ts +2 -0
- package/src/tools/tests/patterns/requestToJoin.test.ts +14 -6
- package/src/tools/tests/utils.ts +1 -0
- package/src/worker/index.ts +6 -0
- package/dist/chunk-45VKEOXG.js.map +0 -1
- package/dist/inspector/custom-element-IBHKHN27.js.map +0 -1
- /package/src/inspector/viewer/{inpsector-button.tsx → inspector-button.tsx} +0 -0
package/dist/react-core/index.js
CHANGED
@@ -5,6 +5,7 @@ import {
|
|
5
5
|
} from "./chunk-7DYMJ74I.js";
|
6
6
|
|
7
7
|
// src/react-core/hooks.ts
|
8
|
+
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
8
9
|
import React, {
|
9
10
|
useCallback,
|
10
11
|
useContext,
|
@@ -248,6 +249,32 @@ var CoValueJazzApi = class {
|
|
248
249
|
}
|
249
250
|
return new AnonymousJazzAgent2(this.localNode);
|
250
251
|
}
|
252
|
+
/**
|
253
|
+
* The timestamp of the creation time of the CoValue
|
254
|
+
*
|
255
|
+
* @category Content
|
256
|
+
*/
|
257
|
+
get createdAt() {
|
258
|
+
const createdAt = this.raw.core.verified.header.meta?.createdAt;
|
259
|
+
if (typeof createdAt === "string") {
|
260
|
+
return new Date(createdAt).getTime();
|
261
|
+
}
|
262
|
+
return this.raw.core.earliestTxMadeAt;
|
263
|
+
}
|
264
|
+
/**
|
265
|
+
* The timestamp of the last updated time of the CoValue
|
266
|
+
*
|
267
|
+
* Returns the creation time if there are no updates.
|
268
|
+
*
|
269
|
+
* @category Content
|
270
|
+
*/
|
271
|
+
get lastUpdatedAt() {
|
272
|
+
const value = this.raw.core.latestTxMadeAt;
|
273
|
+
if (value === 0) {
|
274
|
+
return this.createdAt;
|
275
|
+
}
|
276
|
+
return value;
|
277
|
+
}
|
251
278
|
};
|
252
279
|
|
253
280
|
// src/tools/implementation/inspect.ts
|
@@ -765,22 +792,6 @@ var CoMapJazzApi = class extends CoValueJazzApi {
|
|
765
792
|
get raw() {
|
766
793
|
return this.getRaw();
|
767
794
|
}
|
768
|
-
/**
|
769
|
-
* The timestamp of the creation time of the CoMap
|
770
|
-
*
|
771
|
-
* @category Content
|
772
|
-
*/
|
773
|
-
get createdAt() {
|
774
|
-
return this.raw.earliestTxMadeAt ?? Number.MAX_SAFE_INTEGER;
|
775
|
-
}
|
776
|
-
/**
|
777
|
-
* The timestamp of the last updated time of the CoMap
|
778
|
-
*
|
779
|
-
* @category Content
|
780
|
-
*/
|
781
|
-
get lastUpdatedAt() {
|
782
|
-
return this.raw.latestTxMadeAt;
|
783
|
-
}
|
784
795
|
/** @internal */
|
785
796
|
get schema() {
|
786
797
|
return this.coMap.constructor._schema;
|
@@ -1523,6 +1534,39 @@ var CoListProxyHandler = {
|
|
1523
1534
|
} else {
|
1524
1535
|
return Reflect.has(target, key);
|
1525
1536
|
}
|
1537
|
+
},
|
1538
|
+
ownKeys(target) {
|
1539
|
+
const keys = Reflect.ownKeys(target);
|
1540
|
+
const indexKeys = target.$jazz.raw.entries().map((_entry, i) => String(i));
|
1541
|
+
keys.push(...indexKeys);
|
1542
|
+
return keys;
|
1543
|
+
},
|
1544
|
+
getOwnPropertyDescriptor(target, key) {
|
1545
|
+
if (key === TypeSym) {
|
1546
|
+
return {
|
1547
|
+
enumerable: false,
|
1548
|
+
configurable: true,
|
1549
|
+
writable: false,
|
1550
|
+
value: target[TypeSym]
|
1551
|
+
};
|
1552
|
+
} else if (key in target) {
|
1553
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
1554
|
+
} else if (typeof key === "string" && !isNaN(+key)) {
|
1555
|
+
const index = Number(key);
|
1556
|
+
if (index >= 0 && index < target.$jazz.raw.entries().length) {
|
1557
|
+
return {
|
1558
|
+
enumerable: true,
|
1559
|
+
configurable: true,
|
1560
|
+
writable: true
|
1561
|
+
};
|
1562
|
+
}
|
1563
|
+
} else if (key === "length") {
|
1564
|
+
return {
|
1565
|
+
enumerable: false,
|
1566
|
+
configurable: false,
|
1567
|
+
writable: false
|
1568
|
+
};
|
1569
|
+
}
|
1526
1570
|
}
|
1527
1571
|
};
|
1528
1572
|
|
@@ -4228,9 +4272,13 @@ function enrichCoMapSchema(schema, coValueClass) {
|
|
4228
4272
|
}
|
4229
4273
|
return coMapDefiner(pickedShape);
|
4230
4274
|
},
|
4231
|
-
partial: () => {
|
4275
|
+
partial: (keys) => {
|
4232
4276
|
const partialShape = {};
|
4233
4277
|
for (const [key, value] of Object.entries(coValueSchema.shape)) {
|
4278
|
+
if (keys && !keys[key]) {
|
4279
|
+
partialShape[key] = value;
|
4280
|
+
continue;
|
4281
|
+
}
|
4234
4282
|
if (isAnyCoValueSchema(value)) {
|
4235
4283
|
partialShape[key] = coOptionalDefiner(value);
|
4236
4284
|
} else {
|
@@ -4860,6 +4908,25 @@ function useCoState(Schema4, id, options) {
|
|
4860
4908
|
);
|
4861
4909
|
return value;
|
4862
4910
|
}
|
4911
|
+
function useCoStateWithSelector(Schema4, id, options) {
|
4912
|
+
const subscription = useCoValueSubscription(Schema4, id, options);
|
4913
|
+
return useSyncExternalStoreWithSelector(
|
4914
|
+
React.useCallback(
|
4915
|
+
(callback) => {
|
4916
|
+
if (!subscription) {
|
4917
|
+
return () => {
|
4918
|
+
};
|
4919
|
+
}
|
4920
|
+
return subscription.subscribe(callback);
|
4921
|
+
},
|
4922
|
+
[subscription]
|
4923
|
+
),
|
4924
|
+
() => subscription ? subscription.getCurrentValue() : null,
|
4925
|
+
() => subscription ? subscription.getCurrentValue() : null,
|
4926
|
+
options.select,
|
4927
|
+
options.equalityFn ?? Object.is
|
4928
|
+
);
|
4929
|
+
}
|
4863
4930
|
function useAccountSubscription(Schema4, options) {
|
4864
4931
|
const contextManager = useJazzContextManager();
|
4865
4932
|
const createSubscription = () => {
|
@@ -5029,6 +5096,7 @@ export {
|
|
5029
5096
|
useAccount,
|
5030
5097
|
useAuthSecretStorage,
|
5031
5098
|
useCoState,
|
5099
|
+
useCoStateWithSelector,
|
5032
5100
|
useDemoAuth,
|
5033
5101
|
useIsAuthenticated,
|
5034
5102
|
useJazzContext,
|