@fluidframework/legacy-dds 2.53.1 → 2.61.0-355054
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.cjs +1 -2
- package/CHANGELOG.md +4 -0
- package/api-report/{legacy-dds.legacy.alpha.api.md → legacy-dds.legacy.beta.api.md} +20 -20
- package/dist/array/interfaces.d.ts +4 -8
- package/dist/array/interfaces.d.ts.map +1 -1
- package/dist/array/interfaces.js.map +1 -1
- package/dist/array/sharedArray.d.ts +8 -0
- package/dist/array/sharedArray.d.ts.map +1 -1
- package/dist/array/sharedArray.js +131 -8
- package/dist/array/sharedArray.js.map +1 -1
- package/dist/array/sharedArrayFactory.d.ts +2 -4
- package/dist/array/sharedArrayFactory.d.ts.map +1 -1
- package/dist/array/sharedArrayFactory.js +2 -4
- package/dist/array/sharedArrayFactory.js.map +1 -1
- package/dist/array/sharedArrayOperations.d.ts +9 -18
- package/dist/array/sharedArrayOperations.d.ts.map +1 -1
- package/dist/array/sharedArrayOperations.js +1 -2
- package/dist/array/sharedArrayOperations.js.map +1 -1
- package/dist/legacy.d.ts +2 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/signal/interfaces.d.ts +3 -6
- package/dist/signal/interfaces.d.ts.map +1 -1
- package/dist/signal/interfaces.js.map +1 -1
- package/dist/signal/sharedSignal.d.ts +1 -0
- package/dist/signal/sharedSignal.d.ts.map +1 -1
- package/dist/signal/sharedSignal.js +23 -9
- package/dist/signal/sharedSignal.js.map +1 -1
- package/dist/signal/sharedSignalFactory.d.ts +1 -2
- package/dist/signal/sharedSignalFactory.d.ts.map +1 -1
- package/dist/signal/sharedSignalFactory.js +1 -2
- package/dist/signal/sharedSignalFactory.js.map +1 -1
- package/internal.d.ts +1 -1
- package/legacy.d.ts +1 -1
- package/lib/array/interfaces.d.ts +4 -8
- package/lib/array/interfaces.d.ts.map +1 -1
- package/lib/array/interfaces.js.map +1 -1
- package/lib/array/sharedArray.d.ts +8 -0
- package/lib/array/sharedArray.d.ts.map +1 -1
- package/lib/array/sharedArray.js +131 -8
- package/lib/array/sharedArray.js.map +1 -1
- package/lib/array/sharedArrayFactory.d.ts +2 -4
- package/lib/array/sharedArrayFactory.d.ts.map +1 -1
- package/lib/array/sharedArrayFactory.js +2 -4
- package/lib/array/sharedArrayFactory.js.map +1 -1
- package/lib/array/sharedArrayOperations.d.ts +9 -18
- package/lib/array/sharedArrayOperations.d.ts.map +1 -1
- package/lib/array/sharedArrayOperations.js +1 -2
- package/lib/array/sharedArrayOperations.js.map +1 -1
- package/lib/legacy.d.ts +2 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/signal/interfaces.d.ts +3 -6
- package/lib/signal/interfaces.d.ts.map +1 -1
- package/lib/signal/interfaces.js.map +1 -1
- package/lib/signal/sharedSignal.d.ts +1 -0
- package/lib/signal/sharedSignal.d.ts.map +1 -1
- package/lib/signal/sharedSignal.js +15 -1
- package/lib/signal/sharedSignal.js.map +1 -1
- package/lib/signal/sharedSignalFactory.d.ts +1 -2
- package/lib/signal/sharedSignalFactory.d.ts.map +1 -1
- package/lib/signal/sharedSignalFactory.js +1 -2
- package/lib/signal/sharedSignalFactory.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +24 -24
- package/src/array/interfaces.ts +4 -8
- package/src/array/sharedArray.ts +146 -10
- package/src/array/sharedArrayFactory.ts +2 -4
- package/src/array/sharedArrayOperations.ts +9 -18
- package/src/packageVersion.ts +1 -1
- package/src/signal/interfaces.ts +3 -6
- package/src/signal/sharedSignal.ts +16 -2
- package/src/signal/sharedSignalFactory.ts +1 -2
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.SharedSignalClass = void 0;
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
9
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
10
|
+
const internal_2 = require("@fluidframework/driver-definitions/internal");
|
|
11
|
+
const internal_3 = require("@fluidframework/runtime-utils/internal");
|
|
12
|
+
const internal_4 = require("@fluidframework/shared-object-base/internal");
|
|
11
13
|
const sharedSignalFactory_js_1 = require("./sharedSignalFactory.js");
|
|
12
14
|
const snapshotFileName = "header";
|
|
13
15
|
/**
|
|
@@ -15,7 +17,7 @@ const snapshotFileName = "header";
|
|
|
15
17
|
*
|
|
16
18
|
* @internal
|
|
17
19
|
*/
|
|
18
|
-
class SharedSignalClass extends
|
|
20
|
+
class SharedSignalClass extends internal_4.SharedObject {
|
|
19
21
|
/**
|
|
20
22
|
* Create a new shared signal
|
|
21
23
|
*
|
|
@@ -63,9 +65,9 @@ class SharedSignalClass extends internal_3.SharedObject {
|
|
|
63
65
|
const tree = {
|
|
64
66
|
entries: [
|
|
65
67
|
{
|
|
66
|
-
mode:
|
|
68
|
+
mode: internal_2.FileMode.File,
|
|
67
69
|
path: snapshotFileName,
|
|
68
|
-
type:
|
|
70
|
+
type: internal_2.TreeEntry[internal_2.TreeEntry.Blob],
|
|
69
71
|
value: {
|
|
70
72
|
contents: JSON.stringify(""),
|
|
71
73
|
// eslint-disable-next-line unicorn/text-encoding-identifier-case
|
|
@@ -74,7 +76,7 @@ class SharedSignalClass extends internal_3.SharedObject {
|
|
|
74
76
|
},
|
|
75
77
|
],
|
|
76
78
|
};
|
|
77
|
-
const summaryTreeWithStats = (0,
|
|
79
|
+
const summaryTreeWithStats = (0, internal_3.convertToSummaryTreeWithStats)(tree);
|
|
78
80
|
return summaryTreeWithStats;
|
|
79
81
|
}
|
|
80
82
|
/**
|
|
@@ -98,7 +100,7 @@ class SharedSignalClass extends internal_3.SharedObject {
|
|
|
98
100
|
* For messages from a remote client, this will be undefined.
|
|
99
101
|
*/
|
|
100
102
|
processCore(message, local, _localOpMetadata) {
|
|
101
|
-
if (message.type ===
|
|
103
|
+
if (message.type === internal_2.MessageType.Operation && !local) {
|
|
102
104
|
const op = message.contents;
|
|
103
105
|
switch (op.type) {
|
|
104
106
|
case "signal": {
|
|
@@ -114,8 +116,20 @@ class SharedSignalClass extends internal_3.SharedObject {
|
|
|
114
116
|
notifyCore(op, isLocal) {
|
|
115
117
|
this.emit("notify", op.metadata, isLocal);
|
|
116
118
|
}
|
|
119
|
+
// Nothing to roll back. Allowing other DDSs to handle rollback if necessary.
|
|
120
|
+
rollback(content, _localOpMetadata) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
117
123
|
applyStashedOp(_content) {
|
|
118
|
-
|
|
124
|
+
const op = _content;
|
|
125
|
+
switch (op.type) {
|
|
126
|
+
case "signal": {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
default: {
|
|
130
|
+
(0, internal_1.unreachableCase)(op);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
119
133
|
}
|
|
120
134
|
}
|
|
121
135
|
exports.SharedSignalClass = SharedSignalClass;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSignal.js","sourceRoot":"","sources":["../../src/signal/sharedSignal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"sharedSignal.js","sourceRoot":"","sources":["../../src/signal/sharedSignal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAuD;AACvD,kEAAsE;AAOtE,0EAA+F;AAM/F,qEAAuF;AAEvF,0EAA2E;AAQ3E,qEAA+D;AAE/D,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;GAIG;AACH,MAAa,iBACZ,SAAQ,uBAAoC;IAG5C;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EA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ACO,YAAY,KAAU,CAAC;IAEjC;;;;;;;OAOG;IACO,WAAW,CACpB,OAAkC,EAClC,KAAc,EACd,gBAAyB;QAEzB,IAAK,OAAO,CAAC,IAAoB,KAAK,sBAAW,CAAC,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC;YACvE,MAAM,EAAE,GAAG,OAAO,CAAC,QAA+B,CAAC;YAEnD,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;gBACjB,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACf,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;oBAC3B,MAAM;gBACP,CAAC;gBAED,OAAO,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;gBACtC,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAEO,UAAU,CAAC,EAAuB,EAAE,OAAgB;QAC3D,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,6EAA6E;IACtE,QAAQ,CAAC,OAAgB,EAAE,gBAAyB;QAC1D,OAAO;IACR,CAAC;IAES,cAAc,CAAC,QAAiB;QACzC,MAAM,EAAE,GAAG,QAA+B,CAAC;QAE3C,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;YACjB,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACf,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,IAAA,0BAAe,EAAC,EAAW,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAhJD,8CAgJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISequencedDocumentMessage,\n\tITree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { convertToSummaryTreeWithStats } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport type {\n\tISharedSignal,\n\tISharedSignalEvents,\n\tISignalOperation,\n\tSerializableTypeForSharedSignal,\n} from \"./interfaces.js\";\nimport { SharedSignalFactory } from \"./sharedSignalFactory.js\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * Represents a shared signal that allows communication between distributed clients.\n *\n * @internal\n */\nexport class SharedSignalClass<T extends SerializableTypeForSharedSignal = any>\n\textends SharedObject<ISharedSignalEvents<T>>\n\timplements ISharedSignal<T>\n{\n\t/**\n\t * Create a new shared signal\n\t *\n\t * @param runtime - data store runtime the new shared signal belongs to\n\t * @param id - optional name of the shared signal\n\t * @returns newly create shared signal (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedSignalClass {\n\t\treturn runtime.createChannel(id, SharedSignalFactory.Type) as SharedSignalClass;\n\t}\n\n\t/**\n\t * Get a factory for SharedSignal to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedSignal\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new SharedSignalFactory();\n\t}\n\n\t/**\n\t * Constructs a new shared signal. If the object is non-local an id and service interfaces will\n\t * be provided\n\t * @param id - optional name of the shared signal\n\t * @param runtime - data store runtime the shared signal belongs to\n\t * @param attributes - represents the attributes of a channel/DDS.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"loop_sharedSignal_\" /* telemetryContextPrefix */);\n\t}\n\n\t/**\n\t * Method used for generating a signal.\n\t */\n\tpublic notify(metadata?: T): void {\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: ISignalOperation<T> = {\n\t\t\ttype: \"signal\",\n\t\t\tmetadata,\n\t\t};\n\n\t\tthis.notifyCore(op, true);\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tprotected summarizeCore(_serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst tree: ITree = {\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tmode: FileMode.File,\n\t\t\t\t\tpath: snapshotFileName,\n\t\t\t\t\ttype: TreeEntry[TreeEntry.Blob],\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontents: JSON.stringify(\"\"),\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tconst summaryTreeWithStats = convertToSummaryTreeWithStats(tree);\n\n\t\treturn summaryTreeWithStats;\n\t}\n\n\t/**\n\t * Load share signal from snapshot\n\t *\n\t * @param _storage - the storage to get the snapshot from\n\t * @returns - promise that resolved when the load is completed\n\t */\n\tprotected async loadCore(_storage: IChannelStorageService): Promise<void> {}\n\n\tprotected override initializeLocalCore(): void {}\n\n\t/**\n\t * Callback on disconnect\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Process a shared signal operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by 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 */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\t_localOpMetadata: unknown,\n\t): void {\n\t\tif ((message.type as MessageType) === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as ISignalOperation<T>;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"signal\": {\n\t\t\t\t\tthis.notifyCore(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate notifyCore(op: ISignalOperation<T>, isLocal: boolean): void {\n\t\tthis.emit(\"notify\", op.metadata, isLocal);\n\t}\n\n\t// Nothing to roll back. Allowing other DDSs to handle rollback if necessary.\n\tpublic rollback(content: unknown, _localOpMetadata: unknown): void {\n\t\treturn;\n\t}\n\n\tprotected applyStashedOp(_content: unknown): void {\n\t\tconst op = _content as ISignalOperation<T>;\n\n\t\tswitch (op.type) {\n\t\t\tcase \"signal\": {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(op as never);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -17,8 +17,7 @@ export declare class SharedSignalFactory implements IChannelFactory<ISharedSigna
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Entrypoint for {@link ISharedSignal} creation.
|
|
20
|
-
* @legacy
|
|
21
|
-
* @alpha
|
|
20
|
+
* @legacy @beta
|
|
22
21
|
*/
|
|
23
22
|
export declare const SharedSignal: import("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedSignal<any>> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedSignal<any>>;
|
|
24
23
|
//# sourceMappingURL=sharedSignalFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSignalFactory.d.ts","sourceRoot":"","sources":["../../src/signal/sharedSignalFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,eAAe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sB,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa;CAK1E;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,0LAA6D,CAAC"}
|
|
@@ -38,8 +38,7 @@ SharedSignalFactory.Attributes = {
|
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
40
|
* Entrypoint for {@link ISharedSignal} creation.
|
|
41
|
-
* @legacy
|
|
42
|
-
* @alpha
|
|
41
|
+
* @legacy @beta
|
|
43
42
|
*/
|
|
44
43
|
exports.SharedSignal = (0, internal_1.createSharedObjectKind)(SharedSignalFactory);
|
|
45
44
|
//# sourceMappingURL=sharedSignalFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSignalFactory.js","sourceRoot":"","sources":["../../src/signal/sharedSignalFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,0EAAqF;AAErF,4DAAkD;AAGlD,uDAAsD;AAEtD;;GAEG;AACH,MAAa,mBAAmB;IAS/B,IAAW,IAAI;QACd,OAAO,mBAAmB,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,mBAAmB,CAAC,UAAU,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,mCAAiB,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC9D,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,MAAM,GAAG,IAAI,mCAAiB,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,CAAC,eAAe,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC;IACf,CAAC;;AAhCF,kDAiCC;AAhCuB,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yright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelFactory,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { createSharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { pkgVersion } from \"../packageVersion.js\";\n\nimport type { ISharedSignal } from \"./interfaces.js\";\nimport { SharedSignalClass } from \"./sharedSignal.js\";\n\n/**\n * @internal\n */\nexport class SharedSignalFactory implements IChannelFactory<ISharedSignal> {\n\tpublic static readonly Type: string = \"https://graph.microsoft.com/types/signal\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: SharedSignalFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn SharedSignalFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn SharedSignalFactory.Attributes;\n\t}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedSignal> {\n\t\tconst signal = new SharedSignalClass(id, runtime, attributes);\n\t\tawait signal.load(services);\n\t\treturn signal;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): ISharedSignal {\n\t\tconst signal = new SharedSignalClass(id, document, this.attributes);\n\t\tsignal.initializeLocal();\n\t\treturn signal;\n\t}\n}\n\n/**\n * Entrypoint for {@link ISharedSignal} creation.\n * @legacy @beta\n */\nexport const SharedSignal = createSharedObjectKind<ISharedSignal>(SharedSignalFactory);\n"]}
|
package/internal.d.ts
CHANGED
package/legacy.d.ts
CHANGED
|
@@ -11,16 +11,14 @@ import type { ISharedArrayOperation } from "./sharedArrayOperations.js";
|
|
|
11
11
|
* It can be used as a generic constraint (`extends SerializableTypeForSharedArray`) but is
|
|
12
12
|
* *never* meant to be a concrete/real type on its own.
|
|
13
13
|
*
|
|
14
|
-
* @legacy
|
|
15
|
-
* @alpha
|
|
14
|
+
* @legacy @beta
|
|
16
15
|
*/
|
|
17
16
|
export type SerializableTypeForSharedArray = boolean | number | string | object | IFluidHandle;
|
|
18
17
|
/**
|
|
19
18
|
* Interface defining the events that can be emitted by the SharedArray DDS
|
|
20
19
|
* and the events that can be listened to by the SharedArray DDS
|
|
21
20
|
*
|
|
22
|
-
* @legacy
|
|
23
|
-
* @alpha
|
|
21
|
+
* @legacy @beta
|
|
24
22
|
*/
|
|
25
23
|
export interface ISharedArrayEvents extends ISharedObjectEvents {
|
|
26
24
|
/**
|
|
@@ -47,8 +45,7 @@ export interface ISharedArrayEvents extends ISharedObjectEvents {
|
|
|
47
45
|
*
|
|
48
46
|
* @typeParam T - The type of the SharedArray
|
|
49
47
|
*
|
|
50
|
-
* @legacy
|
|
51
|
-
* @alpha
|
|
48
|
+
* @legacy @beta
|
|
52
49
|
*/
|
|
53
50
|
export interface ISharedArray<T extends SerializableTypeForSharedArray> extends ISharedObject<ISharedArrayEvents> {
|
|
54
51
|
get(): readonly T[];
|
|
@@ -132,8 +129,7 @@ export interface SnapshotFormat<T> {
|
|
|
132
129
|
dataArray: T[];
|
|
133
130
|
}
|
|
134
131
|
/**
|
|
135
|
-
* @legacy
|
|
136
|
-
* @alpha
|
|
132
|
+
* @legacy @beta
|
|
137
133
|
*/
|
|
138
134
|
export interface IRevertible {
|
|
139
135
|
revert(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/array/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,KAAK,EACX,mBAAmB,EACnB,aAAa,EACb,MAAM,6CA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;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;CAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/array/interfaces.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 type { IEventThisPlaceHolder, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { Serializable } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISharedObjectEvents,\n\tISharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedArrayOperation } from \"./sharedArrayOperations.js\";\n/**\n * Basic types for the SharedArray DDS\n * It can be used as a generic constraint (`extends SerializableTypeForSharedArray`) but is\n * *never* meant to be a concrete/real type on its own.\n *\n * @legacy
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/array/interfaces.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 type { IEventThisPlaceHolder, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { Serializable } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISharedObjectEvents,\n\tISharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedArrayOperation } from \"./sharedArrayOperations.js\";\n/**\n * Basic types for the SharedArray DDS\n * It can be used as a generic constraint (`extends SerializableTypeForSharedArray`) but is\n * *never* meant to be a concrete/real type on its own.\n *\n * @legacy @beta\n */\nexport type SerializableTypeForSharedArray = boolean | number | string | object | IFluidHandle;\n\n/**\n * Interface defining the events that can be emitted by the SharedArray DDS\n * and the events that can be listened to by the SharedArray DDS\n *\n * @legacy @beta\n */\nexport interface ISharedArrayEvents extends ISharedObjectEvents {\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(\n\t\tevent: \"valueChanged\",\n\t\tlistener: (\n\t\t\top: ISharedArrayOperation,\n\t\t\tisLocal: boolean,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t): void;\n\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"revertible\", listener: (revertible: IRevertible) => void): void;\n}\n\n/**\n * Interface defining the SharedArray DDS\n * It is a generic interface that can be used to create a SharedArray of any type\n * The type of the SharedArray is defined by the type parameter T\n *\n * @typeParam T - The type of the SharedArray\n *\n * @legacy @beta\n */\nexport interface ISharedArray<T extends SerializableTypeForSharedArray>\n\textends ISharedObject<ISharedArrayEvents> {\n\tget(): readonly T[];\n\tinsert<TWrite>(index: number, value: Serializable<TWrite> & T): void;\n\tdelete(index: number): void;\n\tmove(oldIndex: number, newIndex: number): void;\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n\tinsertBulkAfter<TWrite>(ref: T | undefined, values: (Serializable<TWrite> & T)[]): void;\n}\n\n/**\n *\n * @internal\n */\nexport interface ISharedArrayRevertible extends ISharedObject<ISharedArrayEvents> {\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n}\n\n/**\n * Interface defining the in memory shared array entry of the DDS\n *\n * @internal\n */\nexport interface SharedArrayEntry<T extends SerializableTypeForSharedArray>\n\textends SharedArrayEntryCore<T> {\n\t/**\n\t * Flag that tracks whether an ack from the server has been received for a local insert.\n\t * True for local changes.\n\t */\n\tisAckPending: boolean;\n\n\t/**\n\t * Counter is shared by delete and undo/redo (of delete and insert) as undo/redo simply\n\t * operates on the isDeleted flag of the DDS. This flag will help us skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping\n\t */\n\tisLocalPendingDelete: number;\n\n\t/**\n\t * Counter is for move and its undo/redo. This flag will be used to skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping. Only exception\n\t * being if there is a remote delete, we will have to respect that\n\t */\n\tisLocalPendingMove: number;\n}\n\n/**\n * Interface defining the core entry attributes\n *\n * @internal\n */\nexport interface SharedArrayEntryCore<T extends SerializableTypeForSharedArray> {\n\t/**\n\t * a unique ID for this particular entry\n\t */\n\tentryId: string;\n\n\t/**\n\t * the value stored in this entry, may not be unique\n\t */\n\tvalue: T;\n\n\t/**\n\t * Flag to track whether this entry is deleted or not.\n\t */\n\tisDeleted: boolean;\n\n\t/**\n\t * Primarily used for move op and tracks the old entry id from which this entry was changed from.\n\t */\n\tprevEntryId?: string;\n\n\t/**\n\t * Primarily used for move op and tracks the new entry id to which this entry was changed to.\n\t */\n\tnextEntryId?: string;\n}\n\n/**\n * Format of the snapshot for the DDS\n *\n * @internal\n */\nexport interface SnapshotFormat<T> {\n\t/**\n\t * Array of the data entries that represent the DDS in-memory representation\n\t */\n\tdataArray: T[];\n}\n\n/**\n * @legacy @beta\n */\nexport interface IRevertible {\n\trevert(): void;\n\tdispose(): void;\n}\n"]}
|
|
@@ -27,6 +27,12 @@ export declare class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
27
27
|
* handling for this data structure
|
|
28
28
|
*/
|
|
29
29
|
private readonly idToEntryMap;
|
|
30
|
+
/**
|
|
31
|
+
* Set of entry IDs that are marked for deletion by remote clients, but have local pending deletes.
|
|
32
|
+
* Used to prevent resuscitating entries while rolling back a delete operation.
|
|
33
|
+
* We should not rollback to life an entry that was deleted by remote clients.
|
|
34
|
+
*/
|
|
35
|
+
private readonly remoteDeleteWithLocalPendingDelete;
|
|
30
36
|
/**
|
|
31
37
|
* Create a new shared array
|
|
32
38
|
*
|
|
@@ -87,6 +93,7 @@ export declare class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
87
93
|
* @param newEntryId - EntryId of the to be live entry
|
|
88
94
|
*/
|
|
89
95
|
toggleMove(oldEntryId: string, newEntryId: string): void;
|
|
96
|
+
rollback(op: unknown, _localOpMetadata: unknown): void;
|
|
90
97
|
/**
|
|
91
98
|
* Load share array from snapshot
|
|
92
99
|
*
|
|
@@ -174,6 +181,7 @@ export declare class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
174
181
|
* existingEntry -\> deadeEntry(appended) -\> existing chain(if any).
|
|
175
182
|
*/
|
|
176
183
|
private updateDeadEntry;
|
|
184
|
+
private handleStashedInsert;
|
|
177
185
|
protected applyStashedOp(content: unknown): void;
|
|
178
186
|
}
|
|
179
187
|
//# sourceMappingURL=sharedArray.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedArray.d.ts","sourceRoot":"","sources":["../../src/array/sharedArray.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACX,yBAAyB,EAEzB,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAG3E,OAAO,KAAK,EACX,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,8BAA8B,EAI9B,MAAM,iBAAiB,CAAC;AAczB;;;;GAIG;AACH,qBAAa,gBAAgB,CAAC,CAAC,SAAS,8BAA8B,CACrE,SAAQ,YAAY,CAAC,kBAAkB,CACvC,YAAW,YAAY,CAAC,CAAC,CAAC,EAAE,sBAAsB;IAElD;;OAEG;IACH,OAAO,CAAC,WAAW,CAAwB;IAE3C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CAAC,QAAQ;IAahB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,eAAe;IAoBvB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAiBtB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,mDAAmD;IAgB3D,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,wBAAwB;IAiBhC;;;;;;;;;OASG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAevB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,mBAAmB;IAc3B,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CA6DhD"}
|
package/lib/array/sharedArray.js
CHANGED
|
@@ -45,6 +45,12 @@ export class SharedArrayClass extends SharedObject {
|
|
|
45
45
|
*/
|
|
46
46
|
constructor(id, runtime, attributes) {
|
|
47
47
|
super(id, runtime, attributes, "loop_sharedArray_" /* telemetryContextPrefix */);
|
|
48
|
+
/**
|
|
49
|
+
* Set of entry IDs that are marked for deletion by remote clients, but have local pending deletes.
|
|
50
|
+
* Used to prevent resuscitating entries while rolling back a delete operation.
|
|
51
|
+
* We should not rollback to life an entry that was deleted by remote clients.
|
|
52
|
+
*/
|
|
53
|
+
this.remoteDeleteWithLocalPendingDelete = new Set();
|
|
48
54
|
this.sharedArray = [];
|
|
49
55
|
this.idToEntryMap = new Map();
|
|
50
56
|
}
|
|
@@ -277,6 +283,91 @@ export class SharedArrayClass extends SharedObject {
|
|
|
277
283
|
}
|
|
278
284
|
this.submitLocalMessage(op);
|
|
279
285
|
}
|
|
286
|
+
rollback(op, _localOpMetadata) {
|
|
287
|
+
const arrayOp = op;
|
|
288
|
+
switch (arrayOp.type) {
|
|
289
|
+
case OperationType.insertEntry: {
|
|
290
|
+
const liveEntry = this.getLiveEntry(arrayOp.entryId);
|
|
291
|
+
liveEntry.isDeleted = true;
|
|
292
|
+
const deleteOp = {
|
|
293
|
+
type: OperationType.deleteEntry,
|
|
294
|
+
entryId: arrayOp.entryId,
|
|
295
|
+
};
|
|
296
|
+
this.emitValueChangedEvent(deleteOp, true /* isLocal */);
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
case OperationType.deleteEntry: {
|
|
300
|
+
if (this.remoteDeleteWithLocalPendingDelete.has(arrayOp.entryId)) {
|
|
301
|
+
// If remote already deleted the entry, we should not resurrect it.
|
|
302
|
+
// Just remove the local pending delete.
|
|
303
|
+
this.remoteDeleteWithLocalPendingDelete.delete(arrayOp.entryId);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
const liveEntry = this.getLiveEntry(arrayOp.entryId);
|
|
307
|
+
liveEntry.isDeleted = false;
|
|
308
|
+
const insertOp = {
|
|
309
|
+
type: OperationType.insertEntry,
|
|
310
|
+
entryId: arrayOp.entryId,
|
|
311
|
+
value: liveEntry.value,
|
|
312
|
+
};
|
|
313
|
+
this.emitValueChangedEvent(insertOp, true /* isLocal */);
|
|
314
|
+
const entry = this.getEntryForId(arrayOp.entryId);
|
|
315
|
+
if (entry !== undefined && entry.isLocalPendingDelete > 0) {
|
|
316
|
+
entry.isLocalPendingDelete -= 1;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
case OperationType.moveEntry: {
|
|
322
|
+
const { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;
|
|
323
|
+
if (this.getEntryForId(newEntryId).isDeleted) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
this.updateLiveEntry(newEntryId, oldEntryId);
|
|
327
|
+
const inputEntry = this.getEntryForId(oldEntryId);
|
|
328
|
+
inputEntry.prevEntryId = undefined;
|
|
329
|
+
inputEntry.nextEntryId = undefined;
|
|
330
|
+
inputEntry.isLocalPendingMove = 0;
|
|
331
|
+
const moveOp = {
|
|
332
|
+
type: OperationType.moveEntry,
|
|
333
|
+
entryId: newEntryId,
|
|
334
|
+
changedToEntryId: oldEntryId,
|
|
335
|
+
};
|
|
336
|
+
this.emitValueChangedEvent(moveOp, true /* isLocal */);
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
case OperationType.toggle: {
|
|
340
|
+
const entryId = arrayOp.entryId;
|
|
341
|
+
const liveEntry = this.getLiveEntry(entryId);
|
|
342
|
+
const isDeleted = liveEntry.isDeleted;
|
|
343
|
+
// Toggling the isDeleted flag to undo the last operation for the skip list payload/value
|
|
344
|
+
liveEntry.isDeleted = !isDeleted;
|
|
345
|
+
liveEntry.isLocalPendingDelete -= 1;
|
|
346
|
+
const toggleOp = {
|
|
347
|
+
type: OperationType.toggle,
|
|
348
|
+
entryId,
|
|
349
|
+
isDeleted: liveEntry.isDeleted,
|
|
350
|
+
};
|
|
351
|
+
this.emitValueChangedEvent(toggleOp, true /* isLocal */);
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
case OperationType.toggleMove: {
|
|
355
|
+
const { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;
|
|
356
|
+
this.getEntryForId(oldEntryId).isLocalPendingMove -= 1;
|
|
357
|
+
this.updateLiveEntry(oldEntryId, newEntryId);
|
|
358
|
+
const toggleMoveOp = {
|
|
359
|
+
type: OperationType.toggleMove,
|
|
360
|
+
entryId: newEntryId,
|
|
361
|
+
changedToEntryId: oldEntryId,
|
|
362
|
+
};
|
|
363
|
+
this.emitValueChangedEvent(toggleMoveOp, true /* isLocal */);
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
default: {
|
|
367
|
+
unreachableCase(arrayOp);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
280
371
|
/**
|
|
281
372
|
* Load share array from snapshot
|
|
282
373
|
*
|
|
@@ -401,10 +492,13 @@ export class SharedArrayClass extends SharedObject {
|
|
|
401
492
|
if (local) {
|
|
402
493
|
// Decrementing local pending counter as op is already applied to local state
|
|
403
494
|
opEntry.isLocalPendingDelete -= 1;
|
|
495
|
+
this.remoteDeleteWithLocalPendingDelete.delete(op.entryId);
|
|
404
496
|
}
|
|
405
497
|
else {
|
|
406
|
-
|
|
407
|
-
|
|
498
|
+
if (this.isLocalPending(op.entryId, "isLocalPendingDelete")) {
|
|
499
|
+
this.remoteDeleteWithLocalPendingDelete.add(op.entryId);
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
408
502
|
// last element in skip list is the most recent and live entry, so marking it deleted
|
|
409
503
|
this.getLiveEntry(op.entryId).isDeleted = true;
|
|
410
504
|
}
|
|
@@ -656,28 +750,57 @@ export class SharedArrayClass extends SharedObject {
|
|
|
656
750
|
deadEntry.prevEntryId = existingEntryId;
|
|
657
751
|
deadEntry.isDeleted = true;
|
|
658
752
|
}
|
|
753
|
+
handleStashedInsert(entryId, insertAfterEntryId, value) {
|
|
754
|
+
let index = 0;
|
|
755
|
+
if (insertAfterEntryId !== undefined) {
|
|
756
|
+
index = this.findIndexOfEntryId(insertAfterEntryId) + 1;
|
|
757
|
+
}
|
|
758
|
+
const newEntry = this.createNewEntry(entryId, value);
|
|
759
|
+
newEntry.isAckPending = true;
|
|
760
|
+
this.addEntry(index, newEntry);
|
|
761
|
+
}
|
|
659
762
|
applyStashedOp(content) {
|
|
660
763
|
const op = content;
|
|
661
764
|
switch (op.type) {
|
|
662
765
|
case OperationType.insertEntry: {
|
|
663
|
-
this.
|
|
664
|
-
op.value);
|
|
766
|
+
this.handleStashedInsert(op.entryId, op.insertAfterEntryId, op.value);
|
|
665
767
|
break;
|
|
666
768
|
}
|
|
667
769
|
case OperationType.deleteEntry: {
|
|
668
|
-
this.
|
|
770
|
+
this.getLiveEntry(op.entryId).isDeleted = true;
|
|
771
|
+
this.getEntryForId(op.entryId).isLocalPendingDelete += 1;
|
|
669
772
|
break;
|
|
670
773
|
}
|
|
671
774
|
case OperationType.moveEntry: {
|
|
672
|
-
this.
|
|
775
|
+
const opEntry = this.getEntryForId(op.entryId);
|
|
776
|
+
this.handleStashedInsert(op.changedToEntryId, op.insertAfterEntryId, opEntry.value);
|
|
777
|
+
const newElementEntryId = op.changedToEntryId;
|
|
778
|
+
const newElement = this.getEntryForId(newElementEntryId);
|
|
779
|
+
if (this.isLocalPending(op.entryId, "isLocalPendingDelete") ||
|
|
780
|
+
this.isLocalPending(op.entryId, "isLocalPendingMove")) {
|
|
781
|
+
this.updateDeadEntry(op.entryId, newElementEntryId);
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
// move the element
|
|
785
|
+
const liveEntry = this.getLiveEntry(op.entryId);
|
|
786
|
+
const isDeleted = liveEntry.isDeleted;
|
|
787
|
+
this.updateLiveEntry(liveEntry.entryId, newElementEntryId);
|
|
788
|
+
// mark newly added element as deleted if existing live element was already deleted
|
|
789
|
+
if (isDeleted) {
|
|
790
|
+
newElement.isDeleted = isDeleted;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
newElement.isLocalPendingMove += 1;
|
|
673
794
|
break;
|
|
674
795
|
}
|
|
675
796
|
case OperationType.toggle: {
|
|
676
|
-
this.
|
|
797
|
+
this.getLiveEntry(op.entryId).isDeleted = op.isDeleted;
|
|
798
|
+
this.getEntryForId(op.entryId).isLocalPendingDelete += 1;
|
|
677
799
|
break;
|
|
678
800
|
}
|
|
679
801
|
case OperationType.toggleMove: {
|
|
680
|
-
this.
|
|
802
|
+
this.updateLiveEntry(this.getLiveEntry(op.entryId).entryId, op.entryId);
|
|
803
|
+
this.getEntryForId(op.entryId).isLocalPendingMove += 1;
|
|
681
804
|
break;
|
|
682
805
|
}
|
|
683
806
|
default: {
|