superdoc 2.12.1-next.3 → 2.13.0-next.10

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 (41) hide show
  1. package/dist/chunks/{create-super-doc-ui-BWWWNPP8.cjs → create-super-doc-ui-mHK2pqj3.cjs} +3 -1
  2. package/dist/chunks/{create-super-doc-ui-FnwgTkUv.es.js → create-super-doc-ui-u1giSvlm.es.js} +3 -1
  3. package/dist/collaboration-upgrade-engine.cjs +1 -1
  4. package/dist/collaboration-upgrade-engine.es.js +1 -1
  5. package/dist/document-api/src/blocks/blocks.d.ts +3 -1
  6. package/dist/document-api/src/blocks/find-text.d.ts +3 -0
  7. package/dist/document-api/src/content-controls/content-controls.types.d.ts +1 -1
  8. package/dist/document-api/src/contract/command-catalog.d.ts +1 -1
  9. package/dist/document-api/src/contract/operation-definitions.d.ts +11 -1
  10. package/dist/document-api/src/contract/operation-registry.d.ts +7 -2
  11. package/dist/document-api/src/index.d.ts +7 -6
  12. package/dist/document-api/src/invoke/invoke.d.ts +2 -1
  13. package/dist/document-api/src/types/blocks.types.d.ts +38 -0
  14. package/dist/document-api/src/types/mutation-plan.types.d.ts +28 -4
  15. package/dist/document-api/src/types/table-operations.types.d.ts +2 -0
  16. package/dist/layout-engine/dom-contract/src/data-attrs.d.ts +3 -0
  17. package/dist/layout-engine/painters/dom/src/page-content.d.ts +3 -2
  18. package/dist/layout-engine/painters/dom/src/renderer.d.ts +1 -0
  19. package/dist/public/collaboration-worker.cjs +9 -0
  20. package/dist/public/collaboration-worker.es.js +8 -0
  21. package/dist/public/ui-react.cjs +1 -1
  22. package/dist/public/ui-react.es.js +1 -1
  23. package/dist/public/ui-vue.cjs +1 -1
  24. package/dist/public/ui-vue.es.js +1 -1
  25. package/dist/public/ui.cjs +1 -1
  26. package/dist/public/ui.es.js +1 -1
  27. package/dist/style.css +26 -26
  28. package/dist/style.layered.css +26 -26
  29. package/dist/superdoc/src/core/collaboration/collaboration-exception.d.ts +2 -0
  30. package/dist/superdoc/src/core/collaboration/resolve-v2-collaboration-target.d.ts +16 -5
  31. package/dist/superdoc/src/core/types/index.d.ts +58 -41
  32. package/dist/superdoc/src/public/collaboration-worker.d.cts +18 -0
  33. package/dist/superdoc/src/public/collaboration-worker.d.ts +48 -0
  34. package/dist/superdoc/src/public/index.d.cts +4 -0
  35. package/dist/superdoc/src/public/index.d.ts +2 -0
  36. package/dist/superdoc.cjs +350 -238
  37. package/dist/superdoc.es.js +350 -238
  38. package/dist-cdn/style.layered.css +1 -1
  39. package/dist-cdn/superdoc.min.css +1 -1
  40. package/dist-cdn/superdoc.min.js +35 -35
  41. package/package.json +13 -2
package/dist/style.css CHANGED
@@ -1818,11 +1818,11 @@ img[data-v-c95b2073] {
1818
1818
  pointer-events: auto;
1819
1819
  }
1820
1820
 
