@sqlrooms/crdt 0.27.0-rc.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.
@@ -0,0 +1,28 @@
1
+ import { SchemaType, InferType } from 'loro-mirror';
2
+ import { StateCreator } from 'zustand';
3
+ export type StoreSet<S> = Parameters<StateCreator<S>>[0];
4
+ export type StoreGet<S> = Parameters<StateCreator<S>>[1];
5
+ export type MirrorSchema<T extends SchemaType = SchemaType> = T;
6
+ /**
7
+ * `loro-mirror` injects internal `$cid` metadata into mirrored map objects.
8
+ *
9
+ * Store state typically doesn't include `$cid`, so binding `select()` functions
10
+ * naturally return the same shape *minus* `$cid`. This helper strips `$cid`
11
+ * recursively so `select()` can be type-safe without forcing `any` casts.
12
+ */
13
+ export type StripCidDeep<T> = T extends (infer U)[] ? StripCidDeep<U>[] : T extends Record<string, any> ? T extends {
14
+ $cid: any;
15
+ } ? Omit<{
16
+ [K in keyof T]: StripCidDeep<T[K]>;
17
+ }, '$cid'> : {
18
+ [K in keyof T]: StripCidDeep<T[K]>;
19
+ } : T;
20
+ export type InferredState<TSchema extends SchemaType> = InferType<TSchema> extends Record<string, any> ? InferType<TSchema> : Record<string, never>;
21
+ /**
22
+ * Local equivalent of `createSlice` from `@sqlrooms/room-store`.
23
+ *
24
+ * Kept inline so `@sqlrooms/crdt` stays dependency-light (no need to depend on
25
+ * `@sqlrooms/room-store` just for a typing helper).
26
+ */
27
+ export declare function createSlice<SliceState, StoreState extends SliceState = SliceState>(sliceCreator: (...args: Parameters<StateCreator<StoreState>>) => SliceState): StateCreator<SliceState>;
28
+ //# sourceMappingURL=type-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-helpers.d.ts","sourceRoot":"","sources":["../src/type-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAClD,OAAO,EAAC,YAAY,EAAW,MAAM,SAAS,CAAC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* Local equivalent of `createSlice` from `@sqlrooms/room-store`.
3
+ *
4
+ * Kept inline so `@sqlrooms/crdt` stays dependency-light (no need to depend on
5
+ * `@sqlrooms/room-store` just for a typing helper).
6
+ */
7
+ export function createSlice(sliceCreator) {
8
+ return (set, get, store) => sliceCreator(set, get, store);
9
+ }
10
+ //# sourceMappingURL=type-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-helpers.js","sourceRoot":"","sources":["../src/type-helpers.ts"],"names":[],"mappings":"AA4BA;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAIzB,YAA2E;IAE3E,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CACzB,YAAY,CAAC,GAAG,EAAE,GAAuB,EAAE,KAA6B,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import {SchemaType, InferType} from 'loro-mirror';\nimport {StateCreator, StoreApi} from 'zustand';\n\nexport type StoreSet<S> = Parameters<StateCreator<S>>[0];\nexport type StoreGet<S> = Parameters<StateCreator<S>>[1];\n\nexport type MirrorSchema<T extends SchemaType = SchemaType> = T;\n\n/**\n * `loro-mirror` injects internal `$cid` metadata into mirrored map objects.\n *\n * Store state typically doesn't include `$cid`, so binding `select()` functions\n * naturally return the same shape *minus* `$cid`. This helper strips `$cid`\n * recursively so `select()` can be type-safe without forcing `any` casts.\n */\nexport type StripCidDeep<T> = T extends (infer U)[]\n ? StripCidDeep<U>[]\n : T extends Record<string, any>\n ? T extends {$cid: any}\n ? Omit<{[K in keyof T]: StripCidDeep<T[K]>}, '$cid'>\n : {[K in keyof T]: StripCidDeep<T[K]>}\n : T;\n\nexport type InferredState<TSchema extends SchemaType> =\n InferType<TSchema> extends Record<string, any>\n ? InferType<TSchema>\n : Record<string, never>;\n\n/**\n * Local equivalent of `createSlice` from `@sqlrooms/room-store`.\n *\n * Kept inline so `@sqlrooms/crdt` stays dependency-light (no need to depend on\n * `@sqlrooms/room-store` just for a typing helper).\n */\nexport function createSlice<\n SliceState,\n StoreState extends SliceState = SliceState,\n>(\n sliceCreator: (...args: Parameters<StateCreator<StoreState>>) => SliceState,\n): StateCreator<SliceState> {\n return (set, get, store) =>\n sliceCreator(set, get as () => StoreState, store as StoreApi<StoreState>);\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@sqlrooms/crdt",
3
+ "version": "0.27.0-rc.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "module": "dist/index.js",
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "author": "SQLRooms Contributors",
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/sqlrooms/sqlrooms.git"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "dependencies": {
22
+ "immer": "^11.0.1",
23
+ "loro-crdt": "^1.10.3",
24
+ "loro-mirror": "^1.1.2",
25
+ "zustand": "^5.0.8"
26
+ },
27
+ "devDependencies": {
28
+ "@jest/globals": "^30.2.0",
29
+ "@types/jest": "^30.0.0",
30
+ "jest": "^30.1.3",
31
+ "ts-jest": "^29.4.4"
32
+ },
33
+ "peerDependencies": {
34
+ "react": ">=18"
35
+ },
36
+ "scripts": {
37
+ "dev": "tsc -w",
38
+ "build": "tsc",
39
+ "lint": "eslint .",
40
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
41
+ "typecheck": "tsc --noEmit",
42
+ "typedoc": "typedoc"
43
+ },
44
+ "gitHead": "ceafff23c197b8188040f8c93baf4e7d3dd4b081"
45
+ }