diff --git a/package.json b/package.json index 9ffa8d5..3f6231b 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ } }, "lint-staged": { - "*.{js,jsx,ts,tsx,json,babelrc}": [ + "*.{js,jsx,ts,tsx,babelrc}": [ "yarn run format", "git add" ] diff --git a/packages/backend/package.json b/packages/backend/package.json index b559b56..061790d 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -1,6 +1,6 @@ { "name": "@slate-collaborative/backend", - "version": "0.0.1", + "version": "0.0.2", "files": [ "lib" ], @@ -25,7 +25,7 @@ "watch": "yarn build:js -w" }, "dependencies": { - "@slate-collaborative/bridge": "^0.0.1", + "@slate-collaborative/bridge": "^0.0.2", "automerge": "^0.12.1", "lodash": "^4.17.15", "socket.io": "^2.2.0", diff --git a/packages/bridge/.babelrc b/packages/bridge/.babelrc index a2309a2..89aef8b 100644 --- a/packages/bridge/.babelrc +++ b/packages/bridge/.babelrc @@ -1,5 +1,15 @@ { - "presets": ["@babel/env", "@babel/typescript"], + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "esmodules": false + } + } + ], + "@babel/typescript" + ], "plugins": [ "@babel/proposal-class-properties", "@babel/proposal-object-rest-spread" diff --git a/packages/bridge/package.json b/packages/bridge/package.json index 7e412f1..9f6eaf7 100644 --- a/packages/bridge/package.json +++ b/packages/bridge/package.json @@ -1,6 +1,6 @@ { "name": "@slate-collaborative/bridge", - "version": "0.0.1", + "version": "0.0.2", "files": [ "lib" ], diff --git a/packages/bridge/src/apply/index.ts b/packages/bridge/src/apply/index.ts index 2679830..b4ea794 100644 --- a/packages/bridge/src/apply/index.ts +++ b/packages/bridge/src/apply/index.ts @@ -17,7 +17,7 @@ const opType: any = { // set_value: setValue } -export const applyOperation = (doc: SyncDoc, op: Operation): SyncDoc => { +const applyOperation = (doc: SyncDoc, op: Operation): SyncDoc => { try { const applyOp = opType[op.type] @@ -34,5 +34,7 @@ export const applyOperation = (doc: SyncDoc, op: Operation): SyncDoc => { } } -export const applySlateOps = (doc: SyncDoc, operations: Operations) => +const applySlateOps = (doc: SyncDoc, operations: Operations) => operations.reduce(applyOperation, doc) + +export { applyOperation, applySlateOps } diff --git a/packages/bridge/src/utils/index.ts b/packages/bridge/src/utils/index.ts index 3029458..f2e6e69 100644 --- a/packages/bridge/src/utils/index.ts +++ b/packages/bridge/src/utils/index.ts @@ -1,7 +1,7 @@ import toSync from './toSync' import hexGen from './hexGen' -export const toJS = node => { +const toJS = node => { try { return JSON.parse(JSON.stringify(node)) } catch (e) { @@ -10,8 +10,8 @@ export const toJS = node => { } } -export const cloneNode = node => toSync(toJS(node)) +const cloneNode = node => toSync(toJS(node)) const toSlatePath = path => (path ? path.filter(d => Number.isInteger(d)) : []) -export { toSync, toSlatePath, hexGen } +export { toSync, toJS, toSlatePath, hexGen, cloneNode } diff --git a/packages/client/package.json b/packages/client/package.json index 6682be4..78081c1 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@slate-collaborative/client", - "version": "0.0.1", + "version": "0.0.2", "files": [ "lib" ], @@ -25,7 +25,7 @@ }, "dependencies": { "@babel/preset-react": "^7.0.0", - "@slate-collaborative/bridge": "^0.0.1", + "@slate-collaborative/bridge": "^0.0.2", "automerge": "^0.12.1", "immutable": "^4.0.0-rc.12", "react": "^16.9.0", diff --git a/packages/example/package.json b/packages/example/package.json index 5a05cd2..ff8b3b3 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -5,8 +5,8 @@ "dependencies": { "@emotion/core": "^10.0.17", "@emotion/styled": "^10.0.17", - "@slate-collaborative/backend": "0.0.1", - "@slate-collaborative/client": "0.0.1", + "@slate-collaborative/backend": "0.0.2", + "@slate-collaborative/client": "0.0.2", "@types/faker": "^4.1.5", "@types/jest": "24.0.18", "@types/node": "12.7.5", diff --git a/packages/example/tsconfig.json b/packages/example/tsconfig.json index 3821f08..7f81348 100644 --- a/packages/example/tsconfig.json +++ b/packages/example/tsconfig.json @@ -1,9 +1,15 @@ { - "include": ["src/**/*"], + "include": [ + "src/**/*" + ], "extends": "../../tsconfig.base.json", "compilerOptions": { "target": "es5", - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "baseUrl": "src", "jsx": "react", "allowJs": true,