@fluidframework/sequence 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.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.
Files changed (94) hide show
  1. package/.eslintrc.js +9 -12
  2. package/.mocharc.js +2 -2
  3. package/.vscode/launch.json +15 -14
  4. package/README.md +188 -179
  5. package/api-extractor.json +2 -2
  6. package/dist/defaultMap.d.ts.map +1 -1
  7. package/dist/defaultMap.js +5 -4
  8. package/dist/defaultMap.js.map +1 -1
  9. package/dist/defaultMapInterfaces.d.ts.map +1 -1
  10. package/dist/defaultMapInterfaces.js.map +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/intervalCollection.d.ts.map +1 -1
  15. package/dist/intervalCollection.js +50 -36
  16. package/dist/intervalCollection.js.map +1 -1
  17. package/dist/intervalTree.d.ts.map +1 -1
  18. package/dist/intervalTree.js.map +1 -1
  19. package/dist/localValues.d.ts.map +1 -1
  20. package/dist/localValues.js.map +1 -1
  21. package/dist/packageVersion.d.ts +1 -1
  22. package/dist/packageVersion.js +1 -1
  23. package/dist/packageVersion.js.map +1 -1
  24. package/dist/sequence.d.ts +1 -1
  25. package/dist/sequence.d.ts.map +1 -1
  26. package/dist/sequence.js +13 -17
  27. package/dist/sequence.js.map +1 -1
  28. package/dist/sequenceDeltaEvent.d.ts.map +1 -1
  29. package/dist/sequenceDeltaEvent.js.map +1 -1
  30. package/dist/sequenceFactory.d.ts.map +1 -1
  31. package/dist/sequenceFactory.js.map +1 -1
  32. package/dist/sharedIntervalCollection.d.ts.map +1 -1
  33. package/dist/sharedIntervalCollection.js.map +1 -1
  34. package/dist/sharedSequence.d.ts.map +1 -1
  35. package/dist/sharedSequence.js +3 -3
  36. package/dist/sharedSequence.js.map +1 -1
  37. package/dist/sharedString.d.ts.map +1 -1
  38. package/dist/sharedString.js +5 -4
  39. package/dist/sharedString.js.map +1 -1
  40. package/lib/defaultMap.d.ts.map +1 -1
  41. package/lib/defaultMap.js +6 -5
  42. package/lib/defaultMap.js.map +1 -1
  43. package/lib/defaultMapInterfaces.d.ts.map +1 -1
  44. package/lib/defaultMapInterfaces.js.map +1 -1
  45. package/lib/index.d.ts +2 -2
  46. package/lib/index.d.ts.map +1 -1
  47. package/lib/index.js +2 -2
  48. package/lib/index.js.map +1 -1
  49. package/lib/intervalCollection.d.ts.map +1 -1
  50. package/lib/intervalCollection.js +50 -36
  51. package/lib/intervalCollection.js.map +1 -1
  52. package/lib/intervalTree.d.ts.map +1 -1
  53. package/lib/intervalTree.js.map +1 -1
  54. package/lib/localValues.d.ts.map +1 -1
  55. package/lib/localValues.js +1 -1
  56. package/lib/localValues.js.map +1 -1
  57. package/lib/packageVersion.d.ts +1 -1
  58. package/lib/packageVersion.js +1 -1
  59. package/lib/packageVersion.js.map +1 -1
  60. package/lib/sequence.d.ts +1 -1
  61. package/lib/sequence.d.ts.map +1 -1
  62. package/lib/sequence.js +15 -19
  63. package/lib/sequence.js.map +1 -1
  64. package/lib/sequenceDeltaEvent.d.ts.map +1 -1
  65. package/lib/sequenceDeltaEvent.js.map +1 -1
  66. package/lib/sequenceFactory.d.ts.map +1 -1
  67. package/lib/sequenceFactory.js +1 -1
  68. package/lib/sequenceFactory.js.map +1 -1
  69. package/lib/sharedIntervalCollection.d.ts.map +1 -1
  70. package/lib/sharedIntervalCollection.js.map +1 -1
  71. package/lib/sharedSequence.d.ts.map +1 -1
  72. package/lib/sharedSequence.js +4 -4
  73. package/lib/sharedSequence.js.map +1 -1
  74. package/lib/sharedString.d.ts.map +1 -1
  75. package/lib/sharedString.js +5 -4
  76. package/lib/sharedString.js.map +1 -1
  77. package/package.json +55 -55
  78. package/prettier.config.cjs +1 -1
  79. package/src/defaultMap.ts +406 -405
  80. package/src/defaultMapInterfaces.ts +120 -115
  81. package/src/index.ts +27 -17
  82. package/src/intervalCollection.ts +2198 -1997
  83. package/src/intervalTree.ts +139 -139
  84. package/src/localValues.ts +64 -73
  85. package/src/packageVersion.ts +1 -1
  86. package/src/sequence.ts +739 -694
  87. package/src/sequenceDeltaEvent.ts +143 -137
  88. package/src/sequenceFactory.ts +48 -46
  89. package/src/sharedIntervalCollection.ts +150 -136
  90. package/src/sharedSequence.ts +165 -160
  91. package/src/sharedString.ts +385 -343
  92. package/tsconfig.esnext.json +6 -6
  93. package/tsconfig.json +8 -12
  94. package/.editorconfig +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"sharedIntervalCollection.js","sourceRoot":"","sources":["../src/sharedIntervalCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,+DAA8D;AAQ9D,+EAA8F;AAE9F,2EAI4C;AAC5C,6DAK8B;AAC9B,6CAA0C;AAC1C,qDAA8C;AAG9C,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;GAGG;AACH,MAAa,+BAA+B;IASxC,IAAW,IAAI;QACX,OAAO,+BAA+B,CAAC,IAAI,CAAC;IAChD,CAAC;IAED,IAAW,UAAU;QACjB,OAAO,+BAA+B,CAAC,UAAU,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CACb,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAC9B,MAAM,GAAG,GAAG,IAAI,wBAAwB,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAClE,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzB,OAAO,GAAG,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,OAA+B,EAAE,EAAU;QACrD,MAAM,GAAG,GAAG,IAAI,wBAAwB,CACpC,EAAE,EACF,OAAO,EACP,IAAI,CAAC,UAAU,CAAC,CAAC;QACrB,GAAG,CAAC,eAAe,EAAE,CAAC;QAEtB,OAAO,GAAG,CAAC;IACf,CAAC;;AAvCL,0EAwCC;AAvC0B,oCAAI,GAAG,4DAA4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E,eAAwB;QACzD,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,EAAE,eAA2C,CAAC,CAAC;IACtG,CAAC;IAES,YAAY,KAAK,CAAC;IAE5B;;OAEG;IACO,KAAK,CAAC,QAAQ,CAAC,OAA+B;QACpD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAES,WAAW,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QAC9F,IAAI,OAAO,CAAC,IAAI,KAAK,kCAAW,CAAC,SAAS,EAAE;YACxC,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;SACjG;IACL,CAAC;IAED;;;OAGG;IACO,yBAAyB,CAAC,KAAa;QAC7C,OAAO,KAAK,CAAC;IACjB,CAAC;IAES,cAAc;QACpB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ;AArFD,4DAqFC;KA/DoB,MAAM,CAAC,WAAW","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluidframework/common-utils\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelServices,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n createSingleBlobSummary,\n IFluidSerializer,\n SharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport {\n Interval,\n IntervalCollection,\n IntervalCollectionValueType,\n ISerializableInterval,\n} from \"./intervalCollection\";\nimport { DefaultMap } from \"./defaultMap\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { IMapMessageLocalMetadata } from \"./defaultMapInterfaces\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * The factory that defines the SharedIntervalCollection.\n * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.\n */\nexport class SharedIntervalCollectionFactory implements IChannelFactory {\n public static readonly Type = \"https://graph.microsoft.com/types/sharedIntervalCollection\";\n\n public static readonly Attributes: IChannelAttributes = {\n type: SharedIntervalCollectionFactory.Type,\n snapshotFormatVersion: \"0.1\",\n packageVersion: pkgVersion,\n };\n\n public get type() {\n return SharedIntervalCollectionFactory.Type;\n }\n\n public get attributes() {\n return SharedIntervalCollectionFactory.Attributes;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n */\n public async load(\n runtime: IFluidDataStoreRuntime,\n id: string,\n services: IChannelServices,\n attributes: IChannelAttributes): Promise<SharedIntervalCollection> {\n const map = new SharedIntervalCollection(id, runtime, attributes);\n await map.load(services);\n\n return map;\n }\n\n public create(runtime: IFluidDataStoreRuntime, id: string): SharedIntervalCollection {\n const map = new SharedIntervalCollection(\n id,\n runtime,\n this.attributes);\n map.initializeLocal();\n\n return map;\n }\n}\n\nexport interface ISharedIntervalCollection<TInterval extends ISerializableInterval> {\n getIntervalCollection(label: string): IntervalCollection<TInterval>;\n}\n\n/**\n * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.\n */\nexport class SharedIntervalCollection\n extends SharedObject implements ISharedIntervalCollection<Interval> {\n /**\n * Create a SharedIntervalCollection\n *\n * @param runtime - data store runtime the new shared map belongs to\n * @param id - optional name of the shared map\n * @returns newly create shared map (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string) {\n return runtime.createChannel(id, SharedIntervalCollectionFactory.Type) as SharedIntervalCollection;\n }\n\n /**\n * Get a factory for SharedIntervalCollection to register with the data store.\n *\n * @returns a factory that creates and load SharedIntervalCollection\n */\n public static getFactory(): IChannelFactory {\n return new SharedIntervalCollectionFactory();\n }\n\n public readonly [Symbol.toStringTag]: string = \"SharedIntervalCollection\";\n private readonly intervalCollections: DefaultMap<IntervalCollection<Interval>>;\n\n /**\n * Constructs a new shared SharedIntervalCollection. If the object is non-local an id and service interfaces will\n * be provided\n */\n constructor(\n id: string,\n runtime: IFluidDataStoreRuntime,\n attributes: IChannelAttributes,\n ) {\n super(id, runtime, attributes, \"fluid_sharedIntervalCollection_\");\n this.intervalCollections = new DefaultMap(\n this.serializer,\n this.handle,\n (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n new IntervalCollectionValueType(),\n );\n }\n\n public getIntervalCollection(label: string): IntervalCollection<Interval> {\n const realLabel = this.getIntervalCollectionPath(label);\n const sharedCollection = this.intervalCollections.get(realLabel);\n return sharedCollection;\n }\n\n protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n return createSingleBlobSummary(snapshotFileName, this.intervalCollections.serialize(serializer));\n }\n\n protected reSubmitCore(content: any, localOpMetadata: unknown) {\n this.intervalCollections.tryResubmitMessage(content, localOpMetadata as IMapMessageLocalMetadata);\n }\n\n protected onDisconnect() { }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n */\n protected async loadCore(storage: IChannelStorageService) {\n const blob = await storage.readBlob(snapshotFileName);\n const header = bufferToString(blob, \"utf8\");\n this.intervalCollections.populate(header);\n }\n\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n if (message.type === MessageType.Operation) {\n this.intervalCollections.tryProcessMessage(message.contents, local, message, localOpMetadata);\n }\n }\n\n /**\n * Creates the full path of the intervalCollection label\n * @param label - the incoming label\n */\n protected getIntervalCollectionPath(label: string): string {\n return label;\n }\n\n protected applyStashedOp() {\n throw new Error(\"not implemented\");\n }\n}\n"]}