1821
- .superdoc[data-v-770204b4] {
1821
+ .superdoc[data-v-ebe9a1fb] {
1822
1822
  display: flex;
1823
1823
  position: relative;
1824
1824
  }
1825
- .sd-visually-hidden[data-v-770204b4] {
1825
+ .sd-visually-hidden[data-v-ebe9a1fb] {
1826
1826
  position: absolute;
1827
1827
  width: 1px;
1828
1828
  height: 1px;
@@ -1833,14 +1833,14 @@ img[data-v-c95b2073] {
1833
1833
  white-space: nowrap;
1834
1834
  border: 0;
1835
1835
  }
1836
- .superdoc__mutation-status[data-v-770204b4] {
1836
+ .superdoc__mutation-status[data-v-ebe9a1fb] {
1837
1837
  position: sticky;
1838
1838
  z-index: 10;
1839
1839
  top: 12px;
1840
1840
  height: 0;
1841
1841
  pointer-events: none;
1842
1842
  }
1843
- .superdoc__edit-rejected-status[data-v-770204b4] {
1843
+ .superdoc__edit-rejected-status[data-v-ebe9a1fb] {
1844
1844
  position: absolute;
1845
1845
  top: 0;
1846
1846
  left: 50%;
@@ -1858,30 +1858,30 @@ img[data-v-c95b2073] {
1858
1858
  line-height: 20px;
1859
1859
  pointer-events: none;
1860
1860
  }
1861
- .right-sidebar[data-v-770204b4] {
1861
+ .right-sidebar[data-v-ebe9a1fb] {
1862
1862
  min-width: 320px;
1863
1863
  height: 100%;
1864
1864
  }
1865
- .floating-comments[data-v-770204b4] {
1865
+ .floating-comments[data-v-ebe9a1fb] {
1866
1866
  min-width: 300px;
1867
1867
  width: 300px;
1868
1868
  height: 100%;
1869
1869
  overflow: visible;
1870
1870
  }
1871
- .superdoc__layers[data-v-770204b4] {
1871
+ .superdoc__layers[data-v-ebe9a1fb] {
1872
1872
  height: 100%;
1873
1873
  position: relative;
1874
1874
  box-sizing: border-box;
1875
1875
  }
1876
- .superdoc__document[data-v-770204b4] {
1876
+ .superdoc__document[data-v-ebe9a1fb] {
1877
1877
  width: 100%;
1878
1878
  position: relative;
1879
1879
  }
1880
- .superdoc__sub-document[data-v-770204b4] {
1880
+ .superdoc__sub-document[data-v-ebe9a1fb] {
1881
1881
  width: 100%;
1882
1882
  position: relative;
1883
1883
  }
1884
- .superdoc__selection-layer[data-v-770204b4] {
1884
+ .superdoc__selection-layer[data-v-ebe9a1fb] {
1885
1885
  position: absolute;
1886
1886
  min-width: 100%;
1887
1887
  min-height: 100%;
@@ -1892,13 +1892,13 @@ img[data-v-c95b2073] {
1892
1892
  /* SD-3497: PDF whiteboard overlay sits above the rendered PDF canvas but below
1893
1893
  the PDF comment anchors (z-index 6 in PdfCommentsLayer) so anchors stay
1894
1894
  clickable, and below the selection layer (z-index 10). */
1895
- .superdoc__whiteboard-layer[data-v-770204b4] {
1895
+ .superdoc__whiteboard-layer[data-v-ebe9a1fb] {
1896
1896
  z-index: 4;
1897
1897
  }
1898
- .superdoc__temp-selection[data-v-770204b4] {
1898
+ .superdoc__temp-selection[data-v-ebe9a1fb] {
1899
1899
  position: absolute;
1900
1900
  }
1901
- .superdoc__right-sidebar[data-v-770204b4] {
1901
+ .superdoc__right-sidebar[data-v-ebe9a1fb] {
1902
1902
  width: 320px;
1903
1903
  min-width: 320px;
1904
1904
  padding: 0 10px;
@@ -1906,7 +1906,7 @@ img[data-v-c95b2073] {
1906
1906
  position: relative;
1907
1907
  z-index: 2;
1908
1908
  }
1909
- .superdoc__compact-comment-popover[data-v-770204b4] {
1909
+ .superdoc__compact-comment-popover[data-v-ebe9a1fb] {
1910
1910
  position: absolute;
1911
1911
  top: 12px;
1912
1912
  right: 12px;
@@ -1915,14 +1915,14 @@ img[data-v-c95b2073] {
1915
1915
  }
1916
1916
 
1917
1917
  /* Tools styles */
1918
- .tools[data-v-770204b4] {
1918
+ .tools[data-v-ebe9a1fb] {
1919
1919
  position: absolute;
1920
1920
  z-index: 3;
1921
1921
  display: flex;
1922
1922
  flex-direction: column;
1923
1923
  gap: var(--sd-ui-tools-gap, 6px);
1924
1924
  }
1925
- .tools-item[data-v-770204b4] {
1925
+ .tools-item[data-v-ebe9a1fb] {
1926
1926
  display: flex;
1927
1927
  align-items: center;
1928
1928
  justify-content: center;
@@ -1933,10 +1933,10 @@ img[data-v-c95b2073] {
1933
1933
  cursor: pointer;
1934
1934
  position: relative;
1935
1935
  }
1936
- .tools-item i[data-v-770204b4] {
1936
+ .tools-item i[data-v-ebe9a1fb] {
1937
1937
  cursor: pointer;
1938
1938
  }
1939
- .superdoc__tools-icon[data-v-770204b4] {
1939
+ .superdoc__tools-icon[data-v-ebe9a1fb] {
1940
1940
  width: var(--sd-ui-tools-icon-size, 20px);
1941
1941
  height: var(--sd-ui-tools-icon-size, 20px);
1942
1942
  flex-shrink: 0;
@@ -1951,22 +1951,22 @@ img[data-v-c95b2073] {
1951
1951
 
1952
1952
  /* 834px is iPad screen size in portrait orientation */
1953
1953
  @media (max-width: 834px) {
1954
- .superdoc .superdoc__layers[data-v-770204b4] {
1954
+ .superdoc .superdoc__layers[data-v-ebe9a1fb] {
1955
1955
  margin: 0;
1956
1956
  border: 0 !important;
1957
1957
  box-shadow: none;
1958
1958
  }
1959
- .superdoc__sub-document[data-v-770204b4] {
1959
+ .superdoc__sub-document[data-v-ebe9a1fb] {
1960
1960
  max-width: 100%;
1961
1961
  }
1962
- .superdoc__right-sidebar[data-v-770204b4] {
1962
+ .superdoc__right-sidebar[data-v-ebe9a1fb] {
1963
1963
  padding: 10px;
1964
1964
  position: relative;
1965
1965
  }
1966
1966
  }
1967
1967
 
1968
1968
  /* AI Writer styles */
1969
- .ai-writer-container[data-v-770204b4] {
1969
+ .ai-writer-container[data-v-ebe9a1fb] {
1970
1970
  position: fixed;
1971
1971
  z-index: 1000;
1972
1972
  background: white;
@@ -1982,10 +1982,10 @@ img[data-v-c95b2073] {
1982
1982
  transform: translateY(-50%);
1983
1983
  z-index: 50;
1984
1984
  } */
1985
- .ai-tool > svg[data-v-770204b4] {
1985
+ .ai-tool > svg[data-v-ebe9a1fb] {
1986
1986
  fill: transparent;
1987
1987
  }
1988
- .ai-tool[data-v-770204b4]::before {
1988
+ .ai-tool[data-v-ebe9a1fb]::before {
1989
1989
  content: '';
1990
1990
  position: absolute;
1991
1991
  width: 20px;
@@ -2006,7 +2006,7 @@ img[data-v-c95b2073] {
2006
2006
  filter: brightness(1.2);
2007
2007
  transition: filter 0.2s ease;
2008
2008
  }
2009
- .ai-tool[data-v-770204b4]:hover::before {
2009
+ .ai-tool[data-v-ebe9a1fb]:hover::before {
2010
2010
  filter: brightness(1.3);
2011
2011
  }
2012
2012
 
@@ -2359,7 +2359,7 @@ img[data-v-c95b2073] {
2359
2359
  transform: scale(1);
2360
2360
  }
2361
2361
 
2362
- .superdoc-toolbar-overflow[data-v-975959f9] {
2362
+ .superdoc-toolbar-overflow[data-v-5f8ee279] {
2363
2363
  min-width: auto !important;
2364
2364
  max-width: 200px;
2365
2365
  flex-wrap: wrap;
@@ -1818,11 +1818,11 @@ img[data-v-c95b2073] {
1818
1818
  pointer-events: auto;
1819
1819
  }
1820
1820
 
1821
- .superdoc[data-v-770204b4] {
1821
+ .superdoc[data-v-ebe9a1fb] {
1822
1822
  display: flex;
1823
1823
  position: relative;
1824
1824
  }
1825
- .sd-visually-hidden[data-v-770204b4] {
1825
+ .sd-visually-hidden[data-v-ebe9a1fb] {
1826
1826
  position: absolute;
1827
1827
  width: 1px;
1828
1828
  height: 1px;
@@ -1833,14 +1833,14 @@ img[data-v-c95b2073] {
1833
1833
  white-space: nowrap;
1834
1834
  border: 0;
1835
1835
  }
1836
- .superdoc__mutation-status[data-v-770204b4] {
1836
+ .superdoc__mutation-status[data-v-ebe9a1fb] {
1837
1837
  position: sticky;
1838
1838
  z-index: 10;
1839
1839
  top: 12px;
1840
1840
  height: 0;
1841
1841
  pointer-events: none;
1842
1842
  }
1843
- .superdoc__edit-rejected-status[data-v-770204b4] {
1843
+ .superdoc__edit-rejected-status[data-v-ebe9a1fb] {
1844
1844
  position: absolute;
1845
1845
  top: 0;
1846
1846
  left: 50%;
@@ -1858,30 +1858,30 @@ img[data-v-c95b2073] {
1858
1858
  line-height: 20px;
1859
1859
  pointer-events: none;
1860
1860
  }
1861
- .right-sidebar[data-v-770204b4] {
1861
+ .right-sidebar[data-v-ebe9a1fb] {
1862
1862
  min-width: 320px;
1863
1863
  height: 100%;
1864
1864
  }
1865
- .floating-comments[data-v-770204b4] {
1865
+ .floating-comments[data-v-ebe9a1fb] {
1866
1866
  min-width: 300px;
1867
1867
  width: 300px;
1868
1868
  height: 100%;
1869
1869
  overflow: visible;
1870
1870
  }
1871
- .superdoc__layers[data-v-770204b4] {
1871
+ .superdoc__layers[data-v-ebe9a1fb] {
1872
1872
  height: 100%;
1873
1873
  position: relative;
1874
1874
  box-sizing: border-box;
1875
1875
  }
1876
- .superdoc__document[data-v-770204b4] {
1876
+ .superdoc__document[data-v-ebe9a1fb] {
1877
1877
  width: 100%;
1878
1878
  position: relative;
1879
1879
  }
1880
- .superdoc__sub-document[data-v-770204b4] {
1880
+ .superdoc__sub-document[data-v-ebe9a1fb] {
1881
1881
  width: 100%;
1882
1882
  position: relative;
1883
1883
  }
1884
- .superdoc__selection-layer[data-v-770204b4] {
1884
+ .superdoc__selection-layer[data-v-ebe9a1fb] {
1885
1885
  position: absolute;
1886
1886
  min-width: 100%;
1887
1887
  min-height: 100%;
@@ -1892,13 +1892,13 @@ img[data-v-c95b2073] {
1892
1892
  /* SD-3497: PDF whiteboard overlay sits above the rendered PDF canvas but below
1893
1893
  the PDF comment anchors (z-index 6 in PdfCommentsLayer) so anchors stay
1894
1894
  clickable, and below the selection layer (z-index 10). */
1895
- .superdoc__whiteboard-layer[data-v-770204b4] {
1895
+ .superdoc__whiteboard-layer[data-v-ebe9a1fb] {
1896
1896
  z-index: 4;
1897
1897
  }
1898
- .superdoc__temp-selection[data-v-770204b4] {
1898
+ .superdoc__temp-selection[data-v-ebe9a1fb] {
1899
1899
  position: absolute;
1900
1900
  }
1901
- .superdoc__right-sidebar[data-v-770204b4] {
1901
+ .superdoc__right-sidebar[data-v-ebe9a1fb] {
1902
1902
  width: 320px;
1903
1903
  min-width: 320px;
1904
1904
  padding: 0 10px;
@@ -1906,7 +1906,7 @@ img[data-v-c95b2073] {
1906
1906
  position: relative;
1907
1907
  z-index: 2;
1908
1908
  }
1909
- .superdoc__compact-comment-popover[data-v-770204b4] {
1909
+ .superdoc__compact-comment-popover[data-v-ebe9a1fb] {
1910
1910
  position: absolute;
1911
1911
  top: 12px;
1912
1912
  right: 12px;
@@ -1915,14 +1915,14 @@ img[data-v-c95b2073] {
1915
1915
  }
1916
1916
 
1917
1917
  /* Tools styles */
1918
- .tools[data-v-770204b4] {
1918
+ .tools[data-v-ebe9a1fb] {
1919
1919
  position: absolute;
1920
1920
  z-index: 3;
1921
1921
  display: flex;
1922
1922
  flex-direction: column;
1923
1923
  gap: var(--sd-ui-tools-gap, 6px);
1924
1924
  }
1925
- .tools-item[data-v-770204b4] {
1925
+ .tools-item[data-v-ebe9a1fb] {
1926
1926
  display: flex;
1927
1927
  align-items: center;
1928
1928
  justify-content: center;
@@ -1933,10 +1933,10 @@ img[data-v-c95b2073] {
1933
1933
  cursor: pointer;
1934
1934
  position: relative;
1935
1935
  }
1936
- .tools-item i[data-v-770204b4] {
1936
+ .tools-item i[data-v-ebe9a1fb] {
1937
1937
  cursor: pointer;
1938
1938
  }
1939
- .superdoc__tools-icon[data-v-770204b4] {
1939
+ .superdoc__tools-icon[data-v-ebe9a1fb] {
1940
1940
  width: var(--sd-ui-tools-icon-size, 20px);
1941
1941
  height: var(--sd-ui-tools-icon-size, 20px);
1942
1942
  flex-shrink: 0;
@@ -1951,22 +1951,22 @@ img[data-v-c95b2073] {
1951
1951
 
1952
1952
  /* 834px is iPad screen size in portrait orientation */
1953
1953
  @media (max-width: 834px) {
1954
- .superdoc .superdoc__layers[data-v-770204b4] {
1954
+ .superdoc .superdoc__layers[data-v-ebe9a1fb] {
1955
1955
  margin: 0;
1956
1956
  border: 0 !important;
1957
1957
  box-shadow: none;
1958
1958
  }
1959
- .superdoc__sub-document[data-v-770204b4] {
1959
+ .superdoc__sub-document[data-v-ebe9a1fb] {
1960
1960
  max-width: 100%;
1961
1961
  }
1962
- .superdoc__right-sidebar[data-v-770204b4] {
1962
+ .superdoc__right-sidebar[data-v-ebe9a1fb] {
1963
1963
  padding: 10px;
1964
1964
  position: relative;
1965
1965
  }
1966
1966
  }
1967
1967
 
1968
1968
  /* AI Writer styles */
1969
- .ai-writer-container[data-v-770204b4] {
1969
+ .ai-writer-container[data-v-ebe9a1fb] {
1970
1970
  position: fixed;
1971
1971
  z-index: 1000;
1972
1972
  background: white;
@@ -1982,10 +1982,10 @@ img[data-v-c95b2073] {
1982
1982
  transform: translateY(-50%);
1983
1983
  z-index: 50;
1984
1984
  } */
1985
- .ai-tool > svg[data-v-770204b4] {
1985
+ .ai-tool > svg[data-v-ebe9a1fb] {
1986
1986
  fill: transparent;
1987
1987
  }
1988
- .ai-tool[data-v-770204b4]::before {
1988
+ .ai-tool[data-v-ebe9a1fb]::before {
1989
1989
  content: '';
1990
1990
  position: absolute;
1991
1991
  width: 20px;
@@ -2006,7 +2006,7 @@ img[data-v-c95b2073] {
2006
2006
  filter: brightness(1.2);
2007
2007
  transition: filter 0.2s ease;
2008
2008
  }
2009
- .ai-tool[data-v-770204b4]:hover::before {
2009
+ .ai-tool[data-v-ebe9a1fb]:hover::before {
2010
2010
  filter: brightness(1.3);
2011
2011
  }
2012
2012
 
@@ -2359,7 +2359,7 @@ img[data-v-c95b2073] {
2359
2359
  transform: scale(1);
2360
2360
  }
2361
2361
 
2362
- .superdoc-toolbar-overflow[data-v-975959f9] {
2362
+ .superdoc-toolbar-overflow[data-v-5f8ee279] {
2363
2363
  min-width: auto !important;
2364
2364
  max-width: 200px;
2365
2365
  flex-wrap: wrap;
@@ -0,0 +1,2 @@
1
+ import { SuperDocExceptionCollaborationPayload } from '../types/index.js';
2
+ export declare function createCollaborationException(code: string, documentId: string | null): SuperDocExceptionCollaborationPayload | null;
@@ -7,20 +7,20 @@
7
7
  * first-class single-doc provider families — y-websocket, Hocuspocus, and
8
8
  * Liveblocks — each bound to one `Y.Doc`, one provider session, and one
9
9
  * awareness channel (implemented inside the bundled v2 runtime) and surfaced
10
- * publicly through {@link V2CollaborationConfig} (`Document.v2Collaboration`).
10
+ * publicly through {@link DocumentCollaborationConfig} (`Document.collaboration`).
11
11
  *
12
12
  * The resolver never returns a "maybe collaborative" result: it either returns
13
13
  * a normalized, supported target or a stable, redacted diagnostic. Tokens, auth
14
14
  * keys, auth endpoints, and query strings are never echoed back in diagnostics.
15
15
  */
16
16
  /** Provider families the shipped v2 single-doc runtime can drive. */
17
- export type SupportedV2ProviderFamily = 'y-websocket' | 'hocuspocus' | 'liveblocks';
17
+ export type SupportedV2ProviderFamily = 'y-websocket' | 'hocuspocus' | 'liveblocks' | 'extension';
18
18
  /**
19
19
  * Stable, machine-readable reasons a target cannot be treated as a supported v2
20
20
  * collaboration room. These strings are part of the diagnostic contract and are
21
21
  * safe to assert against in tests; they never carry caller-provided values.
22
22
  */
23
- export type V2CollaborationUnsupportedReason = 'missing-target' | 'invalid-document-id' | 'invalid-server-url' | 'invalid-room-mode' | 'invalid-auth-endpoint' | 'missing-auth' | 'mixed-auth' | 'unsupported-document-type' | 'unsupported-multi-document' | 'unsupported-legacy-provider' | 'unsupported-provider-family';
23
+ export type V2CollaborationUnsupportedReason = 'missing-target' | 'invalid-document-id' | 'invalid-server-url' | 'invalid-room-mode' | 'invalid-auth-endpoint' | 'invalid-adapter-id' | 'invalid-provider-options' | 'missing-auth' | 'mixed-auth' | 'unsupported-document-type' | 'unsupported-multi-document' | 'unsupported-legacy-provider' | 'unsupported-provider-family';
24
24
  /**
25
25
  * Normalized, supported v2 collaboration room target.
26
26
  *
@@ -38,11 +38,15 @@ export interface NormalizedV2CollaborationTarget {
38
38
  /** Optional connection query params (e.g. auth token) forwarded verbatim. */
39
39
  params?: Record<string, string>;
40
40
  /** Hocuspocus auth-message token. */
41
- token?: string;
41
+ token?: string | (() => string | Promise<string>);
42
42
  /** Liveblocks anonymous public key auth mode. */
43
43
  publicApiKey?: string;
44
44
  /** Liveblocks server-side auth endpoint mode. */
45
45
  authEndpoint?: string;
46
+ /** Adapter registration key for a customer collaboration Worker. */
47
+ adapterId?: string;
48
+ /** Structured-clone-safe options interpreted by the registered adapter. */
49
+ providerOptions?: unknown;
46
50
  /** Explicit room operation; join is the default at the untrusted input boundary. */
47
51
  roomMode: 'join' | 'create';
48
52
  }
@@ -68,7 +72,9 @@ export interface LegacyCollaborationLike {
68
72
  [key: string]: unknown;
69
73
  }
70
74
  export interface ResolveV2CollaborationTargetInput {
71
- /** Document-level v2 collaboration config (canonical supported entry point). */
75
+ /** Preferred connection settings. Explicit null or invalid input never falls back to the alias. */
76
+ collaboration?: unknown;
77
+ /** Compatibility spelling for document-level connection settings. */
72
78
  v2Collaboration?: unknown;
73
79
  /** Legacy provider-agnostic collaboration block (`modules.collaboration` / upgrade opts). */
74
80
  legacyCollaboration?: LegacyCollaborationLike | null;
@@ -83,6 +89,11 @@ export interface ResolveV2CollaborationTargetInput {
83
89
  */
84
90
  authEndpointBaseUrl?: string;
85
91
  }
92
+ /** Select the public spelling before validation; do not merge settings from different rooms. */
93
+ export declare function readCollaborationConfig(input: {
94
+ collaboration?: unknown;
95
+ v2Collaboration?: unknown;
96
+ }): unknown;
86
97
  /**
87
98
  * Redact a connection URL for safe inclusion in diagnostics and artifacts.
88
99
  *
@@ -591,10 +591,12 @@ export interface CollaborationProvider {
591
591
  off?: (...args: unknown[]) => unknown;
592
592
  disconnect?: () => unknown;
593
593
  destroy?: () => unknown;
594
+ /** Send a provider-specific stateless string payload. */
595
+ sendStateless?: (message: string) => unknown;
594
596
  [key: string]: unknown;
595
597
  }
596
598
  /**
597
- * Document-level v2 collaboration handoff.
599
+ * Connection settings for one shared document, used at startup and during an upgrade.
598
600
  *
599
601
  * This is the public surface for SuperDoc v2's shipped real-time collaboration
600
602
  * model. v2 collaboration is always single-doc: one `Y.Doc`, one provider
@@ -604,18 +606,19 @@ export interface CollaborationProvider {
604
606
  * single-doc provider internally. One `documentId` maps to exactly one
605
607
  * room/provider/root identity.
606
608
  *
607
- * SuperDoc v2 supports three first-class provider families through this field:
608
- * y-websocket, Hocuspocus, and Liveblocks. The provider is selected with
609
- * `providerType`; omitting it preserves the original y-websocket-only shape
610
- * (`{ documentId, serverUrl, params? }`) for backward compatibility.
609
+ * SuperDoc v2 includes y-websocket, Hocuspocus, and Liveblocks adapters and can
610
+ * route a named provider extension through a configured collaboration Worker.
611
+ * The provider is selected with `providerType`; omitting it preserves the
612
+ * original y-websocket-only shape (`{ documentId, serverUrl, params? }`).
611
613
  *
612
614
  * This is intentionally distinct from the legacy provider-agnostic
613
- * {@link CollaborationConfig} (`Config.modules.collaboration`): v2 owns its
614
- * provider internally and does **not** accept an external Yjs `provider`/`ydoc`
615
- * through this field. External `{ ydoc, provider }` remains a v1 /
616
- * provider-compat concern only and is rejected as a v2 content driver.
615
+ * {@link CollaborationConfig} (`Config.modules.collaboration`): v2 owns the
616
+ * Y.Doc. Provider extensions receive that document inside the collaboration
617
+ * Worker instead of replacing it.
617
618
  */
618
- export type V2CollaborationConfig = V2YWebsocketCollaborationConfig | V2HocuspocusCollaborationConfig | V2LiveblocksCollaborationConfig;
619
+ export type DocumentCollaborationConfig = V2YWebsocketCollaborationConfig | V2HocuspocusCollaborationConfig | V2LiveblocksCollaborationConfig | V2ProviderExtensionCollaborationConfig;
620
+ /** @deprecated replaceWith=`DocumentCollaborationConfig` compat-indefinitely: existing v2 integrations import this type. */
621
+ export type V2CollaborationConfig = DocumentCollaborationConfig;
619
622
  /**
620
623
  * y-websocket single-doc provider config.
621
624
  *
@@ -653,8 +656,8 @@ export interface V2HocuspocusCollaborationConfig {
653
656
  url?: string;
654
657
  /** Optional connection params forwarded to the backend. */
655
658
  params?: Record<string, string> | null;
656
- /** Auth-message token forwarded to the Hocuspocus backend. */
657
- token?: string;
659
+ /** Static auth token or resolver invoked for every Hocuspocus connection. */
660
+ token?: string | (() => string | Promise<string>);
658
661
  /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
659
662
  roomMode?: 'join' | 'create';
660
663
  }
@@ -681,6 +684,20 @@ export interface V2LiveblocksCollaborationConfig {
681
684
  /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
682
685
  roomMode?: 'join' | 'create';
683
686
  }
687
+ /** Named provider adapter implemented by the configured collaboration Worker. */
688
+ export interface V2ProviderExtensionCollaborationConfig {
689
+ providerType: 'extension';
690
+ /** Adapter registration key understood by the collaboration Worker. */
691
+ adapterId: string;
692
+ /** Stable shared document identity. */
693
+ documentId: string;
694
+ /** Structured-clone-safe options passed to the registered adapter factory. */
695
+ providerOptions?: unknown;
696
+ /** Optional host-owned credential resolver available to the adapter. */
697
+ token?: string | (() => string | Promise<string>);
698
+ /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
699
+ roomMode?: 'join' | 'create';
700
+ }
684
701
  export interface Comment {
685
702
  id?: string;
686
703
  commentId?: string;
@@ -932,29 +949,21 @@ export interface AwarenessUser extends User {
932
949
  }
933
950
  /**
934
951
  * One entry in the `states` array delivered to
935
- * {@link Config.onAwarenessUpdate}. SuperDoc emits an entry per remote
936
- * client, derived from the underlying Yjs awareness states.
952
+ * {@link Config.onAwarenessUpdate}. In V2, `states` includes the current
953
+ * user and remote participants. Do not append the current user again.
937
954
  *
938
- * The runtime helper `awarenessStatesToArray` spreads each remote user
939
- * onto the top of the entry (`{ clientId, ...value.user, color }`), so
940
- * `User` fields like `name`, `email`, `image` appear at the top level
941
- * (not nested under a `user` property). Consumers should read `state.id`,
942
- * `state.name`, and `state.email`, not `state.user.name`.
955
+ * Display fields such as `name`, `email`, and `color` are at the top
956
+ * level, not nested under `user`. Fields may be absent; a presence
957
+ * entry is not an authenticated account record.
943
958
  *
944
959
  * Application-specific fields attached to the awareness state by the
945
960
  * provider surface through the `[key: string]: unknown` index
946
961
  * signature; consumers narrow before use.
947
962
  */
948
963
  export interface AwarenessState extends User {
949
- /** Yjs client identifier for the remote peer. */
964
+ /** Presence identifier. In V2, scoped to this editor instance, not a Yjs transport id. */
950
965
  clientId?: number;
951
- /**
952
- * Color assigned by SuperDoc's presence system. Spread onto the
953
- * awareness entry after the user fields, so it takes precedence
954
- * over any color the awareness user carried in (see
955
- * {@link AwarenessUser.color}). Used when the presence system
956
- * computes a stable palette assignment for the remote peer.
957
- */
966
+ /** Resolved cursor color supplied by the presence system. */
958
967
  color?: string;
959
968
  /** Application-specific fields spread from the awareness provider. */
960
969
  [key: string]: unknown;
@@ -998,12 +1007,11 @@ export interface Document {
998
1007
  */
999
1008
  provider?: CollaborationProvider;
1000
1009
  /**
1001
- * Document-level v2 collaboration handoff. When present, the v2 runtime
1002
- * makes this document collaborative through the shipped single-doc
1003
- * y-websocket provider (one room / Y.Doc / awareness channel per
1004
- * `documentId`). See {@link V2CollaborationConfig}. Ignored by the v1
1005
- * editor, which uses `Config.modules.collaboration` instead.
1010
+ * Connect this document to a shared room. SuperDoc owns the provider and Y.Doc.
1011
+ * Takes precedence over `v2Collaboration`; `null` opens a local document.
1006
1012
  */
1013
+ collaboration?: DocumentCollaborationConfig | null;
1014
+ /** @deprecated replaceWith=`collaboration` compat-indefinitely: existing v2 integrations use this field. */
1007
1015
  v2Collaboration?: V2CollaborationConfig | null;
1008
1016
  }
1009
1017
  type DocumentSourceOptions = Omit<Document, 'data' | 'type' | 'url'>;
@@ -1126,9 +1134,8 @@ export interface CollaborationConfig {
1126
1134
  /**
1127
1135
  * Options for `upgradeToCollaboration()`.
1128
1136
  *
1129
- * v2 promotes a local single-DOCX editor into the shipped single-doc
1130
- * y-websocket room described by {@link V2CollaborationConfig}. Pass a
1131
- * `v2Collaboration` target to promote into a supported v2 room.
1137
+ * Promote a local DOCX into a shared room using `collaboration`.
1138
+ * Supports the same providers as {@link DocumentCollaborationConfig}.
1132
1139
  *
1133
1140
  * The legacy `ydoc` / `provider` fields remain accepted for source
1134
1141
  * compatibility with v1-shaped callers, but v2 does **not** drive document
@@ -1138,14 +1145,15 @@ export interface CollaborationConfig {
1138
1145
  * fields are therefore optional and only honored when they resolve to a
1139
1146
  * supported v2 room.
1140
1147
  *
1141
- * @see {@link V2CollaborationConfig}
1148
+ * @see {@link DocumentCollaborationConfig}
1142
1149
  */
1143
1150
  export interface UpgradeToCollaborationOptions {
1144
1151
  /**
1145
- * Canonical supported v2 promotion target: the single-doc y-websocket room
1146
- * ({ documentId, serverUrl, params? }) to create from the current document.
1147
- * Promotion fails if the v2 room already exists.
1152
+ * Create a shared room from the current document. Fails if the room already exists.
1153
+ * Takes precedence over `v2Collaboration`.
1148
1154
  */
1155
+ collaboration?: DocumentCollaborationConfig;
1156
+ /** @deprecated replaceWith=`collaboration` compat-indefinitely: existing v2 integrations use this field. */
1149
1157
  v2Collaboration?: V2CollaborationConfig;
1150
1158
  /**
1151
1159
  * Legacy external Yjs document. Accepted for v1 source compatibility; not a
@@ -3242,6 +3250,14 @@ export interface SuperDocExceptionEditorPayload {
3242
3250
  /** Structured browser-worker failure detail when editor startup failed in its worker transport. */
3243
3251
  workerFailure?: SuperDocWorkerFailureDetail;
3244
3252
  }
3253
+ /** Connection failure while opening a collaboration room, reported through `onException`. */
3254
+ export interface SuperDocExceptionCollaborationPayload extends SuperDocExceptionEditorPayload {
3255
+ error: Error;
3256
+ code: 'collaboration-access-denied' | 'collaboration-connection-failed' | 'collaboration-sync-timeout';
3257
+ /** Access denial requires an explicit provider rejection; a timeout is not proof of denied access. */
3258
+ collaborationReason: 'access-denied' | 'connection-failed' | 'sync-timeout';
3259
+ editor: null;
3260
+ }
3245
3261
  /**
3246
3262
  * Exception payload raised by the built-in toolbar.
3247
3263
  *
@@ -3311,6 +3327,7 @@ export interface SuperDocExceptionDiagnosticPayload {
3311
3327
  * Consumers can narrow with `'stage' in payload` (store init),
3312
3328
  * `'code' in payload` (editor lifecycle), `'itemName' in payload`
3313
3329
  * (built-in toolbar), `'source' in payload` (hyperlink activation),
3330
+ * `'collaborationReason' in payload` (collaboration connection),
3314
3331
  * or `'diagnosticCode' in payload` (structured diagnostic).
3315
3332
  *
3316
3333
  * The union exists today because multiple independent emit sites pre-date a
@@ -3318,7 +3335,7 @@ export interface SuperDocExceptionDiagnosticPayload {
3318
3335
  * separate follow-up; consumers can narrow with the `in` checks above in the
3319
3336
  * meantime.
3320
3337
  */
3321
- export type SuperDocExceptionPayload = SuperDocExceptionStorePayload | SuperDocExceptionRestorePayload | SuperDocExceptionEditorPayload | SuperDocExceptionToolbarPayload | SuperDocExceptionHyperlinkPayload | SuperDocExceptionDiagnosticPayload;
3338
+ export type SuperDocExceptionPayload = SuperDocExceptionStorePayload | SuperDocExceptionRestorePayload | SuperDocExceptionEditorPayload | SuperDocExceptionCollaborationPayload | SuperDocExceptionToolbarPayload | SuperDocExceptionHyperlinkPayload | SuperDocExceptionDiagnosticPayload;
3322
3339
  /**
3323
3340
  * Zoom mode. `manual` holds whatever value was last set; `fit-width`
3324
3341
  * continuously recomputes the zoom that fits the page width into the
@@ -3827,7 +3844,7 @@ export interface Config {
3827
3844
  role?: 'editor' | 'viewer' | 'suggester';
3828
3845
  /**
3829
3846
  * Document to open. Pass a URL, file, byte source, or structured source.
3830
- * Use a structured document carrying `v2Collaboration` for collaboration,
3847
+ * Use a structured document carrying `collaboration` for collaboration,
3831
3848
  * or a structured source for other metadata. Omit it to open a blank DOCX.
3832
3849
  */
3833
3850
  document?: DocumentSource | null;
@@ -0,0 +1,18 @@
1
+ // Generated by scripts/ensure-types.cjs. Do not edit by hand.
2
+ import type { SuperDocCollaborationProviderAdapter as __Cjs_SuperDocCollaborationProviderAdapter } from './collaboration-worker.js' with { "resolution-mode": "import" };
3
+ import type { SuperDocCollaborationProviderAttachInput as __Cjs_SuperDocCollaborationProviderAttachInput } from './collaboration-worker.js' with { "resolution-mode": "import" };
4
+ import type { SuperDocCollaborationProviderAwareness as __Cjs_SuperDocCollaborationProviderAwareness } from './collaboration-worker.js' with { "resolution-mode": "import" };
5
+ import type { SuperDocCollaborationProviderFactory as __Cjs_SuperDocCollaborationProviderFactory } from './collaboration-worker.js' with { "resolution-mode": "import" };
6
+ import type { SuperDocCollaborationProviderFactoryInput as __Cjs_SuperDocCollaborationProviderFactoryInput } from './collaboration-worker.js' with { "resolution-mode": "import" };
7
+ import type { SuperDocCollaborationProviderFamily as __Cjs_SuperDocCollaborationProviderFamily } from './collaboration-worker.js' with { "resolution-mode": "import" };
8
+ import type { SuperDocCollaborationProviderTransport as __Cjs_SuperDocCollaborationProviderTransport } from './collaboration-worker.js' with { "resolution-mode": "import" };
9
+ import type { SuperDocCollaborationWorkerOptions as __Cjs_SuperDocCollaborationWorkerOptions } from './collaboration-worker.js' with { "resolution-mode": "import" };
10
+ export declare const bootstrapSuperDocCollaborationWorker: typeof import('./collaboration-worker.js', { with: { "resolution-mode": "import" } }).bootstrapSuperDocCollaborationWorker;
11
+ export type { __Cjs_SuperDocCollaborationProviderAdapter as SuperDocCollaborationProviderAdapter };
12
+ export type { __Cjs_SuperDocCollaborationProviderAttachInput as SuperDocCollaborationProviderAttachInput };
13
+ export type { __Cjs_SuperDocCollaborationProviderAwareness as SuperDocCollaborationProviderAwareness };
14
+ export type { __Cjs_SuperDocCollaborationProviderFactory as SuperDocCollaborationProviderFactory };
15
+ export type { __Cjs_SuperDocCollaborationProviderFactoryInput as SuperDocCollaborationProviderFactoryInput };
16
+ export type { __Cjs_SuperDocCollaborationProviderFamily as SuperDocCollaborationProviderFamily };
17
+ export type { __Cjs_SuperDocCollaborationProviderTransport as SuperDocCollaborationProviderTransport };
18
+ export type { __Cjs_SuperDocCollaborationWorkerOptions as SuperDocCollaborationWorkerOptions };