diff --git a/bin/utils.js b/bin/utils.js index 6152b10..3bd9575 100644 --- a/bin/utils.js +++ b/bin/utils.js @@ -2,10 +2,10 @@ const Y = require('yjs') const syncProtocol = require('y-protocols/dist/sync.js') const awarenessProtocol = require('y-protocols/dist/awareness.js') -const encoding = require('lib0/dist/encoding.js') -const decoding = require('lib0/dist/decoding.js') -const mutex = require('lib0/dist/mutex.js') -const map = require('lib0/dist/map.js') +const encoding = require('lib0/dist/encoding.cjs') +const decoding = require('lib0/dist/decoding.cjs') +const mutex = require('lib0/dist/mutex.cjs') +const map = require('lib0/dist/map.cjs') const wsReadyStateConnecting = 0 const wsReadyStateOpen = 1 @@ -16,7 +16,7 @@ const wsReadyStateClosed = 3 // eslint-disable-line const gcEnabled = process.env.GC !== 'false' && process.env.GC !== '0' const persistenceDir = process.env.YPERSISTENCE /** - * @type {{bindState: function(string,WSSharedDoc):void, writeState:function(string,WSSharedDoc):Promise}|null} + * @type {{bindState: function(string,WSSharedDoc):void, writeState:function(string,WSSharedDoc):Promise}|null} */ let persistence = null if (typeof persistenceDir === 'string') { @@ -27,7 +27,7 @@ if (typeof persistenceDir === 'string') { /** * @param {{bindState: function(string,WSSharedDoc):void, - * writeState:function(string,WSSharedDoc):Promise}|null} persistence_ + * writeState:function(string,WSSharedDoc):Promise}|null} persistence_ */ exports.setPersistence = persistence_ => { persistence = persistence_ diff --git a/package-lock.json b/package-lock.json index f685743..d3a98f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,15 +5,15 @@ "requires": true, "dependencies": { "@types/estree": { - "version": "0.0.39", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", - "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "version": "0.0.42", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.42.tgz", + "integrity": "sha512-K1DPVvnBCPxzD+G51/cxVIoc2X8uUVl1zpJeE6iKcgHMj4+tbat5Xu4TjV7v2QSDbIeAfLi2hIk+u2+s0MlpUQ==", "dev": true }, "@types/node": { - "version": "11.13.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.7.tgz", - "integrity": "sha512-suFHr6hcA9mp8vFrZTgrmqW2ZU3mbWsryQtQlY/QvwTISCw7nw/j+bCQPPohqmskhmqa5wLNuMHTTsc+xf1MQg==", + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.6.tgz", + "integrity": "sha512-Jg1F+bmxcpENHP23sVKkNuU3uaxPnsBMW0cLjleiikFKomJQbsn0Cqk2yDvQArqzZN6ABfBkZ0To7pQ8sLdWDg==", "dev": true }, "acorn": { @@ -917,6 +917,11 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "isomorphic.js": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.1.0.tgz", + "integrity": "sha512-qoOHpuSbJ56TlPR+vi0xRxdhNBbh/xFbgjB2d+ysekcM5iSh9jzxHURnACQxy0Sb9SnZhxxo9EyN+XbGcQhkAg==" + }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", @@ -971,9 +976,12 @@ } }, "lib0": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.1.1.tgz", - "integrity": "sha512-ghjoI4xL/xzVR1fRLYEOnJjYMguoI2dnDUf5HYOpTfD6R5GPKLml6xNKl4ZfBVmczkIOQPNthhukp6nlgbmDLw==" + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.3.tgz", + "integrity": "sha512-J1Gw9PT78tO3QODgvzk9NVTXTXTsru9LKq+iPOdWw5s1/QiapUKmCJMCWBrNSGkJ0f3WQkZJtGzn3azJwMDdeg==", + "requires": { + "isomorphic.js": "^0.1.0" + } }, "load-json-file": { "version": "2.0.0", @@ -1379,14 +1387,22 @@ } }, "rollup": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.10.1.tgz", - "integrity": "sha512-pW353tmBE7QP622ITkGxtqF0d5gSRCVPD9xqM+fcPjudeZfoXMFW2sCzsTe2TU/zU1xamIjiS9xuFCPVT9fESw==", + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.29.0.tgz", + "integrity": "sha512-V63Iz0dSdI5qPPN5HmCN6OBRzBFhMqNWcvwgq863JtSCTU6Vdvqq6S2fYle/dSCyoPrBkIP3EIr1RVs3HTRqqg==", "dev": true, "requires": { - "@types/estree": "0.0.39", - "@types/node": "^11.13.5", - "acorn": "^6.1.1" + "@types/estree": "*", + "@types/node": "*", + "acorn": "^7.1.0" + }, + "dependencies": { + "acorn": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", + "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "dev": true + } } }, "rollup-cli": { @@ -1631,6 +1647,12 @@ "prelude-ls": "~1.1.2" } }, + "typescript": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.4.tgz", + "integrity": "sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==", + "dev": true + }, "uniq": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", @@ -1702,20 +1724,41 @@ "dev": true }, "y-protocols": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-0.1.0.tgz", - "integrity": "sha512-CQCCcexfTNI7wyvVlaTuOOuaWxuD4SkmZbwyIZVGKglAuC+ruivLmbB14b1oN1CdMPhlUkKsz6524o5sWdKNnA==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-0.2.0.tgz", + "integrity": "sha512-B9MCxMqLZCziLmQFlrXVN7MbIhXzF9bdwePcHzlVFIEHxnEvYIqAQYj4FHS376LBgfcjTUs7T614D+w0bpcJLA==", "requires": { - "lib0": "^0.1.0" + "lib0": "^0.2.3" + }, + "dependencies": { + "lib0": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.3.tgz", + "integrity": "sha512-J1Gw9PT78tO3QODgvzk9NVTXTXTsru9LKq+iPOdWw5s1/QiapUKmCJMCWBrNSGkJ0f3WQkZJtGzn3azJwMDdeg==", + "requires": { + "isomorphic.js": "^0.1.0" + } + } } }, "yjs": { - "version": "13.0.0-98", - "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.0.0-98.tgz", - "integrity": "sha512-/NX8tDDx2ZFbwnb6E6iFyqMRixSmJcXA95Tiytt/itZsXt33m1udUl8zEpWGnfAR7T+Cj26mF+bLo9cInBKqpg==", + "version": "13.0.0-105", + "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.0.0-105.tgz", + "integrity": "sha512-nsTm0LVMsOVKpRYXrJHqu9g+ISphBoEnqropblkTUFBbv0TyYVbq11CqN846ip0RC9Nq1Kh8kZ+QHUL1CHnuyA==", "dev": true, "requires": { - "lib0": "^0.1.1" + "lib0": "^0.2.2" + }, + "dependencies": { + "lib0": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.3.tgz", + "integrity": "sha512-J1Gw9PT78tO3QODgvzk9NVTXTXTsru9LKq+iPOdWw5s1/QiapUKmCJMCWBrNSGkJ0f3WQkZJtGzn3azJwMDdeg==", + "dev": true, + "requires": { + "isomorphic.js": "^0.1.0" + } + } } } } diff --git a/package.json b/package.json index d0992f5..694503c 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,14 @@ "name": "y-websocket", "version": "1.0.7", "description": "Websockets provider for Yjs", - "main": "./dist/y-websocket.js", + "main": "./dist/y-websocket.cjs", "module": "./src/y-websocket.js", "sideEffects": false, "scripts": { "start": "node ./bin/server.js", "dist": "rm -rf dist && rollup -c", - "test": "echo 'should lint here'", - "lint": "standard", - "preversion": "npm run lint && npm run test && npm run dist" + "lint": "standard && tsc", + "preversion": "npm run lint && npm run dist" }, "bin": { "y-websocket-server": "./bin/server.js" @@ -40,14 +39,15 @@ ] }, "dependencies": { - "y-protocols": "^0.1.0", - "lib0": "^0.1.1" + "lib0": "^0.2.3", + "y-protocols": "^0.2.0" }, "devDependencies": { - "rollup": "^1.1.2", + "rollup": "^1.29.0", "rollup-cli": "^1.0.9", "standard": "^12.0.1", - "yjs": "13.0.0-98" + "typescript": "^3.7.4", + "yjs": "13.0.0-105" }, "peerDependenies": { "yjs": ">=13.0.0-98" diff --git a/rollup.config.js b/rollup.config.js index 0babef6..3adbcfc 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -3,14 +3,14 @@ export default { external: id => /^(lib0|yjs|y-protocols)/.test(id), output: [{ name: 'y-websocket', - file: 'dist/y-websocket.js', + file: 'dist/y-websocket.cjs', format: 'cjs', sourcemap: true, paths: path => { if (/^lib0\//.test(path)) { - return `lib0/dist${path.slice(4)}` + return `lib0/dist${path.slice(4, -3)}.cjs` } else if (/^y-protocols\//.test(path)) { - return `y-protocols/dist${path.slice(11)}` + return `y-protocols/dist${path.slice(11, -3)}.cjs` } return path } diff --git a/src/y-websocket.js b/src/y-websocket.js index 0a635ef..b63a9e2 100644 --- a/src/y-websocket.js +++ b/src/y-websocket.js @@ -62,7 +62,7 @@ const readMessage = (provider, buf, emitSynced) => { awarenessProtocol.applyAwarenessUpdate(provider.awareness, decoding.readVarUint8Array(decoder), provider) break case messageAuth: - authProtocol.readAuthMessage(decoder, provider, permissionDeniedHandler) + authProtocol.readAuthMessage(decoder, provider.doc, permissionDeniedHandler) break default: console.error('Unable to compute message') diff --git a/tsconfig.json b/tsconfig.json index 7682d2d..5118228 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,7 @@ /* Strict Type-Checking Options */ "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ @@ -40,6 +40,7 @@ "paths": { "yjs": ["node_modules/yjs/src/index.js"], "lib0/*": ["node_modules/lib0/*"], + "lib0/dist/*": ["node_modules/lib0/dist/*"], "y-protocols/*": ["node_modules/y-protocols/*"] }, // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ @@ -59,5 +60,6 @@ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ "maxNodeModuleJsDepth": 5 - } + }, + "include": ["./src/y-websocket.js"] }