diff --git a/package.json b/package.json index cb39e534..5137c067 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ }, "homepage": "https://docs.yjs.dev", "dependencies": { - "lib0": "^1.0.0-rc.5" + "lib0": "^1.0.0-rc.7" }, "devDependencies": { "@types/node": "^22.14.1", diff --git a/src/index.js b/src/index.js index d81bc5e8..97d9f447 100644 --- a/src/index.js +++ b/src/index.js @@ -122,7 +122,10 @@ export { intersectUpdateWithContentIds, intersectUpdateWithContentIdsV2, createDocFromUpdate, - createDocFromUpdateV2 + createDocFromUpdateV2, + $ytype, + $ytypeAny, + $attributionManager } from './internals.js' export * from './utils/meta.js' diff --git a/src/utils/AttributionManager.js b/src/utils/AttributionManager.js index d7500fc8..aecd42ed 100644 --- a/src/utils/AttributionManager.js +++ b/src/utils/AttributionManager.js @@ -143,6 +143,8 @@ export class AbstractAttributionManager extends ObservableV2 { } } +export const $attributionManager = AbstractAttributionManager.prototype.$type = s.$type('y:am', AbstractAttributionManager) + /** * @implements AbstractAttributionManager * @@ -159,6 +161,8 @@ export class TwosetAttributionManager extends ObservableV2 { this.deletes = deletes } + get $type () { return $attributionManager } + /** * @param {Array>} contents - where to write the result * @param {number} client @@ -204,6 +208,8 @@ export class TwosetAttributionManager extends ObservableV2 { * @extends {ObservableV2<{change:(idset:IdSet,origin:any,local:boolean)=>void}>} */ export class NoAttributionsManager extends ObservableV2 { + get $type () { return $attributionManager } + /** * @param {Array>} contents - where to write the result * @param {number} _client @@ -449,6 +455,8 @@ export class DiffAttributionManager extends ObservableV2 { prevDoc.on('destroy', this._destroyHandler) } + get $type () { return $attributionManager } + destroy () { super.destroy() this._nextDoc.off('destroy', this._destroyHandler) @@ -602,6 +610,8 @@ export class SnapshotAttributionManager extends ObservableV2 { this.attrs = mergeIdMaps([diffIdMap(inserts, prevSnapshot.ds), deletes]) } + get $type () { return $attributionManager } + /** * @param {Array>} contents - where to write the result * @param {number} client diff --git a/src/ytype.js b/src/ytype.js index ef98d0ef..bac8c382 100644 --- a/src/ytype.js +++ b/src/ytype.js @@ -23,7 +23,6 @@ import { } from './internals.js' import * as contentType from './structs/ContentType.js' - import * as traits from 'lib0/traits' import * as delta from 'lib0/delta' import * as array from 'lib0/array' @@ -1437,6 +1436,14 @@ export class YType { } } +/** + * @template {import('lib0/delta').ReadableDeltaConf} DConf + * @param {DConf} _dconf + * @return {s.Schema>>} + */ +export const $ytype = _dconf => s.$instanceOf(YType) +export const $ytypeAny = s.$instanceOf(YType) + /** * @param {import('./utils/UpdateDecoder.js').UpdateDecoderV1 | import('./utils/UpdateDecoder.js').UpdateDecoderV2} decoder * @return {YType} diff --git a/tests/snapshot.tests.js b/tests/snapshot.tests.js index d64205ee..501de1c3 100644 --- a/tests/snapshot.tests.js +++ b/tests/snapshot.tests.js @@ -232,7 +232,8 @@ export const testContainsUpdate = _tc => { * @param {t.TestCase} _tc */ export const testContainsUpdate2 = _tc => { - const local = new Y.Doc(), remote = new Y.Doc() + const local = new Y.Doc() + const remote = new Y.Doc() local.get('t').insert(0, 'abcdefghij') local.get('t').delete(0, 3) Y.applyUpdate(remote, Y.encodeStateAsUpdate(local))