1
+ {"version":3,"file":"sharedInterv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,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAES,WAAW,CACpB,OAAkC,EAClC,KAAc,EACd,eAAwB;QAExB,IAAI,OAAO,CAAC,IAAI,KAAK,kCAAW,CAAC,SAAS,EAAE;YAC3C,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CACzC,OAAO,CAAC,QAAQ,EAChB,KAAK,EACL,OAAO,EACP,eAAe,CACf,CAAC;SACF;IACF,CAAC;IAED;;;OAGG;IACO,yBAAyB,CAAC,KAAa;QAChD,OAAO,KAAK,CAAC;IACd,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AArGD,4DAqGC;KA1EiB,MAAM,CAAC,WAAW","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluidframework/common-utils\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelServices,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base\";\nimport {\n\tInterval,\n\tIntervalCollection,\n\tIntervalCollectionValueType,\n\tISerializableInterval,\n} from \"./intervalCollection\";\nimport { DefaultMap } from \"./defaultMap\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { IMapMessageLocalMetadata } from \"./defaultMapInterfaces\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * The factory that defines the SharedIntervalCollection.\n * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.\n */\nexport class SharedIntervalCollectionFactory implements IChannelFactory {\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/sharedIntervalCollection\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: SharedIntervalCollectionFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type() {\n\t\treturn SharedIntervalCollectionFactory.Type;\n\t}\n\n\tpublic get attributes() {\n\t\treturn SharedIntervalCollectionFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<SharedIntervalCollection> {\n\t\tconst map = new SharedIntervalCollection(id, runtime, attributes);\n\t\tawait map.load(services);\n\n\t\treturn map;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): SharedIntervalCollection {\n\t\tconst map = new SharedIntervalCollection(id, runtime, this.attributes);\n\t\tmap.initializeLocal();\n\n\t\treturn map;\n\t}\n}\n\nexport interface ISharedIntervalCollection<TInterval extends ISerializableInterval> {\n\tgetIntervalCollection(label: string): IntervalCollection<TInterval>;\n}\n\n/**\n * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.\n */\nexport class SharedIntervalCollection\n\textends SharedObject\n\timplements ISharedIntervalCollection<Interval>\n{\n\t/**\n\t * Create a SharedIntervalCollection\n\t *\n\t * @param runtime - data store runtime the new shared map belongs to\n\t * @param id - optional name of the shared map\n\t * @returns newly create shared map (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(\n\t\t\tid,\n\t\t\tSharedIntervalCollectionFactory.Type,\n\t\t) as SharedIntervalCollection;\n\t}\n\n\t/**\n\t * Get a factory for SharedIntervalCollection to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedIntervalCollection\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new SharedIntervalCollectionFactory();\n\t}\n\n\tpublic readonly [Symbol.toStringTag]: string = \"SharedIntervalCollection\";\n\tprivate readonly intervalCollections: DefaultMap<IntervalCollection<Interval>>;\n\n\t/**\n\t * Constructs a new shared SharedIntervalCollection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tconstructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {\n\t\tsuper(id, runtime, attributes, \"fluid_sharedIntervalCollection_\");\n\t\tthis.intervalCollections = new DefaultMap(\n\t\t\tthis.serializer,\n\t\t\tthis.handle,\n\t\t\t(op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),\n\t\t\tnew IntervalCollectionValueType(),\n\t\t);\n\t}\n\n\tpublic getIntervalCollection(label: string): IntervalCollection<Interval> {\n\t\tconst realLabel = this.getIntervalCollectionPath(label);\n\t\tconst sharedCollection = this.intervalCollections.get(realLabel);\n\t\treturn sharedCollection;\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(\n\t\t\tsnapshotFileName,\n\t\t\tthis.intervalCollections.serialize(serializer),\n\t\t);\n\t}\n\n\tprotected reSubmitCore(content: any, localOpMetadata: unknown) {\n\t\tthis.intervalCollections.tryResubmitMessage(\n\t\t\tcontent,\n\t\t\tlocalOpMetadata as IMapMessageLocalMetadata,\n\t\t);\n\t}\n\n\tprotected onDisconnect() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService) {\n\t\tconst blob = await storage.readBlob(snapshotFileName);\n\t\tconst header = bufferToString(blob, \"utf8\");\n\t\tthis.intervalCollections.populate(header);\n\t}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tthis.intervalCollections.tryProcessMessage(\n\t\t\t\tmessage.contents,\n\t\t\t\tlocal,\n\t\t\t\tmessage,\n\t\t\t\tlocalOpMetadata,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Creates the full path of the intervalCollection label\n\t * @param label - the incoming label\n\t */\n\tprotected getIntervalCollectionPath(label: string): string {\n\t\treturn label;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedSequence.d.ts","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EACnD,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACjH,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAInD,MAAM,WAAW,eAAe,CAAC,CAAC,CAAE,SAAQ,YAAY;IACpD,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5B;AAED,qBAAa,WAAW,CAAC,CAAC,CAAE,SAAQ,WAAW;IAkBxB,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE;IAjB3C,gBAAuB,UAAU,EAAE,MAAM,CAAiB;WAC5C,EAAE,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,IAAI,WAAW,CAAC,GAAG,CAAC;WAGlD,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY;IAWlD,SAAgB,IAAI,SAA0B;gBAE3B,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE;IAKpC,YAAY;IAMZ,KAAK,CAAC,KAAK,SAAI,EAAE,GAAG,CAAC,EAAE,MAAM;IAO7B,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAKrC,QAAQ;IAIR,MAAM,CAAC,OAAO,EAAE,QAAQ;I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merge_tree_1.BaseSegment {
41
41
  return b;
42
42
  }
43
43
  canAppend(segment) {
44
- return SubSequence.is(segment)
45
- && (this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun);
44
+ return (SubSequence.is(segment) &&
45
+ (this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun));
46
46
  }
47
47
  toString() {
48
48
  return this.items.toString();
@@ -65,7 +65,7 @@ class SubSequence extends merge_tree_1.BaseSegment {
65
65
  }
66
66
  this.items = remnantItems;
67
67
  this.cachedLength = this.items.length;
68
- return (this.items.length === 0);
68
+ return this.items.length === 0;
69
69
  }
70
70
  createSplitSegmentAt(pos) {
71
71
  if (pos > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"sharedSequence.js","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,2DAEoC;AAEpC,yCAAmD;AAEnD,MAAM,MAAM,GAAG,GAAG,CAAC;AAMnB,MAAa,WAAe,SAAQ,wBAAW;IAkB3C,YAAmB,KAAwB;QACvC,KAAK,EAAE,CAAC;QADO,UAAK,GAAL,KAAK,CAAmB;QAF3B,SAAI,GAAG,WAAW,CAAC,UAAU,CAAC;QAI1C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;IACrC,CAAC;IAnBM,MAAM,CAAC,EAAE,CAAC,OAAiB;QAC9B,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAC;IACnD,CAAC;IACM,MAAM,CAAC,cAAc,CAAI,IAAkB;QAC9C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,EAAE;YACrD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAI,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,IAAI,CAAC,KAAK,EAAE;gBACZ,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrC;YACD,O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AAC,CAAC,CAAC;SAC3D;QACD,IAAI,GAAG,KAAK,SAAS,EAAE;YACnB,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAlFD,wCAkFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n BaseSegment, IJSONSegment, ISegment, PropertySet,\n} from \"@fluidframework/merge-tree\";\nimport { IChannelAttributes, IFluidDataStoreRuntime, Serializable } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\n\nconst MaxRun = 128;\n\nexport interface IJSONRunSegment<T> extends IJSONSegment {\n items: Serializable<T>[];\n}\n\nexport class SubSequence<T> extends BaseSegment {\n public static readonly typeString: string = \"SubSequence\";\n public static is(segment: ISegment): segment is SubSequence<any> {\n return segment.type === SubSequence.typeString;\n }\n public static fromJSONObject<U>(spec: Serializable) {\n if (spec && typeof spec === \"object\" && \"items\" in spec) {\n const segment = new SubSequence<U>(spec.items);\n if (spec.props) {\n segment.addProperties(spec.props);\n }\n return segment;\n }\n return undefined;\n }\n\n public readonly type = SubSequence.typeString;\n\n constructor(public items: Serializable<T>[]) {\n super();\n this.cachedLength = items.length;\n }\n\n public toJSONObject() {\n const obj: IJSONRunSegment<T> = { items: this.items };\n super.addSerializedProps(obj);\n return obj;\n }\n\n public clone(start = 0, end?: number) {\n const clonedItems = this.items.slice(start, end);\n const b = new SubSequence(clonedItems);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment): boolean {\n return SubSequence.is(segment)\n && (this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun);\n }\n\n public toString() {\n return this.items.toString();\n }\n\n public append(segment: ISegment) {\n assert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);\n super.append(segment);\n this.items = this.items.concat(segment.items);\n }\n\n // TODO: retain removed items for undo\n // returns true if entire run removed\n public removeRange(start: number, end: number) {\n let remnantItems: Serializable<T>[] = [];\n const len = this.items.length;\n if (start > 0) {\n remnantItems = remnantItems.concat(this.items.slice(0, start));\n }\n if (end < len) {\n remnantItems = remnantItems.concat(this.items.slice(end));\n }\n this.items = remnantItems;\n this.cachedLength = this.items.length;\n return (this.items.length === 0);\n }\n\n protected createSplitSegmentAt(pos: number) {\n if (pos > 0) {\n const remainingItems = this.items.slice(pos);\n this.items = this.items.slice(0, pos);\n this.cachedLength = this.items.length;\n const leafSegment = new SubSequence(remainingItems);\n return leafSegment;\n }\n }\n}\n\nexport class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {\n constructor(\n document: IFluidDataStoreRuntime,\n public id: string,\n attributes: IChannelAttributes,\n specToSegment: (spec: IJSONSegment) => ISegment,\n ) {\n super(document, id, attributes, specToSegment);\n }\n\n /**\n * @param pos - The position to insert the items at.\n * @param items - The items to insert.\n * @param props - Optional. Properties to set on the inserted items.\n */\n public insert(pos: number, items: Serializable<T>[], props?: PropertySet) {\n const segment = new SubSequence<T>(items);\n if (props) {\n segment.addProperties(props);\n }\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to remove\n */\n public remove(start: number, end: number) {\n this.removeRange(start, end);\n }\n\n /**\n * Returns the total count of items in the sequence\n */\n public getItemCount(): number {\n return this.getLength();\n }\n\n /**\n * Gets the items in the specified range\n *\n * @param start - The inclusive start of the range\n * @param end - The exclusive end of the range\n */\n public getItems(start: number, end?: number): Serializable<T>[] {\n const items: Serializable<T>[] = [];\n let firstSegment: ISegment | undefined;\n\n // Return if the range is incorrect.\n if (end !== undefined && end <= start) {\n return items;\n }\n\n this.walkSegments(\n (segment: ISegment) => {\n if (SubSequence.is(segment)) {\n if (firstSegment === undefined) {\n firstSegment = segment;\n }\n items.push(...segment.items);\n }\n return true;\n },\n start,\n end);\n\n // The above call to walkSegments adds all the items in the walked\n // segments. However, we only want items beginning at |start| in\n // the first segment. Similarly, if |end| is passed in, we only\n // want items until |end| in the last segment. Remove the rest of\n // the items.\n if (firstSegment !== undefined) {\n items.splice(0, start - this.getPosition(firstSegment));\n }\n if (end !== undefined) {\n items.splice(end - start);\n }\n return items;\n }\n}\n"]}
