@hocuspocus/extension-sqlite 2.15.2 → 3.0.4-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.
Files changed (51) hide show
  1. package/dist/hocuspocus-sqlite.cjs +2 -9
  2. package/dist/hocuspocus-sqlite.cjs.map +1 -1
  3. package/dist/hocuspocus-sqlite.esm.js.map +1 -1
  4. package/dist/packages/extension-database/src/Database.d.ts +1 -1
  5. package/dist/packages/extension-logger/src/Logger.d.ts +1 -1
  6. package/dist/packages/extension-redis/src/Redis.d.ts +4 -3
  7. package/dist/packages/extension-sqlite/src/SQLite.d.ts +2 -1
  8. package/dist/packages/extension-throttle/src/index.d.ts +2 -2
  9. package/dist/packages/extension-webhook/src/index.d.ts +3 -3
  10. package/dist/packages/provider/src/HocuspocusProvider.d.ts +12 -45
  11. package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +5 -9
  12. package/dist/packages/provider/src/IncomingMessage.d.ts +3 -3
  13. package/dist/packages/provider/src/MessageReceiver.d.ts +2 -4
  14. package/dist/packages/provider/src/MessageSender.d.ts +2 -2
  15. package/dist/packages/provider/src/OutgoingMessage.d.ts +2 -2
  16. package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +2 -1
  17. package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +2 -1
  18. package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +2 -1
  19. package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +2 -1
  20. package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +2 -1
  21. package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +2 -1
  22. package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +2 -1
  23. package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +2 -1
  24. package/dist/packages/provider/src/index.d.ts +0 -2
  25. package/dist/packages/provider/src/types.d.ts +12 -12
  26. package/dist/packages/server/src/ClientConnection.d.ts +19 -10
  27. package/dist/packages/server/src/Connection.d.ts +7 -23
  28. package/dist/packages/server/src/DirectConnection.d.ts +2 -2
  29. package/dist/packages/server/src/Document.d.ts +3 -7
  30. package/dist/packages/server/src/Hocuspocus.d.ts +7 -36
  31. package/dist/packages/server/src/IncomingMessage.d.ts +3 -3
  32. package/dist/packages/server/src/MessageReceiver.d.ts +4 -6
  33. package/dist/packages/server/src/OutgoingMessage.d.ts +4 -3
  34. package/dist/packages/server/src/Server.d.ts +23 -3
  35. package/dist/packages/server/src/index.d.ts +1 -1
  36. package/dist/packages/server/src/types.d.ts +15 -29
  37. package/dist/packages/server/src/util/getParameters.d.ts +1 -1
  38. package/dist/packages/transformer/src/Prosemirror.d.ts +1 -1
  39. package/dist/packages/transformer/src/Tiptap.d.ts +3 -3
  40. package/dist/packages/transformer/src/types.d.ts +1 -1
  41. package/dist/tests/utils/newHocuspocus.d.ts +2 -2
  42. package/dist/tests/utils/newHocuspocusProvider.d.ts +2 -2
  43. package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +4 -3
  44. package/dist/tests/utils/retryableAssertion.d.ts +1 -1
  45. package/package.json +3 -6
  46. package/src/SQLite.ts +2 -1
  47. package/dist/packages/provider/src/TiptapCollabProvider.d.ts +0 -161
  48. package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +0 -19
  49. package/dist/packages/server/src/Debugger.d.ts +0 -14
  50. package/dist/tests/server/getMessageLogs.d.ts +0 -1
  51. package/dist/tests/server/requiresAuthentication.d.ts +0 -1
@@ -1,16 +1,9 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var extensionDatabase = require('@hocuspocus/extension-database');
6
4
  var sqlite3 = require('sqlite3');
7
5
  var kleur = require('kleur');
