Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Add crdt as a separate package

Hakan Shehu3042625e34f8
diff --git a/apps/desktop/electron.vite.config.ts b/apps/desktop/electron.vite.config.ts
index b7d593fa..4b2581b6 100644
--- a/apps/desktop/electron.vite.config.ts
+++ b/apps/desktop/electron.vite.config.ts
@@ -6,7 +6,7 @@ export default defineConfig({
main: {
plugins: [
externalizeDepsPlugin({
- exclude: ['@colanode/core'],
+ exclude: ['@colanode/core', '@colanode/crdt'],
}),
],
resolve: {
@@ -20,7 +20,11 @@ export default defineConfig({
},
},
preload: {
- plugins: [externalizeDepsPlugin()],
+ plugins: [
+ externalizeDepsPlugin({
+ exclude: ['@colanode/core', '@colanode/crdt'],
+ }),
+ ],
resolve: {
alias: {
'@/lib': resolve('src/lib'),
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 9873c107..640e77fd 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -21,6 +21,7 @@
},
"dependencies": {
"@colanode/core": "workspace:*",
+ "@colanode/crdt": "workspace:*",
"@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0",
"@hookform/resolvers": "^3.9.0",
diff --git a/apps/desktop/src/main/node-manager.ts b/apps/desktop/src/main/node-manager.ts
index 71671464..d7c23d41 100644
--- a/apps/desktop/src/main/node-manager.ts
+++ b/apps/desktop/src/main/node-manager.ts
@@ -1,5 +1,6 @@
import * as Y from 'yjs';
-import { NodeAttributes, registry, applyCrdt } from '@colanode/core';
+import { NodeAttributes, registry } from '@colanode/core';
+import { applyCrdt } from '@colanode/crdt';
import { fromUint8Array, toUint8Array } from 'js-base64';
import {
LocalCreateNodeChangeData,
diff --git a/apps/desktop/tsconfig.json b/apps/desktop/tsconfig.json
index 316b605a..6059233f 100644
--- a/apps/desktop/tsconfig.json
+++ b/apps/desktop/tsconfig.json
@@ -2,6 +2,7 @@
"files": [],
"references": [
{ "path": "../../packages/core/tsconfig.json" },
+ { "path": "../../packages/crdt/tsconfig.json" },
{ "path": "./tsconfig.node.json" },
{ "path": "./tsconfig.web.json" }
]
diff --git a/package.json b/package.json
index 9db58a8e..be651926 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"build": "turbo run build",
"clean": "turbo run clean",
"dev": "turbo run dev",
- "watch": "turbo watch build --filter=@colanode/core --filter=@colanode/server --filter=@colanode/desktop",
+ "watch": "turbo watch build --filter=@colanode/core --filter=@colanode/crdt --filter=@colanode/server --filter=@colanode/desktop",
"lint": "turbo run lint --parallel",
"test": "turbo run test -- --watch false",
"format": "prettier --write ."
diff --git a/packages/core/package.json b/packages/core/package.json
index 85768365..c94249ce 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -24,8 +24,6 @@
"vitest": "^1.6.0"
},
"dependencies": {
- "diff": "^7.0.0",
- "yjs": "^13.6.20",
"zod": "^3.23.8"
}
}
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 2cc006a4..ba86d7eb 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -1,6 +1,3 @@
-import * as yjs from 'yjs';
-import { z as zod } from 'zod';
-import { applyCrdt } from './crdt';
import {
ChannelAttributes,
channelAttributesSchema,
@@ -160,10 +157,10 @@ import {
UserNode,
Node,
} from './registry';
+import { ZodText } from './registry/zod';
export {
- yjs,
- zod,
+ ZodText,
registry,
type ChannelAttributes,
channelAttributesSchema,
@@ -299,5 +296,4 @@ export {
type BlockLeaf,
type Block,
type Node,
- applyCrdt,
};
diff --git a/packages/crdt/package.json b/packages/crdt/package.json
new file mode 100644
index 00000000..97eea733
--- /dev/null
+++ b/packages/crdt/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "@colanode/crdt",
+ "version": "1.0.0",
+ "type": "module",
+ "types": "./src/index.ts",
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "files": [
+ "src"
+ ],
+ "scripts": {
+ "compile": "tsc --noEmit",
+ "test": "vitest",
+ "lint": "eslint . --max-warnings 0",
+ "build?": "No build step required. This package links directly to its source files",
+ "coverage": "vitest run --coverage "
+ },
+ "author": "Hakan Shehu",
+ "devDependencies": {
+ "eslint": "^8.57.1",
+ "prettier": "^3.3.3",
+ "typescript": "^5.6.3",
+ "vitest": "^1.6.0"
+ },
+ "dependencies": {
+ "@colanode/core": "workspace:*",
+ "diff": "^7.0.0",
+ "yjs": "^13.6.20",
+ "zod": "^3.23.8"
+ }
+}
diff --git a/packages/core/src/crdt.ts b/packages/crdt/src/index.ts
similarity index 99%
rename from packages/core/src/crdt.ts
rename to packages/crdt/src/index.ts
index 0bc65e63..ae6d1fe0 100644
--- a/packages/core/src/crdt.ts
+++ b/packages/crdt/src/index.ts
@@ -1,6 +1,6 @@
import { z } from 'zod';
import * as Y from 'yjs';
-import { ZodText } from './registry/zod';
+import { ZodText } from '@colanode/core';
import { isEqual } from 'lodash';
import { diffChars } from 'diff';
diff --git a/packages/crdt/tsconfig.json b/packages/crdt/tsconfig.json
new file mode 100644
index 00000000..85d3bf47
--- /dev/null
+++ b/packages/crdt/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "display": "Crdt Library",
+ "extends": "../../tsconfig.base.json",
+ "references": [
+ {
+ "path": "../core"
+ }
+ ],
+ "compilerOptions": {
+ "declaration": true,
+ "declarationMap": true,
+ "composite": true,
+ },
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b27c8286..aca1ceae 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -33,6 +33,9 @@ importers:
'@colanode/core':
specifier: workspace:*
version: link:../../packages/core
+ '@colanode/crdt':
+ specifier: workspace:*
+ version: link:../../packages/crdt
'@electron-toolkit/preload':
specifier: ^3.0.1
version: 3.0.1([email protected])
@@ -500,6 +503,28 @@ importers:
packages/core:
dependencies:
+ zod:
+ specifier: ^3.23.8
+ version: 3.23.8
+ devDependencies:
+ eslint:
+ specifier: ^8.57.1
+ version: 8.57.1
+ prettier:
+ specifier: ^3.3.3
+ version: 3.3.3
+ typescript:
+ specifier: ^5.6.3
+ version: 5.6.3
+ vitest:
+ specifier: ^1.6.0
+ version: 1.6.0(@types/[email protected])
+
+ packages/crdt:
+ dependencies:
+ '@colanode/core':
+ specifier: workspace:*
+ version: link:../core
diff:
specifier: ^7.0.0
version: 7.0.0
@@ -7299,7 +7324,7 @@ snapshots:
'@babel/traverse': 7.25.9
'@babel/types': 7.26.0
convert-source-map: 2.0.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
gensync: 1.0.0-beta.2
json5: 2.2.3
semver: 6.3.1
@@ -7387,7 +7412,7 @@ snapshots:
'@babel/parser': 7.26.2
'@babel/template': 7.25.9
'@babel/types': 7.26.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
globals: 11.12.0
transitivePeerDependencies:
- supports-color
@@ -7413,7 +7438,7 @@ snapshots:
'@electron/get': 3.1.0
chalk: 4.1.2
commander: 4.1.1
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 10.1.0
listr2: 7.0.2
semver: 7.6.3
@@ -7428,7 +7453,7 @@ snapshots:
'@electron/rebuild': 3.7.0
'@malept/cross-spawn-promise': 2.0.0
chalk: 4.1.2
- debug: 4.3.7
+ debug: 4.3.7([email protected])
find-up: 5.0.0
fs-extra: 10.1.0
log-symbols: 4.1.0
@@ -7456,7 +7481,7 @@ snapshots:
'@electron/rebuild': 3.7.0
'@malept/cross-spawn-promise': 2.0.0
chalk: 4.1.2
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fast-glob: 3.3.2
filenamify: 4.3.0
find-up: 5.0.0
@@ -7562,7 +7587,7 @@ snapshots:
'@electron-forge/shared-types': 7.5.0
'@electron-forge/web-multi-logger': 7.5.0
chalk: 4.1.2
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 10.1.0
listr2: 7.0.2
transitivePeerDependencies:
@@ -7592,7 +7617,7 @@ snapshots:
dependencies:
'@electron-forge/shared-types': 7.5.0
'@malept/cross-spawn-promise': 2.0.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 10.1.0
username: 5.1.0
transitivePeerDependencies:
@@ -7696,7 +7721,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
env-paths: 2.2.1
fs-extra: 8.1.0
got: 11.8.6
@@ -7710,7 +7735,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
env-paths: 2.2.1
fs-extra: 8.1.0
got: 11.8.6
@@ -7740,7 +7765,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 9.1.0
promise-retry: 2.0.1
transitivePeerDependencies:
@@ -7749,7 +7774,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
compare-version: 0.1.2
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 10.1.0
isbinaryfile: 4.0.10
minimist: 1.2.8
@@ -7765,7 +7790,7 @@ snapshots:
'@electron/osx-sign': 1.0.5
'@electron/universal': 2.0.1
'@electron/windows-sign': 1.1.3
- debug: 4.3.7
+ debug: 4.3.7([email protected])
extract-zip: 2.0.1
filenamify: 4.3.0
fs-extra: 11.2.0
@@ -7786,7 +7811,7 @@ snapshots:
'@electron/node-gyp': https://codeload.github.com/electron/node-gyp/tar.gz/06b29aafb7708acef8b3669835c8a7857ebc92d2
'@malept/cross-spawn-promise': 2.0.0
chalk: 4.1.2
- debug: 4.3.7
+ debug: 4.3.7([email protected])
detect-libc: 2.0.3
fs-extra: 10.1.0
got: 11.8.6
@@ -7805,7 +7830,7 @@ snapshots:
dependencies:
'@electron/asar': 3.2.16
'@malept/cross-spawn-promise': 1.1.1
- debug: 4.3.7
+ debug: 4.3.7([email protected])
dir-compare: 3.3.0
fs-extra: 9.1.0
minimatch: 3.1.2
@@ -7817,7 +7842,7 @@ snapshots:
dependencies:
'@electron/asar': 3.2.16
'@malept/cross-spawn-promise': 2.0.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
dir-compare: 4.2.0
fs-extra: 11.2.0
minimatch: 9.0.5
@@ -7828,7 +7853,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
cross-dirname: 0.1.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 11.2.0
minimist: 1.2.8
postject: 1.0.0-alpha.6
@@ -7991,7 +8016,7 @@ snapshots:
'@eslint/[email protected]':
dependencies:
ajv: 6.12.6
- debug: 4.3.7
+ debug: 4.3.7([email protected])
espree: 9.6.1
globals: 13.24.0
ignore: 5.3.2
@@ -8030,7 +8055,7 @@ snapshots:
'@humanwhocodes/[email protected]':
dependencies:
'@humanwhocodes/object-schema': 2.0.3
- debug: 4.3.7
+ debug: 4.3.7([email protected])
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
@@ -8161,7 +8186,7 @@ snapshots:
'@malept/[email protected]':
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 9.1.0
lodash: 4.17.21
tmp-promise: 3.0.3
@@ -9535,7 +9560,7 @@ snapshots:
'@typescript-eslint/scope-manager': 5.62.0
'@typescript-eslint/type-utils': 5.62.0([email protected])([email protected])
'@typescript-eslint/utils': 5.62.0([email protected])([email protected])
- debug: 4.3.7
+ debug: 4.3.7([email protected])
eslint: 8.57.1
graphemer: 1.4.0
ignore: 5.3.2
@@ -9570,7 +9595,7 @@ snapshots:
'@typescript-eslint/scope-manager': 5.62.0
'@typescript-eslint/types': 5.62.0
'@typescript-eslint/typescript-estree': 5.62.0([email protected])
- debug: 4.3.7
+ debug: 4.3.7([email protected])
eslint: 8.57.1
optionalDependencies:
typescript: 5.6.3
@@ -9583,7 +9608,7 @@ snapshots:
'@typescript-eslint/types': 7.18.0
'@typescript-eslint/typescript-estree': 7.18.0([email protected])
'@typescript-eslint/visitor-keys': 7.18.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
eslint: 8.57.1
optionalDependencies:
typescript: 5.6.3
@@ -9604,7 +9629,7 @@ snapshots:
dependencies:
'@typescript-eslint/typescript-estree': 5.62.0([email protected])
'@typescript-eslint/utils': 5.62.0([email protected])([email protected])
- debug: 4.3.7
+ debug: 4.3.7([email protected])
eslint: 8.57.1
tsutils: 3.21.0([email protected])
optionalDependencies:
@@ -9616,7 +9641,7 @@ snapshots:
dependencies:
'@typescript-eslint/typescript-estree': 7.18.0([email protected])
'@typescript-eslint/utils': 7.18.0([email protected])([email protected])
- debug: 4.3.7
+ debug: 4.3.7([email protected])
eslint: 8.57.1
ts-api-utils: 1.4.0([email protected])
optionalDependencies:
@@ -9632,7 +9657,7 @@ snapshots:
dependencies:
'@typescript-eslint/types': 5.62.0
'@typescript-eslint/visitor-keys': 5.62.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
globby: 11.1.0
is-glob: 4.0.3
semver: 7.6.3
@@ -9646,7 +9671,7 @@ snapshots:
dependencies:
'@typescript-eslint/types': 7.18.0
'@typescript-eslint/visitor-keys': 7.18.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
globby: 11.1.0
is-glob: 4.0.3
minimatch: 9.0.5
@@ -9756,7 +9781,7 @@ snapshots:
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
transitivePeerDependencies:
- supports-color
@@ -9818,7 +9843,7 @@ snapshots:
builder-util: 24.13.1
builder-util-runtime: 9.2.4
chromium-pickle-js: 0.2.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
dmg-builder: 24.13.3([email protected])
ejs: 3.1.10
electron-builder-squirrel-windows: 24.13.3([email protected])
@@ -10103,14 +10128,14 @@ snapshots:
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
sax: 1.4.1
transitivePeerDependencies:
- supports-color
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
sax: 1.4.1
transitivePeerDependencies:
- supports-color
@@ -10124,7 +10149,7 @@ snapshots:
builder-util-runtime: 9.2.4
chalk: 4.1.2
cross-spawn: 7.0.3
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 10.1.0
http-proxy-agent: 5.0.0
https-proxy-agent: 5.0.1
@@ -10470,10 +10495,6 @@ snapshots:
dependencies:
ms: 2.1.3
- dependencies:
- ms: 2.1.3
-
dependencies:
ms: 2.1.3
@@ -10642,7 +10663,7 @@ snapshots:
dependencies:
'@malept/cross-spawn-promise': 1.1.1
asar: 3.2.0
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 9.1.0
glob: 7.2.3
lodash: 4.17.21
@@ -10658,7 +10679,7 @@ snapshots:
dependencies:
'@malept/cross-spawn-promise': 1.1.1
- debug: 4.3.7
+ debug: 4.3.7([email protected])
electron-installer-common: 0.10.3
fs-extra: 9.1.0
get-folder-size: 2.0.1
@@ -10672,7 +10693,7 @@ snapshots:
dependencies:
'@malept/cross-spawn-promise': 1.1.1
- debug: 4.3.7
+ debug: 4.3.7([email protected])
electron-installer-common: 0.10.3
fs-extra: 9.1.0
lodash: 4.17.21
@@ -10724,7 +10745,7 @@ snapshots:
dependencies:
'@electron/asar': 3.2.16
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 7.0.1
lodash: 4.17.21
temp: 0.9.4
@@ -11033,7 +11054,7 @@ snapshots:
ajv: 6.12.6
chalk: 4.1.2
cross-spawn: 7.0.3
- debug: 4.3.7
+ debug: 4.3.7([email protected])
doctrine: 3.0.0
escape-string-regexp: 4.0.0
eslint-scope: 7.2.2
@@ -11167,7 +11188,7 @@ snapshots:
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
get-stream: 5.2.0
yauzl: 2.10.0
optionalDependencies:
@@ -11268,7 +11289,7 @@ snapshots:
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
fs-extra: 10.1.0
transitivePeerDependencies:
- supports-color
@@ -11354,7 +11375,7 @@ snapshots:
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
flora-colossus: 2.0.0
fs-extra: 10.1.0
transitivePeerDependencies:
@@ -11584,7 +11605,7 @@ snapshots:
dependencies:
'@tootallnate/once': 2.0.0
agent-base: 6.0.2
- debug: 4.3.7
+ debug: 4.3.7([email protected])
transitivePeerDependencies:
- supports-color
@@ -11596,7 +11617,7 @@ snapshots:
dependencies:
agent-base: 6.0.2
- debug: 4.3.7
+ debug: 4.3.7([email protected])
transitivePeerDependencies:
- supports-color
@@ -12946,7 +12967,7 @@ snapshots:
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
transitivePeerDependencies:
- supports-color
@@ -13320,7 +13341,7 @@ snapshots:
dependencies:
agent-base: 6.0.2
- debug: 4.3.7
+ debug: 4.3.7([email protected])
socks: 2.8.3
transitivePeerDependencies:
- supports-color
@@ -13478,7 +13499,7 @@ snapshots:
dependencies:
- debug: 4.3.7
+ debug: 4.3.7([email protected])
transitivePeerDependencies:
- supports-color