1
+ {"version":3,"file":"sharedSequence.js","sourceRoot":"","sources":["../src/sharedSequence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,2DAA8F;AAM9F,yCAAmD;AAEnD,MAAM,MAAM,GAAG,GAAG,CAAC;AAMnB,MAAa,WAAe,SAAQ,wBAAW;IAkB9C,YAAmB,KAAwB;QAC1C,KAAK,EAAE,CAAC;QADU,UAAK,GAAL,KAAK,CAAmB;QAF3B,SAAI,GAAG,WAAW,CAAC,UAAU,CAAC;QAI7C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;IAClC,CAAC;IAnBM,MAAM,CAAC,EAAE,CAAC,OAAiB;QACjC,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAC;IAChD,CAAC;IACM,MAAM,CAAC,cAAc,CAAI,IAAkB;QACjD,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,EAAE;YACxD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAI,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,IAAI,CAAC,KAAK,EAAE;gBACf,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAClC;YACD,OAAO,OAAO,CAAC;SACf;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IASM,YAAY;QAClB,MAAM,GAAG,GAAuB,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QACtD,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,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C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { BaseSegment, IJSONSegment, ISegment, PropertySet } from \"@fluidframework/merge-tree\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\n\nconst MaxRun = 128;\n\nexport interface IJSONRunSegment<T> extends IJSONSegment {\n\titems: Serializable<T>[];\n}\n\nexport class SubSequence<T> extends BaseSegment {\n\tpublic static readonly typeString: string = \"SubSequence\";\n\tpublic static is(segment: ISegment): segment is SubSequence<any> {\n\t\treturn segment.type === SubSequence.typeString;\n\t}\n\tpublic static fromJSONObject<U>(spec: Serializable) {\n\t\tif (spec && typeof spec === \"object\" && \"items\" in spec) {\n\t\t\tconst segment = new SubSequence<U>(spec.items);\n\t\t\tif (spec.props) {\n\t\t\t\tsegment.addProperties(spec.props);\n\t\t\t}\n\t\t\treturn segment;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic readonly type = SubSequence.typeString;\n\n\tconstructor(public items: Serializable<T>[]) {\n\t\tsuper();\n\t\tthis.cachedLength = items.length;\n\t}\n\n\tpublic toJSONObject() {\n\t\tconst obj: IJSONRunSegment<T> = { items: this.items };\n\t\tsuper.addSerializedProps(obj);\n\t\treturn obj;\n\t}\n\n\tpublic clone(start = 0, end?: number) {\n\t\tconst clonedItems = this.items.slice(start, end);\n\t\tconst b = new SubSequence(clonedItems);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\treturn (\n\t\t\tSubSequence.is(segment) &&\n\t\t\t(this.cachedLength <= MaxRun || segment.cachedLength <= MaxRun)\n\t\t);\n\t}\n\n\tpublic toString() {\n\t\treturn this.items.toString();\n\t}\n\n\tpublic append(segment: ISegment) {\n\t\tassert(SubSequence.is(segment), 0x448 /* can only append to another run segment */);\n\t\tsuper.append(segment);\n\t\tthis.items = this.items.concat(segment.items);\n\t}\n\n\t// TODO: retain removed items for undo\n\t// returns true if entire run removed\n\tpublic removeRange(start: number, end: number) {\n\t\tlet remnantItems: Serializable<T>[] = [];\n\t\tconst len = this.items.length;\n\t\tif (start > 0) {\n\t\t\tremnantItems = remnantItems.concat(this.items.slice(0, start));\n\t\t}\n\t\tif (end < len) {\n\t\t\tremnantItems = remnantItems.concat(this.items.slice(end));\n\t\t}\n\t\tthis.items = remnantItems;\n\t\tthis.cachedLength = this.items.length;\n\t\treturn this.items.length === 0;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number) {\n\t\tif (pos > 0) {\n\t\t\tconst remainingItems = this.items.slice(pos);\n\t\t\tthis.items = this.items.slice(0, pos);\n\t\t\tthis.cachedLength = this.items.length;\n\t\t\tconst leafSegment = new SubSequence(remainingItems);\n\t\t\treturn leafSegment;\n\t\t}\n\t}\n}\n\nexport class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t\tspecToSegment: (spec: IJSONSegment) => ISegment,\n\t) {\n\t\tsuper(document, id, attributes, specToSegment);\n\t}\n\n\t/**\n\t * @param pos - The position to insert the items at.\n\t * @param items - The items to insert.\n\t * @param props - Optional. Properties to set on the inserted items.\n\t */\n\tpublic insert(pos: number, items: Serializable<T>[], props?: PropertySet) {\n\t\tconst segment = new SubSequence<T>(items);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\t\tconst insertOp = this.client.insertSegmentLocal(pos, segment);\n\t\tif (insertOp) {\n\t\t\tthis.submitSequenceMessage(insertOp);\n\t\t}\n\t}\n\n\t/**\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to remove\n\t */\n\tpublic remove(start: number, end: number) {\n\t\tthis.removeRange(start, end);\n\t}\n\n\t/**\n\t * Returns the total count of items in the sequence\n\t */\n\tpublic getItemCount(): number {\n\t\treturn this.getLength();\n\t}\n\n\t/**\n\t * Gets the items in the specified range\n\t *\n\t * @param start - The inclusive start of the range\n\t * @param end - The exclusive end of the range\n\t */\n\tpublic getItems(start: number, end?: number): Serializable<T>[] {\n\t\tconst items: Serializable<T>[] = [];\n\t\tlet firstSegment: ISegment | undefined;\n\n\t\t// Return if the range is incorrect.\n\t\tif (end !== undefined && end <= start) {\n\t\t\treturn items;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment: ISegment) => {\n\t\t\t\tif (SubSequence.is(segment)) {\n\t\t\t\t\tif (firstSegment === undefined) {\n\t\t\t\t\t\tfirstSegment = segment;\n\t\t\t\t\t}\n\t\t\t\t\titems.push(...segment.items);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\n\t\t// The above call to walkSegments adds all the items in the walked\n\t\t// segments. However, we only want items beginning at |start| in\n\t\t// the first segment. Similarly, if |end| is passed in, we only\n\t\t// want items until |end| in the last segment. Remove the rest of\n\t\t// the items.\n\t\tif (firstSegment !== undefined) {\n\t\t\titems.splice(0, start - this.getPosition(firstSegment));\n\t\t}\n\t\tif (end !== undefined) {\n\t\t\titems.splice(end - start);\n\t\t}\n\t\treturn items;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedString.d.ts","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EAEnB,iBAAiB,EACjB,QAAQ,EAER,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,aAAa,EAEb,WAAW,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAA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,CACd,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,UAAO,GAEd;QACA,IAAI,EAAE,iBAAiB,CAAC;QACxB,GAAG,EAAE,MAAM,CAAC;KACX,GACD,SAAS;IAIZ;;;;;OAKG;IACI,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAW3C;;OAEG;IACI,uBAAuB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAWpD,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAWzD;;;OAGG;IACI,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIxD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAOhE;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,GACV;IACF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC1B,CAWA"}
@@ -273,7 +273,7 @@ const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumT
273
273
  }
274
274
  textSegment.text += endTags;
275
275
  textSegment.text += beginTags;
276
- if ((start <= 0) && (end >= segment.text.length)) {
276
+ if (start <= 0 && end >= segment.text.length) {
277
277
  textSegment.text += segment.text;
278
278
  }
279
279
  else {
@@ -284,9 +284,10 @@ const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumT
284
284
  }
285
285
  }