8
6
 
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var sqlite3__default = /*#__PURE__*/_interopDefaultLegacy(sqlite3);
12
- var kleur__default = /*#__PURE__*/_interopDefaultLegacy(kleur);
13
-
14
7
  const schema = `CREATE TABLE IF NOT EXISTS "documents" (
15
8
  "name" varchar(255) NOT NULL,
16
9
  "data" blob NOT NULL,
@@ -57,12 +50,12 @@ class SQLite extends extensionDatabase.Database {
57
50
  };
58
51
  }
59
52
  async onConfigure() {
60
- this.db = new sqlite3__default["default"].Database(this.configuration.database);
53
+ this.db = new sqlite3.Database(this.configuration.database);
61
54
  this.db.run(this.configuration.schema);
62
55
  }
63
56
  async onListen() {
64
57
  if (this.configuration.database === SQLITE_INMEMORY) {
65
- console.warn(` ${kleur__default["default"].yellow('The SQLite extension is configured as an in-memory database. All changes will be lost on restart!')}`);
58
+ console.warn(` ${kleur.yellow('The SQLite extension is configured as an in-memory database. All changes will be lost on restart!')}`);
66
59
  console.log();
67
60
  }
68
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-sqlite.cjs","sources":["../src/SQLite.ts"],"sourcesContent":["import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database'\nimport sqlite3 from 'sqlite3'\nimport kleur from 'kleur'\n\nexport const schema = `CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)`\n\nexport const selectQuery = `\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n`\n\nexport const upsertQuery = `\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n`\n\nconst SQLITE_INMEMORY = ':memory:'\n\nexport interface SQLiteConfiguration extends DatabaseConfiguration {\n /**\n * Valid values are filenames, \":memory:\" for an anonymous in-memory database and an empty\n * string for an anonymous disk-based database. Anonymous databases are not persisted and\n * when closing the database handle, their contents are lost.\n *\n * https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback\n */\n database: string,\n /**\n * The database schema to create.\n */\n schema: string,\n}\n\nexport class SQLite extends Database {\n db?: sqlite3.Database\n\n configuration: SQLiteConfiguration = {\n database: SQLITE_INMEMORY,\n schema,\n fetch: async ({ documentName }) => {\n return new Promise((resolve, reject) => {\n this.db?.get(selectQuery, {\n $name: documentName,\n }, (error, row) => {\n if (error) {\n reject(error)\n }\n\n resolve((row as any)?.data)\n })\n })\n },\n store: async ({ documentName, state }) => {\n this.db?.run(upsertQuery, {\n $name: documentName,\n $data: state,\n })\n },\n }\n\n constructor(configuration?: Partial<SQLiteConfiguration>) {\n super({})\n\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure() {\n this.db = new sqlite3.Database(this.configuration.database)\n this.db.run(this.configuration.schema)\n }\n\n async onListen() {\n if (this.configuration.database === SQLITE_INMEMORY) {\n console.warn(` ${kleur.yellow('The SQLite extension is configured as an in-memory database. All changes will be lost on restart!')}`)\n console.log()\n }\n }\n}\n"],"names":["Database","sqlite3","kleur"],"mappings":";;;;;;;;;;;;;AAIa,MAAA,MAAM,GAAG,CAAA;;;;GAIpB;AAEW,MAAA,WAAW,GAAG,CAAA;;EAE1B;AAEY,MAAA,WAAW,GAAG,CAAA;;;EAG1B;AAED,MAAM,eAAe,GAAG,UAAU,CAAA;AAiB5B,MAAO,MAAO,SAAQA,0BAAQ,CAAA;AA2BlC,IAAA,WAAA,CAAY,aAA4C,EAAA;QACtD,KAAK,CAAC,EAAE,CAAC,CAAA;AAzBX,QAAA,IAAA,CAAA,aAAa,GAAwB;AACnC,YAAA,QAAQ,EAAE,eAAe;YACzB,MAAM;AACN,YAAA,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAI;gBAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;;AACrC,oBAAA,CAAA,EAAA,GAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,WAAW,EAAE;AACxB,wBAAA,KAAK,EAAE,YAAY;AACpB,qBAAA,EAAE,CAAC,KAAK,EAAE,GAAG,KAAI;AAChB,wBAAA,IAAI,KAAK,EAAE;4BACT,MAAM,CAAC,KAAK,CAAC,CAAA;AACd,yBAAA;wBAED,OAAO,CAAE,GAAW,KAAX,IAAA,IAAA,GAAG,uBAAH,GAAG,CAAU,IAAI,CAAC,CAAA;AAC7B,qBAAC,CAAC,CAAA;AACJ,iBAAC,CAAC,CAAA;aACH;YACD,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAI;;AACvC,gBAAA,CAAA,EAAA,GAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,WAAW,EAAE;AACxB,oBAAA,KAAK,EAAE,YAAY;AACnB,oBAAA,KAAK,EAAE,KAAK;AACb,iBAAA,CAAC,CAAA;aACH;SACF,CAAA;QAKC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SACjB,CAAA;KACF;AAED,IAAA,MAAM,WAAW,GAAA;AACf,QAAA,IAAI,CAAC,EAAE,GAAG,IAAIC,2BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC3D,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;KACvC;AAED,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,KAAK,eAAe,EAAE;AACnD,YAAA,OAAO,CAAC,IAAI,CAAC,CAAA,EAAA,EAAKC,yBAAK,CAAC,MAAM,CAAC,mGAAmG,CAAC,CAAE,CAAA,CAAC,CAAA;YACtI,OAAO,CAAC,GAAG,EAAE,CAAA;AACd,SAAA;KACF;AACF;;;;;;;"}
1
+ {"version":3,"file":"hocuspocus-sqlite.cjs","sources":["../src/SQLite.ts"],"sourcesContent":["import type { DatabaseConfiguration } from '@hocuspocus/extension-database'\nimport { Database } from '@hocuspocus/extension-database'\nimport sqlite3 from 'sqlite3'\nimport kleur from 'kleur'\n\nexport const schema = `CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)`\n\nexport const selectQuery = `\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n`\n\nexport const upsertQuery = `\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n`\n\nconst SQLITE_INMEMORY = ':memory:'\n\nexport interface SQLiteConfiguration extends DatabaseConfiguration {\n /**\n * Valid values are filenames, \":memory:\" for an anonymous in-memory database and an empty\n * string for an anonymous disk-based database. Anonymous databases are not persisted and\n * when closing the database handle, their contents are lost.\n *\n * https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback\n */\n database: string,\n /**\n * The database schema to create.\n */\n schema: string,\n}\n\nexport class SQLite extends Database {\n db?: sqlite3.Database\n\n configuration: SQLiteConfiguration = {\n database: SQLITE_INMEMORY,\n schema,\n fetch: async ({ documentName }) => {\n return new Promise((resolve, reject) => {\n this.db?.get(selectQuery, {\n $name: documentName,\n }, (error, row) => {\n if (error) {\n reject(error)\n }\n\n resolve((row as any)?.data)\n })\n })\n },\n store: async ({ documentName, state }) => {\n this.db?.run(upsertQuery, {\n $name: documentName,\n $data: state,\n })\n },\n }\n\n constructor(configuration?: Partial<SQLiteConfiguration>) {\n super({})\n\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure() {\n this.db = new sqlite3.Database(this.configuration.database)\n this.db.run(this.configuration.schema)\n }\n\n async onListen() {\n if (this.configuration.database === SQLITE_INMEMORY) {\n console.warn(` ${kleur.yellow('The SQLite extension is configured as an in-memory database. All changes will be lost on restart!')}`)\n console.log()\n }\n }\n}\n"],"names":["Database"],"mappings":";;;;;;AAKa,MAAA,MAAM,GAAG,CAAA;;;;;AAMT,MAAA,WAAW,GAAG;;;AAId,MAAA,WAAW,GAAG;;;;AAK3B,MAAM,eAAe,GAAG,UAAU;AAiB5B,MAAO,MAAO,SAAQA,0BAAQ,CAAA;AA2BlC,IAAA,WAAA,CAAY,aAA4C,EAAA;QACtD,KAAK,CAAC,EAAE,CAAC;AAzBX,QAAA,IAAA,CAAA,aAAa,GAAwB;AACnC,YAAA,QAAQ,EAAE,eAAe;YACzB,MAAM;AACN,YAAA,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAI;gBAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;;AACrC,oBAAA,CAAA,EAAA,GAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,WAAW,EAAE;AACxB,wBAAA,KAAK,EAAE,YAAY;AACpB,qBAAA,EAAE,CAAC,KAAK,EAAE,GAAG,KAAI;AAChB,wBAAA,IAAI,KAAK,EAAE;4BACT,MAAM,CAAC,KAAK,CAAC;AACd;wBAED,OAAO,CAAE,GAAW,KAAX,IAAA,IAAA,GAAG,uBAAH,GAAG,CAAU,IAAI,CAAC;AAC7B,qBAAC,CAAC;AACJ,iBAAC,CAAC;aACH;YACD,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAI;;AACvC,gBAAA,CAAA,EAAA,GAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,WAAW,EAAE;AACxB,oBAAA,KAAK,EAAE,YAAY;AACnB,oBAAA,KAAK,EAAE,KAAK;AACb,iBAAA,CAAC;aACH;SACF;QAKC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SACjB;;AAGH,IAAA,MAAM,WAAW,GAAA;AACf,QAAA,IAAI,CAAC,EAAE,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;QAC3D,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;;AAGxC,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,KAAK,eAAe,EAAE;AACnD,YAAA,OAAO,CAAC,IAAI,CAAC,CAAA,EAAA,EAAK,KAAK,CAAC,MAAM,CAAC,mGAAmG,CAAC,CAAE,CAAA,CAAC;YACtI,OAAO,CAAC,GAAG,EAAE;AACd;;AAEJ;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-sqlite.esm.js","sources":["../src/SQLite.ts"],"sourcesContent":["import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database'\nimport sqlite3 from 'sqlite3'\nimport kleur from 'kleur'\n\nexport const schema = `CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)`\n\nexport const selectQuery = `\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n`\n\nexport const upsertQuery = `\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n`\n\nconst SQLITE_INMEMORY = ':memory:'\n\nexport interface SQLiteConfiguration extends DatabaseConfiguration {\n /**\n * Valid values are filenames, \":memory:\" for an anonymous in-memory database and an empty\n * string for an anonymous disk-based database. Anonymous databases are not persisted and\n * when closing the database handle, their contents are lost.\n *\n * https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback\n */\n database: string,\n /**\n * The database schema to create.\n */\n schema: string,\n}\n\nexport class SQLite extends Database {\n db?: sqlite3.Database\n\n configuration: SQLiteConfiguration = {\n database: SQLITE_INMEMORY,\n schema,\n fetch: async ({ documentName }) => {\n return new Promise((resolve, reject) => {\n this.db?.get(selectQuery, {\n $name: documentName,\n }, (error, row) => {\n if (error) {\n reject(error)\n }\n\n resolve((row as any)?.data)\n })\n })\n },\n store: async ({ documentName, state }) => {\n this.db?.run(upsertQuery, {\n $name: documentName,\n $data: state,\n })\n },\n }\n\n constructor(configuration?: Partial<SQLiteConfiguration>) {\n super({})\n\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure() {\n this.db = new sqlite3.Database(this.configuration.database)\n this.db.run(this.configuration.schema)\n }\n\n async onListen() {\n if (this.configuration.database === SQLITE_INMEMORY) {\n console.warn(` ${kleur.yellow('The SQLite extension is configured as an in-memory database. All changes will be lost on restart!')}`)\n console.log()\n }\n }\n}\n"],"names":[],"mappings":";;;;AAIa,MAAA,MAAM,GAAG,CAAA;;;;GAIpB;AAEW,MAAA,WAAW,GAAG,CAAA;;EAE1B;AAEY,MAAA,WAAW,GAAG,CAAA;;;EAG1B;AAED,MAAM,eAAe,GAAG,UAAU,CAAA;AAiB5B,MAAO,MAAO,SAAQ,QAAQ,CAAA;AA2BlC,IAAA,WAAA,CAAY,aAA4C,EAAA;QACtD,KAAK,CAAC,EAAE,CAAC,CAAA;AAzBX,QAAA,IAAA,CAAA,aAAa,GAAwB;AACnC,YAAA,QAAQ,EAAE,eAAe;YACzB,MAAM;AACN,YAAA,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAI;gBAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;;AACrC,oBAAA,CAAA,EAAA,GAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,WAAW,EAAE;AACxB,wBAAA,KAAK,EAAE,YAAY;AACpB,qBAAA,EAAE,CAAC,KAAK,EAAE,GAAG,KAAI;AAChB,wBAAA,IAAI,KAAK,EAAE;4BACT,MAAM,CAAC,KAAK,CAAC,CAAA;AACd,yBAAA;wBAED,OAAO,CAAE,GAAW,KAAX,IAAA,IAAA,GAAG,uBAAH,GAAG,CAAU,IAAI,CAAC,CAAA;AAC7B,qBAAC,CAAC,CAAA;AACJ,iBAAC,CAAC,CAAA;aACH;YACD,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAI;;AACvC,gBAAA,CAAA,EAAA,GAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,WAAW,EAAE;AACxB,oBAAA,KAAK,EAAE,YAAY;AACnB,oBAAA,KAAK,EAAE,KAAK;AACb,iBAAA,CAAC,CAAA;aACH;SACF,CAAA;QAKC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SACjB,CAAA;KACF;AAED,IAAA,MAAM,WAAW,GAAA;AACf,QAAA,IAAI,CAAC,EAAE,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC3D,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;KACvC;AAED,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,KAAK,eAAe,EAAE;AACnD,YAAA,OAAO,CAAC,IAAI,CAAC,CAAA,EAAA,EAAK,KAAK,CAAC,MAAM,CAAC,mGAAmG,CAAC,CAAE,CAAA,CAAC,CAAA;YACtI,OAAO,CAAC,GAAG,EAAE,CAAA;AACd,SAAA;KACF;AACF;;;;"}
1
+ {"version":3,"file":"hocuspocus-sqlite.esm.js","sources":["../src/SQLite.ts"],"sourcesContent":["import type { DatabaseConfiguration } from '@hocuspocus/extension-database'\nimport { Database } from '@hocuspocus/extension-database'\nimport sqlite3 from 'sqlite3'\nimport kleur from 'kleur'\n\nexport const schema = `CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)`\n\nexport const selectQuery = `\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n`\n\nexport const upsertQuery = `\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n`\n\nconst SQLITE_INMEMORY = ':memory:'\n\nexport interface SQLiteConfiguration extends DatabaseConfiguration {\n /**\n * Valid values are filenames, \":memory:\" for an anonymous in-memory database and an empty\n * string for an anonymous disk-based database. Anonymous databases are not persisted and\n * when closing the database handle, their contents are lost.\n *\n * https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback\n */\n database: string,\n /**\n * The database schema to create.\n */\n schema: string,\n}\n\nexport class SQLite extends Database {\n db?: sqlite3.Database\n\n configuration: SQLiteConfiguration = {\n database: SQLITE_INMEMORY,\n schema,\n fetch: async ({ documentName }) => {\n return new Promise((resolve, reject) => {\n this.db?.get(selectQuery, {\n $name: documentName,\n }, (error, row) => {\n if (error) {\n reject(error)\n }\n\n resolve((row as any)?.data)\n })\n })\n },\n store: async ({ documentName, state }) => {\n this.db?.run(upsertQuery, {\n $name: documentName,\n $data: state,\n })\n },\n }\n\n constructor(configuration?: Partial<SQLiteConfiguration>) {\n super({})\n\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure() {\n this.db = new sqlite3.Database(this.configuration.database)\n this.db.run(this.configuration.schema)\n }\n\n async onListen() {\n if (this.configuration.database === SQLITE_INMEMORY) {\n console.warn(` ${kleur.yellow('The SQLite extension is configured as an in-memory database. All changes will be lost on restart!')}`)\n console.log()\n }\n }\n}\n"],"names":[],"mappings":";;;;AAKa,MAAA,MAAM,GAAG,CAAA;;;;;AAMT,MAAA,WAAW,GAAG;;;AAId,MAAA,WAAW,GAAG;;;;AAK3B,MAAM,eAAe,GAAG,UAAU;AAiB5B,MAAO,MAAO,SAAQ,QAAQ,CAAA;AA2BlC,IAAA,WAAA,CAAY,aAA4C,EAAA;QACtD,KAAK,CAAC,EAAE,CAAC;AAzBX,QAAA,IAAA,CAAA,aAAa,GAAwB;AACnC,YAAA,QAAQ,EAAE,eAAe;YACzB,MAAM;AACN,YAAA,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAI;gBAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;;AACrC,oBAAA,CAAA,EAAA,GAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,WAAW,EAAE;AACxB,wBAAA,KAAK,EAAE,YAAY;AACpB,qBAAA,EAAE,CAAC,KAAK,EAAE,GAAG,KAAI;AAChB,wBAAA,IAAI,KAAK,EAAE;4BACT,MAAM,CAAC,KAAK,CAAC;AACd;wBAED,OAAO,CAAE,GAAW,KAAX,IAAA,IAAA,GAAG,uBAAH,GAAG,CAAU,IAAI,CAAC;AAC7B,qBAAC,CAAC;AACJ,iBAAC,CAAC;aACH;YACD,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAI;;AACvC,gBAAA,CAAA,EAAA,GAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,WAAW,EAAE;AACxB,oBAAA,KAAK,EAAE,YAAY;AACnB,oBAAA,KAAK,EAAE,KAAK;AACb,iBAAA,CAAC;aACH;SACF;QAKC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SACjB;;AAGH,IAAA,MAAM,WAAW,GAAA;AACf,QAAA,IAAI,CAAC,EAAE,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;QAC3D,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;;AAGxC,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,KAAK,eAAe,EAAE;AACnD,YAAA,OAAO,CAAC,IAAI,CAAC,CAAA,EAAA,EAAK,KAAK,CAAC,MAAM,CAAC,mGAAmG,CAAC,CAAE,CAAA,CAAC;YACtI,OAAO,CAAC,GAAG,EAAE;AACd;;AAEJ;;;;"}
@@ -1,4 +1,4 @@
1
- import { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server';
1
+ import type { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server';
2
2
  export interface DatabaseConfiguration {
3
3
  /**
4
4
  * Pass a Promise to retrieve updates from your database. The Promise should resolve to
@@ -1,4 +1,4 @@
1
- import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
1
+ import type { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
2
2
  export interface LoggerConfiguration {
3
3
  /**
4
4
  * Prepend all logging message with a string.
@@ -1,7 +1,9 @@
1
1
  /// <reference types="node" />
2
- import RedisClient, { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
2
+ /// <reference types="node" />
3
+ import type { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
4
+ import RedisClient from 'ioredis';
3
5
  import Redlock from 'redlock';
4
- import { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
6
+ import type { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
5
7
  export type RedisInstance = RedisClient.Cluster | RedisClient.Redis;
6
8
  export interface Configuration {
7
9
  /**
@@ -63,7 +65,6 @@ export declare class Redis implements Extension {
63
65
  instance: Hocuspocus;
64
66
  redlock: Redlock;
65
67
  locks: Map<string, Redlock.Lock>;
66
- logger: Debugger;
67
68
  messagePrefix: Buffer;
68
69
  /**
69
70
  * When we have a high frequency of updates to a document we don't need tons of setTimeouts
@@ -1,4 +1,5 @@
1
- import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database';
1
+ import type { DatabaseConfiguration } from '@hocuspocus/extension-database';
2
+ import { Database } from '@hocuspocus/extension-database';
2
3
  import sqlite3 from 'sqlite3';
3
4
  export declare const schema = "CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)";
4
5
  export declare const selectQuery = "\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n";
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Extension, onConnectPayload } from '@hocuspocus/server';
2
+ import type { Extension, onConnectPayload } from '@hocuspocus/server';
3
3
  export interface ThrottleConfiguration {
4
4
  throttle: number | null | false;
5
5
  consideredSeconds: number;
@@ -10,7 +10,7 @@ export declare class Throttle implements Extension {
10
10
  configuration: ThrottleConfiguration;
11
11
  connectionsByIp: Map<string, Array<number>>;
12
12
  bannedIps: Map<string, number>;
13
- cleanupInterval?: NodeJS.Timer;
13
+ cleanupInterval?: NodeJS.Timeout;
14
14
  /**
15
15
  * Constructor
16
16
  */
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
- import { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
3
- import { Doc } from 'yjs';
4
- import { Transformer } from '@hocuspocus/transformer';
2
+ import type { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
3
+ import type { Doc } from 'yjs';
4
+ import type { Transformer } from '@hocuspocus/transformer';
5
5
  export declare enum Events {
6
6
  onChange = "change",
7
7
  onConnect = "connect",
@@ -1,10 +1,10 @@
1
- import * as mutex from 'lib0/mutex';
2
- import type { CloseEvent, Event, MessageEvent } from 'ws';
1
+ import type { Event, MessageEvent } from 'ws';
3
2
  import { Awareness } from 'y-protocols/awareness';
4
3
  import * as Y from 'yjs';
5
4
  import EventEmitter from './EventEmitter.js';
6
- import { CompleteHocuspocusProviderWebsocketConfiguration, HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
7
- import { ConstructableOutgoingMessage, WebSocketStatus, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSyncedParameters } from './types.js';
5
+ import type { CompleteHocuspocusProviderWebsocketConfiguration } from './HocuspocusProviderWebsocket.js';
6
+ import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
7
+ import type { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters } from './types.js';
8
8
  export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, 'name'>> & Partial<CompleteHocuspocusProviderConfiguration> & (Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, 'url'>> | Required<Pick<CompleteHocuspocusProviderConfiguration, 'websocketProvider'>>);
9
9
  export interface CompleteHocuspocusProviderConfiguration {
10
10
  /**
@@ -15,10 +15,6 @@ export interface CompleteHocuspocusProviderConfiguration {
15
15
  * The actual Y.js document
16
16
  */
17
17
  document: Y.Doc;
18
- /**
19
- * Pass false to disable broadcasting between browser tabs.
20
- */
21
- broadcast: boolean;
22
18
  /**
23
19
  * An Awareness instance to keep the presence state of all clients.
24
20
  *
@@ -32,12 +28,6 @@ export interface CompleteHocuspocusProviderConfiguration {
32
28
  * A token that’s sent to the backend for authentication purposes.
33
29
  */
34
30
  token: string | (() => string) | (() => Promise<string>) | null;
35
- /**
36
- * URL parameters that should be added.
37
- */
38
- parameters: {
39
- [key: string]: any;
40
- };
41
31
  /**
42
32
  * Hocuspocus websocket provider
43
33
  */
@@ -52,7 +42,6 @@ export interface CompleteHocuspocusProviderConfiguration {
52
42
  onConnect: () => void;
53
43
  onMessage: (data: onMessageParameters) => void;
54
44
  onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
55
- onStatus: (data: onStatusParameters) => void;
56
45
  onSynced: (data: onSyncedParameters) => void;
57
46
  onDisconnect: (data: onDisconnectParameters) => void;
58
47
  onClose: (data: onCloseParameters) => void;
@@ -60,47 +49,29 @@ export interface CompleteHocuspocusProviderConfiguration {
60
49
  onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void;
61
50
  onAwarenessChange: (data: onAwarenessChangeParameters) => void;
62
51
  onStateless: (data: onStatelessParameters) => void;
63
- /**
64
- * Don’t output any warnings.
65
- */
66
- quiet: boolean;
67
- /**
68
- * Pass `false` to start the connection manually.
69
- */
70
- connect: boolean;
71
- /**
72
- * Pass `false` to close the connection manually.
73
- */
74
- preserveConnection: boolean;
75
52
  }
76
53
  export declare class AwarenessError extends Error {
77
54
  code: number;
78
55
  }
79
56
  export declare class HocuspocusProvider extends EventEmitter {
80
57
  configuration: CompleteHocuspocusProviderConfiguration;
81
- subscribedToBroadcastChannel: boolean;
82
58
  isSynced: boolean;
83
59
  unsyncedChanges: number;
84
- status: WebSocketStatus;
85
60
  isAuthenticated: boolean;
86
61
  authorizedScope: string | undefined;
87
- mux: mutex.mutex;
62
+ manageSocket: boolean;
63
+ private isAttached;
88
64
  intervals: any;
89
- isConnected: boolean;
90
65
  constructor(configuration: HocuspocusProviderConfiguration);
91
66
  boundDocumentUpdateHandler: (update: Uint8Array, origin: any) => void;
92
67
  boundAwarenessUpdateHandler: ({ added, updated, removed }: any, origin: any) => void;
93
- boundBroadcastChannelSubscriber: (data: ArrayBuffer) => void;
94
68
  boundPageHide: () => void;
95
69
  boundOnOpen: (event: Event) => Promise<void>;
96
- boundOnClose: (event: CloseEvent) => void;
97
- boundOnStatus: ({ status }: onStatusParameters) => void;
70
+ boundOnClose: () => void;
98
71
  forwardConnect: (e: any) => this;
99
- forwardOpen: (e: any) => this;
100
72
  forwardClose: (e: any) => this;
101
73
  forwardDisconnect: (e: any) => this;
102
74
  forwardDestroy: (e: any) => this;
103
- onStatus({ status }: onStatusParameters): void;
104
75
  setConfiguration(configuration?: Partial<HocuspocusProviderConfiguration>): void;
105
76
  get document(): Y.Doc;
106
77
  get awareness(): Awareness | null;
@@ -123,22 +94,18 @@ export declare class HocuspocusProvider extends EventEmitter {
123
94
  get synced(): boolean;
124
95
  set synced(state: boolean);
125
96
  receiveStateless(payload: string): void;
126
- get isAuthenticationRequired(): boolean;
127
- connect(): Promise<any>;
97
+ connect(): Promise<void>;
128
98
  disconnect(): void;
129
99
  onOpen(event: Event): Promise<void>;
130
100
  getToken(): Promise<string | null>;
131
101
  startSync(): void;
132
- send(message: ConstructableOutgoingMessage, args: any, broadcast?: boolean): void;
102
+ send(message: ConstructableOutgoingMessage, args: any): void;
133
103
  onMessage(event: MessageEvent): void;
134
- onClose(event: CloseEvent): void;
104
+ onClose(): void;
135
105
  destroy(): void;
106
+ detach(): void;
107
+ attach(): void;
136
108
  permissionDeniedHandler(reason: string): void;
137
109
  authenticatedHandler(scope: string): void;
138
- get broadcastChannel(): string;
139
- broadcastChannelSubscriber(data: ArrayBuffer): void;
140
- subscribeToBroadcastChannel(): void;
141
- disconnectBroadcastChannel(): void;
142
- broadcast(Message: ConstructableOutgoingMessage, args?: any): void;
143
110
  setAwarenessField(key: string, value: any): void;
144
111
  }
@@ -1,8 +1,8 @@
1
- import type { MessageEvent } from 'ws';
2
- import { Event } from 'ws';
1
+ import type { MessageEvent, Event } from 'ws';
3
2
  import EventEmitter from './EventEmitter.js';
4
- import { HocuspocusProvider } from './HocuspocusProvider.js';
5
- import { WebSocketStatus, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.js';
3
+ import type { HocuspocusProvider } from './HocuspocusProvider.js';
4
+ import type { onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.js';
5
+ import { WebSocketStatus } from './types.js';
6
6
  export type HocusPocusWebSocket = WebSocket & {
7
7
  identifier: string;
8
8
  };
@@ -72,10 +72,6 @@ export interface CompleteHocuspocusProviderWebsocketConfiguration {
72
72
  onDestroy: () => void;
73
73
  onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void;
74
74
  onAwarenessChange: (data: onAwarenessChangeParameters) => void;
75
- /**
76
- * Don’t output any warnings.
77
- */
78
- quiet: boolean;
79
75
  /**
80
76
  * Map of attached providers keyed by documentName.
81
77
  */
@@ -102,7 +98,7 @@ export declare class HocuspocusProviderWebsocket extends EventEmitter {
102
98
  receivedOnStatusPayload?: onStatusParameters | undefined;
103
99
  onOpen(event: Event): Promise<void>;
104
100
  onStatus(data: onStatusParameters): Promise<void>;
105
- attach(provider: HocuspocusProvider): Promise<any> | undefined;
101
+ attach(provider: HocuspocusProvider): void;
106
102
  detach(provider: HocuspocusProvider): void;
107
103
  setConfiguration(configuration?: Partial<HocuspocusProviderWebsocketConfiguration>): void;
108
104
  cancelWebsocketRetry?: () => void;
@@ -1,6 +1,6 @@
1
- import { Decoder } from 'lib0/decoding';
2
- import { Encoder } from 'lib0/encoding';
3
- import { MessageType } from './types.js';
1
+ import type { Decoder } from 'lib0/decoding';
2
+ import type { Encoder } from 'lib0/encoding';
3
+ import type { MessageType } from './types.js';
4
4
  export declare class IncomingMessage {
5
5
  data: any;
6
6
  encoder: Encoder;
@@ -1,10 +1,8 @@
1
- import { HocuspocusProvider } from './HocuspocusProvider.js';
2
- import { IncomingMessage } from './IncomingMessage.js';
1
+ import type { HocuspocusProvider } from './HocuspocusProvider.js';
2
+ import type { IncomingMessage } from './IncomingMessage.js';
3
3
  export declare class MessageReceiver {
4
4
  message: IncomingMessage;
5
- broadcasted: boolean;
6
5
  constructor(message: IncomingMessage);
7
- setBroadcasted(value: boolean): this;
8
6
  apply(provider: HocuspocusProvider, emitSynced: boolean): void;
9
7
  private applySyncMessage;
10
8
  applySyncStatusMessage(provider: HocuspocusProvider, applied: boolean): void;
@@ -1,5 +1,5 @@
1
- import { Encoder } from 'lib0/encoding';
2
- import { ConstructableOutgoingMessage } from './types.js';
1
+ import type { Encoder } from 'lib0/encoding';
2
+ import type { ConstructableOutgoingMessage } from './types.js';
3
3
  export declare class MessageSender {
4
4
  encoder: Encoder;
5
5
  message: any;
@@ -1,5 +1,5 @@
1
- import { Encoder } from 'lib0/encoding';
2
- import { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.js';
1
+ import type { Encoder } from 'lib0/encoding';
2
+ import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.js';
3
3
  export declare class OutgoingMessage implements OutgoingMessageInterface {
4
4
  encoder: Encoder;
5
5
  type?: MessageType;
@@ -1,4 +1,5 @@
1
- import { MessageType, OutgoingMessageArguments } from '../types.js';
1
+ import type { OutgoingMessageArguments } from '../types.js';
2
+ import { MessageType } from '../types.js';
2
3
  import { OutgoingMessage } from '../OutgoingMessage.js';
3
4
  export declare class AuthenticationMessage extends OutgoingMessage {
4
5
  type: MessageType;
@@ -1,5 +1,6 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import { MessageType, OutgoingMessageArguments } from '../types.js';
2
+ import type { OutgoingMessageArguments } from '../types.js';
3
+ import { MessageType } from '../types.js';
3
4
  import { OutgoingMessage } from '../OutgoingMessage.js';
4
5
  export declare class AwarenessMessage extends OutgoingMessage {
5
6
  type: MessageType;
@@ -1,5 +1,6 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import { MessageType, OutgoingMessageArguments } from '../types.js';
2
+ import type { OutgoingMessageArguments } from '../types.js';
3
+ import { MessageType } from '../types.js';
3
4
  import { OutgoingMessage } from '../OutgoingMessage.js';
4
5
  export declare class CloseMessage extends OutgoingMessage {
5
6
  type: MessageType;
@@ -1,5 +1,6 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import { MessageType, OutgoingMessageArguments } from '../types.js';
2
+ import type { OutgoingMessageArguments } from '../types.js';
3
+ import { MessageType } from '../types.js';
3
4
  import { OutgoingMessage } from '../OutgoingMessage.js';
4
5
  export declare class QueryAwarenessMessage extends OutgoingMessage {
5
6
  type: MessageType;
@@ -1,4 +1,5 @@
1
- import { MessageType, OutgoingMessageArguments } from '../types.js';
1
+ import type { OutgoingMessageArguments } from '../types.js';
2
+ import { MessageType } from '../types.js';
2
3
  import { OutgoingMessage } from '../OutgoingMessage.js';
3
4
  export declare class StatelessMessage extends OutgoingMessage {
4
5
  type: MessageType;
@@ -1,5 +1,6 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import { MessageType, OutgoingMessageArguments } from '../types.js';
2
+ import type { OutgoingMessageArguments } from '../types.js';
3
+ import { MessageType } from '../types.js';
3
4
  import { OutgoingMessage } from '../OutgoingMessage.js';
4
5
  export declare class SyncStepOneMessage extends OutgoingMessage {
5
6
  type: MessageType;
@@ -1,5 +1,6 @@
1
1
  import * as encoding from 'lib0/encoding';
2
- import { MessageType, OutgoingMessageArguments } from '../types.js';
2
+ import type { OutgoingMessageArguments } from '../types.js';
3
+ import { MessageType } from '../types.js';
3
4
  import { OutgoingMessage } from '../OutgoingMessage.js';
4
5
  export declare class SyncStepTwoMessage extends OutgoingMessage {
5
6
  type: MessageType;
@@ -1,4 +1,5 @@
1
- import { MessageType, OutgoingMessageArguments } from '../types.js';
1
+ import type { OutgoingMessageArguments } from '../types.js';
2
+ import { MessageType } from '../types.js';
2
3
  import { OutgoingMessage } from '../OutgoingMessage.js';
3
4
  export declare class UpdateMessage extends OutgoingMessage {
4
5
  type: MessageType;
@@ -1,5 +1,3 @@
1
1
  export * from './HocuspocusProvider.js';
2
- export * from './TiptapCollabProvider.js';
3
- export * from './TiptapCollabProviderWebsocket.js';
4
2
  export * from './HocuspocusProviderWebsocket.js';
5
3
  export * from './types.js';
@@ -1,16 +1,16 @@
1
- import { Encoder } from 'lib0/encoding';
1
+ import type { Encoder } from 'lib0/encoding';
2
2
  import type { Event, MessageEvent } from 'ws';
3
- import { Awareness } from 'y-protocols/awareness';
4
- import * as Y from 'yjs';
5
- import { CloseEvent } from '@hocuspocus/common';
6
- import { IncomingMessage } from './IncomingMessage.js';
7
- import { OutgoingMessage } from './OutgoingMessage.js';
8
- import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js';
9
- import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js';
10
- import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js';
11
- import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js';
12
- import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js';
13
- import { UpdateMessage } from './OutgoingMessages/UpdateMessage.js';
3
+ import type { Awareness } from 'y-protocols/awareness';
4
+ import type * as Y from 'yjs';
5
+ import type { CloseEvent } from '@hocuspocus/common';
6
+ import type { IncomingMessage } from './IncomingMessage.js';
7
+ import type { OutgoingMessage } from './OutgoingMessage.js';
8
+ import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js';
9
+ import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js';
10
+ import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js';
11
+ import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js';
12
+ import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js';
13
+ import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.js';
14
14
  export declare enum MessageType {
15
15
  Sync = 0,
16
16
  Awareness = 1,
@@ -1,10 +1,11 @@
1
1
  /// <reference types="node" />
2
- import { IncomingMessage } from 'http';
3
- import WebSocket from 'ws';
4
- import { Debugger } from './Debugger.js';
5
- import Document from './Document.js';
6
- import { Hocuspocus } from './Hocuspocus.js';
7
- import { onDisconnectPayload } from './types.js';
2
+ /// <reference types="node" />
3
+ import type { IncomingMessage } from 'http';
4
+ import { type CloseEvent } from '@hocuspocus/common';
5
+ import type WebSocket from 'ws';
6
+ import type Document from './Document.js';
7
+ import type { Hocuspocus } from './Hocuspocus.js';
8
+ import type { onDisconnectPayload } from './types.js';
8
9
  /**
9
10
  * The `ClientConnection` class is responsible for handling an incoming WebSocket
10
11
  *
@@ -16,7 +17,6 @@ export declare class ClientConnection {
16
17
  private readonly request;
17
18
  private readonly documentProvider;
18
19
  private readonly hooks;
19
- private readonly debuggerTool;
20
20
  private readonly opts;
21
21
  private readonly defaultContext;
22
22
  private readonly documentConnections;
@@ -24,8 +24,10 @@ export declare class ClientConnection {
24
24
  private readonly documentConnectionsEstablished;
25
25
  private readonly hookPayloads;
26
26
  private readonly callbacks;
27
- private readonly closeIdleConnectionTimeout;
28
27
  private readonly socketId;
28
+ timeout: number;
29
+ pingInterval: NodeJS.Timeout;
30
+ pongReceived: boolean;
29
31
  /**
30
32
  * The `ClientConnection` class receives incoming WebSocket connections,
31
33
  * runs all hooks:
@@ -38,10 +40,17 @@ export declare class ClientConnection {
38
40
  */
39
41
  constructor(websocket: WebSocket, request: IncomingMessage, documentProvider: {
40
42
  createDocument: Hocuspocus['createDocument'];
41
- }, hooks: Hocuspocus['hooks'], debuggerTool: Debugger, opts: {
42
- requiresAuthentication: boolean;
43
+ }, hooks: Hocuspocus['hooks'], opts: {
43
44
  timeout: number;
44
45
  }, defaultContext?: any);
46
+ private handleWebsocketClose;
47
+ close(event?: CloseEvent): void;
48
+ handlePong: () => void;
49
+ /**
50
+ * Check if pong was received and close the connection otherwise
51
+ * @private
52
+ */
53
+ private check;
45
54
  /**
46
55
  * Set a callback that will be triggered when the connection is closed
47
56
  */
@@ -1,32 +1,21 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { IncomingMessage as HTTPIncomingMessage } from 'http';
4
- import AsyncLock from 'async-lock';
5
- import WebSocket from 'ws';
6
- import { CloseEvent } from '@hocuspocus/common';
7
- import Document from './Document.js';
8
- import { Debugger } from './Debugger.js';
9
- import { onStatelessPayload } from './types.js';
2
+ import type { IncomingMessage as HTTPIncomingMessage } from 'http';
3
+ import type WebSocket from 'ws';
4
+ import { type CloseEvent } from '@hocuspocus/common';
5
+ import type Document from './Document.js';
6
+ import type { onStatelessPayload } from './types.js';
10
7
  export declare class Connection {
11
8
  webSocket: WebSocket;
12
9
  context: any;
13
10
  document: Document;
14
- pingInterval: NodeJS.Timeout;
15
- pongReceived: boolean;
16
11
  request: HTTPIncomingMessage;
17
- timeout: number;
18
12
  callbacks: any;
19
13
  socketId: string;
20
- lock: AsyncLock;
21
- readOnly: Boolean;
22
- logger: Debugger;
14
+ readOnly: boolean;
23
15
  /**
24
16
  * Constructor.
25
17
  */
26
- constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, timeout: number, socketId: string, context: any, readOnly: boolean | undefined, logger: Debugger);
27
- boundClose: (event?: CloseEvent) => void;
28
- boundHandlePong: () => void;
29
- handlePong(): void;
18
+ constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, socketId: string, context: any, readOnly?: boolean);
30
19
  /**
31
20
  * Set a callback that will be triggered when the connection is closed
32
21
  */
@@ -51,11 +40,6 @@ export declare class Connection {
51
40
  * Graceful wrapper around the WebSocket close method.
52
41
  */
53
42
  close(event?: CloseEvent): void;
54
- /**
55
- * Check if pong was received and close the connection otherwise
56
- * @private
57
- */
58
- private check;
59
43
  /**
60
44
  * Send the current document awareness to the client, if any
61
45
  * @private
@@ -1,4 +1,4 @@
1
- import Document from './Document.js';
1
+ import type Document from './Document.js';
2
2
  import type { Hocuspocus } from './Hocuspocus.js';
3
3
  import type { DirectConnection as DirectConnectionInterface } from './types.js';
4
4
  export declare class DirectConnection implements DirectConnectionInterface {
@@ -9,6 +9,6 @@ export declare class DirectConnection implements DirectConnectionInterface {
9
9
  * Constructor.
10
10
  */
11
11
  constructor(document: Document, instance: Hocuspocus, context?: any);
12
- transact(transaction: (document: Document) => void, transactionOrigin?: any): Promise<void>;
12
+ transact(transaction: (document: Document) => void): Promise<void>;
13
13
  disconnect(): Promise<void>;
14
14
  }
@@ -1,9 +1,7 @@
1
- import WebSocket from 'ws';
1
+ import type WebSocket from 'ws';
2
2
  import { Awareness } from 'y-protocols/awareness';
3
3
  import { Doc } from 'yjs';
4
- import { mutex } from 'lib0/mutex.js';
5
- import Connection from './Connection.js';
6
- import { Debugger } from './Debugger.js';
4
+ import type Connection from './Connection.js';
7
5
  export declare class Document extends Doc {
8
6
  awareness: Awareness;
9
7
  callbacks: {
@@ -16,14 +14,12 @@ export declare class Document extends Doc {
16
14
  }>;
17
15
  directConnectionsCount: number;
18
16
  name: string;
19
- mux: mutex;
20
- logger?: Debugger;
21
17
  isLoading: boolean;
22
18
  isDestroyed: boolean;
23
19
  /**
24
20
  * Constructor.
25
21
  */
26
- constructor(name: string, logger?: Debugger, yDocOptions?: {});
22
+ constructor(name: string, yDocOptions?: object);
27
23
  /**
28
24
  * Check if the Document (XMLFragment or Map) is empty
29
25
  */