@fluid-experimental/tree 2.0.0-internal.8.0.0 → 2.0.0-rc.1.0.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.
- package/CHANGELOG.md +34 -0
- package/api-extractor-lint.json +1 -10
- package/api-extractor.json +0 -9
- package/api-report/experimental-tree.api.md +131 -130
- package/dist/ChangeTypes.d.ts +15 -15
- package/dist/ChangeTypes.js +4 -4
- package/dist/ChangeTypes.js.map +1 -1
- package/dist/Checkout.d.ts +4 -4
- package/dist/Checkout.js +3 -3
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts +1 -1
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/EagerCheckout.d.ts +1 -1
- package/dist/EagerCheckout.js +1 -1
- package/dist/EagerCheckout.js.map +1 -1
- package/dist/EditLog.d.ts +3 -2
- package/dist/EditLog.d.ts.map +1 -1
- package/dist/EditLog.js +3 -5
- package/dist/EditLog.js.map +1 -1
- package/dist/EditUtilities.d.ts +5 -5
- package/dist/EditUtilities.js +2 -2
- package/dist/EditUtilities.js.map +1 -1
- package/dist/EventTypes.d.ts +1 -1
- package/dist/EventTypes.js +1 -1
- package/dist/EventTypes.js.map +1 -1
- package/dist/Forest.d.ts +4 -4
- package/dist/Forest.js +3 -6
- package/dist/Forest.js.map +1 -1
- package/dist/Identifiers.d.ts +14 -14
- package/dist/Identifiers.js.map +1 -1
- package/dist/InitialTree.d.ts +1 -1
- package/dist/InitialTree.js +1 -1
- package/dist/InitialTree.js.map +1 -1
- package/dist/LogViewer.d.ts +2 -2
- package/dist/LogViewer.js +1 -1
- package/dist/LogViewer.js.map +1 -1
- package/dist/NodeIdUtilities.d.ts +3 -3
- package/dist/NodeIdUtilities.js.map +1 -1
- package/dist/PayloadUtilities.d.ts +1 -1
- package/dist/PayloadUtilities.js +1 -1
- package/dist/PayloadUtilities.js.map +1 -1
- package/dist/ReconciliationPath.d.ts +3 -3
- package/dist/ReconciliationPath.js.map +1 -1
- package/dist/RevisionValueCache.d.ts +1 -1
- package/dist/RevisionValueCache.js +2 -2
- package/dist/RevisionValueCache.js.map +1 -1
- package/dist/RevisionView.d.ts +2 -2
- package/dist/RevisionView.js +2 -2
- package/dist/RevisionView.js.map +1 -1
- package/dist/SharedTree.d.ts +14 -14
- package/dist/SharedTree.js +2 -2
- package/dist/SharedTree.js.map +1 -1
- package/dist/Transaction.d.ts +3 -3
- package/dist/Transaction.js +2 -2
- package/dist/Transaction.js.map +1 -1
- package/dist/TransactionInternal.d.ts +17 -17
- package/dist/TransactionInternal.js +3 -3
- package/dist/TransactionInternal.js.map +1 -1
- package/dist/TreeView.d.ts +7 -7
- package/dist/TreeView.js +1 -1
- package/dist/TreeView.js.map +1 -1
- package/dist/id-compressor/IdCompressor.js +2 -5
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/migration-shim/migrationShim.d.ts +3 -3
- package/dist/migration-shim/migrationShim.d.ts.map +1 -1
- package/dist/migration-shim/migrationShim.js +9 -5
- package/dist/migration-shim/migrationShim.js.map +1 -1
- package/dist/migration-shim/migrationShimFactory.d.ts +2 -2
- package/dist/migration-shim/migrationShimFactory.d.ts.map +1 -1
- package/dist/migration-shim/migrationShimFactory.js.map +1 -1
- package/dist/migration-shim/sharedTreeShim.d.ts +4 -4
- package/dist/migration-shim/sharedTreeShim.d.ts.map +1 -1
- package/dist/migration-shim/sharedTreeShim.js +1 -1
- package/dist/migration-shim/sharedTreeShim.js.map +1 -1
- package/dist/migration-shim/sharedTreeShimFactory.d.ts +1 -2
- package/dist/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
- package/dist/migration-shim/sharedTreeShimFactory.js.map +1 -1
- package/dist/migration-shim/shimDeltaConnection.d.ts +16 -0
- package/dist/migration-shim/shimDeltaConnection.d.ts.map +1 -1
- package/dist/migration-shim/shimDeltaConnection.js +16 -2
- package/dist/migration-shim/shimDeltaConnection.js.map +1 -1
- package/dist/migration-shim/types.d.ts +1 -1
- package/dist/migration-shim/types.d.ts.map +1 -1
- package/dist/migration-shim/types.js.map +1 -1
- package/dist/persisted-types/0.0.2.d.ts +24 -24
- package/dist/persisted-types/0.0.2.js +5 -5
- package/dist/persisted-types/0.0.2.js.map +1 -1
- package/dist/persisted-types/0.1.1.d.ts +14 -14
- package/dist/persisted-types/0.1.1.js +3 -3
- package/dist/persisted-types/0.1.1.js.map +1 -1
- package/dist/tree-alpha.d.ts +2674 -119
- package/dist/tree-beta.d.ts +1 -50
- package/dist/tree-public.d.ts +1 -52
- package/dist/tree-untrimmed.d.ts +142 -143
- package/lib/ChangeTypes.d.ts +15 -15
- package/lib/ChangeTypes.js +4 -4
- package/lib/ChangeTypes.js.map +1 -1
- package/lib/Checkout.d.ts +4 -4
- package/lib/Checkout.js +3 -3
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts +1 -1
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js.map +1 -1
- package/lib/EagerCheckout.d.ts +1 -1
- package/lib/EagerCheckout.js +1 -1
- package/lib/EagerCheckout.js.map +1 -1
- package/lib/EditLog.d.ts +3 -2
- package/lib/EditLog.d.ts.map +1 -1
- package/lib/EditLog.js +2 -1
- package/lib/EditLog.js.map +1 -1
- package/lib/EditUtilities.d.ts +5 -5
- package/lib/EditUtilities.js +2 -2
- package/lib/EditUtilities.js.map +1 -1
- package/lib/EventTypes.d.ts +1 -1
- package/lib/EventTypes.js +1 -1
- package/lib/EventTypes.js.map +1 -1
- package/lib/Forest.d.ts +4 -4
- package/lib/Forest.js +2 -2
- package/lib/Forest.js.map +1 -1
- package/lib/Identifiers.d.ts +14 -14
- package/lib/Identifiers.js.map +1 -1
- package/lib/InitialTree.d.ts +1 -1
- package/lib/InitialTree.js +1 -1
- package/lib/InitialTree.js.map +1 -1
- package/lib/LogViewer.d.ts +2 -2
- package/lib/LogViewer.js +1 -1
- package/lib/LogViewer.js.map +1 -1
- package/lib/NodeIdUtilities.d.ts +3 -3
- package/lib/NodeIdUtilities.js.map +1 -1
- package/lib/PayloadUtilities.d.ts +1 -1
- package/lib/PayloadUtilities.js +1 -1
- package/lib/PayloadUtilities.js.map +1 -1
- package/lib/ReconciliationPath.d.ts +3 -3
- package/lib/ReconciliationPath.js.map +1 -1
- package/lib/RevisionValueCache.d.ts +1 -1
- package/lib/RevisionValueCache.js +1 -1
- package/lib/RevisionValueCache.js.map +1 -1
- package/lib/RevisionView.d.ts +2 -2
- package/lib/RevisionView.js +2 -2
- package/lib/RevisionView.js.map +1 -1
- package/lib/SharedTree.d.ts +14 -14
- package/lib/SharedTree.js +2 -2
- package/lib/SharedTree.js.map +1 -1
- package/lib/Transaction.d.ts +3 -3
- package/lib/Transaction.js +2 -2
- package/lib/Transaction.js.map +1 -1
- package/lib/TransactionInternal.d.ts +17 -17
- package/lib/TransactionInternal.js +3 -3
- package/lib/TransactionInternal.js.map +1 -1
- package/lib/TreeView.d.ts +7 -7
- package/lib/TreeView.js +1 -1
- package/lib/TreeView.js.map +1 -1
- package/lib/id-compressor/IdCompressor.js +1 -1
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/migration-shim/migrationShim.d.ts +3 -3
- package/lib/migration-shim/migrationShim.d.ts.map +1 -1
- package/lib/migration-shim/migrationShim.js +9 -5
- package/lib/migration-shim/migrationShim.js.map +1 -1
- package/lib/migration-shim/migrationShimFactory.d.ts +2 -2
- package/lib/migration-shim/migrationShimFactory.d.ts.map +1 -1
- package/lib/migration-shim/migrationShimFactory.js.map +1 -1
- package/lib/migration-shim/sharedTreeShim.d.ts +4 -4
- package/lib/migration-shim/sharedTreeShim.d.ts.map +1 -1
- package/lib/migration-shim/sharedTreeShim.js +1 -1
- package/lib/migration-shim/sharedTreeShim.js.map +1 -1
- package/lib/migration-shim/sharedTreeShimFactory.d.ts +1 -2
- package/lib/migration-shim/sharedTreeShimFactory.d.ts.map +1 -1
- package/lib/migration-shim/sharedTreeShimFactory.js.map +1 -1
- package/lib/migration-shim/shimDeltaConnection.d.ts +16 -0
- package/lib/migration-shim/shimDeltaConnection.d.ts.map +1 -1
- package/lib/migration-shim/shimDeltaConnection.js +16 -2
- package/lib/migration-shim/shimDeltaConnection.js.map +1 -1
- package/lib/migration-shim/types.d.ts +1 -1
- package/lib/migration-shim/types.d.ts.map +1 -1
- package/lib/migration-shim/types.js.map +1 -1
- package/lib/persisted-types/0.0.2.d.ts +24 -24
- package/lib/persisted-types/0.0.2.js +5 -5
- package/lib/persisted-types/0.0.2.js.map +1 -1
- package/lib/persisted-types/0.1.1.d.ts +14 -14
- package/lib/persisted-types/0.1.1.js +3 -3
- package/lib/persisted-types/0.1.1.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts +1 -2
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/package.json +25 -25
- package/src/ChangeTypes.ts +15 -15
- package/src/Checkout.ts +4 -4
- package/src/Common.ts +1 -1
- package/src/EagerCheckout.ts +1 -1
- package/src/EditLog.ts +4 -3
- package/src/EditUtilities.ts +5 -5
- package/src/EventTypes.ts +1 -1
- package/src/Forest.ts +5 -5
- package/src/Identifiers.ts +14 -14
- package/src/InitialTree.ts +1 -1
- package/src/LogViewer.ts +2 -2
- package/src/NodeIdUtilities.ts +3 -3
- package/src/PayloadUtilities.ts +1 -1
- package/src/ReconciliationPath.ts +3 -3
- package/src/RevisionValueCache.ts +2 -2
- package/src/RevisionView.ts +2 -2
- package/src/SharedTree.ts +14 -14
- package/src/Transaction.ts +3 -3
- package/src/TransactionInternal.ts +17 -17
- package/src/TreeView.ts +7 -7
- package/src/id-compressor/IdCompressor.ts +1 -1
- package/src/migration-shim/migrationShim.ts +17 -9
- package/src/migration-shim/migrationShimFactory.ts +2 -2
- package/src/migration-shim/sharedTreeShim.ts +6 -5
- package/src/migration-shim/sharedTreeShimFactory.ts +1 -2
- package/src/migration-shim/shimDeltaConnection.ts +16 -2
- package/src/migration-shim/types.ts +1 -1
- package/src/persisted-types/0.0.2.ts +24 -24
- package/src/persisted-types/0.1.1.ts +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeIdUtilities.js","sourceRoot":"","sources":["../src/NodeIdUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAA0D;AAG1D,qCAA6C;AA6F7C;;;GAGG;AACH,SAAgB,iBAAiB,CAChC,YAAmC,EACnC,SAAqB;IAErB,OAAO;QACN,kBAAkB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC/D,uBAAuB,EAAE,CAAC,EAAE,EAAE,EAAE,CAC/B,YAAY,CAAC,uBAAuB,CAAC,EAAE,EAAE,SAAS,IAAI,YAAY,CAAC,cAAc,CAAC;KACnF,CAAC;AACH,CAAC;AATD,8CASC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CACpC,YAAmC;IAEnC,OAAO;QACN,kBAAkB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC1B,MAAM,UAAU,GAAG,YAAY,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;YACvD,IAAA,0BAAiB,EAAC,IAAA,yBAAS,EAAC,UAAU,CAAC,CAAC,CAAC;YACzC,OAAO,UAAU,CAAC;QACnB,CAAC;QACD,uBAAuB,EAAE,CAAC,EAAE,EAAE,EAAE;YAC/B,MAAM,UAAU,GAAG,YAAY,CAAC,uBAAuB,CAAC,EAAE,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;YACzF,IAAA,0BAAiB,EAAC,IAAA,yBAAS,EAAC,UAAU,CAAC,CAAC,CAAC;YACzC,OAAO,UAAU,CAAC;QACnB,CAAC;KACD,CAAC;AACH,CAAC;AAfD,sDAeC;AAED,SAAgB,gBAAgB,CAAC,UAAwB;IACxD,OAAO;QACN,cAAc,EAAE,CAAC,QAAiB,EAAE,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,QAAQ,CAAW;QAC1F,eAAe,EAAE,CAAC,EAAgB,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAW;QAC1E,kBAAkB,EAAE,CAAC,EAAgB,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAuB;QAC5F,qBAAqB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAiB;QAChF,wBAAwB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAiB;QACtF,kBAAkB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAkB;QACtF,uBAAuB,EAAE,CAAC,EAAiB,EAAE,SAAoB,EAAE,EAAE,CACpE,UAAU,CAAC,uBAAuB,CAAC,EAAE,EAAE,SAAS,CAAW;QAC5D,cAAc,EAAE,UAAU,CAAC,cAAc;KACzC,CAAC;AACH,CAAC;AAZD,4CAYC;AAED,+EAA+E;AAC/E,SAAgB,SAAS,CAA8B,IAAyB;IAC/E,OAAQ,IAAsB,CAAC,UAAU,IAAK,IAAY,CAAC;AAC5D,CAAC;AAFD,8BAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IdCompressor, isFinalId } from './id-compressor';\nimport { FinalNodeId, NodeId, OpSpaceNodeId, SessionId, StableNodeId } from './Identifiers';\nimport { NodeData } from './persisted-types';\nimport { assertWithMessage } from './Common';\n\n/**\n * An object which can generate node IDs and convert node IDs between compressed and stable variants\n * @
|
|
1
|
+
{"version":3,"file":"NodeIdUtilities.js","sourceRoot":"","sources":["../src/NodeIdUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAA0D;AAG1D,qCAA6C;AA6F7C;;;GAGG;AACH,SAAgB,iBAAiB,CAChC,YAAmC,EACnC,SAAqB;IAErB,OAAO;QACN,kBAAk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E,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAiB;QACtF,kBAAkB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAkB;QACtF,uBAAuB,EAAE,CAAC,EAAiB,EAAE,SAAoB,EAAE,EAAE,CACpE,UAAU,CAAC,uBAAuB,CAAC,EAAE,EAAE,SAAS,CAAW;QAC5D,cAAc,EAAE,UAAU,CAAC,cAAc;KACzC,CAAC;AACH,CAAC;AAZD,4CAYC;AAED,+EAA+E;AAC/E,SAAgB,SAAS,CAA8B,IAAyB;IAC/E,OAAQ,IAAsB,CAAC,UAAU,IAAK,IAAY,CAAC;AAC5D,CAAC;AAFD,8BAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IdCompressor, isFinalId } from './id-compressor';\nimport { FinalNodeId, NodeId, OpSpaceNodeId, SessionId, StableNodeId } from './Identifiers';\nimport { NodeData } from './persisted-types';\nimport { assertWithMessage } from './Common';\n\n/**\n * An object which can generate node IDs and convert node IDs between compressed and stable variants\n * @alpha\n */\nexport interface NodeIdContext extends NodeIdGenerator, NodeIdConverter {}\n\n/**\n * An object which can generate node IDs\n * @alpha\n */\nexport interface NodeIdGenerator {\n\t/**\n\t * Generates a node identifier.\n\t * The returned IDs may be used as the identifier of a node in the SharedTree.\n\t * `NodeId`s are *always* unique and stable within the scope of the tree and session that generated them. They are *not* unique within\n\t * a Fluid container, and *cannot* be compared across instances of a SharedTree. They are *not* stable across sessions/lifetimes of a\n\t * SharedTree, and *cannot* be persisted (e.g. stored in payloads, uploaded in blobs, etc.). If stable persistence is needed,\n\t * NodeIdConverter.convertToStableNodeId may be used to return a corresponding UUID that is globally unique and stable.\n\t * @param override - if supplied, calls to `convertToStableNodeId` using the returned node ID will return the override instead of\n\t * the UUID. Calls to `generateNodeId` with the same override always return the same ID. Performance note: passing an override string\n\t * incurs a storage cost that is significantly higher that a node ID without one, and should be avoided if possible.\n\t */\n\tgenerateNodeId(override?: string): NodeId;\n}\n\n/**\n * An object which can convert node IDs between compressed and stable variants\n * @alpha\n */\nexport interface NodeIdConverter {\n\t/**\n\t * Given a NodeId, returns the corresponding stable ID or throws if the supplied node ID was not generated with this tree (`NodeId`s\n\t * may not be used across SharedTree instances, see `generateNodeId` for more).\n\t * The returned value will be a UUID, unless the creation of `id` used an override string (see `generateNodeId` for more).\n\t * The result is safe to persist and re-use across `SharedTree` instances, unlike `NodeId`.\n\t */\n\tconvertToStableNodeId(id: NodeId): StableNodeId;\n\n\t/**\n\t * Given a NodeId, attempt to return the corresponding stable ID.\n\t * The returned value will be a UUID, unless the creation of `id` used an override string (see `generateNodeId` for more).\n\t * The returned stable ID is undefined if `id` was never created with this SharedTree. If a stable ID is returned, this does not imply\n\t * that there is a node with `id` in the current revision of the tree, only that `id` was at some point generated by some instance of\n\t * this tree.\n\t */\n\ttryConvertToStableNodeId(id: NodeId): StableNodeId | undefined;\n\n\t/**\n\t * Given a stable ID, return the corresponding NodeId or throws if the supplied stable ID was never generated with this tree, either\n\t * as a UUID corresponding to a `NodeId` or as an override passed to `generateNodeId`.\n\t * If a stable ID is returned, this does not imply that there is a node with `id` in the current revision of the tree, only that\n\t * `id` was at some point generated by an instance of this SharedTree.\n\t */\n\tconvertToNodeId(id: StableNodeId): NodeId;\n\n\t/**\n\t * Given a stable ID, return the corresponding NodeId or return undefined if the supplied stable ID was never generated with this tree,\n\t * either as a UUID corresponding to a `NodeId` or as an override passed to `generateNodeId`.\n\t * If a stable ID is returned, this does not imply that there is a node with `id` in the current revision of the tree, only that\n\t * `id` was at some point generated by an instance of this SharedTree.\n\t */\n\ttryConvertToNodeId(id: StableNodeId): NodeId | undefined;\n}\n\n/**\n * An object which can normalize node IDs. See docs on {@link IdCompressor} for semantics of normalization.\n */\nexport interface NodeIdNormalizer<TId extends OpSpaceNodeId> {\n\tlocalSessionId: SessionId;\n\t/**\n\t * Normalizes the given ID to op space\n\t */\n\tnormalizeToOpSpace(id: NodeId): TId;\n\t/**\n\t * Normalizes the given ID to session space\n\t */\n\tnormalizeToSessionSpace(id: TId, sessionId: SessionId): NodeId;\n}\n\n/**\n * An object which can normalize node IDs. It is contextualized to a known session context, and therefore\n * can normalize IDs into session space without requiring any additional information.\n */\nexport interface ContextualizedNodeIdNormalizer<TId extends OpSpaceNodeId>\n\textends Omit<NodeIdNormalizer<TId>, 'localSessionId' | 'normalizeToSessionSpace'> {\n\t/**\n\t * Normalizes the given ID to session space\n\t */\n\tnormalizeToSessionSpace(id: TId): NodeId;\n}\n\n/**\n * Create a {@link ContextualizedNodeIdNormalizer} that uses either the given session ID to normalize IDs\n * to session space. If no ID is given, it will use the local session ID belonging to the normalizer.\n */\nexport function scopeIdNormalizer<TId extends OpSpaceNodeId>(\n\tidNormalizer: NodeIdNormalizer<TId>,\n\tsessionId?: SessionId\n): ContextualizedNodeIdNormalizer<TId> {\n\treturn {\n\t\tnormalizeToOpSpace: (id) => idNormalizer.normalizeToOpSpace(id),\n\t\tnormalizeToSessionSpace: (id) =>\n\t\t\tidNormalizer.normalizeToSessionSpace(id, sessionId ?? idNormalizer.localSessionId),\n\t};\n}\n\n/**\n * Create a {@link ContextualizedNodeIdNormalizer} that uses the local session ID belonging to the normalizer\n * to normalize IDs to session space. These IDs are expected to be sequenced, and will fail to normalize if\n * they are not.\n */\nexport function sequencedIdNormalizer<TId extends OpSpaceNodeId>(\n\tidNormalizer: NodeIdNormalizer<TId>\n): ContextualizedNodeIdNormalizer<FinalNodeId & TId> {\n\treturn {\n\t\tnormalizeToOpSpace: (id) => {\n\t\t\tconst normalized = idNormalizer.normalizeToOpSpace(id);\n\t\t\tassertWithMessage(isFinalId(normalized));\n\t\t\treturn normalized;\n\t\t},\n\t\tnormalizeToSessionSpace: (id) => {\n\t\t\tconst normalized = idNormalizer.normalizeToSessionSpace(id, idNormalizer.localSessionId);\n\t\t\tassertWithMessage(isFinalId(normalized));\n\t\t\treturn normalized;\n\t\t},\n\t};\n}\n\nexport function getNodeIdContext(compressor: IdCompressor): NodeIdContext & NodeIdNormalizer<OpSpaceNodeId> {\n\treturn {\n\t\tgenerateNodeId: (override?: string) => compressor.generateCompressedId(override) as NodeId,\n\t\tconvertToNodeId: (id: StableNodeId) => compressor.recompress(id) as NodeId,\n\t\ttryConvertToNodeId: (id: StableNodeId) => compressor.tryRecompress(id) as NodeId | undefined,\n\t\tconvertToStableNodeId: (id: NodeId) => compressor.decompress(id) as StableNodeId,\n\t\ttryConvertToStableNodeId: (id: NodeId) => compressor.tryDecompress(id) as StableNodeId,\n\t\tnormalizeToOpSpace: (id: NodeId) => compressor.normalizeToOpSpace(id) as OpSpaceNodeId,\n\t\tnormalizeToSessionSpace: (id: OpSpaceNodeId, sessionId: SessionId) =>\n\t\t\tcompressor.normalizeToSessionSpace(id, sessionId) as NodeId,\n\t\tlocalSessionId: compressor.localSessionId,\n\t};\n}\n\n/** Accepts either a node or a node's identifier, and returns the identifier */\nexport function getNodeId<TId extends number | string>(node: TId | NodeData<TId>): TId {\n\treturn (node as NodeData<TId>).identifier ?? (node as TId);\n}\n"]}
|
|
@@ -36,7 +36,7 @@ import { Payload } from './persisted-types';
|
|
|
36
36
|
* IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.
|
|
37
37
|
*
|
|
38
38
|
* TODO:#54095: Is there a better way to do this comparison?
|
|
39
|
-
* @
|
|
39
|
+
* @alpha
|
|
40
40
|
*/
|
|
41
41
|
export declare function comparePayloads(a: Payload, b: Payload): boolean;
|
|
42
42
|
//# sourceMappingURL=PayloadUtilities.d.ts.map
|
package/dist/PayloadUtilities.js
CHANGED
|
@@ -39,7 +39,7 @@ const core_utils_1 = require("@fluidframework/core-utils");
|
|
|
39
39
|
* IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.
|
|
40
40
|
*
|
|
41
41
|
* TODO:#54095: Is there a better way to do this comparison?
|
|
42
|
-
* @
|
|
42
|
+
* @alpha
|
|
43
43
|
*/
|
|
44
44
|
function comparePayloads(a, b) {
|
|
45
45
|
// === is not reflective because of how NaN is handled, so use Object.is instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadUtilities.js","sourceRoot":"","sources":["../src/PayloadUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAA2D;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,eAAe,CAAC,CAAU,EAAE,CAAU;IACrD,iFAAiF;IACjF,sCAAsC;IACtC,0DAA0D;IAC1D,mFAAmF;IACnF,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC;KACZ;IAED,2HAA2H;IAC3H,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QACnD,OAAO,KAAK,CAAC;KACb;IAED,qFAAqF;IACrF,uEAAuE;IACvE,0FAA0F;IAC1F,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE;QAC7B,OAAO,KAAK,CAAC;KACb;IAED,wEAAwE;IACxE,6HAA6H;IAC7H;QACC,MAAM,OAAO,GAAG,CAAiB,CAAC;QAClC,MAAM,OAAO,GAAG,CAAiB,CAAC;QAClC,IAAI,OAAO,CAAC,YAAY,KAAK,CAAC,EAAE;YAC/B,IAAI,OAAO,CAAC,YAAY,KAAK,CAAC,EAAE;gBAC/B,OAAO,KAAK,CAAC;aACb;YACD,OAAO,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY,CAAC;SACzC;KACD;IAED,0GAA0G;IAC1G,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE;QAClC,OAAO,KAAK,CAAC;KACb;IAED,8EAA8E;IAC9E,IAAI,CAAC,YAAY,KAAK,KAAK,CAAC,YAAY,KAAK,EAAE;QAC9C,OAAO,KAAK,CAAC;KACb;IAED,gIAAgI;IAChI,gDAAgD;IAChD,IAAI,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,EAAE;QAC1B,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,KAAK,CAAC,IAAI,EAAE,CAAC;KACb;IAED,8BAA8B;IAC9B,+FAA+F;IAC/F,IAAI,CAAC,IAAA,0BAAa,EAAC,KAAK,EAAE,KAAK,CAAC,EAAE;QACjC,OAAO,KAAK,CAAC;KACb;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,KAAK,GAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,KAAK,GAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAEnC,kHAAkH;QAClH,uEAAuE;QACvE,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,KAAK,EAAE;YACpB,OAAO,KAAK,CAAC;SACb;QACD,IAAI,CAAC,KAAK,EAAE;YACX,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;gBACnC,OAAO,KAAK,CAAC;aACb;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AA/ED,0CA+EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { compareArrays } from '@fluidframework/core-utils';\nimport { Payload } from './persisted-types';\n\n/**\n * @returns true if two `Payloads` are identical.\n * May return false for equivalent payloads encoded differently.\n *\n * Object field order and object identity are not considered significant, and are ignored by this function.\n * (This is because they may not be preserved through roundtrip).\n *\n * For other information which Fluid would lose on serialization round trip,\n * behavior is unspecified other than this this function is reflective (all payloads are equal to themselves)\n * and commutative (argument order does not matter).\n *\n * This means that any Payload is equal to itself and a deep clone of itself.\n *\n * Payloads might not be equal to a version of themselves that has been serialized then deserialized.\n * If they are serialized then deserialized again, the two deserialized objects will compare equal,\n * however the serialized strings may be unequal (due to field order for objects being unspecified).\n *\n * Fluid will cause lossy operations due to use of JSON.stringify().\n * This includes:\n * - Loss of object identity\n * - Loss of field order (may be ordered arbitrarily)\n * - -0 becomes +0\n * - NaN, Infinity, -Infinity all become null\n * - custom toJSON functions may cause arbitrary behavior\n * - functions become undefined or null\n * - non enumerable properties (including prototype) are lost\n * - more (this is not a complete list)\n *\n * Inputs must not contain cyclic references other than fields set to their immediate parent (for the JavaScript feature detection pattern).\n *\n * IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.\n *\n * TODO:#54095: Is there a better way to do this comparison?\n * @
|
|
1
|
+
{"version":3,"file":"PayloadUtilities.js","sourceRoot":"","sources":["../src/PayloadUtilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAA2D;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,eAAe,CAAC,CAAU,EAAE,CAAU;IACrD,iFAAiF;IACjF,sCAAsC;IACtC,0DAA0D;IAC1D,mFAAmF;IACnF,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC;KACZ;IAED,2HAA2H;IAC3H,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QACnD,OAAO,KAAK,CAAC;KACb;IAED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QACnC,MAAM,KAAK,GAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAEnC,kHAAkH;QAClH,uEAAuE;QACvE,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,KAAK,EAAE;YACpB,OAAO,KAAK,CAAC;SACb;QACD,IAAI,CAAC,KAAK,EAAE;YACX,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;gBACnC,OAAO,KAAK,CAAC;aACb;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AA/ED,0CA+EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { compareArrays } from '@fluidframework/core-utils';\nimport { Payload } from './persisted-types';\n\n/**\n * @returns true if two `Payloads` are identical.\n * May return false for equivalent payloads encoded differently.\n *\n * Object field order and object identity are not considered significant, and are ignored by this function.\n * (This is because they may not be preserved through roundtrip).\n *\n * For other information which Fluid would lose on serialization round trip,\n * behavior is unspecified other than this this function is reflective (all payloads are equal to themselves)\n * and commutative (argument order does not matter).\n *\n * This means that any Payload is equal to itself and a deep clone of itself.\n *\n * Payloads might not be equal to a version of themselves that has been serialized then deserialized.\n * If they are serialized then deserialized again, the two deserialized objects will compare equal,\n * however the serialized strings may be unequal (due to field order for objects being unspecified).\n *\n * Fluid will cause lossy operations due to use of JSON.stringify().\n * This includes:\n * - Loss of object identity\n * - Loss of field order (may be ordered arbitrarily)\n * - -0 becomes +0\n * - NaN, Infinity, -Infinity all become null\n * - custom toJSON functions may cause arbitrary behavior\n * - functions become undefined or null\n * - non enumerable properties (including prototype) are lost\n * - more (this is not a complete list)\n *\n * Inputs must not contain cyclic references other than fields set to their immediate parent (for the JavaScript feature detection pattern).\n *\n * IFluidHandle instances (detected via JavaScript feature detection pattern) are only compared by absolutePath.\n *\n * TODO:#54095: Is there a better way to do this comparison?\n * @alpha\n */\nexport function comparePayloads(a: Payload, b: Payload): boolean {\n\t// === is not reflective because of how NaN is handled, so use Object.is instead.\n\t// This treats -0 and +0 as different.\n\t// Since -0 is not preserved in serialization round trips,\n\t// it can be handed in any way that is reflective and commutative, so this is fine.\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\n\t// Primitives which are equal would have early returned above, so now if the values are not both objects, they are unequal.\n\tif (typeof a !== 'object' || typeof b !== 'object') {\n\t\treturn false;\n\t}\n\n\t// null is of type object, and needs to be treated as distinct from the empty object.\n\t// Handling it early also avoids type errors trying to access its keys.\n\t// Rationale: 'undefined' payloads are reserved for future use (see 'SetValue' interface).\n\tif (a === null || b === null) {\n\t\treturn false;\n\t}\n\n\t// Special case IFluidHandles, comparing them only by their absolutePath\n\t// Detect them using JavaScript feature detection pattern: they have a `IFluidHandle` field that is set to the parent object.\n\t{\n\t\tconst aHandle = a as IFluidHandle;\n\t\tconst bHandle = b as IFluidHandle;\n\t\tif (aHandle.IFluidHandle === a) {\n\t\t\tif (bHandle.IFluidHandle !== b) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn a.absolutePath === b.absolutePath;\n\t\t}\n\t}\n\n\t// Fluid Serialization (like Json) only keeps enumerable properties, so we can ignore non-enumerable ones.\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\n\tif (aKeys.length !== bKeys.length) {\n\t\treturn false;\n\t}\n\n\t// make sure objects with numeric keys (or no keys) compare unequal to arrays.\n\tif (a instanceof Array !== b instanceof Array) {\n\t\treturn false;\n\t}\n\n\t// Fluid Serialization (like Json) orders object fields arbitrarily, so reordering fields is not considered considered a change.\n\t// Therefor the keys arrays must be sorted here.\n\tif (!(a instanceof Array)) {\n\t\taKeys.sort();\n\t\tbKeys.sort();\n\t}\n\n\t// First check keys are equal.\n\t// This will often early exit, and thus is worth doing as a separate pass than recursive check.\n\tif (!compareArrays(aKeys, bKeys)) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < aKeys.length; i++) {\n\t\tconst aItem: Payload = a[aKeys[i]];\n\t\tconst bItem: Payload = b[bKeys[i]];\n\n\t\t// The JavaScript feature detection pattern, used for IFluidHandle, uses a field that is set to the parent object.\n\t\t// Detect this pattern and special case it to avoid infinite recursion.\n\t\tconst aSelf = Object.is(aItem, a);\n\t\tconst bSelf = Object.is(bItem, b);\n\t\tif (aSelf !== bSelf) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!aSelf) {\n\t\t\tif (!comparePayloads(aItem, bItem)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n"]}
|
|
@@ -10,7 +10,7 @@ import { TreeView } from './TreeView';
|
|
|
10
10
|
* change is actually applied.
|
|
11
11
|
* The path only contains edits that were successfully applied.
|
|
12
12
|
* This path is always empty for a change that has no concurrent edits.
|
|
13
|
-
* @
|
|
13
|
+
* @alpha
|
|
14
14
|
*/
|
|
15
15
|
export interface ReconciliationPath {
|
|
16
16
|
/**
|
|
@@ -25,7 +25,7 @@ export interface ReconciliationPath {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* An edit in the `ReconciliationPath`.
|
|
28
|
-
* @
|
|
28
|
+
* @alpha
|
|
29
29
|
*/
|
|
30
30
|
export interface ReconciliationEdit {
|
|
31
31
|
/**
|
|
@@ -48,7 +48,7 @@ export interface ReconciliationEdit {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* A change in the `ReconciliationPath`.
|
|
51
|
-
* @
|
|
51
|
+
* @alpha
|
|
52
52
|
*/
|
|
53
53
|
export interface ReconciliationChange {
|
|
54
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReconciliationPath.js","sourceRoot":"","sources":["../src/ReconciliationPath.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ChangeInternal } from './persisted-types';\nimport { TransactionView } from './RevisionView';\nimport { TreeView } from './TreeView';\n\n/**\n * The path of edits from the revision view where a change was meant to have been applied to the view where the edit that contains the\n * change is actually applied.\n * The path only contains edits that were successfully applied.\n * This path is always empty for a change that has no concurrent edits.\n * @
|
|
1
|
+
{"version":3,"file":"ReconciliationPath.js","sourceRoot":"","sources":["../src/ReconciliationPath.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ChangeInternal } from './persisted-types';\nimport { TransactionView } from './RevisionView';\nimport { TreeView } from './TreeView';\n\n/**\n * The path of edits from the revision view where a change was meant to have been applied to the view where the edit that contains the\n * change is actually applied.\n * The path only contains edits that were successfully applied.\n * This path is always empty for a change that has no concurrent edits.\n * @alpha\n */\nexport interface ReconciliationPath {\n\t/**\n\t * The number of edits in the path.\n\t */\n\treadonly length: number;\n\t/**\n\t * Allows access to edit information.\n\t * @returns Reconciliation information for the edit at the given `index`.\n\t */\n\treadonly [index: number]: ReconciliationEdit;\n}\n\n/**\n * An edit in the `ReconciliationPath`.\n * @alpha\n */\nexport interface ReconciliationEdit {\n\t/**\n\t * The state before the edit was applied.\n\t */\n\treadonly before: TreeView;\n\t/**\n\t * The state after the edit was applied.\n\t */\n\treadonly after: TreeView;\n\t/**\n\t * The number of changes in the edit.\n\t */\n\treadonly length: number;\n\t/**\n\t * Allows access to change information.\n\t * @returns Reconciliation information for the change at the given `index`.\n\t */\n\treadonly [index: number]: ReconciliationChange;\n}\n\n/**\n * A change in the `ReconciliationPath`.\n * @alpha\n */\nexport interface ReconciliationChange {\n\t/**\n\t * The resolved change that was applied during the edit.\n\t * Resolved changes are guaranteed to be expressed with valid tree locations instead of anchors that need resolution.\n\t */\n\treadonly resolvedChange: ChangeInternal;\n\t/**\n\t * The resulting view from applying the resolved change.\n\t */\n\treadonly after: TransactionView;\n}\n"]}
|
|
@@ -9,7 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.RevisionValueCache = void 0;
|
|
11
11
|
const core_utils_1 = require("@fluidframework/core-utils");
|
|
12
|
-
const
|
|
12
|
+
const sorted_btree_es6_1 = require("@tylerbu/sorted-btree-es6");
|
|
13
13
|
const lru_cache_1 = __importDefault(require("lru-cache"));
|
|
14
14
|
const Common_1 = require("./Common");
|
|
15
15
|
/**
|
|
@@ -46,7 +46,7 @@ class RevisionValueCache {
|
|
|
46
46
|
* This is sorted to allow efficient access to the nearest preceding entry (see getClosestEntry).
|
|
47
47
|
* Contains all cached values, regardless of why they are cached (retained, LRU or window).
|
|
48
48
|
*/
|
|
49
|
-
this.sortedEntries = new
|
|
49
|
+
this.sortedEntries = new sorted_btree_es6_1.BTree(undefined, Common_1.compareFiniteNumbers);
|
|
50
50
|
(0, core_utils_1.assert)(retentionWindowStart >= 0, 0x62c /* retentionWindowStart must be initialized >= 0 */);
|
|
51
51
|
this.evictableRevisions = new lru_cache_1.default({
|
|
52
52
|
max: evictableSize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RevisionValueCache.js","sourceRoot":"","sources":["../src/RevisionValueCache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,2DAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"RevisionValueCache.js","sourceRoot":"","sources":["../src/RevisionValueCache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,2DAAoD;AACpD,gEAAkD;AAClD,0DAA4B;AAC5B,qCAAsD;AAetD;;;;;;;;;;;;GAYG;AACH,MAAa,kBAAkB;IAqB9B;IACC;;OAEG;IACH,aAAqB;IACrB;;;O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I,CAAC,gBAAgB,KAAK,QAAQ,EAAE;YACvC,OAAO;SACP;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,QAAQ,GAAG,IAAI,CAAC,oBAAoB,EAAE;YACzC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SAC7C;IACF,CAAC;CACD;AAnID,gDAmIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/core-utils';\nimport { BTree } from '@tylerbu/sorted-btree-es6';\nimport LRU from 'lru-cache';\nimport { fail, compareFiniteNumbers } from './Common';\n\n/**\n * A revision corresponds to an index in an `EditLog`.\n *\n * It is associated with the output `RevisionView` of applying the edit at the index to the previous revision.\n * For example:\n *\n * - revision 0 corresponds to the initialRevision.\n *\n * - revision 1 corresponds to the output of editLog[0] applied to the initialRevision.\n * @alpha\n */\nexport type Revision = number;\n\n/**\n * A cache of `TValue`s corresponding to `Revision`s.\n *\n * A value is kept in cache if it meets any of the following criteria:\n *\n * - The revision is \\>= `retentionWindowStart`\n *\n * - The value has been used recently, meaning getClosestEntry or cacheValue was called with its revision. Note that\n * being returned when a large revision was passed to getClosestEntry does not count.\n *\n * - The value is `retained` meaning it was provided to to constructor in retainedEntries or passed to\n * `cacheRetainedValue`\n */\nexport class RevisionValueCache<TValue> {\n\t/**\n\t * A cache of entries for revisions.\n\t * This is sorted to allow efficient access to the nearest preceding entry (see getClosestEntry).\n\t * Contains all cached values, regardless of why they are cached (retained, LRU or window).\n\t */\n\tprivate readonly sortedEntries = new BTree<Revision, TValue>(undefined, compareFiniteNumbers);\n\n\t/**\n\t * Cache of most recently used evictable entries.\n\t * Subset of `sortedValues` eligible for eviction:\n\t * All entries are also in `sortedValues`, and are removed from `sortedValues` when evicted from this cache.\n\t * Evicts least recently used entries.\n\t */\n\tprivate readonly evictableRevisions: LRU<Revision, TValue>;\n\n\t/**\n\t * The oldest revision that must be retained in memory.\n\t */\n\tprivate retainedRevision?: Revision;\n\n\tpublic constructor(\n\t\t/**\n\t\t * Maximum capacity for evictable cache entries (those neither marked as retained nor within the retention window).\n\t\t */\n\t\tevictableSize: number,\n\t\t/**\n\t\t * The first revision within the retention window. All entries with revisions \\>= retentionWindowStart will be retained.\n\t\t * Must be \\>= 0.\n\t\t */\n\t\tprivate retentionWindowStart: Revision,\n\t\t/**\n\t\t * The oldest revision that must be retained in memory.\n\t\t */\n\t\tretainedRevision?: [Revision, TValue]\n\t) {\n\t\tassert(retentionWindowStart >= 0, 0x62c /* retentionWindowStart must be initialized >= 0 */);\n\t\tthis.evictableRevisions = new LRU({\n\t\t\tmax: evictableSize,\n\t\t\tnoDisposeOnSet: true,\n\t\t\tdispose: (revision) => {\n\t\t\t\tif (revision >= this.retentionWindowStart) {\n\t\t\t\t\tfail('Entries in retention window should never be evicted.');\n\t\t\t\t}\n\t\t\t\tif (this.retainedRevision === revision) {\n\t\t\t\t\tfail('Retained entries should not be evicted');\n\t\t\t\t}\n\t\t\t\tthis.sortedEntries.delete(revision);\n\t\t\t},\n\t\t});\n\n\t\tif (retainedRevision !== undefined) {\n\t\t\tthis.cacheRetainedValue(retainedRevision[0], retainedRevision[1]);\n\t\t}\n\t}\n\n\t/**\n\t * @returns if the supplied revision is within the retention window.\n\t */\n\tpublic isWithinRetentionWindow(revision: Revision): boolean {\n\t\treturn revision >= this.retentionWindowStart;\n\t}\n\n\t/**\n\t * Sets the new retention window.\n\t * @param newRetentionWindowStart - defines the trailing edge (inclusive) of the new retention window.\n\t */\n\tpublic updateRetentionWindow(newRetentionWindowStart: Revision): void {\n\t\tif (newRetentionWindowStart < this.retentionWindowStart) {\n\t\t\tfail('retention window boundary must not move backwards');\n\t\t}\n\t\tconst prevRetentionWindowStart = this.retentionWindowStart;\n\t\tthis.retentionWindowStart = newRetentionWindowStart;\n\t\tconst oldWindowEntries: [Revision, TValue][] = [];\n\t\tthis.sortedEntries.forRange(\n\t\t\tprevRetentionWindowStart,\n\t\t\tthis.retentionWindowStart,\n\t\t\tfalse,\n\t\t\t(windowRevision, windowEntry) => {\n\t\t\t\tif (this.retainedRevision !== windowRevision) {\n\t\t\t\t\t// Adding to the LRU can cause eviction which in turn mutates the b-tree we are enumerating. Thus, store list of\n\t\t\t\t\t// old window entries separately.\n\t\t\t\t\toldWindowEntries.push([windowRevision, windowEntry]);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\toldWindowEntries.forEach(([revision, value]) => {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t});\n\t}\n\n\t/**\n\t * @returns a [cachedRevision, value] where cachedRevision \\<= requestedRevision, or undefined if no such revision\n\t * is cached.\n\t */\n\tpublic getClosestEntry(requestedRevision: Revision): [revision: Revision, value: TValue] | undefined {\n\t\tconst fromLRU = this.evictableRevisions.get(requestedRevision);\n\t\tif (fromLRU !== undefined) {\n\t\t\treturn [requestedRevision, fromLRU];\n\t\t}\n\t\treturn this.sortedEntries.getPairOrNextLower(requestedRevision) ?? undefined;\n\t}\n\n\t/**\n\t * Caches the supplied value and guarantees it will never be evicted.\n\t * This will make the previously retained value evictable.\n\t */\n\tpublic cacheRetainedValue(revision: Revision, value: TValue): void {\n\t\tif (this.retainedRevision !== undefined) {\n\t\t\tthis.sortedEntries.delete(this.retainedRevision);\n\t\t}\n\t\tthis.retainedRevision = revision;\n\t\tthis.sortedEntries.set(revision, value);\n\t}\n\n\t/**\n\t * Caches the supplied value.\n\t * The cached value is subject to eviction unless it is within the retention window or was previously added\n\t * via `cacheRetainedValue`.\n\t * Note that if a non-retained entry starts out within the retention window and passes outside of it due to a call to\n\t * updateRetentionWindow it is then subject to eviction.\n\t */\n\tpublic cacheValue(revision: Revision, value: TValue): void {\n\t\tif (this.retainedRevision === revision) {\n\t\t\treturn;\n\t\t}\n\t\tthis.sortedEntries.set(revision, value);\n\t\tif (revision < this.retentionWindowStart) {\n\t\t\tthis.evictableRevisions.set(revision, value);\n\t\t}\n\t}\n}\n"]}
|
package/dist/RevisionView.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { TreeView, TreeViewNode, TreeViewPlace, TreeViewRange } from './TreeView
|
|
|
9
9
|
import { HasVariadicTraits } from './ChangeTypes';
|
|
10
10
|
/**
|
|
11
11
|
* An immutable view of a distributed tree.
|
|
12
|
-
* @
|
|
12
|
+
* @alpha
|
|
13
13
|
*/
|
|
14
14
|
export declare class RevisionView extends TreeView {
|
|
15
15
|
/**
|
|
@@ -31,7 +31,7 @@ export declare class RevisionView extends TreeView {
|
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* An view of a distributed tree that is part of an ongoing transaction between `RevisionView`s.
|
|
34
|
-
* @
|
|
34
|
+
* @alpha
|
|
35
35
|
*/
|
|
36
36
|
export declare class TransactionView extends TreeView {
|
|
37
37
|
/** Conclude a transaction by generating an immutable `RevisionView` from this view */
|
package/dist/RevisionView.js
CHANGED
|
@@ -10,7 +10,7 @@ const Forest_1 = require("./Forest");
|
|
|
10
10
|
const TreeView_1 = require("./TreeView");
|
|
11
11
|
/**
|
|
12
12
|
* An immutable view of a distributed tree.
|
|
13
|
-
* @
|
|
13
|
+
* @alpha
|
|
14
14
|
*/
|
|
15
15
|
class RevisionView extends TreeView_1.TreeView {
|
|
16
16
|
static fromTree(root, idConverterOrExpensiveValidation, expensiveValidation = false) {
|
|
@@ -52,7 +52,7 @@ class RevisionView extends TreeView_1.TreeView {
|
|
|
52
52
|
exports.RevisionView = RevisionView;
|
|
53
53
|
/**
|
|
54
54
|
* An view of a distributed tree that is part of an ongoing transaction between `RevisionView`s.
|
|
55
|
-
* @
|
|
55
|
+
* @alpha
|
|
56
56
|
*/
|
|
57
57
|
class TransactionView extends TreeView_1.TreeView {
|
|
58
58
|
/** Conclude a transaction by generating an immutable `RevisionView` from this view */
|
package/dist/RevisionView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1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":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copyPropertyIfDefined, fail, Mutable, MutableMap } from './Common';\nimport { Forest } from './Forest';\nimport { NodeId, StableNodeId, TraitLabel } from './Identifiers';\nimport { NodeIdConverter } from './NodeIdUtilities';\nimport { Payload, TreeNode, TreeNodeSequence } from './persisted-types';\nimport { TreeView, TreeViewNode, TreeViewPlace, TreeViewRange } from './TreeView';\nimport { HasVariadicTraits } from './ChangeTypes';\n\n/**\n * An immutable view of a distributed tree.\n * @internal\n */\nexport class RevisionView extends TreeView {\n\t/**\n\t * Constructs a {@link RevisionView} using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the {@link RevisionView}\n\t * @param expensiveValidation - whether or not to perform additional validation, e.g. to catch errors when testing\n\t */\n\tpublic static fromTree<T extends TreeNode<T, NodeId>>(root: T, expensiveValidation?: boolean): RevisionView;\n\t/**\n\t * Constructs a {@link RevisionView} using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the `RevisionView`\n\t * @param idConverter - the {@link NodeIdConverter} that will recompress the IDs the in the tree\n\t * @param expensiveValidation - whether or not to perform additional validation, e.g. to catch errors when testing\n\t */\n\tpublic static fromTree<T extends TreeNode<T, StableNodeId>>(\n\t\troot: T,\n\t\tidConverter: NodeIdConverter,\n\t\texpensiveValidation?: boolean\n\t): RevisionView;\n\n\tpublic static fromTree<T extends TreeNode<T, NodeId> | TreeNode<T, StableNodeId>>(\n\t\troot: T,\n\t\tidConverterOrExpensiveValidation?: NodeIdConverter | boolean,\n\t\texpensiveValidation = false\n\t): RevisionView {\n\t\tif (typeof idConverterOrExpensiveValidation === 'object') {\n\t\t\tconst rootId = idConverterOrExpensiveValidation.convertToNodeId(root.identifier as StableNodeId);\n\n\t\t\tconst treeViewNodes = convertTreeNodesToViewNodes(root, (node) => {\n\t\t\t\tconst identifier = idConverterOrExpensiveValidation.convertToNodeId(node.identifier as StableNodeId);\n\t\t\t\tconst viewNode = {\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\tidentifier,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, viewNode, 'payload');\n\t\t\t\treturn viewNode;\n\t\t\t});\n\n\t\t\treturn new RevisionView(rootId, Forest.create(expensiveValidation).add(treeViewNodes));\n\t\t} else {\n\t\t\treturn new RevisionView(\n\t\t\t\troot.identifier as NodeId,\n\t\t\t\tForest.create(expensiveValidation).add(\n\t\t\t\t\tconvertTreeNodesToViewNodes(root, (node) => {\n\t\t\t\t\t\tconst viewNode = {\n\t\t\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\t\t\tidentifier: node.identifier as NodeId,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcopyPropertyIfDefined(node, viewNode, 'payload');\n\t\t\t\t\t\treturn viewNode;\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Begin a transaction by generating a mutable `TransactionView` from this view */\n\tpublic openForTransaction(): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest);\n\t}\n\n\tpublic equals(view: TreeView): boolean {\n\t\tif (!(view instanceof RevisionView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.hasEqualForest(view);\n\t}\n}\n\n/**\n * An view of a distributed tree that is part of an ongoing transaction between `RevisionView`s.\n * @internal\n */\nexport class TransactionView extends TreeView {\n\t/** Conclude a transaction by generating an immutable `RevisionView` from this view */\n\tpublic close(): RevisionView {\n\t\treturn new RevisionView(this.root, this.forest);\n\t}\n\n\t/** Inserts all nodes in a NodeSequence into the view */\n\tpublic addNodes(sequence: Iterable<TreeViewNode>): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.add(sequence));\n\t}\n\n\t/** Remove all nodes with the given ids from the view */\n\tpublic deleteNodes(nodes: Iterable<NodeId>): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.delete(nodes, true));\n\t}\n\n\t/**\n\t * Parents a set of detached nodes at a specified place.\n\t * @param nodesToAttach - the nodes to parent in the specified place. The nodes must already be present in the view.\n\t * @param place - the location to insert the nodes.\n\t */\n\tpublic attachRange(nodesToAttach: readonly NodeId[], place: TreeViewPlace): TransactionView {\n\t\tconst { parent, label } = place.trait;\n\t\tconst index = this.findIndexWithinTrait(place);\n\t\treturn new TransactionView(this.root, this.forest.attachRangeOfChildren(parent, label, index, nodesToAttach));\n\t}\n\n\t/**\n\t * Detaches a range of nodes from their parent. The detached nodes remain in the view.\n\t * @param rangeToDetach - the range of nodes to detach\n\t */\n\tpublic detachRange(rangeToDetach: TreeViewRange): { view: TransactionView; detached: readonly NodeId[] } {\n\t\tconst { start, end } = rangeToDetach;\n\t\tconst { trait: traitLocation } = start;\n\t\tconst { parent, label } = traitLocation;\n\t\tconst startIndex = this.findIndexWithinTrait(start);\n\t\tconst endIndex = this.findIndexWithinTrait(end);\n\t\tconst { forest, detached } = this.forest.detachRangeOfChildren(parent, label, startIndex, endIndex);\n\t\treturn { view: new TransactionView(this.root, forest), detached };\n\t}\n\n\t/**\n\t * Sets or overwrites a node's value. The node must exist in this view.\n\t * @param nodeId - the id of the node\n\t * @param value - the new value\n\t */\n\tpublic setNodeValue(nodeId: NodeId, value: Payload): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.setValue(nodeId, value));\n\t}\n\n\tpublic equals(view: TreeView): boolean {\n\t\tif (!(view instanceof TransactionView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.hasEqualForest(view);\n\t}\n}\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n * Returning undefined means that conversion for the given node was impossible, at which time the entire tree conversion will be aborted\n * and return undefined.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'>): TOut[];\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'> | undefined): TOut[] | undefined;\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n * Returning undefined means that conversion for the given node was impossible, at which time the entire tree conversion will be aborted\n * and return undefined.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'> | undefined): TOut[] | undefined {\n\tconst convertedRoot = convert(root) as Mutable<TOut>;\n\tif (convertedRoot === undefined || root.traits === undefined) {\n\t\treturn undefined;\n\t}\n\t// `convertedRoot` might be the same as `root`, in which case stash the children of `root` before wiping them from `convertedRoot`\n\tconst rootTraits = (root as unknown as TOut) === convertedRoot ? { traits: root.traits } : root;\n\tconvertedRoot.traits = new Map();\n\tconst pendingNodes: {\n\t\tchildIterator: Iterator<[TraitLabel, TIn]>;\n\t\tnewNode: Mutable<TOut>;\n\t}[] = [{ childIterator: iterateChildren(rootTraits)[Symbol.iterator](), newNode: convertedRoot }];\n\tconst resultNodes: TOut[] = [];\n\n\twhile (pendingNodes.length > 0) {\n\t\tconst { childIterator, newNode } = pendingNodes[pendingNodes.length - 1] ?? fail('Undefined node');\n\t\tconst { value, done } = childIterator.next();\n\t\tif (done === true) {\n\t\t\tresultNodes.push(\n\t\t\t\tpendingNodes.pop()?.newNode ?? fail('covertTreeNodesToViewNodes incorrectly coordinated parentage')\n\t\t\t);\n\t\t} else {\n\t\t\tconst [traitLabel, child] = value as [TraitLabel, TIn];\n\t\t\tconst convertedChild = convert(child) as TOut;\n\t\t\tif (convertedChild === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (child.traits !== undefined) {\n\t\t\t\tconst childTraits = (child as unknown as TOut) === convertedChild ? { traits: child.traits } : child;\n\t\t\t\t(convertedChild as Mutable<TOut>).traits = new Map();\n\t\t\t\tpendingNodes.push({\n\t\t\t\t\tchildIterator: iterateChildren(childTraits)[Symbol.iterator](),\n\t\t\t\t\tnewNode: convertedChild,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst newTraits = newNode.traits as MutableMap<TOut['traits']>;\n\t\t\tlet newTrait = newTraits.get(traitLabel);\n\t\t\tif (newTrait === undefined) {\n\t\t\t\tnewTrait = [];\n\t\t\t\tnewTraits.set(traitLabel, newTrait);\n\t\t\t}\n\t\t\t(newTrait as NodeId[]).push(convertedChild.identifier);\n\t\t}\n\t}\n\n\treturn resultNodes;\n}\n\n/**\n * Returns an iterable of the supplied node's traits in a stable order.\n */\nexport function* iterateChildren<T>(hasTraits: HasVariadicTraits<T>): Iterable<[TraitLabel, T]> {\n\tif (hasTraits.traits !== undefined) {\n\t\tfor (const [label, trait] of Object.entries(hasTraits.traits).sort()) {\n\t\t\tif (trait !== undefined) {\n\t\t\t\tif (isTreeNodeSequence(trait)) {\n\t\t\t\t\tfor (const child of trait) {\n\t\t\t\t\t\tyield [label as TraitLabel, child];\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tyield [label as TraitLabel, trait];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction isTreeNodeSequence<TChild>(sequence: TreeNodeSequence<TChild> | TChild): sequence is TreeNodeSequence<TChild> {\n\treturn Array.isArray(sequence);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RevisionView.js","sourceRoot":"","sources":["../src/RevisionView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAA4E;AAC5E,qCAAkC;AAIlC,yCAAkF;AAGlF;;;GAGG;AACH,MAAa,YAAa,SAAQ,mBAAQ;IAmBlC,MAAM,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Ac;iBACvB,CAAC,CAAC;aACH;YAED,MAAM,SAAS,GAAG,OAAO,CAAC,MAAoC,CAAC;YAC/D,IAAI,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACzC,IAAI,QAAQ,KAAK,SAAS,EAAE;gBAC3B,QAAQ,GAAG,EAAE,CAAC;gBACd,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;aACpC;YACA,QAAqB,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;SACvD;KACD;IAED,OAAO,WAAW,CAAC;AACpB,CAAC;AAlDD,kEAkDC;AAED;;GAEG;AACH,QAAe,CAAC,CAAC,eAAe,CAAI,SAA+B;IAClE,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,EAAE;QACnC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACrE,IAAI,KAAK,KAAK,SAAS,EAAE;gBACxB,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE;oBAC9B,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;wBAC1B,MAAM,CAAC,KAAmB,EAAE,KAAK,CAAC,CAAC;qBACnC;iBACD;qBAAM;oBACN,MAAM,CAAC,KAAmB,EAAE,KAAK,CAAC,CAAC;iBACnC;aACD;SACD;KACD;AACF,CAAC;AAdD,0CAcC;AAED,SAAS,kBAAkB,CAAS,QAA2C;IAC9E,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copyPropertyIfDefined, fail, Mutable, MutableMap } from './Common';\nimport { Forest } from './Forest';\nimport { NodeId, StableNodeId, TraitLabel } from './Identifiers';\nimport { NodeIdConverter } from './NodeIdUtilities';\nimport { Payload, TreeNode, TreeNodeSequence } from './persisted-types';\nimport { TreeView, TreeViewNode, TreeViewPlace, TreeViewRange } from './TreeView';\nimport { HasVariadicTraits } from './ChangeTypes';\n\n/**\n * An immutable view of a distributed tree.\n * @alpha\n */\nexport class RevisionView extends TreeView {\n\t/**\n\t * Constructs a {@link RevisionView} using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the {@link RevisionView}\n\t * @param expensiveValidation - whether or not to perform additional validation, e.g. to catch errors when testing\n\t */\n\tpublic static fromTree<T extends TreeNode<T, NodeId>>(root: T, expensiveValidation?: boolean): RevisionView;\n\t/**\n\t * Constructs a {@link RevisionView} using the supplied tree.\n\t * @param root - the root of the tree to use as the contents of the `RevisionView`\n\t * @param idConverter - the {@link NodeIdConverter} that will recompress the IDs the in the tree\n\t * @param expensiveValidation - whether or not to perform additional validation, e.g. to catch errors when testing\n\t */\n\tpublic static fromTree<T extends TreeNode<T, StableNodeId>>(\n\t\troot: T,\n\t\tidConverter: NodeIdConverter,\n\t\texpensiveValidation?: boolean\n\t): RevisionView;\n\n\tpublic static fromTree<T extends TreeNode<T, NodeId> | TreeNode<T, StableNodeId>>(\n\t\troot: T,\n\t\tidConverterOrExpensiveValidation?: NodeIdConverter | boolean,\n\t\texpensiveValidation = false\n\t): RevisionView {\n\t\tif (typeof idConverterOrExpensiveValidation === 'object') {\n\t\t\tconst rootId = idConverterOrExpensiveValidation.convertToNodeId(root.identifier as StableNodeId);\n\n\t\t\tconst treeViewNodes = convertTreeNodesToViewNodes(root, (node) => {\n\t\t\t\tconst identifier = idConverterOrExpensiveValidation.convertToNodeId(node.identifier as StableNodeId);\n\t\t\t\tconst viewNode = {\n\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\tidentifier,\n\t\t\t\t};\n\t\t\t\tcopyPropertyIfDefined(node, viewNode, 'payload');\n\t\t\t\treturn viewNode;\n\t\t\t});\n\n\t\t\treturn new RevisionView(rootId, Forest.create(expensiveValidation).add(treeViewNodes));\n\t\t} else {\n\t\t\treturn new RevisionView(\n\t\t\t\troot.identifier as NodeId,\n\t\t\t\tForest.create(expensiveValidation).add(\n\t\t\t\t\tconvertTreeNodesToViewNodes(root, (node) => {\n\t\t\t\t\t\tconst viewNode = {\n\t\t\t\t\t\t\tdefinition: node.definition,\n\t\t\t\t\t\t\tidentifier: node.identifier as NodeId,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcopyPropertyIfDefined(node, viewNode, 'payload');\n\t\t\t\t\t\treturn viewNode;\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\t/** Begin a transaction by generating a mutable `TransactionView` from this view */\n\tpublic openForTransaction(): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest);\n\t}\n\n\tpublic equals(view: TreeView): boolean {\n\t\tif (!(view instanceof RevisionView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.hasEqualForest(view);\n\t}\n}\n\n/**\n * An view of a distributed tree that is part of an ongoing transaction between `RevisionView`s.\n * @alpha\n */\nexport class TransactionView extends TreeView {\n\t/** Conclude a transaction by generating an immutable `RevisionView` from this view */\n\tpublic close(): RevisionView {\n\t\treturn new RevisionView(this.root, this.forest);\n\t}\n\n\t/** Inserts all nodes in a NodeSequence into the view */\n\tpublic addNodes(sequence: Iterable<TreeViewNode>): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.add(sequence));\n\t}\n\n\t/** Remove all nodes with the given ids from the view */\n\tpublic deleteNodes(nodes: Iterable<NodeId>): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.delete(nodes, true));\n\t}\n\n\t/**\n\t * Parents a set of detached nodes at a specified place.\n\t * @param nodesToAttach - the nodes to parent in the specified place. The nodes must already be present in the view.\n\t * @param place - the location to insert the nodes.\n\t */\n\tpublic attachRange(nodesToAttach: readonly NodeId[], place: TreeViewPlace): TransactionView {\n\t\tconst { parent, label } = place.trait;\n\t\tconst index = this.findIndexWithinTrait(place);\n\t\treturn new TransactionView(this.root, this.forest.attachRangeOfChildren(parent, label, index, nodesToAttach));\n\t}\n\n\t/**\n\t * Detaches a range of nodes from their parent. The detached nodes remain in the view.\n\t * @param rangeToDetach - the range of nodes to detach\n\t */\n\tpublic detachRange(rangeToDetach: TreeViewRange): { view: TransactionView; detached: readonly NodeId[] } {\n\t\tconst { start, end } = rangeToDetach;\n\t\tconst { trait: traitLocation } = start;\n\t\tconst { parent, label } = traitLocation;\n\t\tconst startIndex = this.findIndexWithinTrait(start);\n\t\tconst endIndex = this.findIndexWithinTrait(end);\n\t\tconst { forest, detached } = this.forest.detachRangeOfChildren(parent, label, startIndex, endIndex);\n\t\treturn { view: new TransactionView(this.root, forest), detached };\n\t}\n\n\t/**\n\t * Sets or overwrites a node's value. The node must exist in this view.\n\t * @param nodeId - the id of the node\n\t * @param value - the new value\n\t */\n\tpublic setNodeValue(nodeId: NodeId, value: Payload): TransactionView {\n\t\treturn new TransactionView(this.root, this.forest.setValue(nodeId, value));\n\t}\n\n\tpublic equals(view: TreeView): boolean {\n\t\tif (!(view instanceof TransactionView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.hasEqualForest(view);\n\t}\n}\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n * Returning undefined means that conversion for the given node was impossible, at which time the entire tree conversion will be aborted\n * and return undefined.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'>): TOut[];\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'> | undefined): TOut[] | undefined;\n\n/**\n * Transform an input tree into a list of {@link TreeViewNode}s.\n * @param tree - the input tree\n * @param convert - a conversion function that will run on each node in the input tree to produce the output nodes.\n * Returning undefined means that conversion for the given node was impossible, at which time the entire tree conversion will be aborted\n * and return undefined.\n */\nexport function convertTreeNodesToViewNodes<\n\tTIn extends HasVariadicTraits<TIn>,\n\tTOut extends TreeViewNode = TreeViewNode,\n>(root: TIn, convert: (node: TIn) => Omit<TOut, 'traits'> | undefined): TOut[] | undefined {\n\tconst convertedRoot = convert(root) as Mutable<TOut>;\n\tif (convertedRoot === undefined || root.traits === undefined) {\n\t\treturn undefined;\n\t}\n\t// `convertedRoot` might be the same as `root`, in which case stash the children of `root` before wiping them from `convertedRoot`\n\tconst rootTraits = (root as unknown as TOut) === convertedRoot ? { traits: root.traits } : root;\n\tconvertedRoot.traits = new Map();\n\tconst pendingNodes: {\n\t\tchildIterator: Iterator<[TraitLabel, TIn]>;\n\t\tnewNode: Mutable<TOut>;\n\t}[] = [{ childIterator: iterateChildren(rootTraits)[Symbol.iterator](), newNode: convertedRoot }];\n\tconst resultNodes: TOut[] = [];\n\n\twhile (pendingNodes.length > 0) {\n\t\tconst { childIterator, newNode } = pendingNodes[pendingNodes.length - 1] ?? fail('Undefined node');\n\t\tconst { value, done } = childIterator.next();\n\t\tif (done === true) {\n\t\t\tresultNodes.push(\n\t\t\t\tpendingNodes.pop()?.newNode ?? fail('covertTreeNodesToViewNodes incorrectly coordinated parentage')\n\t\t\t);\n\t\t} else {\n\t\t\tconst [traitLabel, child] = value as [TraitLabel, TIn];\n\t\t\tconst convertedChild = convert(child) as TOut;\n\t\t\tif (convertedChild === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (child.traits !== undefined) {\n\t\t\t\tconst childTraits = (child as unknown as TOut) === convertedChild ? { traits: child.traits } : child;\n\t\t\t\t(convertedChild as Mutable<TOut>).traits = new Map();\n\t\t\t\tpendingNodes.push({\n\t\t\t\t\tchildIterator: iterateChildren(childTraits)[Symbol.iterator](),\n\t\t\t\t\tnewNode: convertedChild,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst newTraits = newNode.traits as MutableMap<TOut['traits']>;\n\t\t\tlet newTrait = newTraits.get(traitLabel);\n\t\t\tif (newTrait === undefined) {\n\t\t\t\tnewTrait = [];\n\t\t\t\tnewTraits.set(traitLabel, newTrait);\n\t\t\t}\n\t\t\t(newTrait as NodeId[]).push(convertedChild.identifier);\n\t\t}\n\t}\n\n\treturn resultNodes;\n}\n\n/**\n * Returns an iterable of the supplied node's traits in a stable order.\n */\nexport function* iterateChildren<T>(hasTraits: HasVariadicTraits<T>): Iterable<[TraitLabel, T]> {\n\tif (hasTraits.traits !== undefined) {\n\t\tfor (const [label, trait] of Object.entries(hasTraits.traits).sort()) {\n\t\t\tif (trait !== undefined) {\n\t\t\t\tif (isTreeNodeSequence(trait)) {\n\t\t\t\t\tfor (const child of trait) {\n\t\t\t\t\t\tyield [label as TraitLabel, child];\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tyield [label as TraitLabel, trait];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction isTreeNodeSequence<TChild>(sequence: TreeNodeSequence<TChild> | TChild): sequence is TreeNodeSequence<TChild> {\n\treturn Array.isArray(sequence);\n}\n"]}
|
package/dist/SharedTree.d.ts
CHANGED
|
@@ -18,17 +18,17 @@ import { Change } from './ChangeTypes';
|
|
|
18
18
|
import { TransactionInternal } from './TransactionInternal';
|
|
19
19
|
/**
|
|
20
20
|
* The write format and associated options used to construct a `SharedTree`
|
|
21
|
-
* @
|
|
21
|
+
* @alpha
|
|
22
22
|
*/
|
|
23
23
|
export type SharedTreeArgs<WF extends WriteFormat = WriteFormat> = [writeFormat: WF, options?: SharedTreeOptions<WF>];
|
|
24
24
|
/**
|
|
25
25
|
* The type of shared tree options for a given write format
|
|
26
|
-
* @
|
|
26
|
+
* @alpha
|
|
27
27
|
*/
|
|
28
28
|
export type SharedTreeOptions<WF extends WriteFormat, HistoryCompatibility extends 'Forwards' | 'None' = 'Forwards'> = SharedTreeBaseOptions & Omit<WF extends WriteFormat.v0_0_2 ? SharedTreeOptions_0_0_2 : WF extends WriteFormat.v0_1_1 ? SharedTreeOptions_0_1_1 : never, HistoryCompatibility extends 'Forwards' ? 'summarizeHistory' : never>;
|
|
29
29
|
/**
|
|
30
30
|
* Configuration options for SharedTree that are independent of write format versions.
|
|
31
|
-
* @
|
|
31
|
+
* @alpha
|
|
32
32
|
*/
|
|
33
33
|
export interface SharedTreeBaseOptions {
|
|
34
34
|
/**
|
|
@@ -48,7 +48,7 @@ export interface SharedTreeBaseOptions {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Configuration options for a SharedTree with write format 0.0.2
|
|
51
|
-
* @
|
|
51
|
+
* @alpha
|
|
52
52
|
*/
|
|
53
53
|
export interface SharedTreeOptions_0_0_2 {
|
|
54
54
|
/**
|
|
@@ -69,7 +69,7 @@ export interface SharedTreeOptions_0_0_2 {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Configuration options for a SharedTree with write format 0.1.1
|
|
72
|
-
* @
|
|
72
|
+
* @alpha
|
|
73
73
|
*/
|
|
74
74
|
export interface SharedTreeOptions_0_1_1 {
|
|
75
75
|
/**
|
|
@@ -95,7 +95,7 @@ export interface SharedTreeOptions_0_1_1 {
|
|
|
95
95
|
/**
|
|
96
96
|
* Factory for SharedTree.
|
|
97
97
|
* Includes history in the summary.
|
|
98
|
-
* @
|
|
98
|
+
* @alpha
|
|
99
99
|
*/
|
|
100
100
|
export declare class SharedTreeFactory implements IChannelFactory {
|
|
101
101
|
/**
|
|
@@ -137,7 +137,7 @@ export declare class SharedTreeFactory implements IChannelFactory {
|
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* The arguments included when the EditCommitted SharedTreeEvent is emitted.
|
|
140
|
-
* @
|
|
140
|
+
* @alpha
|
|
141
141
|
*/
|
|
142
142
|
export interface EditCommittedEventArguments {
|
|
143
143
|
/** The ID of the edit committed. */
|
|
@@ -149,7 +149,7 @@ export interface EditCommittedEventArguments {
|
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* The arguments included when the {@link SharedTreeEvent.SequencedEditApplied} SharedTreeEvent is emitted.
|
|
152
|
-
* @
|
|
152
|
+
* @alpha
|
|
153
153
|
*/
|
|
154
154
|
export interface SequencedEditAppliedEventArguments {
|
|
155
155
|
/** The ID of the edit committed. */
|
|
@@ -167,7 +167,7 @@ export interface SequencedEditAppliedEventArguments {
|
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* The outcome of an edit.
|
|
170
|
-
* @
|
|
170
|
+
* @alpha
|
|
171
171
|
*/
|
|
172
172
|
export type EditApplicationOutcome = {
|
|
173
173
|
/**
|
|
@@ -190,7 +190,7 @@ export type EditApplicationOutcome = {
|
|
|
190
190
|
};
|
|
191
191
|
/**
|
|
192
192
|
* Events which may be emitted by `SharedTree`. See {@link SharedTreeEvent} for documentation of event semantics.
|
|
193
|
-
* @
|
|
193
|
+
* @alpha
|
|
194
194
|
*/
|
|
195
195
|
export interface ISharedTreeEvents extends ISharedObjectEvents {
|
|
196
196
|
(event: 'committedEdit', listener: EditCommittedHandler): any;
|
|
@@ -198,17 +198,17 @@ export interface ISharedTreeEvents extends ISharedObjectEvents {
|
|
|
198
198
|
}
|
|
199
199
|
/**
|
|
200
200
|
* Expected type for a handler of the `EditCommitted` event.
|
|
201
|
-
* @
|
|
201
|
+
* @alpha
|
|
202
202
|
*/
|
|
203
203
|
export type EditCommittedHandler = (args: EditCommittedEventArguments) => void;
|
|
204
204
|
/**
|
|
205
205
|
* Expected type for a handler of the {@link SharedTreeEvent.SequencedEditApplied} event.
|
|
206
|
-
* @
|
|
206
|
+
* @alpha
|
|
207
207
|
*/
|
|
208
208
|
export type SequencedEditAppliedHandler = (args: SequencedEditAppliedEventArguments) => void;
|
|
209
209
|
/**
|
|
210
210
|
* Contains information resulting from processing stashed shared tree ops
|
|
211
|
-
* @
|
|
211
|
+
* @alpha
|
|
212
212
|
*/
|
|
213
213
|
export interface StashedLocalOpMetadata {
|
|
214
214
|
/** A modified version of the edit in an edit op that should be resubmitted rather than the original edit */
|
|
@@ -216,7 +216,7 @@ export interface StashedLocalOpMetadata {
|
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
218
|
* A [distributed tree](../Readme.md).
|
|
219
|
-
* @
|
|
219
|
+
* @alpha
|
|
220
220
|
*/
|
|
221
221
|
export declare class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeIdContext {
|
|
222
222
|
private writeFormat;
|
package/dist/SharedTree.js
CHANGED
|
@@ -32,7 +32,7 @@ const UuidUtilities_1 = require("./UuidUtilities");
|
|
|
32
32
|
/**
|
|
33
33
|
* Factory for SharedTree.
|
|
34
34
|
* Includes history in the summary.
|
|
35
|
-
* @
|
|
35
|
+
* @alpha
|
|
36
36
|
*/
|
|
37
37
|
class SharedTreeFactory {
|
|
38
38
|
/**
|
|
@@ -113,7 +113,7 @@ const sharedTreeTelemetryProperties = { all: { isSharedTreeEvent: true } };
|
|
|
113
113
|
const stashedSessionId = '8477b8d5-cf6c-4673-8345-8f076a8f9bc6';
|
|
114
114
|
/**
|
|
115
115
|
* A [distributed tree](../Readme.md).
|
|
116
|
-
* @
|
|
116
|
+
* @alpha
|
|
117
117
|
*/
|
|
118
118
|
class SharedTree extends shared_object_base_1.SharedObject {
|
|
119
119
|
/**
|