286
286
  else {
287
- if (placeholder && (placeholder.length > 0)) {
288
- const placeholderText = placeholder === "*" ?
289
- `\n${segment.toString()}` : placeholder.repeat(segment.cachedLength);
287
+ if (placeholder && placeholder.length > 0) {
288
+ const placeholderText = placeholder === "*"
289
+ ? `\n${segment.toString()}`
290
+ : placeholder.repeat(segment.cachedLength);
290
291
  textSegment.text += placeholderText;
291
292
  }
292
293
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAcoC;AAEpC,yCAAmD;AACnD,uDAAwD;AA8BxD;;;;;;;;;GASG;AACH,MAAa,YAAa,SAAQ,gCAA0C;IAyBxE,YAAY,QAAgC,EAAS,EAAU,EAAE,UAA8B;QAC3F,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,qCAAmB,CAAC,eAAsB,CAAC,CAAC;QAD3B,OAAE,GAAF,EAAE,CAAQ;QAE3D,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC9D,CAAC;IA3BD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAC7D,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,qCAAmB,CAAC,IAAI,CAAiB,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,UAAU;QACpB,OAAO,IAAI,qCAAmB,EAAE,CAAC;IACrC,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IASD;;;;;OAKG;IACI,oBAAoB,CACvB,YAA+B,EAC/B,OAAsB,EACtB,KAAmB;QACnB,MAAM,OAAO,GAAG,IAAI,mBAAM,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,KAAK,EAAE;YACP,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;SAChC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,C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AM,CAAC;YACnC,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACrC,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;SAC5D;KACJ;SAAM;QACH,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;YACzC,MAAM,eAAe,GAAG,WAAW,KAAK,GAAG,CAAC,CAAC;gBACzC,KAAK,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACzE,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;SACvC;aAAM;YACH,MAAM,MAAM,GAAG,OAAiB,CAAC;YACjC,IAAI,IAAA,4BAAe,EAAC,MAAM,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE;gBACxD,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC9C,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;aACzB;SACJ;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ICombiningOp,\n IMergeTreeInsertMsg,\n IMergeTreeRemoveMsg,\n IMergeTreeTextHelper,\n IRelativePosition,\n ISegment,\n ISegmentAction,\n Marker,\n PropertySet,\n ReferencePosition,\n ReferenceType,\n refHasTileLabel,\n TextSegment,\n} from \"@fluidframework/merge-tree\";\nimport { IFluidDataStoreRuntime, IChannelAttributes } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\nimport { SharedStringFactory } from \"./sequenceFactory\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n /**\n * Inserts the text at the position.\n * @param pos - The position to insert the text at\n * @param text - The text to insert\n * @param props - The properties of the text\n */\n insertText(pos: number, text: string, props?: PropertySet): void;\n\n /**\n * Inserts a marker at the position.\n * @param pos - The position to insert the marker at\n * @param refType - The reference type of the marker\n * @param props - The properties of the marker\n */\n insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg | undefined;\n\n /**\n * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n */\n posFromRelativePos(relativePos: IRelativePosition): number;\n}\n\nexport type SharedStringSegment = TextSegment | Marker;\n\n/**\n * The Shared String is a specialized data structure for handling collaborative\n * text. It is based on a more general Sequence data structure but has\n * additional features that make working with text easier.\n *\n * In addition to text, a Shared String can also contain markers. Markers can be\n * used to store metadata at positions within the text, like the details of an\n * image or Fluid object that should be rendered with the text.\n *\n */\nexport class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {\n /**\n * Create a new shared string.\n * @param runtime - data store runtime the new shared string belongs to\n * @param id - optional name of the shared string\n * @returns newly create shared string (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string) {\n return runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n }\n\n /**\n * Get a factory for SharedString to register with the data store.\n * @returns a factory that creates and load SharedString\n */\n public static getFactory() {\n return new SharedStringFactory();\n }\n\n public get ISharedString(): ISharedString {\n return this;\n }\n\n private readonly mergeTreeTextHelper: IMergeTreeTextHelper;\n\n constructor(document: IFluidDataStoreRuntime, public id: string, attributes: IChannelAttributes) {\n super(document, id, attributes, SharedStringFactory.segmentFromSpec as any);\n this.mergeTreeTextHelper = this.client.createTextHelper();\n }\n\n /**\n * Inserts a marker at a relative position.\n * @param relativePos1 - The relative position to insert the marker at\n * @param refType - The reference type of the marker\n * @param props - The properties of the marker\n */\n public insertMarkerRelative(\n relativePos1: IRelativePosition,\n refType: ReferenceType,\n props?: PropertySet) {\n const segment = new Marker(refType);\n if (props) {\n segment.addProperties(props);\n }\n\n const pos = this.posFromRelativePos(relativePos1);\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * {@inheritDoc ISharedString.insertMarker}\n */\n public insertMarker(\n pos: number,\n refType: ReferenceType,\n props?: PropertySet): IMergeTreeInsertMsg | undefined {\n const segment = new Marker(refType);\n if (props) {\n segment.addProperties(props);\n }\n\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n return insertOp;\n }\n\n /**\n * Inserts the text at the position.\n * @param relativePos1 - The relative position to insert the text at\n * @param text - The text to insert\n * @param props - The properties of text\n */\n public insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet) {\n const segment = new TextSegment(text);\n if (props) {\n segment.addProperties(props);\n }\n\n const pos = this.posFromRelativePos(relativePos1);\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * {@inheritDoc ISharedString.insertText}\n */\n public insertText(pos: number, text: string, props?: PropertySet) {\n const segment = new TextSegment(text);\n if (props) {\n segment.addProperties(props);\n }\n\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n /**\n * Replaces a range with the provided text.\n * @param start - The inclusive start of the range to replace\n * @param end - The exclusive end of the range to replace\n * @param text - The text to replace the range with\n * @param props - Optional. The properties of the replacement text\n */\n public replaceText(start: number, end: number, text: string, props?: PropertySet) {\n this.replaceRange(start, end, TextSegment.make(text, props));\n }\n\n /**\n * Removes the text in the given range.\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to replace\n * @returns the message sent.\n */\n public removeText(start: number, end: number): IMergeTreeRemoveMsg {\n return this.removeRange(start, end);\n }\n\n /**\n * Annotates the marker with the provided properties and calls the callback on consensus.\n * @param marker - The marker to annotate\n * @param props - The properties to annotate the marker with\n * @param consensusCallback - The callback called when consensus is reached\n */\n public annotateMarkerNotifyConsensus(\n marker: Marker,\n props: PropertySet,\n callback: (m: Marker) => void) {\n const annotateOp = this.client.annotateMarkerNotifyConsensus(marker, props, callback);\n if (annotateOp) {\n this.submitSequenceMessage(annotateOp);\n }\n }\n\n /**\n * Annotates the marker with the provided properties.\n * @param marker - The marker to annotate\n * @param props - The properties to annotate the marker with\n * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n */\n public annotateMarker(\n marker: Marker,\n props: PropertySet,\n combiningOp?: ICombiningOp) {\n const annotateOp = this.client.annotateMarker(marker, props, combiningOp);\n if (annotateOp) {\n this.submitSequenceMessage(annotateOp);\n }\n }\n\n /**\n * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.\n * Note that Markers receive `ReferenceType.Tile` by default.\n * @param startPos - Position at which to start the search\n * @param clientId - clientId dictating the perspective to search from\n * @param tileLabel - Label of the tile to search for\n * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`\n */\n public findTile(startPos: number | undefined, tileLabel: string, preceding = true): {\n tile: ReferencePosition;\n pos: number;\n } | undefined {\n return this.client.findTile(startPos ?? 0, tileLabel, preceding);\n }\n\n /**\n * Retrieve text from the SharedString in string format.\n * @param start - The starting index of the text to retrieve, or 0 if omitted.\n * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n * @returns The requested text content as a string.\n */\n public getText(start?: number, end?: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"\", start, end);\n }\n\n /**\n * Adds spaces for markers and handles, so that position calculations account for them.\n */\n public getTextWithPlaceholders(start?: number, end?: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \" \", start, end);\n }\n\n public getTextRangeWithMarkers(start: number, end: number) {\n const segmentWindow = this.client.getCollabWindow();\n return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, \"*\", start, end);\n }\n\n /**\n * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided\n * id in this `SharedString`.\n */\n public getMarkerFromId(id: string): ISegment | undefined {\n return this.client.getMarkerFromId(id);\n }\n\n /**\n * Revert an op\n */\n protected rollback(content: any, localOpMetadata: unknown): void {\n if (this.client.rollback !== undefined) {\n this.client.rollback(content, localOpMetadata);\n } else {\n super.rollback(content, localOpMetadata);\n }\n }\n}\n\ninterface ITextAndMarkerAccumulator {\n parallelText: string[];\n parallelMarkers: Marker[];\n parallelMarkerLabel: string;\n placeholder?: string;\n tagsInProgress: string[];\n textSegment: TextSegment;\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n *\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n */\nexport function getTextAndMarkers(sharedString: SharedString, label: string, start?: number, end?: number): {\n parallelText: string[];\n parallelMarkers: Marker[];\n} {\n const accum: ITextAndMarkerAccumulator = {\n parallelMarkerLabel: label,\n parallelMarkers: [],\n parallelText: [],\n tagsInProgress: [],\n textSegment: new TextSegment(\"\"),\n };\n\n sharedString.walkSegments(gatherTextAndMarkers, start, end, accum);\n return { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };\n}\n\nconst gatherTextAndMarkers: ISegmentAction<ITextAndMarkerAccumulator> = (\n segment: ISegment,\n pos: number,\n refSeq: number,\n clientId: number,\n start: number,\n end: number,\n accumText: ITextAndMarkerAccumulator,\n) => {\n const { placeholder, tagsInProgress, textSegment } = accumText;\n if (TextSegment.is(segment)) {\n let beginTags = \"\";\n let endTags = \"\";\n // TODO: let clients pass in function to get tag\n const tags = [] as string[];\n const initTags = [] as string[];\n\n if (segment.properties?.[\"font-weight\"]) {\n tags.push(\"b\");\n }\n if (segment.properties?.[\"text-decoration\"]) {\n tags.push(\"u\");\n }\n const remTags = [] as string[];\n if (tags.length > 0) {\n for (const tag of tags) {\n if (!tagsInProgress.includes(tag)) {\n beginTags += `<${tag}>`;\n initTags.push(tag);\n }\n }\n for (const accumTag of tagsInProgress) {\n if (!tags.includes(accumTag)) {\n endTags += `</${accumTag}>`;\n remTags.push(accumTag);\n }\n }\n for (const initTag of initTags.reverse()) {\n tagsInProgress.push(initTag);\n }\n } else {\n for (const accumTag of tagsInProgress) {\n endTags += `</${accumTag}>`;\n remTags.push(accumTag);\n }\n }\n for (const remTag of remTags) {\n const remdex = tagsInProgress.indexOf(remTag);\n if (remdex >= 0) {\n tagsInProgress.splice(remdex, 1);\n }\n }\n textSegment.text += endTags;\n textSegment.text += beginTags;\n if ((start <= 0) && (end >= segment.text.length)) {\n textSegment.text += segment.text;\n } else {\n const seglen = segment.text.length;\n const _start = start < 0 ? 0 : start;\n const _end = end >= seglen ? undefined : end;\n textSegment.text += segment.text.substring(_start, _end);\n }\n } else {\n if (placeholder && (placeholder.length > 0)) {\n const placeholderText = placeholder === \"*\" ?\n `\\n${segment.toString()}` : placeholder.repeat(segment.cachedLength);\n textSegment.text += placeholderText;\n } else {\n const marker = segment as Marker;\n if (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {\n accumText.parallelMarkers.push(marker);\n accumText.parallelText.push(textSegment.text);\n textSegment.text = \"\";\n }\n }\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CAAC,GAAG,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;SACzD;KACD;SAAM;QACN,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1C,MAAM,eAAe,GACpB,WAAW,KAAK,GAAG;gBAClB,CAAC,CAAC,KAAK,OAAO,CAAC,QAAQ,EAAE,EAAE;gBAC3B,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;SACpC;aAAM;YACN,MAAM,MAAM,GAAG,OAAiB,CAAC;YACjC,IAAI,IAAA,4BAAe,EAAC,MAAM,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE;gBAC3D,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC9C,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;aACtB;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tICombiningOp,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\n\tReferencePosition,\n\tReferenceType,\n\trefHasTileLabel,\n\tTextSegment,\n} from \"@fluidframework/merge-tree\";\nimport { IFluidDataStoreRuntime, IChannelAttributes } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\nimport { SharedStringFactory } from \"./sequenceFactory\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n\t/**\n\t * Inserts the text at the position.\n\t * @param pos - The position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of the text\n\t */\n\tinsertText(pos: number, text: string, props?: PropertySet): void;\n\n\t/**\n\t * Inserts a marker at the position.\n\t * @param pos - The position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tinsertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined;\n\n\t/**\n\t * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n\t */\n\tposFromRelativePos(relativePos: IRelativePosition): number;\n}\n\nexport type SharedStringSegment = TextSegment | Marker;\n\n/**\n * The Shared String is a specialized data structure for handling collaborative\n * text. It is based on a more general Sequence data structure but has\n * additional features that make working with text easier.\n *\n * In addition to text, a Shared String can also contain markers. Markers can be\n * used to store metadata at positions within the text, like the details of an\n * image or Fluid object that should be rendered with the text.\n *\n */\nexport class SharedString\n\textends SharedSegmentSequence<SharedStringSegment>\n\timplements ISharedString\n{\n\t/**\n\t * Create a new shared string.\n\t * @param runtime - data store runtime the new shared string belongs to\n\t * @param id - optional name of the shared string\n\t * @returns newly create shared string (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n\t}\n\n\t/**\n\t * Get a factory for SharedString to register with the data store.\n\t * @returns a factory that creates and load SharedString\n\t */\n\tpublic static getFactory() {\n\t\treturn new SharedStringFactory();\n\t}\n\n\tpublic get ISharedString(): ISharedString {\n\t\treturn this;\n\t}\n\n\tprivate readonly mergeTreeTextHelper: IMergeTreeTextHelper;\n\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(document, id, attributes, SharedStringFactory.segmentFromSpec as any);\n\t\tthis.mergeTreeTextHelper = this.client.createTextHelper();\n\t}\n\n\t/**\n\t * Inserts a marker at a relative position.\n\t * @param relativePos1 - The relative position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tpublic insertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tconst insertOp = this.client.insertSegmentLocal(pos, segment);\n\t\tif (insertOp) {\n\t\t\tthis.submitSequenceMessage(insertOp);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertMarker}\n\t */\n\tpublic insertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst insertOp = this.client.insertSegmentLocal(pos, segment);\n\t\tif (insertOp) {\n\t\t\tthis.submitSequenceMessage(insertOp);\n\t\t}\n\t\treturn insertOp;\n\t}\n\n\t/**\n\t * Inserts the text at the position.\n\t * @param relativePos1 - The relative position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of text\n\t */\n\tpublic insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tconst insertOp = this.client.insertSegmentLocal(pos, segment);\n\t\tif (insertOp) {\n\t\t\tthis.submitSequenceMessage(insertOp);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertText}\n\t */\n\tpublic insertText(pos: number, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst insertOp = this.client.insertSegmentLocal(pos, segment);\n\t\tif (insertOp) {\n\t\t\tthis.submitSequenceMessage(insertOp);\n\t\t}\n\t}\n\n\t/**\n\t * Replaces a range with the provided text.\n\t * @param start - The inclusive start of the range to replace\n\t * @param end - The exclusive end of the range to replace\n\t * @param text - The text to replace the range with\n\t * @param props - Optional. The properties of the replacement text\n\t */\n\tpublic replaceText(start: number, end: number, text: string, props?: PropertySet) {\n\t\tthis.replaceRange(start, end, TextSegment.make(text, props));\n\t}\n\n\t/**\n\t * Removes the text in the given range.\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to replace\n\t * @returns the message sent.\n\t */\n\tpublic removeText(start: number, end: number): IMergeTreeRemoveMsg {\n\t\treturn this.removeRange(start, end);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties and calls the callback on consensus.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param consensusCallback - The callback called when consensus is reached\n\t */\n\tpublic annotateMarkerNotifyConsensus(\n\t\tmarker: Marker,\n\t\tprops: PropertySet,\n\t\tcallback: (m: Marker) => void,\n\t) {\n\t\tconst annotateOp = this.client.annotateMarkerNotifyConsensus(marker, props, callback);\n\t\tif (annotateOp) {\n\t\t\tthis.submitSequenceMessage(annotateOp);\n\t\t}\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n\t */\n\tpublic annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp) {\n\t\tconst annotateOp = this.client.annotateMarker(marker, props, combiningOp);\n\t\tif (annotateOp) {\n\t\t\tthis.submitSequenceMessage(annotateOp);\n\t\t}\n\t}\n\n\t/**\n\t * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.\n\t * Note that Markers receive `ReferenceType.Tile` by default.\n\t * @param startPos - Position at which to start the search\n\t * @param clientId - clientId dictating the perspective to search from\n\t * @param tileLabel - Label of the tile to search for\n\t * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`\n\t */\n\tpublic findTile(\n\t\tstartPos: number | undefined,\n\t\ttileLabel: string,\n\t\tpreceding = true,\n\t):\n\t\t| {\n\t\t\t\ttile: ReferencePosition;\n\t\t\t\tpos: number;\n\t\t }\n\t\t| undefined {\n\t\treturn this.client.findTile(startPos ?? 0, tileLabel, preceding);\n\t}\n\n\t/**\n\t * Retrieve text from the SharedString in string format.\n\t * @param start - The starting index of the text to retrieve, or 0 if omitted.\n\t * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n\t * @returns The requested text content as a string.\n\t */\n\tpublic getText(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Adds spaces for markers and handles, so that position calculations account for them.\n\t */\n\tpublic getTextWithPlaceholders(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\" \",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\tpublic getTextRangeWithMarkers(start: number, end: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"*\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided\n\t * id in this `SharedString`.\n\t */\n\tpublic getMarkerFromId(id: string): ISegment | undefined {\n\t\treturn this.client.getMarkerFromId(id);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tif (this.client.rollback !== undefined) {\n\t\t\tthis.client.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t}\n\t}\n}\n\ninterface ITextAndMarkerAccumulator {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n\tparallelMarkerLabel: string;\n\tplaceholder?: string;\n\ttagsInProgress: string[];\n\ttextSegment: TextSegment;\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n *\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n */\nexport function getTextAndMarkers(\n\tsharedString: SharedString,\n\tlabel: string,\n\tstart?: number,\n\tend?: number,\n): {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n} {\n\tconst accum: ITextAndMarkerAccumulator = {\n\t\tparallelMarkerLabel: label,\n\t\tparallelMarkers: [],\n\t\tparallelText: [],\n\t\ttagsInProgress: [],\n\t\ttextSegment: new TextSegment(\"\"),\n\t};\n\n\tsharedString.walkSegments(gatherTextAndMarkers, start, end, accum);\n\treturn { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };\n}\n\nconst gatherTextAndMarkers: ISegmentAction<ITextAndMarkerAccumulator> = (\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\taccumText: ITextAndMarkerAccumulator,\n) => {\n\tconst { placeholder, tagsInProgress, textSegment } = accumText;\n\tif (TextSegment.is(segment)) {\n\t\tlet beginTags = \"\";\n\t\tlet endTags = \"\";\n\t\t// TODO: let clients pass in function to get tag\n\t\tconst tags = [] as string[];\n\t\tconst initTags = [] as string[];\n\n\t\tif (segment.properties?.[\"font-weight\"]) {\n\t\t\ttags.push(\"b\");\n\t\t}\n\t\tif (segment.properties?.[\"text-decoration\"]) {\n\t\t\ttags.push(\"u\");\n\t\t}\n\t\tconst remTags = [] as string[];\n\t\tif (tags.length > 0) {\n\t\t\tfor (const tag of tags) {\n\t\t\t\tif (!tagsInProgress.includes(tag)) {\n\t\t\t\t\tbeginTags += `<${tag}>`;\n\t\t\t\t\tinitTags.push(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tif (!tags.includes(accumTag)) {\n\t\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\t\tremTags.push(accumTag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const initTag of initTags.reverse()) {\n\t\t\t\ttagsInProgress.push(initTag);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\tremTags.push(accumTag);\n\t\t\t}\n\t\t}\n\t\tfor (const remTag of remTags) {\n\t\t\tconst remdex = tagsInProgress.indexOf(remTag);\n\t\t\tif (remdex >= 0) {\n\t\t\t\ttagsInProgress.splice(remdex, 1);\n\t\t\t}\n\t\t}\n\t\ttextSegment.text += endTags;\n\t\ttextSegment.text += beginTags;\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else {\n\t\tif (placeholder && placeholder.length > 0) {\n\t\t\tconst placeholderText =\n\t\t\t\tplaceholder === \"*\"\n\t\t\t\t\t? `\\n${segment.toString()}`\n\t\t\t\t\t: placeholder.repeat(segment.cachedLength);\n\t\t\ttextSegment.text += placeholderText;\n\t\t} else {\n\t\t\tconst marker = segment as Marker;\n\t\t\tif (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {\n\t\t\t\taccumText.parallelMarkers.push(marker);\n\t\t\t\taccumText.parallelText.push(textSegment.text);\n\t\t\t\ttextSegment.text = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultMap.d.ts","sourceRoot":"","sources":["../src/defaultMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACH,gBAAgB,EAInB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKzE,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAGhB,UAAU,EACV,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EAC3B,MAAM,wBAAwB,CAAC;AAgChC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,KAAK,EAAE,wBAAwB,CAAC;CACnC;AAED;;GAEG;AACH,oBAAY,aAAa,GAAG,sBAAsB,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC;CACrC;AAED,MAAM,WAAW,wBAAwB;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACnC;AAED;;;;;;GAMG;AACH,qBAAa,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OAGG;IACI,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,GAAG,IAAI;IAM1F;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC;IAM1B;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;;;OAIG;IACI,oBAAoB,CAAC,UAAU,EAAE,gBAAgB,GAAG,wBAAwB;IAQ5E,sBAAsB,CAAC,UAAU,EAAE,gBAAgB,GAAG,0BAA0B;IAQhF,SAAS,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM;IAItD;;;OAGG;IACI,wBAAwB,CAAC,IAAI,EAAE,0BAA0B,GAAG,IAAI;IA0BhE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAInC;;;;;;;OAOG;IACI,kBAAkB,CAAC,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,wBAAwB,GAAG,OAAO;IAU/E,4BAA4B,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO;IASrD;;;;;;;OAOG;IACI,iBAAiB,CACvB,EAAE,EAAE,aAAa,EACjB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,yBAAyB,GAAG,SAAS,EAC9C,eAAe,EAAE,OAAO,GACtB,OAAO;IASV;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAYlB;;;;;;;;;OASG;IACH,OAAO,CAAC,SAAS;IAejB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IA2C1B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;CA0B7B"}
package/lib/defaultMap.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { makeHandlesSerializable, parseHandles, ValueType, } from "@fluidframework/shared-object-base";
6
6
  import { assert, TypedEventEmitter } from "@fluidframework/common-utils";
7
- import { makeSerializable, ValueTypeLocalValue, } from "./localValues";
7
+ import { makeSerializable, ValueTypeLocalValue } from "./localValues";
8
8
  /**
9
9
  * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by
10
10
  * string key locations.
@@ -150,8 +150,8 @@ export class DefaultMap {
150
150
  for (const [key, serializable] of Object.entries(json)) {
151
151
  // Back-compat: legacy documents may have handles to an intervalCollection map kernel.
152
152
  // These collections should be empty, and ValueTypes are no longer supported.
153
- if (serializable.type === ValueType[ValueType.Plain]
154
- || serializable.type === ValueType[ValueType.Shared]) {
153
+ if (serializable.type === ValueType[ValueType.Plain] ||
154
+ serializable.type === ValueType[ValueType.Shared]) {
155
155
  continue;
156
156
  }
157
157
  // Back-compat: Sequence previously arbitrarily prefixed all interval collection keys with
@@ -235,7 +235,8 @@ export class DefaultMap {
235
235
  * @returns The local value that was produced
236
236
  */
237
237
  makeLocal(key, serializable) {
238
- assert(serializable.type !== ValueType[ValueType.Plain] && serializable.type !== ValueType[ValueType.Shared], 0x2e1 /* "Support for plain value types removed." */);
238
+ assert(serializable.type !== ValueType[ValueType.Plain] &&
239
+ serializable.type !== ValueType[ValueType.Shared], 0x2e1 /* "Support for plain value types removed." */);
239
240
  serializable.value = parseHandles(serializable.value, this.serializer);
240
241
  const localValue = this.type.factory.load(this.makeMapValueOpEmitter(key), serializable.value);
241
242
  return new ValueTypeLocalValue(localValue, this.type);
@@ -268,7 +269,7 @@ export class DefaultMap {
268
269
  const localValue = this.data.get(op.key);
269
270
  assert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);
270
271
  const handler = localValue.getOpHandler(op.value.opName);
271
- const { rebasedOp, rebasedLocalOpMetadata, } = handler.rebase(localValue.value, op.value, localOpMetadata);
272
+ const { rebasedOp, rebasedLocalOpMetadata } = handler.rebase(localValue.value, op.value, localOpMetadata);
272
273
  this.submitMessage(Object.assign(Object.assign({}, op), { value: rebasedOp }), rebasedLocalOpMetadata);
273
274
  },
274
275
  getStashedOpLocalMetadata: (op) => {
@@ -1 +1 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B,EAAE,MAAW,EAAE,eAAyC,EAAE,EAAE;YACxG,MAAM,gBAAgB,GAAG,uBAAuB,CAC5C,MAAM,EACN,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,MAAM,CAAC,CAAC;YAEjB,MAAM,EAAE,GAA2B;gBAC/B,GAAG;gBACH,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE;oBACH,MAAM;oBACN,KAAK,EAAE,gBAAgB;iBAC1B;aACJ,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;YAExC,MAAM,KAAK,GAAkB,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YACpD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjF,CAAC,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC;IACpB,CAAC;CACJ","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 { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n IFluidSerializer,\n makeHandlesSerializable,\n parseHandles,\n ValueType,\n} from \"@fluidframework/shared-object-base\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n makeSerializable,\n ValueTypeLocalValue,\n} from \"./localValues\";\nimport {\n ISerializableValue,\n ISerializedValue,\n IValueChanged,\n IValueOpEmitter,\n IValueType,\n IValueTypeOperationValue,\n ISharedDefaultMapEvents,\n IMapMessageLocalMetadata,\n} from \"./defaultMapInterfaces\";\n\n/**\n * Defines the means to process and submit a given op on a map.\n */\ninterface IMapMessageHandler {\n /**\n * Apply the given operation.\n * @param op - The map operation to apply\n * @param local - Whether the message originated from the local client\n * @param message - The full message. Not provided for stashed ops.\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n process(\n op: IMapOperation,\n local: boolean,\n message: ISequencedDocumentMessage | undefined,\n localOpMetadata: IMapMessageLocalMetadata,\n ): void;\n\n /**\n * Communicate the operation to remote clients.\n * @param op - The map operation to submit\n */\n submit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;\n\n resubmit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;\n\n getStashedOpLocalMetadata(op: IMapOperation): unknown;\n}\n\n/**\n * Describes an operation specific to a value type.\n */\nexport interface IMapValueTypeOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"act\";\n\n /**\n * Map key being modified.\n */\n key: string;\n\n /**\n * Value of the operation, specific to the value type.\n * @alpha\n */\n value: IValueTypeOperationValue;\n}\n\n/**\n * Description of a map delta operation\n */\nexport type IMapOperation = IMapValueTypeOperation;\n\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n * Directly used in JSON.stringify, direct result from JSON.parse\n */\nexport interface IMapDataObjectSerializable {\n [key: string]: ISerializableValue;\n}\n\nexport interface IMapDataObjectSerialized {\n [key: string]: ISerializedValue;\n}\n\n/**\n * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by\n * string key locations.\n *\n * Creation of values is implicit on access (either via `get` or a remote op application referring to\n * a collection that wasn't previously known)\n */\nexport class DefaultMap<T> {\n /**\n * The number of key/value pairs stored in the map.\n */\n public get size(): number {\n return this.data.size;\n }\n\n /**\n * Mapping of op types to message handlers.\n */\n private readonly messageHandlers: ReadonlyMap<string, IMapMessageHandler> = new Map();\n\n /**\n * The in-memory data the map is storing.\n */\n private readonly data = new Map<string, ValueTypeLocalValue<T>>();\n\n /**\n * Create a new default map.\n * @param serializer - The serializer to serialize / parse handles\n * @param handle - The handle of the shared object using the kernel\n * @param submitMessage - A callback to submit a message through the shared object\n * @param type - The value type to create at values of this map\n * @param eventEmitter - The object that will emit map events\n */\n constructor(\n private readonly serializer: IFluidSerializer,\n private readonly handle: IFluidHandle,\n private readonly submitMessage: (op: any, localOpMetadata: IMapMessageLocalMetadata) => void,\n private readonly type: IValueType<T>,\n public readonly eventEmitter = new TypedEventEmitter<ISharedDefaultMapEvents>(),\n ) {\n this.messageHandlers = this.getMessageHandlers();\n }\n\n /**\n * Get an iterator over the keys in this map.\n * @returns The iterator\n */\n public keys(): IterableIterator<string> {\n return this.data.keys();\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n public entries(): IterableIterator<[string, any]> {\n const localEntriesIterator = this.data.entries();\n const iterator = {\n next(): IteratorResult<[string, any]> {\n const nextVal = localEntriesIterator.next();\n return nextVal.done\n ? { value: undefined, done: true }\n : { value: [nextVal.value[0], nextVal.value[1].value], done: false }; // Unpack the stored value\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the values in this map.\n * @returns The iterator\n */\n public values(): IterableIterator<any> {\n const localValuesIterator = this.data.values();\n const iterator = {\n next(): IteratorResult<any> {\n const nextVal = localValuesIterator.next();\n return nextVal.done\n ? { value: undefined, done: true }\n : { value: nextVal.value.value, done: false }; // Unpack the stored value\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n public [Symbol.iterator](): IterableIterator<[string, any]> {\n return this.entries();\n }\n\n /**\n * Executes the given callback on each entry in the map.\n * @param callbackFn - Callback function\n */\n public forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n this.data.forEach((localValue, key, m) => {\n callbackFn(localValue.value, key, m);\n });\n }\n\n /**\n * {@inheritDoc ISharedMap.get}\n */\n public get(key: string): T {\n const localValue = this.data.get(key) ?? this.createCore(key, true);\n\n return localValue.value;\n }\n\n /**\n * Check if a key exists in the map.\n * @param key - The key to check\n * @returns True if the key exists, false otherwise\n */\n public has(key: string): boolean {\n return this.data.has(key);\n }\n\n /**\n * Serializes the data stored in the shared map to a JSON string\n * @param serializer - The serializer to use to serialize handles in its values.\n * @returns A JSON string containing serialized map data\n */\n public getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {\n const serializableMapData: IMapDataObjectSerialized = {};\n this.data.forEach((localValue, key) => {\n serializableMapData[key] = localValue.makeSerialized(serializer, this.handle);\n });\n return serializableMapData;\n }\n\n public getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {\n const serializableMapData: IMapDataObjectSerializable = {};\n this.data.forEach((localValue, key) => {\n serializableMapData[key] = makeSerializable(localValue, serializer, this.handle);\n });\n return serializableMapData;\n }\n\n public serialize(serializer: IFluidSerializer): string {\n return JSON.stringify(this.getSerializableStorage(serializer));\n }\n\n /**\n * Populate the kernel with the given map data.\n * @param data - A JSON string containing serialized map data\n */\n public populateFromSerializable(json: IMapDataObjectSerializable): void {\n for (const [key, serializable] of Object.entries(json)) {\n // Back-compat: legacy documents may have handles to an intervalCollection map kernel.\n // These collections should be empty, and ValueTypes are no longer supported.\n if (serializable.type === ValueType[ValueType.Plain]\n || serializable.type === ValueType[ValueType.Shared]) {\n continue;\n }\n\n // Back-compat: Sequence previously arbitrarily prefixed all interval collection keys with\n // \"intervalCollections/\". This would burden users trying to iterate the collection and\n // access its value, as well as those trying to match a create message to its underlying\n // collection. See https://github.com/microsoft/FluidFramework/issues/10557 for more context.\n const normalizedKey = key.startsWith(\"intervalCollections/\") ? key.substring(20) : key;\n\n const localValue = {\n key: normalizedKey,\n value: this.makeLocal(key, serializable),\n };\n\n this.data.set(localValue.key, localValue.value);\n }\n }\n\n public populate(json: string): void {\n this.populateFromSerializable(JSON.parse(json) as IMapDataObjectSerializable);\n }\n\n /**\n * Submit the given op if a handler is registered.\n * @param op - The operation to attempt to submit\n * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n * and not sent to the server. This will be sent back when this message is received back from the server. This is\n * also sent if we are asked to resubmit the message.\n * @returns True if the operation was submitted, false otherwise.\n */\n public tryResubmitMessage(op: any, localOpMetadata: IMapMessageLocalMetadata): boolean {\n const type: string = op.type;\n const handler = this.messageHandlers.get(type);\n if (handler !== undefined) {\n handler.resubmit(op as IMapOperation, localOpMetadata);\n return true;\n }\n return false;\n }\n\n public tryGetStashedOpLocalMetadata(op: any): unknown {\n const type: string = op.type;\n if (this.messageHandlers.has(type)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op as IMapOperation);\n }\n throw new Error(\"no apply stashed op handler\");\n }\n\n /**\n * Process the given op if a handler is registered.\n * @param message - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @returns True if the operation was processed, false otherwise.\n */\n public tryProcessMessage(\n op: IMapOperation,\n local: boolean,\n message: ISequencedDocumentMessage | undefined,\n localOpMetadata: unknown,\n ): boolean {\n const handler = this.messageHandlers.get(op.type);\n if (handler !== undefined) {\n handler.process(op, local, message, localOpMetadata as IMapMessageLocalMetadata);\n return true;\n }\n return false;\n }\n\n /**\n * Initializes a default ValueType at the provided key.\n * Should be used when a map operation incurs creation.\n * @param key - The key being initialized\n * @param local - Whether the message originated from the local client\n */\n private createCore(key: string, local: boolean): ValueTypeLocalValue<T> {\n const localValue = new ValueTypeLocalValue(\n this.type.factory.load(this.makeMapValueOpEmitter(key), undefined),\n this.type,\n );\n const previousValue = this.data.get(key);\n this.data.set(key, localValue);\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"create\", event, local, this.eventEmitter);\n return localValue;\n }\n\n /**\n * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will\n * have the information we need to create a real object, but will not be the real object yet. For example,\n * we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's\n * job is to convert that information into a real object for local usage.\n * @param key - The key that the caller intends to store the local value into (used for ops later). But\n * doesn't actually store the local value into that key. So better not lie!\n * @param serializable - The remote information that we can convert into a real object\n * @returns The local value that was produced\n */\n private makeLocal(key: string, serializable: ISerializableValue): ValueTypeLocalValue<T> {\n assert(serializable.type !== ValueType[ValueType.Plain] && serializable.type !== ValueType[ValueType.Shared],\n 0x2e1 /* \"Support for plain value types removed.\" */);\n\n serializable.value = parseHandles(serializable.value, this.serializer);\n const localValue = this.type.factory.load(\n this.makeMapValueOpEmitter(key),\n serializable.value,\n );\n return new ValueTypeLocalValue(localValue, this.type);\n }\n\n /**\n * Get the message handlers for the map.\n * @returns A map of string op names to IMapMessageHandlers for those ops\n */\n private getMessageHandlers() {\n const messageHandlers = new Map<string, IMapMessageHandler>();\n // Ops with type \"act\" describe actions taken by custom value type handlers of whatever item is\n // being addressed. These custom handlers can be retrieved from the ValueTypeLocalValue which has\n // stashed its valueType (and therefore its handlers). We also emit a valueChanged for anyone\n // watching for manipulations of that item.\n messageHandlers.set(\n \"act\",\n {\n process: (op: IMapValueTypeOperation, local, message, localOpMetadata) => {\n const localValue = this.data.get(op.key) ?? this.createCore(op.key, local);\n const handler = localValue.getOpHandler(op.value.opName);\n const previousValue = localValue.value;\n const translatedValue = parseHandles(\n op.value.value,\n this.serializer);\n handler.process(previousValue, translatedValue, local, message, localOpMetadata);\n const event: IValueChanged = { key: op.key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, local, message, this.eventEmitter);\n },\n submit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n this.submitMessage(\n op,\n localOpMetadata,\n );\n },\n resubmit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n const localValue = this.data.get(op.key);\n\n assert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);\n\n const handler = localValue.getOpHandler(op.value.opName);\n const {\n rebasedOp,\n rebasedLocalOpMetadata,\n } = handler.rebase(localValue.value, op.value, localOpMetadata);\n this.submitMessage(\n { ...op, value: rebasedOp },\n rebasedLocalOpMetadata,\n );\n },\n getStashedOpLocalMetadata: (op: IMapValueTypeOperation) => {\n assert(false, 0x016 /* \"apply stashed op not implemented for custom value type ops\" */);\n },\n });\n\n return messageHandlers;\n }\n\n /**\n * Create an emitter for a value type to emit ops from the given key.\n * @alpha\n * @param key - The key of the map that the value type will be stored on\n * @returns A value op emitter for the given key\n */\n private makeMapValueOpEmitter(key: string): IValueOpEmitter {\n const emit = (opName: string, previousValue: any, params: any, localOpMetadata: IMapMessageLocalMetadata) => {\n const translatedParams = makeHandlesSerializable(\n params,\n this.serializer,\n this.handle);\n\n const op: IMapValueTypeOperation = {\n key,\n type: \"act\",\n value: {\n opName,\n value: translatedParams,\n },\n };\n\n this.submitMessage(op, localOpMetadata);\n\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, true, null, this.eventEmitter);\n };\n\n return { emit };\n }\n}\n"]}
1
+ {"version":3,"file":"defaultMap.js","sourceRoot":"","sources":["../src/defaultMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,uBAAuB,EACvB,YAAY,EACZ,SAAS,GACT,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAgFtE;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IAkBtB;;;;;;;OAOG;IACH,YACkB,UAA4B,EAC5B,MAAoB,EACpB,aAGR,EACQ,IAAmB,EACpB,eAAe,IAAI,iBAAiB,EAA2B;QAP9D,eAAU,GAAV,UAAU,CAAkB;QAC5B,WAAM,GAAN,MAAM,CAAc;QACpB,kBAAa,GAAb,aAAa,CAGrB;QACQ,SAAI,GAAJ,IAAI,CAAe;QACpB,iBAAY,GAAZ,YAAY,CAAmD;QA1BhF;;WAEG;QACc,oBAAe,GAA4C,IAAI,GAAG,EAAE,CAAC;QAEtF;;WAEG;QACc,SAAI,GAAG,IAAI,GAAG,EAAkC,CAAC;QAoBjE,IAAI,CAAC,eAAe,GAA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EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,MAAM,CAC3D,UAAU,CAAC,KAAK,EAChB,EAAE,CAAC,KAAK,EACR,eAAe,CACf,CAAC;gBACF,IAAI,CAAC,aAAa,iCAAM,EAAE,KAAE,KAAK,EAAE,SAAS,KAAI,sBAAsB,CAAC,CAAC;YACzE,CAAC;YACD,yBAAyB,EAAE,CAAC,EAA0B,EAAE,EAAE;gBACzD,MAAM,CACL,KAAK,EACL,KAAK,CAAC,kEAAkE,CACxE,CAAC;YACH,CAAC;SACD,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,GAAW;QACxC,MAAM,IAAI,GAAG,CACZ,MAAc,EACd,aAAkB,EAClB,MAAW,EACX,eAAyC,EACxC,EAAE;YACH,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAEvF,MAAM,EAAE,GAA2B;gBAClC,GAAG;gBACH,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE;oBACN,MAAM;oBACN,KAAK,EAAE,gBAAgB;iBACvB;aACD,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;YAExC,MAAM,KAAK,GAAkB,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YACpD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9E,CAAC,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC;IACjB,CAAC;CACD","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 { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIFluidSerializer,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tValueType,\n} from \"@fluidframework/shared-object-base\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { makeSerializable, ValueTypeLocalValue } from \"./localValues\";\nimport {\n\tISerializableValue,\n\tISerializedValue,\n\tIValueChanged,\n\tIValueOpEmitter,\n\tIValueType,\n\tIValueTypeOperationValue,\n\tISharedDefaultMapEvents,\n\tIMapMessageLocalMetadata,\n} from \"./defaultMapInterfaces\";\n\n/**\n * Defines the means to process and submit a given op on a map.\n */\ninterface IMapMessageHandler {\n\t/**\n\t * Apply the given operation.\n\t * @param op - The map operation to apply\n\t * @param local - Whether the message originated from the local client\n\t * @param message - The full message. Not provided for stashed ops.\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprocess(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t): void;\n\n\t/**\n\t * Communicate the operation to remote clients.\n\t * @param op - The map operation to submit\n\t */\n\tsubmit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;\n\n\tresubmit(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): void;\n\n\tgetStashedOpLocalMetadata(op: IMapOperation): unknown;\n}\n\n/**\n * Describes an operation specific to a value type.\n */\nexport interface IMapValueTypeOperation {\n\t/**\n\t * String identifier of the operation type.\n\t */\n\ttype: \"act\";\n\n\t/**\n\t * Map key being modified.\n\t */\n\tkey: string;\n\n\t/**\n\t * Value of the operation, specific to the value type.\n\t * @alpha\n\t */\n\tvalue: IValueTypeOperationValue;\n}\n\n/**\n * Description of a map delta operation\n */\nexport type IMapOperation = IMapValueTypeOperation;\n\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n * Directly used in JSON.stringify, direct result from JSON.parse\n */\nexport interface IMapDataObjectSerializable {\n\t[key: string]: ISerializableValue;\n}\n\nexport interface IMapDataObjectSerialized {\n\t[key: string]: ISerializedValue;\n}\n\n/**\n * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by\n * string key locations.\n *\n * Creation of values is implicit on access (either via `get` or a remote op application referring to\n * a collection that wasn't previously known)\n */\nexport class DefaultMap<T> {\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.data.size;\n\t}\n\n\t/**\n\t * Mapping of op types to message handlers.\n\t */\n\tprivate readonly messageHandlers: ReadonlyMap<string, IMapMessageHandler> = new Map();\n\n\t/**\n\t * The in-memory data the map is storing.\n\t */\n\tprivate readonly data = new Map<string, ValueTypeLocalValue<T>>();\n\n\t/**\n\t * Create a new default map.\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param handle - The handle of the shared object using the kernel\n\t * @param submitMessage - A callback to submit a message through the shared object\n\t * @param type - The value type to create at values of this map\n\t * @param eventEmitter - The object that will emit map events\n\t */\n\tconstructor(\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tprivate readonly handle: IFluidHandle,\n\t\tprivate readonly submitMessage: (\n\t\t\top: any,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => void,\n\t\tprivate readonly type: IValueType<T>,\n\t\tpublic readonly eventEmitter = new TypedEventEmitter<ISharedDefaultMapEvents>(),\n\t) {\n\t\tthis.messageHandlers = this.getMessageHandlers();\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\treturn this.data.keys();\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic entries(): IterableIterator<[string, any]> {\n\t\tconst localEntriesIterator = this.data.entries();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<[string, any]> {\n\t\t\t\tconst nextVal = localEntriesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: [nextVal.value[0], nextVal.value[1].value], done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<any> {\n\t\tconst localValuesIterator = this.data.values();\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<any> {\n\t\t\t\tconst nextVal = localValuesIterator.next();\n\t\t\t\treturn nextVal.done\n\t\t\t\t\t? { value: undefined, done: true }\n\t\t\t\t\t: { value: nextVal.value.value, done: false }; // Unpack the stored value\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic [Symbol.iterator](): IterableIterator<[string, any]> {\n\t\treturn this.entries();\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\tpublic forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n\t\tthis.data.forEach((localValue, key, m) => {\n\t\t\tcallbackFn(localValue.value, key, m);\n\t\t});\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\tpublic get(key: string): T {\n\t\tconst localValue = this.data.get(key) ?? this.createCore(key, true);\n\n\t\treturn localValue.value;\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.data.has(key);\n\t}\n\n\t/**\n\t * Serializes the data stored in the shared map to a JSON string\n\t * @param serializer - The serializer to use to serialize handles in its values.\n\t * @returns A JSON string containing serialized map data\n\t */\n\tpublic getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {\n\t\tconst serializableMapData: IMapDataObjectSerialized = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = localValue.makeSerialized(serializer, this.handle);\n\t\t});\n\t\treturn serializableMapData;\n\t}\n\n\tpublic getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {\n\t\tconst serializableMapData: IMapDataObjectSerializable = {};\n\t\tthis.data.forEach((localValue, key) => {\n\t\t\tserializableMapData[key] = makeSerializable(localValue, serializer, this.handle);\n\t\t});\n\t\treturn serializableMapData;\n\t}\n\n\tpublic serialize(serializer: IFluidSerializer): string {\n\t\treturn JSON.stringify(this.getSerializableStorage(serializer));\n\t}\n\n\t/**\n\t * Populate the kernel with the given map data.\n\t * @param data - A JSON string containing serialized map data\n\t */\n\tpublic populateFromSerializable(json: IMapDataObjectSerializable): void {\n\t\tfor (const [key, serializable] of Object.entries(json)) {\n\t\t\t// Back-compat: legacy documents may have handles to an intervalCollection map kernel.\n\t\t\t// These collections should be empty, and ValueTypes are no longer supported.\n\t\t\tif (\n\t\t\t\tserializable.type === ValueType[ValueType.Plain] ||\n\t\t\t\tserializable.type === ValueType[ValueType.Shared]\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Back-compat: Sequence previously arbitrarily prefixed all interval collection keys with\n\t\t\t// \"intervalCollections/\". This would burden users trying to iterate the collection and\n\t\t\t// access its value, as well as those trying to match a create message to its underlying\n\t\t\t// collection. See https://github.com/microsoft/FluidFramework/issues/10557 for more context.\n\t\t\tconst normalizedKey = key.startsWith(\"intervalCollections/\") ? key.substring(20) : key;\n\n\t\t\tconst localValue = {\n\t\t\t\tkey: normalizedKey,\n\t\t\t\tvalue: this.makeLocal(key, serializable),\n\t\t\t};\n\n\t\t\tthis.data.set(localValue.key, localValue.value);\n\t\t}\n\t}\n\n\tpublic populate(json: string): void {\n\t\tthis.populateFromSerializable(JSON.parse(json) as IMapDataObjectSerializable);\n\t}\n\n\t/**\n\t * Submit the given op if a handler is registered.\n\t * @param op - The operation to attempt to submit\n\t * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t * @returns True if the operation was submitted, false otherwise.\n\t */\n\tpublic tryResubmitMessage(op: any, localOpMetadata: IMapMessageLocalMetadata): boolean {\n\t\tconst type: string = op.type;\n\t\tconst handler = this.messageHandlers.get(type);\n\t\tif (handler !== undefined) {\n\t\t\thandler.resubmit(op as IMapOperation, localOpMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic tryGetStashedOpLocalMetadata(op: any): unknown {\n\t\tconst type: string = op.type;\n\t\tif (this.messageHandlers.has(type)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op as IMapOperation);\n\t\t}\n\t\tthrow new Error(\"no apply stashed op handler\");\n\t}\n\n\t/**\n\t * Process the given op if a handler is registered.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation was processed, false otherwise.\n\t */\n\tpublic tryProcessMessage(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tconst handler = this.messageHandlers.get(op.type);\n\t\tif (handler !== undefined) {\n\t\t\thandler.process(op, local, message, localOpMetadata as IMapMessageLocalMetadata);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Initializes a default ValueType at the provided key.\n\t * Should be used when a map operation incurs creation.\n\t * @param key - The key being initialized\n\t * @param local - Whether the message originated from the local client\n\t */\n\tprivate createCore(key: string, local: boolean): ValueTypeLocalValue<T> {\n\t\tconst localValue = new ValueTypeLocalValue(\n\t\t\tthis.type.factory.load(this.makeMapValueOpEmitter(key), undefined),\n\t\t\tthis.type,\n\t\t);\n\t\tconst previousValue = this.data.get(key);\n\t\tthis.data.set(key, localValue);\n\t\tconst event: IValueChanged = { key, previousValue };\n\t\tthis.eventEmitter.emit(\"create\", event, local, this.eventEmitter);\n\t\treturn localValue;\n\t}\n\n\t/**\n\t * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will\n\t * have the information we need to create a real object, but will not be the real object yet. For example,\n\t * we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's\n\t * job is to convert that information into a real object for local usage.\n\t * @param key - The key that the caller intends to store the local value into (used for ops later). But\n\t * doesn't actually store the local value into that key. So better not lie!\n\t * @param serializable - The remote information that we can convert into a real object\n\t * @returns The local value that was produced\n\t */\n\tprivate makeLocal(key: string, serializable: ISerializableValue): ValueTypeLocalValue<T> {\n\t\tassert(\n\t\t\tserializable.type !== ValueType[ValueType.Plain] &&\n\t\t\t\tserializable.type !== ValueType[ValueType.Shared],\n\t\t\t0x2e1 /* \"Support for plain value types removed.\" */,\n\t\t);\n\n\t\tserializable.value = parseHandles(serializable.value, this.serializer);\n\t\tconst localValue = this.type.factory.load(\n\t\t\tthis.makeMapValueOpEmitter(key),\n\t\t\tserializable.value,\n\t\t);\n\t\treturn new ValueTypeLocalValue(localValue, this.type);\n\t}\n\n\t/**\n\t * Get the message handlers for the map.\n\t * @returns A map of string op names to IMapMessageHandlers for those ops\n\t */\n\tprivate getMessageHandlers() {\n\t\tconst messageHandlers = new Map<string, IMapMessageHandler>();\n\t\t// Ops with type \"act\" describe actions taken by custom value type handlers of whatever item is\n\t\t// being addressed. These custom handlers can be retrieved from the ValueTypeLocalValue which has\n\t\t// stashed its valueType (and therefore its handlers). We also emit a valueChanged for anyone\n\t\t// watching for manipulations of that item.\n\t\tmessageHandlers.set(\"act\", {\n\t\t\tprocess: (op: IMapValueTypeOperation, local, message, localOpMetadata) => {\n\t\t\t\tconst localValue = this.data.get(op.key) ?? this.createCore(op.key, local);\n\t\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\t\tconst previousValue = localValue.value;\n\t\t\t\tconst translatedValue = parseHandles(op.value.value, this.serializer);\n\t\t\t\thandler.process(previousValue, translatedValue, local, message, localOpMetadata);\n\t\t\t\tconst event: IValueChanged = { key: op.key, previousValue };\n\t\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, local, message, this.eventEmitter);\n\t\t\t},\n\t\t\tsubmit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t\t},\n\t\t\tresubmit: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => {\n\t\t\t\tconst localValue = this.data.get(op.key);\n\n\t\t\t\tassert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);\n\n\t\t\t\tconst handler = localValue.getOpHandler(op.value.opName);\n\t\t\t\tconst { rebasedOp, rebasedLocalOpMetadata } = handler.rebase(\n\t\t\t\t\tlocalValue.value,\n\t\t\t\t\top.value,\n\t\t\t\t\tlocalOpMetadata,\n\t\t\t\t);\n\t\t\t\tthis.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);\n\t\t\t},\n\t\t\tgetStashedOpLocalMetadata: (op: IMapValueTypeOperation) => {\n\t\t\t\tassert(\n\t\t\t\t\tfalse,\n\t\t\t\t\t0x016 /* \"apply stashed op not implemented for custom value type ops\" */,\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\treturn messageHandlers;\n\t}\n\n\t/**\n\t * Create an emitter for a value type to emit ops from the given key.\n\t * @alpha\n\t * @param key - The key of the map that the value type will be stored on\n\t * @returns A value op emitter for the given key\n\t */\n\tprivate makeMapValueOpEmitter(key: string): IValueOpEmitter {\n\t\tconst emit = (\n\t\t\topName: string,\n\t\t\tpreviousValue: any,\n\t\t\tparams: any,\n\t\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t\t) => {\n\t\t\tconst translatedParams = makeHandlesSerializable(params, this.serializer, this.handle);\n\n\t\t\tconst op: IMapValueTypeOperation = {\n\t\t\t\tkey,\n\t\t\t\ttype: \"act\",\n\t\t\t\tvalue: {\n\t\t\t\t\topName,\n\t\t\t\t\tvalue: translatedParams,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tthis.submitMessage(op, localOpMetadata);\n\n\t\t\tconst event: IValueChanged = { key, previousValue };\n\t\t\tthis.eventEmitter.emit(\"valueChanged\", event, true, null, this.eventEmitter);\n\t\t};\n\n\t\treturn { emit };\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultMapInterfaces.d.ts","sourceRoot":"","sources":["../src/defaultMapInterfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,aAAa,EAAE,GAAG,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,wBAAwB,GAAG,IAAI,CAAC;CAC1G;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC5B;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;IAE5C;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,EAAE,C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E,CAAC,EACR,EAAE,EAAE,wBAAwB,EAC5B,eAAe,EAAE,wBAAwB,GACvC;QAAE,SAAS,EAAE,wBAAwB,CAAC;QAAC,sBAAsB,EAAE,wBAAwB,CAAA;KAAE,CAAC;CAC7F;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC5B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE1B;;;OAGG;IACH,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IACnE,CACC,KAAK,EAAE,cAAc,GAAG,QAAQ,EAChC,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,qBAAqB,KAAK,IAAI,OACxF;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC;CACX;AAED,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC;CACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultMapInterfaces.js","sourceRoot":"","sources":["../src/defaultMapInterfaces.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 { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { IEventThisPlaceHolder } from \"@fluidframework/common-definitions\";\n\n/**\n * Type of \"valueChanged\" event parameter.\n */\nexport interface IValueChanged {\n /**\n * The key storing the value that changed.\n */\n key: string;\n\n /**\n * The value that was stored at the key prior to the change.\n */\n previousValue: any;\n}\n\n/**\n * Value types are given an IValueOpEmitter to emit their ops through the container type that holds them.\n * @internal\n */\nexport interface IValueOpEmitter {\n /**\n * Called by the value type to emit a value type operation through the container type holding it.\n * @param opName - Name of the emitted operation\n * @param previousValue - JSONable previous value as defined by the value type\n * @param params - JSONable params for the operation as defined by the value type\n * @param localOpMetadata - JSONable local metadata which should be submitted with the op\n * @internal\n */\n emit(opName: string, previousValue: any, params: any, localOpMetadata: IMapMessageLocalMetadata): void;\n}\n\n/**\n * @internal\n */\nexport interface IMapMessageLocalMetadata {\n localSeq: number;\n}\n\n/**\n * A value factory is used to serialize/deserialize value types to a map\n * @alpha\n */\nexport interface IValueFactory<T> {\n /**\n * Create a new value type. Used both in creation of new value types, as well as in loading existing ones\n * from remote.\n * @param emitter - Emitter object that the created value type will use to emit operations\n * @param raw - Initialization parameters as defined by the value type\n * @returns The new value type\n * @alpha\n */\n load(emitter: IValueOpEmitter, raw: any): T;\n\n /**\n * Given a value type, provides a JSONable form of its data to be used for snapshotting. This data must be\n * loadable using the load method of its factory.\n * @param value - The value type to serialize\n * @returns The JSONable form of the value type\n * @alpha\n */\n store(value: T): any;\n}\n\n/**\n * Defines an operation that a value type is able to handle.\n * @alpha\n */\nexport interface IValueOperation<T> {\n /**\n * Performs the actual processing on the incoming operation.\n * @param value - The current value stored at the given key, which should be the value type\n * @param params - The params on the incoming operation\n * @param local - Whether the operation originated from this client\n * @param message - The operation itself\n * @param localOpMetadata - any local metadata submitted by `IValueOpEmitter.emit`.\n * @alpha\n */\n process(\n value: T,\n params: any,\n local: boolean,\n message: ISequencedDocumentMessage | undefined,\n localOpMetadata: IMapMessageLocalMetadata | undefined\n );\n\n /**\n * Rebases an `op` on `value` from its original perspective (ref/local seq) to the current\n * perspective. Should be invoked on reconnection.\n * @param value - The current value stored at the given key, which should be the value type.\n * @param op - The op to be rebased.\n * @param localOpMetadata - Any local metadata that was originally submitted with the op.\n * @returns A rebased version of the op and any local metadata that should be submitted with it.\n */\n rebase(\n value: T,\n op: IValueTypeOperationValue,\n localOpMetadata: IMapMessageLocalMetadata\n ): { rebasedOp: IValueTypeOperationValue; rebasedLocalOpMetadata: IMapMessageLocalMetadata; };\n}\n\n/**\n * Defines a value type that can be registered on a container type.\n */\nexport interface IValueType<T> {\n /**\n * Name of the value type.\n * @alpha\n */\n name: string;\n\n /**\n * Factory method used to convert to/from a JSON form of the type.\n * @alpha\n */\n factory: IValueFactory<T>;\n\n /**\n * Operations that can be applied to the value type.\n * @alpha\n */\n ops: Map<string, IValueOperation<T>>;\n}\n\nexport interface ISharedDefaultMapEvents extends ISharedObjectEvents {\n (event: \"valueChanged\" | \"create\", listener: (\n changed: IValueChanged,\n local: boolean,\n target: IEventThisPlaceHolder) => void);\n}\n\n/**\n * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use\n * ISerializableValue.type to understand whether they're storing a Plain JS object, a SharedObject, or a value type.\n * Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with\n * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to\n * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)\n * and ops (set).\n *\n * The DefaultMap impelmentation for sequence has been specialized to only support a single ValueType, which serializes\n * and deserializes via .store() and .load().\n */\nexport interface ISerializableValue {\n /**\n * A type annotation to help indicate how the value serializes.\n */\n type: string;\n\n /**\n * The JSONable representation of the value.\n */\n value: any;\n}\n\nexport interface ISerializedValue {\n /**\n * A type annotation to help indicate how the value serializes.\n */\n type: string;\n\n /**\n * String representation of the value.\n */\n value: string | undefined;\n}\n\n/**\n * ValueTypes handle ops slightly differently from SharedObjects or plain JS objects. Since the Map/Directory doesn't\n * know how to handle the ValueType's ops, those ops are instead passed along to the ValueType for processing.\n * IValueTypeOperationValue is that passed-along op. The opName on it is the ValueType-specific operation and the\n * value is whatever params the ValueType needs to complete that operation. Similar to ISerializableValue, it is\n * serializable via JSON.stringify/parse but differs in that it has no equivalency with an in-memory value - rather\n * it just describes an operation to be applied to an already-in-memory value.\n * @alpha\n */\nexport interface IValueTypeOperationValue {\n /**\n * The name of the operation.\n */\n opName: string;\n\n /**\n * The payload that is submitted along with the operation.\n */\n value: any;\n}\n"]}
1
+ {"version":3,"file":"defaultMapInterfaces.js","sourceRoot":"","sources":["../src/defaultMapInterfaces.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 { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { IEventThisPlaceHolder } from \"@fluidframework/common-definitions\";\n\n/**\n * Type of \"valueChanged\" event parameter.\n */\nexport interface IValueChanged {\n\t/**\n\t * The key storing the value that changed.\n\t */\n\tkey: string;\n\n\t/**\n\t * The value that was stored at the key prior to the change.\n\t */\n\tpreviousValue: any;\n}\n\n/**\n * Value types are given an IValueOpEmitter to emit their ops through the container type that holds them.\n * @internal\n */\nexport interface IValueOpEmitter {\n\t/**\n\t * Called by the value type to emit a value type operation through the container type holding it.\n\t * @param opName - Name of the emitted operation\n\t * @param previousValue - JSONable previous value as defined by the value type\n\t * @param params - JSONable params for the operation as defined by the value type\n\t * @param localOpMetadata - JSONable local metadata which should be submitted with the op\n\t * @internal\n\t */\n\temit(\n\t\topName: string,\n\t\tpreviousValue: any,\n\t\tparams: any,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t): void;\n}\n\n/**\n * @internal\n */\nexport interface IMapMessageLocalMetadata {\n\tlocalSeq: number;\n}\n\n/**\n * A value factory is used to serialize/deserialize value types to a map\n * @alpha\n */\nexport interface IValueFactory<T> {\n\t/**\n\t * Create a new value type. Used both in creation of new value types, as well as in loading existing ones\n\t * from remote.\n\t * @param emitter - Emitter object that the created value type will use to emit operations\n\t * @param raw - Initialization parameters as defined by the value type\n\t * @returns The new value type\n\t * @alpha\n\t */\n\tload(emitter: IValueOpEmitter, raw: any): T;\n\n\t/**\n\t * Given a value type, provides a JSONable form of its data to be used for snapshotting. This data must be\n\t * loadable using the load method of its factory.\n\t * @param value - The value type to serialize\n\t * @returns The JSONable form of the value type\n\t * @alpha\n\t */\n\tstore(value: T): any;\n}\n\n/**\n * Defines an operation that a value type is able to handle.\n * @alpha\n */\nexport interface IValueOperation<T> {\n\t/**\n\t * Performs the actual processing on the incoming operation.\n\t * @param value - The current value stored at the given key, which should be the value type\n\t * @param params - The params on the incoming operation\n\t * @param local - Whether the operation originated from this client\n\t * @param message - The operation itself\n\t * @param localOpMetadata - any local metadata submitted by `IValueOpEmitter.emit`.\n\t * @alpha\n\t */\n\tprocess(\n\t\tvalue: T,\n\t\tparams: any,\n\t\tlocal: boolean,\n\t\tmessage: ISequencedDocumentMessage | undefined,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata | undefined,\n\t);\n\n\t/**\n\t * Rebases an `op` on `value` from its original perspective (ref/local seq) to the current\n\t * perspective. Should be invoked on reconnection.\n\t * @param value - The current value stored at the given key, which should be the value type.\n\t * @param op - The op to be rebased.\n\t * @param localOpMetadata - Any local metadata that was originally submitted with the op.\n\t * @returns A rebased version of the op and any local metadata that should be submitted with it.\n\t */\n\trebase(\n\t\tvalue: T,\n\t\top: IValueTypeOperationValue,\n\t\tlocalOpMetadata: IMapMessageLocalMetadata,\n\t): { rebasedOp: IValueTypeOperationValue; rebasedLocalOpMetadata: IMapMessageLocalMetadata };\n}\n\n/**\n * Defines a value type that can be registered on a container type.\n */\nexport interface IValueType<T> {\n\t/**\n\t * Name of the value type.\n\t * @alpha\n\t */\n\tname: string;\n\n\t/**\n\t * Factory method used to convert to/from a JSON form of the type.\n\t * @alpha\n\t */\n\tfactory: IValueFactory<T>;\n\n\t/**\n\t * Operations that can be applied to the value type.\n\t * @alpha\n\t */\n\tops: Map<string, IValueOperation<T>>;\n}\n\nexport interface ISharedDefaultMapEvents extends ISharedObjectEvents {\n\t(\n\t\tevent: \"valueChanged\" | \"create\",\n\t\tlistener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void,\n\t);\n}\n\n/**\n * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use\n * ISerializableValue.type to understand whether they're storing a Plain JS object, a SharedObject, or a value type.\n * Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with\n * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to\n * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)\n * and ops (set).\n *\n * The DefaultMap impelmentation for sequence has been specialized to only support a single ValueType, which serializes\n * and deserializes via .store() and .load().\n */\nexport interface ISerializableValue {\n\t/**\n\t * A type annotation to help indicate how the value serializes.\n\t */\n\ttype: string;\n\n\t/**\n\t * The JSONable representation of the value.\n\t */\n\tvalue: any;\n}\n\nexport interface ISerializedValue {\n\t/**\n\t * A type annotation to help indicate how the value serializes.\n\t */\n\ttype: string;\n\n\t/**\n\t * String representation of the value.\n\t */\n\tvalue: string | undefined;\n}\n\n/**\n * ValueTypes handle ops slightly differently from SharedObjects or plain JS objects. Since the Map/Directory doesn't\n * know how to handle the ValueType's ops, those ops are instead passed along to the ValueType for processing.\n * IValueTypeOperationValue is that passed-along op. The opName on it is the ValueType-specific operation and the\n * value is whatever params the ValueType needs to complete that operation. Similar to ISerializableValue, it is\n * serializable via JSON.stringify/parse but differs in that it has no equivalency with an in-memory value - rather\n * it just describes an operation to be applied to an already-in-memory value.\n * @alpha\n */\nexport interface IValueTypeOperationValue {\n\t/**\n\t * The name of the operation.\n\t */\n\topName: string;\n\n\t/**\n\t * The payload that is submitted along with the operation.\n\t */\n\tvalue: any;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -18,9 +18,9 @@ export { IMapMessageLocalMetadata, IValueOpEmitter } from "./defaultMapInterface
18
18
  export { DeserializeCallback, IIntervalCollectionEvent, IIntervalHelpers, Interval, IntervalCollection, IntervalCollectionIterator, IntervalLocator, intervalLocatorFromEndpoint, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, ISerializedIntervalCollectionV2, CompressedSerializedInterval, SerializedIntervalDelta, } from "./intervalCollection";
19
19
  export { IInterval, IntervalConflictResolver } from "./intervalTree";
20
20
  export { ISharedSegmentSequenceEvents, SharedSegmentSequence } from "./sequence";
21
- export { ISequenceDeltaRange, SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent } from "./sequenceDeltaEvent";
21
+ export { ISequenceDeltaRange, SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent, } from "./sequenceDeltaEvent";
22
22
  export { SharedStringFactory } from "./sequenceFactory";
23
- export { getTextAndMarkers, ISharedString, SharedString, SharedStringSegment } from "./sharedString";
23
+ export { getTextAndMarkers, ISharedString, SharedString, SharedStringSegment, } from "./sharedString";
24
24
  export { ISharedIntervalCollection, SharedIntervalCollection, SharedIntervalCollectionFactory, } from "./sharedIntervalCollection";
25
25
  export { IJSONRunSegment, SharedSequence, SubSequence } from "./sharedSequence";
26
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EACH,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,+BAA+B,EAC/B,4BAA4B,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BAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,yBAAyB,EACzB,wBAAwB,EACxB,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
package/lib/index.js CHANGED
@@ -4,9 +4,9 @@
4
4
  */
5
5
  export { Interval, IntervalCollection, IntervalCollectionIterator, intervalLocatorFromEndpoint, IntervalType, SequenceInterval, } from "./intervalCollection";
6
6
  export { SharedSegmentSequence } from "./sequence";
7
- export { SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent } from "./sequenceDeltaEvent";
7
+ export { SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent, } from "./sequenceDeltaEvent";
8
8
  export { SharedStringFactory } from "./sequenceFactory";
9
- export { getTextAndMarkers, SharedString } from "./sharedString";
9
+ export { getTextAndMarkers, SharedString, } from "./sharedString";
10
10
  export { SharedIntervalCollection, SharedIntervalCollectionFactory, } from "./sharedIntervalCollection";
11
11
  export { SharedSequence, SubSequence } from "./sharedSequence";
12
12
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAIH,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAE1B,2BAA2B,EAC3B,YAAY,EAGZ,gBAAgB,GAInB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAgC,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAuB,kBAAkB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAiB,YAAY,EAAuB,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAEN,wBAAwB,EACxB,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAmB,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Supports distributed data structures which are list-like.\n *\n * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of\n * text.\n *\n * See the package's README for a high-level introduction to `SharedString`'s feature set.\n * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for\n * working with text.\n *\n * @packageDocumentation\n */\nexport { IMapMessageLocalMetadata, IValueOpEmitter } from \"./defaultMapInterfaces\";\nexport {\n DeserializeCallback,\n IIntervalCollectionEvent,\n IIntervalHelpers,\n Interval,\n IntervalCollection,\n IntervalCollectionIterator,\n IntervalLocator,\n intervalLocatorFromEndpoint,\n IntervalType,\n ISerializableInterval,\n ISerializedInterval,\n SequenceInterval,\n ISerializedIntervalCollectionV2,\n CompressedSerializedInterval,\n SerializedIntervalDelta,\n} from \"./intervalCollection\";\nexport { IInterval, IntervalConflictResolver } from \"./intervalTree\";\nexport { ISharedSegmentSequenceEvents, SharedSegmentSequence } from \"./sequence\";\nexport { ISequenceDeltaRange, SequenceDeltaEvent, SequenceEvent, SequenceMaintenanceEvent } from \"./sequenceDeltaEvent\";\nexport { SharedStringFactory } from \"./sequenceFactory\";\nexport { getTextAndMarkers, ISharedString, SharedString, SharedStringSegment } from \"./sharedString\";\nexport {\n\tISharedIntervalCollection,\n\tSharedIntervalCollection,\n\tSharedIntervalCollectionFactory,\n} from \"./sharedIntervalCollection\";\nexport { IJSONRunSegment, SharedSequence, SubSequence } from \"./sharedSequence\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAIN,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAE1B,2BAA2B,EAC3B,YAAY,EAGZ,gBAAgB,GAIhB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAgC,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAEN,kBAAkB,EAClB,aAAa,EACb,wBAAwB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EACN,iBAAiB,EAEjB,YAAY,GAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEN,wBAAwB,EACxB,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAmB,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Supports distributed data structures which are list-like.\n *\n * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of\n * text.\n *\n * See the package's README for a high-level introduction to `SharedString`'s feature set.\n * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for\n * working with text.\n *\n * @packageDocumentation\n */\nexport { IMapMessageLocalMetadata, IValueOpEmitter } from \"./defaultMapInterfaces\";\nexport {\n\tDeserializeCallback,\n\tIIntervalCollectionEvent,\n\tIIntervalHelpers,\n\tInterval,\n\tIntervalCollection,\n\tIntervalCollectionIterator,\n\tIntervalLocator,\n\tintervalLocatorFromEndpoint,\n\tIntervalType,\n\tISerializableInterval,\n\tISerializedInterval,\n\tSequenceInterval,\n\tISerializedIntervalCollectionV2,\n\tCompressedSerializedInterval,\n\tSerializedIntervalDelta,\n} from \"./intervalCollection\";\nexport { IInterval, IntervalConflictResolver } from \"./intervalTree\";\nexport { ISharedSegmentSequenceEvents, SharedSegmentSequence } from \"./sequence\";\nexport {\n\tISequenceDeltaRange,\n\tSequenceDeltaEvent,\n\tSequenceEvent,\n\tSequenceMaintenanceEvent,\n} from \"./sequenceDeltaEvent\";\nexport { SharedStringFactory } from \"./sequenceFactory\";\nexport {\n\tgetTextAndMarkers,\n\tISharedString,\n\tSharedString,\n\tSharedStringSegment,\n} from \"./sharedString\";\nexport {\n\tISharedIntervalCollection,\n\tSharedIntervalCollection,\n\tSharedIntervalCollectionFactory,\n} from \"./sharedIntervalCollection\";\nexport { IJSONRunSegment, SharedSequence, SubSequence } from \"./sharedSequence\";\n"]}