diff --git a/bin/gendocs.js b/bin/gendocs.js index 6a552bf..94755c5 100644 --- a/bin/gendocs.js +++ b/bin/gendocs.js @@ -1,6 +1,6 @@ - +// @ts-ignore import jsdoc from 'jsdoc-api' -import fs from 'fs' +import * as fs from 'fs' const firstTagContentRegex = /<\w>([^<]+)<\/\w>([^]*)/ const jsdocReturnRegex = /\* @return {(.*)}/ @@ -10,6 +10,9 @@ const files = fs.readdirSync('./').filter(file => /(?/g +/** + * @param {string} s + */ const toSafeHtml = s => s.replace(_ltregex, '<').replace(_rtregex, '>') const READMEcontent = fs.readFileSync('./README.md', 'utf8') @@ -17,8 +20,11 @@ const READMEcontent = fs.readFileSync('./README.md', 'utf8') jsdoc.explain({ files, configure: '.jsdoc.json' -}).then(json => { +}).then(/** @param {Array} json */ json => { const strBuilder = [] + /** + * @type {Object, name: string, description: string }>} + */ const modules = {} json.forEach(item => { if (item.meta && item.meta.filename) { @@ -31,6 +37,9 @@ jsdoc.explain({ } } }) + /** + * @type {Object} + */ const classDescriptions = {} for (const fileName in modules) { const mod = modules[fileName] @@ -68,6 +77,9 @@ jsdoc.explain({ } // eslint-disable-next-line case 'function': { + /** + * @param {string} name + */ const getOriginalParamTypeDecl = name => { const regval = new RegExp('@param {(.*)} \\[?' + name + '\\]?[^\\w]*').exec(item.comment) return regval ? regval[1] : null @@ -75,9 +87,9 @@ jsdoc.explain({ if (item.params == null && item.returns == null) { break } - const paramVal = (item.params || []).map(ret => `${ret.name}: ${getOriginalParamTypeDecl(ret.name) || ret.type.names.join('|')}`).join(', ') + const paramVal = (item.params || []).map(/** @param {any} ret */ ret => `${ret.name}: ${getOriginalParamTypeDecl(ret.name) || ret.type.names.join('|')}`).join(', ') const evalReturnRegex = jsdocReturnRegex.exec(item.comment) - const returnVal = evalReturnRegex ? `: ${evalReturnRegex[1]}` : (item.returns ? item.returns.map(r => r.type.names.join('|')).join('|') : '') + const returnVal = evalReturnRegex ? `: ${evalReturnRegex[1]}` : (item.returns ? item.returns.map(/** @param {any} r */ r => r.type.names.join('|')).join('|') : '') strBuilder.push(`${item.kind === 'class' ? 'new ' : ''}${item.longname.slice(7)}(${toSafeHtml(paramVal)})${toSafeHtml(returnVal)}
`) const desc = item.description || item.classdesc || classDescriptions[item.longname] || null if (desc) { @@ -87,7 +99,7 @@ jsdoc.explain({ } case 'member': { if (item.type) { - strBuilder.push(`${item.longname.slice(7)}: ${toSafeHtml(jsdocTypeRegex.exec(item.comment)[1])}
`) + strBuilder.push(`${item.longname.slice(7)}: ${toSafeHtml(/** @type {RegExpExecArray} */ (jsdocTypeRegex.exec(item.comment))[1])}
`) if (item.description) { strBuilder.push(`
${item.description}
`) } diff --git a/package-lock.json b/package-lock.json index aa7056f..14cf6ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "jsdoc-plugin-typescript": "^2.0.6", "rollup": "^2.42.1", "standard": "^14.3.4", - "typescript": "^4.2.3" + "typescript": "^5.0.3" }, "engines": { "node": ">=16" @@ -2743,14 +2743,18 @@ } }, "node_modules/lib0": { - "version": "0.2.47", - "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.47.tgz", - "integrity": "sha512-RXprIyaflw7OmFNMpb8HmvDhuRVUFXYCXrmynQN8OGbGevgMx9u6tjQG/yB0dOoDcuB1XXgqFn8Oy3RlKF/Qhg==", + "version": "0.2.73", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.73.tgz", + "integrity": "sha512-aJJIElCLWnHMcYZPtsM07QoSfHwpxCy4VUzBYGXFYEmh/h2QS5uZNbCCfL0CqnkOE30b7Tp9DVfjXag+3qzZjQ==", "dependencies": { "isomorphic.js": "^0.2.4" }, + "bin": { + "0gentesthtml": "bin/gentesthtml.js", + "0serve": "bin/0serve.js" + }, "engines": { - "node": ">=12" + "node": ">=14" }, "funding": { "type": "GitHub Sponsors ❤", @@ -4238,16 +4242,16 @@ } }, "node_modules/typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.3.tgz", + "integrity": "sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=12.20" } }, "node_modules/typical": { @@ -4599,12 +4603,16 @@ } }, "node_modules/yjs": { - "version": "13.5.29", - "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.5.29.tgz", - "integrity": "sha512-Wtx1jLM+LbUUJsN9NJLYgANh1MEI1QAFyLLTHymEwpKwWtLg9hRvucX7YGQ4GHLT6MIIdWt66B5Wu4dkZriEKw==", + "version": "13.5.51", + "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.5.51.tgz", + "integrity": "sha512-F1Nb3z3TdandD80IAeQqgqy/2n9AhDLcXoBhZvCUX1dNVe0ef7fIwi6MjSYaGAYF2Ev8VcLcsGnmuGGOl7AWbw==", "peer": true, "dependencies": { - "lib0": "^0.2.43" + "lib0": "^0.2.72" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=8.0.0" }, "funding": { "type": "GitHub Sponsors ❤", @@ -6661,9 +6669,9 @@ } }, "lib0": { - "version": "0.2.47", - "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.47.tgz", - "integrity": "sha512-RXprIyaflw7OmFNMpb8HmvDhuRVUFXYCXrmynQN8OGbGevgMx9u6tjQG/yB0dOoDcuB1XXgqFn8Oy3RlKF/Qhg==", + "version": "0.2.73", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.73.tgz", + "integrity": "sha512-aJJIElCLWnHMcYZPtsM07QoSfHwpxCy4VUzBYGXFYEmh/h2QS5uZNbCCfL0CqnkOE30b7Tp9DVfjXag+3qzZjQ==", "requires": { "isomorphic.js": "^0.2.4" } @@ -7800,9 +7808,9 @@ "dev": true }, "typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.3.tgz", + "integrity": "sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==", "dev": true }, "typical": { @@ -8100,12 +8108,12 @@ } }, "yjs": { - "version": "13.5.29", - "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.5.29.tgz", - "integrity": "sha512-Wtx1jLM+LbUUJsN9NJLYgANh1MEI1QAFyLLTHymEwpKwWtLg9hRvucX7YGQ4GHLT6MIIdWt66B5Wu4dkZriEKw==", + "version": "13.5.51", + "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.5.51.tgz", + "integrity": "sha512-F1Nb3z3TdandD80IAeQqgqy/2n9AhDLcXoBhZvCUX1dNVe0ef7fIwi6MjSYaGAYF2Ev8VcLcsGnmuGGOl7AWbw==", "peer": true, "requires": { - "lib0": "^0.2.43" + "lib0": "^0.2.72" } }, "yocto-queue": { diff --git a/package.json b/package.json index 941124a..94f755f 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "jsdoc-plugin-typescript": "^2.0.6", "rollup": "^2.42.1", "standard": "^14.3.4", - "typescript": "^4.2.3" + "typescript": "^5.0.3" }, "scripts": { "clean": "rm -rf dist *.d.ts */*.d.ts *.d.ts.map */*.d.ts.map", diff --git a/tsconfig.json b/tsconfig.json index 405269b..1927845 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,23 +1,20 @@ { "compilerOptions": { - /* Basic Options */ - "target": "es2018", - "lib": ["es2018", "dom"], /* Specify library files to be included in the compilation. */ - "allowJs": true, /* Allow javascript files to be compiled. */ - "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": true, /* Generates corresponding '.d.ts' file. */ - "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "outFile": "./index.js", /* Concatenate and emit output to single file. */ - "outDir": "dist", // this is overritten by `npm run types` - "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + "target": "ES2020", + "lib": ["ES2020", "dom"], + "module": "ES2020", + "allowJs": true, + "checkJs": true, + "declaration": true, + "declarationMap": true, + "outDir": "./dist", + "baseUrl": "./", + "rootDir": "./", "emitDeclarationOnly": true, "strict": true, "noImplicitAny": true, - "moduleResolution": "node", - "allowSyntheticDefaultImports": true + "moduleResolution": "nodenext" }, - "include": ["./*.js"], - "exclude": ["./dist"] + "include": ["./**/*.js"], + "exclude": ["./dist/**/*"] } diff --git a/y-keyvalue.js b/y-keyvalue.js index f64aec5..0db6249 100644 --- a/y-keyvalue.js +++ b/y-keyvalue.js @@ -95,7 +95,7 @@ export class YKeyValue extends Observable { */ const itemsToRemove = new Set() const vals = yarray.toArray() - this.doc.transact(tr => { + this.doc.transact(_tr => { /** * Iterate from right to left and update the map while we find the items in addedVals */ @@ -143,7 +143,7 @@ export class YKeyValue extends Observable { * @param {T} val */ set (key, val) { - this.doc.transact(tr => { + this.doc.transact(_tr => { // if this value existed before, we will delete it first if (this.map.has(key)) { this.delete(key) diff --git a/y-multidoc-undomanager.test.js b/y-multidoc-undomanager.test.js index d028bdc..190e893 100644 --- a/y-multidoc-undomanager.test.js +++ b/y-multidoc-undomanager.test.js @@ -3,9 +3,9 @@ import * as t from 'lib0/testing' import { YMultiDocUndoManager } from './y-multidoc-undomanager.js' /** - * @param {t.TestCase} tc + * @param {t.TestCase} _tc */ -export const testUndo = tc => { +export const testUndo = _tc => { const um = new YMultiDocUndoManager() const ydoc1 = new Y.Doc() const ydoc2 = new Y.Doc() @@ -47,16 +47,16 @@ export const testUndo = tc => { } /** - * @param {t.TestCase} tc + * @param {t.TestCase} _tc */ -export const testUndoMap = tc => { +export const testUndoMap = _tc => { const ydoc1 = new Y.Doc() const ymap = ydoc1.getMap() const um = new YMultiDocUndoManager([ymap], { trackedOrigins: new Set(['this-client']) }) - ydoc1.transact(tr => { + ydoc1.transact(_tr => { ymap.set('a', 1) }, 'this-client') @@ -68,9 +68,9 @@ export const testUndoMap = tc => { } /** - * @param {t.TestCase} tc + * @param {t.TestCase} _tc */ -export const testUndoEvents = tc => { +export const testUndoEvents = _tc => { const undoManager = new YMultiDocUndoManager() const ydoc1 = new Y.Doc() const text0 = ydoc1.getText() @@ -83,7 +83,7 @@ export const testUndoEvents = tc => { t.assert(event.changedParentTypes != null && event.changedParentTypes.has(text0)) event.stackItem.meta.set('test', counter++) }) - undoManager.on('stack-item-updated', /** @param {any} event */ event => { + undoManager.on('stack-item-updated', /** @param {any} _event */ _event => { itemUpdated = true }) undoManager.on('stack-item-popped', /** @param {any} event */ event => { @@ -103,9 +103,9 @@ export const testUndoEvents = tc => { } /** - * @param {t.TestCase} tc + * @param {t.TestCase} _tc */ -export const testUndoAfterChangeAfterUndo = tc => { +export const testUndoAfterChangeAfterUndo = _tc => { const um = new YMultiDocUndoManager([], { captureTimeout: -1 }) const ydoc1 = new Y.Doc() const ytype1 = ydoc1.getText() @@ -134,9 +134,9 @@ export const testUndoAfterChangeAfterUndo = tc => { } /** - * @param {t.TestCase} tc + * @param {t.TestCase} _tc */ -export const testAfterDestroy = tc => { +export const testAfterDestroy = _tc => { const um = new YMultiDocUndoManager([], { captureTimeout: -1 }) const ydoc1 = new Y.Doc() const ytype1 = ydoc1.getText()