@arbidocs/coedit 0.5.29 → 0.5.31

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.cjs CHANGED
@@ -539,10 +539,6 @@ function serializeLive(el, scope) {
539
539
 
540
540
  // src/encoding.ts
541
541
  var COLLAB_FORMAT = "arbi-docx/2";
542
- var READABLE_FORMATS = /* @__PURE__ */ new Set(["arbi-docx/1", COLLAB_FORMAT]);
543
- function isReadableFormat(format) {
544
- return format !== void 0 && READABLE_FORMATS.has(format);
545
- }
546
542
  function isBootstrapped(doc) {
547
543
  return doc.getMap("meta").get("format") !== void 0;
548
544
  }
@@ -1583,7 +1579,7 @@ var DocxCollaborationSession = class {
1583
1579
  this.setStatus("error", "not-initialized");
1584
1580
  return;
1585
1581
  }
1586
- if (!isReadableFormat(readFormat(this.doc))) {
1582
+ if (readFormat(this.doc) !== COLLAB_FORMAT) {
1587
1583
  this.setStatus("error", "collaboration-format-mismatch", readFormat(this.doc));
1588
1584
  return;
1589
1585
  }
@@ -1871,6 +1867,13 @@ var DOCUMENT_COLLABORATION_VERSIONS = {
1871
1867
  format: COLLAB_FORMAT,
1872
1868
  protocol: COLLAB_PROTOCOL
1873
1869
  };
1870
+ var FORMAT_REFUSAL = "collaboration-format:";
1871
+ var formatNumber = (format) => Number(format.split("/").pop());
1872
+ function formatRefusal(reason) {
1873
+ if (!reason?.startsWith(FORMAT_REFUSAL)) return null;
1874
+ const server = reason.slice(FORMAT_REFUSAL.length);
1875
+ return { serverNewer: formatNumber(server) > formatNumber(COLLAB_FORMAT) };
1876
+ }
1874
1877
 
1875
1878
  // src/module.ts
1876
1879
  function collaborationModule(options) {
@@ -1882,7 +1885,9 @@ exports.COLLAB_PROTOCOL = COLLAB_PROTOCOL;
1882
1885
  exports.CollaborationSessionError = CollaborationSessionError;
1883
1886
  exports.DOCUMENT_COLLABORATION_VERSIONS = DOCUMENT_COLLABORATION_VERSIONS;
1884
1887
  exports.DocxCollaborationSession = DocxCollaborationSession;
1888
+ exports.FORMAT_REFUSAL = FORMAT_REFUSAL;
1885
1889
  exports.MaterializeError = MaterializeError;
1886
1890
  exports.collaborationModule = collaborationModule;
1891
+ exports.formatRefusal = formatRefusal;
1887
1892
  //# sourceMappingURL=index.cjs.map
1888
1893
  //# sourceMappingURL=index.cjs.map