@arbidocs/coedit 0.5.30 → 0.5.32

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.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { COLLAB_FORMAT, MaterializeError } from './encoding.cjs';
2
2
  export { C as CollaborationSessionError, D as DocxCollaborationSession, a as DocxCollaborationSessionOptions } from './session-WGvWs6yO.cjs';
3
- export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS } from './versions-XSYTVmOU.cjs';
3
+ export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS, F as FORMAT_REFUSAL, f as formatRefusal } from './versions-ClPpc7Sg.cjs';
4
4
  import { EditorModule } from '@docx-editor.dev/core';
5
5
  import { EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
6
6
  import '@docx-editor.dev/core/store';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { COLLAB_FORMAT, MaterializeError } from './encoding.js';
2
2
  export { C as CollaborationSessionError, D as DocxCollaborationSession, a as DocxCollaborationSessionOptions } from './session-WGvWs6yO.js';
3
- export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS } from './versions-XSYTVmOU.js';
3
+ export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS, F as FORMAT_REFUSAL, f as formatRefusal } from './versions-ClPpc7Sg.js';
4
4
  import { EditorModule } from '@docx-editor.dev/core';
5
5
  import { EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
6
6
  import '@docx-editor.dev/core/store';
package/dist/index.js CHANGED
@@ -517,10 +517,6 @@ function serializeLive(el, scope) {
517
517
 
518
518
  // src/encoding.ts
519
519
  var COLLAB_FORMAT = "arbi-docx/2";
520
- var READABLE_FORMATS = /* @__PURE__ */ new Set(["arbi-docx/1", COLLAB_FORMAT]);
521
- function isReadableFormat(format) {
522
- return format !== void 0 && READABLE_FORMATS.has(format);
523
- }
524
520
  function isBootstrapped(doc) {
525
521
  return doc.getMap("meta").get("format") !== void 0;
526
522
  }
@@ -1561,7 +1557,7 @@ var DocxCollaborationSession = class {
1561
1557
  this.setStatus("error", "not-initialized");
1562
1558
  return;
1563
1559
  }
1564
- if (!isReadableFormat(readFormat(this.doc))) {
1560
+ if (readFormat(this.doc) !== COLLAB_FORMAT) {
1565
1561
  this.setStatus("error", "collaboration-format-mismatch", readFormat(this.doc));
1566
1562
  return;
1567
1563
  }
@@ -1849,12 +1845,19 @@ var DOCUMENT_COLLABORATION_VERSIONS = {
1849
1845
  format: COLLAB_FORMAT,
1850
1846
  protocol: COLLAB_PROTOCOL
1851
1847
  };
1848
+ var FORMAT_REFUSAL = "collaboration-format:";
1849
+ var formatNumber = (format) => Number(format.split("/").pop());
1850
+ function formatRefusal(reason) {
1851
+ if (!reason?.startsWith(FORMAT_REFUSAL)) return null;
1852
+ const server = reason.slice(FORMAT_REFUSAL.length);
1853
+ return { serverNewer: formatNumber(server) > formatNumber(COLLAB_FORMAT) };
1854
+ }
1852
1855
 
1853
1856
  // src/module.ts
1854
1857
  function collaborationModule(options) {
1855
1858
  return { id: "collaboration", collaboration: { session: options.session } };
1856
1859
  }
1857
1860
 
1858
- export { COLLAB_FORMAT, COLLAB_PROTOCOL, CollaborationSessionError, DOCUMENT_COLLABORATION_VERSIONS, DocxCollaborationSession, MaterializeError, collaborationModule };
1861
+ export { COLLAB_FORMAT, COLLAB_PROTOCOL, CollaborationSessionError, DOCUMENT_COLLABORATION_VERSIONS, DocxCollaborationSession, FORMAT_REFUSAL, MaterializeError, collaborationModule, formatRefusal };
1859
1862
  //# sourceMappingURL=index.js.map
1860
1863
  //# sourceMappingURL=index.js.map